Skip to content

M4: PNG, PDF, SVG and text clipboard formats in and out (M4.57) - #88

Merged
bflatastic merged 1 commit into
mainfrom
pr/m4-clipboard-flavours
Oct 5, 2026
Merged

bflatastic merged 1 commit into
mainfrom
pr/m4-clipboard-flavours

Conversation

@bflatastic

Copy link
Copy Markdown
Member

Part of M4 (Files). Copy offers PNG, PDF, SVG and plain text to other apps, and Paste takes SVG, PDF, text and bitmaps from them, as Illustrator does.

  • M4.57: clipboard formats in and out.
    • Copy and Cut also offer:
      • PNG, always, at most 4096 px a side;
      • PDF, with the copyAsPdf preference, without the embedded editing data;
      • plain text: the text when every copied object is type, else the SVG markup when copyAsSvg is on;
      • SVG (image/svg+xml), when copyAsSvg is on.
    • Paste: another app's copy is taken as SVG, then PDF, then plain text (as point text), then a bitmap (embedded at the view centre). VectorCraft's own copy still pastes from the lossless internal clipboard. Ctrl/Cmd+V also pastes a bitmap or PDF that arrives without text.
    • Keep Plain Text: with pasteTextFormatting: "plain", text the Type tool copied pastes without its formatting.
    • New queries (cmd/clipboard/flavours.rs):
      • clipboard.exportPng {scale?}, clipboard.exportPdf, clipboard.exportText;
      • clipboard.flavours, which lists what Copy offers;
      • clipboard.importImage {dataBase64, mime?, center?}, clipboard.importText {text, center?} and clipboard.importPdf {dataBase64, page?, password?, center?}.
    • Platform layer: a SystemClipboard service trait (ui-egui/src/sysclip.rs) with desktop backends (apps/vectorcraft/src/clipboard.rs).
      • Windows uses clipboard-win, which writes every format at once plus an opaque bitmap. It was already a transitive dependency through arboard, under the Boost Software License 1.0, which is permissive.
      • macOS and Linux use arboard with image-data.
      • The web build stays SVG-text only.
    • Behaviour change: if another app's copy can't be loaded (broken SVG, whitespace-only text), Paste now reports the error and pastes nothing, instead of pasting the stale internal clipboard.

docs/mcp.md has a "Clipboard formats" section, and docs/control-protocol.md is updated.

Known limits:

  • EMF paste waits for EMF support (M4.95).
  • macOS and Linux carry one format at a time (text, else PNG) and paste text and bitmaps only. They were type-checked on Windows; I couldn't run them here.
  • A clipboard holding only a bitmap doesn't enable Paste when nothing was copied in the app.

Checks

Rebased onto a560f74 (#79). cargo xtask ci passes all 7 steps (fmt, clippy, test, assets, brands, layers, wasm): 2,274 tests, 0 failed.

  • Nothing dropped:
    • every test name on main still exists (2,251 → 2,269), none changed;
    • every command id is present (523 → 530);
    • UI_COMMANDS, menu entries and MCP tools are unchanged.
  • Checked in the running app on Windows: the clipboard listed every format, and a bitmap and text from another app pasted correctly.

🤖 Generated with Claude Code

Copy and Cut also offer other apps a PNG of the copied objects, a PDF
with On Copy: PDF, and plain text when every copied object is type
(clipboard.flavours; clipboard.exportPng {scale?}, exportPdf,
exportText). Paste outside text editing takes what another app copied:
SVG, then PDF (clipboard.importPdf), then plain text as point text
(clipboard.importText), then a bitmap embedded at the view centre
(clipboard.importImage {dataBase64, mime?, center?}); pasting our own
copy keeps the lossless internal clipboard, and Cmd+V pastes a bitmap
that comes with no text. Services gains system_clipboard
(SystemClipboard: write, holds_ours, read, has): on Windows every
format at once, on macOS and Linux one (the text, else the PNG); the
web keeps SVG text only. With When pasting text: Keep Plain Text, text
the Type tool copied pastes without its formatting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant