From 173c723c7cf7eac71717a5632add5afca79c3eb9 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 05 一月 2024 18:39:32 +0800
Subject: [PATCH] fix 修复 富文本编辑器 单页面多实例图片胡乱问题

---
 src/components/Editor/index.vue |   59 +++++++++++++++++++++++------------------------------------
 1 files changed, 23 insertions(+), 36 deletions(-)

diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue
index 05b574f..d2467f1 100644
--- a/src/components/Editor/index.vue
+++ b/src/components/Editor/index.vue
@@ -13,16 +13,16 @@
       :headers="upload.headers"
     >
     </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>
 
@@ -64,30 +64,18 @@
   debug: 'warn',
   modules: {
     // 宸ュ叿鏍忛厤缃�
-    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'] // 閾炬帴銆佸浘鐗囥�佽棰�
-      ],
-      handlers: {
-        image: function (value: any) {
-          if (value) {
-            // 璋冪敤element鍥剧墖涓婁紶
-            (document.querySelector('.editor-img-uploader>.el-upload') as HTMLDivElement)?.click();
-          } else {
-            Quill.format('image', true);
-          }
-        }
-      }
-    }
+    toolbar: [
+      ['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'] // 閾炬帴銆佸浘鐗囥�佽棰�
+    ]
   },
   placeholder: '璇疯緭鍏ュ唴瀹�',
   readOnly: props.readOnly
@@ -129,7 +117,7 @@
     quill.setSelection(length + 1);
     proxy?.$modal.closeLoading();
   } else {
-    proxy?.$modal.loading(res.msg);
+    proxy?.$modal.msgError("鍥剧墖鎻掑叆澶辫触");
     proxy?.$modal.closeLoading();
   }
 };
@@ -157,7 +145,6 @@
 
 // 鍥剧墖澶辫触鎷︽埅
 const handleUploadError = (err: any) => {
-  console.error(err);
   proxy?.$modal.msgError('涓婁紶鏂囦欢澶辫触');
 };
 </script>

--
Gitblit v1.9.3