From 39c7d5c5f5058c6805a4308e721d1234f7cf0d44 Mon Sep 17 00:00:00 2001 From: LiuDQ <21124031@qq.com> Date: Wed, 5 Nov 2025 10:38:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8=EF=BC=9A1.=E5=8F=AA?= =?UTF-8?q?=E8=AF=BB=E6=A8=A1=E5=BC=8F=E9=9A=90=E8=97=8F=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=EF=BC=9B2.=E7=82=B9=E5=87=BB=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=8F=AF=E5=BC=B9=E7=AA=97=E9=A2=84=E8=A7=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Editor/index.vue | 279 ++++++++++++++++++++++++++++---- 1 file changed, 246 insertions(+), 33 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 67394aae..ec1de853 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -24,6 +24,32 @@ @text-change="(e: any) => $emit('update:modelValue', content)" /> + + +
+ +
+ + {{ currentImageIndex + 1 }} / {{ imageUrlList.length }} + +
+
+
-- Gitee From 1b6e7bca9cb9320fc5ed33d208f40f12b404378d Mon Sep 17 00:00:00 2001 From: LiuDQ <21124031@qq.com> Date: Wed, 5 Nov 2025 11:37:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=EF=BC=9A1.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BA=86=E2=80=99=E8=AF=B7=E8=BE=93=E5=85=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E2=80=98=20=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Editor/index.vue | 77 +++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index ec1de853..3e5350ef 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -25,14 +25,17 @@ /> - +
- +
+ 预览图片 +
{ return imageUrlList.value[currentImageIndex.value] || ''; }); +// 图片加载处理 +const handleImageLoad = (event: Event) => { + const img = event.target as HTMLImageElement; + // 图片加载完成后,确保图片能够正确显示 + img.style.display = 'block'; +}; + const options = computed(() => { return { theme: 'snow', @@ -126,7 +136,7 @@ const options = computed(() => { } } }, - placeholder: '请输入内容', + placeholder: props.readOnly ? '' : '请输入内容', // 只读模式下不显示占位符 readOnly: props.readOnly }; }); @@ -176,6 +186,10 @@ watch( const quill = toRaw(quillEditorRef.value).getQuill(); if (quill) { quill.enable(!newVal); + // 如果切换到只读模式,移除焦点 + if (newVal) { + quill.blur(); + } } } // 重新初始化图片点击事件 @@ -317,7 +331,7 @@ const handleUploadError = (err: any) => { onMounted(() => { nextTick(() => { initImageClickEvent(); - // 如果已经是只读模式,确保图片可以点击 + // 如果已经是只读模式,确保图片可以点击并且移除焦点 if (props.readOnly && quillEditorRef.value) { const quill = toRaw(quillEditorRef.value).getQuill(); if (quill) { @@ -326,6 +340,8 @@ onMounted(() => { if (editorContainer) { editorContainer.style.pointerEvents = 'auto'; } + // 移除焦点 + quill.blur(); } } }); @@ -426,6 +442,7 @@ onMounted(() => { /* 只读模式下的图片样式 - 确保图片仍然可以点击 */ .editor :deep(.ql-editor.ql-disabled) { pointer-events: none; /* 禁用整个编辑器的指针事件 */ + user-select: none; /* 禁用文本选择 */ } .editor :deep(.ql-editor.ql-disabled img) { @@ -433,6 +450,23 @@ onMounted(() => { cursor: pointer; } +/* 隐藏只读模式下的占位符和光标 */ +.editor :deep(.ql-editor.ql-disabled::before) { + display: none !important; /* 隐藏占位符 */ +} + +.editor :deep(.ql-editor.ql-disabled .ql-cursor) { + display: none !important; /* 隐藏光标 */ +} + +.editor :deep(.ql-editor.ql-disabled *) { + caret-color: transparent !important; /* 隐藏光标 */ +} + +.editor :deep(.ql-editor.ql-disabled:focus) { + outline: none !important; /* 移除焦点样式 */ +} + /* 图片预览容器样式 */ .image-preview-container { display: flex; @@ -440,6 +474,30 @@ onMounted(() => { align-items: center; justify-content: center; min-height: 400px; + max-height: 80vh; + overflow: auto; +} + +.image-wrapper { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + max-width: 100%; + flex: 1; + overflow: auto; +} + +.preview-image { + max-width: 100%; + max-height: 75vh; + height: auto; + width: auto; + object-fit: contain; + display: block; + margin: 0 auto; + border-radius: 4px; + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); } .image-preview-nav { @@ -448,6 +506,7 @@ onMounted(() => { justify-content: center; gap: 20px; margin-top: 20px; + flex-shrink: 0; } .image-counter { -- Gitee