diff --git a/src/pages/flowEditor/FlowEditorMain.tsx b/src/pages/flowEditor/FlowEditorMain.tsx index d44a0f1..36b8537 100644 --- a/src/pages/flowEditor/FlowEditorMain.tsx +++ b/src/pages/flowEditor/FlowEditorMain.tsx @@ -231,6 +231,29 @@ const FlowEditorMain: React.FC = (props) => { // 兼容 Mac (metaKey) 和 Windows/Linux (ctrlKey) const isModifierKey = e.ctrlKey || e.metaKey; + // 检查事件目标是否在可编辑元素中(input、textarea、contenteditable、CodeMirror等) + const target = e.target as HTMLElement; + const isEditableElement = + target instanceof HTMLInputElement || + target instanceof HTMLTextAreaElement || + target?.getAttribute('contenteditable') === 'true' || + target?.closest('[contenteditable="true"]') !== null || + target?.closest('.cm-content') !== null || // CodeMirror 编辑器 + target?.closest('.cm-editor') !== null || + target?.closest('.arco-input') !== null || // Arco Design 输入框 + target?.closest('.arco-textarea') !== null; + + // 检查是否有打开的弹出层(Modal、Drawer、Popover等),如果有则不拦截快捷键 + const hasOpenPopup = + document.querySelector('.arco-modal-wrapper') !== null || + document.querySelector('.arco-drawer-wrapper') !== null || + document.querySelector('.arco-popover-popup') !== null; + + // 如果在可编辑元素中或有打开的弹出层,不拦截复制粘贴快捷键,让浏览器处理 + if (isEditableElement || hasOpenPopup) { + return; + } + // Ctrl/Cmd+Z 撤销 if (isModifierKey && e.key === 'z' && !e.shiftKey && canUndo) { e.preventDefault();