Skip to content

Commit 41c19e0

Browse files
committed
Fixed backspace bug when current block is empty and previous block's last child is empty
1 parent a850078 commit 41c19e0

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,18 @@ export const KeyboardShortcutsExtension = Extension.create<{
260260
prevBlockInfo.blockContent.beforePos,
261261
);
262262
} else {
263-
const blockContentStartPos =
264-
prevBlockInfo.blockContent.afterPos - 1;
263+
const bottomNestedPrevBlockInfo = getBottomNestedBlockInfo(
264+
state.doc,
265+
prevBlockInfo,
266+
);
267+
if (!bottomNestedPrevBlockInfo.isBlockContainer) {
268+
return false;
269+
}
270+
const blockContentEndPos =
271+
bottomNestedPrevBlockInfo.blockContent.afterPos - 1;
265272

266273
chainedCommands =
267-
chainedCommands.setTextSelection(blockContentStartPos);
274+
chainedCommands.setTextSelection(blockContentEndPos);
268275
}
269276

270277
return chainedCommands

0 commit comments

Comments
 (0)