jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.65k stars 722 forks source link

Deselect / Unselect nodes #456

Closed gpack closed 2 years ago

gpack commented 2 years ago

How do you unselect nodes programmatically?

Example: When a user clicks on a button, I want to unselect the “selected / highlighted” node.

jerosoler commented 2 years ago

Try:

if(editor.node_selected != null) {
          editor.node_selected.classList.remove("selected");
          editor.node_selected = null;
          editor.dispatch('nodeUnselected', true);
}
gpack commented 2 years ago

thanks Jero. that worked!

ShalineeSingh commented 2 years ago

node_selected is not exposed in angular package. It throws an error if I try to access it. Also, editor.dispatch is not defined.

jerosoler commented 2 years ago

Angular package?

editor variable is the: const editor = new Drawflow...

ShalineeSingh commented 2 years ago

I'm following this - https://stackoverflow.com/a/66268903/4955423 Here both this.editor.node_selected and this.editor.dispatch shows error.

MaxMaioli commented 2 years ago

Yeah, used with angular, we miss node_selected property (and probably many others).

jerosoler commented 2 years ago

I can't help in angular, I don't know how it works. Some repositories with angular: https://github.com/urveerendra/cpm-builder https://github.com/venkateshwarans/drawflow-angular https://github.com/RoyaghRamo/angular-drawflow-example

ShalineeSingh commented 2 years ago

For someone who is having the same issue, I found out why most of the things don't work with angular. Type declarations in @types is for earliest version of Drawflow. It has a lot of properties missing.

I created custom types file for current drawflow version and now I'm able to use all the features.