Skip to content

feat(annotations): support highlight/text annotations on rotated docs#753

Open
kduncanhsu wants to merge 2 commits into
box:masterfrom
kduncanhsu:feat/support-highlight-annotations-on-rotated-docs
Open

feat(annotations): support highlight/text annotations on rotated docs#753
kduncanhsu wants to merge 2 commits into
box:masterfrom
kduncanhsu:feat/support-highlight-annotations-on-rotated-docs

Conversation

@kduncanhsu
Copy link
Copy Markdown
Contributor

@kduncanhsu kduncanhsu commented May 15, 2026

Summary

  • Adds rotation support to highlight annotations by converting screen-coordinate selection rects to element-local coordinates, matching the approach already used by drawing/region annotations
  • Portals the highlight promoter popup (PopupHighlight) and error popup (PopupHighlightError) out of the rotated annotation layer so they remain upright and correctly positioned on screen
  • Passes containerEl (the textLayer element) through the selection flow so that setSelectionAction can use it with getElementLocalPosition() to convert screen coordinates to element-local coordinates. Previously only
    containerRect (the DOMRect) was passed, which doesn't provide the element reference needed to account for CSS rotation transforms.
  • Fixes a bug where overdragging past text (selecting an entire line and dragging slightly beyond) would silently fail on rotated documents because the mouseup event never reached the textLayer

Test plan

  • Run npm test — all 965 tests pass
  • Open a PDF, rotate -90°, select partial text → popup appears correctly positioned and upright
  • Rotate -90°, select an entire line (overdrag past end of text) → popup still appears
  • Click the promoter popup → highlight is staged at the correct position within the rotated layer
  • Save the highlight → persists correctly and renders properly at 0°, -90°, -180°, -270°
  • Verify non-rotated highlight behavior is unchanged (no regressions)

@kduncanhsu kduncanhsu marked this pull request as ready for review May 15, 2026 20:43
@kduncanhsu kduncanhsu requested a review from a team as a code owner May 15, 2026 20:43
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Duncan Hsu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants