Skip to content

fix(text-editor): limit Ctrl/Cmd+A to the current code block or table cell - #11119

Open
MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/editor-select-all-scope
Open

MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/editor-select-all-scope

Conversation

@MichaelUray

Copy link
Copy Markdown
Contributor

Fixes #7816

Problem and change

Mod-a was only handled by the TipTap core keymap, which always selects the
whole document, so pressing it inside a code block or table cell selected
everything instead of the block's content.

Add a scoped select-all shortcut: the first press selects the content of the
innermost code block (any node with spec.code, incl. mermaid) or table cell
around the selection; further presses widen to the enclosing scope and finally
fall back to the default whole-document selection. The scope lookup is a pure
helper covered by unit tests.

Tests

New unit tests plugins/text-editor-resources/src/components/extension/shortcuts/__tests__/selectAll.test.ts. Checked manually on a self-hosted instance: Ctrl+A inside a table cell selects only that cell's text and a second Ctrl+A the whole document; the same for a code block; in a normal paragraph Ctrl+A selects the whole document.

… cell

Mod-a was only handled by the TipTap core keymap, which always selects the
whole document, so pressing it inside a code block or table cell selected
everything instead of the block's content.

Add a scoped select-all shortcut: the first press selects the content of the
innermost code block (any node with spec.code, incl. mermaid) or table cell
around the selection; further presses widen to the enclosing scope and finally
fall back to the default whole-document selection. The scope lookup is a pure
helper covered by unit tests.

Fixes hcengineering#7816

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Ctrl/Cmd + A in tables and code blocks

1 participant