Skip to content

Commit c484155

Browse files
committed
fix(table): remove redundant comments
1 parent b4af8bb commit c484155

2 files changed

Lines changed: 0 additions & 18 deletions

File tree

‎packages/core/src/blocks/Table/TableExtension.test.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import type { PartialBlock } from "../defaultBlocks.js";
99
* @vitest-environment jsdom
1010
*/
1111

12-
/**
13-
* Simulate a keyboard shortcut by invoking the view's handleKeyDown prop,
14-
* which is how ProseMirror routes keymap-based handlers like Enter.
15-
*/
1612
function pressEnter(editor: BlockNoteEditor) {
1713
const view = editor.prosemirrorView;
1814
const event = new KeyboardEvent("keydown", { key: "Enter" });
@@ -52,9 +48,6 @@ describe("Table Enter keyboard shortcut", () => {
5248
editor.replaceBlocks(editor.document, testDocument);
5349
});
5450

55-
/**
56-
* Returns the document position just inside the cell containing `cellText`.
57-
*/
5851
function posInCell(cellText: string): number {
5952
const view = editor.prosemirrorView;
6053
let pos = -1;
@@ -92,7 +85,6 @@ describe("Table Enter keyboard shortcut", () => {
9285

9386
const before = editor.document;
9487
expect(() => pressEnter(editor)).not.toThrow();
95-
// The table structure must be left intact (Enter is a no-op here).
9688
expect(editor.document).toStrictEqual(before);
9789
});
9890

‎packages/core/src/blocks/Table/TableExtension.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ export const TableExtension = Extension.create({
3535
return {
3636
// Moves the selection to the cell below.
3737
Enter: () => {
38-
// We use `isInTable` rather than checking whether the cursor's parent
39-
// is a `tableParagraph`, since for cell selections that span multiple
40-
// cells the selection head resolves to a `tableRow` instead.
4138
if (!isInTable(this.editor.state)) {
4239
return false;
4340
}
@@ -46,7 +43,6 @@ export const TableExtension = Extension.create({
4643
const $cell = selectionCell(state);
4744
const $nextCell = $cell ? nextCell($cell, "vert", 1) : null;
4845

49-
// Moves the selection to the cell below, if there is one.
5046
if ($nextCell && dispatch) {
5147
dispatch(
5248
state.tr
@@ -57,12 +53,6 @@ export const TableExtension = Extension.create({
5753
);
5854
}
5955

60-
// Always consume the Enter key while inside a table, even when there
61-
// is no cell below (e.g. the last row) or the selection spans
62-
// multiple cells. Otherwise it falls through to the default
63-
// `splitBlock` handler, which tries to split the table cell and
64-
// throws `Cannot join tableCell onto blockContainer`, crashing the
65-
// editor. On the last row, Enter simply becomes a no-op.
6656
return true;
6757
});
6858
},

0 commit comments

Comments
 (0)