mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +02:00
add: forum/components/CommentPostPreview
- This has been extracted from CommentPost
This commit is contained in:
committed by
Franz Liedke
parent
37a690833a
commit
6c9971eeba
33
js/src/forum/components/CommentPostPreview.js
Normal file
33
js/src/forum/components/CommentPostPreview.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/*global s9e*/
|
||||
|
||||
import Component from "../../common/Component";
|
||||
|
||||
export default class CommentPostPreview extends Component {
|
||||
view() {
|
||||
return <div className="Post-preview" />;
|
||||
}
|
||||
|
||||
oncreate(vnode) {
|
||||
super.oncreate(vnode);
|
||||
|
||||
// Every 50ms, if the composer content has changed, then update the post's
|
||||
// body with a preview.
|
||||
let preview;
|
||||
const updatePreview = () => {
|
||||
const content = app.composer.fields.content();
|
||||
|
||||
if (preview === content) return;
|
||||
|
||||
preview = content;
|
||||
|
||||
s9e.TextFormatter.preview(preview || '', vnode.dom);
|
||||
};
|
||||
updatePreview();
|
||||
|
||||
this.updateInterval = setInterval(updatePreview, 50);
|
||||
}
|
||||
|
||||
onremove(vnode) {
|
||||
clearInterval(this.updateInterval);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user