From 43001a12c7ee29caa38390559542877b5375231d Mon Sep 17 00:00:00 2001 From: Jiangchunfu Date: Fri, 6 Sep 2024 15:51:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=20(#410)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复题目标题插入图片异常问题 * fix: 修改事件监听顺序,避免编辑图片百分比时重新渲染工具条而找不到点击的dom --------- Co-authored-by: jiangchunfu --- .../questions/widgets/TitleModules/TitleContent/index.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/materials/questions/widgets/TitleModules/TitleContent/index.jsx b/web/src/materials/questions/widgets/TitleModules/TitleContent/index.jsx index 0cba4d9a..b19b4a27 100644 --- a/web/src/materials/questions/widgets/TitleModules/TitleContent/index.jsx +++ b/web/src/materials/questions/widgets/TitleModules/TitleContent/index.jsx @@ -48,9 +48,9 @@ export default defineComponent({ watch(status, (v) => { if (v === 'edit') { - document.addEventListener('click', handleDocumentClick) + document.addEventListener('click', handleDocumentClick, {capture: true}) } else { - document.removeEventListener('click', handleDocumentClick) + document.removeEventListener('click', handleDocumentClick, {capture: true}) } }) @@ -96,7 +96,8 @@ export default defineComponent({ function handleDocumentClick(e) { const richEditorDOM = moduleTitleRef.value.querySelector('.rich-editor') - const isClickRichEditor = richEditorDOM?.contains(e.target) + const isUploadImage = e.target.type === 'file' && e.target.tagName.toLowerCase() === 'input' // 富文本上传图片点击事件触发到input file 元素上了, 该元素插入到body了 + const isClickRichEditor = richEditorDOM?.contains(e.target) || isUploadImage if (status.value === 'edit' && richEditorDOM && !isClickRichEditor) { // 监听编辑状态时点击非编辑区域