feat(clipboard): paste images from other programs on desktop too

A paste that finds no text now reads an image off the system clipboard
on desktop as well as on the web. The pixels are written as a PNG beside
the drawing (or in the config folder for a drawing never saved) and
placed as a raster image at the cursor, the same way the web paste
attaches a screenshot. PASTESPEC falls back to the same image paste when
the clipboard holds neither objects nor text.

Refs #645

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-13 22:08:14 +03:00
1 parent d4b4fc37e1
commit 11f68a1185
4 files changed
+62 -33

No files matched your search

+7 -22
View File
@@ -6895,11 +6895,10 @@ impl OpenCADStudio {
self.push_ucs_to_cmd(i);
Task::none()
}
// Nothing but maybe an image: paste it as one.
None if self.clipboard.is_empty() => {
self.tabs[i].active_cmd = None;
self.command_line
.push_error(crate::tr!("clipboard", "no-supported-content").as_ref());
Task::none()
self.read_system_clipboard_image()
}
None => Task::none(),
}
@@ -6917,24 +6916,11 @@ impl OpenCADStudio {
self.focus_cmd_input()
}
Text::EmptyOrUnsupported => {
// Web: no text — the clipboard may still hold an IMAGE
// (a pasted screenshot). Read it through the async
// Clipboard API and attach it the way the IMAGE
// command's pick does; only when that also finds
// No text — the clipboard may still hold an IMAGE (a
// pasted screenshot). Read it and attach it the way the
// IMAGE command's pick does; only when that also finds
// nothing does the unsupported-content error surface.
// Native has no image route off the sync clipboard.
#[cfg(target_arch = "wasm32")]
return Task::perform(
crate::sys::read_clipboard_image(),
Message::SystemClipboardPasteImage,
);
#[cfg(not(target_arch = "wasm32"))]
{
self.command_line.push_error(
crate::tr!("clipboard", "no-supported-content").as_ref(),
);
Task::none()
}
self.read_system_clipboard_image()
}
Text::Unavailable => {
self.command_line
@@ -6954,10 +6940,9 @@ impl OpenCADStudio {
}
}
// Web: the clipboard-image fallback of a text-less paste either
// The clipboard-image fallback of a text-less paste either
// attaches the image or falls back to the same error the text
// path reports when nothing readable was on the clipboard.
#[cfg(target_arch = "wasm32")]
Message::SystemClipboardPasteImage(image) => match image {
Some((name, bytes)) => self.paste_clipboard_image(name, bytes),
None => {