Add ability to delete nodes in editor
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -120,6 +120,26 @@ export class EditorService {
|
||||
return dirties.some(Boolean) || needSaves.some(Boolean);
|
||||
}
|
||||
|
||||
async deleteNode(nodeId: string) {
|
||||
if ( !this.currentPage ) {
|
||||
throw new NoPageLoadedError();
|
||||
}
|
||||
|
||||
const node = this.currentNodes.find(maybeNode => maybeNode.UUID === nodeId);
|
||||
if ( !node ) {
|
||||
throw new Error('Invalid node ID.');
|
||||
}
|
||||
|
||||
const editor = this.nodeIdToEditorContract[nodeId];
|
||||
if ( editor ) {
|
||||
await editor.performDelete();
|
||||
delete this.nodeIdToEditorContract[nodeId];
|
||||
}
|
||||
|
||||
this.currentNodes = this.currentNodes.filter(x => x.UUID !== nodeId);
|
||||
this.dirtyOverride = true;
|
||||
}
|
||||
|
||||
canEdit() {
|
||||
if ( !this.currentPage ) {
|
||||
throw new NoPageLoadedError();
|
||||
|
||||
Reference in New Issue
Block a user