From dfdcee9b95a49291ea6243c2b4a71ea379ea0a0f Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期五, 05 一月 2024 22:51:03 +0800 Subject: [PATCH] !79 update 富文本组件,修复两个组件上传图片位置错乱问题 Merge pull request !79 from 抓蛙师/N/A --- src/components/Editor/index.vue | 53 ++++++++++++++++++++++++++--------------------------- 1 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 05b574f..be7f24a 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -2,7 +2,6 @@ <div> <el-upload v-if="type === 'url'" - ref="uploadRef" :action="upload.url" :before-upload="handleBeforeUpload" :on-success="handleUploadSuccess" @@ -12,17 +11,18 @@ :show-file-list="false" :headers="upload.headers" > + <i ref="uploadRef"></i> </el-upload> - <div class="editor"> - <quill-editor - ref="quillEditorRef" - v-model:content="content" - content-type="html" - :options="options" - :style="styles" - @text-change="(e: any) => $emit('update:modelValue', content)" - /> - </div> + </div> + <div class="editor"> + <quill-editor + ref="quillEditorRef" + v-model:content="content" + content-type="html" + :options="options" + :style="styles" + @text-change="(e: any) => $emit('update:modelValue', content)" + /> </div> </template> @@ -66,27 +66,27 @@ // 宸ュ叿鏍忛厤缃� toolbar: { container: [ - ['bold', 'italic', 'underline', 'strike'], // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾� - ['blockquote', 'code-block'], // 寮曠敤 浠g爜鍧� - [{ list: 'ordered' }, { list: 'bullet' }], // 鏈夊簭銆佹棤搴忓垪琛� - [{ indent: '-1' }, { indent: '+1' }], // 缂╄繘 - [{ size: ['small', false, 'large', 'huge'] }], // 瀛椾綋澶у皬 - [{ header: [1, 2, 3, 4, 5, 6, false] }], // 鏍囬 - [{ color: [] }, { background: [] }], // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹� - [{ align: [] }], // 瀵归綈鏂瑰紡 - ['clean'], // 娓呴櫎鏂囨湰鏍煎紡 - ['link', 'image', 'video'] // 閾炬帴銆佸浘鐗囥�佽棰� + ["bold", "italic", "underline", "strike"], // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾� + ["blockquote", "code-block"], // 寮曠敤 浠g爜鍧� + [{ list: "ordered" }, { list: "bullet" }], // 鏈夊簭銆佹棤搴忓垪琛� + [{ indent: "-1" }, { indent: "+1" }], // 缂╄繘 + [{ size: ["small", false, "large", "huge"] }], // 瀛椾綋澶у皬 + [{ header: [1, 2, 3, 4, 5, 6, false] }], // 鏍囬 + [{ color: [] }, { background: [] }], // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹� + [{ align: [] }], // 瀵归綈鏂瑰紡 + ["clean"], // 娓呴櫎鏂囨湰鏍煎紡 + ["link", "image", "video"] // 閾炬帴銆佸浘鐗囥�佽棰� ], handlers: { image: function (value: any) { if (value) { // 璋冪敤element鍥剧墖涓婁紶 - (document.querySelector('.editor-img-uploader>.el-upload') as HTMLDivElement)?.click(); + proxy?.$refs.uploadRef.click(); } else { - Quill.format('image', true); + Quill.format("image", true); } - } - } + }, + }, } }, placeholder: '璇疯緭鍏ュ唴瀹�', @@ -129,7 +129,7 @@ quill.setSelection(length + 1); proxy?.$modal.closeLoading(); } else { - proxy?.$modal.loading(res.msg); + proxy?.$modal.msgError("鍥剧墖鎻掑叆澶辫触"); proxy?.$modal.closeLoading(); } }; @@ -157,7 +157,6 @@ // 鍥剧墖澶辫触鎷︽埅 const handleUploadError = (err: any) => { - console.error(err); proxy?.$modal.msgError('涓婁紶鏂囦欢澶辫触'); }; </script> -- Gitblit v1.9.3