mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-11-21 19:04:56 +01:00
On Linux, the context-menu Paste used its own navigator.clipboard.readText() flow. On WebKitGTK it lost text copied from other applications. When a web image copy also carried text, it pasted the URL instead of the bitmap. It also skipped ProseMirror's paste handling, so things like callout paste and the pasted-HTML style cleanup never ran. The context menu now reads the clipboard with navigator.clipboard.read(), classifies each format, and replays the result as a paste event on the editor DOM. That runs the same path as Ctrl/Cmd+V: ProseMirror's paste handler, every handlePaste prop (file, callout, link), transformPastedHTML, the clipboard parsers and TipTap's paste rules. Only real attachments (image/*, application/pdf) become files. Other text formats such as text/uri-list stay text, and browser/OS metadata formats are ignored, so a copied link no longer becomes a pasted-0.uri-list attachment. A link offered only as a URI list pastes as its first URI. When the web clipboard is unavailable (WebKitGTK bug #218519), Paste falls back to native arboard reads: the image first, then text through the new read_clipboard_text command. The text is replayed through the same paste path. Every await re-checks the editor origin, as upstream's paste code does. The classification lives in src/lib/utils/clipboard-paste.ts and has regression tests. Closes #259