diff --git a/packages/editor-core/src/config.ts b/packages/editor-core/src/config.ts index 4f0f708e7..c325c2bb8 100644 --- a/packages/editor-core/src/config.ts +++ b/packages/editor-core/src/config.ts @@ -150,6 +150,11 @@ const VALID_ENGINE_OPTIONS = { description: '应用级设计模式下,自动打开第一个窗口', default: true, }, + enableWorkspaceMode: { + type: 'boolean', + description: '是否开启应用级设计模式', + default: false, + }, }; const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => { diff --git a/packages/shell/src/api/workspace.ts b/packages/shell/src/api/workspace.ts index bfc7b27e1..8192ac67d 100644 --- a/packages/shell/src/api/workspace.ts +++ b/packages/shell/src/api/workspace.ts @@ -42,8 +42,8 @@ export class Workspace implements IPublicApiWorkspace { this[workspaceSymbol].registerResourceType(resourceTypeModel); } - openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string, sleep?: boolean): void { - this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName, sleep); + async openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string, sleep?: boolean): Promise { + await this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName, sleep); } openEditorWindowById(id: string) { diff --git a/packages/types/src/shell/api/workspace.ts b/packages/types/src/shell/api/workspace.ts index 8904a8231..8ae2434bc 100644 --- a/packages/types/src/shell/api/workspace.ts +++ b/packages/types/src/shell/api/workspace.ts @@ -30,7 +30,7 @@ export interface IPublicApiWorkspace< registerResourceType(resourceTypeModel: IPublicTypeResourceType): void; /** 打开视图窗口 */ - openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string, sleep?: boolean): void; + openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string, sleep?: boolean): Promise; /** 通过视图 id 打开窗口 */ openEditorWindowById(id: string): void; @@ -47,6 +47,12 @@ export interface IPublicApiWorkspace< /** active 窗口变更事件 */ onChangeActiveWindow(fn: () => void): IPublicTypeDisposable; + /** + * active 视图变更事件 + * @since v1.1.7 + */ + onChangeActiveEditorView(fn: () => void): IPublicTypeDisposable; + /** * window 下的所有视图 renderer ready 事件 * @since v1.1.7 diff --git a/packages/types/src/shell/model/plugin-context.ts b/packages/types/src/shell/model/plugin-context.ts index e670e54ea..ea6fb7102 100644 --- a/packages/types/src/shell/model/plugin-context.ts +++ b/packages/types/src/shell/model/plugin-context.ts @@ -13,7 +13,7 @@ import { IPublicApiWorkspace, } from '../api'; import { IPublicEnumPluginRegisterLevel } from '../enum'; -import { IPublicModelEngineConfig } from './'; +import { IPublicModelEngineConfig, IPublicModelEditorView } from './'; export interface IPublicModelPluginContext { @@ -107,6 +107,8 @@ export interface IPublicModelPluginContext { * @since v1.1.7 */ get registerLevel(): IPublicEnumPluginRegisterLevel; + + get editorWindow(): IPublicModelEditorView; } /** diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index 33daf064a..ba3d91c41 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -128,7 +128,7 @@ export class Workspace implements IWorkspace { title: resource.title, }); this.editorWindowMap.set(this.window.id, this.window); - this.windows.push(this.window); + this.windows = [...this.windows, this.window]; this.emitChangeWindow(); this.emitChangeActiveWindow(); } @@ -214,7 +214,7 @@ export class Workspace implements IWorkspace { } } - openEditorWindow(name: string, title: string, options: Object, viewType?: string, sleep?: boolean) { + async openEditorWindow(name: string, title: string, options: Object, viewType?: string, sleep?: boolean) { if (this.window && !this.window?.initReady && !sleep) { this.windowQueue.push({ name, title, options, viewType, @@ -230,7 +230,7 @@ export class Workspace implements IWorkspace { if (filterWindows && filterWindows.length) { this.window = filterWindows[0]; if (!sleep && this.window.sleep) { - this.window.init(); + await this.window.init(); } else { this.checkWindowQueue(); }