fix: 修复富文本编辑器上传图片 (#410)

* fix: 修复题目标题插入图片异常问题

* fix: 修改事件监听顺序,避免编辑图片百分比时重新渲染工具条而找不到点击的dom

---------

Co-authored-by: jiangchunfu <jiangchunfu@kaike.la>
This commit is contained in:
Jiangchunfu 2024-09-06 15:51:12 +08:00 committed by sudoooooo
parent 39c80352b3
commit afbd63646a

View File

@ -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) {
//