mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-04 17:27:09 +00:00
Merge remote-tracking branch 'origin/develop' into release/1.1.4-beta
This commit is contained in:
commit
1c8df62754
@ -342,14 +342,6 @@ export class DocumentModel implements IDocumentModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChangeNodeVisible(fn: (node: INode, visible: boolean) => void): IPublicTypeDisposable {
|
onChangeNodeVisible(fn: (node: INode, visible: boolean) => void): IPublicTypeDisposable {
|
||||||
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_CHILDREN_CHANGE, fn);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
this.designer.editor?.eventBus.off(EDITOR_EVENT.NODE_CHILDREN_CHANGE, fn);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions<INode>) => void): IPublicTypeDisposable {
|
|
||||||
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_VISIBLE_CHANGE, fn);
|
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_VISIBLE_CHANGE, fn);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@ -357,6 +349,14 @@ export class DocumentModel implements IDocumentModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions<INode>) => void): IPublicTypeDisposable {
|
||||||
|
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_CHILDREN_CHANGE, fn);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
this.designer.editor?.eventBus.off(EDITOR_EVENT.NODE_CHILDREN_CHANGE, fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
addWillPurge(node: INode) {
|
addWillPurge(node: INode) {
|
||||||
this.willPurgeSpace.push(node);
|
this.willPurgeSpace.push(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,11 +98,11 @@ export interface IBaseNode<Schema extends IPublicTypeNodeSchema = IPublicTypeNod
|
|||||||
/**
|
/**
|
||||||
* 导出 schema
|
* 导出 schema
|
||||||
*/
|
*/
|
||||||
export<T = IPublicTypeNodeSchema>(stage: IPublicEnumTransformStage, options?: any): T;
|
export<T = Schema>(stage: IPublicEnumTransformStage, options?: any): T;
|
||||||
|
|
||||||
emitPropChange(val: IPublicTypePropChangeOptions): void;
|
emitPropChange(val: IPublicTypePropChangeOptions): void;
|
||||||
|
|
||||||
import(data: IPublicTypeNodeSchema, checkId?: boolean): void;
|
import(data: Schema, checkId?: boolean): void;
|
||||||
|
|
||||||
internalSetSlotFor(slotFor: Prop | null | undefined): void;
|
internalSetSlotFor(slotFor: Prop | null | undefined): void;
|
||||||
|
|
||||||
@ -394,7 +394,10 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
|||||||
editor?.eventBus.emit(EDITOR_EVENT.NODE_VISIBLE_CHANGE, this, visible);
|
editor?.eventBus.emit(EDITOR_EVENT.NODE_VISIBLE_CHANGE, this, visible);
|
||||||
});
|
});
|
||||||
this.onChildrenChange((info?: { type: string; node: INode }) => {
|
this.onChildrenChange((info?: { type: string; node: INode }) => {
|
||||||
editor?.eventBus.emit(EDITOR_EVENT.NODE_VISIBLE_CHANGE, info);
|
editor?.eventBus.emit(EDITOR_EVENT.NODE_CHILDREN_CHANGE, {
|
||||||
|
type: info?.type,
|
||||||
|
node: this,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,23 +20,10 @@ export class Tree {
|
|||||||
const doc = this.pluginContext.project.currentDocument;
|
const doc = this.pluginContext.project.currentDocument;
|
||||||
this.id = doc?.id;
|
this.id = doc?.id;
|
||||||
|
|
||||||
doc?.onMountNode((payload: {node: IPublicModelNode }) => {
|
doc?.onChangeNodeChildren((info: {node: IPublicModelNode }) => {
|
||||||
const { node } = payload;
|
const { node } = info;
|
||||||
const parentNode = node.parent;
|
const treeNode = this.getTreeNodeById(node.id);
|
||||||
if (!parentNode) {
|
treeNode?.notifyExpandableChanged();
|
||||||
return;
|
|
||||||
}
|
|
||||||
const parentTreeNode = this.getTreeNodeById(parentNode.id);
|
|
||||||
parentTreeNode?.notifyExpandableChanged();
|
|
||||||
});
|
|
||||||
|
|
||||||
doc?.onRemoveNode((node: IPublicModelNode) => {
|
|
||||||
const parentNode = node.parent;
|
|
||||||
if (!parentNode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const parentTreeNode = this.getTreeNodeById(parentNode.id);
|
|
||||||
parentTreeNode?.notifyExpandableChanged();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export default class TreeBranches extends PureComponent<{
|
|||||||
isModal?: boolean;
|
isModal?: boolean;
|
||||||
pluginContext: IPublicModelPluginContext;
|
pluginContext: IPublicModelPluginContext;
|
||||||
expanded: boolean;
|
expanded: boolean;
|
||||||
|
treeChildren: TreeNode[] | null;
|
||||||
}> {
|
}> {
|
||||||
state = {
|
state = {
|
||||||
filterWorking: false,
|
filterWorking: false,
|
||||||
@ -56,13 +57,13 @@ export default class TreeBranches extends PureComponent<{
|
|||||||
treeNode={treeNode}
|
treeNode={treeNode}
|
||||||
isModal={isModal || false}
|
isModal={isModal || false}
|
||||||
pluginContext={this.props.pluginContext}
|
pluginContext={this.props.pluginContext}
|
||||||
|
treeChildren={this.props.treeChildren}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface ITreeNodeChildrenState {
|
interface ITreeNodeChildrenState {
|
||||||
filterWorking: boolean;
|
filterWorking: boolean;
|
||||||
matchSelf: boolean;
|
matchSelf: boolean;
|
||||||
@ -73,6 +74,7 @@ class TreeNodeChildren extends PureComponent<{
|
|||||||
treeNode: TreeNode;
|
treeNode: TreeNode;
|
||||||
isModal?: boolean;
|
isModal?: boolean;
|
||||||
pluginContext: IPublicModelPluginContext;
|
pluginContext: IPublicModelPluginContext;
|
||||||
|
treeChildren: TreeNode[] | null;
|
||||||
}, ITreeNodeChildrenState> {
|
}, ITreeNodeChildrenState> {
|
||||||
state: ITreeNodeChildrenState = {
|
state: ITreeNodeChildrenState = {
|
||||||
filterWorking: false,
|
filterWorking: false,
|
||||||
@ -115,7 +117,7 @@ class TreeNodeChildren extends PureComponent<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { treeNode, isModal } = this.props;
|
const { isModal } = this.props;
|
||||||
const children: any = [];
|
const children: any = [];
|
||||||
let groupContents: any[] = [];
|
let groupContents: any[] = [];
|
||||||
let currentGrp: IPublicModelExclusiveGroup;
|
let currentGrp: IPublicModelExclusiveGroup;
|
||||||
@ -150,7 +152,7 @@ class TreeNodeChildren extends PureComponent<{
|
|||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
treeNode.children?.forEach((child, index) => {
|
this.props.treeChildren?.forEach((child, index) => {
|
||||||
const childIsModal = child.node.componentMeta?.isModal || false;
|
const childIsModal = child.node.componentMeta?.isModal || false;
|
||||||
if (isModal != childIsModal) {
|
if (isModal != childIsModal) {
|
||||||
return;
|
return;
|
||||||
@ -178,7 +180,7 @@ class TreeNodeChildren extends PureComponent<{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
endGroup();
|
endGroup();
|
||||||
const length = treeNode.children?.length || 0;
|
const length = this.props.treeChildren?.length || 0;
|
||||||
if (dropIndex != null && dropIndex >= length) {
|
if (dropIndex != null && dropIndex >= length) {
|
||||||
children.push(insertion);
|
children.push(insertion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import TreeNode from '../controllers/tree-node';
|
|||||||
import TreeTitle from './tree-title';
|
import TreeTitle from './tree-title';
|
||||||
import TreeBranches from './tree-branches';
|
import TreeBranches from './tree-branches';
|
||||||
import { IconEyeClose } from '../icons/eye-close';
|
import { IconEyeClose } from '../icons/eye-close';
|
||||||
import { IPublicModelPluginContext, IPublicModelModalNodesManager, IPublicModelDocumentModel, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
import { IPublicModelPluginContext, IPublicModelModalNodesManager, IPublicTypeDisposable } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
class ModalTreeNodeView extends PureComponent<{
|
class ModalTreeNodeView extends PureComponent<{
|
||||||
treeNode: TreeNode;
|
treeNode: TreeNode;
|
||||||
@ -49,6 +49,7 @@ class ModalTreeNodeView extends PureComponent<{
|
|||||||
<div className="tree-pane-modal-content">
|
<div className="tree-pane-modal-content">
|
||||||
<TreeBranches
|
<TreeBranches
|
||||||
treeNode={rootTreeNode}
|
treeNode={rootTreeNode}
|
||||||
|
treeChildren={rootTreeNode.children}
|
||||||
expanded={expanded}
|
expanded={expanded}
|
||||||
isModal
|
isModal
|
||||||
pluginContext={this.pluginContext}
|
pluginContext={this.pluginContext}
|
||||||
@ -65,7 +66,19 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
pluginContext: IPublicModelPluginContext;
|
pluginContext: IPublicModelPluginContext;
|
||||||
isRootNode?: boolean;
|
isRootNode?: boolean;
|
||||||
}> {
|
}> {
|
||||||
state = {
|
state: {
|
||||||
|
expanded: boolean;
|
||||||
|
selected: boolean;
|
||||||
|
hidden: boolean;
|
||||||
|
locked: boolean;
|
||||||
|
detecting: boolean;
|
||||||
|
isRoot: boolean;
|
||||||
|
highlight: boolean;
|
||||||
|
dropping: boolean;
|
||||||
|
conditionFlow: boolean;
|
||||||
|
expandable: boolean;
|
||||||
|
treeChildren: TreeNode[] | null;
|
||||||
|
} = {
|
||||||
expanded: false,
|
expanded: false,
|
||||||
selected: false,
|
selected: false,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
@ -76,6 +89,7 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
dropping: false,
|
dropping: false,
|
||||||
conditionFlow: false,
|
conditionFlow: false,
|
||||||
expandable: false,
|
expandable: false,
|
||||||
|
treeChildren: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
eventOffCallbacks: Array<IPublicTypeDisposable | undefined> = [];
|
eventOffCallbacks: Array<IPublicTypeDisposable | undefined> = [];
|
||||||
@ -95,6 +109,7 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
conditionFlow: treeNode.node.conditionGroup != null,
|
conditionFlow: treeNode.node.conditionGroup != null,
|
||||||
highlight: treeNode.isFocusingNode(),
|
highlight: treeNode.isFocusingNode(),
|
||||||
expandable: treeNode.expandable,
|
expandable: treeNode.expandable,
|
||||||
|
treeChildren: treeNode.children,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,11 +129,13 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
this.setState({ locked });
|
this.setState({ locked });
|
||||||
});
|
});
|
||||||
treeNode.onExpandableChanged((expandable: boolean) => {
|
treeNode.onExpandableChanged((expandable: boolean) => {
|
||||||
this.setState({ expandable });
|
this.setState({
|
||||||
|
expandable,
|
||||||
|
treeChildren: treeNode.children,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.eventOffCallbacks.push(
|
this.eventOffCallbacks.push(
|
||||||
doc?.onDropLocationChanged((document: IPublicModelDocumentModel) => {
|
doc?.onDropLocationChanged(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
dropping: treeNode.dropDetail?.index != null,
|
dropping: treeNode.dropDetail?.index != null,
|
||||||
});
|
});
|
||||||
@ -210,6 +227,7 @@ export default class TreeNodeView extends PureComponent<{
|
|||||||
isModal={false}
|
isModal={false}
|
||||||
expanded={this.state.expanded}
|
expanded={this.state.expanded}
|
||||||
pluginContext={this.props.pluginContext}
|
pluginContext={this.props.pluginContext}
|
||||||
|
treeChildren={this.state.treeChildren}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -300,7 +300,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
|||||||
* @param fn
|
* @param fn
|
||||||
*/
|
*/
|
||||||
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): IPublicTypeDisposable {
|
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): IPublicTypeDisposable {
|
||||||
return this[documentSymbol].onChangeNodeChildren((info?: IPublicTypeOnChangeOptions) => {
|
return this[documentSymbol].onChangeNodeChildren((info?: IPublicTypeOnChangeOptions<InnerNode>) => {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import {
|
|||||||
ILowCodePluginManager,
|
ILowCodePluginManager,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import {
|
import {
|
||||||
|
ISkeleton,
|
||||||
Skeleton as InnerSkeleton,
|
Skeleton as InnerSkeleton,
|
||||||
} from '@alilc/lowcode-editor-skeleton';
|
} from '@alilc/lowcode-editor-skeleton';
|
||||||
import {
|
import {
|
||||||
@ -65,7 +66,7 @@ export interface IBasicContext extends Omit<IPublicModelPluginContext, 'workspac
|
|||||||
designer: IDesigner;
|
designer: IDesigner;
|
||||||
registerInnerPlugins: () => Promise<void>;
|
registerInnerPlugins: () => Promise<void>;
|
||||||
innerSetters: InnerSetters;
|
innerSetters: InnerSetters;
|
||||||
innerSkeleton: InnerSkeleton;
|
innerSkeleton: ISkeleton;
|
||||||
innerHotkey: IHotKey;
|
innerHotkey: IHotKey;
|
||||||
innerPlugins: ILowCodePluginManager;
|
innerPlugins: ILowCodePluginManager;
|
||||||
canvas: IPublicApiCanvas;
|
canvas: IPublicApiCanvas;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
|
|||||||
|
|
||||||
export function DesignerView(props: {
|
export function DesignerView(props: {
|
||||||
url: string;
|
url: string;
|
||||||
viewName: string;
|
viewName?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="lc-designer lowcode-plugin-designer">
|
<div className="lc-designer lowcode-plugin-designer">
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { ISkeleton } from '@alilc/lowcode-editor-skeleton';
|
||||||
import { IPublicTypeEditorView, IPublicResourceData, IPublicResourceTypeConfig, IBaseModelResource } from '@alilc/lowcode-types';
|
import { IPublicTypeEditorView, IPublicResourceData, IPublicResourceTypeConfig, IBaseModelResource } from '@alilc/lowcode-types';
|
||||||
import { Logger } from '@alilc/lowcode-utils';
|
import { Logger } from '@alilc/lowcode-utils';
|
||||||
import { BasicContext, IBasicContext } from './context/base-context';
|
import { BasicContext, IBasicContext } from './context/base-context';
|
||||||
@ -9,6 +10,8 @@ const logger = new Logger({ level: 'warn', bizName: 'workspace:resource' });
|
|||||||
export interface IBaseResource<T> extends IBaseModelResource<T> {
|
export interface IBaseResource<T> extends IBaseModelResource<T> {
|
||||||
readonly resourceType: ResourceType;
|
readonly resourceType: ResourceType;
|
||||||
|
|
||||||
|
skeleton: ISkeleton;
|
||||||
|
|
||||||
get editorViews(): IPublicTypeEditorView[];
|
get editorViews(): IPublicTypeEditorView[];
|
||||||
|
|
||||||
get defaultViewType(): string;
|
get defaultViewType(): string;
|
||||||
@ -68,7 +71,7 @@ export class Resource implements IResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get children(): IResource[] {
|
get children(): IResource[] {
|
||||||
return this.resourceData?.children?.map(d => new Resource(d, this.resourceType, this.workspace)) || [];
|
return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
|
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
|
||||||
|
|||||||
@ -2,14 +2,14 @@ import { PureComponent } from 'react';
|
|||||||
import { EditorView } from './editor-view';
|
import { EditorView } from './editor-view';
|
||||||
import { observer } from '@alilc/lowcode-editor-core';
|
import { observer } from '@alilc/lowcode-editor-core';
|
||||||
import TopArea from '../layouts/top-area';
|
import TopArea from '../layouts/top-area';
|
||||||
import { Resource } from '../resource';
|
import { IResource } from '../resource';
|
||||||
import { EditorWindow } from '../window';
|
import { IEditorWindow } from '../window';
|
||||||
import './resource-view.less';
|
import './resource-view.less';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ResourceView extends PureComponent<{
|
export class ResourceView extends PureComponent<{
|
||||||
window: EditorWindow;
|
window: IEditorWindow;
|
||||||
resource: Resource;
|
resource: IResource;
|
||||||
}, any> {
|
}, any> {
|
||||||
render() {
|
render() {
|
||||||
const { skeleton } = this.props.resource;
|
const { skeleton } = this.props.resource;
|
||||||
|
|||||||
@ -15,6 +15,8 @@ interface IWindowCOnfig {
|
|||||||
export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'changeViewType'> {
|
export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'changeViewType'> {
|
||||||
readonly resource: IResource;
|
readonly resource: IResource;
|
||||||
|
|
||||||
|
editorViews: Map<string, Context>;
|
||||||
|
|
||||||
changeViewType: (name: string, ignoreEmit?: boolean) => void;
|
changeViewType: (name: string, ignoreEmit?: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,8 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
|
|||||||
plugins: ILowCodePluginManager;
|
plugins: ILowCodePluginManager;
|
||||||
|
|
||||||
getResourceList(): IResource[];
|
getResourceList(): IResource[];
|
||||||
|
|
||||||
|
getResourceType(resourceName: string): IResourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Workspace implements IWorkspace {
|
export class Workspace implements IWorkspace {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user