1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

add: forum/components/CommentPostPreview

- This has been extracted from CommentPost
This commit is contained in:
Alexander Skvortsov
2020-08-09 23:14:24 -04:00
committed by Franz Liedke
parent 37a690833a
commit 6c9971eeba

View 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);
}
}