1
0
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:
Franz Liedke
2020-09-11 16:29:44 +02:00
parent a6e6c54972
commit fb83f8c59c
2 changed files with 4 additions and 2 deletions

View File

@@ -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>,
]);
}

View File

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