diff --git a/src/components/RichTextEditor.vue b/src/components/RichTextEditor.vue index 6ea3b1c..a78d961 100644 --- a/src/components/RichTextEditor.vue +++ b/src/components/RichTextEditor.vue @@ -94,6 +94,12 @@ onMounted(() => { container.remove(); handleInput(); }); + + deleteBtn.addEventListener('touchend', function(e) { + e.stopPropagation(); + container.remove(); + handleInput(); + }); } // 为图片容器添加短按事件以显示/隐藏删除按钮 @@ -799,13 +805,19 @@ const insertImage = () => { imgContainer.addEventListener('touchend', handleTouchEnd) imgContainer.addEventListener('touchcancel', handleTouchCancel) - // 为删除按钮添加点击事件 + // 为删除按钮添加点击事件(鼠标和触摸) deleteBtn.addEventListener('click', function(e) { e.stopPropagation(); imgContainer.remove(); handleInput(); }); + deleteBtn.addEventListener('touchend', function(e) { + e.stopPropagation(); + imgContainer.remove(); + handleInput(); + }); + // 为图片容器添加短按事件以显示/隐藏删除按钮 let touchStartTime = 0; imgContainer.addEventListener('touchstart', function(e) { @@ -1461,6 +1473,12 @@ const adjustExistingImages = () => { container.remove(); handleInput(); }); + + deleteBtn.addEventListener('touchend', function(e) { + e.stopPropagation(); + container.remove(); + handleInput(); + }); } // 为图片容器添加短按事件以显示/隐藏删除按钮 @@ -1535,6 +1553,12 @@ defineExpose({ container.remove(); handleInput(); }); + + deleteBtn.addEventListener('touchend', function(e) { + e.stopPropagation(); + container.remove(); + handleInput(); + }); } // 为图片容器添加短按事件以显示/隐藏删除按钮