fix: 修复富文本编辑器上传图片 (#410)
* fix: 修复题目标题插入图片异常问题 * fix: 修改事件监听顺序,避免编辑图片百分比时重新渲染工具条而找不到点击的dom --------- Co-authored-by: jiangchunfu <jiangchunfu@kaike.la>
This commit is contained in:
parent
39c80352b3
commit
afbd63646a
@ -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) {
|
||||
// 监听编辑状态时点击非编辑区域
|
||||
|
Loading…
Reference in New Issue
Block a user