Skip to content

Commit 5463d3f

Browse files
committed
fix: delete removes the block
1 parent 7e19a27 commit 5463d3f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

libs/block-note-angular/src/lib/components/bna-side-menu/default-buttons/drag-handle-menu/bna-drag-handle-menu.component.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,19 @@ export class BnaDragHandleMenuComponent implements OnChanges {
7676
}
7777

7878
deleteBlock() {
79-
if (this.focusedBlock) {
80-
console.log('delete block', [this.focusedBlock?.id]);
81-
this.editor().removeBlocks([this.focusedBlock.id]);
82-
this.focusedBlock = undefined;
83-
this.dragMenuShown = false;
79+
const selection = this.editor().getSelection();
80+
//Todo: create type
81+
let selectedBlocks = [];
82+
// Get the blocks in the current selection and store on the state. If
83+
// the selection is empty, store the block containing the text cursor
84+
// instead.
85+
if (selection !== undefined) {
86+
selectedBlocks = selection.blocks;
87+
} else {
88+
selectedBlocks = [this.editor().getTextCursorPosition().block];
8489
}
90+
console.log('delete block', selectedBlocks);
91+
this.editor().removeBlocks(selectedBlocks);
8592
this.editor().sideMenu.unfreezeMenu();
8693
}
8794
}

0 commit comments

Comments
 (0)