mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
feat: workspace window add onSave api
This commit is contained in:
parent
62288a139f
commit
b984ef72d2
@ -45,6 +45,8 @@ sidebar_position: 12
|
||||
|
||||
关联模型 [IPublicModelEditorView](./editor-view)
|
||||
|
||||
**@since v1.1.7**
|
||||
|
||||
### editorViews
|
||||
|
||||
窗口所有视图
|
||||
@ -53,6 +55,7 @@ sidebar_position: 12
|
||||
|
||||
关联模型 [IPublicModelEditorView](./editor-view)
|
||||
|
||||
**@since v1.1.7**
|
||||
|
||||
## 方法
|
||||
|
||||
@ -90,3 +93,15 @@ onChangeViewType(fn: (viewName: string) => void): IPublicTypeDisposable;
|
||||
```
|
||||
|
||||
相关类型:[IPublicTypeDisposable](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/disposable.ts)
|
||||
|
||||
### onSave
|
||||
|
||||
窗口视图保存事件
|
||||
|
||||
```
|
||||
onSave(fn: () => void): IPublicTypeDisposable;
|
||||
```
|
||||
|
||||
相关类型:[IPublicTypeDisposable](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/disposable.ts)
|
||||
|
||||
**@since v1.1.7**
|
||||
|
||||
@ -4,7 +4,7 @@ import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/low
|
||||
import { MasterPaneName, BackupPaneName } from './helper/consts';
|
||||
import { TreeMaster } from './controllers/tree-master';
|
||||
import { PaneController } from './controllers/pane-controller';
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export function OutlinePaneContext(props: {
|
||||
treeMaster?: TreeMaster;
|
||||
@ -19,9 +19,11 @@ export function OutlinePaneContext(props: {
|
||||
}) {
|
||||
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
|
||||
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
||||
treeMaster.onPluginContextChange(() => {
|
||||
useEffect(() => {
|
||||
return treeMaster.onPluginContextChange(() => {
|
||||
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Pane
|
||||
|
||||
@ -43,6 +43,10 @@ export class Window implements IPublicModelWindow {
|
||||
return await this[windowSymbol].save();
|
||||
}
|
||||
|
||||
onSave(fn: () => void) {
|
||||
return this[windowSymbol].onSave(fn);
|
||||
}
|
||||
|
||||
get currentEditorView() {
|
||||
if (this[windowSymbol].editorView) {
|
||||
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
IPublicApiWorkspace,
|
||||
} from '../api';
|
||||
import { IPublicEnumPluginRegisterLevel } from '../enum';
|
||||
import { IPublicModelEngineConfig, IPublicModelEditorView } from './';
|
||||
import { IPublicModelEngineConfig, IPublicModelWindow } from './';
|
||||
|
||||
export interface IPublicModelPluginContext {
|
||||
|
||||
@ -108,7 +108,7 @@ export interface IPublicModelPluginContext {
|
||||
*/
|
||||
get registerLevel(): IPublicEnumPluginRegisterLevel;
|
||||
|
||||
get editorWindow(): IPublicModelEditorView;
|
||||
get editorWindow(): IPublicModelWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -42,4 +42,10 @@ export interface IPublicModelWindow<
|
||||
|
||||
/** 窗口视图变更事件 */
|
||||
onChangeViewType(fn: (viewName: string) => void): IPublicTypeDisposable;
|
||||
|
||||
/**
|
||||
* 窗口视图保存事件
|
||||
* @since 1.1.7
|
||||
*/
|
||||
onSave(fn: () => void): IPublicTypeDisposable;
|
||||
}
|
||||
@ -77,7 +77,18 @@ export class EditorWindow implements IEditorWindow {
|
||||
const saveResult = await this.editorViews.get(name)?.save();
|
||||
value[name] = saveResult;
|
||||
}
|
||||
return await this.resource.save(value);
|
||||
const result = await this.resource.save(value);
|
||||
this.emitter.emit('handle.save');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
onSave(fn: () => void) {
|
||||
this.emitter.on('handle.save', fn);
|
||||
|
||||
return () => {
|
||||
this.emitter.off('handle.save', fn);
|
||||
};
|
||||
}
|
||||
|
||||
async init() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user