Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: handle backspace correctly inside a multiline list item

Abdullah Atta94dfee53bc29
diff --git a/packages/editor/src/extensions/list-item/commands.ts b/packages/editor/src/extensions/list-item/commands.ts
index 53dde7f4a..6d4d05dce 100644
--- a/packages/editor/src/extensions/list-item/commands.ts
+++ b/packages/editor/src/extensions/list-item/commands.ts
@@ -59,11 +59,14 @@ export function onBackspacePressed(
} else if (isFirstOfType(type, editor.state)) {
return false;
} else {
- // we have to run join backward twice because on the first join
- // the two list items are joined i.e., the editor just puts their
- // paragraphs next to each other. The next join merges the paragraphs
- // like it should be.
- return editor.chain().joinBackward().joinBackward().run();
+ const block = findParentNodeOfType(type)(selection);
+ if (block && block.start === $from.pos - 1) {
+ // we have to run join backward twice because on the first join
+ // the two list items are joined i.e., the editor just puts their
+ // paragraphs next to each other. The next join merges the paragraphs
+ // like it should be.
+ return editor.chain().joinBackward().joinBackward().run();
+ }
}
}