Skip to content

AI-native design editor. Open-source Figma alternative.

Collab UI polish, vue-router, extract HsvColorArea

Danila Poyarkov76134ccc1a94
diff --git a/.gitignore b/.gitignore
index a0963edaa..9042f1125 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ test-results/
.env
packages/docs/.vitepress/cache/
packages/docs/.vitepress/dist/
+packages/collab/.wrangler/
diff --git a/bun.lock b/bun.lock
index 9b9996d11..fab8794d1 100644
--- a/bun.lock
+++ b/bun.lock
@@ -30,6 +30,7 @@
"tailwindcss": "^4.2.1",
"valibot": "^1.2.0",
"vue": "^3.5.29",
+ "vue-router": "^5.0.3",
"vue-stream-markdown": "^0.6.0",
"y-protocols": "^1.0.7",
"yjs": "^13.6.29",
@@ -157,6 +158,8 @@
"@antfu/install-pkg": ["@antfu/[email protected]", "", { "dependencies": { "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" } }, "sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ=="],
+ "@babel/generator": ["@babel/[email protected]", "", { "dependencies": { "@babel/parser": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw=="],
+
"@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
"@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
@@ -639,6 +642,8 @@
"@vitejs/plugin-vue": ["@vitejs/[email protected]", "", { "dependencies": { "@rolldown/pluginutils": "1.0.0-rc.2" }, "peerDependencies": { "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "vue": "^3.2.25" } }, "sha512-uM5iXipgYIn13UUQCZNdWkYk+sysBeA97d5mHsAoAt1u/wpN3+zxOmsVJWosuzX+IMGRzeYUNytztrYznboIkQ=="],
+ "@vue-macros/common": ["@vue-macros/[email protected]", "", { "dependencies": { "@vue/compiler-sfc": "^3.5.22", "ast-kit": "^2.1.2", "local-pkg": "^1.1.2", "magic-string-ast": "^1.0.2", "unplugin-utils": "^0.3.0" }, "peerDependencies": { "vue": "^2.7.0 || ^3.2.25" }, "optionalPeers": ["vue"] }, "sha512-h9t4ArDdniO9ekYHAD95t9AZcAbb19lEGK+26iAjUODOIJKmObDNBSe4+6ELQAA3vtYiFPPBtHh7+cQCKi3Dng=="],
+
"@vue/compiler-core": ["@vue/[email protected]", "", { "dependencies": { "@babel/parser": "^7.29.0", "@vue/shared": "3.5.29", "entities": "^7.0.1", "estree-walker": "^2.0.2", "source-map-js": "^1.2.1" } }, "sha512-cuzPhD8fwRHk8IGfmYaR4eEe4cAyJEL66Ove/WZL7yWNL134nqLddSLwNRIsFlnnW1kK+p8Ck3viFnC0chXCXw=="],
"@vue/compiler-dom": ["@vue/[email protected]", "", { "dependencies": { "@vue/compiler-core": "3.5.29", "@vue/shared": "3.5.29" } }, "sha512-n0G5o7R3uBVmVxjTIYcz7ovr8sy7QObFG8OQJ3xGCDNhbG60biP/P5KnyY8NLd81OuT1WJflG7N4KWYHaeeaIg=="],
@@ -647,11 +652,11 @@
"@vue/compiler-ssr": ["@vue/[email protected]", "", { "dependencies": { "@vue/compiler-dom": "3.5.29", "@vue/shared": "3.5.29" } }, "sha512-Y/ARJZE6fpjzL5GH/phJmsFwx3g6t2KmHKHx5q+MLl2kencADKIrhH5MLF6HHpRMmlRAYBRSvv347Mepf1zVNw=="],
- "@vue/devtools-api": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-kit": "^7.7.9" } }, "sha512-kIE8wvwlcZ6TJTbNeU2HQNtaxLx3a84aotTITUuL/4bzfPxzajGBOoqjMhwZJ8L9qFYDU/lAYMEEm11dnZOD6g=="],
+ "@vue/devtools-api": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-kit": "^8.0.7" } }, "sha512-tc1TXAxclsn55JblLkFVcIRG7MeSJC4fWsPjfM7qu/IcmPUYnQ5Q8vzWwBpyDY24ZjmZTUCCwjRSNbx58IhlAA=="],
- "@vue/devtools-kit": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-shared": "^7.7.9", "birpc": "^2.3.0", "hookable": "^5.5.3", "mitt": "^3.0.1", "perfect-debounce": "^1.0.0", "speakingurl": "^14.0.1", "superjson": "^2.2.2" } }, "sha512-PyQ6odHSgiDVd4hnTP+aDk2X4gl2HmLDfiyEnn3/oV+ckFDuswRs4IbBT7vacMuGdwY/XemxBoh302ctbsptuA=="],
+ "@vue/devtools-kit": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-shared": "^8.0.7", "birpc": "^2.6.1", "hookable": "^5.5.3", "perfect-debounce": "^2.0.0" } }, "sha512-H6esJGHGl5q0E9iV3m2EoBQHJ+V83WMW83A0/+Fn95eZ2iIvdsq4+UCS6yT/Fdd4cGZSchx/MdWDreM3WqMsDw=="],
- "@vue/devtools-shared": ["@vue/[email protected]", "", { "dependencies": { "rfdc": "^1.4.1" } }, "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA=="],
+ "@vue/devtools-shared": ["@vue/[email protected]", "", {}, "sha512-CgAb9oJH5NUmbQRdYDj/1zMiaICYSLtm+B1kxcP72LBrifGAjUmt8bx52dDH1gWRPlQgxGPqpAMKavzVirAEhA=="],
"@vue/reactivity": ["@vue/[email protected]", "", { "dependencies": { "@vue/shared": "3.5.29" } }, "sha512-zcrANcrRdcLtmGZETBxWqIkoQei8HaFpZWx/GHKxx79JZsiZ8j1du0VUJtu4eJjgFvU/iKL5lRXFXksVmI+5DA=="],
@@ -689,6 +694,10 @@
"assert-never": ["[email protected]", "", {}, "sha512-5oJg84os6NMQNl27T9LnZkvvqzvAnHu03ShCnoj6bsJwS7L8AO4lf+C/XjK/nvzEqQB744moC6V128RucQd1jA=="],
+ "ast-kit": ["[email protected]", "", { "dependencies": { "@babel/parser": "^7.28.5", "pathe": "^2.0.3" } }, "sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw=="],
+
+ "ast-walker-scope": ["[email protected]", "", { "dependencies": { "@babel/parser": "^7.28.4", "ast-kit": "^2.1.3" } }, "sha512-cbdCP0PGOBq0ASG+sjnKIoYkWMKhhz+F/h9pRexUdX2Hd38+WOlBkRKlqkGOSm0YQpcFMQBJeK4WspUAkwsEdg=="],
+
"babel-walk": ["[email protected]", "", { "dependencies": { "@babel/types": "^7.9.6" } }, "sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw=="],
"badgen": ["[email protected]", "", {}, "sha512-svDuwkc63E/z0ky3drpUppB83s/nlgDciH9m+STwwQoWyq7yCgew1qEfJ+9axkKdNq7MskByptWUN9j1PGMwFA=="],
@@ -887,8 +896,12 @@
"jscpd-sarif-reporter": ["[email protected]", "", { "dependencies": { "colors": "^1.4.0", "fs-extra": "^11.2.0", "node-sarif-builder": "^3.4.0" } }, "sha512-b9Sm3IPZ3+m8Lwa4gZa+4/LhDhlc/ZLEsLXKSOy1DANQ6kx0ueqZT+fUHWEdQ6m0o3+RIVIa7DmvLSojQD05ng=="],
+ "jsesc": ["[email protected]", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="],
+
"json-schema": ["[email protected]", "", {}, "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="],
+ "json5": ["[email protected]", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
+
"jsonfile": ["[email protected]", "", { "dependencies": { "universalify": "^2.0.0" }, "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg=="],
"jstransformer": ["[email protected]", "", { "dependencies": { "is-promise": "^2.0.0", "promise": "^7.0.1" } }, "sha512-C9YK3Rf8q6VAPDCCU9fnqo3mAfOH6vUGnMcP4AQAYIEpWtfGLpwOTmZ+igtdK5y+VvI2n3CyYSzy4Qh34eq24A=="],
@@ -929,6 +942,8 @@
"magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
+ "magic-string-ast": ["[email protected]", "", { "dependencies": { "magic-string": "^0.30.19" } }, "sha512-CvkkH1i81zl7mmb94DsRiFeG9V2fR2JeuK8yDgS8oiZSFa++wWLEgZ5ufEOyLHbvSbD1gTRKv9NdX69Rnvr9JA=="],
+
"mark.js": ["[email protected]", "", {}, "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ=="],
"markdown-table": ["[email protected]", "", { "dependencies": { "repeat-string": "^1.0.0" } }, "sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A=="],
@@ -1049,6 +1064,8 @@
"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
+ "muggle-string": ["[email protected]", "", {}, "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ=="],
+
"nanoid": ["[email protected]", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
"node-sarif-builder": ["[email protected]", "", { "dependencies": { "@types/sarif": "^2.1.7", "fs-extra": "^11.1.1" } }, "sha512-tGnJW6OKRii9u/b2WiUViTJS+h7Apxx17qsMUjsUeNDiMMX5ZFf8F8Fcz7PAQ6omvOxHZtvDTmOYKJQwmfpjeg=="],
@@ -1081,7 +1098,7 @@
"pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
- "perfect-debounce": ["[email protected]", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="],
+ "perfect-debounce": ["[email protected]", "", {}, "sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g=="],
"picocolors": ["[email protected]", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
@@ -1157,6 +1174,8 @@
"run-parallel": ["[email protected]", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="],
+ "scule": ["[email protected]", "", {}, "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g=="],
+
"search-insights": ["[email protected]", "", {}, "sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ=="],
"semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
@@ -1265,6 +1284,8 @@
"vue-demi": ["[email protected]", "", { "peerDependencies": { "@vue/composition-api": "^1.0.0-rc.1", "vue": "^3.0.0-0 || ^2.6.0" }, "optionalPeers": ["@vue/composition-api"], "bin": { "vue-demi-fix": "bin/vue-demi-fix.js", "vue-demi-switch": "bin/vue-demi-switch.js" } }, "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg=="],
+ "vue-router": ["[email protected]", "", { "dependencies": { "@babel/generator": "^7.28.6", "@vue-macros/common": "^3.1.1", "@vue/devtools-api": "^8.0.6", "ast-walker-scope": "^0.8.3", "chokidar": "^5.0.0", "json5": "^2.2.3", "local-pkg": "^1.1.2", "magic-string": "^0.30.21", "mlly": "^1.8.0", "muggle-string": "^0.4.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", "scule": "^1.3.0", "tinyglobby": "^0.2.15", "unplugin": "^3.0.0", "unplugin-utils": "^0.3.1", "yaml": "^2.8.2" }, "peerDependencies": { "@pinia/colada": ">=0.21.2", "@vue/compiler-sfc": "^3.5.17", "pinia": "^3.0.4", "vue": "^3.5.0" }, "optionalPeers": ["@pinia/colada", "@vue/compiler-sfc", "pinia"] }, "sha512-nG1c7aAFac7NYj8Hluo68WyWfc41xkEjaR0ViLHCa3oDvTQ/nIuLJlXJX1NUPw/DXzx/8+OKMng045HHQKQKWw=="],
+
"vue-stream-markdown": ["[email protected]", "", { "dependencies": { "@floating-ui/dom": "^1.7.5", "@vueuse/core": "^14.2.1", "marked": "^17.0.3", "mdast-util-from-markdown": "^2.0.3", "mdast-util-frontmatter": "^2.0.1", "mdast-util-gfm": "^3.1.0", "mdast-util-math": "^3.0.0", "mdast-util-to-markdown": "^2.1.2", "micromark-extension-cjk-friendly": "^2.0.1", "micromark-extension-cjk-friendly-gfm-strikethrough": "^2.0.1", "micromark-extension-frontmatter": "^2.0.0", "micromark-extension-gfm": "^3.0.0", "micromark-extension-math": "^3.1.0", "micromark-util-types": "^2.0.2" }, "peerDependencies": { "beautiful-mermaid": ">=0.1.0", "katex": ">=0.16.20", "mermaid": ">=11", "shiki": ">=3.15.0", "vue": ">=3.0.0" }, "optionalPeers": ["beautiful-mermaid", "katex", "mermaid", "shiki"] }, "sha512-RLuI5zt5czh6dkTA0/XkkMv+ApVDQXSEGUs5TgEPc0bEhhcalXItu/IxZZU0/Kf0xJ3zSMawF7PRsxoMLc88Yg=="],
"webpack-virtual-modules": ["[email protected]", "", {}, "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ=="],
@@ -1283,6 +1304,8 @@
"y-protocols": ["[email protected]", "", { "dependencies": { "lib0": "^0.2.85" }, "peerDependencies": { "yjs": "^13.0.0" } }, "sha512-YSVsLoXxO67J6eE/nV4AtFtT3QEotZf5sK5BHxFBXso7VDUT3Tx07IfA6hsu5Q5OmBdMkQVmFZ9QOA7fikWvnw=="],
+ "yaml": ["[email protected]", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A=="],
+
"yjs": ["[email protected]", "", { "dependencies": { "lib0": "^0.2.99" } }, "sha512-kHqDPdltoXH+X4w1lVmMtddE3Oeqq48nM40FD5ojTd8xYhQpzIDcfE2keMSU5bAgRPJBe225WTUdyUgj1DtbiQ=="],
"yoga-layout": ["[email protected]", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="],
@@ -1327,20 +1350,30 @@
"vitepress/@vitejs/plugin-vue": ["@vitejs/[email protected]", "", { "peerDependencies": { "vite": "^5.0.0 || ^6.0.0", "vue": "^3.2.25" } }, "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA=="],
+ "vitepress/@vue/devtools-api": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-kit": "^7.7.9" } }, "sha512-kIE8wvwlcZ6TJTbNeU2HQNtaxLx3a84aotTITUuL/4bzfPxzajGBOoqjMhwZJ8L9qFYDU/lAYMEEm11dnZOD6g=="],
+
"vitepress/@vueuse/core": ["@vueuse/[email protected]", "", { "dependencies": { "@types/web-bluetooth": "^0.0.21", "@vueuse/metadata": "12.8.2", "@vueuse/shared": "12.8.2", "vue": "^3.5.13" } }, "sha512-HbvCmZdzAu3VGi/pWYm5Ut+Kd9mn1ZHnn4L5G8kOQTPs/IwIAmJoBrmYk2ckLArgMXZj0AW3n5CAejLUO+PhdQ=="],
"vitepress/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="],
+ "vue-router/unplugin": ["[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "picomatch": "^4.0.3", "webpack-virtual-modules": "^0.6.2" } }, "sha512-0Mqk3AT2TZCXWKdcoaufeXNukv2mTrEZExeXlHIOZXdqYoHHr4n51pymnwV8x2BOVxwXbK2HLlI7usrqMpycdg=="],
+
"@vueuse/integrations/@vueuse/core/@vueuse/metadata": ["@vueuse/[email protected]", "", {}, "sha512-rAyLGEuoBJ/Il5AmFHiziCPdQzRt88VxR+Y/A/QhJ1EWtWqPBBAxTAFaSkviwEuOEZNtW8pvkPgoCZQ+HxqW1A=="],
"mlly/pkg-types/confbox": ["[email protected]", "", {}, "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w=="],
+ "vitepress/@vue/devtools-api/@vue/devtools-kit": ["@vue/[email protected]", "", { "dependencies": { "@vue/devtools-shared": "^7.7.9", "birpc": "^2.3.0", "hookable": "^5.5.3", "mitt": "^3.0.1", "perfect-debounce": "^1.0.0", "speakingurl": "^14.0.1", "superjson": "^2.2.2" } }, "sha512-PyQ6odHSgiDVd4hnTP+aDk2X4gl2HmLDfiyEnn3/oV+ckFDuswRs4IbBT7vacMuGdwY/XemxBoh302ctbsptuA=="],
+
"vitepress/@vueuse/core/@vueuse/metadata": ["@vueuse/[email protected]", "", {}, "sha512-rAyLGEuoBJ/Il5AmFHiziCPdQzRt88VxR+Y/A/QhJ1EWtWqPBBAxTAFaSkviwEuOEZNtW8pvkPgoCZQ+HxqW1A=="],
"vitepress/@vueuse/core/@vueuse/shared": ["@vueuse/[email protected]", "", { "dependencies": { "vue": "^3.5.13" } }, "sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w=="],
"vitepress/vite/esbuild": ["[email protected]", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="],
+ "vitepress/@vue/devtools-api/@vue/devtools-kit/@vue/devtools-shared": ["@vue/[email protected]", "", { "dependencies": { "rfdc": "^1.4.1" } }, "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA=="],
+
+ "vitepress/@vue/devtools-api/@vue/devtools-kit/perfect-debounce": ["[email protected]", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="],
+
"vitepress/vite/esbuild/@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
"vitepress/vite/esbuild/@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="],
diff --git a/components.d.ts b/components.d.ts
index 5c7426443..5345b737b 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -29,6 +29,7 @@ declare module 'vue' {
FillPicker: typeof import('./src/components/FillPicker.vue')['default']
FillSection: typeof import('./src/components/properties/FillSection.vue')['default']
FontPicker: typeof import('./src/components/FontPicker.vue')['default']
+ HsvColorArea: typeof import('./src/components/HsvColorArea.vue')['default']
IconLucideALargeSmall: typeof import('~icons/lucide/a-large-small')['default']
IconLucideAlignCenter: typeof import('~icons/lucide/align-center')['default']
IconLucideAlignHorizontalJustifyCenter: typeof import('~icons/lucide/align-horizontal-justify-center')['default']
@@ -74,6 +75,7 @@ declare module 'vue' {
IconLucideTriangleAlert: typeof import('~icons/lucide/triangle-alert')['default']
IconLucideUnderline: typeof import('~icons/lucide/underline')['default']
IconLucideUnlink: typeof import('~icons/lucide/unlink')['default']
+ IconLucideUsers: typeof import('~icons/lucide/users')['default']
IconLucideX: typeof import('~icons/lucide/x')['default']
LayersPanel: typeof import('./src/components/LayersPanel.vue')['default']
LayoutSection: typeof import('./src/components/properties/LayoutSection.vue')['default']
@@ -81,6 +83,8 @@ declare module 'vue' {
PagesPanel: typeof import('./src/components/PagesPanel.vue')['default']
PositionSection: typeof import('./src/components/properties/PositionSection.vue')['default']
PropertiesPanel: typeof import('./src/components/PropertiesPanel.vue')['default']
+ RouterLink: typeof import('vue-router')['RouterLink']
+ RouterView: typeof import('vue-router')['RouterView']
SafariBanner: typeof import('./src/components/SafariBanner.vue')['default']
ScrubInput: typeof import('./src/components/ScrubInput.vue')['default']
StrokeSection: typeof import('./src/components/properties/StrokeSection.vue')['default']
diff --git a/package.json b/package.json
index ed5966e28..390d26c9b 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
"tailwindcss": "^4.2.1",
"valibot": "^1.2.0",
"vue": "^3.5.29",
+ "vue-router": "^5.0.3",
"vue-stream-markdown": "^0.6.0",
"y-protocols": "^1.0.7",
"yjs": "^13.6.29",
diff --git a/public/_redirects b/public/_redirects
index 7f2da2490..bbb3e7a1f 100644
--- a/public/_redirects
+++ b/public/_redirects
@@ -1 +1 @@
-/share/* /index.html 200
+/* /index.html 200
diff --git a/src/App.vue b/src/App.vue
index bed401b90..7c2aa3f3e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,99 +1,3 @@
-<script setup lang="ts">
-import { useEventListener, useUrlSearchParams } from '@vueuse/core'
-import { SplitterGroup, SplitterPanel, SplitterResizeHandle } from 'reka-ui'
-
-import { useKeyboard } from './composables/use-keyboard'
-import { useMenu } from './composables/use-menu'
-import { useCollab } from './composables/use-collab'
-import { createDemoShapes } from './demo'
-import { provideEditorStore } from './stores/editor'
-
-import CollabPanel from './components/CollabPanel.vue'
-import EditorCanvas from './components/EditorCanvas.vue'
-import LayersPanel from './components/LayersPanel.vue'
-import PropertiesPanel from './components/PropertiesPanel.vue'
-import SafariBanner from './components/SafariBanner.vue'
-import Toolbar from './components/Toolbar.vue'
-
-const store = provideEditorStore()
-useKeyboard(store)
-useMenu(store)
-const collab = useCollab(store)
-;(window as Window & { __OPEN_PENCIL_STORE__?: typeof store }).__OPEN_PENCIL_STORE__ = store
-
-useEventListener(
- document,
- 'wheel',
- (e: WheelEvent) => {
- if (e.ctrlKey || e.metaKey) e.preventDefault()
- },
- { passive: false }
-)
-
-const params = useUrlSearchParams('history')
-const showChrome = !('no-chrome' in params)
-if (!('test' in params)) {
- createDemoShapes(store)
-}
-
-// Auto-join room from /share/:roomId URL
-const shareMatch = window.location.pathname.match(/^\/share\/([a-zA-Z0-9_-]+)/)
-if (shareMatch) {
- collab.connect(shareMatch[1])
-}
-</script>
-
<template>
- <div class="flex h-screen w-screen flex-col">
- <SafariBanner />
- <SplitterGroup
- v-if="showChrome"
- direction="horizontal"
- class="flex-1 overflow-hidden"
- auto-save-id="editor-layout"
- >
- <SplitterPanel :default-size="15" :min-size="10" :max-size="30" class="flex">
- <LayersPanel />
- </SplitterPanel>
- <SplitterResizeHandle class="group relative z-10 -mx-1 w-2 cursor-col-resize">
- <div class="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2" />
- </SplitterResizeHandle>
- <SplitterPanel :default-size="70" :min-size="30" class="flex">
- <div class="relative flex min-w-0 flex-1">
- <EditorCanvas />
- <Toolbar />
- <div class="absolute right-3 top-3 z-10">
- <CollabPanel
- :state="collab.state.value"
- :peers="collab.remotePeers.value"
- @share="() => {
- const roomId = collab.shareCurrentDoc()
- window.history.pushState({}, '', `/share/${roomId}`)
- }"
- @join="(roomId: string) => {
- collab.connect(roomId)
- window.history.pushState({}, '', `/share/${roomId}`)
- }"
- @disconnect="() => {
- collab.disconnect()
- window.history.pushState({}, '', '/')
- }"
- @update:name="collab.setLocalName"
- />
- </div>
- </div>
- </SplitterPanel>
- <SplitterResizeHandle class="group relative z-10 -mx-1 w-2 cursor-col-resize">
- <div class="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2" />
- </SplitterResizeHandle>
- <SplitterPanel :default-size="15" :min-size="10" :max-size="30" class="flex">
- <PropertiesPanel />
- </SplitterPanel>
- </SplitterGroup>
- <div v-else class="flex flex-1 overflow-hidden">
- <div class="relative flex min-w-0 flex-1">
- <EditorCanvas />
- </div>
- </div>
- </div>
+ <RouterView />
</template>
diff --git a/src/app.css b/src/app.css
index 1022e5871..cf8dcde9d 100644
--- a/src/app.css
+++ b/src/app.css
@@ -1,6 +1,14 @@
@import 'tailwindcss';
@import 'tw-animate-css';
+@utility scrollbar-none {
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+ &::-webkit-scrollbar {
+ display: none;
+ }
+}
+
@theme {
--color-panel: #2a2a2a;
--color-canvas: #1e1e1e;
diff --git a/src/components/AppMenu.vue b/src/components/AppMenu.vue
index 27613cc82..8ccd0f2a0 100644
--- a/src/components/AppMenu.vue
+++ b/src/components/AppMenu.vue
@@ -62,8 +62,16 @@ const editMenu: MenuItem[] = [
const viewMenu: MenuItem[] = [
{ label: 'Zoom to fit', shortcut: '⇧1', action: () => store.zoomToFit() },
- { label: 'Zoom in', shortcut: `${mod}=`, action: () => store.applyZoom(-100, window.innerWidth / 2, window.innerHeight / 2) },
- { label: 'Zoom out', shortcut: `${mod}-`, action: () => store.applyZoom(100, window.innerWidth / 2, window.innerHeight / 2) }
+ {
+ label: 'Zoom in',
+ shortcut: `${mod}=`,
+ action: () => store.applyZoom(-100, window.innerWidth / 2, window.innerHeight / 2)
+ },
+ {
+ label: 'Zoom out',
+ shortcut: `${mod}-`,
+ action: () => store.applyZoom(100, window.innerWidth / 2, window.innerHeight / 2)
+ }
]
const objectMenu: MenuItem[] = [
@@ -114,8 +122,11 @@ const topMenus = [
</script>
<template>
- <div v-if="!IS_TAURI" class="border-b border-border px-1 py-1">
- <MenubarRoot class="flex items-center gap-0.5">
+ <div
+ v-if="!IS_TAURI"
+ class="shrink-0 overflow-x-auto border-b border-border px-1 py-1 scrollbar-none"
+ >
+ <MenubarRoot class="flex w-max items-center gap-0.5">
<MenubarMenu v-for="menu in topMenus" :key="menu.label">
<MenubarTrigger
class="flex cursor-pointer items-center rounded px-2 py-1 text-xs text-muted transition-colors select-none hover:bg-hover hover:text-surface data-[state=open]:bg-hover data-[state=open]:text-surface"
@@ -130,10 +141,7 @@ const topMenus = [
class="min-w-52 rounded-lg border border-border bg-panel p-1 shadow-lg"
>
<template v-for="(item, i) in menu.items" :key="i">
- <MenubarSeparator
- v-if="item.separator"
- class="mx-1 my-1 h-px bg-border"
- />
+ <MenubarSeparator v-if="item.separator" class="mx-1 my-1 h-px bg-border" />
<MenubarSub v-else-if="item.sub">
<MenubarSubTrigger
class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs text-surface outline-none select-none hover:bg-hover"
@@ -147,18 +155,11 @@ const topMenus = [
class="min-w-44 rounded-lg border border-border bg-panel p-1 shadow-lg"
>
<template v-for="(sub, j) in item.sub" :key="j">
- <MenubarSeparator
- v-if="sub.separator"
- class="mx-1 my-1 h-px bg-border"
- />
+ <MenubarSeparator v-if="sub.separator" class="mx-1 my-1 h-px bg-border" />
<MenubarItem
v-else
class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"
- :class="
- sub.disabled
- ? 'text-muted/50'
- : 'text-surface hover:bg-hover'
- "
+ :class="sub.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"
:disabled="sub.disabled"
@select="sub.action?.()"
>
@@ -174,18 +175,12 @@ const topMenus = [
<MenubarItem
v-else
class="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none select-none"
- :class="
- item.disabled
- ? 'text-muted/50'
- : 'text-surface hover:bg-hover'
- "
+ :class="item.disabled ? 'text-muted/50' : 'text-surface hover:bg-hover'"
:disabled="item.disabled"
@select="item.action?.()"
>
<span class="flex-1">{{ item.label }}</span>
- <span v-if="item.shortcut" class="text-[11px] text-muted">{{
- item.shortcut
- }}</span>
+ <span v-if="item.shortcut" class="text-[11px] text-muted">{{ item.shortcut }}</span>
</MenubarItem>
</template>
</MenubarContent>
diff --git a/src/components/CollabPanel.vue b/src/components/CollabPanel.vue
index 8a61ae97e..eb32bae44 100644
--- a/src/components/CollabPanel.vue
+++ b/src/components/CollabPanel.vue
@@ -9,7 +9,7 @@ import {
TooltipTrigger,
TooltipPortal,
TooltipContent,
- TooltipProvider,
+ TooltipProvider
} from 'reka-ui'
import type { CollabState, RemotePeer } from '@/composables/use-collab'
@@ -18,6 +18,7 @@ import type { Color } from '@/types'
const props = defineProps<{
state: CollabState
peers: RemotePeer[]
+ pendingRoomId?: string | null
}>()
const emit = defineEmits<{
@@ -30,30 +31,37 @@ const emit = defineEmits<{
const joinInput = ref('')
const nameDraft = ref(props.state.localName)
const copied = ref(false)
+const popoverOpen = ref(!!props.pendingRoomId)
const shareUrl = computed(() => {
if (!props.state.roomId) return ''
return `${window.location.origin}/share/${props.state.roomId}`
})
+const isJoining = computed(() => !!props.pendingRoomId && !props.state.connected)
+
function copyLink() {
if (!shareUrl.value) return
navigator.clipboard.writeText(shareUrl.value)
copied.value = true
- setTimeout(() => { copied.value = false }, 2000)
+ setTimeout(() => {
+ copied.value = false
+ }, 2000)
}
function onShare() {
if (!nameDraft.value.trim()) return
emit('update:name', nameDraft.value.trim())
emit('share')
+ popoverOpen.value = false
}
function onJoin() {
- if (!joinInput.value.trim() || !nameDraft.value.trim()) return
+ const roomId = props.pendingRoomId || joinInput.value.trim().replace(/.*\/share\//, '')
+ if (!roomId || !nameDraft.value.trim()) return
emit('update:name', nameDraft.value.trim())
- const roomId = joinInput.value.trim().replace(/.*\/share\//, '')
emit('join', roomId)
+ popoverOpen.value = false
}
function colorToCSS(c: Color): string {
@@ -61,16 +69,22 @@ function colorToCSS(c: Color): string {
}
function initials(name: string): string {
- return name.split(' ').map(w => w[0]).join('').toUpperCase().slice(0, 2) || '?'
+ return (
+ name
+ .split(' ')
+ .map((w) => w[0])
+ .join('')
+ .toUpperCase()
+ .slice(0, 2) || '?'
+ )
}
</script>
<template>
- <div class="flex items-center gap-1">
+ <div class="flex w-full items-center gap-2">
<!-- Avatar stack for connected peers -->
<TooltipProvider v-if="state.connected" :delay-duration="200">
<div class="flex -space-x-1.5">
- <!-- Local user -->
<TooltipRoot>
<TooltipTrigger as-child>
<div
@@ -90,7 +104,6 @@ function initials(name: string): string {
</TooltipPortal>
</TooltipRoot>
- <!-- Remote peers -->
<TooltipRoot v-for="peer in peers" :key="peer.clientId">
<TooltipTrigger as-child>
<div
@@ -112,17 +125,23 @@ function initials(name: string): string {
</div>
</TooltipProvider>
+ <div class="flex-1" />
+
<!-- Share button / popover -->
- <PopoverRoot>
+ <PopoverRoot v-model:open="popoverOpen">
<PopoverTrigger as-child>
<button
class="flex h-7 cursor-pointer items-center gap-1.5 rounded-md border-none px-3 text-xs font-medium transition-colors"
- :class="state.connected
- ? 'bg-green-600 text-white hover:bg-green-700'
- : 'bg-accent text-white hover:bg-accent/90'"
+ :class="
+ state.connected
+ ? 'bg-green-600 text-white hover:bg-green-700'
+ : isJoining
+ ? 'bg-amber-600 text-white animate-pulse'
+ : 'bg-accent text-white hover:bg-accent/90'
+ "
>
<icon-lucide-share-2 class="size-3.5" />
- {{ state.connected ? 'Connected' : 'Share' }}
+ {{ state.connected ? 'Connected' : isJoining ? 'Join room' : 'Share' }}
</button>
</PopoverTrigger>
@@ -165,6 +184,34 @@ function initials(name: string): string {
</button>
</template>
+ <!-- Joining via /share/ link -->
+ <template v-else-if="isJoining">
+ <div class="mb-1 text-xs font-medium text-surface">Join collaboration</div>
+ <div class="mb-3 text-[11px] text-muted">
+ Someone shared this file with you. Enter your name to join.
+ </div>
+
+ <div class="mb-3">
+ <label class="mb-1 block text-xs text-muted">Your name</label>
+ <input
+ v-model="nameDraft"
+ class="w-full rounded border border-border bg-input px-2 py-1 text-xs text-surface"
+ placeholder="Enter your name"
+ autofocus
+ @keydown.enter="onJoin"
+ />
+ </div>
+
+ <button
+ class="flex h-8 w-full cursor-pointer items-center justify-center gap-1.5 rounded border-none bg-accent text-xs font-medium text-white hover:bg-accent/90 disabled:opacity-50"
+ :disabled="!nameDraft.trim()"
+ @click="onJoin"
+ >
+ <icon-lucide-users class="size-3.5" />
+ Join room
+ </button>
+ </template>
+
<!-- Not connected: share or join -->
<template v-else>
<div class="mb-3">
diff --git a/src/components/ColorPicker.vue b/src/components/ColorPicker.vue
index 41a9760a3..5210eadb2 100644
--- a/src/components/ColorPicker.vue
+++ b/src/components/ColorPicker.vue
@@ -1,8 +1,8 @@
<script setup lang="ts">
-import { ref, computed, watch } from 'vue'
+import { computed } from 'vue'
import { PopoverRoot, PopoverTrigger, PopoverPortal, PopoverContent } from 'reka-ui'
-import { colorToHexRaw, parseColor } from '@/engine/color'
+import HsvColorArea from './HsvColorArea.vue'
import type { Color } from '@/types'
@@ -14,120 +14,6 @@ const emit = defineEmits<{
update: [color: Color]
}>()
-const hue = ref(0)
-const saturation = ref(100)
-const brightness = ref(100)
-const alpha = ref(1)
-
-function rgbToHsv(r: number, g: number, b: number) {
- const max = Math.max(r, g, b)
- const min = Math.min(r, g, b)
- const d = max - min
- let h = 0
- const s = max === 0 ? 0 : d / max
- const v = max
-
- if (d !== 0) {
- if (max === r) h = ((g - b) / d + 6) % 6
- else if (max === g) h = (b - r) / d + 2
- else h = (r - g) / d + 4
- h *= 60
- }
- return { h, s: s * 100, v: v * 100 }
-}
-
-function hsvToRgb(h: number, s: number, v: number) {
- s /= 100
- v /= 100
- const c = v * s
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
- const m = v - c
- let r = 0
- let g = 0
- let b = 0
-
- if (h < 60) [r, g, b] = [c, x, 0]
- else if (h < 120) [r, g, b] = [x, c, 0]
- else if (h < 180) [r, g, b] = [0, c, x]
- else if (h < 240) [r, g, b] = [0, x, c]
- else if (h < 300) [r, g, b] = [x, 0, c]
- else [r, g, b] = [c, 0, x]
-
- return { r: r + m, g: g + m, b: b + m }
-}
-
-watch(
- () => props.color,
- (c) => {
- const hsv = rgbToHsv(c.r, c.g, c.b)
- hue.value = hsv.h
- saturation.value = hsv.s
- brightness.value = hsv.v
- alpha.value = c.a
- },
- { immediate: true }
-)
-
-function emitColor() {
- const rgb = hsvToRgb(hue.value, saturation.value, brightness.value)
- emit('update', { r: rgb.r, g: rgb.g, b: rgb.b, a: alpha.value })
-}
-
-const hexValue = computed(() => {
- return colorToHexRaw(props.color)
-})
-
-function onHexInput(e: Event) {
- const input = (e.target as HTMLInputElement).value.replace('#', '')
- if (input.length !== 6) return
- const parsed = parseColor(`#${input}`)
- emit('update', { ...parsed, a: alpha.value })
-}
-
-const svAreaRef = ref<HTMLDivElement | null>(null)
-
-function onSvPointerDown(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el) return
- el.setPointerCapture(e.pointerId)
- updateSv(e)
-}
-
-function onSvPointerMove(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el || !el.hasPointerCapture(e.pointerId)) return
- updateSv(e)
-}
-
-function updateSv(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el) return
- const rect = el.getBoundingClientRect()
- saturation.value = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100))
- brightness.value = Math.max(0, Math.min(100, 100 - ((e.clientY - rect.top) / rect.height) * 100))
- emitColor()
-}
-
-function onHueInput(e: Event) {
- hue.value = +(e.target as HTMLInputElement).value
- emitColor()
-}
-
-function onAlphaSliderInput(e: Event) {
- alpha.value = +(e.target as HTMLInputElement).value / 100
- emitColor()
-}
-
-function onAlphaNumberInput(e: Event) {
- alpha.value = Math.max(0, Math.min(1, +(e.target as HTMLInputElement).value / 100))
- emitColor()
-}
-
-const hueColor = computed(() => {
- const rgb = hsvToRgb(hue.value, 100, 100)
- return `rgb(${Math.round(rgb.r * 255)}, ${Math.round(rgb.g * 255)}, ${Math.round(rgb.b * 255)})`
-})
-
const swatchColor = computed(() => {
const c = props.color
return `rgba(${Math.round(c.r * 255)}, ${Math.round(c.g * 255)}, ${Math.round(c.b * 255)}, ${c.a})`
@@ -149,138 +35,8 @@ const swatchColor = computed(() => {
:side-offset="4"
side="left"
>
- <!-- SV area -->
- <div
- ref="svAreaRef"
- class="relative h-[140px] w-full cursor-crosshair overflow-hidden rounded"
- :style="{ background: hueColor }"
- @pointerdown="onSvPointerDown"
- @pointermove="onSvPointerMove"
- >
- <div class="absolute inset-0 bg-gradient-to-r from-white to-transparent" />
- <div class="absolute inset-0 bg-gradient-to-t from-black to-transparent" />
- <div
- class="pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm"
- :style="{ left: `${saturation}%`, top: `${100 - brightness}%` }"
- />
- </div>
-
- <!-- Hue slider -->
- <div class="mt-2">
- <input
- type="range"
- class="hue-slider"
- :value="hue"
- min="0"
- max="360"
- @input="onHueInput"
- />
- </div>
-
- <!-- Alpha slider -->
- <div class="alpha-wrap mt-2">
- <div
- class="alpha-gradient"
- :style="{ background: `linear-gradient(to right, transparent, ${hueColor})` }"
- />
- <input
- type="range"
- class="alpha-slider"
- :value="alpha * 100"
- min="0"
- max="100"
- @input="onAlphaSliderInput"
- />
- </div>
-
- <!-- Hex input -->
- <div class="mt-2 flex items-center gap-1">
- <span class="text-[11px] text-muted">#</span>
- <input
- type="text"
- class="min-w-0 flex-1 rounded border border-border bg-input px-1.5 py-0.5 font-mono text-xs text-surface"
- :value="hexValue"
- maxlength="6"
- @change="onHexInput"
- />
- <input
- type="number"
- class="w-10 rounded border border-border bg-input px-1 py-0.5 text-right text-xs text-surface"
- :value="Math.round(alpha * 100)"
- min="0"
- max="100"
- @change="onAlphaNumberInput"
- />
- <span class="text-[11px] text-muted">%</span>
- </div>
+ <HsvColorArea :color="color" @update="emit('update', $event)" />
</PopoverContent>
</PopoverPortal>
</PopoverRoot>
</template>
-
-<style scoped>
-.hue-slider,
-.alpha-slider {
- width: 100%;
- height: 12px;
- -webkit-appearance: none;
- appearance: none;
- border-radius: 6px;
- outline: none;
-}
-
-.hue-slider {
- background: linear-gradient(
- to right,
- #f00 0%,
- #ff0 17%,
- #0f0 33%,
- #0ff 50%,
- #00f 67%,
- #f0f 83%,
- #f00 100%
- );
-}
-
-.alpha-wrap {
- position: relative;
- height: 12px;
- border-radius: 6px;
- background-image:
- linear-gradient(45deg, #444 25%, transparent 25%),
- linear-gradient(-45deg, #444 25%, transparent 25%),
- linear-gradient(45deg, transparent 75%, #444 75%),
- linear-gradient(-45deg, transparent 75%, #444 75%);
- background-size: 8px 8px;
- background-position:
- 0 0,
- 0 4px,
- 4px -4px,
- -4px 0;
- background-color: #333;
-}
-
-.alpha-gradient {
- position: absolute;
- inset: 0;
- border-radius: 6px;
-}
-
-.alpha-slider {
- position: absolute;
- inset: 0;
- background: transparent;
-}
-
-.hue-slider::-webkit-slider-thumb,
-.alpha-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- width: 14px;
- height: 14px;
- border-radius: 50%;
- background: white;
- border: 2px solid white;
- box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
- cursor: pointer;
-}
-</style>
diff --git a/src/components/FillPicker.vue b/src/components/FillPicker.vue
index a66aba8ea..f2bf1a203 100644
--- a/src/components/FillPicker.vue
+++ b/src/components/FillPicker.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { ref, computed, watch } from 'vue'
+import { ref, computed } from 'vue'
import {
PopoverRoot,
PopoverTrigger,
@@ -16,11 +16,12 @@ import {
SelectViewport
} from 'reka-ui'
+import HsvColorArea from './HsvColorArea.vue'
import ScrubInput from './ScrubInput.vue'
import { colorToHexRaw, colorToRgba255, parseColor } from '@/engine/color'
import type { Color } from '@/types'
-import type { Fill, FillType, GradientStop, GradientTransform } from '@/engine/scene-graph'
+import type { Fill, GradientStop, GradientTransform } from '@/engine/scene-graph'
type FillCategory = 'SOLID' | 'GRADIENT' | 'IMAGE'
type GradientSubtype =
@@ -73,65 +74,7 @@ const activeColor = computed(() => {
return props.fill.color
})
-const hue = ref(0)
-const saturation = ref(100)
-const brightness = ref(100)
-const alpha = ref(1)
-
-function rgbToHsv(r: number, g: number, b: number) {
- const max = Math.max(r, g, b)
- const min = Math.min(r, g, b)
- const d = max - min
- let h = 0
- const s = max === 0 ? 0 : d / max
- const v = max
-
- if (d !== 0) {
- if (max === r) h = ((g - b) / d + 6) % 6
- else if (max === g) h = (b - r) / d + 2
- else h = (r - g) / d + 4
- h *= 60
- }
- return { h, s: s * 100, v: v * 100 }
-}
-
-function hsvToRgb(h: number, s: number, v: number) {
- s /= 100
- v /= 100
- const c = v * s
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
- const m = v - c
- let r = 0
- let g = 0
- let b = 0
-
- if (h < 60) [r, g, b] = [c, x, 0]
- else if (h < 120) [r, g, b] = [x, c, 0]
- else if (h < 180) [r, g, b] = [0, c, x]
- else if (h < 240) [r, g, b] = [0, x, c]
- else if (h < 300) [r, g, b] = [x, 0, c]
- else [r, g, b] = [c, 0, x]
-
- return { r: r + m, g: g + m, b: b + m }
-}
-
-function syncFromColor(c: Color) {
- const hsv = rgbToHsv(c.r, c.g, c.b)
- hue.value = hsv.h
- saturation.value = hsv.s
- brightness.value = hsv.v
- alpha.value = c.a
-}
-
-watch(activeColor, syncFromColor, { immediate: true })
-
-function currentRgb(): Color {
- const rgb = hsvToRgb(hue.value, saturation.value, brightness.value)
- return { r: rgb.r, g: rgb.g, b: rgb.b, a: alpha.value }
-}
-
-function emitColor() {
- const color = currentRgb()
+function onColorUpdate(color: Color) {
if (isGradient.value && props.fill.gradientStops?.length) {
const stops = [...props.fill.gradientStops]
const idx = Math.min(activeStopIndex.value, stops.length - 1)
@@ -181,9 +124,6 @@ function setGradientSubtype(type: string) {
function selectStop(index: number) {
activeStopIndex.value = index
- if (props.fill.gradientStops?.[index]) {
- syncFromColor(props.fill.gradientStops[index].color)
- }
}
function addStop() {
@@ -193,8 +133,7 @@ function addStop() {
stops.length >= 2
? (stops[stops.length - 2].position + stops[stops.length - 1].position) / 2
: 0.5
- const color = currentRgb()
- stops.push({ color, position: newPos })
+ stops.push({ color: { ...activeColor.value }, position: newPos })
stops.sort((a, b) => a.position - b.position)
const newIndex = stops.findIndex((s) => s.position === newPos)
activeStopIndex.value = newIndex
@@ -233,69 +172,6 @@ function updateStopOpacity(index: number, value: string) {
emit('update', { ...props.fill, gradientStops: stops })
}
-const hexValue = computed(() => colorToHexRaw(activeColor.value))
-
-function onHexInput(e: Event) {
- const input = (e.target as HTMLInputElement).value.replace('#', '')
- if (input.length !== 6) return
- const parsed = parseColor(`#${input}`)
- const rgb: Color = { ...parsed, a: alpha.value }
-
- if (isGradient.value && props.fill.gradientStops?.length) {
- const stops = [...props.fill.gradientStops]
- const idx = Math.min(activeStopIndex.value, stops.length - 1)
- stops[idx] = { ...stops[idx], color: rgb }
- emit('update', { ...props.fill, gradientStops: stops })
- } else {
- emit('update', { ...props.fill, color: rgb })
- }
- syncFromColor(rgb)
-}
-
-const svAreaRef = ref<HTMLDivElement | null>(null)
-
-function onSvPointerDown(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el) return
- el.setPointerCapture(e.pointerId)
- updateSv(e)
-}
-
-function onSvPointerMove(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el || !el.hasPointerCapture(e.pointerId)) return
- updateSv(e)
-}
-
-function updateSv(e: PointerEvent) {
- const el = svAreaRef.value
- if (!el) return
- const rect = el.getBoundingClientRect()
- saturation.value = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100))
- brightness.value = Math.max(0, Math.min(100, 100 - ((e.clientY - rect.top) / rect.height) * 100))
- emitColor()
-}
-
-function onHueInput(e: Event) {
- hue.value = +(e.target as HTMLInputElement).value
- emitColor()
-}
-
-function onAlphaSliderInput(e: Event) {
- alpha.value = +(e.target as HTMLInputElement).value / 100
- emitColor()
-}
-
-function onAlphaNumberInput(e: Event) {
- alpha.value = Math.max(0, Math.min(1, +(e.target as HTMLInputElement).value / 100))
- emitColor()
-}
-
-const hueColor = computed(() => {
- const rgb = hsvToRgb(hue.value, 100, 100)
- return `rgb(${Math.round(rgb.r * 255)}, ${Math.round(rgb.g * 255)}, ${Math.round(rgb.b * 255)})`
-})
-
const swatchBackground = computed(() => {
if (isGradient.value && props.fill.gradientStops?.length) {
const stops = props.fill.gradientStops
@@ -529,139 +405,12 @@ function stopSwatchColor(stop: GradientStop) {
</div>
<!-- HSV color area (solid mode, or editing active gradient stop) -->
- <template v-if="fill.type !== 'IMAGE'">
- <div
- ref="svAreaRef"
- class="relative h-[140px] w-full cursor-crosshair overflow-hidden rounded"
- :style="{ background: hueColor }"
- @pointerdown="onSvPointerDown"
- @pointermove="onSvPointerMove"
- >
- <div class="absolute inset-0 bg-gradient-to-r from-white to-transparent" />
- <div class="absolute inset-0 bg-gradient-to-t from-black to-transparent" />
- <div
- class="pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm"
- :style="{ left: `${saturation}%`, top: `${100 - brightness}%` }"
- />
- </div>
-
- <!-- Hue slider -->
- <div class="mt-2">
- <input
- type="range"
- class="hue-slider"
- :value="hue"
- min="0"
- max="360"
- @input="onHueInput"
- />
- </div>
-
- <!-- Alpha slider -->
- <div class="alpha-wrap mt-2">
- <div
- class="alpha-gradient"
- :style="{ background: `linear-gradient(to right, transparent, ${hueColor})` }"
- />
- <input
- type="range"
- class="alpha-slider"
- :value="alpha * 100"
- min="0"
- max="100"
- @input="onAlphaSliderInput"
- />
- </div>
-
- <!-- Hex input -->
- <div class="mt-2 flex items-center gap-1">
- <span class="text-[11px] text-muted">#</span>
- <input
- type="text"
- class="min-w-0 flex-1 rounded border border-border bg-input px-1.5 py-0.5 font-mono text-xs text-surface"
- :value="hexValue"
- maxlength="6"
- @change="onHexInput"
- />
- <input
- type="number"
- class="w-10 rounded border border-border bg-input px-1 py-0.5 text-right text-xs text-surface"
- :value="Math.round(alpha * 100)"
- min="0"
- max="100"
- @change="onAlphaNumberInput"
- />
- <span class="text-[11px] text-muted">%</span>
- </div>
- </template>
+ <HsvColorArea
+ v-if="fill.type !== 'IMAGE'"
+ :color="activeColor"
+ @update="onColorUpdate"
+ />
</PopoverContent>
</PopoverPortal>
</PopoverRoot>
</template>
-
-<style scoped>
-.hue-slider,
-.alpha-slider {
- width: 100%;
- height: 12px;
- -webkit-appearance: none;
- appearance: none;
- border-radius: 6px;
- outline: none;
-}
-
-.hue-slider {
- background: linear-gradient(
- to right,
- #f00 0%,
- #ff0 17%,
- #0f0 33%,
- #0ff 50%,
- #00f 67%,
- #f0f 83%,
- #f00 100%
- );
-}
-
-.alpha-wrap {
- position: relative;
- height: 12px;
- border-radius: 6px;
- background-image:
- linear-gradient(45deg, #444 25%, transparent 25%),
- linear-gradient(-45deg, #444 25%, transparent 25%),
- linear-gradient(45deg, transparent 75%, #444 75%),
- linear-gradient(-45deg, transparent 75%, #444 75%);
- background-size: 8px 8px;
- background-position:
- 0 0,
- 0 4px,
- 4px -4px,
- -4px 0;
- background-color: #333;
-}
-
-.alpha-gradient {
- position: absolute;
- inset: 0;
- border-radius: 6px;
-}
-
-.alpha-slider {
- position: absolute;
- inset: 0;
- background: transparent;
-}
-
-.hue-slider::-webkit-slider-thumb,
-.alpha-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- width: 14px;
- height: 14px;
- border-radius: 50%;
- background: white;
- border: 2px solid white;
- box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
- cursor: pointer;
-}
-</style>
diff --git a/src/components/HsvColorArea.vue b/src/components/HsvColorArea.vue
new file mode 100644
index 000000000..bfdd9262b
--- /dev/null
+++ b/src/components/HsvColorArea.vue
@@ -0,0 +1,262 @@
+<script setup lang="ts">
+import { ref, computed, watch } from 'vue'
+
+import { colorToHexRaw, parseColor } from '@/engine/color'
+
+import type { Color } from '@/types'
+
+const props = defineProps<{
+ color: Color
+}>()
+
+const emit = defineEmits<{
+ update: [color: Color]
+}>()
+
+const hue = ref(0)
+const saturation = ref(100)
+const brightness = ref(100)
+const alpha = ref(1)
+
+function rgbToHsv(r: number, g: number, b: number) {
+ const max = Math.max(r, g, b)
+ const min = Math.min(r, g, b)
+ const d = max - min
+ let h = 0
+ const s = max === 0 ? 0 : d / max
+ const v = max
+
+ if (d !== 0) {
+ if (max === r) h = ((g - b) / d + 6) % 6
+ else if (max === g) h = (b - r) / d + 2
+ else h = (r - g) / d + 4
+ h *= 60
+ }
+ return { h, s: s * 100, v: v * 100 }
+}
+
+function hsvToRgb(h: number, s: number, v: number) {
+ s /= 100
+ v /= 100
+ const c = v * s
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
+ const m = v - c
+ let r = 0
+ let g = 0
+ let b = 0
+
+ if (h < 60) [r, g, b] = [c, x, 0]
+ else if (h < 120) [r, g, b] = [x, c, 0]
+ else if (h < 180) [r, g, b] = [0, c, x]
+ else if (h < 240) [r, g, b] = [0, x, c]
+ else if (h < 300) [r, g, b] = [x, 0, c]
+ else [r, g, b] = [c, 0, x]
+
+ return { r: r + m, g: g + m, b: b + m }
+}
+
+watch(
+ () => props.color,
+ (c) => {
+ const hsv = rgbToHsv(c.r, c.g, c.b)
+ hue.value = hsv.h
+ saturation.value = hsv.s
+ brightness.value = hsv.v
+ alpha.value = c.a
+ },
+ { immediate: true }
+)
+
+function emitColor() {
+ const rgb = hsvToRgb(hue.value, saturation.value, brightness.value)
+ emit('update', { r: rgb.r, g: rgb.g, b: rgb.b, a: alpha.value })
+}
+
+const hexValue = computed(() => colorToHexRaw(props.color))
+
+function onHexInput(e: Event) {
+ const input = (e.target as HTMLInputElement).value.replace('#', '')
+ if (input.length !== 6) return
+ const parsed = parseColor(`#${input}`)
+ const color: Color = { ...parsed, a: alpha.value }
+ emit('update', color)
+}
+
+const svAreaRef = ref<HTMLDivElement | null>(null)
+
+function onSvPointerDown(e: PointerEvent) {
+ const el = svAreaRef.value
+ if (!el) return
+ el.setPointerCapture(e.pointerId)
+ updateSv(e)
+}
+
+function onSvPointerMove(e: PointerEvent) {
+ const el = svAreaRef.value
+ if (!el || !el.hasPointerCapture(e.pointerId)) return
+ updateSv(e)
+}
+
+function updateSv(e: PointerEvent) {
+ const el = svAreaRef.value
+ if (!el) return
+ const rect = el.getBoundingClientRect()
+ saturation.value = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100))
+ brightness.value = Math.max(0, Math.min(100, 100 - ((e.clientY - rect.top) / rect.height) * 100))
+ emitColor()
+}
+
+function onHueInput(e: Event) {
+ hue.value = +(e.target as HTMLInputElement).value
+ emitColor()
+}
+
+function onAlphaSliderInput(e: Event) {
+ alpha.value = +(e.target as HTMLInputElement).value / 100
+ emitColor()
+}
+
+function onAlphaNumberInput(e: Event) {
+ alpha.value = Math.max(0, Math.min(1, +(e.target as HTMLInputElement).value / 100))
+ emitColor()
+}
+
+const hueColor = computed(() => {
+ const rgb = hsvToRgb(hue.value, 100, 100)
+ return `rgb(${Math.round(rgb.r * 255)}, ${Math.round(rgb.g * 255)}, ${Math.round(rgb.b * 255)})`
+})
+</script>
+
+<template>
+ <!-- SV area -->
+ <div
+ ref="svAreaRef"
+ class="relative h-[140px] w-full cursor-crosshair overflow-hidden rounded"
+ :style="{ background: hueColor }"
+ @pointerdown="onSvPointerDown"
+ @pointermove="onSvPointerMove"
+ >
+ <div class="absolute inset-0 bg-gradient-to-r from-white to-transparent" />
+ <div class="absolute inset-0 bg-gradient-to-t from-black to-transparent" />
+ <div
+ class="pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm"
+ :style="{ left: `${saturation}%`, top: `${100 - brightness}%` }"
+ />
+ </div>
+
+ <!-- Hue slider -->
+ <div class="mt-2">
+ <input
+ type="range"
+ class="hue-slider"
+ :value="hue"
+ min="0"
+ max="360"
+ @input="onHueInput"
+ />
+ </div>
+
+ <!-- Alpha slider -->
+ <div class="alpha-wrap mt-2">
+ <div
+ class="alpha-gradient"
+ :style="{ background: `linear-gradient(to right, transparent, ${hueColor})` }"
+ />
+ <input
+ type="range"
+ class="alpha-slider"
+ :value="alpha * 100"
+ min="0"
+ max="100"
+ @input="onAlphaSliderInput"
+ />
+ </div>
+
+ <!-- Hex input -->
+ <div class="mt-2 flex items-center gap-1">
+ <span class="text-[11px] text-muted">#</span>
+ <input
+ type="text"
+ class="min-w-0 flex-1 rounded border border-border bg-input px-1.5 py-0.5 font-mono text-xs text-surface"
+ :value="hexValue"
+ maxlength="6"
+ @change="onHexInput"
+ />
+ <input
+ type="number"
+ class="w-10 rounded border border-border bg-input px-1 py-0.5 text-right text-xs text-surface"
+ :value="Math.round(alpha * 100)"
+ min="0"
+ max="100"
+ @change="onAlphaNumberInput"
+ />
+ <span class="text-[11px] text-muted">%</span>
+ </div>
+</template>
+
+<style scoped>
+.hue-slider,
+.alpha-slider {
+ width: 100%;
+ height: 12px;
+ -webkit-appearance: none;
+ appearance: none;
+ border-radius: 6px;
+ outline: none;
+}
+
+.hue-slider {
+ background: linear-gradient(
+ to right,
+ #f00 0%,
+ #ff0 17%,
+ #0f0 33%,
+ #0ff 50%,
+ #00f 67%,
+ #f0f 83%,
+ #f00 100%
+ );
+}
+
+.alpha-wrap {
+ position: relative;
+ height: 12px;
+ border-radius: 6px;
+ background-image:
+ linear-gradient(45deg, #444 25%, transparent 25%),
+ linear-gradient(-45deg, #444 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, #444 75%),
+ linear-gradient(-45deg, transparent 75%, #444 75%);
+ background-size: 8px 8px;
+ background-position:
+ 0 0,
+ 0 4px,
+ 4px -4px,
+ -4px 0;
+ background-color: #333;
+}
+
+.alpha-gradient {
+ position: absolute;
+ inset: 0;
+ border-radius: 6px;
+}
+
+.alpha-slider {
+ position: absolute;
+ inset: 0;
+ background: transparent;
+}
+
+.hue-slider::-webkit-slider-thumb,
+.alpha-slider::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background: white;
+ border: 2px solid white;
+ box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
+ cursor: pointer;
+}
+</style>
diff --git a/src/components/LayersPanel.vue b/src/components/LayersPanel.vue
index b7f937cc4..b11e3e426 100644
--- a/src/components/LayersPanel.vue
+++ b/src/components/LayersPanel.vue
@@ -223,7 +223,7 @@ function updateDropTarget(ev: PointerEvent) {
<template>
<aside
- class="flex min-w-0 flex-1 flex-col overflow-y-auto border-r border-border bg-panel"
+ class="flex min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto border-r border-border bg-panel"
style="contain: paint layout style"
>
<AppMenu />
diff --git a/src/components/SafariBanner.vue b/src/components/SafariBanner.vue
index e763fb20d..bc75d8d7e 100644
--- a/src/components/SafariBanner.vue
+++ b/src/components/SafariBanner.vue
@@ -13,8 +13,10 @@ const show = !IS_TAURI && typeof window !== 'undefined' && !window.showSaveFileP
class="flex items-center gap-2 border-b border-amber-500/30 bg-amber-500/10 px-3 py-1.5 text-xs text-amber-200"
>
<span class="flex-1">
- Your browser doesn't support the local file API. Files will be downloaded instead of saved in place.
- <a href="https://www.google.com/chrome/" target="_blank" class="underline">Use Chrome</a> or Edge for full support.
+ Your browser doesn't support the local file API. Files will be downloaded instead of saved in
+ place.
+ <a href="https://www.google.com/chrome/" target="_blank" class="underline">Use Chrome</a> or
+ Edge for full support.
</span>
<button
class="shrink-0 rounded px-1.5 py-0.5 text-amber-300 transition-colors hover:bg-amber-500/20"
diff --git a/src/composables/use-canvas.ts b/src/composables/use-canvas.ts
index a64481563..c3b19a7cf 100644
--- a/src/composables/use-canvas.ts
+++ b/src/composables/use-canvas.ts
@@ -83,9 +83,7 @@ export function useCanvas(canvasRef: Ref<HTMLCanvasElement | null>, store: Edito
cursorY: store.state.penCursorY ?? undefined
}
: null,
- remoteCursors: store.state.remoteCursors.length > 0
- ? store.state.remoteCursors
- : undefined
+ remoteCursors: store.state.remoteCursors.length > 0 ? store.state.remoteCursors : undefined
})
}
diff --git a/src/composables/use-collab.ts b/src/composables/use-collab.ts
index 3d7273ca8..f586b65f9 100644
--- a/src/composables/use-collab.ts
+++ b/src/composables/use-collab.ts
@@ -1,12 +1,12 @@
+import * as decoding from 'lib0/decoding'
+import * as encoding from 'lib0/encoding'
import { ref, onUnmounted, computed } from 'vue'
-import * as Y from 'yjs'
-import * as syncProtocol from 'y-protocols/sync'
import * as awarenessProtocol from 'y-protocols/awareness'
-import * as encoding from 'lib0/encoding'
-import * as decoding from 'lib0/decoding'
+import * as syncProtocol from 'y-protocols/sync'
+import * as Y from 'yjs'
-import type { EditorStore } from '@/stores/editor'
import type { SceneNode } from '@/engine/scene-graph'
+import type { EditorStore } from '@/stores/editor'
import type { Color } from '@/types'
const MSG_SYNC = 0
@@ -17,12 +17,12 @@ const COLLAB_URL = import.meta.env.VITE_COLLAB_URL || 'wss://collab.openpencil.d
const PEER_COLORS: Color[] = [
{ r: 0.96, g: 0.26, b: 0.21, a: 1 },
{ r: 0.13, g: 0.59, b: 0.95, a: 1 },
- { r: 0.30, g: 0.69, b: 0.31, a: 1 },
- { r: 1.00, g: 0.76, b: 0.03, a: 1 },
+ { r: 0.3, g: 0.69, b: 0.31, a: 1 },
+ { r: 1.0, g: 0.76, b: 0.03, a: 1 },
{ r: 0.61, g: 0.15, b: 0.69, a: 1 },
- { r: 1.00, g: 0.34, b: 0.13, a: 1 },
- { r: 0.00, g: 0.74, b: 0.83, a: 1 },
- { r: 0.91, g: 0.12, b: 0.39, a: 1 },
+ { r: 1.0, g: 0.34, b: 0.13, a: 1 },
+ { r: 0.0, g: 0.74, b: 0.83, a: 1 },
+ { r: 0.91, g: 0.12, b: 0.39, a: 1 }
]
export interface RemotePeer {
@@ -47,7 +47,7 @@ export function useCollab(store: EditorStore) {
roomId: null,
peers: [],
localName: localStorage.getItem('op-collab-name') || '',
- localColor: PEER_COLORS[Math.floor(Math.random() * PEER_COLORS.length)],
+ localColor: PEER_COLORS[Math.floor(Math.random() * PEER_COLORS.length)]
})
let ws: WebSocket | null = null
@@ -86,6 +86,15 @@ export function useCollab(store: EditorStore) {
store.requestRender()
})
+ // Register doc update listener before opening WebSocket
+ ydoc.on('update', (update: Uint8Array, origin: unknown) => {
+ if (origin === 'remote') return
+ const encoder = encoding.createEncoder()
+ encoding.writeVarUint(encoder, MSG_SYNC)
+ syncProtocol.writeUpdate(encoder, update)
+ sendBinary(encoding.toUint8Array(encoder))
+ })
+
// WebSocket connection
const url = `${COLLAB_URL}/room/${roomId}`
ws = new WebSocket(url)
@@ -174,16 +183,6 @@ export function useCollab(store: EditorStore) {
}
// Sync doc updates to server
- function setupDocSync() {
- if (!ydoc) return
- ydoc.on('update', (update: Uint8Array, origin: unknown) => {
- if (origin === 'remote') return
- const encoder = encoding.createEncoder()
- encoding.writeVarUint(encoder, MSG_SYNC)
- syncProtocol.writeUpdate(encoder, update)
- sendBinary(encoding.toUint8Array(encoder))
- })
- }
function syncNodeToYjs(nodeId: string) {
if (!ydoc || !ynodes) return
@@ -197,20 +196,21 @@ export function useCollab(store: EditorStore) {
ynode = new Y.Map()
ynodes!.set(nodeId, ynode)
}
- // Sync all scalar properties
- for (const [key, value] of Object.entries(node)) {
- if (key === 'childIds') {
- ynode.set(key, JSON.stringify(value))
- } else if (typeof value === 'object' && value !== null) {
- ynode.set(key, JSON.stringify(value))
- } else {
- ynode.set(key, value)
- }
- }
+ syncNodePropsToYMap(node, ynode)
})
suppressYjsEvents = false
}
+ function syncNodePropsToYMap(node: SceneNode, ynode: Y.Map<unknown>) {
+ for (const [key, value] of Object.entries(node)) {
+ if (typeof value === 'object' && value !== null) {
+ ynode.set(key, JSON.stringify(value))
+ } else {
+ ynode.set(key, value)
+ }
+ }
+ }
+
function syncAllNodesToYjs() {
if (!ydoc || !ynodes) return
suppressYjsEvents = true
@@ -221,15 +221,7 @@ export function useCollab(store: EditorStore) {
ynode = new Y.Map()
ynodes!.set(node.id, ynode)
}
- for (const [key, value] of Object.entries(node)) {
- if (key === 'childIds') {
- ynode.set(key, JSON.stringify(value))
- } else if (typeof value === 'object' && value !== null) {
- ynode.set(key, JSON.stringify(value))
- } else {
- ynode.set(key, value)
- }
- }
+ syncNodePropsToYMap(node, ynode)
}
})
suppressYjsEvents = false
@@ -271,8 +263,15 @@ export function useCollab(store: EditorStore) {
const props: Record<string, unknown> = {}
for (const [key, value] of ynode.entries()) {
- if (key === 'childIds' || key === 'fills' || key === 'strokes' || key === 'effects' ||
- key === 'vectorNetwork' || key === 'boundVariables' || key === 'styleRuns') {
+ if (
+ key === 'childIds' ||
+ key === 'fills' ||
+ key === 'strokes' ||
+ key === 'effects' ||
+ key === 'vectorNetwork' ||
+ key === 'boundVariables' ||
+ key === 'styleRuns'
+ ) {
try {
props[key] = typeof value === 'string' ? JSON.parse(value) : value
} catch {
@@ -304,7 +303,7 @@ export function useCollab(store: EditorStore) {
if (!awareness) return
awareness.setLocalStateField('user', {
name: state.value.localName,
- color: state.value.localColor,
+ color: state.value.localColor
})
}
@@ -334,7 +333,7 @@ export function useCollab(store: EditorStore) {
name: user.name || 'Anonymous',
color: user.color || PEER_COLORS[clientId % PEER_COLORS.length],
cursor: peerState.cursor as RemotePeer['cursor'],
- selection: peerState.selection as string[],
+ selection: peerState.selection as string[]
})
})
@@ -342,13 +341,13 @@ export function useCollab(store: EditorStore) {
// Update store's remoteCursors for renderer
store.state.remoteCursors = peers
- .filter(p => p.cursor && p.cursor.pageId === currentPageId)
- .map(p => ({
+ .filter((p) => p.cursor && p.cursor.pageId === currentPageId)
+ .map((p) => ({
name: p.name,
color: p.color,
x: p.cursor!.x,
y: p.cursor!.y,
- selection: p.selection,
+ selection: p.selection
}))
store.requestRender()
}
@@ -371,14 +370,12 @@ export function useCollab(store: EditorStore) {
function shareCurrentDoc(): string {
const roomId = generateRoomId()
connect(roomId)
- setupDocSync()
syncAllNodesToYjs()
return roomId
}
function joinRoom(roomId: string) {
connect(roomId)
- setupDocSync()
}
onUnmounted(() => {
@@ -393,6 +390,6 @@ export function useCollab(store: EditorStore) {
shareCurrentDoc,
updateCursor,
updateSelection,
- setLocalName,
+ setLocalName
}
}
diff --git a/src/main.ts b/src/main.ts
index 5b83bee06..0ce40fadb 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -4,6 +4,7 @@ import './app.css'
import { preloadFonts } from '@/engine/fonts'
import App from './App.vue'
+import router from './router'
preloadFonts()
-createApp(App).mount('#app')
+createApp(App).use(router).mount('#app')
diff --git a/src/router.ts b/src/router.ts
new file mode 100644
index 000000000..c722e8306
--- /dev/null
+++ b/src/router.ts
@@ -0,0 +1,13 @@
+import { createRouter, createWebHistory } from 'vue-router'
+
+import EditorView from './views/EditorView.vue'
+
+const router = createRouter({
+ history: createWebHistory(),
+ routes: [
+ { path: '/', component: EditorView },
+ { path: '/share/:roomId', component: EditorView }
+ ]
+})
+
+export default router
diff --git a/src/views/EditorView.vue b/src/views/EditorView.vue
new file mode 100644
index 000000000..36eafaf7e
--- /dev/null
+++ b/src/views/EditorView.vue
@@ -0,0 +1,108 @@
+<script setup lang="ts">
+import { useEventListener, useUrlSearchParams } from '@vueuse/core'
+import { useRoute, useRouter } from 'vue-router'
+import { SplitterGroup, SplitterPanel, SplitterResizeHandle } from 'reka-ui'
+
+import { useKeyboard } from '@/composables/use-keyboard'
+import { useMenu } from '@/composables/use-menu'
+import { useCollab } from '@/composables/use-collab'
+import { createDemoShapes } from '@/demo'
+import { provideEditorStore } from '@/stores/editor'
+
+import CollabPanel from '@/components/CollabPanel.vue'
+import EditorCanvas from '@/components/EditorCanvas.vue'
+import LayersPanel from '@/components/LayersPanel.vue'
+import PropertiesPanel from '@/components/PropertiesPanel.vue'
+import SafariBanner from '@/components/SafariBanner.vue'
+import Toolbar from '@/components/Toolbar.vue'
+
+const route = useRoute()
+const router = useRouter()
+
+const store = provideEditorStore()
+useKeyboard(store)
+useMenu(store)
+const collab = useCollab(store)
+;(window as Window & { __OPEN_PENCIL_STORE__?: typeof store }).__OPEN_PENCIL_STORE__ = store
+
+useEventListener(
+ document,
+ 'wheel',
+ (e: WheelEvent) => {
+ if (e.ctrlKey || e.metaKey) e.preventDefault()
+ },
+ { passive: false }
+)
+
+const params = useUrlSearchParams('history')
+const showChrome = !('no-chrome' in params)
+if (!('test' in params)) {
+ createDemoShapes(store)
+}
+
+const pendingRoomId = (route.params.roomId as string) || null
+
+function onShare() {
+ const roomId = collab.shareCurrentDoc()
+ router.push(`/share/${roomId}`)
+}
+
+function onJoin(roomId: string) {
+ collab.connect(roomId)
+ router.push(`/share/${roomId}`)
+}
+
+function onDisconnect() {
+ collab.disconnect()
+ router.push('/')
+}
+</script>
+
+<template>
+ <div class="flex h-screen w-screen flex-col">
+ <SafariBanner />
+ <SplitterGroup
+ v-if="showChrome"
+ direction="horizontal"
+ class="flex-1 overflow-hidden"
+ auto-save-id="editor-layout"
+ >
+ <SplitterPanel :default-size="18" :min-size="10" :max-size="30" class="flex">
+ <LayersPanel />
+ </SplitterPanel>
+ <SplitterResizeHandle class="group relative z-10 -mx-1 w-2 cursor-col-resize">
+ <div class="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2" />
+ </SplitterResizeHandle>
+ <SplitterPanel :default-size="64" :min-size="30" class="flex">
+ <div class="relative flex min-w-0 flex-1">
+ <EditorCanvas />
+ <Toolbar />
+ </div>
+ </SplitterPanel>
+ <SplitterResizeHandle class="group relative z-10 -mx-1 w-2 cursor-col-resize">
+ <div class="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2" />
+ </SplitterResizeHandle>
+ <SplitterPanel :default-size="18" :min-size="10" :max-size="30" class="flex flex-col">
+ <div
+ class="flex shrink-0 items-center justify-between border-b border-border px-1.5 py-1.5"
+ >
+ <CollabPanel
+ :state="collab.state.value"
+ :peers="collab.remotePeers.value"
+ :pending-room-id="pendingRoomId"
+ @share="onShare"
+ @join="onJoin"
+ @disconnect="onDisconnect"
+ @update:name="collab.setLocalName"
+ />
+ </div>
+ <PropertiesPanel />
+ </SplitterPanel>
+ </SplitterGroup>
+ <div v-else class="flex flex-1 overflow-hidden">
+ <div class="relative flex min-w-0 flex-1">
+ <EditorCanvas />
+ </div>
+ </div>
+ </div>
+</template>