AI-native design editor. Open-source Figma alternative.
fix(tauri): restore desktop clipboard access
Danila Poyarkovb5665afab5b6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cca3c4136..37639a3ac 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,6 +33,7 @@### Fixes+- Fix desktop clipboard copy/cut/paste by using Tauri's system clipboard bridge when browser clipboard events are unavailable.- Add AI provider connection testing with clearer setup errors for OpenAI-compatible endpoints.- Increase per-test timeout for slow `gold-preview.fig` fixture tests (`clipboard roundtrip`, `group reclassification`, `glyph blob preservation`, `auto-layout text measurement`, and `render/canvas/cache`) so they no longer flake on slower CI runners.- Fix clone operations (duplicate, instance creation, clipboard copy) sharing mutable references with the original — editing fills, strokes, variable bindings, overrides, or vector networks on one no longer corrupts the other.diff --git a/bun.lock b/bun.lockindex ffb2251ca..8ce80c4ec 100644--- a/bun.lock+++ b/bun.lock@@ -26,6 +26,7 @@"@tailwindcss/vite": "^4.2.1","@tanstack/vue-table": "^8.21.3","@tauri-apps/api": "^2",+ "@tauri-apps/plugin-clipboard-manager": "^2","@tauri-apps/plugin-dialog": "^2.6.0","@tauri-apps/plugin-fs": "^2.4.5","@tauri-apps/plugin-opener": "^2",@@ -1176,6 +1177,8 @@"@tauri-apps/cli-win32-x64-msvc": ["@tauri-apps/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-6Cn7YpPFwzChy0ERz6djKEmUehWrYlM+xTaNzGPgZocw3BD7OfwfWHKVWxXzdjEW2KfKkHddfdxK1XXTYqBRLg=="],+ "@tauri-apps/plugin-clipboard-manager": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-CUlb5Hqi2oZbcZf4VUyUH53XWPPdtpw43EUpCza5HWZJwxEoDowFzNUDt1tRUXA8Uq+XPn17Ysfptip33sG4eQ=="],+"@tauri-apps/plugin-dialog": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-q4Uq3eY87TdcYzXACiYSPhmpBA76shgmQswGkSVio4C82Sz2W4iehe9TnKYwbq7weHiL88Yw19XZm7v28+Micg=="],"@tauri-apps/plugin-fs": ["@tauri-apps/[email protected]", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-dVxWWGE6VrOxC7/jlhyE+ON/Cc2REJlM35R3PJX3UvFw2XwYhLGQVAIyrehenDdKjotipjYEVc4YjOl3qq90fA=="],diff --git a/desktop/Cargo.lock b/desktop/Cargo.lockindex d2111edd1..9a11d5d88 100644--- a/desktop/Cargo.lock+++ b/desktop/Cargo.lock@@ -56,6 +56,27 @@ dependencies = ["derive_arbitrary",]+[[package]]+name = "arboard"+version = "3.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf"+dependencies = [+ "clipboard-win",+ "image",+ "log",+ "objc2",+ "objc2-app-kit",+ "objc2-core-foundation",+ "objc2-core-graphics",+ "objc2-foundation",+ "parking_lot",+ "percent-encoding",+ "windows-sys 0.60.2",+ "wl-clipboard-rs",+ "x11rb",+]+[[package]]name = "async-broadcast"version = "0.7.2"@@ -319,6 +340,12 @@ version = "1.5.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"+[[package]]+name = "byteorder-lite"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"+[[package]]name = "bytes"version = "1.11.1"@@ -458,6 +485,15 @@ dependencies = ["windows-link 0.2.1",]+[[package]]+name = "clipboard-win"+version = "5.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4"+dependencies = [+ "error-code",+]+[[package]]name = "combine"version = "4.6.7"@@ -612,6 +648,12 @@ version = "0.8.21"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"+[[package]]+name = "crunchy"+version = "0.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"+[[package]]name = "crypto-common"version = "0.1.7"@@ -820,6 +862,12 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "downcast-rs"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"+[[package]]name = "dpi"version = "0.1.2"@@ -951,6 +999,12 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "error-code"+version = "3.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59"+[[package]]name = "event-listener"version = "5.4.1"@@ -978,6 +1032,12 @@ version = "2.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"+[[package]]+name = "fax"+version = "0.2.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a"+[[package]]name = "fdeflate"version = "0.3.7"@@ -1033,6 +1093,12 @@ dependencies = ["thiserror 1.0.69",]+[[package]]+name = "fixedbitset"+version = "0.5.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"+[[package]]name = "flate2"version = "1.1.9"@@ -1354,6 +1420,16 @@ dependencies = ["version_check",]+[[package]]+name = "gethostname"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"+dependencies = [+ "rustix",+ "windows-link 0.2.1",+]+[[package]]name = "getrandom"version = "0.1.16"@@ -1553,6 +1629,17 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "half"+version = "2.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"+dependencies = [+ "cfg-if",+ "crunchy",+ "zerocopy",+]+[[package]]name = "hashbrown"version = "0.12.3"@@ -1749,7 +1836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3e795dff5605e0f04bff85ca41b51a96b83e80b281e96231bcaaf1ac35103371"dependencies = ["byteorder",- "png",+ "png 0.17.16",][[package]]@@ -1866,6 +1953,20 @@ dependencies = ["icu_properties",]+[[package]]+name = "image"+version = "0.25.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"+dependencies = [+ "bytemuck",+ "byteorder-lite",+ "moxcms",+ "num-traits",+ "png 0.18.1",+ "tiff",+]+[[package]]name = "indexmap"version = "1.9.3"@@ -2271,6 +2372,16 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "moxcms"+version = "0.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"+dependencies = [+ "num-traits",+ "pxfm",+]+[[package]]name = "muda"version = "0.17.1"@@ -2286,7 +2397,7 @@ dependencies = ["objc2-core-foundation","objc2-foundation","once_cell",- "png",+ "png 0.17.16","serde","thiserror 2.0.18","windows-sys 0.60.2",@@ -2334,6 +2445,15 @@ version = "0.1.14"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"+[[package]]+name = "nom"+version = "8.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"+dependencies = [+ "memchr",+]+[[package]]name = "notify"version = "8.2.0"@@ -2665,6 +2785,7 @@ dependencies = ["serde_json","tauri","tauri-build",+ "tauri-plugin-clipboard-manager","tauri-plugin-dialog","tauri-plugin-fs","tauri-plugin-opener",@@ -2807,6 +2928,17 @@ version = "2.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"+[[package]]+name = "petgraph"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"+dependencies = [+ "fixedbitset",+ "hashbrown 0.15.5",+ "indexmap 2.13.0",+]+[[package]]name = "phf"version = "0.8.0"@@ -2978,7 +3110,7 @@ checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07"dependencies = ["base64 0.22.1","indexmap 2.13.0",- "quick-xml",+ "quick-xml 0.38.4","serde","time",]@@ -2996,6 +3128,19 @@ dependencies = ["miniz_oxide",]+[[package]]+name = "png"+version = "0.18.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"+dependencies = [+ "bitflags 2.11.0",+ "crc32fast",+ "fdeflate",+ "flate2",+ "miniz_oxide",+]+[[package]]name = "polling"version = "3.11.0"@@ -3118,6 +3263,18 @@ dependencies = ["unicode-ident",]+[[package]]+name = "pxfm"+version = "0.1.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f"++[[package]]+name = "quick-error"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"+[[package]]name = "quick-xml"version = "0.38.4"@@ -3127,6 +3284,15 @@ dependencies = ["memchr",]+[[package]]+name = "quick-xml"+version = "0.39.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e"+dependencies = [+ "memchr",+]+[[package]]name = "quinn"version = "0.11.11"@@ -4333,7 +4499,7 @@ dependencies = ["ico","json-patch","plist",- "png",+ "png 0.17.16","proc-macro2","quote","semver",@@ -4380,6 +4546,21 @@ dependencies = ["walkdir",]+[[package]]+name = "tauri-plugin-clipboard-manager"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "206dc20af4ed210748ba945c2774e60fd0acd52b9a73a028402caf809e9b6ecf"+dependencies = [+ "arboard",+ "log",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.18",+]+[[package]]name = "tauri-plugin-dialog"version = "2.6.0"@@ -4688,6 +4869,20 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "tiff"+version = "0.11.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52"+dependencies = [+ "fax",+ "flate2",+ "half",+ "quick-error",+ "weezl",+ "zune-jpeg",+]+[[package]]name = "time"version = "0.3.47"@@ -4969,12 +5164,23 @@ dependencies = ["objc2-core-graphics","objc2-foundation","once_cell",- "png",+ "png 0.17.16","serde","thiserror 2.0.18","windows-sys 0.60.2",]+[[package]]+name = "tree_magic_mini"+version = "3.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"+dependencies = [+ "memchr",+ "nom",+ "petgraph",+]+[[package]]name = "try-lock"version = "0.2.5"@@ -5314,6 +5520,76 @@ dependencies = ["semver",]+[[package]]+name = "wayland-backend"+version = "0.3.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2857dd20b54e916ec7253b3d6b4d5c4d7d4ca2c33c2e11c6c76a99bd8744755d"+dependencies = [+ "cc",+ "downcast-rs",+ "rustix",+ "smallvec",+ "wayland-sys",+]++[[package]]+name = "wayland-client"+version = "0.31.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "645c7c96bb74690c3189b5c9cb4ca1627062bb23693a4fad9d8c3de958260144"+dependencies = [+ "bitflags 2.11.0",+ "rustix",+ "wayland-backend",+ "wayland-scanner",+]++[[package]]+name = "wayland-protocols"+version = "0.32.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6"+dependencies = [+ "bitflags 2.11.0",+ "wayland-backend",+ "wayland-client",+ "wayland-scanner",+]++[[package]]+name = "wayland-protocols-wlr"+version = "0.3.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234"+dependencies = [+ "bitflags 2.11.0",+ "wayland-backend",+ "wayland-client",+ "wayland-protocols",+ "wayland-scanner",+]++[[package]]+name = "wayland-scanner"+version = "0.31.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9c324a910fd86ebdc364a3e61ec1f11737d3b1d6c273c0239ee8ff4bc0d24b4a"+dependencies = [+ "proc-macro2",+ "quick-xml 0.39.4",+ "quote",+]++[[package]]+name = "wayland-sys"+version = "0.31.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be"+dependencies = [+ "pkg-config",+]+[[package]]name = "web-sys"version = "0.3.90"@@ -5432,6 +5708,12 @@ dependencies = ["windows-core 0.61.2",]+[[package]]+name = "weezl"+version = "0.1.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"+[[package]]name = "winapi"version = "0.3.9"@@ -5991,6 +6273,24 @@ dependencies = ["wasmparser",]+[[package]]+name = "wl-clipboard-rs"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e9651471a32e87d96ef3a127715382b2d11cc7c8bb9822ded8a7cc94072eb0a3"+dependencies = [+ "libc",+ "log",+ "os_pipe",+ "rustix",+ "thiserror 2.0.18",+ "tree_magic_mini",+ "wayland-backend",+ "wayland-client",+ "wayland-protocols",+ "wayland-protocols-wlr",+]+[[package]]name = "writeable"version = "0.6.2"@@ -6063,6 +6363,23 @@ dependencies = ["pkg-config",]+[[package]]+name = "x11rb"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"+dependencies = [+ "gethostname",+ "rustix",+ "x11rb-protocol",+]++[[package]]+name = "x11rb-protocol"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"+[[package]]name = "xattr"version = "1.6.1"@@ -6309,6 +6626,21 @@ dependencies = ["pkg-config",]+[[package]]+name = "zune-core"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9"++[[package]]+name = "zune-jpeg"+version = "0.5.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"+dependencies = [+ "zune-core",+]+[[package]]name = "zvariant"version = "5.10.0"diff --git a/desktop/Cargo.toml b/desktop/Cargo.tomlindex 71e94284b..7ee5031e7 100644--- a/desktop/Cargo.toml+++ b/desktop/Cargo.toml@@ -33,6 +33,7 @@ font-kit = "0.14.3"fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs", branch = "dev" }tauri-plugin-updater = "2"tauri-plugin-process = "2"+tauri-plugin-clipboard-manager = "2"[target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies]tauri-plugin-single-instance = "2"diff --git a/desktop/capabilities/default.json b/desktop/capabilities/default.jsonindex e33eac910..00063fe9b 100644--- a/desktop/capabilities/default.json+++ b/desktop/capabilities/default.json@@ -11,6 +11,9 @@"dialog:allow-open","updater:default","process:default",+ "clipboard-manager:allow-read-text",+ "clipboard-manager:allow-write-html",+ "clipboard-manager:allow-write-text",{"identifier": "fs:allow-read-file","allow": [{ "path": "**" }]diff --git a/desktop/src/lib.rs b/desktop/src/lib.rsindex 6ae99b108..fe05ef1b6 100644--- a/desktop/src/lib.rs+++ b/desktop/src/lib.rs@@ -125,6 +125,7 @@ pub fn run() {]).plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_dialog::init())+ .plugin(tauri_plugin_clipboard_manager::init()).plugin(tauri_plugin_fs::init()).plugin(tauri_plugin_shell::init()).plugin(tauri_plugin_updater::Builder::new().build())diff --git a/lint/plugin.js b/lint/plugin.jsindex 692900360..583f5028d 100644--- a/lint/plugin.js+++ b/lint/plugin.js@@ -2083,6 +2083,25 @@ const noLocalJsonObjectAliases = {}}+const noImportTypeAnnotations = {+ meta: {+ docs: {+ description: 'Disallow inline import() type annotations — use top-level import type instead'+ }+ },+ create(context) {+ return {+ TSImportType(node) {+ context.report({+ node,+ message:+ 'Use a top-level import type instead of an inline import() type annotation. Dynamic imports are only for runtime lazy loading.'+ })+ }+ }+ }+}+const noFlatKiwiModules = createProgramFilenameRule({description: 'Disallow flat top-level Kiwi modules — group code under Kiwi subdomains',check(file) {@@ -2101,6 +2120,7 @@ const plugin = {meta: { name: 'open-pencil' },rules: {'no-inline-named-types': noInlineNamedTypes,+ 'no-import-type-annotations': noImportTypeAnnotations,'no-structuredclone-scene-arrays': noStructuredCloneSceneArrays,'no-vue-style-blocks': noVueStyleBlocks,'no-native-title-attributes-in-vue': noNativeTitleAttributesInVue,diff --git a/oxlint.json b/oxlint.jsonindex ad86e2da6..29e7c27e9 100644--- a/oxlint.json+++ b/oxlint.json@@ -137,6 +137,7 @@],"vue/require-default-export": "error","vue/require-typed-ref": "error",+ "open-pencil/no-import-type-annotations": "error","open-pencil/no-inline-named-types": ["error",{diff --git a/package.json b/package.jsonindex 17932629f..8dc73024f 100644--- a/package.json+++ b/package.json@@ -56,11 +56,14 @@"@open-pencil/dom-css": "workspace:*","@open-pencil/fig": "workspace:*","@open-pencil/kiwi": "workspace:*",+ "@open-pencil/pen": "workspace:*",+ "@open-pencil/scene-graph": "workspace:*","@open-pencil/vue": "workspace:*","@openrouter/ai-sdk-provider": "^2.9.0","@tailwindcss/vite": "^4.2.1","@tanstack/vue-table": "^8.21.3","@tauri-apps/api": "^2",+ "@tauri-apps/plugin-clipboard-manager": "^2","@tauri-apps/plugin-dialog": "^2.6.0","@tauri-apps/plugin-fs": "^2.4.5","@tauri-apps/plugin-opener": "^2",@@ -95,12 +98,7 @@"y-protocols": "^1.0.7","yjs": "^13.6.29","yoga-layout": "npm:@open-pencil/[email protected]",- "zod": "^4.3.6",- "@open-pencil/scene-graph": "workspace:*",- "@open-pencil/pen": "workspace:*"- },- "overrides": {- "brace-expansion": "5.0.6"+ "zod": "^4.3.6"},"devDependencies": {"@agentclientprotocol/sdk": "^0.14.1",@@ -139,5 +137,8 @@"vue-tsc": "^3.2.5","workbox-window": "^7.4.0","ws": "^8.19.0"+ },+ "overrides": {+ "brace-expansion": "5.0.6"}}diff --git a/src/app/editor/canvas/menu/actions.ts b/src/app/editor/canvas/menu/actions.tsindex b8ceb0b44..08cd7c692 100644--- a/src/app/editor/canvas/menu/actions.ts+++ b/src/app/editor/canvas/menu/actions.ts@@ -5,7 +5,10 @@ import { nodeToXPath } from '@open-pencil/core/xpath'import type { EditorStore } from '@/app/editor/active-store'import { pasteClipboardToReplace } from '@/app/editor/clipboard/paste-to-replace'+import { executeClipboardCommand } from '@/app/editor/clipboard/system'import { toast } from '@/app/shell/ui'+import { writeTauriClipboardText } from '@/app/tauri/clipboard'+import { isTauri } from '@/app/tauri/env'function toArrayBuffer(data: Uint8Array): ArrayBuffer {const bytes = new Uint8Array(data.length)@@ -21,26 +24,25 @@ export function createCanvasMenuActions(store: EditorStore, selectedIds: Ref<Set}function execCommand(cmd: 'copy' | 'cut' | 'paste') {- try {- if (window.document.execCommand(cmd)) return- } catch (error) {- console.warn(`Clipboard command ${cmd} failed`, error)- }-- toast.error('Clipboard access is blocked in this browser context')+ void executeClipboardCommand(store, cmd).then((ok) => {+ if (!ok) toast.error('Clipboard access is blocked in this browser context')+ })}async function clipboardWrite(text: string | null, label: string) {if (!text) return- await copy(text)+ if (isTauri()) {+ await writeTauriClipboardText(text)+ } else {+ await copy(text)+ }toast.info(`Copied as ${label}`)}async function copyNodeId() {const nodeIds = ids()if (nodeIds.length === 0) return- await copy(nodeIds.join(', '))- toast.info(`Copied node ID${nodeIds.length > 1 ? 's' : ''}`)+ await clipboardWrite(nodeIds.join(', '), `node ID${nodeIds.length > 1 ? 's' : ''}`)}async function copyXPath() {@@ -50,8 +52,7 @@ export function createCanvasMenuActions(store: EditorStore, selectedIds: Ref<Set.map((id) => nodeToXPath(store.graph, id)).filter((xpath): xpath is string => xpath !== null)if (xpaths.length === 0) return- await copy(xpaths.join('\n'))- toast.info(`Copied XPath${xpaths.length > 1 ? 's' : ''}`)+ await clipboardWrite(xpaths.join('\n'), `XPath${xpaths.length > 1 ? 's' : ''}`)}async function copyAsPNG() {diff --git a/src/app/editor/clipboard/paste-to-replace.ts b/src/app/editor/clipboard/paste-to-replace.tsindex a9459f729..9446d16be 100644--- a/src/app/editor/clipboard/paste-to-replace.ts+++ b/src/app/editor/clipboard/paste-to-replace.ts@@ -1,7 +1,18 @@import type { EditorStore } from '@/app/editor/active-store'import { toast } from '@/app/shell/ui'+import { readTauriClipboardText } from '@/app/tauri/clipboard'+import { isTauri } from '@/app/tauri/env'++function isDesignClipboardHtml(text: string) {+ return text.includes('<!--(openpencil)') || text.includes('(figma)')+}async function readClipboardHtml() {+ if (isTauri()) {+ const text = await readTauriClipboardText()+ return text && isDesignClipboardHtml(text) ? text : null+ }+if (typeof navigator.clipboard.read !== 'function') return nullconst items = await navigator.clipboard.read()for (const item of items) {diff --git a/src/app/editor/clipboard/system.ts b/src/app/editor/clipboard/system.tsnew file mode 100644index 000000000..2ed639f92--- /dev/null+++ b/src/app/editor/clipboard/system.ts@@ -0,0 +1,71 @@+import type { Vector } from '@open-pencil/scene-graph/primitives'++import type { EditorStore } from '@/app/editor/active-store'+import { readTauriClipboardText, writeTauriClipboardHtml } from '@/app/tauri/clipboard'+import { isTauri } from '@/app/tauri/env'++function createTransfer() {+ if (typeof DataTransfer === 'undefined') return null+ return new DataTransfer()+}++function isDesignClipboardHtml(text: string) {+ return text.includes('<!--(openpencil)') || text.includes('(figma)')+}++export async function copySelectionToTauriClipboard(store: EditorStore) {+ if (!isTauri()) return false+ try {+ const transfer = createTransfer()+ if (!transfer) return false+ await store.writeCopyData(transfer)+ const html = transfer.getData('text/html')+ const plainText = transfer.getData('text/plain')+ if (!html && !plainText) return false+ await writeTauriClipboardHtml(html || plainText, plainText)+ return true+ } catch (error) {+ console.warn('Tauri clipboard copy failed', error)+ return false+ }+}++export async function pasteFromTauriClipboard(store: EditorStore, cursorPos?: Vector) {+ if (!isTauri()) return false+ try {+ const text = await readTauriClipboardText()+ if (!text || !isDesignClipboardHtml(text)) return false+ await store.pasteFromHTML(text, cursorPos)+ return true+ } catch (error) {+ console.warn('Tauri clipboard paste failed', error)+ return false+ }+}++export async function executeClipboardCommand(+ store: EditorStore,+ command: 'copy' | 'cut' | 'paste'+) {+ if (command === 'copy') {+ if (await copySelectionToTauriClipboard(store)) return true+ }++ if (command === 'cut') {+ if (await copySelectionToTauriClipboard(store)) {+ store.deleteSelected()+ return true+ }+ }++ if (command === 'paste') {+ if (await pasteFromTauriClipboard(store)) return true+ }++ try {+ return document.execCommand(command)+ } catch (error) {+ console.warn(`Clipboard command ${command} failed`, error)+ return false+ }+}diff --git a/src/app/shell/keyboard/clipboard.ts b/src/app/shell/keyboard/clipboard.tsindex b4f07ecce..bd7a4d949 100644--- a/src/app/shell/keyboard/clipboard.ts+++ b/src/app/shell/keyboard/clipboard.ts@@ -3,18 +3,38 @@ import { useEventListener } from '@vueuse/core'import { extractImageFilesFromClipboard } from '@open-pencil/vue'import type { EditorStore } from '@/app/editor/active-store'+import {+ copySelectionToTauriClipboard,+ pasteFromTauriClipboard+} from '@/app/editor/clipboard/system'import { isEditing } from '@/app/shell/keyboard/focus'+import { isTauri } from '@/app/tauri/env'++function cursorPosition(store: EditorStore) {+ const { cursorCanvasX: ccx, cursorCanvasY: ccy } = store.state+ return ccx != null && ccy != null ? { x: ccx, y: ccy } : undefined+}export function bindEditorClipboard(store: EditorStore) {useEventListener(window, 'copy', (e: ClipboardEvent) => {if (isEditing(e)) returne.preventDefault()+ if (isTauri()) {+ void copySelectionToTauriClipboard(store)+ return+ }if (e.clipboardData) void store.writeCopyData(e.clipboardData)})useEventListener(window, 'cut', (e: ClipboardEvent) => {if (isEditing(e)) returne.preventDefault()+ if (isTauri()) {+ void copySelectionToTauriClipboard(store).then((copied) => {+ if (copied) store.deleteSelected()+ })+ return+ }if (e.clipboardData) void store.writeCopyData(e.clipboardData)store.deleteSelected()})@@ -23,8 +43,7 @@ export function bindEditorClipboard(store: EditorStore) {if (isEditing(e)) returne.preventDefault()- const { cursorCanvasX: ccx, cursorCanvasY: ccy } = store.state- const cursorPos = ccx != null && ccy != null ? { x: ccx, y: ccy } : undefined+ const cursorPos = cursorPosition(store)const imageFiles = extractImageFilesFromClipboard(e)if (imageFiles.length) {@@ -35,6 +54,11 @@ export function bindEditorClipboard(store: EditorStore) {}const html = e.clipboardData?.getData('text/html') ?? ''- if (html) void store.pasteFromHTML(html, cursorPos)+ if (html) {+ void store.pasteFromHTML(html, cursorPos)+ return+ }++ if (isTauri()) void pasteFromTauriClipboard(store, cursorPos)})}diff --git a/src/app/shell/menu/app-menu.ts b/src/app/shell/menu/app-menu.tsindex 7ead26f86..90b8bfa0b 100644--- a/src/app/shell/menu/app-menu.ts+++ b/src/app/shell/menu/app-menu.ts@@ -4,6 +4,7 @@ import type { MenuEntry } from '@open-pencil/vue'import { useEditorCommands, useI18n } from '@open-pencil/vue'import { useEditorStore } from '@/app/editor/active-store'+import { executeClipboardCommand } from '@/app/editor/clipboard/system'import { createSharedEditorMenuActions } from '@/app/shell/menu/editor-actions'import type { AppMenuActionItem, AppMenuEntry, AppMenuGroupSchema } from '@/app/shell/menu/schema'import { APP_MENU_SCHEMA } from '@/app/shell/menu/schema'@@ -84,7 +85,9 @@ export function useAppMenu() {save: () => void store.saveFigFile(),'save-as': () => void store.saveFigFileAs(),'export-selection': () => exportSelection('png'),- cut: () => document.execCommand('cut'),+ copy: () => void executeClipboardCommand(store, 'copy'),+ cut: () => void executeClipboardCommand(store, 'cut'),+ paste: () => void executeClipboardCommand(store, 'paste'),'export-png': () => exportSelection('png'),'export-svg': () => exportSelection('svg'),'export-fig': () => exportSelection('fig'),diff --git a/src/app/shell/menu/use.ts b/src/app/shell/menu/use.tsindex 66f6b7f39..364c07792 100644--- a/src/app/shell/menu/use.ts+++ b/src/app/shell/menu/use.ts@@ -5,6 +5,7 @@ import type { EditorCommandId } from '@open-pencil/vue'import { useEditorStore } from '@/app/editor/active-store'import { pasteClipboardToReplace } from '@/app/editor/clipboard/paste-to-replace'+import { executeClipboardCommand } from '@/app/editor/clipboard/system'import { createSharedEditorMenuActions } from '@/app/shell/menu/editor-actions'import { importFileDialog, openFileDialog } from '@/app/shell/menu/files'import { useAppTheme } from '@/app/shell/theme'@@ -42,10 +43,6 @@ const COMMAND_MENU_IDS = new Set<string>([export { importFileDialog, openFileDialog }export { openFileFromPath } from '@/app/shell/menu/files'-function execBrowserCommand(command: 'copy' | 'cut' | 'paste'): void {- document.execCommand(command)-}-export function useMenu() {if (!isTauri()) return@@ -77,9 +74,9 @@ export function useMenu() {autosave: () => {store.state.autosaveEnabled = !store.state.autosaveEnabled},- copy: () => execBrowserCommand('copy'),- cut: () => execBrowserCommand('cut'),- paste: () => execBrowserCommand('paste'),+ copy: () => void executeClipboardCommand(store, 'copy'),+ cut: () => void executeClipboardCommand(store, 'cut'),+ paste: () => void executeClipboardCommand(store, 'paste'),'paste-to-replace': () => void pasteClipboardToReplace(store),'check-updates': () => void checkForAppUpdate({ messages: dialogs }),...createSharedEditorMenuActions(setTheme)diff --git a/src/app/tauri/clipboard.ts b/src/app/tauri/clipboard.tsnew file mode 100644index 000000000..d5dbcaa52--- /dev/null+++ b/src/app/tauri/clipboard.ts@@ -0,0 +1,20 @@+import { readText, writeHtml, writeText } from '@tauri-apps/plugin-clipboard-manager'++import { isTauri } from '@/app/tauri/env'++export async function writeTauriClipboardHtml(html: string, plainText: string) {+ if (!isTauri()) return false+ await writeHtml(html, plainText)+ return true+}++export async function writeTauriClipboardText(text: string) {+ if (!isTauri()) return false+ await writeText(text)+ return true+}++export async function readTauriClipboardText() {+ if (!isTauri()) return null+ return readText()+}diff --git a/tests/e2e/clipboard/tauri-clipboard.spec.ts b/tests/e2e/clipboard/tauri-clipboard.spec.tsnew file mode 100644index 000000000..e9cb85c37--- /dev/null+++ b/tests/e2e/clipboard/tauri-clipboard.spec.ts@@ -0,0 +1,189 @@+import type { Page } from '@playwright/test'++import { expect, test } from '#tests/e2e/fixtures'+import { CanvasHelper } from '#tests/helpers/canvas'++type PageChildSummary = {+ name: string+ type: string+}++async function installTauriClipboardMock(page: Page) {+ await page.addInitScript(() => {+ const state = {+ text: '',+ html: '',+ writes: [] as Array<{ cmd: string; args: unknown }>+ }++ Object.defineProperty(window, '__OPENPENCIL_TEST_CLIPBOARD__', {+ configurable: true,+ value: state+ })++ let callbackId = 1+ const callbacks = new Map<number, unknown>()++ Object.defineProperty(window, '__TAURI_INTERNALS__', {+ configurable: true,+ value: {+ callbacks,+ metadata: {+ currentWindow: { label: 'main' },+ currentWebview: { label: 'main' }+ },+ convertFileSrc: (filePath: string) => filePath,+ invoke: async (cmd: string, args?: Record<string, unknown>) => {+ state.writes.push({ cmd, args })+ switch (cmd) {+ case 'plugin:clipboard-manager|write_html': {+ state.html = String(args?.html ?? '')+ state.text = String(args?.altText ?? state.html)+ return null+ }+ case 'plugin:clipboard-manager|write_text': {+ state.text = String(args?.text ?? '')+ state.html = ''+ return null+ }+ case 'plugin:clipboard-manager|read_text':+ return state.html || state.text+ case 'list_system_fonts':+ case 'take_pending_open':+ return []+ case 'load_system_font':+ return null+ case 'plugin:event|listen':+ case 'plugin:event|unlisten':+ case 'plugin:process|exit':+ case 'plugin:process|restart':+ return null+ default:+ return null+ }+ },+ transformCallback: (callback: unknown) => {+ const id = callbackId+++ callbacks.set(id, callback)+ return id+ },+ unregisterCallback: (id: number) => {+ callbacks.delete(id)+ },+ runCallback: () => null+ }+ })+ })+}++async function createTauriEditorPage(page: Page) {+ await installTauriClipboardMock(page)+ await page.goto('/')+ const canvas = new CanvasHelper(page)+ await canvas.waitForInit()+ return canvas+}++function pageChildren(page: Page): Promise<PageChildSummary[]> {+ return page.evaluate(() => {+ const store = window.openPencil?.getStore?.()+ if (!store) throw new Error('OpenPencil store not initialized')+ return store.graph.getChildren(store.state.currentPageId).map((node) => ({+ name: node.name,+ type: node.type+ }))+ })+}++function selectedCount(page: Page): Promise<number> {+ return page.evaluate(() => {+ const store = window.openPencil?.getStore?.()+ if (!store) throw new Error('OpenPencil store not initialized')+ return store.state.selectedIds.size+ })+}++function testClipboard(page: Page) {+ return page.evaluate(() => window.__OPENPENCIL_TEST_CLIPBOARD__)+}++async function dispatchClipboardEvent(page: Page, type: 'copy' | 'cut' | 'paste') {+ await page.evaluate((eventType) => {+ window.dispatchEvent(new ClipboardEvent(eventType, { bubbles: true, cancelable: true }))+ }, type)+}++test('Tauri copy writes selected design HTML without requiring ClipboardEvent.clipboardData', async ({+ page+}) => {+ const canvas = await createTauriEditorPage(page)+ await canvas.drawRect(160, 160, 96, 72)++ await dispatchClipboardEvent(page, 'copy')++ await expect+ .poll(() => testClipboard(page))+ .toMatchObject({+ text: 'Rectangle'+ })+ const clipboard = await testClipboard(page)+ expect(clipboard.html).toContain('(figma)')+ expect(+ clipboard.writes.some((entry) => entry.cmd === 'plugin:clipboard-manager|write_html')+ ).toBe(true)+ await expect(page.getByText('Clipboard access is blocked in this browser context')).toHaveCount(0)+ canvas.assertNoErrors()+})++test('Tauri paste restores copied design data from plugin clipboard text', async ({ page }) => {+ const canvas = await createTauriEditorPage(page)+ await canvas.drawRect(160, 160, 96, 72)+ await dispatchClipboardEvent(page, 'copy')+ await expect.poll(() => testClipboard(page)).toMatchObject({ text: 'Rectangle' })++ expect(await pageChildren(page)).toHaveLength(1)+ await canvas.deleteSelection()+ expect(await pageChildren(page)).toHaveLength(0)++ await dispatchClipboardEvent(page, 'paste')+ await canvas.waitForRender()++ const children = await pageChildren(page)+ expect(children).toEqual([{ name: 'Rectangle', type: 'RECTANGLE' }])+ expect(await selectedCount(page)).toBe(1)+ await expect(page.getByText('Clipboard access is blocked in this browser context')).toHaveCount(0)+ canvas.assertNoErrors()+})++test('Tauri cut writes design data and deletes selection only after clipboard write succeeds', async ({+ page+}) => {+ const canvas = await createTauriEditorPage(page)+ await canvas.drawRect(160, 160, 96, 72)++ await dispatchClipboardEvent(page, 'cut')+ await canvas.waitForRender()++ await expect.poll(() => pageChildren(page)).toEqual([])+ const clipboard = await testClipboard(page)+ expect(clipboard.html).toContain('(figma)')+ expect(clipboard.text).toBe('Rectangle')+ await expect(page.getByText('Clipboard access is blocked in this browser context')).toHaveCount(0)+ canvas.assertNoErrors()+})++test('Tauri context-menu copy uses plugin clipboard fallback instead of blocked browser command', async ({+ page+}) => {+ const canvas = await createTauriEditorPage(page)+ await canvas.drawRect(160, 160, 96, 72)++ const box = await canvas.canvas.boundingBox()+ if (!box) throw new Error('Canvas has no bounding box')+ await page.mouse.click(box.x + 190, box.y + 190, { button: 'right' })+ await page.getByTestId('context-copy').click()++ await expect.poll(() => testClipboard(page)).toMatchObject({ text: 'Rectangle' })+ await expect(page.getByText('Clipboard access is blocked in this browser context')).toHaveCount(0)+ canvas.assertNoErrors()+})