Merge remote-tracking branch 'origin/develop' into release/1.1.4-beta

This commit is contained in:
JackLian 2023-03-22 09:14:50 +08:00
commit 1c8df62754
12 changed files with 63 additions and 45 deletions

View File

@ -342,14 +342,6 @@ export class DocumentModel implements IDocumentModel {
}
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);
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) {
this.willPurgeSpace.push(node);
}

View File

@ -98,11 +98,11 @@ export interface IBaseNode<Schema extends IPublicTypeNodeSchema = IPublicTypeNod
/**
* schema
*/
export<T = IPublicTypeNodeSchema>(stage: IPublicEnumTransformStage, options?: any): T;
export<T = Schema>(stage: IPublicEnumTransformStage, options?: any): T;
emitPropChange(val: IPublicTypePropChangeOptions): void;
import(data: IPublicTypeNodeSchema, checkId?: boolean): void;
import(data: Schema, checkId?: boolean): 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);
});
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,
});
});
}

View File

@ -20,23 +20,10 @@ export class Tree {
const doc = this.pluginContext.project.currentDocument;
this.id = doc?.id;
doc?.onMountNode((payload: {node: IPublicModelNode }) => {
const { node } = payload;
const parentNode = node.parent;
if (!parentNode) {
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();
doc?.onChangeNodeChildren((info: {node: IPublicModelNode }) => {
const { node } = info;
const treeNode = this.getTreeNodeById(node.id);
treeNode?.notifyExpandableChanged();
});
}

View File

@ -9,6 +9,7 @@ export default class TreeBranches extends PureComponent<{
isModal?: boolean;
pluginContext: IPublicModelPluginContext;
expanded: boolean;
treeChildren: TreeNode[] | null;
}> {
state = {
filterWorking: false,
@ -56,13 +57,13 @@ export default class TreeBranches extends PureComponent<{
treeNode={treeNode}
isModal={isModal || false}
pluginContext={this.props.pluginContext}
treeChildren={this.props.treeChildren}
/>
</div>
);
}
}
interface ITreeNodeChildrenState {
filterWorking: boolean;
matchSelf: boolean;
@ -73,6 +74,7 @@ class TreeNodeChildren extends PureComponent<{
treeNode: TreeNode;
isModal?: boolean;
pluginContext: IPublicModelPluginContext;
treeChildren: TreeNode[] | null;
}, ITreeNodeChildrenState> {
state: ITreeNodeChildrenState = {
filterWorking: false,
@ -115,7 +117,7 @@ class TreeNodeChildren extends PureComponent<{
}
render() {
const { treeNode, isModal } = this.props;
const { isModal } = this.props;
const children: any = [];
let groupContents: any[] = [];
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;
if (isModal != childIsModal) {
return;
@ -178,7 +180,7 @@ class TreeNodeChildren extends PureComponent<{
}
});
endGroup();
const length = treeNode.children?.length || 0;
const length = this.props.treeChildren?.length || 0;
if (dropIndex != null && dropIndex >= length) {
children.push(insertion);
}

View File

@ -4,7 +4,7 @@ import TreeNode from '../controllers/tree-node';
import TreeTitle from './tree-title';
import TreeBranches from './tree-branches';
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<{
treeNode: TreeNode;
@ -49,6 +49,7 @@ class ModalTreeNodeView extends PureComponent<{
<div className="tree-pane-modal-content">
<TreeBranches
treeNode={rootTreeNode}
treeChildren={rootTreeNode.children}
expanded={expanded}
isModal
pluginContext={this.pluginContext}
@ -65,7 +66,19 @@ export default class TreeNodeView extends PureComponent<{
pluginContext: IPublicModelPluginContext;
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,
selected: false,
hidden: false,
@ -76,6 +89,7 @@ export default class TreeNodeView extends PureComponent<{
dropping: false,
conditionFlow: false,
expandable: false,
treeChildren: [],
};
eventOffCallbacks: Array<IPublicTypeDisposable | undefined> = [];
@ -95,6 +109,7 @@ export default class TreeNodeView extends PureComponent<{
conditionFlow: treeNode.node.conditionGroup != null,
highlight: treeNode.isFocusingNode(),
expandable: treeNode.expandable,
treeChildren: treeNode.children,
};
}
@ -114,11 +129,13 @@ export default class TreeNodeView extends PureComponent<{
this.setState({ locked });
});
treeNode.onExpandableChanged((expandable: boolean) => {
this.setState({ expandable });
this.setState({
expandable,
treeChildren: treeNode.children,
});
});
this.eventOffCallbacks.push(
doc?.onDropLocationChanged((document: IPublicModelDocumentModel) => {
doc?.onDropLocationChanged(() => {
this.setState({
dropping: treeNode.dropDetail?.index != null,
});
@ -210,6 +227,7 @@ export default class TreeNodeView extends PureComponent<{
isModal={false}
expanded={this.state.expanded}
pluginContext={this.props.pluginContext}
treeChildren={this.state.treeChildren}
/>
</div>
);

View File

@ -300,7 +300,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
* @param fn
*/
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): IPublicTypeDisposable {
return this[documentSymbol].onChangeNodeChildren((info?: IPublicTypeOnChangeOptions) => {
return this[documentSymbol].onChangeNodeChildren((info?: IPublicTypeOnChangeOptions<InnerNode>) => {
if (!info) {
return;
}

View File

@ -16,6 +16,7 @@ import {
ILowCodePluginManager,
} from '@alilc/lowcode-designer';
import {
ISkeleton,
Skeleton as InnerSkeleton,
} from '@alilc/lowcode-editor-skeleton';
import {
@ -65,7 +66,7 @@ export interface IBasicContext extends Omit<IPublicModelPluginContext, 'workspac
designer: IDesigner;
registerInnerPlugins: () => Promise<void>;
innerSetters: InnerSetters;
innerSkeleton: InnerSkeleton;
innerSkeleton: ISkeleton;
innerHotkey: IHotKey;
innerPlugins: ILowCodePluginManager;
canvas: IPublicApiCanvas;

View File

@ -2,7 +2,7 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
export function DesignerView(props: {
url: string;
viewName: string;
viewName?: string;
}) {
return (
<div className="lc-designer lowcode-plugin-designer">

View File

@ -1,3 +1,4 @@
import { ISkeleton } from '@alilc/lowcode-editor-skeleton';
import { IPublicTypeEditorView, IPublicResourceData, IPublicResourceTypeConfig, IBaseModelResource } from '@alilc/lowcode-types';
import { Logger } from '@alilc/lowcode-utils';
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> {
readonly resourceType: ResourceType;
skeleton: ISkeleton;
get editorViews(): IPublicTypeEditorView[];
get defaultViewType(): string;
@ -68,7 +71,7 @@ export class Resource implements 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) {

View File

@ -2,14 +2,14 @@ import { PureComponent } from 'react';
import { EditorView } from './editor-view';
import { observer } from '@alilc/lowcode-editor-core';
import TopArea from '../layouts/top-area';
import { Resource } from '../resource';
import { EditorWindow } from '../window';
import { IResource } from '../resource';
import { IEditorWindow } from '../window';
import './resource-view.less';
@observer
export class ResourceView extends PureComponent<{
window: EditorWindow;
resource: Resource;
window: IEditorWindow;
resource: IResource;
}, any> {
render() {
const { skeleton } = this.props.resource;

View File

@ -15,6 +15,8 @@ interface IWindowCOnfig {
export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'changeViewType'> {
readonly resource: IResource;
editorViews: Map<string, Context>;
changeViewType: (name: string, ignoreEmit?: boolean) => void;
}

View File

@ -27,6 +27,8 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
plugins: ILowCodePluginManager;
getResourceList(): IResource[];
getResourceType(resourceName: string): IResourceType;
}
export class Workspace implements IWorkspace {