Open psociety opened 1 year ago
You can use this method:
Or use:
editor.selectNode = function(id) {
if(this.node_selected != null) {
this.node_selected.classList.remove("selected");
if(this.node_selected != this.ele_selected) {
this.dispatch('nodeUnselected', true);
}
}
const element = document.querySelector(`#node-${id}`);
this.ele_selected = element;
this.node_selected = element;
this.node_selected.classList.add("selected");
if(this.node_selected != this.ele_selected) {
this.dispatch('nodeSelected', this.ele_selected.id.slice(5));
}
}
editor.selectNode(6);
I'm also doing a similar workaround:
// @ts-ignore
this.editor.click({
target: block.$html
})
But i thought it wasn't a good idea to do it that way xD
You can use this method:
Or use:
editor.selectNode = function(id) { if(this.node_selected != null) { this.node_selected.classList.remove("selected"); if(this.node_selected != this.ele_selected) { this.dispatch('nodeUnselected', true); } } const element = document.querySelector(`#node-${id}`); this.ele_selected = element; this.node_selected = element; this.node_selected.classList.add("selected"); if(this.node_selected != this.ele_selected) { this.dispatch('nodeSelected', this.ele_selected.id.slice(5)); } } editor.selectNode(6);
My 2 cents:
this.node_selected should be "initialized" after this.el_selected comparaison, i.e
this.ele_selected = element;
if(this.node_selected != this.ele_selected) {
this.node_selected = element;
this.node_selected.classList.add('selected');
this.dispatch('nodeSelected', this.ele_selected.id.slice(5));
}
Thank you for creating drawflow!
I would like to select a node but i can't find a method to do it :(
It would be cool to be able to do
editor.selectNode(NODE_ID)
.