* Deletes all selected items from the graph. * @todo Refactor deletion task to LGraph. Selection is a canvas property, delete is a graph action.
()
| 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 |
no test coverage detected