Repository navigation
fix(text-editor): limit Ctrl/Cmd+A to the current code block or table cell - #11119
Open
MichaelUray wants to merge 1 commit into
Open
MichaelUray wants to merge 1 commit into
MichaelUray wants to merge 1 commit into
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.