Skip to content

Build your personal knowledge base with Trilium Notes

text editor/collapsible: fix empty block deletion issue

Adorian Dorancac69f160c7e
diff --git a/packages/ckeditor5-collapsible/src/collapsible-editing.ts b/packages/ckeditor5-collapsible/src/collapsible-editing.ts
index 81d0d9caaf..df9422221d 100644
--- a/packages/ckeditor5-collapsible/src/collapsible-editing.ts
+++ b/packages/ckeditor5-collapsible/src/collapsible-editing.ts
@@ -392,6 +392,12 @@ export default class CollapsibleEditing extends Plugin {
const adjacent = data.direction === "forward" ? position.nodeAfter : position.nodeBefore;
if (!adjacent || !adjacent.is("element", "details")) return;
+ // Don't hijack a delete when the current block is empty — the user is
+ // removing the empty block, not the details next to it. Default behaviour
+ // collapses the empty paragraph naturally.
+ const currentBlock = position.parent;
+ if (currentBlock?.is("element") && currentBlock.isEmpty) return;
+
this.editor.model.change(writer => writer.setSelection(adjacent, "on"));
data.preventDefault();
evt.stop();