Skip to content

Commit

Permalink
close #1552 Fixed: Text Editor value can not change
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jul 28, 2020
1 parent 2c2c229 commit 8509b6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
31 changes: 25 additions & 6 deletions resources/assets/js/components/AkauntingHtmlEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '<p><br></p>') {
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);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions resources/views/partials/form/text_editor_group.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ class="form-group {{ $col }}{{ isset($attributes['required']) ? ' required' : ''
<akaunting-html-editor
name="{{ $name }}"

@if (!empty($attributes['v-model']))
:value="{{ $attributes['v-model'] . ' = ' . `$value` }}"
@elseif (!empty($attributes['data-field']))
:value="{{ 'form.' . $attributes['data-field'] . '.' . $name . ' = '. `$value` }}"
@else
:value="form.{{ $name }} = `{{ $value }}`"
@if (!empty($value))
:value="{{ `$value` }}"
@endif

@if (!empty($attributes['v-model']))
Expand Down

0 comments on commit 8509b6f

Please sign in to comment.