|
@@ -4,7 +4,7 @@
|
|
<quill-editor
|
|
<quill-editor
|
|
class="ql-editor"
|
|
class="ql-editor"
|
|
v-model="forms[keyWord]"
|
|
v-model="forms[keyWord]"
|
|
- ref="myQuillEditor"
|
|
|
|
|
|
+ :ref="alias"
|
|
:options="editorOption"
|
|
:options="editorOption"
|
|
@change="onEditorChange($event)"
|
|
@change="onEditorChange($event)"
|
|
></quill-editor>
|
|
></quill-editor>
|
|
@@ -177,6 +177,10 @@ export default {
|
|
form: {
|
|
form: {
|
|
type: Object,
|
|
type: Object,
|
|
},
|
|
},
|
|
|
|
+ alias: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: 'myQuillEditor'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
name: "editor",
|
|
name: "editor",
|
|
components: { quillEditor },
|
|
components: { quillEditor },
|
|
@@ -217,9 +221,9 @@ export default {
|
|
video: function (value) {
|
|
video: function (value) {
|
|
if (value) {
|
|
if (value) {
|
|
that.dialogFormVisible = true;
|
|
that.dialogFormVisible = true;
|
|
- let editor = that.$refs.myQuillEditor.quill;
|
|
|
|
|
|
+ let editor = that.$refs[this.alias].quill;
|
|
// 光标所在位置
|
|
// 光标所在位置
|
|
- console.log(editor.getContents())
|
|
|
|
|
|
+ console.log(editor, editor.getSelection())
|
|
that.editorIndex = editor.getSelection()?.index||0;
|
|
that.editorIndex = editor.getSelection()?.index||0;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -257,7 +261,7 @@ export default {
|
|
};
|
|
};
|
|
quill.insertEmbed(this.editorIndex, "video", params);
|
|
quill.insertEmbed(this.editorIndex, "video", params);
|
|
// 调整光标到最后
|
|
// 调整光标到最后
|
|
- console.log(this.editorIndex,)
|
|
|
|
|
|
+ console.log(this.editorIndex)
|
|
quill.setSelection(this.editorIndex + 1, { preload: false });
|
|
quill.setSelection(this.editorIndex + 1, { preload: false });
|
|
|
|
|
|
this.dialogFormVisible = false;
|
|
this.dialogFormVisible = false;
|
|
@@ -380,7 +384,7 @@ export default {
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
editor() {
|
|
editor() {
|
|
- return this.$refs.myQuillEditor.quill;
|
|
|
|
|
|
+ return this.$refs[this.alias].quill;
|
|
},
|
|
},
|
|
forms() {
|
|
forms() {
|
|
return this.form;
|
|
return this.form;
|