Make formatText util an object so it can be extended

This commit is contained in:
Toby Zerner 2015-07-27 14:17:12 +09:30
parent 9cbb1aaf50
commit 01b225fd6d
4 changed files with 15 additions and 11 deletions

View File

@ -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 [

View File

@ -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>
);

View File

@ -0,0 +1,11 @@
/*global s9e*/
export default {
format(text) {
const elm = document.createElement('div');
s9e.TextFormatter.preview(text || '', elm);
return elm.innerHTML;
}
}

View File

@ -1,7 +0,0 @@
export default function formatText(text) {
const elm = document.createElement('div');
s9e.TextFormatter.preview(text || '', elm);
return elm.innerHTML;
}