Akaunting Html Editor component fixed.. 0.js and 37.js file deleted :)

This commit is contained in:
Cüneyt Şentürk 2021-01-18 16:20:57 +03:00
parent 1a562e4707
commit 12c1be09e6

View File

@ -11,20 +11,30 @@
<button type="button" class="ql-list" value="bullet"></button> <button type="button" class="ql-list" value="bullet"></button>
</div> </div>
</div> </div>
<div :id="editorId" :name="name" class="" ref="editor"> <div :id="editorId" :name="name" class="" ref="editor">
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { import Quill from 'quill';
export default {
name: 'akaunting-html-editor', name: 'akaunting-html-editor',
props: { props: {
name: String,
value: { value: {
type: String, type: String,
default: '' default: ''
}, },
name: String theme: {
type: String,
default: 'snow'
}, },
},
data () { data () {
return { return {
editor: null, editor: null,
@ -34,14 +44,17 @@
toolbarId: null toolbarId: null
} }
}, },
methods: { methods: {
initialize (Quill) { initialize (Quill) {
let theme = this.theme;
this.editor = new Quill(`#${this.editorId}`, { this.editor = new Quill(`#${this.editorId}`, {
theme: 'snow', theme: theme,
modules: { modules: {
toolbar: `#${this.toolbarId}` toolbar: `#${this.toolbarId}`
} }
}) });
if (this.value.length > 0) { if (this.value.length > 0) {
this.editor.pasteHTML(this.value) this.editor.pasteHTML(this.value)
@ -60,12 +73,12 @@
this.content = html; this.content = html;
this.$emit('input', this.content); this.$emit('input', this.content);
}) });
}, },
pasteHTML () { pasteHTML () {
if (!this.editor) { if (!this.editor) {
return return;
} }
this.editor.pasteHTML(this.value); this.editor.pasteHTML(this.value);
@ -80,16 +93,12 @@
} }
return text; return text;
} },
}, },
async mounted () { async mounted () {
this.content = this.value; this.content = this.value;
let Quill = await import('quill');
Quill = Quill.default || Quill;
this.editorId = this.randomString(); this.editorId = this.randomString();
this.toolbarId = this.randomString(); this.toolbarId = this.randomString();
@ -107,7 +116,7 @@
content (newVal) { content (newVal) {
this.$emit('input', newVal); this.$emit('input', newVal);
} },
} },
} }
</script> </script>