Add ability to delete nodes in editor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-13 22:47:59 -05:00
parent 331d40e49c
commit b0cf07ab49
5 changed files with 76 additions and 2 deletions

View File

@@ -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();