From 9c151ee963ccefabe70985f4e4b23b1258b514a3 Mon Sep 17 00:00:00 2001 From: les Date: Sun, 16 Feb 2020 21:04:18 +0100 Subject: [PATCH] get value updates from outside in editor --- components/Editor.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/Editor.vue b/components/Editor.vue index 2cd07791..74268355 100644 --- a/components/Editor.vue +++ b/components/Editor.vue @@ -67,12 +67,25 @@ export default { data () { return { linkActive: false, - editor: null + editor: null, + update: false + } + }, + watch: { + value () { + if (this.update) { + this.update = false + return + } + this.editor.setContent(this.value) } }, mounted () { this.editor = new Editor({ - onUpdate: _.debounce(({ getHTML }) => this.$emit('input', getHTML()), 300), + onUpdate: _.debounce(({ getHTML }) => { + this.update = true + this.$emit('input', getHTML()) + }, 300), content: this.value, extensions: [ new Blockquote(),