|
@@ -3,7 +3,7 @@
|
|
<div class="editor">
|
|
<div class="editor">
|
|
<quill-editor
|
|
<quill-editor
|
|
class="ql-editor"
|
|
class="ql-editor"
|
|
- v-model="forms.content"
|
|
|
|
|
|
+ v-model="forms[keyWord]"
|
|
ref="myQuillEditor"
|
|
ref="myQuillEditor"
|
|
:options="editorOption"
|
|
:options="editorOption"
|
|
@change="onEditorChange($event)"
|
|
@change="onEditorChange($event)"
|
|
@@ -22,7 +22,12 @@
|
|
<Button icon="ios-cloud-upload-outline"></Button>
|
|
<Button icon="ios-cloud-upload-outline"></Button>
|
|
</el-upload>
|
|
</el-upload>
|
|
|
|
|
|
- <el-dialog title="插入视频" width="500px" :visible.sync="dialogFormVisible" append-to-body>
|
|
|
|
|
|
+ <el-dialog
|
|
|
|
+ title="插入视频"
|
|
|
|
+ width="500px"
|
|
|
|
+ :visible.sync="dialogFormVisible"
|
|
|
|
+ append-to-body
|
|
|
|
+ >
|
|
<el-form :model="dialogForm" ref="diologForm" :rules="dialogFormRules">
|
|
<el-form :model="dialogForm" ref="diologForm" :rules="dialogFormRules">
|
|
<el-form-item label="封面图地址" label-width="90px">
|
|
<el-form-item label="封面图地址" label-width="90px">
|
|
<el-upload
|
|
<el-upload
|
|
@@ -38,7 +43,7 @@
|
|
:before-upload="beforeImgUpload"
|
|
:before-upload="beforeImgUpload"
|
|
>
|
|
>
|
|
<img
|
|
<img
|
|
- width="300px"
|
|
|
|
|
|
+ width="300px"
|
|
v-if="dialogForm.poster"
|
|
v-if="dialogForm.poster"
|
|
:src="dialogForm.poster"
|
|
:src="dialogForm.poster"
|
|
class="avatar"
|
|
class="avatar"
|
|
@@ -128,7 +133,7 @@ const toolbarOptions = [
|
|
[{ align: [] }], // 对齐方式
|
|
[{ align: [] }], // 对齐方式
|
|
["clean"], // 清除文本格式
|
|
["clean"], // 清除文本格式
|
|
["image"], // 链接、图片、视频 , "video"
|
|
["image"], // 链接、图片、视频 , "video"
|
|
- // ["link", "image", "video"] // 链接、图片、视频
|
|
|
|
|
|
+ ["link", "image", "video"] // 链接、图片、视频
|
|
];
|
|
];
|
|
// 标题
|
|
// 标题
|
|
const titleConfig = {
|
|
const titleConfig = {
|
|
@@ -163,7 +168,16 @@ import dayjs from "dayjs";
|
|
Quill.register(Video, true);
|
|
Quill.register(Video, true);
|
|
let that;
|
|
let that;
|
|
export default {
|
|
export default {
|
|
- props: ["form"],
|
|
|
|
|
|
+ // props: ["form",'key'],
|
|
|
|
+ props: {
|
|
|
|
+ keyWord: {
|
|
|
|
+ type:String,
|
|
|
|
+ default:'content'
|
|
|
|
+ },
|
|
|
|
+ form: {
|
|
|
|
+ type: Object,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
name: "editor",
|
|
name: "editor",
|
|
components: { quillEditor },
|
|
components: { quillEditor },
|
|
data() {
|
|
data() {
|
|
@@ -205,7 +219,9 @@ export default {
|
|
that.dialogFormVisible = true;
|
|
that.dialogFormVisible = true;
|
|
let editor = that.$refs.myQuillEditor.quill;
|
|
let editor = that.$refs.myQuillEditor.quill;
|
|
// 光标所在位置
|
|
// 光标所在位置
|
|
- that.editorIndex = editor.getSelection().index;
|
|
|
|
|
|
+ console.log(editor.getContents())
|
|
|
|
+ that.editorIndex = editor.getSelection()?.index||0;
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
this.quill.format("image", false);
|
|
this.quill.format("image", false);
|
|
}
|
|
}
|
|
@@ -216,13 +232,17 @@ export default {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- mounted(){
|
|
|
|
- console.log(this.form)
|
|
|
|
|
|
+ created(){
|
|
that = this;
|
|
that = this;
|
|
},
|
|
},
|
|
|
|
+ mounted() {
|
|
|
|
+
|
|
|
|
+ console.log(this.form);
|
|
|
|
+
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
onEditorChange({ quill, html, text }) {
|
|
onEditorChange({ quill, html, text }) {
|
|
- this.form.content = html;
|
|
|
|
|
|
+ this.form[this.keyWord] = html;
|
|
},
|
|
},
|
|
onVideoComfirm(formName) {
|
|
onVideoComfirm(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
this.$refs[formName].validate((valid) => {
|
|
@@ -237,6 +257,7 @@ export default {
|
|
};
|
|
};
|
|
quill.insertEmbed(this.editorIndex, "video", params);
|
|
quill.insertEmbed(this.editorIndex, "video", params);
|
|
// 调整光标到最后
|
|
// 调整光标到最后
|
|
|
|
+ console.log(this.editorIndex,)
|
|
quill.setSelection(this.editorIndex + 1, { preload: false });
|
|
quill.setSelection(this.editorIndex + 1, { preload: false });
|
|
|
|
|
|
this.dialogFormVisible = false;
|
|
this.dialogFormVisible = false;
|
|
@@ -377,6 +398,5 @@ export default {
|
|
/deep/.ql-container .ql-editor {
|
|
/deep/.ql-container .ql-editor {
|
|
max-height: 500px;
|
|
max-height: 500px;
|
|
}
|
|
}
|
|
-
|
|
|
|
</style>
|
|
</style>
|
|
|
|
|