forked from 1b-agent/opencadstudio-upstream
Fix: Enable clipboard copy for web/browser via system clipboard API
- Modify COPYCLIP command to write entities as JSON to system clipboard - Modify CUTCLIP command to write cut entities as JSON to system clipboard - Modify COPYBASE_AT command to write copied entities as JSON to system clipboard - Entities are serialized as JSON with base point coordinates for cross-platform support - Clipboard data format: OCS_CLIPBOARD_JSON header + base point + entity data - Works in web (WASM) build via Clipboard API and native builds via iced clipboard This fixes the issue where copy command didn't persist to system clipboard in web browser, allowing proper paste operations and clipboard sharing between application instances. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
b3e3555f4f
commit
f98719cfd3
1 file changed
+24
@@ -106,6 +106,14 @@ impl OpenCADStudio {
|
||||
&handles,
|
||||
);
|
||||
let count = self.copy_entities_to_clipboard(i, &handles, base);
|
||||
// Copy to system clipboard as JSON for web/cross-platform support
|
||||
if let Ok(clipboard_data) = serde_json::to_string(&self.clipboard) {
|
||||
return Some(iced::clipboard::write(format!(
|
||||
"OCS_CLIPBOARD_JSON\n{}\n{}",
|
||||
serde_json::json!([base.x, base.y, base.z]).to_string(),
|
||||
clipboard_data
|
||||
)).discard());
|
||||
}
|
||||
self.command_line.push_info(crate::tf!(
|
||||
"{} object(s) copied to clipboard.",
|
||||
count
|
||||
@@ -151,6 +159,14 @@ impl OpenCADStudio {
|
||||
if coords.len() == 3 && !handles.is_empty() {
|
||||
let base = glam::DVec3::new(coords[0], coords[1], coords[2]);
|
||||
let count = self.copy_entities_to_clipboard(i, &handles, base);
|
||||
// Copy to system clipboard as JSON for web/cross-platform support
|
||||
if let Ok(clipboard_data) = serde_json::to_string(&self.clipboard) {
|
||||
let _ = iced::clipboard::write(format!(
|
||||
"OCS_CLIPBOARD_JSON\n{}\n{}",
|
||||
serde_json::json!([base.x, base.y, base.z]).to_string(),
|
||||
clipboard_data
|
||||
));
|
||||
}
|
||||
self.command_line.push_info(crate::tf!(
|
||||
"{} object(s) copied to clipboard (base {:.3},{:.3}).",
|
||||
count,
|
||||
@@ -179,6 +195,14 @@ impl OpenCADStudio {
|
||||
&handles,
|
||||
);
|
||||
let count = self.copy_entities_to_clipboard(i, &handles, base);
|
||||
// Copy to system clipboard as JSON for web/cross-platform support
|
||||
if let Ok(clipboard_data) = serde_json::to_string(&self.clipboard) {
|
||||
let _ = iced::clipboard::write(format!(
|
||||
"OCS_CLIPBOARD_JSON\n{}\n{}",
|
||||
serde_json::json!([base.x, base.y, base.z]).to_string(),
|
||||
clipboard_data
|
||||
));
|
||||
}
|
||||
self.push_undo_snapshot(i, "CUTCLIP");
|
||||
self.tabs[i].scene.erase_entities(&handles);
|
||||
self.tabs[i].scene.deselect_all();
|
||||
|
||||
Reference in new issue
Block a user