mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +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">
|
<header className="Post-header">
|
||||||
<ul>{listItems(this.headerItems().toArray())}</ul>
|
<ul>{listItems(this.headerItems().toArray())}</ul>
|
||||||
</header>,
|
</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.
|
// body with a preview.
|
||||||
let preview;
|
let preview;
|
||||||
const updatePreview = () => {
|
const updatePreview = () => {
|
||||||
const content = app.composer.fields.content();
|
const content = this.attrs.content();
|
||||||
|
|
||||||
if (preview === content) return;
|
if (preview === content) return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user