fix 修复 富文本编辑器 单页面多实例图片胡乱问题

This commit is contained in:
疯狂的狮子Li 2024-01-05 18:39:18 +08:00
parent 595a521a3c
commit 173c723c7c

View File

@ -13,6 +13,7 @@
:headers="upload.headers" :headers="upload.headers"
> >
</el-upload> </el-upload>
</div>
<div class="editor"> <div class="editor">
<quill-editor <quill-editor
ref="quillEditorRef" ref="quillEditorRef"
@ -23,7 +24,6 @@
@text-change="(e: any) => $emit('update:modelValue', content)" @text-change="(e: any) => $emit('update:modelValue', content)"
/> />
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -64,8 +64,7 @@ const options = ref<any>({
debug: 'warn', debug: 'warn',
modules: { modules: {
// //
toolbar: { toolbar: [
container: [
['bold', 'italic', 'underline', 'strike'], // 线 线 ['bold', 'italic', 'underline', 'strike'], // 线 线
['blockquote', 'code-block'], // ['blockquote', 'code-block'], //
[{ list: 'ordered' }, { list: 'bullet' }], // [{ list: 'ordered' }, { list: 'bullet' }], //
@ -76,18 +75,7 @@ const options = ref<any>({
[{ align: [] }], // [{ align: [] }], //
['clean'], // ['clean'], //
['link', 'image', 'video'] // ['link', 'image', 'video'] //
], ]
handlers: {
image: function (value: any) {
if (value) {
// element
(document.querySelector('.editor-img-uploader>.el-upload') as HTMLDivElement)?.click();
} else {
Quill.format('image', true);
}
}
}
}
}, },
placeholder: '请输入内容', placeholder: '请输入内容',
readOnly: props.readOnly readOnly: props.readOnly
@ -129,7 +117,7 @@ const handleUploadSuccess = (res: any) => {
quill.setSelection(length + 1); quill.setSelection(length + 1);
proxy?.$modal.closeLoading(); proxy?.$modal.closeLoading();
} else { } else {
proxy?.$modal.loading(res.msg); proxy?.$modal.msgError("图片插入失败");
proxy?.$modal.closeLoading(); proxy?.$modal.closeLoading();
} }
}; };
@ -157,7 +145,6 @@ const handleBeforeUpload = (file: any) => {
// //
const handleUploadError = (err: any) => { const handleUploadError = (err: any) => {
console.error(err);
proxy?.$modal.msgError('上传文件失败'); proxy?.$modal.msgError('上传文件失败');
}; };
</script> </script>