diff --git a/resources/assets/js/components/AkauntingHtmlEditor.vue b/resources/assets/js/components/AkauntingHtmlEditor.vue index 22be7451b..329a6119a 100644 --- a/resources/assets/js/components/AkauntingHtmlEditor.vue +++ b/resources/assets/js/components/AkauntingHtmlEditor.vue @@ -49,45 +49,64 @@ let editorRef = this.$refs.editor; let node = editorRef.children[0]; + this.editor.on('text-change', () => { - let html = node.innerHTML + let html = node.innerHTML; + if (html === '


') { html = ''; } - this.content = html + + this.content = html; + this.$emit('input', this.content); }) }, + pasteHTML () { if (!this.editor) { return } - this.editor.pasteHTML(this.value) + + this.editor.pasteHTML(this.value); }, + randomString() { let text = ""; let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - for (let i = 0; i < 5; i++) + for (let i = 0; i < 5; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); + } return text; } }, + async mounted () { - let Quill = await import('quill') - Quill = Quill.default || Quill + this.content = this.value; + + let Quill = await import('quill'); + + Quill = Quill.default || Quill; + this.editorId = this.randomString(); this.toolbarId = this.randomString(); + this.$nextTick(() => { this.initialize(Quill) }); }, + watch: { value (newVal) { if (newVal !== this.content) { this.pasteHTML(newVal); } + }, + + content (newVal) { + this.$emit('input', newVal); } } } diff --git a/resources/views/partials/form/text_editor_group.blade.php b/resources/views/partials/form/text_editor_group.blade.php index 807f6cad0..d249fee82 100644 --- a/resources/views/partials/form/text_editor_group.blade.php +++ b/resources/views/partials/form/text_editor_group.blade.php @@ -10,12 +10,8 @@