mirror of
https://github.com/flarum/framework.git
synced 2025-06-08 09:44:33 +08:00
Live preview of post editing/replying thanks to TextFormatter 👏
This commit is contained in:
@ -34,6 +34,27 @@ export default class ReplyComposer extends ComposerBody {
|
||||
return items;
|
||||
}
|
||||
|
||||
config(isInitialized, context) {
|
||||
super.config(isInitialized, context);
|
||||
|
||||
if (isInitialized) return;
|
||||
|
||||
// Every 50ms, if the content has changed, then update the post's
|
||||
// editedContent property and redraw. This will cause the preview in the
|
||||
// post's component to update.
|
||||
const updateInterval = setInterval(() => {
|
||||
const discussion = this.props.discussion;
|
||||
const content = this.content();
|
||||
|
||||
if (content === discussion.replyContent) return;
|
||||
|
||||
discussion.replyContent = content;
|
||||
m.redraw();
|
||||
}, 50);
|
||||
|
||||
context.onunload = () => clearInterval(updateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data to submit to the server when the reply is saved.
|
||||
*
|
||||
|
Reference in New Issue
Block a user