Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent the deletion of certain nodes #826

Open
TheoCtla opened this issue Feb 21, 2024 · 6 comments
Open

prevent the deletion of certain nodes #826

TheoCtla opened this issue Feb 21, 2024 · 6 comments
Assignees

Comments

@TheoCtla
Copy link

I'd like to know if there's a function to prevent certain nodes from being deleted, I've tried it myself but it didn't work.
Thanks

@TheoCtla
Copy link
Author

Or if you can give me the name of the function that deletes the nodes, so that I can override it.

@jerosoler
Copy link
Owner

@jerosoler jerosoler self-assigned this Feb 21, 2024
@TheoCtla
Copy link
Author

Thanks, so it'll be good if i override the function "RemoveNodeId" ?

@jerosoler
Copy link
Owner

Yes, no problem!

@TheoCtla
Copy link
Author

I've tried overriding the "RemoveNodeId" function but it doesn't work. I'd like to remove the deletion of two nodes in particular, do you have any advice?

@jerosoler
Copy link
Owner

For example by class.

    editor.removeNodeId = function(id) {
        const node = editor.getNodeFromId(id.slice(5));
        if(node.class === "nodelete")  {
            return;
        }
        this.removeConnectionNodeId(id);
        let moduleName = this.getModuleFromNodeId(id.slice(5));
        if (this.module === moduleName) {
            this.container.querySelector(`#${id}`).remove();
        }
        
        delete this.drawflow.drawflow[moduleName].data[id.slice(5)];
        this.dispatch('nodeRemoved', id.slice(5));
    }
    editor.start();
    editor.addNode("item", 1, 1, 700, 400, "nodelete", {}, 'A');
    editor.addNode("item", 1, 1, 900, 700, "item", {}, 'B');
    editor.addNode("item", 1, 1, 500, 550, "nodelete", {}, 'C');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants