jerosoler / Drawflow

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

Hide close or remove button ( 'X' ) for first dragged node. #707

Open Co-Maheshh opened 1 year ago

Co-Maheshh commented 1 year ago

Kindly help me to add restriction so that user cannot delete first dragged node. Have a look in the code tried this but its not working.

mythis.editor.on("nodeRemoved", (id) => { if(id == 0){ this.toast.error("Cannot remove") return false; }
})

jerosoler commented 1 year ago

View:

RodrigoSester commented 1 day ago

you can set a display: none; in the drawflow-delete class.

in my case I used the nodeMoved event to change the value of my css variable

JS

this.editor.on("nodeMoved", function() {
  document.documentElement.style.setProperty('--dfDeleteDisplay', 'none');
});

CSS

:root {
  --dfDeleteDisplay: 'block';
}

.drawflow-delete {
  display: --dfDeleteDisplay;
}