mirror of
https://github.com/flarum/framework.git
synced 2025-05-24 23:59:57 +08:00
Live preview of post editing/replying thanks to TextFormatter 👏
This commit is contained in:
@ -19,6 +19,29 @@ export default class EditPostComposer extends ComposerBody {
|
||||
props.confirmExit = props.confirmExit || app.trans('core.confirm_discard_edit');
|
||||
props.originalContent = props.originalContent || props.post.content();
|
||||
props.user = props.user || props.post.user();
|
||||
|
||||
props.post.editedContent = props.originalContent;
|
||||
}
|
||||
|
||||
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 post = this.props.post;
|
||||
const content = this.content();
|
||||
|
||||
if (content === post.editedContent) return;
|
||||
|
||||
post.editedContent = content;
|
||||
m.redraw();
|
||||
}, 50);
|
||||
|
||||
context.onunload = () => clearInterval(updateInterval);
|
||||
}
|
||||
|
||||
headerItems() {
|
||||
|
Reference in New Issue
Block a user