From 3eaeb27630ca5caaffc0c0628ce9e15bcd0814ce Mon Sep 17 00:00:00 2001 From: baiqi Date: Tue, 12 Nov 2024 18:10:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=84=91=E5=9B=BE):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=93=8D=E4=BD=9C=E7=9B=91=E5=90=AC=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E7=BC=96=E8=BE=91=E4=BA=8B=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms-minders/featureCaseMinder/index.vue | 1 + .../ms-minder-editor/hooks/useShortCut.ts | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue b/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue index 5c088a2082..7fcd48cd00 100644 --- a/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue +++ b/frontend/src/components/business/ms-minders/featureCaseMinder/index.vue @@ -229,6 +229,7 @@ count: props.modulesCount[e.id], isNew: false, changed: false, + disabled: ['NONE', 'root'].includes(e.id || e.data?.id), // 全部模块节点和根节点不可编辑文本 }, children: props.modulesCount[e.id] > 0 && !e.children?.length diff --git a/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts b/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts index 2f4637cf62..f295ea1bdd 100644 --- a/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts +++ b/frontend/src/components/pure/ms-minder-editor/hooks/useShortCut.ts @@ -59,7 +59,6 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati 'enter': 'appendSiblingNode', 'tab': 'appendChildNode', 'backspace': 'delete', - 'f2': 'input', // 进入编辑状态 }; // 业务快捷键 const businessShortcuts: { [key: string]: ShortcutKey } = { @@ -98,6 +97,27 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati } }; + const handleShortcutInput = (event: KeyboardEvent) => { + const { editor } = window; + const { fsm } = editor; + const state = fsm.state(); + switch (state) { + case 'input': { + // 输入状态下不响应快捷键 + return; + } + default: + } + const key = event.key.toLowerCase(); + + if (key === 'f2') { + // 执行快捷键编辑事件 + if (shortcuts.input) { + shortcuts.input(event); + } + } + }; + const handleShortcutSave = (event: KeyboardEvent) => { const { editor } = window; const { fsm } = editor; @@ -124,6 +144,7 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati const minderContainer = document.querySelector('.ms-minder-container'); if (minderContainer) { window.addEventListener('keydown', handleShortcutSave); + window.addEventListener('keydown', handleShortcutInput); minderContainer.addEventListener('keydown', (e) => handleKeyDown(e as KeyboardEvent)); minderContainer.addEventListener('copy', (e) => minderCopy(e as ClipboardEvent)); minderContainer.addEventListener('cut', (e) => minderCut(e as ClipboardEvent)); @@ -135,6 +156,7 @@ export default function useShortCut(shortcuts: Shortcuts, options: MinderOperati const minderContainer = document.querySelector('.ms-minder-container'); if (minderContainer) { window.removeEventListener('keydown', handleShortcutSave); + window.removeEventListener('keydown', handleShortcutInput); minderContainer.removeEventListener('keydown', (e) => handleKeyDown(e as KeyboardEvent)); minderContainer.removeEventListener('copy', (e) => minderCopy(e as ClipboardEvent)); minderContainer.removeEventListener('cut', (e) => minderCut(e as ClipboardEvent));