mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-05-18 05:05:36 +02:00
editor: fix crash in backspace handler (#9740)
* editor: fix crash in backspace handler * replace nextNode with .nodeAfter Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> * editor: fix position of node when deleting nextNode --------- Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
This commit is contained in:
@@ -58,7 +58,6 @@ export const Quirks = Extension.create<QuirksOptions>({
|
||||
Backspace: ({ editor }) => {
|
||||
const { empty, $anchor } = editor.state.selection;
|
||||
|
||||
const nextNode = editor.state.doc.nodeAt($anchor.pos + 1);
|
||||
const node = findFromParentNode(
|
||||
editor.state,
|
||||
this.options.irremovableNodesOnBackspace
|
||||
@@ -76,14 +75,15 @@ export const Quirks = Extension.create<QuirksOptions>({
|
||||
// manually handle this case.
|
||||
else if (
|
||||
isAndroid &&
|
||||
nextNode &&
|
||||
$anchor.nodeAfter &&
|
||||
this.options.irremovableNodesOnBackspace.includes(
|
||||
nextNode.type.name
|
||||
$anchor.nodeAfter.type.name
|
||||
) &&
|
||||
!nextNode.textContent.length
|
||||
!$anchor.nodeAfter.textContent.length
|
||||
) {
|
||||
const node = $anchor.nodeAfter;
|
||||
return this.editor.commands.command(({ tr }) => {
|
||||
tr.delete($anchor.pos + 1, $anchor.pos + 1 + nextNode.nodeSize);
|
||||
tr.delete($anchor.pos, $anchor.pos + node.nodeSize);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user