Skip to content

fix: allow selecting tables alongside other blocks - #2

Open
Hbrehman wants to merge 1 commit into
mainfrom
cursor/fix-table-cross-block-selection-b800
Open

Hbrehman wants to merge 1 commit into
mainfrom
cursor/fix-table-cross-block-selection-b800

Conversation

@Hbrehman

@Hbrehman Hbrehman commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Documents that contain a table could not be selected together with neighbouring blocks, and Ctrl/Cmd+A did not select the whole document.

Rationale

Two prosemirror-tables behaviours trapped the selection inside the table:

  1. normalizeSelection treated any TextSelection with one endpoint in a cell and $to.parentOffset === 0 as an accidental intra-table span, and clamped it back to a single cell. That is also the shape of a mouse selection that has just crossed from a table into the next paragraph, and of select-all when the document starts with a table and ends on an empty block.
  2. handleMouseDown creates a CellSelection and then refuses to update once the pointer leaves the table (inSameTable).

BlockNote disables TipTap's core extensions, so there was no Mod-a keymap and native select-all was unreliable.

Changes

  • Replace stock tableEditing() with a thin wrapper that:
    • keeps cell selection, copy/paste, and table fixing
    • only clamps TextSelections that stay inside the same table
    • converts a cell-drag that leaves the table into a TextSelection spanning the table and the pointer
  • Add a Notion-style Mod-a keymap (first press = current block, second = whole document, TextSelection not AllSelection). Table ranges use first/last cell text positions. Whole-doc endpoints that fall inside a table are expanded to the table node's boundaries so Backspace can delete the isolating table instead of only emptying its cells.
  • Extract getTableContentRange / getBlockContentRange / getWholeDocTextSelection so setSelection and the keymap share the same table endpoints.

Impact

Cell-to-cell selection inside a table is unchanged. Selections that start outside a table, or that drag out of one, can now include the table and neighbouring blocks. Mod-a is now handled by the editor.

Testing

  • Fail-first then passing unit tests in tableCrossBlockSelection.test.ts:
    • setSelection across paragraph+table and table+paragraph
    • TextSelection that leaves a table at parentOffset === 0 is not clamped
    • Mod-a in a table, then again, selects the whole document
    • Mod-a + Backspace clears documents that contain / start with a table
  • KeyboardShortcutsExtension.test.ts: Notion-style escalate-and-clear for paragraphs and checklists
  • Browser test tableCrossBlockSelection.browser.test.ts for mouse-drag (runs in the Docker e2e suite)
  • packages/core unit suite: 778 passed
  • Scoped vp lint --type-aware on the changed core files: clean

Screenshots/Video

N/A (selection behaviour; covered by unit tests)

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature
Open in Web Open in Cursor 

@Hbrehman
Hbrehman marked this pull request as ready for review September 12, 2026 18:40
prosemirror-tables' normalizeSelection clamped any TextSelection that
left a table when $to.parentOffset === 0, and cell-drag handling refused
to escape the table. That blocked mouse selection of a table plus
neighbouring blocks and made native Ctrl/Cmd+A unreliable.

Keep cell selection inside tables, but preserve TextSelections that
span a table and other blocks. Add a Notion-style Mod-a keymap (first
press selects the current block, second selects the document) that uses
table-aware ranges so select-all works in documents that contain tables.
@cursor
cursor Bot force-pushed the cursor/fix-table-cross-block-selection-b800 branch from 165bf79 to c96e9e4 Compare September 12, 2026 18:41
@cursor cursor Bot changed the title fix: allow selecting tables alongside other blocks (#3017) fix: allow selecting tables alongside other blocks Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant