@pairdraw/vue 0.19.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/dist/canvas/CanvasRoot.vue.js +2 -0
  2. package/dist/canvas/CanvasRoot.vue.js.map +1 -1
  3. package/dist/canvas/auto-layout/value-edit.js +1 -1
  4. package/dist/canvas/auto-layout/value-edit.js.map +1 -1
  5. package/dist/canvas/eyedropper/index.d.ts +26 -0
  6. package/dist/canvas/eyedropper/index.d.ts.map +1 -0
  7. package/dist/canvas/eyedropper/index.js +62 -0
  8. package/dist/canvas/eyedropper/index.js.map +1 -0
  9. package/dist/canvas/eyedropper/sample.js +13 -0
  10. package/dist/canvas/eyedropper/sample.js.map +1 -0
  11. package/dist/canvas/eyedropper/use.d.ts +33 -0
  12. package/dist/canvas/eyedropper/use.d.ts.map +1 -0
  13. package/dist/canvas/eyedropper/use.js +52 -0
  14. package/dist/canvas/eyedropper/use.js.map +1 -0
  15. package/dist/canvas/pointer/drag-move.js +4 -0
  16. package/dist/canvas/pointer/drag-move.js.map +1 -1
  17. package/dist/canvas/surface/kit-loader.js +2 -3
  18. package/dist/canvas/surface/kit-loader.js.map +1 -1
  19. package/dist/canvas/surface/lifecycle.js +30 -1
  20. package/dist/canvas/surface/lifecycle.js.map +1 -1
  21. package/dist/canvas/surface/types.d.ts +9 -0
  22. package/dist/canvas/surface/types.d.ts.map +1 -1
  23. package/dist/canvas/text-edit/textarea.d.ts +1 -0
  24. package/dist/canvas/text-edit/textarea.d.ts.map +1 -1
  25. package/dist/canvas/tools/registry.js +5 -1
  26. package/dist/canvas/tools/registry.js.map +1 -1
  27. package/dist/canvas/useCanvasInput.d.ts +152 -10
  28. package/dist/canvas/useCanvasInput.d.ts.map +1 -1
  29. package/dist/canvas/useCanvasInput.js +3 -2
  30. package/dist/canvas/useCanvasInput.js.map +1 -1
  31. package/dist/controls/document-colors/index.d.ts +2 -0
  32. package/dist/controls/document-colors/index.js +2 -0
  33. package/dist/controls/document-colors/use.d.ts +14 -0
  34. package/dist/controls/document-colors/use.d.ts.map +1 -0
  35. package/dist/controls/document-colors/use.js +27 -0
  36. package/dist/controls/document-colors/use.js.map +1 -0
  37. package/dist/controls/effects/helpers.d.ts +13 -2
  38. package/dist/controls/effects/helpers.d.ts.map +1 -1
  39. package/dist/controls/effects/helpers.js +89 -34
  40. package/dist/controls/effects/helpers.js.map +1 -1
  41. package/dist/controls/effects/index.d.ts +2 -1
  42. package/dist/controls/effects/index.js +2 -1
  43. package/dist/controls/effects/use.d.ts +9 -7
  44. package/dist/controls/effects/use.d.ts.map +1 -1
  45. package/dist/controls/effects/use.js +6 -3
  46. package/dist/controls/effects/use.js.map +1 -1
  47. package/dist/controls/node-props/use.d.ts +3 -3
  48. package/dist/controls/position/use.d.ts +1 -1
  49. package/dist/controls/typography/features.d.ts +24 -0
  50. package/dist/controls/typography/features.d.ts.map +1 -0
  51. package/dist/controls/typography/features.js +130 -0
  52. package/dist/controls/typography/features.js.map +1 -0
  53. package/dist/controls/typography/index.d.ts +2 -1
  54. package/dist/controls/typography/index.js +2 -1
  55. package/dist/controls/typography/use.d.ts +6 -0
  56. package/dist/controls/typography/use.d.ts.map +1 -1
  57. package/dist/controls/typography/use.js +4 -1
  58. package/dist/controls/typography/use.js.map +1 -1
  59. package/dist/editor/commands/registry.d.ts +4 -0
  60. package/dist/editor/commands/registry.d.ts.map +1 -1
  61. package/dist/editor/commands/registry.js +2 -0
  62. package/dist/editor/commands/registry.js.map +1 -1
  63. package/dist/editor/commands/selection.js +22 -0
  64. package/dist/editor/commands/selection.js.map +1 -1
  65. package/dist/editor/commands/types.d.ts +1 -1
  66. package/dist/editor/commands/types.d.ts.map +1 -1
  67. package/dist/editor/menu-model/canvas.d.ts.map +1 -1
  68. package/dist/editor/menu-model/canvas.js +7 -1
  69. package/dist/editor/menu-model/canvas.js.map +1 -1
  70. package/dist/editor/selection-capabilities/use.d.ts +2 -0
  71. package/dist/editor/selection-capabilities/use.js +5 -0
  72. package/dist/editor/selection-capabilities/use.js.map +1 -1
  73. package/dist/editor/selection-state/use.d.ts +1 -0
  74. package/dist/editor/selection-state/use.js +5 -0
  75. package/dist/editor/selection-state/use.js.map +1 -1
  76. package/dist/editor/tool-cursor/index.d.ts.map +1 -1
  77. package/dist/editor/tool-cursor/index.js +5 -1
  78. package/dist/editor/tool-cursor/index.js.map +1 -1
  79. package/dist/i18n/index.d.ts +5 -2
  80. package/dist/i18n/index.js +5 -2
  81. package/dist/i18n/locales/de/ai.json.js +53 -2
  82. package/dist/i18n/locales/de/commands.json.js +2 -0
  83. package/dist/i18n/locales/de/design-check.json.js +13 -1
  84. package/dist/i18n/locales/de/design-memory.json.js +82 -0
  85. package/dist/i18n/locales/de/design-memory.json.js.map +1 -0
  86. package/dist/i18n/locales/de/fonts.json.js +10 -0
  87. package/dist/i18n/locales/de/index.js +5 -1
  88. package/dist/i18n/locales/de/index.js.map +1 -1
  89. package/dist/i18n/locales/de/menu.json.js +2 -0
  90. package/dist/i18n/locales/de/panels.json.js +94 -1
  91. package/dist/i18n/locales/de/settings.json.js +1 -0
  92. package/dist/i18n/locales/de/tools.json.js +3 -1
  93. package/dist/i18n/locales/de/variables/panel.json.js +20 -0
  94. package/dist/i18n/locales/de/variations.json.js +23 -0
  95. package/dist/i18n/locales/de/variations.json.js.map +1 -0
  96. package/dist/i18n/locales/es/ai.json.js +52 -1
  97. package/dist/i18n/locales/es/commands.json.js +2 -0
  98. package/dist/i18n/locales/es/design-check.json.js +13 -1
  99. package/dist/i18n/locales/es/design-memory.json.js +82 -0
  100. package/dist/i18n/locales/es/design-memory.json.js.map +1 -0
  101. package/dist/i18n/locales/es/fonts.json.js +10 -0
  102. package/dist/i18n/locales/es/index.js +5 -1
  103. package/dist/i18n/locales/es/index.js.map +1 -1
  104. package/dist/i18n/locales/es/menu.json.js +2 -0
  105. package/dist/i18n/locales/es/panels.json.js +94 -1
  106. package/dist/i18n/locales/es/settings.json.js +1 -0
  107. package/dist/i18n/locales/es/tools.json.js +3 -1
  108. package/dist/i18n/locales/es/variables/panel.json.js +20 -0
  109. package/dist/i18n/locales/es/variations.json.js +23 -0
  110. package/dist/i18n/locales/es/variations.json.js.map +1 -0
  111. package/dist/i18n/locales/fr/ai.json.js +53 -2
  112. package/dist/i18n/locales/fr/commands.json.js +2 -0
  113. package/dist/i18n/locales/fr/design-check.json.js +13 -1
  114. package/dist/i18n/locales/fr/design-memory.json.js +82 -0
  115. package/dist/i18n/locales/fr/design-memory.json.js.map +1 -0
  116. package/dist/i18n/locales/fr/fonts.json.js +10 -0
  117. package/dist/i18n/locales/fr/index.js +5 -1
  118. package/dist/i18n/locales/fr/index.js.map +1 -1
  119. package/dist/i18n/locales/fr/menu.json.js +2 -0
  120. package/dist/i18n/locales/fr/panels.json.js +94 -1
  121. package/dist/i18n/locales/fr/settings.json.js +1 -0
  122. package/dist/i18n/locales/fr/tools.json.js +3 -1
  123. package/dist/i18n/locales/fr/variables/panel.json.js +20 -0
  124. package/dist/i18n/locales/fr/variations.json.js +23 -0
  125. package/dist/i18n/locales/fr/variations.json.js.map +1 -0
  126. package/dist/i18n/locales/it/ai.json.js +53 -2
  127. package/dist/i18n/locales/it/commands.json.js +2 -0
  128. package/dist/i18n/locales/it/design-check.json.js +13 -1
  129. package/dist/i18n/locales/it/design-memory.json.js +82 -0
  130. package/dist/i18n/locales/it/design-memory.json.js.map +1 -0
  131. package/dist/i18n/locales/it/fonts.json.js +10 -0
  132. package/dist/i18n/locales/it/index.js +5 -1
  133. package/dist/i18n/locales/it/index.js.map +1 -1
  134. package/dist/i18n/locales/it/menu.json.js +2 -0
  135. package/dist/i18n/locales/it/panels.json.js +94 -1
  136. package/dist/i18n/locales/it/settings.json.js +1 -0
  137. package/dist/i18n/locales/it/tools.json.js +3 -1
  138. package/dist/i18n/locales/it/variables/panel.json.js +20 -0
  139. package/dist/i18n/locales/it/variations.json.js +23 -0
  140. package/dist/i18n/locales/it/variations.json.js.map +1 -0
  141. package/dist/i18n/locales/ja/ai.json.js +53 -2
  142. package/dist/i18n/locales/ja/commands.json.js +2 -0
  143. package/dist/i18n/locales/ja/design-check.json.js +13 -1
  144. package/dist/i18n/locales/ja/design-memory.json.js +61 -0
  145. package/dist/i18n/locales/ja/design-memory.json.js.map +1 -0
  146. package/dist/i18n/locales/ja/fonts.json.js +10 -0
  147. package/dist/i18n/locales/ja/index.js +5 -1
  148. package/dist/i18n/locales/ja/index.js.map +1 -1
  149. package/dist/i18n/locales/ja/menu.json.js +2 -0
  150. package/dist/i18n/locales/ja/panels.json.js +91 -1
  151. package/dist/i18n/locales/ja/settings.json.js +1 -0
  152. package/dist/i18n/locales/ja/tools.json.js +3 -1
  153. package/dist/i18n/locales/ja/variables/panel.json.js +20 -0
  154. package/dist/i18n/locales/ja/variations.json.js +23 -0
  155. package/dist/i18n/locales/ja/variations.json.js.map +1 -0
  156. package/dist/i18n/locales/pl/ai.json.js +53 -2
  157. package/dist/i18n/locales/pl/commands.json.js +2 -0
  158. package/dist/i18n/locales/pl/design-check.json.js +13 -1
  159. package/dist/i18n/locales/pl/design-memory.json.js +89 -0
  160. package/dist/i18n/locales/pl/design-memory.json.js.map +1 -0
  161. package/dist/i18n/locales/pl/fonts.json.js +10 -0
  162. package/dist/i18n/locales/pl/index.js +5 -1
  163. package/dist/i18n/locales/pl/index.js.map +1 -1
  164. package/dist/i18n/locales/pl/menu.json.js +2 -0
  165. package/dist/i18n/locales/pl/panels.json.js +95 -1
  166. package/dist/i18n/locales/pl/settings.json.js +1 -0
  167. package/dist/i18n/locales/pl/tools.json.js +3 -1
  168. package/dist/i18n/locales/pl/variables/panel.json.js +20 -0
  169. package/dist/i18n/locales/pl/variations.json.js +23 -0
  170. package/dist/i18n/locales/pl/variations.json.js.map +1 -0
  171. package/dist/i18n/locales/ru/ai.json.js +53 -2
  172. package/dist/i18n/locales/ru/commands.json.js +3 -1
  173. package/dist/i18n/locales/ru/design-check.json.js +13 -1
  174. package/dist/i18n/locales/ru/design-memory.json.js +89 -0
  175. package/dist/i18n/locales/ru/design-memory.json.js.map +1 -0
  176. package/dist/i18n/locales/ru/fonts.json.js +10 -0
  177. package/dist/i18n/locales/ru/index.js +5 -1
  178. package/dist/i18n/locales/ru/index.js.map +1 -1
  179. package/dist/i18n/locales/ru/menu.json.js +2 -0
  180. package/dist/i18n/locales/ru/panels.json.js +95 -1
  181. package/dist/i18n/locales/ru/settings.json.js +1 -0
  182. package/dist/i18n/locales/ru/tools.json.js +3 -1
  183. package/dist/i18n/locales/ru/variables/panel.json.js +20 -0
  184. package/dist/i18n/locales/ru/variations.json.js +23 -0
  185. package/dist/i18n/locales/ru/variations.json.js.map +1 -0
  186. package/dist/i18n/locales/zh-cn/ai.json.js +53 -2
  187. package/dist/i18n/locales/zh-cn/commands.json.js +2 -0
  188. package/dist/i18n/locales/zh-cn/design-check.json.js +13 -1
  189. package/dist/i18n/locales/zh-cn/design-memory.json.js +61 -0
  190. package/dist/i18n/locales/zh-cn/design-memory.json.js.map +1 -0
  191. package/dist/i18n/locales/zh-cn/fonts.json.js +10 -0
  192. package/dist/i18n/locales/zh-cn/index.js +5 -1
  193. package/dist/i18n/locales/zh-cn/index.js.map +1 -1
  194. package/dist/i18n/locales/zh-cn/menu.json.js +2 -0
  195. package/dist/i18n/locales/zh-cn/panels.json.js +91 -1
  196. package/dist/i18n/locales/zh-cn/settings.json.js +1 -0
  197. package/dist/i18n/locales/zh-cn/tools.json.js +3 -1
  198. package/dist/i18n/locales/zh-cn/variables/panel.json.js +20 -0
  199. package/dist/i18n/locales/zh-cn/variations.json.js +23 -0
  200. package/dist/i18n/locales/zh-cn/variations.json.js.map +1 -0
  201. package/dist/i18n/messages/ai.d.ts +65 -2
  202. package/dist/i18n/messages/ai.d.ts.map +1 -1
  203. package/dist/i18n/messages/ai.js +53 -2
  204. package/dist/i18n/messages/ai.js.map +1 -1
  205. package/dist/i18n/messages/chat-usage.d.ts +34 -0
  206. package/dist/i18n/messages/chat-usage.d.ts.map +1 -0
  207. package/dist/i18n/messages/chat-usage.js +25 -0
  208. package/dist/i18n/messages/chat-usage.js.map +1 -0
  209. package/dist/i18n/messages/commands.d.ts +2 -0
  210. package/dist/i18n/messages/commands.d.ts.map +1 -1
  211. package/dist/i18n/messages/commands.js +2 -0
  212. package/dist/i18n/messages/commands.js.map +1 -1
  213. package/dist/i18n/messages/design-check.d.ts +12 -0
  214. package/dist/i18n/messages/design-check.d.ts.map +1 -1
  215. package/dist/i18n/messages/design-check.js +13 -1
  216. package/dist/i18n/messages/design-check.js.map +1 -1
  217. package/dist/i18n/messages/design-memory.d.ts +68 -0
  218. package/dist/i18n/messages/design-memory.d.ts.map +1 -0
  219. package/dist/i18n/messages/design-memory.js +85 -0
  220. package/dist/i18n/messages/design-memory.js.map +1 -0
  221. package/dist/i18n/messages/fonts.d.ts +12 -0
  222. package/dist/i18n/messages/fonts.d.ts.map +1 -1
  223. package/dist/i18n/messages/fonts.js +10 -0
  224. package/dist/i18n/messages/fonts.js.map +1 -1
  225. package/dist/i18n/messages/menu.d.ts +2 -0
  226. package/dist/i18n/messages/menu.d.ts.map +1 -1
  227. package/dist/i18n/messages/menu.js +2 -0
  228. package/dist/i18n/messages/menu.js.map +1 -1
  229. package/dist/i18n/messages/panels.d.ts +114 -0
  230. package/dist/i18n/messages/panels.d.ts.map +1 -1
  231. package/dist/i18n/messages/panels.js +94 -1
  232. package/dist/i18n/messages/panels.js.map +1 -1
  233. package/dist/i18n/messages/settings.d.ts +1 -0
  234. package/dist/i18n/messages/settings.d.ts.map +1 -1
  235. package/dist/i18n/messages/settings.js +1 -0
  236. package/dist/i18n/messages/settings.js.map +1 -1
  237. package/dist/i18n/messages/tools.d.ts +2 -0
  238. package/dist/i18n/messages/tools.d.ts.map +1 -1
  239. package/dist/i18n/messages/tools.js +3 -1
  240. package/dist/i18n/messages/tools.js.map +1 -1
  241. package/dist/i18n/messages/variables/panel.d.ts +24 -0
  242. package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
  243. package/dist/i18n/messages/variables/panel.js +20 -0
  244. package/dist/i18n/messages/variables/panel.js.map +1 -1
  245. package/dist/i18n/messages/variations.d.ts +28 -0
  246. package/dist/i18n/messages/variations.d.ts.map +1 -0
  247. package/dist/i18n/messages/variations.js +26 -0
  248. package/dist/i18n/messages/variations.js.map +1 -0
  249. package/dist/i18n/messages.d.ts +356 -3
  250. package/dist/i18n/messages.d.ts.map +1 -1
  251. package/dist/i18n/messages.js +8 -2
  252. package/dist/i18n/messages.js.map +1 -1
  253. package/dist/i18n/useI18n.d.ts +1193 -9
  254. package/dist/i18n/useI18n.d.ts.map +1 -1
  255. package/dist/i18n/useI18n.js +8 -1
  256. package/dist/i18n/useI18n.js.map +1 -1
  257. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +5 -2
  258. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
  259. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +12 -3
  260. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
  261. package/dist/primitives/ColorPicker/index.d.ts +2 -1
  262. package/dist/primitives/ColorPicker/index.js +2 -1
  263. package/dist/primitives/ColorPicker/outside.d.ts +16 -0
  264. package/dist/primitives/ColorPicker/outside.d.ts.map +1 -0
  265. package/dist/primitives/ColorPicker/outside.js +20 -0
  266. package/dist/primitives/ColorPicker/outside.js.map +1 -0
  267. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +5 -0
  268. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
  269. package/dist/primitives/FontPicker/FontPickerRoot.vue.js +63 -56
  270. package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
  271. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +1 -1
  272. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts +3 -0
  273. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts.map +1 -1
  274. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js +3 -1
  275. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js.map +1 -1
  276. package/dist/shared/assets/cursors/eyedropper.svg.js +6 -0
  277. package/dist/shared/assets/cursors/eyedropper.svg.js.map +1 -0
  278. package/dist/shared/frame.d.ts +28 -0
  279. package/dist/shared/frame.d.ts.map +1 -0
  280. package/dist/shared/frame.js +92 -0
  281. package/dist/shared/frame.js.map +1 -0
  282. package/dist/shared/input/auto-layout/drag.js +71 -0
  283. package/dist/shared/input/auto-layout/drag.js.map +1 -0
  284. package/dist/shared/input/{auto-layout-hover.d.ts → auto-layout/hover.d.ts} +3 -3
  285. package/dist/shared/input/auto-layout/hover.d.ts.map +1 -0
  286. package/dist/shared/input/{auto-layout-hover.js → auto-layout/hover.js} +42 -86
  287. package/dist/shared/input/auto-layout/hover.js.map +1 -0
  288. package/dist/shared/input/{auto-layout.js → auto-layout/index.js} +2 -2
  289. package/dist/shared/input/auto-layout/index.js.map +1 -0
  290. package/dist/shared/input/index.d.ts +1 -1
  291. package/dist/shared/input/index.js +1 -1
  292. package/dist/shared/input/move/drag.js +1 -1
  293. package/dist/shared/input/resize.js +1 -1
  294. package/dist/shared/input/select.js +5 -3
  295. package/dist/shared/input/select.js.map +1 -1
  296. package/dist/shared/input/types.d.ts +10 -2
  297. package/dist/shared/input/types.d.ts.map +1 -1
  298. package/dist/shared/input/types.js.map +1 -1
  299. package/package.json +19 -4
  300. package/dist/shared/input/auto-layout-hover.d.ts.map +0 -1
  301. package/dist/shared/input/auto-layout-hover.js.map +0 -1
  302. package/dist/shared/input/auto-layout.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":[],"sources":["../../../src/canvas/tools/registry.ts"],"sourcesContent":["import type { Ref } from 'vue'\n\nimport type { Editor, Tool } from '@pairdraw/core'\n\nimport { startPenInput, updatePenHover } from '#vue/canvas/pen/input'\nimport { startPencilInput } from '#vue/canvas/pencil/input'\nimport { onSelectionHandle, scaleHoverCursor, tryStartScaleDrag } from '#vue/canvas/scale/input'\nimport { startZoomDrag, zoomToolCursor } from '#vue/canvas/zoom/input'\nimport { HAND_GRAB_CURSOR } from '#vue/editor/tool-cursor'\nimport { attachModifiers, startConnectorDraw } from '#vue/shared/input/connector/draw'\nimport { startShapeDraw, startTextDraw } from '#vue/shared/input/draw'\nimport { startPanDrag } from '#vue/shared/input/pan/drag'\nimport { handleSelectDown } from '#vue/shared/input/select'\nimport type { HitTestFns } from '#vue/shared/input/select'\nimport { startStickyDraw } from '#vue/shared/input/sticky/draw'\nimport type { DragState } from '#vue/shared/input/types'\n\n/** Where the pointer is, in canvas (`cx`, `cy`) and screen (`sx`, `sy`) coordinates. */\nexport interface CanvasToolPointer {\n event: MouseEvent\n cx: number\n cy: number\n sx: number\n sy: number\n}\n\n/** What a canvas tool works with: the editor and the canvas input's own pieces. */\nexport interface CanvasToolContext {\n editor: Editor\n hitFns: HitTestFns\n cursorOverride: Ref<string | null>\n setDrag: (d: DragState) => void\n tryStartRotation: (cx: number, cy: number) => boolean\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean\n /** Shows what the pointer is over while selecting: the cursor, guides, and auto layout. */\n hoverLayers: (pointer: CanvasToolPointer) => void\n}\n\n/** What a tool does on the canvas: on a press, and while the pointer moves with no drag. */\nexport interface CanvasTool {\n press: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n hover?: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n}\n\nconst pan: CanvasTool = {\n press: ({ event }, { editor, setDrag, cursorOverride }) => {\n startPanDrag(event, setDrag, editor)\n cursorOverride.value = HAND_GRAB_CURSOR\n }\n}\n\n/** Draws the layer of the tool's own type, from the press to the release. */\nconst shape: CanvasTool = {\n press: ({ cx, cy }, { editor, setDrag }) => startShapeDraw(cx, cy, editor, setDrag)\n}\n\n/** Selects, moves, resizes, and turns layers: the Move tool. */\nconst select: CanvasTool = {\n press: ({ event, cx, cy, sx, sy }, context) =>\n handleSelectDown(\n event,\n cx,\n cy,\n sx,\n sy,\n context.editor,\n context.hitFns,\n context.tryStartRotation,\n context.handleTextEditClick,\n context.setDrag\n ),\n hover: (pointer, { hoverLayers }) => hoverLayers(pointer)\n}\n\n/**\n * Every tool's canvas behaviour, by id. A tool added to `Tool` needs an entry here, and the\n * editor's profile decides which tools are on offer.\n */\nexport const CANVAS_TOOLS: Readonly<Record<Tool, CanvasTool>> = {\n SELECT: select,\n // Handles scale the selection with its contents, and never resize it as Move's do; elsewhere a\n // press selects as Move does.\n SCALE: {\n press: (pointer, context) => {\n const drag = tryStartScaleDrag(pointer.cx, pointer.cy, context.editor)\n if (drag) {\n context.setDrag(drag)\n context.cursorOverride.value = drag.cursor\n } else if (!onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n select.press(pointer, context)\n }\n },\n hover: (pointer, context) => {\n context.hoverLayers(pointer)\n const cursor = scaleHoverCursor(pointer.cx, pointer.cy, context.editor)\n if (cursor) context.cursorOverride.value = cursor\n else if (onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n context.cursorOverride.value = null\n }\n }\n },\n ZOOM: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag, cursorOverride }) => {\n if (event.button !== 0) return\n setDrag(startZoomDrag(cx, cy, sx, sy, event.altKey, editor))\n cursorOverride.value = zoomToolCursor(event.altKey)\n },\n hover: ({ event }, { cursorOverride }) => {\n cursorOverride.value = zoomToolCursor(event.altKey)\n }\n },\n HAND: pan,\n // Comments are placed by the app's comments layer above the canvas.\n COMMENT: { press: () => undefined },\n PEN: {\n press: ({ event, cx, cy }, { editor, setDrag, cursorOverride }) =>\n startPenInput(event, cx, cy, editor, setDrag, cursorOverride),\n hover: ({ cx, cy }, { editor }) => {\n updatePenHover(cx, cy, editor)\n }\n },\n PENCIL: { press: ({ cx, cy }, { editor, setDrag }) => startPencilInput(cx, cy, editor, setDrag) },\n TEXT: { press: ({ cx, cy }, { editor, setDrag }) => startTextDraw(cx, cy, editor, setDrag) },\n CONNECTOR: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag }) =>\n startConnectorDraw(cx, cy, sx, sy, editor, setDrag, attachModifiers(event)),\n hover: ({ event, cx, cy }, { editor }) => editor.connectorHover(cx, cy, attachModifiers(event))\n },\n STICKY: { press: ({ cx, cy }, { editor, setDrag }) => startStickyDraw(cx, cy, editor, setDrag) },\n FRAME: shape,\n SECTION: shape,\n RECTANGLE: shape,\n ELLIPSE: shape,\n LINE: shape,\n POLYGON: shape,\n STAR: shape,\n SHAPE_WITH_TEXT: shape\n}\n"],"mappings":";;;;;;;;;;;AA4CA,MAAM,MAAkB,EACtB,QAAQ,EAAE,SAAS,EAAE,QAAQ,SAAS,qBAAqB;CACzD,aAAa,OAAO,SAAS,MAAM;CACnC,eAAe,QAAQ;AACzB,EACF;;AAGA,MAAM,QAAoB,EACxB,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,eAAe,IAAI,IAAI,QAAQ,OAAO,EACpF;;AAGA,MAAM,SAAqB;CACzB,QAAQ,EAAE,OAAO,IAAI,IAAI,IAAI,MAAM,YACjC,iBACE,OACA,IACA,IACA,IACA,IACA,QAAQ,QACR,QAAQ,QACR,QAAQ,kBACR,QAAQ,qBACR,QAAQ,OACV;CACF,QAAQ,SAAS,EAAE,kBAAkB,YAAY,OAAO;AAC1D;;;;;AAMA,MAAa,eAAmD;CAC9D,QAAQ;CAGR,OAAO;EACL,QAAQ,SAAS,YAAY;GAC3B,MAAM,OAAO,kBAAkB,QAAQ,IAAI,QAAQ,IAAI,QAAQ,MAAM;GACrE,IAAI,MAAM;IACR,QAAQ,QAAQ,IAAI;IACpB,QAAQ,eAAe,QAAQ,KAAK;GACtC,OAAO,IAAI,CAAC,kBAAkB,QAAQ,IAAI,QAAQ,IAAI,QAAQ,MAAM,GAClE,OAAO,MAAM,SAAS,OAAO;EAEjC;EACA,QAAQ,SAAS,YAAY;GAC3B,QAAQ,YAAY,OAAO;GAC3B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,EAAE,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,gBAAgB,IAAI,IAAI,QAAQ,OAAO,EAAE;CAC/F,OAAO;CACP,SAAS;CACT,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,iBAAiB;AACnB"}
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../../src/canvas/tools/registry.ts"],"sourcesContent":["import type { Ref } from 'vue'\n\nimport type { Editor, Tool } from '@pairdraw/core'\n\nimport { handleEyedropperDown } from '#vue/canvas/eyedropper'\nimport { startPenInput, updatePenHover } from '#vue/canvas/pen/input'\nimport { startPencilInput } from '#vue/canvas/pencil/input'\nimport { onSelectionHandle, scaleHoverCursor, tryStartScaleDrag } from '#vue/canvas/scale/input'\nimport { startZoomDrag, zoomToolCursor } from '#vue/canvas/zoom/input'\nimport { HAND_GRAB_CURSOR } from '#vue/editor/tool-cursor'\nimport { attachModifiers, startConnectorDraw } from '#vue/shared/input/connector/draw'\nimport { startShapeDraw, startTextDraw } from '#vue/shared/input/draw'\nimport { startPanDrag } from '#vue/shared/input/pan/drag'\nimport { handleSelectDown } from '#vue/shared/input/select'\nimport type { HitTestFns } from '#vue/shared/input/select'\nimport { startStickyDraw } from '#vue/shared/input/sticky/draw'\nimport type { DragState } from '#vue/shared/input/types'\n\n/** Where the pointer is, in canvas (`cx`, `cy`) and screen (`sx`, `sy`) coordinates. */\nexport interface CanvasToolPointer {\n event: MouseEvent\n cx: number\n cy: number\n sx: number\n sy: number\n}\n\n/** What a canvas tool works with: the editor and the canvas input's own pieces. */\nexport interface CanvasToolContext {\n editor: Editor\n hitFns: HitTestFns\n cursorOverride: Ref<string | null>\n setDrag: (d: DragState) => void\n tryStartRotation: (cx: number, cy: number) => boolean\n handleTextEditClick: (cx: number, cy: number, shiftKey: boolean) => boolean\n /** Settings → Editor's large nudge, in pixels. */\n bigNudge: () => number\n /** Shows what the pointer is over while selecting: the cursor, guides, and auto layout. */\n hoverLayers: (pointer: CanvasToolPointer) => void\n}\n\n/** What a tool does on the canvas: on a press, and while the pointer moves with no drag. */\nexport interface CanvasTool {\n press: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n hover?: (pointer: CanvasToolPointer, context: CanvasToolContext) => void\n}\n\nconst pan: CanvasTool = {\n press: ({ event }, { editor, setDrag, cursorOverride }) => {\n startPanDrag(event, setDrag, editor)\n cursorOverride.value = HAND_GRAB_CURSOR\n }\n}\n\n/** Draws the layer of the tool's own type, from the press to the release. */\nconst shape: CanvasTool = {\n press: ({ cx, cy }, { editor, setDrag }) => startShapeDraw(cx, cy, editor, setDrag)\n}\n\n/** Selects, moves, resizes, and turns layers: the Move tool. */\nconst select: CanvasTool = {\n press: ({ event, cx, cy, sx, sy }, context) =>\n handleSelectDown(\n event,\n cx,\n cy,\n sx,\n sy,\n context.editor,\n context.hitFns,\n context.tryStartRotation,\n context.handleTextEditClick,\n context.setDrag,\n context.bigNudge()\n ),\n hover: (pointer, { hoverLayers }) => hoverLayers(pointer)\n}\n\n/**\n * Every tool's canvas behaviour, by id. A tool added to `Tool` needs an entry here, and the\n * editor's profile decides which tools are on offer.\n */\nexport const CANVAS_TOOLS: Readonly<Record<Tool, CanvasTool>> = {\n SELECT: select,\n // Handles scale the selection with its contents, and never resize it as Move's do; elsewhere a\n // press selects as Move does.\n SCALE: {\n press: (pointer, context) => {\n const drag = tryStartScaleDrag(pointer.cx, pointer.cy, context.editor)\n if (drag) {\n context.setDrag(drag)\n context.cursorOverride.value = drag.cursor\n } else if (!onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n select.press(pointer, context)\n }\n },\n hover: (pointer, context) => {\n context.hoverLayers(pointer)\n const cursor = scaleHoverCursor(pointer.cx, pointer.cy, context.editor)\n if (cursor) context.cursorOverride.value = cursor\n else if (onSelectionHandle(pointer.cx, pointer.cy, context.editor)) {\n context.cursorOverride.value = null\n }\n }\n },\n ZOOM: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag, cursorOverride }) => {\n if (event.button !== 0) return\n setDrag(startZoomDrag(cx, cy, sx, sy, event.altKey, editor))\n cursorOverride.value = zoomToolCursor(event.altKey)\n },\n hover: ({ event }, { cursorOverride }) => {\n cursorOverride.value = zoomToolCursor(event.altKey)\n }\n },\n HAND: pan,\n // Comments are placed by the app's comments layer above the canvas.\n COMMENT: { press: () => undefined },\n EYEDROPPER: {\n press: ({ event, cx, cy }, { editor }) => {\n if (event.button === 0) handleEyedropperDown(editor, cx, cy, event.altKey)\n }\n },\n PEN: {\n press: ({ event, cx, cy }, { editor, setDrag, cursorOverride }) =>\n startPenInput(event, cx, cy, editor, setDrag, cursorOverride),\n hover: ({ cx, cy }, { editor }) => {\n updatePenHover(cx, cy, editor)\n }\n },\n PENCIL: { press: ({ cx, cy }, { editor, setDrag }) => startPencilInput(cx, cy, editor, setDrag) },\n TEXT: { press: ({ cx, cy }, { editor, setDrag }) => startTextDraw(cx, cy, editor, setDrag) },\n CONNECTOR: {\n press: ({ event, cx, cy, sx, sy }, { editor, setDrag }) =>\n startConnectorDraw(cx, cy, sx, sy, editor, setDrag, attachModifiers(event)),\n hover: ({ event, cx, cy }, { editor }) => editor.connectorHover(cx, cy, attachModifiers(event))\n },\n STICKY: { press: ({ cx, cy }, { editor, setDrag }) => startStickyDraw(cx, cy, editor, setDrag) },\n FRAME: shape,\n SECTION: shape,\n RECTANGLE: shape,\n ELLIPSE: shape,\n LINE: shape,\n POLYGON: shape,\n STAR: shape,\n SHAPE_WITH_TEXT: shape\n}\n"],"mappings":";;;;;;;;;;;;AA+CA,MAAM,MAAkB,EACtB,QAAQ,EAAE,SAAS,EAAE,QAAQ,SAAS,qBAAqB;CACzD,aAAa,OAAO,SAAS,MAAM;CACnC,eAAe,QAAQ;AACzB,EACF;;AAGA,MAAM,QAAoB,EACxB,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,eAAe,IAAI,IAAI,QAAQ,OAAO,EACpF;;AAGA,MAAM,SAAqB;CACzB,QAAQ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AM,WAAW,GAAG,qBAAqB,QAAQ,IAAI,IAAI,MAAM,MAAM;CAC3E,EACF;CACA,KAAK;EACH,QAAQ,EAAE,OAAO,IAAI,MAAM,EAAE,QAAQ,SAAS,qBAC5C,cAAc,OAAO,IAAI,IAAI,QAAQ,SAAS,cAAc;EAC9D,QAAQ,EAAE,IAAI,MAAM,EAAE,aAAa;GACjC,eAAe,IAAI,IAAI,MAAM;EAC/B;CACF;CACA,QAAQ,EAAE,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,iBAAiB,IAAI,IAAI,QAAQ,OAAO,EAAE;CAChG,MAAM,EAAE,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,cAAc,IAAI,IAAI,QAAQ,OAAO,EAAE;CAC3F,WAAW;EACT,QAAQ,EAAE,OAAO,IAAI,IAAI,IAAI,MAAM,EAAE,QAAQ,cAC3C,mBAAmB,IAAI,IAAI,IAAI,IAAI,QAAQ,SAAS,gBAAgB,KAAK,CAAC;EAC5E,QAAQ,EAAE,OAAO,IAAI,MAAM,EAAE,aAAa,OAAO,eAAe,IAAI,IAAI,gBAAgB,KAAK,CAAC;CAChG;CACA,QAAQ,EAAE,QAAQ,EAAE,IAAI,MAAM,EAAE,QAAQ,cAAc,gBAAgB,IAAI,IAAI,QAAQ,OAAO,EAAE;CAC/F,OAAO;CACP,SAAS;CACT,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,iBAAiB;AACnB"}
@@ -1,5 +1,5 @@
1
1
  import { CanvasLabelEdit } from "./labels/edit.js";
2
- import { AutoLayoutValueField } from "../shared/input/auto-layout-hover.js";
2
+ import { AutoLayoutValueField } from "../shared/input/auto-layout/hover.js";
3
3
  import { DragState } from "../shared/input/types.js";
4
4
  import { WheelZoomOptions } from "../shared/input/wheel.js";
5
5
  import { Ref } from "vue";
@@ -10,8 +10,15 @@ declare function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, editor
10
10
  /** How far wheel and pinch zoom move per event; 1 is the default rate. */
11
11
  zoomSpeed?: () => number,
12
12
  /** Whether a plain wheel zooms and whether a wheel zoom is inverted. */
13
- zoomOptions?: () => WheelZoomOptions): {
13
+ zoomOptions?: () => WheelZoomOptions,
14
+ /** Settings → Editor's large nudge, in pixels, for handle drags with Shift. */
15
+ bigNudge?: () => number): {
14
16
  drag: Ref<{
17
+ type: "auto-layout";
18
+ update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void;
19
+ commit: () => void;
20
+ cancel: () => void;
21
+ } | {
15
22
  type: "shape-handle";
16
23
  update: (screenX: number, screenY: number, shiftKey: boolean) => void;
17
24
  commit: () => void;
@@ -647,6 +654,10 @@ zoomOptions?: () => WheelZoomOptions): {
647
654
  } | null;
648
655
  origChildren: (Map<string, {
649
656
  type: import("@pairdraw/scene-graph").NodeType;
657
+ x: number;
658
+ y: number;
659
+ width: number;
660
+ height: number;
650
661
  strokes: {
651
662
  weight: number;
652
663
  align: "INSIDE" | "CENTER" | "OUTSIDE";
@@ -732,10 +743,6 @@ zoomOptions?: () => WheelZoomOptions): {
732
743
  } | undefined;
733
744
  customEffectId?: string | undefined;
734
745
  }[];
735
- x: number;
736
- y: number;
737
- width: number;
738
- height: number;
739
746
  vectorNetwork: {
740
747
  vertices: {
741
748
  x: number;
@@ -1270,6 +1277,23 @@ zoomOptions?: () => WheelZoomOptions): {
1270
1277
  derivedSymbolDataLayoutVersion: number | null;
1271
1278
  uniformScaleFactor: number | null;
1272
1279
  };
1280
+ drawio?: {
1281
+ styleNames: string[];
1282
+ styleValues: Partial<Record<string, string>>;
1283
+ labelX: number;
1284
+ points: {
1285
+ x: number;
1286
+ y: number;
1287
+ }[];
1288
+ sourcePoint: {
1289
+ x: number;
1290
+ y: number;
1291
+ } | null;
1292
+ targetPoint: {
1293
+ x: number;
1294
+ y: number;
1295
+ } | null;
1296
+ } | null | undefined;
1273
1297
  };
1274
1298
  derivedLayout: {
1275
1299
  x?: number | undefined;
@@ -1466,6 +1490,51 @@ zoomOptions?: () => WheelZoomOptions): {
1466
1490
  uniformBindings?: Record<string, string> | undefined;
1467
1491
  visible: boolean;
1468
1492
  blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
1493
+ } | {
1494
+ type: "NOISE";
1495
+ color: {
1496
+ r: number;
1497
+ g: number;
1498
+ b: number;
1499
+ a: number;
1500
+ };
1501
+ visible: boolean;
1502
+ blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
1503
+ noise: {
1504
+ noiseType: import("@pairdraw/scene-graph").NoiseType;
1505
+ noiseSize: {
1506
+ x: number;
1507
+ y: number;
1508
+ };
1509
+ density: number;
1510
+ secondaryColor?: {
1511
+ r: number;
1512
+ g: number;
1513
+ b: number;
1514
+ a: number;
1515
+ } | undefined;
1516
+ opacity?: number | undefined;
1517
+ seed?: number | undefined;
1518
+ };
1519
+ } | {
1520
+ type: "TEXTURE";
1521
+ color: {
1522
+ r: number;
1523
+ g: number;
1524
+ b: number;
1525
+ a: number;
1526
+ };
1527
+ radius: number;
1528
+ visible: boolean;
1529
+ blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
1530
+ texture: {
1531
+ noiseSize: {
1532
+ x: number;
1533
+ y: number;
1534
+ };
1535
+ clipToShape: boolean;
1536
+ seed?: number | undefined;
1537
+ };
1469
1538
  })[];
1470
1539
  layoutGrids: {
1471
1540
  visible?: boolean | undefined;
@@ -1511,6 +1580,8 @@ zoomOptions?: () => WheelZoomOptions): {
1511
1580
  visible: boolean;
1512
1581
  locked: boolean;
1513
1582
  clipsContent: boolean;
1583
+ overflowDirection: import("@pairdraw/scene-graph").OverflowDirection;
1584
+ scrollBehavior: import("@pairdraw/scene-graph").ScrollBehavior;
1514
1585
  blendMode: import("@pairdraw/scene-graph").BlendMode;
1515
1586
  text: string;
1516
1587
  fontSize: number;
@@ -2384,6 +2455,7 @@ zoomOptions?: () => WheelZoomOptions): {
2384
2455
  transition: {
2385
2456
  type: import("@pairdraw/scene-graph").PrototypeTransitionType;
2386
2457
  duration: number;
2458
+ easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
2387
2459
  };
2388
2460
  overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
2389
2461
  } | {
@@ -2765,6 +2837,11 @@ zoomOptions?: () => WheelZoomOptions): {
2765
2837
  originalOwnerId?: string | undefined;
2766
2838
  originalPosition?: number | undefined;
2767
2839
  } | null, DragState | {
2840
+ type: "auto-layout";
2841
+ update: (screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) => void;
2842
+ commit: () => void;
2843
+ cancel: () => void;
2844
+ } | {
2768
2845
  type: "shape-handle";
2769
2846
  update: (screenX: number, screenY: number, shiftKey: boolean) => void;
2770
2847
  commit: () => void;
@@ -3400,6 +3477,10 @@ zoomOptions?: () => WheelZoomOptions): {
3400
3477
  } | null;
3401
3478
  origChildren: (Map<string, {
3402
3479
  type: import("@pairdraw/scene-graph").NodeType;
3480
+ x: number;
3481
+ y: number;
3482
+ width: number;
3483
+ height: number;
3403
3484
  strokes: {
3404
3485
  weight: number;
3405
3486
  align: "INSIDE" | "CENTER" | "OUTSIDE";
@@ -3485,10 +3566,6 @@ zoomOptions?: () => WheelZoomOptions): {
3485
3566
  } | undefined;
3486
3567
  customEffectId?: string | undefined;
3487
3568
  }[];
3488
- x: number;
3489
- y: number;
3490
- width: number;
3491
- height: number;
3492
3569
  vectorNetwork: {
3493
3570
  vertices: {
3494
3571
  x: number;
@@ -4023,6 +4100,23 @@ zoomOptions?: () => WheelZoomOptions): {
4023
4100
  derivedSymbolDataLayoutVersion: number | null;
4024
4101
  uniformScaleFactor: number | null;
4025
4102
  };
4103
+ drawio?: {
4104
+ styleNames: string[];
4105
+ styleValues: Partial<Record<string, string>>;
4106
+ labelX: number;
4107
+ points: {
4108
+ x: number;
4109
+ y: number;
4110
+ }[];
4111
+ sourcePoint: {
4112
+ x: number;
4113
+ y: number;
4114
+ } | null;
4115
+ targetPoint: {
4116
+ x: number;
4117
+ y: number;
4118
+ } | null;
4119
+ } | null | undefined;
4026
4120
  };
4027
4121
  derivedLayout: {
4028
4122
  x?: number | undefined;
@@ -4219,6 +4313,51 @@ zoomOptions?: () => WheelZoomOptions): {
4219
4313
  uniformBindings?: Record<string, string> | undefined;
4220
4314
  visible: boolean;
4221
4315
  blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
4316
+ } | {
4317
+ type: "NOISE";
4318
+ color: {
4319
+ r: number;
4320
+ g: number;
4321
+ b: number;
4322
+ a: number;
4323
+ };
4324
+ visible: boolean;
4325
+ blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
4326
+ noise: {
4327
+ noiseType: import("@pairdraw/scene-graph").NoiseType;
4328
+ noiseSize: {
4329
+ x: number;
4330
+ y: number;
4331
+ };
4332
+ density: number;
4333
+ secondaryColor?: {
4334
+ r: number;
4335
+ g: number;
4336
+ b: number;
4337
+ a: number;
4338
+ } | undefined;
4339
+ opacity?: number | undefined;
4340
+ seed?: number | undefined;
4341
+ };
4342
+ } | {
4343
+ type: "TEXTURE";
4344
+ color: {
4345
+ r: number;
4346
+ g: number;
4347
+ b: number;
4348
+ a: number;
4349
+ };
4350
+ radius: number;
4351
+ visible: boolean;
4352
+ blendMode?: import("@pairdraw/scene-graph").BlendMode | undefined;
4353
+ texture: {
4354
+ noiseSize: {
4355
+ x: number;
4356
+ y: number;
4357
+ };
4358
+ clipToShape: boolean;
4359
+ seed?: number | undefined;
4360
+ };
4222
4361
  })[];
4223
4362
  layoutGrids: {
4224
4363
  visible?: boolean | undefined;
@@ -4264,6 +4403,8 @@ zoomOptions?: () => WheelZoomOptions): {
4264
4403
  visible: boolean;
4265
4404
  locked: boolean;
4266
4405
  clipsContent: boolean;
4406
+ overflowDirection: import("@pairdraw/scene-graph").OverflowDirection;
4407
+ scrollBehavior: import("@pairdraw/scene-graph").ScrollBehavior;
4267
4408
  blendMode: import("@pairdraw/scene-graph").BlendMode;
4268
4409
  text: string;
4269
4410
  fontSize: number;
@@ -5137,6 +5278,7 @@ zoomOptions?: () => WheelZoomOptions): {
5137
5278
  transition: {
5138
5279
  type: import("@pairdraw/scene-graph").PrototypeTransitionType;
5139
5280
  duration: number;
5281
+ easing?: import("@pairdraw/scene-graph").PrototypeEasingType | undefined;
5140
5282
  };
5141
5283
  overlayPosition: import("@pairdraw/scene-graph").PrototypeOverlayPositionType;
5142
5284
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"useCanvasInput.d.ts","names":[],"sources":["../../src/canvas/useCanvasInput.ts"],"mappings":";;;;;;;;iBAwDgB,eACd,WAAW,IAAI,2BACf,QAAQ,QACR,sBAAsB,YAAY,eAAe,kBACjD,wBAAwB,YAAY,eAAe,kBACnD,oBAAoB,YAAY,eAAe,kBAC/C,gBAAgB,YAAY,qBAC5B,yBACA,2BAEA;;AAAA,0BAEA;;AAAA,oBAAmB"}
1
+ {"version":3,"file":"useCanvasInput.d.ts","names":[],"sources":["../../src/canvas/useCanvasInput.ts"],"mappings":";;;;;;;;iBAwDgB,eACd,WAAW,IAAI,2BACf,QAAQ,QACR,sBAAsB,YAAY,eAAe,kBACjD,wBAAwB,YAAY,eAAe,kBACnD,oBAAoB,YAAY,eAAe,kBAC/C,gBAAgB,YAAY,qBAC5B,yBACA,2BAEA;;AAAA,0BAEA;;AAAA,oBAAmB,kBAEnB;;AAAA"}
@@ -1,4 +1,4 @@
1
- import { resolveAutoLayoutHover } from "../shared/input/auto-layout-hover.js";
1
+ import { resolveAutoLayoutHover } from "../shared/input/auto-layout/hover.js";
2
2
  import { createAutoLayoutValueEdit } from "./auto-layout/value-edit.js";
3
3
  import { createGuideInput } from "./guides/input.js";
4
4
  import { createCanvasLabelEdit } from "./labels/edit.js";
@@ -44,7 +44,7 @@ const ESCAPABLE_DRAGS = /* @__PURE__ */ new Set([
44
44
  "zoom",
45
45
  "scale"
46
46
  ]);
47
- function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle, onCursorMove, onActivate, isEnabled = () => true, zoomSpeed = () => 1, zoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS) {
47
+ function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponentLabel, hitTestFrameTitle, onCursorMove, onActivate, isEnabled = () => true, zoomSpeed = () => 1, zoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS, bigNudge = () => 10) {
48
48
  const drag = ref(null);
49
49
  const profile = () => resolveEditorProfile(editor.state);
50
50
  watch(() => drag.value?.type, (type) => editor.setTransforming(type === "move" || type === "resize" || type === "rotate"));
@@ -155,6 +155,7 @@ function useCanvasInput(canvasRef, editor, hitTestSectionTitle, hitTestComponent
155
155
  setDrag,
156
156
  tryStartRotation,
157
157
  handleTextEditClick,
158
+ bigNudge,
158
159
  hoverLayers
159
160
  };
160
161
  function onMouseDown(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"useCanvasInput.js","names":["createCanvasTransformInput"],"sources":["../../src/canvas/useCanvasInput.ts"],"sourcesContent":["import { useEventListener } from '@vueuse/core'\nimport { onScopeDispose, ref, watch, type Ref } from 'vue'\n\nimport { resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { createAutoLayoutValueEdit } from '#vue/canvas/auto-layout/value-edit'\nimport { createGuideInput } from '#vue/canvas/guides/input'\nimport { createCanvasLabelEdit } from '#vue/canvas/labels/edit'\nimport { finishPencilDrag } from '#vue/canvas/pencil/input'\nimport { moveDrag, type DragMoveContext } from '#vue/canvas/pointer/drag-move'\nimport { createCanvasPointer } from '#vue/canvas/pointer/use'\nimport { createTextEditInput } from '#vue/canvas/text-edit/input'\nimport { hoverCanvasTool, pressCanvasTool } from '#vue/canvas/tools/input'\nimport type { CanvasToolContext, CanvasToolPointer } from '#vue/canvas/tools/registry'\nimport { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { finishMarquee } from '#vue/canvas/transform/marquee'\nimport {\n cancelNodeEditDrag,\n handleNodeEditPointerUp,\n updateNodeEditHover\n} from '#vue/canvas/vector-input/input'\nimport { stopViewportTween } from '#vue/canvas/viewport/tween'\nimport { resolveAutoLayoutHover } from '#vue/shared/input/auto-layout-hover'\nimport { createClickCounter } from '#vue/shared/input/click-count'\nimport { refreshConnectorDrag } from '#vue/shared/input/connector/draw'\nimport { cancelMove, handleMoveUp } from '#vue/shared/input/move/drag'\nimport { setupPanZoom } from '#vue/shared/input/pan/zoom'\nimport { cancelResizePreview, commitResizePreview } from '#vue/shared/input/resize'\nimport { updateHoverCursor } from '#vue/shared/input/select'\nimport { resolveShapeHandleHover } from '#vue/shared/input/shape-handles'\nimport { useSpaceHeld } from '#vue/shared/input/space-key'\nimport type { DragState } from '#vue/shared/input/types'\nimport { DEFAULT_WHEEL_ZOOM_OPTIONS, type WheelZoomOptions } from '#vue/shared/input/wheel'\n\n/**\n * Wires pointer and mouse interaction to a Pairdraw canvas.\n *\n * This composable coordinates selection, dragging, resizing, rotation,\n * panning, drawing tools, scoped hit testing, and text-edit interaction.\n * It is primarily intended for editor shell components that own the canvas.\n */\n/** Drags Escape abandons, leaving the document as it was before the press. */\nconst ESCAPABLE_DRAGS: ReadonlySet<DragState['type']> = new Set<DragState['type']>([\n 'draw',\n 'gradient',\n 'image-crop',\n 'rotate',\n 'connector-draw',\n 'connector-end',\n 'connector-line',\n 'line-end',\n 'zoom',\n 'scale'\n])\n\nexport function useCanvasInput(\n canvasRef: Ref<HTMLCanvasElement | null>,\n editor: Editor,\n hitTestSectionTitle: (cx: number, cy: number) => SceneNode | null,\n hitTestComponentLabel: (cx: number, cy: number) => SceneNode | null,\n hitTestFrameTitle: (cx: number, cy: number) => SceneNode | null,\n onCursorMove?: (cx: number, cy: number) => void,\n onActivate?: () => void,\n isEnabled: () => boolean = () => true,\n /** How far wheel and pinch zoom move per event; 1 is the default rate. */\n zoomSpeed: () => number = () => 1,\n /** Whether a plain wheel zooms and whether a wheel zoom is inverted. */\n zoomOptions: () => WheelZoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS\n) {\n const drag = ref<DragState | null>(null)\n const profile = () => resolveEditorProfile(editor.state)\n // Canvas chrome that explains layout, such as auto layout child outlines, steps aside while\n // layers move, resize, or rotate.\n watch(\n () => drag.value?.type,\n (type) => editor.setTransforming(type === 'move' || type === 'resize' || type === 'rotate')\n )\n const canvasLabelEdit = createCanvasLabelEdit(editor)\n const cursorOverride = ref<string | null>(null)\n /** Whether the primary button is held on a preview control, such as a slider thumb. */\n const valueEdit = createAutoLayoutValueEdit(editor)\n const selectedIdsBeforeClickSequence = ref<ReadonlySet<string>>(new Set())\n const lastPointer = ref<{ cx: number; cy: number; sx: number; sy: number } | null>(null)\n const pointerInside = ref(false)\n let altHeld = false\n let metaHeld = false\n let controlHeld = false\n const spaceHeld = useSpaceHeld()\n const { recordClick, getClickCount } = createClickCounter()\n\n const { getCoords, canvasToLocal, hitTestInScope, hitFns } = createCanvasPointer(\n canvasRef,\n editor,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n )\n\n function canMeasure() {\n return (\n pointerInside.value &&\n !drag.value &&\n editor.state.activeTool === 'SELECT' &&\n editor.state.selectedIds.size > 0 &&\n !editor.state.editingTextId &&\n !editor.state.nodeEditState &&\n !editor.state.penState\n )\n }\n\n /** ⌘ or Ctrl held: hover reaches the deepest layer, the one a click would select, as in Figma. */\n function hoverDeep(e?: MouseEvent) {\n return e ? e.metaKey || e.ctrlKey : metaHeld || controlHeld\n }\n\n function refreshMeasurement() {\n const mode = altHeld && canMeasure() ? (metaHeld || controlHeld ? 'deep' : 'shallow') : 'off'\n editor.setMeasurementMode(mode)\n const pointer = lastPointer.value\n if (!pointer || drag.value || editor.state.activeTool !== 'SELECT' || !pointerInside.value)\n return\n cursorOverride.value = updateHoverCursor(\n pointer.cx,\n pointer.cy,\n editor,\n hitFns,\n mode === 'deep' || hoverDeep()\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(pointer.cx, pointer.cy, mode))\n editor.setShapeHandleHover(shapeHandleHoverAt(pointer.sx, pointer.sy, altHeld))\n }\n\n // Handles that edit, which a read-only document does not offer.\n function autoLayoutHoverAt(cx: number, cy: number, mode: typeof editor.state.measurementMode) {\n return mode === 'off' && profile().edits ? resolveAutoLayoutHover(cx, cy, editor) : null\n }\n\n function shapeHandleHoverAt(sx: number, sy: number, altKey: boolean) {\n return profile().edits ? resolveShapeHandleHover(editor, sx, sy, altKey) : null\n }\n\n function updateModifier(code: string, held: boolean) {\n if (!isEnabled()) return\n if (code === 'AltLeft' || code === 'AltRight') altHeld = held\n if (code === 'MetaLeft' || code === 'MetaRight') metaHeld = held\n if (code === 'ControlLeft' || code === 'ControlRight') controlHeld = held\n if (code.startsWith('Alt') || code.startsWith('Meta') || code.startsWith('Control')) {\n refreshMeasurement()\n }\n }\n\n function resetMeasurementModifiers() {\n altHeld = false\n metaHeld = false\n controlHeld = false\n editor.setMeasurementMode('off')\n }\n\n function setDrag(d: DragState) {\n editor.setMeasurementMode('off')\n drag.value = d\n }\n\n const guideInput = createGuideInput({\n canvasRef,\n editor,\n canvasToLocal,\n setDrag,\n setCursor: (cursor) => {\n cursorOverride.value = cursor\n }\n })\n\n const { handleTextEditClick, onDblClick: onTextDblClick } = createTextEditInput({\n editor,\n getCoords,\n hitTestInScope,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle,\n getClickCount,\n wasSelectedBeforeClickSequence: (id) => selectedIdsBeforeClickSequence.value.has(id),\n onEditCanvasLabel: canvasLabelEdit.start,\n setDrag\n })\n\n const {\n tryStartRotation,\n handlePanMove,\n handleRotateMove,\n handleTextSelectMove,\n handleMarqueeMove\n } = createCanvasTransformInput(editor, setDrag)\n const dragMoveContext: DragMoveContext = {\n editor,\n guideInput,\n transform: { handlePanMove, handleRotateMove, handleTextSelectMove, handleMarqueeMove },\n spaceHeld: () => spaceHeld.value\n }\n\n function onDblClick(e: MouseEvent) {\n if (profile().pointer === 'pan') return\n const { cx, cy } = getCoords(e)\n if (profile().edits && valueEdit.start(cx, cy)) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n onTextDblClick(e)\n }\n\n function hoverLayers({ event, cx, cy, sx, sy }: CanvasToolPointer) {\n const guideCursor = profile().edits ? guideInput.updateHover(sx, sy) : null\n cursorOverride.value =\n guideCursor ??\n updateHoverCursor(\n cx,\n cy,\n editor,\n hitFns,\n editor.state.measurementMode === 'deep' || hoverDeep(event)\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(cx, cy, editor.state.measurementMode))\n }\n\n const toolContext: CanvasToolContext = {\n editor,\n hitFns,\n cursorOverride,\n setDrag,\n tryStartRotation,\n handleTextEditClick,\n hoverLayers\n }\n\n function onMouseDown(e: MouseEvent) {\n onActivate?.()\n if (!isEnabled()) return\n // A canvas that only pans, as a preview's does, leaves its controls to the islands above it.\n const panOnly = profile().pointer === 'pan'\n if (panOnly && e.button === 0 && editor.state.activeTool !== 'HAND') {\n e.preventDefault()\n return\n }\n // Safari treats an unprevented press as the start of a text selection drag and freezes the\n // cursor until the pointer leaves the canvas; the canvas handles its own drags.\n if (e.button === 0) e.preventDefault()\n editor.setMeasurementMode('off')\n // A press takes the view over from a glide, where it is.\n stopViewportTween(editor)\n const openValueEdit = valueEdit.edit.value\n if (openValueEdit) valueEdit.commit(openValueEdit.value)\n if (!editor.state.editingTextId) canvasRef.value?.focus()\n editor.setHoveredNode(null)\n const { sx, sy, cx, cy } = getCoords(e)\n // Guides belong to the document, so a read-only one neither moves nor gains them.\n const guidesEditable = e.button === 0 && profile().edits\n if (guidesEditable && guideInput.tryStartExisting(sx, sy, e.altKey)) {\n e.preventDefault()\n return\n }\n if (guidesEditable && guideInput.tryStartFromRuler(sx, sy, cx, cy)) {\n e.preventDefault()\n return\n }\n editor.setSelectedGuide(null)\n\n const selectedIdsBeforeMouseDown = new Set(editor.state.selectedIds)\n const clickCount = recordClick(sx, sy)\n if (clickCount === 1) selectedIdsBeforeClickSequence.value = selectedIdsBeforeMouseDown\n pressCanvasTool({ event: e, cx, cy, sx, sy }, toolContext)\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!isEnabled()) return\n pointerInside.value = true\n const coords = getCoords(e)\n lastPointer.value = { cx: coords.cx, cy: coords.cy, sx: coords.sx, sy: coords.sy }\n if (onCursorMove) {\n onCursorMove(coords.cx, coords.cy)\n }\n\n if (profile().pointer === 'pan' && !drag.value) return\n\n if (!drag.value) {\n const { cx, cy, sx, sy } = coords\n updateNodeEditHover(editor, cx, cy)\n editor.setShapeHandleHover(shapeHandleHoverAt(sx, sy, e.altKey))\n hoverCanvasTool({ event: e, ...coords }, toolContext)\n }\n\n if (!drag.value) return\n moveDrag(drag.value, e, coords, dragMoveContext)\n }\n\n function onMouseUp() {\n if (!drag.value) return\n const d = drag.value\n\n if (handleNodeEditPointerUp(drag, editor)) return\n\n if (d.type === 'guide') {\n guideInput.finish(d)\n } else if (d.type === 'move') handleMoveUp(d, editor)\n else if (d.type === 'text-select') {\n drag.value = null\n return\n } else if (d.type === 'resize') commitResizePreview(d, editor)\n else if (d.type === 'pen-drag') {\n const penState = editor.state.penState\n if (penState?.pendingClose) {\n editor.penCommit(true)\n }\n drag.value = null\n return\n } else if (d.type === 'pencil-drag') finishPencilDrag(editor)\n else if (d.type === 'rotate') {\n const preview = editor.state.rotationPreview\n if (preview?.nodeId === d.nodeId && preview.angle !== d.origRotation) {\n editor.updateNode(d.nodeId, { rotation: preview.angle })\n editor.commitRotation(d.nodeId, d.origRotation)\n }\n if (editor.state.rotationPreview === preview) editor.setRotationPreview(null)\n } else if ('commit' in d) d.commit()\n else if (d.type === 'marquee') finishMarquee(editor, d)\n\n drag.value = null\n cursorOverride.value = null\n refreshMeasurement()\n }\n\n function clearTransientInteractionFeedback() {\n editor.setSnapGuides([])\n editor.setLayoutInsertIndicator(null)\n editor.setDropTarget(null)\n editor.setShapeHandleHover(null)\n guideInput.clearHoverAndPreview()\n }\n\n /** Drops what a drag showed without changing the document. */\n function discardDrawnPreview(d: DragState) {\n if (d.type === 'resize') cancelResizePreview(d, editor)\n else if ('cancel' in d) d.cancel()\n else if (d.type === 'pencil-drag') editor.pencilCancel()\n }\n\n /** Takes back what a drag in progress has previewed, by its kind. */\n function discardDrag(d: DragState) {\n discardDrawnPreview(d)\n if (d.type === 'move') cancelMove(d, editor)\n else if (d.type === 'rotate') {\n if (editor.state.rotationPreview?.nodeId === d.nodeId) editor.setRotationPreview(null)\n } else cancelNodeEditDrag(d, editor)\n }\n\n function cancelPointerInteraction() {\n const d = drag.value\n // Cleared first: ending a preview fires events whose listeners cancel again.\n drag.value = null\n if (d) discardDrag(d)\n cursorOverride.value = null\n clearTransientInteractionFeedback()\n }\n\n function onPointerDown(e: PointerEvent) {\n if (e.pointerType !== 'mouse' || e.button !== 0) return\n canvasRef.value?.setPointerCapture(e.pointerId)\n }\n\n function onPointerUp(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n onMouseUp()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n function onPointerCancel(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n cancelPointerInteraction()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n useEventListener(canvasRef, 'pointerdown', onPointerDown)\n useEventListener(canvasRef, 'pointerup', onPointerUp)\n useEventListener(canvasRef, 'pointercancel', onPointerCancel)\n useEventListener(canvasRef, 'dblclick', onDblClick)\n useEventListener(canvasRef, 'mousedown', onMouseDown)\n useEventListener(canvasRef, 'mousemove', onMouseMove)\n useEventListener(canvasRef, 'mouseup', onMouseUp)\n useEventListener(window, 'keydown', (event) => {\n if (guideInput.deleteSelected(event)) return\n updateModifier(event.code, true)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n useEventListener(window, 'keyup', (event) => {\n updateModifier(event.code, false)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n // Pressing or releasing ⌘ or Ctrl mid-drag switches a marquee between deep and plain at once.\n useEventListener(window, ['keydown', 'keyup'], (event: KeyboardEvent) => {\n const d = drag.value\n const pointer = lastPointer.value\n // Before the first move there is no marquee to redo.\n if (d?.type !== 'marquee' || !pointer || !editor.state.marquee || !isEnabled()) return\n if (!event.code.startsWith('Meta') && !event.code.startsWith('Control')) return\n handleMarqueeMove(d, pointer.cx, pointer.cy, event.metaKey || event.ctrlKey)\n })\n useEventListener(\n window,\n 'keydown',\n (event) => {\n if (event.code !== 'Escape' || event.isComposing || !isEnabled()) return\n const type = drag.value?.type\n // A vector edit marquee carries on through Escape, as in Figma, and keeps the path open.\n const swallowed = type === 'edit-marquee'\n if (!type || (!ESCAPABLE_DRAGS.has(type) && !swallowed)) return\n event.preventDefault()\n event.stopImmediatePropagation()\n if (!swallowed) cancelPointerInteraction()\n },\n { capture: true }\n )\n // Space during a move keeps layers in their parents, as in Figma, instead of switching to the hand.\n function holdParentsDuringMove(event: KeyboardEvent, held: boolean) {\n if (event.code !== 'Space' || drag.value?.type !== 'move' || !isEnabled()) return\n event.preventDefault()\n event.stopImmediatePropagation()\n drag.value.keepParents = held\n if (held) editor.setDropTarget(null)\n }\n useEventListener(window, 'keydown', (event) => holdParentsDuringMove(event, true), {\n capture: true\n })\n useEventListener(window, 'keyup', (event) => holdParentsDuringMove(event, false), {\n capture: true\n })\n useEventListener(window, 'blur', () => {\n resetMeasurementModifiers()\n cancelPointerInteraction()\n })\n useEventListener(canvasRef, 'mouseleave', () => {\n pointerInside.value = false\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n if (!drag.value) {\n editor.setHoveredNode(null)\n editor.setHoveredGuide(null)\n editor.setShapeHandleHover(null)\n }\n })\n useEventListener(\n window,\n 'mouseup',\n () => {\n if (drag.value) onMouseUp()\n },\n { capture: true }\n )\n\n const stopRotationListener = editor.onEditorEvent('rotation:preview-changed', (preview) => {\n if (drag.value?.type === 'rotate' && preview?.nodeId !== drag.value.nodeId)\n cancelPointerInteraction()\n })\n const stopToolListener = editor.onEditorEvent('tool:changed', () => {\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n cancelPointerInteraction()\n })\n // A document that turns read-only mid-gesture drops the gesture and any open inline edit.\n const stopReadOnlyListener = editor.onEditorEvent('document:read-only-changed', (readOnly) => {\n if (!readOnly) return\n valueEdit.cancel()\n canvasLabelEdit.cancel()\n cancelPointerInteraction()\n })\n const stopPlayListeners = (['selection:changed', 'page:changed', 'graph:replaced'] as const).map(\n (event) =>\n editor.onEditorEvent(event, () => {\n const type = drag.value?.type\n if (\n type === 'draw' ||\n type === 'sticky-draw' ||\n type === 'rotate' ||\n type === 'shape-handle' ||\n type === 'image-crop' ||\n type === 'sticky-scale' ||\n type === 'scale'\n )\n cancelPointerInteraction()\n })\n )\n onScopeDispose(() => {\n stopRotationListener()\n stopToolListener()\n stopReadOnlyListener()\n for (const stop of stopPlayListeners) stop()\n cancelPointerInteraction()\n // A canvas unmounted mid-rename keeps the name typed, as the field's blur does in Chromium.\n canvasLabelEdit.commit()\n })\n\n setupPanZoom(canvasRef, editor, drag, onMouseDown, onMouseMove, onMouseUp, zoomSpeed, zoomOptions)\n return {\n drag,\n cursorOverride,\n canvasLabelEdit: canvasLabelEdit.edit,\n updateCanvasLabelEdit: canvasLabelEdit.update,\n commitCanvasLabelEdit: canvasLabelEdit.commit,\n cancelCanvasLabelEdit: canvasLabelEdit.cancel,\n autoLayoutValueEdit: valueEdit.edit,\n updateAutoLayoutValueEdit: valueEdit.update,\n commitAutoLayoutValueEdit: valueEdit.commit,\n cancelAutoLayoutValueEdit: valueEdit.cancel,\n cleanupInteractions() {\n valueEdit.cancel()\n cancelPointerInteraction()\n pointerInside.value = false\n resetMeasurementModifiers()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,kCAAkD,IAAI,IAAuB;CACjF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AA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useCanvasInput.js","names":["createCanvasTransformInput"],"sources":["../../src/canvas/useCanvasInput.ts"],"sourcesContent":["import { useEventListener } from '@vueuse/core'\nimport { onScopeDispose, ref, watch, type Ref } from 'vue'\n\nimport { resolveEditorProfile, type Editor } from '@pairdraw/core'\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { createAutoLayoutValueEdit } from '#vue/canvas/auto-layout/value-edit'\nimport { createGuideInput } from '#vue/canvas/guides/input'\nimport { createCanvasLabelEdit } from '#vue/canvas/labels/edit'\nimport { finishPencilDrag } from '#vue/canvas/pencil/input'\nimport { moveDrag, type DragMoveContext } from '#vue/canvas/pointer/drag-move'\nimport { createCanvasPointer } from '#vue/canvas/pointer/use'\nimport { createTextEditInput } from '#vue/canvas/text-edit/input'\nimport { hoverCanvasTool, pressCanvasTool } from '#vue/canvas/tools/input'\nimport type { CanvasToolContext, CanvasToolPointer } from '#vue/canvas/tools/registry'\nimport { createCanvasTransformInput } from '#vue/canvas/transform/input'\nimport { finishMarquee } from '#vue/canvas/transform/marquee'\nimport {\n cancelNodeEditDrag,\n handleNodeEditPointerUp,\n updateNodeEditHover\n} from '#vue/canvas/vector-input/input'\nimport { stopViewportTween } from '#vue/canvas/viewport/tween'\nimport { resolveAutoLayoutHover } from '#vue/shared/input/auto-layout/hover'\nimport { createClickCounter } from '#vue/shared/input/click-count'\nimport { refreshConnectorDrag } from '#vue/shared/input/connector/draw'\nimport { cancelMove, handleMoveUp } from '#vue/shared/input/move/drag'\nimport { setupPanZoom } from '#vue/shared/input/pan/zoom'\nimport { cancelResizePreview, commitResizePreview } from '#vue/shared/input/resize'\nimport { updateHoverCursor } from '#vue/shared/input/select'\nimport { resolveShapeHandleHover } from '#vue/shared/input/shape-handles'\nimport { useSpaceHeld } from '#vue/shared/input/space-key'\nimport type { DragState } from '#vue/shared/input/types'\nimport { DEFAULT_WHEEL_ZOOM_OPTIONS, type WheelZoomOptions } from '#vue/shared/input/wheel'\n\n/**\n * Wires pointer and mouse interaction to a Pairdraw canvas.\n *\n * This composable coordinates selection, dragging, resizing, rotation,\n * panning, drawing tools, scoped hit testing, and text-edit interaction.\n * It is primarily intended for editor shell components that own the canvas.\n */\n/** Drags Escape abandons, leaving the document as it was before the press. */\nconst ESCAPABLE_DRAGS: ReadonlySet<DragState['type']> = new Set<DragState['type']>([\n 'draw',\n 'gradient',\n 'image-crop',\n 'rotate',\n 'connector-draw',\n 'connector-end',\n 'connector-line',\n 'line-end',\n 'zoom',\n 'scale'\n])\n\nexport function useCanvasInput(\n canvasRef: Ref<HTMLCanvasElement | null>,\n editor: Editor,\n hitTestSectionTitle: (cx: number, cy: number) => SceneNode | null,\n hitTestComponentLabel: (cx: number, cy: number) => SceneNode | null,\n hitTestFrameTitle: (cx: number, cy: number) => SceneNode | null,\n onCursorMove?: (cx: number, cy: number) => void,\n onActivate?: () => void,\n isEnabled: () => boolean = () => true,\n /** How far wheel and pinch zoom move per event; 1 is the default rate. */\n zoomSpeed: () => number = () => 1,\n /** Whether a plain wheel zooms and whether a wheel zoom is inverted. */\n zoomOptions: () => WheelZoomOptions = () => DEFAULT_WHEEL_ZOOM_OPTIONS,\n /** Settings → Editor's large nudge, in pixels, for handle drags with Shift. */\n bigNudge: () => number = () => 10\n) {\n const drag = ref<DragState | null>(null)\n const profile = () => resolveEditorProfile(editor.state)\n // Canvas chrome that explains layout, such as auto layout child outlines, steps aside while\n // layers move, resize, or rotate.\n watch(\n () => drag.value?.type,\n (type) => editor.setTransforming(type === 'move' || type === 'resize' || type === 'rotate')\n )\n const canvasLabelEdit = createCanvasLabelEdit(editor)\n const cursorOverride = ref<string | null>(null)\n /** Whether the primary button is held on a preview control, such as a slider thumb. */\n const valueEdit = createAutoLayoutValueEdit(editor)\n const selectedIdsBeforeClickSequence = ref<ReadonlySet<string>>(new Set())\n const lastPointer = ref<{ cx: number; cy: number; sx: number; sy: number } | null>(null)\n const pointerInside = ref(false)\n let altHeld = false\n let metaHeld = false\n let controlHeld = false\n const spaceHeld = useSpaceHeld()\n const { recordClick, getClickCount } = createClickCounter()\n\n const { getCoords, canvasToLocal, hitTestInScope, hitFns } = createCanvasPointer(\n canvasRef,\n editor,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle\n )\n\n function canMeasure() {\n return (\n pointerInside.value &&\n !drag.value &&\n editor.state.activeTool === 'SELECT' &&\n editor.state.selectedIds.size > 0 &&\n !editor.state.editingTextId &&\n !editor.state.nodeEditState &&\n !editor.state.penState\n )\n }\n\n /** ⌘ or Ctrl held: hover reaches the deepest layer, the one a click would select, as in Figma. */\n function hoverDeep(e?: MouseEvent) {\n return e ? e.metaKey || e.ctrlKey : metaHeld || controlHeld\n }\n\n function refreshMeasurement() {\n const mode = altHeld && canMeasure() ? (metaHeld || controlHeld ? 'deep' : 'shallow') : 'off'\n editor.setMeasurementMode(mode)\n const pointer = lastPointer.value\n if (!pointer || drag.value || editor.state.activeTool !== 'SELECT' || !pointerInside.value)\n return\n cursorOverride.value = updateHoverCursor(\n pointer.cx,\n pointer.cy,\n editor,\n hitFns,\n mode === 'deep' || hoverDeep()\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(pointer.cx, pointer.cy, mode))\n editor.setShapeHandleHover(shapeHandleHoverAt(pointer.sx, pointer.sy, altHeld))\n }\n\n // Handles that edit, which a read-only document does not offer.\n function autoLayoutHoverAt(cx: number, cy: number, mode: typeof editor.state.measurementMode) {\n return mode === 'off' && profile().edits ? resolveAutoLayoutHover(cx, cy, editor) : null\n }\n\n function shapeHandleHoverAt(sx: number, sy: number, altKey: boolean) {\n return profile().edits ? resolveShapeHandleHover(editor, sx, sy, altKey) : null\n }\n\n function updateModifier(code: string, held: boolean) {\n if (!isEnabled()) return\n if (code === 'AltLeft' || code === 'AltRight') altHeld = held\n if (code === 'MetaLeft' || code === 'MetaRight') metaHeld = held\n if (code === 'ControlLeft' || code === 'ControlRight') controlHeld = held\n if (code.startsWith('Alt') || code.startsWith('Meta') || code.startsWith('Control')) {\n refreshMeasurement()\n }\n }\n\n function resetMeasurementModifiers() {\n altHeld = false\n metaHeld = false\n controlHeld = false\n editor.setMeasurementMode('off')\n }\n\n function setDrag(d: DragState) {\n editor.setMeasurementMode('off')\n drag.value = d\n }\n\n const guideInput = createGuideInput({\n canvasRef,\n editor,\n canvasToLocal,\n setDrag,\n setCursor: (cursor) => {\n cursorOverride.value = cursor\n }\n })\n\n const { handleTextEditClick, onDblClick: onTextDblClick } = createTextEditInput({\n editor,\n getCoords,\n hitTestInScope,\n hitTestSectionTitle,\n hitTestComponentLabel,\n hitTestFrameTitle,\n getClickCount,\n wasSelectedBeforeClickSequence: (id) => selectedIdsBeforeClickSequence.value.has(id),\n onEditCanvasLabel: canvasLabelEdit.start,\n setDrag\n })\n\n const {\n tryStartRotation,\n handlePanMove,\n handleRotateMove,\n handleTextSelectMove,\n handleMarqueeMove\n } = createCanvasTransformInput(editor, setDrag)\n const dragMoveContext: DragMoveContext = {\n editor,\n guideInput,\n transform: { handlePanMove, handleRotateMove, handleTextSelectMove, handleMarqueeMove },\n spaceHeld: () => spaceHeld.value\n }\n\n function onDblClick(e: MouseEvent) {\n if (profile().pointer === 'pan') return\n const { cx, cy } = getCoords(e)\n if (profile().edits && valueEdit.start(cx, cy)) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n onTextDblClick(e)\n }\n\n function hoverLayers({ event, cx, cy, sx, sy }: CanvasToolPointer) {\n const guideCursor = profile().edits ? guideInput.updateHover(sx, sy) : null\n cursorOverride.value =\n guideCursor ??\n updateHoverCursor(\n cx,\n cy,\n editor,\n hitFns,\n editor.state.measurementMode === 'deep' || hoverDeep(event)\n )\n editor.setAutoLayoutHover(autoLayoutHoverAt(cx, cy, editor.state.measurementMode))\n }\n\n const toolContext: CanvasToolContext = {\n editor,\n hitFns,\n cursorOverride,\n setDrag,\n tryStartRotation,\n handleTextEditClick,\n bigNudge,\n hoverLayers\n }\n\n function onMouseDown(e: MouseEvent) {\n onActivate?.()\n if (!isEnabled()) return\n // A canvas that only pans, as a preview's does, leaves its controls to the islands above it.\n const panOnly = profile().pointer === 'pan'\n if (panOnly && e.button === 0 && editor.state.activeTool !== 'HAND') {\n e.preventDefault()\n return\n }\n // Safari treats an unprevented press as the start of a text selection drag and freezes the\n // cursor until the pointer leaves the canvas; the canvas handles its own drags.\n if (e.button === 0) e.preventDefault()\n editor.setMeasurementMode('off')\n // A press takes the view over from a glide, where it is.\n stopViewportTween(editor)\n const openValueEdit = valueEdit.edit.value\n if (openValueEdit) valueEdit.commit(openValueEdit.value)\n if (!editor.state.editingTextId) canvasRef.value?.focus()\n editor.setHoveredNode(null)\n const { sx, sy, cx, cy } = getCoords(e)\n // Guides belong to the document, so a read-only one neither moves nor gains them.\n const guidesEditable = e.button === 0 && profile().edits\n if (guidesEditable && guideInput.tryStartExisting(sx, sy, e.altKey)) {\n e.preventDefault()\n return\n }\n if (guidesEditable && guideInput.tryStartFromRuler(sx, sy, cx, cy)) {\n e.preventDefault()\n return\n }\n editor.setSelectedGuide(null)\n\n const selectedIdsBeforeMouseDown = new Set(editor.state.selectedIds)\n const clickCount = recordClick(sx, sy)\n if (clickCount === 1) selectedIdsBeforeClickSequence.value = selectedIdsBeforeMouseDown\n pressCanvasTool({ event: e, cx, cy, sx, sy }, toolContext)\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!isEnabled()) return\n pointerInside.value = true\n const coords = getCoords(e)\n lastPointer.value = { cx: coords.cx, cy: coords.cy, sx: coords.sx, sy: coords.sy }\n if (onCursorMove) {\n onCursorMove(coords.cx, coords.cy)\n }\n\n if (profile().pointer === 'pan' && !drag.value) return\n\n if (!drag.value) {\n const { cx, cy, sx, sy } = coords\n updateNodeEditHover(editor, cx, cy)\n editor.setShapeHandleHover(shapeHandleHoverAt(sx, sy, e.altKey))\n hoverCanvasTool({ event: e, ...coords }, toolContext)\n }\n\n if (!drag.value) return\n moveDrag(drag.value, e, coords, dragMoveContext)\n }\n\n function onMouseUp() {\n if (!drag.value) return\n const d = drag.value\n\n if (handleNodeEditPointerUp(drag, editor)) return\n\n if (d.type === 'guide') {\n guideInput.finish(d)\n } else if (d.type === 'move') handleMoveUp(d, editor)\n else if (d.type === 'text-select') {\n drag.value = null\n return\n } else if (d.type === 'resize') commitResizePreview(d, editor)\n else if (d.type === 'pen-drag') {\n const penState = editor.state.penState\n if (penState?.pendingClose) {\n editor.penCommit(true)\n }\n drag.value = null\n return\n } else if (d.type === 'pencil-drag') finishPencilDrag(editor)\n else if (d.type === 'rotate') {\n const preview = editor.state.rotationPreview\n if (preview?.nodeId === d.nodeId && preview.angle !== d.origRotation) {\n editor.updateNode(d.nodeId, { rotation: preview.angle })\n editor.commitRotation(d.nodeId, d.origRotation)\n }\n if (editor.state.rotationPreview === preview) editor.setRotationPreview(null)\n } else if ('commit' in d) d.commit()\n else if (d.type === 'marquee') finishMarquee(editor, d)\n\n drag.value = null\n cursorOverride.value = null\n refreshMeasurement()\n }\n\n function clearTransientInteractionFeedback() {\n editor.setSnapGuides([])\n editor.setLayoutInsertIndicator(null)\n editor.setDropTarget(null)\n editor.setShapeHandleHover(null)\n guideInput.clearHoverAndPreview()\n }\n\n /** Drops what a drag showed without changing the document. */\n function discardDrawnPreview(d: DragState) {\n if (d.type === 'resize') cancelResizePreview(d, editor)\n else if ('cancel' in d) d.cancel()\n else if (d.type === 'pencil-drag') editor.pencilCancel()\n }\n\n /** Takes back what a drag in progress has previewed, by its kind. */\n function discardDrag(d: DragState) {\n discardDrawnPreview(d)\n if (d.type === 'move') cancelMove(d, editor)\n else if (d.type === 'rotate') {\n if (editor.state.rotationPreview?.nodeId === d.nodeId) editor.setRotationPreview(null)\n } else cancelNodeEditDrag(d, editor)\n }\n\n function cancelPointerInteraction() {\n const d = drag.value\n // Cleared first: ending a preview fires events whose listeners cancel again.\n drag.value = null\n if (d) discardDrag(d)\n cursorOverride.value = null\n clearTransientInteractionFeedback()\n }\n\n function onPointerDown(e: PointerEvent) {\n if (e.pointerType !== 'mouse' || e.button !== 0) return\n canvasRef.value?.setPointerCapture(e.pointerId)\n }\n\n function onPointerUp(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n onMouseUp()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n function onPointerCancel(e: PointerEvent) {\n if (e.pointerType !== 'mouse') return\n cancelPointerInteraction()\n if (canvasRef.value?.hasPointerCapture(e.pointerId)) {\n canvasRef.value.releasePointerCapture(e.pointerId)\n }\n }\n\n useEventListener(canvasRef, 'pointerdown', onPointerDown)\n useEventListener(canvasRef, 'pointerup', onPointerUp)\n useEventListener(canvasRef, 'pointercancel', onPointerCancel)\n useEventListener(canvasRef, 'dblclick', onDblClick)\n useEventListener(canvasRef, 'mousedown', onMouseDown)\n useEventListener(canvasRef, 'mousemove', onMouseMove)\n useEventListener(canvasRef, 'mouseup', onMouseUp)\n useEventListener(window, 'keydown', (event) => {\n if (guideInput.deleteSelected(event)) return\n updateModifier(event.code, true)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n useEventListener(window, 'keyup', (event) => {\n updateModifier(event.code, false)\n refreshConnectorDrag(drag.value, lastPointer.value, event, editor)\n })\n // Pressing or releasing ⌘ or Ctrl mid-drag switches a marquee between deep and plain at once.\n useEventListener(window, ['keydown', 'keyup'], (event: KeyboardEvent) => {\n const d = drag.value\n const pointer = lastPointer.value\n // Before the first move there is no marquee to redo.\n if (d?.type !== 'marquee' || !pointer || !editor.state.marquee || !isEnabled()) return\n if (!event.code.startsWith('Meta') && !event.code.startsWith('Control')) return\n handleMarqueeMove(d, pointer.cx, pointer.cy, event.metaKey || event.ctrlKey)\n })\n useEventListener(\n window,\n 'keydown',\n (event) => {\n if (event.code !== 'Escape' || event.isComposing || !isEnabled()) return\n const type = drag.value?.type\n // A vector edit marquee carries on through Escape, as in Figma, and keeps the path open.\n const swallowed = type === 'edit-marquee'\n if (!type || (!ESCAPABLE_DRAGS.has(type) && !swallowed)) return\n event.preventDefault()\n event.stopImmediatePropagation()\n if (!swallowed) cancelPointerInteraction()\n },\n { capture: true }\n )\n // Space during a move keeps layers in their parents, as in Figma, instead of switching to the hand.\n function holdParentsDuringMove(event: KeyboardEvent, held: boolean) {\n if (event.code !== 'Space' || drag.value?.type !== 'move' || !isEnabled()) return\n event.preventDefault()\n event.stopImmediatePropagation()\n drag.value.keepParents = held\n if (held) editor.setDropTarget(null)\n }\n useEventListener(window, 'keydown', (event) => holdParentsDuringMove(event, true), {\n capture: true\n })\n useEventListener(window, 'keyup', (event) => holdParentsDuringMove(event, false), {\n capture: true\n })\n useEventListener(window, 'blur', () => {\n resetMeasurementModifiers()\n cancelPointerInteraction()\n })\n useEventListener(canvasRef, 'mouseleave', () => {\n pointerInside.value = false\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n if (!drag.value) {\n editor.setHoveredNode(null)\n editor.setHoveredGuide(null)\n editor.setShapeHandleHover(null)\n }\n })\n useEventListener(\n window,\n 'mouseup',\n () => {\n if (drag.value) onMouseUp()\n },\n { capture: true }\n )\n\n const stopRotationListener = editor.onEditorEvent('rotation:preview-changed', (preview) => {\n if (drag.value?.type === 'rotate' && preview?.nodeId !== drag.value.nodeId)\n cancelPointerInteraction()\n })\n const stopToolListener = editor.onEditorEvent('tool:changed', () => {\n if (!isEnabled()) return\n editor.setMeasurementMode('off')\n cancelPointerInteraction()\n })\n // A document that turns read-only mid-gesture drops the gesture and any open inline edit.\n const stopReadOnlyListener = editor.onEditorEvent('document:read-only-changed', (readOnly) => {\n if (!readOnly) return\n valueEdit.cancel()\n canvasLabelEdit.cancel()\n cancelPointerInteraction()\n })\n const stopPlayListeners = (['selection:changed', 'page:changed', 'graph:replaced'] as const).map(\n (event) =>\n editor.onEditorEvent(event, () => {\n const type = drag.value?.type\n if (\n type === 'draw' ||\n type === 'sticky-draw' ||\n type === 'rotate' ||\n type === 'shape-handle' ||\n type === 'image-crop' ||\n type === 'sticky-scale' ||\n type === 'scale'\n )\n cancelPointerInteraction()\n })\n )\n onScopeDispose(() => {\n stopRotationListener()\n stopToolListener()\n stopReadOnlyListener()\n for (const stop of stopPlayListeners) stop()\n cancelPointerInteraction()\n // A canvas unmounted mid-rename keeps the name typed, as the field's blur does in Chromium.\n canvasLabelEdit.commit()\n })\n\n setupPanZoom(canvasRef, editor, drag, onMouseDown, onMouseMove, onMouseUp, zoomSpeed, zoomOptions)\n return {\n drag,\n cursorOverride,\n canvasLabelEdit: canvasLabelEdit.edit,\n updateCanvasLabelEdit: canvasLabelEdit.update,\n commitCanvasLabelEdit: canvasLabelEdit.commit,\n cancelCanvasLabelEdit: canvasLabelEdit.cancel,\n autoLayoutValueEdit: valueEdit.edit,\n updateAutoLayoutValueEdit: valueEdit.update,\n commitAutoLayoutValueEdit: valueEdit.commit,\n cancelAutoLayoutValueEdit: valueEdit.cancel,\n cleanupInteractions() {\n valueEdit.cancel()\n cancelPointerInteraction()\n pointerInside.value = false\n resetMeasurementModifiers()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,kCAAkD,IAAI,IAAuB;CACjF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,eACd,WACA,QACA,qBACA,uBACA,mBACA,cACA,YACA,kBAAiC,MAEjC,kBAAgC,GAEhC,oBAA4C,4BAE5C,iBAA+B,IAC/B;CACA,MAAM,OAAO,IAAsB,IAAI;CACvC,MAAM,gBAAgB,qBAAqB,OAAO,KAAK;CAGvD,YACQ,KAAK,OAAO,OACjB,SAAS,OAAO,gBAAgB,SAAS,UAAU,SAAS,YAAY,SAAS,QAAQ,CAC5F;CACA,MAAM,kBAAkB,sBAAsB,MAAM;CACpD,MAAM,iBAAiB,IAAmB,IAAI;;CAE9C,MAAM,YAAY,0BAA0B,MAAM;CAClD,MAAM,iCAAiC,oBAAyB,IAAI,IAAI,CAAC;CACzE,MAAM,cAAc,IAA+D,IAAI;CACvF,MAAM,gBAAgB,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;CAC3B,CAAC;CACD,MAAM,oBAAqB;EAAC;EAAqB;EAAgB;CAAgB,CAAC,CAAW,KAC1F,UACC,OAAO,cAAc,aAAa;EAChC,MAAM,OAAO,KAAK,OAAO;EACzB,IACE,SAAS,UACT,SAAS,iBACT,SAAS,YACT,SAAS,kBACT,SAAS,gBACT,SAAS,kBACT,SAAS,SAET,yBAAyB;CAC7B,CAAC,CACL;CACA,qBAAqB;EACnB,qBAAqB;EACrB,iBAAiB;EACjB,qBAAqB;EACrB,KAAK,MAAM,QAAQ,mBAAmB,KAAK;EAC3C,yBAAyB;EAEzB,gBAAgB,OAAO;CACzB,CAAC;CAED,aAAa,WAAW,QAAQ,MAAM,aAAa,aAAa,WAAW,WAAW,WAAW;CACjG,OAAO;EACL;EACA;EACA,iBAAiB,gBAAgB;EACjC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,uBAAuB,gBAAgB;EACvC,qBAAqB,UAAU;EAC/B,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,2BAA2B,UAAU;EACrC,sBAAsB;GACpB,UAAU,OAAO;GACjB,yBAAyB;GACzB,cAAc,QAAQ;GACtB,0BAA0B;EAC5B;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import { useDocumentColors } from "./use.js";
2
+ export { useDocumentColors };
@@ -0,0 +1,2 @@
1
+ import { useDocumentColors } from "./use.js";
2
+ export { useDocumentColors };
@@ -0,0 +1,14 @@
1
+ import { ComputedRef } from "vue";
2
+ import { DocumentColor } from "@pairdraw/core";
3
+ //#region src/controls/document-colors/use.d.ts
4
+ /**
5
+ * The solid colours the active page uses, most used first.
6
+ *
7
+ * Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open
8
+ * picker walks the tree once, not on every render. Outside an editor, such as a preference picker,
9
+ * the list is empty.
10
+ */
11
+ declare function useDocumentColors(): ComputedRef<DocumentColor[]>;
12
+ //#endregion
13
+ export { useDocumentColors };
14
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","names":[],"sources":["../../../src/controls/document-colors/use.ts"],"mappings":";;;;;;;;;;iBAcgB,qBAAqB,YAAY"}
@@ -0,0 +1,27 @@
1
+ import { EDITOR_KEY } from "../../editor/context/index.js";
2
+ import { computed, inject } from "vue";
3
+ import { documentColors } from "@pairdraw/core";
4
+ //#region src/controls/document-colors/use.ts
5
+ /**
6
+ * The solid colours the active page uses, most used first.
7
+ *
8
+ * Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open
9
+ * picker walks the tree once, not on every render. Outside an editor, such as a preference picker,
10
+ * the list is empty.
11
+ */
12
+ function useDocumentColors() {
13
+ const editor = injectEditor();
14
+ return computed(() => {
15
+ if (!editor) return [];
16
+ editor.state.sceneVersion;
17
+ return documentColors(editor.graph, editor.state.currentPageId);
18
+ });
19
+ }
20
+ /** The injected editor, or null when the holder is not an editor subtree. */
21
+ function injectEditor() {
22
+ return inject(EDITOR_KEY, null) ?? null;
23
+ }
24
+ //#endregion
25
+ export { useDocumentColors };
26
+
27
+ //# sourceMappingURL=use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.js","names":[],"sources":["../../../src/controls/document-colors/use.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport type { ComputedRef } from 'vue'\n\nimport { documentColors, type DocumentColor, type Editor } from '@pairdraw/core'\n\nimport { EDITOR_KEY } from '#vue/editor/context'\n\n/**\n * The solid colours the active page uses, most used first.\n *\n * Recomputed only when the scene or page changes (the dependency on `sceneVersion`), so an open\n * picker walks the tree once, not on every render. Outside an editor, such as a preference picker,\n * the list is empty.\n */\nexport function useDocumentColors(): ComputedRef<DocumentColor[]> {\n const editor = injectEditor()\n return computed(() => {\n if (!editor) return []\n void editor.state.sceneVersion\n return documentColors(editor.graph, editor.state.currentPageId)\n })\n}\n\n/** The injected editor, or null when the holder is not an editor subtree. */\nfunction injectEditor(): Editor | null {\n const editor = inject(EDITOR_KEY, null)\n return editor ?? null\n}\n"],"mappings":";;;;;;;;;;;AAcA,SAAgB,oBAAkD;CAChE,MAAM,SAAS,aAAa;CAC5B,OAAO,eAAe;EACpB,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,OAAY,MAAM;EAClB,OAAO,eAAe,OAAO,OAAO,OAAO,MAAM,aAAa;CAChE,CAAC;AACH;;AAGA,SAAS,eAA8B;CAErC,OADe,OAAO,YAAY,IACtB,KAAK;AACnB"}
@@ -1,11 +1,22 @@
1
1
  import { Ref } from "vue";
2
2
  import { Editor } from "@pairdraw/core";
3
- import { Effect, SceneNode, ShadowEffect } from "@pairdraw/scene-graph";
3
+ import { Effect, NoiseEffectParams, SceneNode, ShadowEffect, TextureEffectParams } from "@pairdraw/scene-graph";
4
4
  import { Color } from "@pairdraw/scene-graph/primitives";
5
5
  //#region src/controls/effects/helpers.d.ts
6
+ /**
7
+ * One change to an effect: values to merge, or a function that reads the layer's own effect and
8
+ * returns only what it changes, so every selected layer keeps its other values.
9
+ */
10
+ type EffectChange = Partial<Effect> | ((current: Effect) => Partial<Effect>);
11
+ /** A noise value change that keeps every other grain value the layer has. */
12
+ declare function noiseChange(changes: Partial<NoiseEffectParams>): EffectChange;
13
+ /** A texture value change that keeps every other grain value the layer has. */
14
+ declare function textureChange(changes: Partial<TextureEffectParams>): EffectChange;
15
+ /** A change of a noise's type, which also keeps the grain square. */
16
+ declare function noiseTypeChange(type: NoiseEffectParams['noiseType']): EffectChange;
6
17
  declare function isShadow(type: Effect['type']): type is ShadowEffect['type'];
7
18
  declare function isShadowEffect(effect: Effect): effect is ShadowEffect;
8
19
  declare function createDefaultEffect(): Effect;
9
20
  //#endregion
10
- export { createDefaultEffect, isShadow, isShadowEffect };
21
+ export { EffectChange, createDefaultEffect, isShadow, isShadowEffect, noiseChange, noiseTypeChange, textureChange };
11
22
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/effects/helpers.ts"],"mappings":";;;;;iBAuCgB,SAAS,MAAM,iBAAiB,QAAQ;iBAIxC,eAAe,QAAQ,SAAS,UAAU;iBAI1C,uBAAuB"}
1
+ {"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/controls/effects/helpers.ts"],"mappings":";;;;;;;;;KA6BY,eAAe,QAAQ,YAAY,SAAS,WAAW,QAAQ;;iBAG3D,YAAY,SAAS,QAAQ,qBAAqB;;iBAQlD,cAAc,SAAS,QAAQ,uBAAuB;;iBAQtD,gBAAgB,MAAM,iCAAiC;iBAqCvD,SAAS,MAAM,iBAAiB,QAAQ;iBAIxC,eAAe,QAAQ,SAAS,UAAU;iBAI1C,uBAAuB"}