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) { // 监听编辑状态时点击非编辑区域