mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-05 09:47:20 +00:00
Merge remote-tracking branch 'origin/develop' into release/1.1.7-beta
This commit is contained in:
commit
abbd0b525d
@ -62,11 +62,11 @@ delete(node: IPublicModelNode): boolean;
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
/**
|
/**
|
||||||
* 删除指定节点
|
* 插入一个节点
|
||||||
* delete the node
|
* insert the node
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
delete(node: IPublicModelNode): boolean;
|
insert(node: IPublicModelNode): boolean;
|
||||||
```
|
```
|
||||||
|
|
||||||
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
|
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
|
||||||
|
|||||||
@ -45,6 +45,8 @@ sidebar_position: 12
|
|||||||
|
|
||||||
关联模型 [IPublicModelEditorView](./editor-view)
|
关联模型 [IPublicModelEditorView](./editor-view)
|
||||||
|
|
||||||
|
**@since v1.1.7**
|
||||||
|
|
||||||
### editorViews
|
### editorViews
|
||||||
|
|
||||||
窗口所有视图
|
窗口所有视图
|
||||||
@ -53,6 +55,7 @@ sidebar_position: 12
|
|||||||
|
|
||||||
关联模型 [IPublicModelEditorView](./editor-view)
|
关联模型 [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)
|
相关类型:[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**
|
||||||
|
|||||||
@ -106,6 +106,11 @@ function processChildren(schema: IPublicTypeNodeSchema): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInternalDep(internalDeps: Record<string, IInternalDependency>, depName: string) {
|
||||||
|
const dep = internalDeps[depName];
|
||||||
|
return (dep && dep.type !== InternalDependencyType.PAGE) ? dep : null;
|
||||||
|
}
|
||||||
|
|
||||||
export class SchemaParser implements ISchemaParser {
|
export class SchemaParser implements ISchemaParser {
|
||||||
validate(schema: IPublicTypeProjectSchema): boolean {
|
validate(schema: IPublicTypeProjectSchema): boolean {
|
||||||
if (SUPPORT_SCHEMA_VERSION_LIST.indexOf(schema.version) < 0) {
|
if (SUPPORT_SCHEMA_VERSION_LIST.indexOf(schema.version) < 0) {
|
||||||
@ -221,12 +226,11 @@ export class SchemaParser implements ISchemaParser {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 分析容器内部组件依赖
|
|
||||||
containers.forEach((container) => {
|
containers.forEach((container) => {
|
||||||
const depNames = this.getComponentNames(container);
|
const depNames = this.getComponentNames(container);
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
container.deps = uniqueArray<string>(depNames, (i: string) => i)
|
container.deps = uniqueArray<string>(depNames, (i: string) => i)
|
||||||
.map((depName) => internalDeps[depName] || compDeps[depName])
|
.map((depName) => getInternalDep(internalDeps, depName) || compDeps[depName])
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
|
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,6 +21,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
|
|
||||||
if (ir && ir.deps && ir.deps.length > 0) {
|
if (ir && ir.deps && ir.deps.length > 0) {
|
||||||
let lowcodeMaterialsStyleAdded = false;
|
let lowcodeMaterialsStyleAdded = false;
|
||||||
|
let fusionUIStyleAdded = false;
|
||||||
let nextStyleAddedMap: Record<string, boolean> = {};
|
let nextStyleAddedMap: Record<string, boolean> = {};
|
||||||
ir.deps.forEach((dep: any) => {
|
ir.deps.forEach((dep: any) => {
|
||||||
if (dep.package === '@alifd/next' && !nextStyleAddedMap[dep.exportName]) {
|
if (dep.package === '@alifd/next' && !nextStyleAddedMap[dep.exportName]) {
|
||||||
@ -41,6 +42,15 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
|||||||
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport],
|
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport],
|
||||||
});
|
});
|
||||||
lowcodeMaterialsStyleAdded = true;
|
lowcodeMaterialsStyleAdded = true;
|
||||||
|
} else if (dep.package === '@alifd/fusion-ui' && !fusionUIStyleAdded) {
|
||||||
|
chunks.push({
|
||||||
|
type: ChunkType.STRING,
|
||||||
|
fileType: FileType.JSX,
|
||||||
|
name: COMMON_CHUNK_NAME.InternalDepsImport,
|
||||||
|
content: 'import \'@alifd/fusion-ui/lib/style\';',
|
||||||
|
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport],
|
||||||
|
});
|
||||||
|
fusionUIStyleAdded = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/low
|
|||||||
import { MasterPaneName, BackupPaneName } from './helper/consts';
|
import { MasterPaneName, BackupPaneName } from './helper/consts';
|
||||||
import { TreeMaster } from './controllers/tree-master';
|
import { TreeMaster } from './controllers/tree-master';
|
||||||
import { PaneController } from './controllers/pane-controller';
|
import { PaneController } from './controllers/pane-controller';
|
||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
export function OutlinePaneContext(props: {
|
export function OutlinePaneContext(props: {
|
||||||
treeMaster?: TreeMaster;
|
treeMaster?: TreeMaster;
|
||||||
@ -19,9 +19,11 @@ export function OutlinePaneContext(props: {
|
|||||||
}) {
|
}) {
|
||||||
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
|
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
|
||||||
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
||||||
treeMaster.onPluginContextChange(() => {
|
useEffect(() => {
|
||||||
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
return treeMaster.onPluginContextChange(() => {
|
||||||
});
|
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pane
|
<Pane
|
||||||
|
|||||||
@ -17,7 +17,9 @@ export class Pane extends PureComponent<{
|
|||||||
}> {
|
}> {
|
||||||
private controller;
|
private controller;
|
||||||
|
|
||||||
private dispose: IPublicTypeDisposable;
|
private simulatorRendererReadyDispose: IPublicTypeDisposable;
|
||||||
|
private changeDocumentDispose: IPublicTypeDisposable;
|
||||||
|
private removeDocumentDispose: IPublicTypeDisposable;
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -26,16 +28,22 @@ export class Pane extends PureComponent<{
|
|||||||
this.state = {
|
this.state = {
|
||||||
tree: treeMaster.currentTree,
|
tree: treeMaster.currentTree,
|
||||||
};
|
};
|
||||||
this.dispose = this.props.treeMaster.pluginContext?.project?.onSimulatorRendererReady(() => {
|
this.simulatorRendererReadyDispose = this.props.treeMaster.pluginContext?.project?.onSimulatorRendererReady(this.changeTree);
|
||||||
this.setState({
|
this.changeDocumentDispose = this.props.treeMaster.pluginContext?.project?.onChangeDocument(this.changeTree);
|
||||||
tree: this.props.treeMaster.currentTree,
|
this.removeDocumentDispose = this.props.treeMaster.pluginContext?.project?.onRemoveDocument(this.changeTree);
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeTree = () => {
|
||||||
|
this.setState({
|
||||||
|
tree: this.props.treeMaster.currentTree,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.controller.purge();
|
this.controller.purge();
|
||||||
this.dispose && this.dispose();
|
this.simulatorRendererReadyDispose?.();
|
||||||
|
this.changeDocumentDispose?.();
|
||||||
|
this.removeDocumentDispose?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -13,7 +13,13 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get target() {
|
get target() {
|
||||||
const { node: innerNode, detail, instance } = this[activeTrackerSymbol]._target;
|
const _target = this[activeTrackerSymbol]._target;
|
||||||
|
|
||||||
|
if (!_target) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { node: innerNode, detail, instance } = _target;
|
||||||
const publicNode = ShellNode.create(innerNode);
|
const publicNode = ShellNode.create(innerNode);
|
||||||
return {
|
return {
|
||||||
node: publicNode!,
|
node: publicNode!,
|
||||||
|
|||||||
@ -43,6 +43,10 @@ export class Window implements IPublicModelWindow {
|
|||||||
return await this[windowSymbol].save();
|
return await this[windowSymbol].save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSave(fn: () => void) {
|
||||||
|
return this[windowSymbol].onSave(fn);
|
||||||
|
}
|
||||||
|
|
||||||
get currentEditorView() {
|
get currentEditorView() {
|
||||||
if (this[windowSymbol].editorView) {
|
if (this[windowSymbol].editorView) {
|
||||||
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
|
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export interface IPublicModelActiveTracker {
|
|||||||
/**
|
/**
|
||||||
* @since 1.1.7
|
* @since 1.1.7
|
||||||
*/
|
*/
|
||||||
target: IPublicTypeActiveTarget;
|
target: IPublicTypeActiveTarget | null;
|
||||||
|
|
||||||
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void;
|
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void;
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import {
|
|||||||
IPublicApiWorkspace,
|
IPublicApiWorkspace,
|
||||||
} from '../api';
|
} from '../api';
|
||||||
import { IPublicEnumPluginRegisterLevel } from '../enum';
|
import { IPublicEnumPluginRegisterLevel } from '../enum';
|
||||||
import { IPublicModelEngineConfig, IPublicModelEditorView } from './';
|
import { IPublicModelEngineConfig, IPublicModelWindow } from './';
|
||||||
|
|
||||||
export interface IPublicModelPluginContext {
|
export interface IPublicModelPluginContext {
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ export interface IPublicModelPluginContext {
|
|||||||
*/
|
*/
|
||||||
get registerLevel(): IPublicEnumPluginRegisterLevel;
|
get registerLevel(): IPublicEnumPluginRegisterLevel;
|
||||||
|
|
||||||
get editorWindow(): IPublicModelEditorView;
|
get editorWindow(): IPublicModelWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -42,4 +42,10 @@ export interface IPublicModelWindow<
|
|||||||
|
|
||||||
/** 窗口视图变更事件 */
|
/** 窗口视图变更事件 */
|
||||||
onChangeViewType(fn: (viewName: string) => void): IPublicTypeDisposable;
|
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();
|
const saveResult = await this.editorViews.get(name)?.save();
|
||||||
value[name] = saveResult;
|
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() {
|
async init() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user