Repository navigation
Extend selection across paragraphs with Shift+ArrowUp/Down - #21
Open
rogegoncalves wants to merge 1 commit into
Open
rogegoncalves wants to merge 1 commit into
rogegoncalves wants to merge 1 commit into
Conversation
Each paragraph is its own editing host, so the native Shift+Arrow extension stopped at the paragraph edge. From a wrapped paragraph the textarea took the first step, but the next key reached the viewer root, where the native extension moved the DOM selection out of the paragraphs and the active range was cleared. onViewerKeyDown now moves the focus boundary one line: inside the paragraph, or into the next/previous paragraph (from the model) on the edge line, and applies it with setSelectionFromDocxBoundaries. Moves inside a single paragraph stay native, tables keep their cell selection, and once the selection spans paragraphs the key is always handled so the range is never dropped. Refs extend-hq#20 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@rogegoncalves is attempting to deploy a commit to the Extend Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Shift+ArrowUp/Down couldn't extend a selection across paragraphs (the keyboard half of #20):
Root cause
onKeyDownonly handles vertical arrows without Shift (isPlainVerticalArrowKey). With Shift the browser handles the key and keeps the selection inside the paragraph's own editing host.setSelectionFromDocxBoundaries(anchor, focus). The next Shift+Arrow reaches the viewer root, andonViewerKeyDowndoesn't handle arrows. The native extension moves the DOM selection's anchor out of the paragraphs, so on keyupsetActiveRangeFromSelectioncan't resolve the range and clearsactiveTextRange.Fix
onViewerKeyDownhandles Shift+ArrowUp/Down with the helpers the Shift+click support uses (resolveParagraphBoundaryFromSelectionPoint,resolveBoundaryFromPoint,setSelectionFromDocxBoundaries). Anchor and focus come from the DOM selection;setSelectionFromDocxBoundariessets it withsetBaseAndExtent, so the direction is kept. The focus boundary moves one line. On the edge line of its paragraph, it moves into the next or previous paragraph, found in the model withnextParagraphLocation/lastParagraphLocationInNodeas the wrapped route does, at the caret's x on that paragraph's first or last line. That paragraph is scrolled into view first, so page breaks and paragraph spacing don't stop the move.Known limitation: the column comes from the current caret, so after passing a short line the following lines use the shorter column. Word remembers the original column.
Refs #20.
Verification
tests/visual/fidelity-smoke.spec.ts. It presses Shift+ArrowDown twice, Shift+ArrowUp once and Backspace across regular paragraphs, then Shift+ArrowDown twice from a heading on the wrapped route, checkingactiveTextRangeafter each key. It fails without the fix (the second Shift+ArrowDown doesn't extend) and passed 10 of 10 runs with it.pnpm run test:visual: 12 passed.pnpm run typecheck: clean.vitest run: 748 passed, 15 skipped, the same as onmain.🤖 Generated with Claude Code