mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
feat: workspace add onChangeActiveWindow event api
This commit is contained in:
parent
8ac68b982b
commit
22d2fddc3e
@ -73,4 +73,8 @@ export class Workspace implements IPublicApiWorkspace {
|
|||||||
onChangeActiveWindow(fn: () => void): IPublicTypeDisposable {
|
onChangeActiveWindow(fn: () => void): IPublicTypeDisposable {
|
||||||
return this[workspaceSymbol].onChangeActiveWindow(fn);
|
return this[workspaceSymbol].onChangeActiveWindow(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangeActiveEditorView(fn: () => void): IPublicTypeDisposable {
|
||||||
|
return this[workspaceSymbol].onChangeActiveEditorView(fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export class EditorView {
|
|||||||
constructor(editorView: IViewContext) {
|
constructor(editorView: IViewContext) {
|
||||||
this[editorViewSymbol] = editorView;
|
this[editorViewSymbol] = editorView;
|
||||||
this[pluginContextSymbol] = this[editorViewSymbol].innerPlugins._getLowCodePluginContext({
|
this[pluginContextSymbol] = this[editorViewSymbol].innerPlugins._getLowCodePluginContext({
|
||||||
pluginName: '',
|
pluginName: editorView.editorWindow + editorView.viewName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,7 @@ import { createModuleEventBus, IEventBus, makeObservable, obx } from '@alilc/low
|
|||||||
import { Context, IViewContext } from './context/view-context';
|
import { Context, IViewContext } from './context/view-context';
|
||||||
import { IWorkspace } from './workspace';
|
import { IWorkspace } from './workspace';
|
||||||
import { IResource } from './resource';
|
import { IResource } from './resource';
|
||||||
import { IPublicTypeDisposable } from '../../types/es/shell/type/disposable';
|
import { IPublicModelWindow, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||||
import { IPublicModelWindow } from '@alilc/lowcode-types';
|
|
||||||
|
|
||||||
interface IWindowCOnfig {
|
interface IWindowCOnfig {
|
||||||
title: string | undefined;
|
title: string | undefined;
|
||||||
@ -158,6 +157,10 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
|
|
||||||
if (!ignoreEmit) {
|
if (!ignoreEmit) {
|
||||||
this.emitter.emit('window.change.view.type', name);
|
this.emitter.emit('window.change.view.type', name);
|
||||||
|
|
||||||
|
if (this.id === this.workspace.window.id) {
|
||||||
|
this.workspace.emitChangeActiveEditorView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.editorView.setActivate(true);
|
this.editorView.setActivate(true);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,6 +13,8 @@ enum EVENT {
|
|||||||
CHANGE_ACTIVE_WINDOW = 'change_active_window',
|
CHANGE_ACTIVE_WINDOW = 'change_active_window',
|
||||||
|
|
||||||
WINDOW_RENDER_READY = 'window_render_ready',
|
WINDOW_RENDER_READY = 'window_render_ready',
|
||||||
|
|
||||||
|
CHANGE_ACTIVE_EDITOR_VIEW = 'change_active_editor_view',
|
||||||
}
|
}
|
||||||
|
|
||||||
const CHANGE_EVENT = 'resource.list.change';
|
const CHANGE_EVENT = 'resource.list.change';
|
||||||
@ -42,6 +44,10 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
|
|||||||
initWindow(): void;
|
initWindow(): void;
|
||||||
|
|
||||||
setActive(active: boolean): void;
|
setActive(active: boolean): void;
|
||||||
|
|
||||||
|
onChangeActiveEditorView(fn: () => void): IPublicTypeDisposable;
|
||||||
|
|
||||||
|
emitChangeActiveEditorView(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Workspace implements IWorkspace {
|
export class Workspace implements IWorkspace {
|
||||||
@ -258,12 +264,24 @@ export class Workspace implements IWorkspace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangeActiveEditorView(fn: () => void) {
|
||||||
|
this.emitter.on(EVENT.CHANGE_ACTIVE_EDITOR_VIEW, fn);
|
||||||
|
return () => {
|
||||||
|
this.emitter.removeListener(EVENT.CHANGE_ACTIVE_EDITOR_VIEW, fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
emitChangeActiveEditorView() {
|
||||||
|
this.emitter.emit(EVENT.CHANGE_ACTIVE_EDITOR_VIEW);
|
||||||
|
}
|
||||||
|
|
||||||
emitChangeWindow() {
|
emitChangeWindow() {
|
||||||
this.emitter.emit(EVENT.CHANGE_WINDOW);
|
this.emitter.emit(EVENT.CHANGE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
emitChangeActiveWindow() {
|
emitChangeActiveWindow() {
|
||||||
this.emitter.emit(EVENT.CHANGE_ACTIVE_WINDOW);
|
this.emitter.emit(EVENT.CHANGE_ACTIVE_WINDOW);
|
||||||
|
this.emitChangeActiveEditorView();
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeActiveWindow(fn: () => void) {
|
onChangeActiveWindow(fn: () => void) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user