This commit is contained in:
X1627315083@163.com
2026-03-04 15:40:30 +08:00
parent eb67982228
commit e96aa5dca8
4 changed files with 53 additions and 8 deletions

View File

@@ -100,4 +100,21 @@ export class NodeManager {
}
return this.createNode(options_)
}
copyNodeById(id: string) {
const node = this.stateManager.getNodeById(id)
const flowNode = this.stateManager.flowManager.getNodeById(id)
console.log(node,this.stateManager.flowManager.getNodeById(id))
if (!node) return console.warn(`copyNodeById: ${id}找不到对应节点`)
const node_ = {
...JSON.parse(JSON.stringify(node)),
id: createId(),
position: {
x: node.position.x,
y: node.position.y + (flowNode?.dimensions?.height || 0) + 50,
}
}
this.stateManager.addNode(node_)
// return this.createNode(options_)
}
}

View File

@@ -127,4 +127,12 @@ export class StateManager {
setNodesDraggable(v: boolean) { this.nodesDraggable.value = v }
/** 设置是否可以平移画布 */
setPanOnDrag(v: boolean) { this.panOnDrag.value = v }
/** 获取节点最大zIndex值 */
getMaxZIndex() {
return this.nodes.value.reduce((max, node) => Math.max(max, node.zIndex), 0)
}
/** 获取节点最小zIndex值 */
getMinZIndex() {
return this.nodes.value.reduce((min, node) => Math.min(min, node.zIndex), 0)
}
}