Is there a way I can disable deletion of a particular node & edge? #746
Replies: 1 comment
|
Hi @advayumare, To your question: there isn't a built-in Mark the elements you want to protect, e.g. import type { Middleware } from 'ng-diagram';
export const protectDeletion: Middleware<'protect-deletion'> = {
name: 'protect-deletion',
execute: ({ helpers }, next, cancel) => {
const locked =
helpers.getRemovedNodes().some((n) => n.data?.locked) ||
helpers.getRemovedEdges().some((e) => e.data?.locked);
locked ? cancel() : next();
},
};Register it on the component: middlewares = createMiddlewares((defaults) => [protectDeletion, ...defaults]);
// <ng-diagram [middlewares]="middlewares" ... />This covers everything: the Delete/Backspace key, programmatic One heads-up:
|
Uh oh!
There was an error while loading. Please reload this page.
Hello Team,
First of all I have been looking for a angular diagramming library for years now, finally a wonderful option now. thanks for that.
I just wanted to know if there's an in built flag or api that allows disabling deletion of an edge and a node.
All reactions