|
@@ -88,7 +88,24 @@ class Command {
|
|
|
this.queue = []
|
|
|
this.destroyed = true
|
|
|
}
|
|
|
-
|
|
|
+ __queueRemote(graph, node, nodeId) {
|
|
|
+ const nodeIds = []
|
|
|
+ // 当前节点所有的出边
|
|
|
+ const edges = node.getOutEdges() || []
|
|
|
+ const nodeModel = node.getModel()
|
|
|
+ if (nodeModel.clazz !== 'end') {
|
|
|
+ nodeIds.push(nodeModel.id)
|
|
|
+ }
|
|
|
+ edges.forEach(e => {
|
|
|
+ const targetNode = e.getTarget()
|
|
|
+ const targetNodeModel = targetNode.getModel()
|
|
|
+ if (!nodeId || nodeId != targetNodeModel.id) {
|
|
|
+ const ids = this.__queueRemote(graph, targetNode, nodeModel.id)
|
|
|
+ nodeIds.push(...ids)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return nodeIds
|
|
|
+ }
|
|
|
initCommands() {
|
|
|
const cmdPlugin = this
|
|
|
cmdPlugin.registerCommand('add', {
|
|
@@ -129,7 +146,18 @@ class Command {
|
|
|
const selectedItems = graph.get('selectedItems')
|
|
|
graph.emit('beforedelete', { items: selectedItems })
|
|
|
if (selectedItems && selectedItems.length > 0) {
|
|
|
- selectedItems.forEach(i => graph.remove(i))
|
|
|
+ selectedItems.forEach(i => {
|
|
|
+ const node = graph.findById(i)
|
|
|
+ const nodeModel = node.getModel()
|
|
|
+ if (nodeModel.clazz !== 'end') {
|
|
|
+ const ids = cmdPlugin.__queueRemote(graph, node) || []
|
|
|
+ ids.forEach(id => {
|
|
|
+ graph.remove(id)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ graph.remove(i)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
graph.emit('afterdelete', { items: selectedItems })
|
|
|
},
|