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 bedae8680..f83104591 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); }