fix(web): paste clipboard text into the TEXT / MText editors

Ctrl+V was globally bound to the entity paste command, so it never pasted
into an open text editor, and even when routed there iced's clipboard read
is a no-op on the web. Route Ctrl+V to the focused editor and, on the web,
read the system clipboard via the browser's async Clipboard API (the
keypress is a user gesture, so the read is permitted):

- MText editor: insert at the caret (web + native).
- TEXT field: append on the web; native lets the text_input paste itself.
- No editor open: falls through to the entity paste command as before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-20 17:05:02 +03:00
commit e1c5917644
5 changed files with 77 additions and 1 deletions

View file

@ -799,6 +799,14 @@ pub enum Message {
PollWebFonts,
/// Web: a per-script font finished fetching — `Ok(bytes)` or `Err(reason)`.
WebFontLoaded(crate::scene::text::web_font::Script, Result<Vec<u8>, String>),
/// Ctrl+V. Routed by `update`: into the open text/MText editor (via an async
/// system-clipboard read, which is the only paste path that works on the
/// web) or, with no editor open, the entity paste command.
PasteShortcut,
/// System-clipboard text read for the MText editor (`None` = empty/denied).
MTextPasteClip(Option<String>),
/// System-clipboard text read for the single-line TEXT editor.
TextInlinePasteClip(Option<String>),
OpenFile,
/// File picker returned. `Some((path, size_in_bytes))` → start loading;
/// `None` → user cancelled the dialog (no overlay shown).