From 0c022fdecd04c80d833ed0979b3a6b7a673548b9 Mon Sep 17 00:00:00 2001 From: baiqi Date: Thu, 15 Aug 2024 17:04:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=A8=E4=BE=8B=E8=84=91=E5=9B=BE):=20?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E7=94=A8=E4=BE=8B=E8=8A=82=E7=82=B9=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E5=A4=8D=E5=88=B6=E4=B8=8D=E5=8F=AF=E5=89=AA=E5=88=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooks/useMinderOperation.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/pure/ms-minder-editor/hooks/useMinderOperation.ts b/frontend/src/components/pure/ms-minder-editor/hooks/useMinderOperation.ts index dd8152f167..0738ad5801 100644 --- a/frontend/src/components/pure/ms-minder-editor/hooks/useMinderOperation.ts +++ b/frontend/src/components/pure/ms-minder-editor/hooks/useMinderOperation.ts @@ -54,19 +54,23 @@ export default function useMinderOperation(options: MinderOperationProps) { * 执行复制 */ const minderCopy = async (e?: ClipboardEvent) => { - if ((!options.canShowMoreMenu || !options.canShowMoreMenuNodeOperation) && options.canShowBatchCopy === false) { + const { editor } = window; + const { minder, fsm } = editor; + const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes(); + if ( + !options.canShowMoreMenu || + !options.canShowMoreMenuNodeOperation || + (selectedNodes.length > 1 && options.canShowBatchCopy === false) + ) { e?.preventDefault(); return; } - const { editor } = window; - const { minder, fsm } = editor; const state = fsm.state(); switch (state) { case 'input': { break; } case 'normal': { - const selectedNodes = minder.getSelectedNodes(); minderStore.dispatchEvent(MinderEventName.COPY_NODE, undefined, undefined, undefined, selectedNodes); if (e?.clipboardData) { e.clipboardData.setData('text/plain', encode(selectedNodes)); @@ -87,15 +91,18 @@ export default function useMinderOperation(options: MinderOperationProps) { * 执行剪切 */ const minderCut = async (e?: ClipboardEvent) => { + const { editor } = window; + const { minder, fsm } = editor; + const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes(); if ( - (options.disabled || !options.canShowMoreMenu || !options.canShowMoreMenuNodeOperation) && - options.canShowBatchCut === false + options.disabled || + !options.canShowMoreMenu || + !options.canShowMoreMenuNodeOperation || + (selectedNodes.length > 1 && options.canShowBatchCut === false) ) { e?.preventDefault(); return; } - const { editor } = window; - const { minder, fsm } = editor; if (minder.getStatus() !== 'normal') { e?.preventDefault(); return; @@ -107,7 +114,6 @@ export default function useMinderOperation(options: MinderOperationProps) { } case 'normal': { markDeleteNode(minder); - const selectedNodes: MinderJsonNode[] = minder.getSelectedNodes(); if (selectedNodes.length) { const newNodes = selectedNodes.map((node) => ({ ...node,