GeezerVison is showing github.com — fix: expandable state not changed when node added/removed · william24255/lowcode-engine@37dffae
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/plugin-outline-pane/src
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: docs/docs/api/project.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ sidebar_position: 3 |
5 | 5 | ## 模块简介 |
6 | 6 |
|
7 | 7 | 引擎编排模块中包含多种模型,包括: |
8 | | -- [文档模型 DocumentModel)](./model/document-model) |
| 8 | +- [文档模型 DocumentModel](./model/document-model) |
9 | 9 | - [节点模型 Node](./model/node) |
10 | 10 | - [节点孩子模型 NodeChildren](./model/node-children) |
11 | 11 | - [属性模型 Prop](./model/prop) |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/plugin-outline-pane/src/controllers/tree-node.ts +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,6 +28,7 @@ export default class TreeNode { |
28 | 28 | onHiddenChanged: (hidden: boolean) => void; |
29 | 29 | onLockedChanged: (locked: boolean) => void; |
30 | 30 | onTitleLabelChanged: (treeNode: TreeNode) => void; |
| 31 | + onExpandableChanged: (expandable: boolean) => void; |
31 | 32 |
|
32 | 33 | get id(): string { |
33 | 34 | return this.node.id; |
@@ -41,6 +42,13 @@ export default class TreeNode { |
41 | 42 | return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null; |
42 | 43 | } |
43 | 44 |
|
| 45 | + /** |
| 46 | + * 触发 onExpandableChanged 回调 |
| 47 | + */ |
| 48 | + notifyExpandableChanged(): void { |
| 49 | + this.onExpandableChanged && this.onExpandableChanged(this.expandable); |
| 50 | + } |
| 51 | + |
44 | 52 | /** |
45 | 53 | * 插入"线"位置信息 |
46 | 54 | */ |
@@ -96,7 +104,7 @@ export default class TreeNode { |
96 | 104 |
|
97 | 105 | get detecting() { |
98 | 106 | const doc = this.pluginContext.project.currentDocument; |
99 | | - return doc?.isDetectingNode(this.node); |
| 107 | + return !!(doc?.isDetectingNode(this.node)); |
100 | 108 | } |
101 | 109 |
|
102 | 110 | get hidden(): boolean { |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/plugin-outline-pane/src/controllers/tree.ts +21-1Lines changed: 21 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,27 @@ export class Tree { |
17 | 17 |
|
18 | 18 | constructor(pluginContext: IPublicModelPluginContext) { |
19 | 19 | this.pluginContext = pluginContext; |
20 | | - this.id = this.pluginContext.project.currentDocument?.id; |
| 20 | + const doc = this.pluginContext.project.currentDocument; |
| 21 | + this.id = doc?.id; |
| 22 | + |
| 23 | + doc?.onMountNode((payload: {node: IPublicModelNode }) => { |
| 24 | + const { node } = payload; |
| 25 | + const parentNode = node.parent; |
| 26 | + if (!parentNode) { |
| 27 | + return; |
| 28 | + } |
| 29 | + const parentTreeNode = this.getTreeNodeById(parentNode.id); |
| 30 | + parentTreeNode?.notifyExpandableChanged(); |
| 31 | + }); |
| 32 | + |
| 33 | + doc?.onRemoveNode((node: IPublicModelNode) => { |
| 34 | + const parentNode = node.parent; |
| 35 | + if (!parentNode) { |
| 36 | + return; |
| 37 | + } |
| 38 | + const parentTreeNode = this.getTreeNodeById(parentNode.id); |
| 39 | + parentTreeNode?.notifyExpandableChanged(); |
| 40 | + }); |
21 | 41 | } |
22 | 42 |
|
23 | 43 | setNodeSelected(nodeId: string): void { |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/plugin-outline-pane/src/views/tree-node.tsx +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ class ModalTreeNodeView extends Component<{ |
32 | 32 | const { project } = this.pluginContext; |
33 | 33 | const rootNode = project.currentDocument?.root; |
34 | 34 | const rootTreeNode = treeNode.tree.getTreeNode(rootNode!); |
35 | | - const expanded = rootTreeNode.expanded; |
| 35 | + const { expanded } = rootTreeNode; |
36 | 36 |
|
37 | 37 | const hasVisibleModalNode = !!this.modalNodesManager?.getVisibleModalNode(); |
38 | 38 | return ( |
@@ -100,7 +100,7 @@ export default class TreeNodeView extends Component<{ |
100 | 100 |
|
101 | 101 | componentDidMount() { |
102 | 102 | const { treeNode, pluginContext } = this.props; |
103 | | - const { event, project } = pluginContext; |
| 103 | + const { project } = pluginContext; |
104 | 104 |
|
105 | 105 | const doc = project.currentDocument; |
106 | 106 |
|
@@ -113,6 +113,9 @@ export default class TreeNodeView extends Component<{ |
113 | 113 | treeNode.onLockedChanged = (locked: boolean) => { |
114 | 114 | this.setState({ locked }); |
115 | 115 | }; |
| 116 | + treeNode.onExpandableChanged = (expandable: boolean) => { |
| 117 | + this.setState({ expandable }); |
| 118 | + }; |
116 | 119 |
|
117 | 120 | this.eventOffCallbacks.push( |
118 | 121 | doc?.onDropLocationChanged((document: IPublicModelDocumentModel) => { |
|
Collapse file
Copy file name to clipboardExpand all lines: scripts/sync-oss.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,6 @@ const package = require('../packages/engine/package.json'); |
4 | 4 | const { version, name } = package; |
5 | 5 | const options = { |
6 | 6 | method: 'PUT', |
7 | | - // 暂时使用 日常环境的 uipaas-node,上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com |
8 | 7 | hostname: 'uipaas-node.alibaba-inc.com', |
9 | 8 | path: '/staticAssets/cdn/packages', |
10 | 9 | headers: { |
|