Commit 066ea07
Paste routes by recency: one internal copy no longer blocks image paste
Reported (and reproduced to the letter): copy a device on the canvas, and
for the REST OF THE SESSION pasting an image from the OS clipboard - one
verified fresh in Paint - pastes the stale device copy instead. Mechanism:
the Ctrl+V keydown handler preventDefault()ed whenever the object clipboard
was non-empty, which suppresses the browser's paste EVENT - the only place
image pasting (and the OS clipboard itself) lives. Only New Diagram or a
reload cleared it, which is exactly the save/new/hard-refresh dance that
"fixed" it in the field.
The fix is a recency rule, not a priority swap ("image always wins" would
break stamping copies of a device while an old screenshot sits in the OS
clipboard). Internal copies now also STAMP the OS clipboard - a marker
type plus the copied labels as plain text, so pasting into a text editor
yields something meaningful - making the OS clipboard's own
last-writer-wins ordering the arbiter. The paste event routes: marker
present -> the objects are newest, paste them; image without marker -> the
image is newest, paste it; neither -> object-clipboard fallback (old
behavior, covers a failed stamp). The Ctrl+V keydown no longer touches
preventDefault; its only job is an 80ms fallback timer for the one case
that fires no paste event at all (empty OS clipboard). Duplicate (Ctrl+D)
deliberately does not stamp - it should not clobber the user's clipboard.
execCommand does the stamping because navigator.clipboard requires a
secure context and plain-HTTP LAN deployments are a supported layout.
Verified: five new harness checks drive the REAL listeners with synthetic
ClipboardEvents - marker routes to objects, image-without-marker pastes
the image (the reported bug, pinned), text-only falls back, the timer
fallback fires when no paste event arrives (127/127) - and headless
Chromium with real clipboard permissions confirms Ctrl+C writes the actual
OS clipboard (readText returned every sample label, zone included).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 7e524c9 commit 066ea07
2 files changed
Lines changed: 148 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3150 | 3150 | | |
3151 | 3151 | | |
3152 | 3152 | | |
3153 | | - | |
| 3153 | + | |
3154 | 3154 | | |
3155 | 3155 | | |
3156 | 3156 | | |
| |||
3229 | 3229 | | |
3230 | 3230 | | |
3231 | 3231 | | |
3232 | | - | |
| 3232 | + | |
3233 | 3233 | | |
3234 | 3234 | | |
3235 | 3235 | | |
| |||
4374 | 4374 | | |
4375 | 4375 | | |
4376 | 4376 | | |
4377 | | - | |
| 4377 | + | |
4378 | 4378 | | |
4379 | 4379 | | |
4380 | 4380 | | |
| |||
8368 | 8368 | | |
8369 | 8369 | | |
8370 | 8370 | | |
| 8371 | + | |
| 8372 | + | |
| 8373 | + | |
| 8374 | + | |
| 8375 | + | |
8371 | 8376 | | |
8372 | 8377 | | |
8373 | 8378 | | |
8374 | 8379 | | |
| 8380 | + | |
| 8381 | + | |
| 8382 | + | |
| 8383 | + | |
| 8384 | + | |
| 8385 | + | |
| 8386 | + | |
| 8387 | + | |
| 8388 | + | |
| 8389 | + | |
| 8390 | + | |
| 8391 | + | |
8375 | 8392 | | |
8376 | 8393 | | |
8377 | 8394 | | |
| |||
8419 | 8436 | | |
8420 | 8437 | | |
8421 | 8438 | | |
| 8439 | + | |
| 8440 | + | |
| 8441 | + | |
| 8442 | + | |
| 8443 | + | |
| 8444 | + | |
8422 | 8445 | | |
8423 | 8446 | | |
8424 | 8447 | | |
| |||
8647 | 8670 | | |
8648 | 8671 | | |
8649 | 8672 | | |
8650 | | - | |
| 8673 | + | |
| 8674 | + | |
8651 | 8675 | | |
8652 | | - | |
| 8676 | + | |
| 8677 | + | |
| 8678 | + | |
| 8679 | + | |
8653 | 8680 | | |
8654 | 8681 | | |
8655 | | - | |
| 8682 | + | |
| 8683 | + | |
| 8684 | + | |
| 8685 | + | |
| 8686 | + | |
| 8687 | + | |
| 8688 | + | |
8656 | 8689 | | |
8657 | | - | |
8658 | | - | |
8659 | | - | |
| 8690 | + | |
| 8691 | + | |
| 8692 | + | |
| 8693 | + | |
| 8694 | + | |
| 8695 | + | |
| 8696 | + | |
| 8697 | + | |
| 8698 | + | |
| 8699 | + | |
| 8700 | + | |
| 8701 | + | |
| 8702 | + | |
| 8703 | + | |
| 8704 | + | |
| 8705 | + | |
| 8706 | + | |
| 8707 | + | |
| 8708 | + | |
| 8709 | + | |
| 8710 | + | |
| 8711 | + | |
| 8712 | + | |
| 8713 | + | |
| 8714 | + | |
| 8715 | + | |
| 8716 | + | |
| 8717 | + | |
| 8718 | + | |
| 8719 | + | |
| 8720 | + | |
| 8721 | + | |
| 8722 | + | |
| 8723 | + | |
| 8724 | + | |
| 8725 | + | |
| 8726 | + | |
| 8727 | + | |
| 8728 | + | |
8660 | 8729 | | |
8661 | 8730 | | |
8662 | 8731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
311 | 381 | | |
312 | 382 | | |
313 | 383 | | |
| |||
0 commit comments