M4.57: PNG, PDF and text clipboard flavours in and out

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>
This commit is contained in:
bflatastic
2026-10-05 10:52:01 +07:00
co-authored by Claude Opus 5.5
parent a560f74e17
commit 0968e34e7e
24 changed files with 1314 additions and 77 deletions
+4
View File
@@ -206,6 +206,9 @@ pub struct ToolContext<'a> {
pub unit: Unit,
/// Units ▸ Stroke: the unit measurement labels show stroke widths in.
pub stroke_unit: Unit,
/// Clipboard Handling → When pasting text: Keep Plain Text. Text pasted while typing takes
/// the style at the caret, even the text the Type tool copied with its formatting.
pub paste_plain_text: bool,
}
impl ToolContext<'_> {
@@ -405,6 +408,7 @@ pub(crate) mod testutil {
preview_bounds: false,
unit: Unit::Points,
stroke_unit: Unit::Points,
paste_plain_text: false,
}
}
}
+2 -2
View File
@@ -365,9 +365,9 @@ impl Tool for TypeTool {
s
};
self.clicks = (None, 0);
// Pasting what we copied keeps its formatting.
// Pasting what we copied keeps its formatting (unless pasted text is kept plain).
let clip: String = self.clipboard.iter().map(|r| r.text.as_str()).collect();
if s.len() > 1 && s == clip {
if s.len() > 1 && s == clip && !cx.paste_plain_text {
let runs = self.clipboard.clone();
return self.replace(cx, "", Some(runs));
}