mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
Make formatText util an object so it can be extended
This commit is contained in:
@@ -6,7 +6,7 @@ import PostEdited from 'flarum/components/PostEdited';
|
|||||||
import EditPostComposer from 'flarum/components/EditPostComposer';
|
import EditPostComposer from 'flarum/components/EditPostComposer';
|
||||||
import Composer from 'flarum/components/Composer';
|
import Composer from 'flarum/components/Composer';
|
||||||
import ItemList from 'flarum/utils/ItemList';
|
import ItemList from 'flarum/utils/ItemList';
|
||||||
import formatText from 'flarum/utils/formatText';
|
import Formatter from 'flarum/utils/Formatter';
|
||||||
import listItems from 'flarum/helpers/listItems';
|
import listItems from 'flarum/helpers/listItems';
|
||||||
import Button from 'flarum/components/Button';
|
import Button from 'flarum/components/Button';
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export default class CommentPost extends Post {
|
|||||||
|
|
||||||
content() {
|
content() {
|
||||||
const content = this.isEditing()
|
const content = this.isEditing()
|
||||||
? formatText(this.props.post.editedContent)
|
? Formatter.format(this.props.post.editedContent)
|
||||||
: this.props.post.contentHtml();
|
: this.props.post.contentHtml();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@@ -2,7 +2,7 @@ import Component from 'flarum/Component';
|
|||||||
import avatar from 'flarum/helpers/avatar';
|
import avatar from 'flarum/helpers/avatar';
|
||||||
import username from 'flarum/helpers/username';
|
import username from 'flarum/helpers/username';
|
||||||
import DiscussionControls from 'flarum/utils/DiscussionControls';
|
import DiscussionControls from 'flarum/utils/DiscussionControls';
|
||||||
import formatText from 'flarum/utils/formatText';
|
import Formatter from 'flarum/utils/Formatter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `ReplyPlaceholder` component displays a placeholder for a reply, which,
|
* The `ReplyPlaceholder` component displays a placeholder for a reply, which,
|
||||||
@@ -26,7 +26,7 @@ export default class ReplyPlaceholder extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="Post-body">
|
<div className="Post-body">
|
||||||
{m.trust(formatText(this.props.discussion.replyContent))}
|
{m.trust(Formatter.format(this.props.discussion.replyContent))}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
|
11
framework/core/js/forum/src/utils/Formatter.js
Normal file
11
framework/core/js/forum/src/utils/Formatter.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*global s9e*/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
format(text) {
|
||||||
|
const elm = document.createElement('div');
|
||||||
|
|
||||||
|
s9e.TextFormatter.preview(text || '', elm);
|
||||||
|
|
||||||
|
return elm.innerHTML;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +0,0 @@
|
|||||||
export default function formatText(text) {
|
|
||||||
const elm = document.createElement('div');
|
|
||||||
|
|
||||||
s9e.TextFormatter.preview(text || '', elm);
|
|
||||||
|
|
||||||
return elm.innerHTML;
|
|
||||||
}
|
|
Reference in New Issue
Block a user