mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-13 20:36:34 +00:00
fix: fixed an issue where the outline tree was not displayed correctly when deleting a node
This commit is contained in:
parent
ebe21c4d07
commit
06aaef777d
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user