Live preview of post editing/replying thanks to TextFormatter 👏

This commit is contained in:
Toby Zerner
2015-07-22 16:05:00 +09:30
parent a0fe68272c
commit 017c258e46
14 changed files with 130 additions and 26 deletions

View File

@ -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.
*