feat: add hotkey in workspace plugins

This commit is contained in:
liujuping 2023-07-14 12:25:12 +08:00 committed by 林熠
parent 87a4076427
commit 8414425740
2 changed files with 3 additions and 2 deletions

View File

@ -317,8 +317,8 @@ function getKeyInfo(combination: string, action?: string): KeyInfo {
function fireCallback(callback: IPublicTypeHotkeyCallback, e: KeyboardEvent, combo?: string, sequence?: string): void { function fireCallback(callback: IPublicTypeHotkeyCallback, e: KeyboardEvent, combo?: string, sequence?: string): void {
try { try {
const workspace = globalContext.get('workspace'); const workspace = globalContext.get('workspace');
const editor = workspace.isActive ? workspace.window.editor : globalContext.get('editor'); const editor = workspace.isActive ? workspace.window?.editor : globalContext.get('editor');
const designer = editor.get('designer'); const designer = editor?.get('designer');
const node = designer?.currentSelection?.getNodes()?.[0]; const node = designer?.currentSelection?.getNodes()?.[0];
const npm = node?.componentMeta?.npm; const npm = node?.componentMeta?.npm;
const selected = const selected =

View File

@ -103,6 +103,7 @@ export class Workspace implements IWorkspace {
readonly shellModelFactory: any, readonly shellModelFactory: any,
) { ) {
this.context = new BasicContext(this, '', IPublicEnumPluginRegisterLevel.Workspace); this.context = new BasicContext(this, '', IPublicEnumPluginRegisterLevel.Workspace);
this.context.innerHotkey.activate(true);
makeObservable(this); makeObservable(this);
} }