From 841442574080d6399d549a1a974c71d5b4a572f0 Mon Sep 17 00:00:00 2001 From: liujuping Date: Fri, 14 Jul 2023 12:25:12 +0800 Subject: [PATCH] feat: add hotkey in workspace plugins --- packages/editor-core/src/hotkey.ts | 4 ++-- packages/workspace/src/workspace.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/editor-core/src/hotkey.ts b/packages/editor-core/src/hotkey.ts index adc74262a..d0dd40cc2 100644 --- a/packages/editor-core/src/hotkey.ts +++ b/packages/editor-core/src/hotkey.ts @@ -317,8 +317,8 @@ function getKeyInfo(combination: string, action?: string): KeyInfo { function fireCallback(callback: IPublicTypeHotkeyCallback, e: KeyboardEvent, combo?: string, sequence?: string): void { try { const workspace = globalContext.get('workspace'); - const editor = workspace.isActive ? workspace.window.editor : globalContext.get('editor'); - const designer = editor.get('designer'); + const editor = workspace.isActive ? workspace.window?.editor : globalContext.get('editor'); + const designer = editor?.get('designer'); const node = designer?.currentSelection?.getNodes()?.[0]; const npm = node?.componentMeta?.npm; const selected = diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index 6c35d8b35..6410c6e20 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -103,6 +103,7 @@ export class Workspace implements IWorkspace { readonly shellModelFactory: any, ) { this.context = new BasicContext(this, '', IPublicEnumPluginRegisterLevel.Workspace); + this.context.innerHotkey.activate(true); makeObservable(this); }