mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 00:25:33 +08:00
Make formatText util an object so it can be extended
This commit is contained in:
parent
9cbb1aaf50
commit
01b225fd6d
|
@ -6,7 +6,7 @@ import PostEdited from 'flarum/components/PostEdited';
|
|||
import EditPostComposer from 'flarum/components/EditPostComposer';
|
||||
import Composer from 'flarum/components/Composer';
|
||||
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 Button from 'flarum/components/Button';
|
||||
|
||||
|
@ -43,7 +43,7 @@ export default class CommentPost extends Post {
|
|||
|
||||
content() {
|
||||
const content = this.isEditing()
|
||||
? formatText(this.props.post.editedContent)
|
||||
? Formatter.format(this.props.post.editedContent)
|
||||
: this.props.post.contentHtml();
|
||||
|
||||
return [
|
||||
|
|
|
@ -2,7 +2,7 @@ import Component from 'flarum/Component';
|
|||
import avatar from 'flarum/helpers/avatar';
|
||||
import username from 'flarum/helpers/username';
|
||||
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,
|
||||
|
@ -26,7 +26,7 @@ export default class ReplyPlaceholder extends Component {
|
|||
</div>
|
||||
</header>
|
||||
<div className="Post-body">
|
||||
{m.trust(formatText(this.props.discussion.replyContent))}
|
||||
{m.trust(Formatter.format(this.props.discussion.replyContent))}
|
||||
</div>
|
||||
</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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user