MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / deleteSelected

Method deleteSelected

src/LGraphCanvas.ts:3909–3940  ·  view source on GitHub ↗

* Deletes all selected items from the graph. * @todo Refactor deletion task to LGraph. Selection is a canvas property, delete is a graph action.

()

Source from the content-addressed store, hash-verified

3907 * @todo Refactor deletion task to LGraph. Selection is a canvas property, delete is a graph action.
3908 */
3909 deleteSelected(): void {
3910 const { graph } = this
3911 if (!graph) throw new NullGraphError()
3912
3913 this.emitBeforeChange()
3914 graph.beforeChange()
3915
3916 for (const item of this.selectedItems) {
3917 if (item instanceof LGraphNode) {
3918 const node = item
3919 if (node.block_delete) continue
3920 node.connectInputToOutput()
3921 graph.remove(node)
3922 this.onNodeDeselected?.(node)
3923 } else if (item instanceof LGraphGroup) {
3924 graph.remove(item)
3925 } else if (item instanceof Reroute) {
3926 graph.removeReroute(item.id)
3927 }
3928 }
3929
3930 this.selected_nodes = {}
3931 this.selectedItems.clear()
3932 this.current_node = null
3933 this.highlighted_links = {}
3934
3935 this.state.selectionChanged = true
3936 this.onSelectionChange?.(this.selected_nodes)
3937 this.setDirty(true)
3938 graph.afterChange()
3939 this.emitAfterChange()
3940 }
3941
3942 /**
3943 * deletes all nodes in the current selection from the graph

Callers 3

processKeyMethod · 0.95
deleteSelectedNodesMethod · 0.95
onMenuNodeRemoveMethod · 0.80

Calls 9

emitBeforeChangeMethod · 0.95
setDirtyMethod · 0.95
emitAfterChangeMethod · 0.95
beforeChangeMethod · 0.80
connectInputToOutputMethod · 0.80
afterChangeMethod · 0.80
removeRerouteMethod · 0.65
removeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected