Skip to content

fix(paste): align pre-paste text measurement with final shape geometry#8345

Merged
AniKrisn merged 7 commits intomainfrom
ani/fix-text-paste-measurement
Mar 30, 2026
Merged

fix(paste): align pre-paste text measurement with final shape geometry#8345
AniKrisn merged 7 commits intomainfrom
ani/fix-text-paste-measurement

Conversation

@AniKrisn
Copy link
Copy Markdown
Contributor

@AniKrisn AniKrisn commented Mar 25, 2026

This fixes pasted text positioning by measuring the same rich-text HTML that the final text shape renders. Previously, we positioned pasted text using a different pre-measurement format, which could make it land slightly off-center.

Closes #8343

Change type

  • bugfix

Test plan

  1. Copy text from a rich text editor
  2. Paste onto the canvas with Cmd+V
  3. Copy the same text in plain text
  4. Paste onto the canvas with Cmd+V
  5. The text should be in the same place, and centred on the page

Note: unit tests won't catch text measurement bugs.

  • End to end tests

Release notes

  • Fixed slight positioning drift when pasting text onto the canvas.

Code changes

Section LOC change
Core code +3 / -5

Use the same normalized rich-text HTML for pre-paste measurement
that TextShapeUtil uses for final shape geometry, fixing a
positioning drift when pasting text.

Closes #8343
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
analytics Ready Ready Preview Mar 30, 2026 2:37pm
chat-template Ready Ready Preview Mar 30, 2026 2:37pm
examples Ready Ready Preview Mar 30, 2026 2:37pm
tldraw-docs Ready Ready Preview Mar 30, 2026 2:37pm
tldraw-shader Ready Ready Preview Mar 30, 2026 2:37pm
workflow-template Ready Ready Preview Mar 30, 2026 2:37pm

Request Review

@huppy-bot huppy-bot Bot added the bugfix Bug fix label Mar 25, 2026
@AniKrisn AniKrisn requested a review from mimecuvalo March 25, 2026 15:46
@steveruizok
Copy link
Copy Markdown
Collaborator

Looks good, asking the bot to push a test here. Review that it's checking what matters and then land this one

AniKrisn and others added 6 commits March 26, 2026 15:15
Add end-to-end and unit tests to validate pasted text measurement and geometry. The Playwright e2e spec checks that pasted plain, HTML, and multiline text shapes have props.w matching the computed geometry width. The package unit tests spy on textMeasure.measureHtml to ensure the same measurement HTML is used for paste and shape geometry, verify pasted shapes are centered on the paste point, and assert autoSize/textAlign behavior for single- vs multi-line content. These tests guard against mismatches caused by using different HTML for measurement during paste vs geometry computation.
Remove unit tests that relied on spying on internal measureHtml calls
and replace with a single E2E test that verifies the actual invariant:
pasting the same text as plain text or HTML produces identical shapes
in a real browser.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
tldraw-mcp-app e3e9af5 Mar 30 2026, 02:30 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
agent-template e3e9af5 Mar 30 2026, 02:30 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 30, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
image-pipeline-template e3e9af5 Commit Preview URL

Branch Preview URL
Mar 30 2026, 02:35 PM

@AniKrisn AniKrisn added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit c3622b0 Mar 30, 2026
23 checks passed
@AniKrisn AniKrisn deleted the ani/fix-text-paste-measurement branch March 30, 2026 15:04
github-merge-queue Bot pushed a commit that referenced this pull request Apr 3, 2026
Adds the standard `Cmd+Shift+V` / `Ctrl+Shift+V` shortcut to paste
clipboard content as plain text, skipping HTML and rich content.

**Breaking behavior change:** Previously, `Cmd+Shift+V` toggled
paste-at-cursor positioning (added in #4088 for Autodesk). Since the
"Paste at cursor" preference (#4066) now covers that use case, this
repurposes `Cmd+Shift+V` for plain text paste — the standard shortcut in
most apps. Users who relied on `Cmd+Shift+V` for paste-at-cursor should
use the preference toggle instead.

- **Preference off:** `Cmd+V` pastes at center, `Cmd+Shift+V` pastes
plain text at center
- **Preference on:** `Cmd+V` pastes at cursor, `Cmd+Shift+V` pastes
plain text at cursor

Note: depends on #8345 for consistent paste positioning between plain
text and rich text paste.

Closes #8183

### Change type

- [x] `feature`

### Test plan

1. Copy rich text from a web page
2. `Cmd+V` — pastes with formatting (existing behavior, unchanged)
3. `Cmd+Shift+V` — pastes as plain text, no HTML formatting
4. Toggle "Paste at cursor" preference and verify both shortcuts respect
it
5. Verify that `Cmd+Shift+V` no longer triggers paste-at-cursor
positioning

- [ ] Unit tests
- [ ] End to end tests

### Release notes

- Added `Cmd+Shift+V` / `Ctrl+Shift+V` shortcut to paste clipboard
content as plain text
- Changed `Cmd+Shift+V` from paste-at-cursor to paste-as-plain-text

### Code changes

| Section        | LOC change  |
| -------------- | ----------- |
| Core code      | +105 / -12  |
| Tests          | +97 / -0    |
| Config/tooling | +1 / -1     |

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text paste positioning differs from final shape geometry

2 participants