From 98414b7cec7431c31009498b01e59f64dbdf1ec0 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Thu, 27 Feb 2020 11:56:57 +0300 Subject: [PATCH] Fixed #204 - Editor infinite loop with some specific values --- src/components/editor/Editor.vue | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/editor/Editor.vue b/src/components/editor/Editor.vue index 8e5c140cd..3973016af 100644 --- a/src/components/editor/Editor.vue +++ b/src/components/editor/Editor.vue @@ -76,22 +76,25 @@ export default { formats: this.formats }); - this.quill.on('text-change', (delta, source) => { - let html = this.$refs.editorElement.children[0].innerHTML; - if (html === '


') { - html = ''; - } - - this.$emit('input', html); - this.$emit('text-change', { - htmlValue: html, - textValue: this.quill.getText(), - delta: delta, - source: source - }); - }); - this.renderValue(this.value); + + this.quill.on('text-change', (delta, oldContents, source) => { + if (source === 'user') { + let html = this.$refs.editorElement.children[0].innerHTML; + let text = this.quill.getText().trim(); + if (html === '


') { + html = ''; + } + + this.$emit('input', html); + this.$emit('text-change', { + htmlValue: html, + textValue: text, + delta: delta, + source: source + }); + } + }); }, methods: { renderValue(value) {