mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
TextFormatterPreview: Pass in content callback
This makes the component itself less dependent on global state, which has benefits for testability and reusability.
This commit is contained in:
@@ -50,7 +50,9 @@ export default class CommentPost extends Post {
|
||||
<header className="Post-header">
|
||||
<ul>{listItems(this.headerItems().toArray())}</ul>
|
||||
</header>,
|
||||
<div className="Post-body">{this.isEditing() ? <TextFormatterPreview /> : m.trust(this.attrs.post.contentHtml())}</div>,
|
||||
<div className="Post-body">
|
||||
{this.isEditing() ? <TextFormatterPreview content={() => app.composer.fields.content()} /> : m.trust(this.attrs.post.contentHtml())}
|
||||
</div>,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ export default class TextFormatterPreview extends Component {
|
||||
// body with a preview.
|
||||
let preview;
|
||||
const updatePreview = () => {
|
||||
const content = app.composer.fields.content();
|
||||
const content = this.attrs.content();
|
||||
|
||||
if (preview === content) return;
|
||||
|
||||
|
Reference in New Issue
Block a user