kritzel-stencil 0.0.131 → 0.0.132

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 (356) hide show
  1. package/dist/cjs/index-nzUNdMPh.js +6 -2
  2. package/dist/cjs/{index-BwINBV6L.js → index-ouFX0OVi.js} +715 -676
  3. package/dist/cjs/index-ouFX0OVi.js.map +1 -0
  4. package/dist/cjs/index.cjs.js +1 -1
  5. package/dist/cjs/kritzel-brush-style.cjs.entry.js +32 -0
  6. package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +1 -0
  7. package/dist/cjs/{kritzel-brush-style_23.cjs.entry.js → kritzel-color_22.cjs.entry.js} +1044 -873
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/stencil.cjs.js +1 -1
  10. package/dist/collection/classes/commands/add-object.command.js +6 -7
  11. package/dist/collection/classes/commands/add-object.command.js.map +1 -1
  12. package/dist/collection/classes/commands/add-selection-group.command.js +9 -9
  13. package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
  14. package/dist/collection/classes/commands/base.command.js +3 -3
  15. package/dist/collection/classes/commands/base.command.js.map +1 -1
  16. package/dist/collection/classes/commands/batch.command.js +2 -2
  17. package/dist/collection/classes/commands/batch.command.js.map +1 -1
  18. package/dist/collection/classes/commands/move-selection-group.command.js +7 -7
  19. package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
  20. package/dist/collection/classes/commands/remove-object.command.js +8 -9
  21. package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
  22. package/dist/collection/classes/commands/remove-selection-group.command.js +7 -7
  23. package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
  24. package/dist/collection/classes/commands/resize-selection-group.command.js +7 -7
  25. package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
  26. package/dist/collection/classes/commands/rotate-selection-group.command.js +12 -12
  27. package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
  28. package/dist/collection/classes/commands/update-object.command.js +4 -5
  29. package/dist/collection/classes/commands/update-object.command.js.map +1 -1
  30. package/dist/collection/classes/commands/update-viewport.command.js +11 -11
  31. package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
  32. package/dist/collection/classes/{store.class.js → core/core.class.js} +120 -145
  33. package/dist/collection/classes/core/core.class.js.map +1 -0
  34. package/dist/collection/classes/{database.class.js → core/database.class.js} +28 -20
  35. package/dist/collection/classes/core/database.class.js.map +1 -0
  36. package/dist/collection/classes/core/history.class.js +88 -0
  37. package/dist/collection/classes/core/history.class.js.map +1 -0
  38. package/dist/collection/classes/{reviver.class.js → core/reviver.class.js} +27 -23
  39. package/dist/collection/classes/core/reviver.class.js.map +1 -0
  40. package/dist/collection/classes/core/store.class.js +51 -0
  41. package/dist/collection/classes/core/store.class.js.map +1 -0
  42. package/dist/collection/classes/core/viewport.class.js +165 -0
  43. package/dist/collection/classes/core/viewport.class.js.map +1 -0
  44. package/dist/collection/classes/core/workspace.class.js +42 -0
  45. package/dist/collection/classes/core/workspace.class.js.map +1 -0
  46. package/dist/collection/classes/handlers/base.handler.js +4 -4
  47. package/dist/collection/classes/handlers/base.handler.js.map +1 -1
  48. package/dist/collection/classes/handlers/context-menu.handler.js +24 -19
  49. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  50. package/dist/collection/classes/handlers/hover.handler.js +5 -5
  51. package/dist/collection/classes/handlers/hover.handler.js.map +1 -1
  52. package/dist/collection/classes/handlers/key.handler.js +38 -44
  53. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  54. package/dist/collection/classes/handlers/move.handler.js +34 -34
  55. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  56. package/dist/collection/classes/handlers/resize.handler.js +53 -56
  57. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  58. package/dist/collection/classes/handlers/rotation.handler.js +53 -55
  59. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  60. package/dist/collection/classes/handlers/selection.handler.js +73 -72
  61. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  62. package/dist/collection/classes/objects/base-object.class.js +22 -17
  63. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  64. package/dist/collection/classes/objects/custom-element.class.js +3 -3
  65. package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
  66. package/dist/collection/classes/objects/image.class.js +5 -5
  67. package/dist/collection/classes/objects/image.class.js.map +1 -1
  68. package/dist/collection/classes/objects/path.class.js +7 -7
  69. package/dist/collection/classes/objects/path.class.js.map +1 -1
  70. package/dist/collection/classes/objects/selection-box.class.js +4 -4
  71. package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
  72. package/dist/collection/classes/objects/selection-group.class.js +16 -16
  73. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  74. package/dist/collection/classes/objects/text.class.js +13 -13
  75. package/dist/collection/classes/objects/text.class.js.map +1 -1
  76. package/dist/collection/classes/registries/tool.registry.js +2 -2
  77. package/dist/collection/classes/registries/tool.registry.js.map +1 -1
  78. package/dist/collection/classes/tools/base-tool.class.js +11 -5
  79. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  80. package/dist/collection/classes/tools/brush-tool.class.js +57 -53
  81. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  82. package/dist/collection/classes/tools/eraser-tool.class.js +26 -26
  83. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  84. package/dist/collection/classes/tools/image-tool.class.js +11 -11
  85. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  86. package/dist/collection/classes/tools/selection-tool.class.js +39 -37
  87. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  88. package/dist/collection/classes/tools/text-tool.class.js +37 -37
  89. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  90. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +28 -28
  91. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
  92. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +7 -9
  93. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +177 -7
  94. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  95. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +236 -233
  96. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  97. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -1
  98. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
  99. package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
  100. package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -1
  101. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +5 -0
  102. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +3 -3
  103. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
  104. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +12 -12
  105. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
  106. package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
  107. package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -1
  108. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
  109. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
  110. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
  111. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
  112. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +1 -0
  113. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
  114. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +5 -1
  115. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +2 -2
  116. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
  117. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +18 -7
  118. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +24 -9
  119. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
  120. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +4 -42
  121. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
  122. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +0 -4
  123. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +52 -10
  124. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
  125. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +4 -0
  126. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
  127. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
  128. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +79 -7
  129. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
  130. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +47 -15
  131. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  132. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +4 -0
  133. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +6 -6
  134. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
  135. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
  136. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
  137. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +12 -1
  138. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +23 -7
  139. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  140. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +5 -0
  141. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
  142. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -1
  143. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +25 -15
  144. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
  145. package/dist/collection/configs/default-engine-state.js +0 -1
  146. package/dist/collection/configs/default-engine-state.js.map +1 -1
  147. package/dist/collection/helpers/devices.helper.js +20 -0
  148. package/dist/collection/helpers/devices.helper.js.map +1 -1
  149. package/dist/collection/helpers/event.helper.js +1 -5
  150. package/dist/collection/helpers/event.helper.js.map +1 -1
  151. package/dist/collection/helpers/html.helper.js +29 -0
  152. package/dist/collection/helpers/html.helper.js.map +1 -1
  153. package/dist/collection/helpers/object.helper.js +1 -1
  154. package/dist/collection/helpers/object.helper.js.map +1 -1
  155. package/dist/collection/index.js +1 -1
  156. package/dist/collection/index.js.map +1 -1
  157. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  158. package/dist/collection/interfaces/serializable.interface.js.map +1 -1
  159. package/dist/collection/types/deep-readonly.type.js +2 -0
  160. package/dist/collection/types/deep-readonly.type.js.map +1 -0
  161. package/dist/components/index.js +3 -3
  162. package/dist/components/kritzel-brush-style.js +59 -1
  163. package/dist/components/kritzel-brush-style.js.map +1 -1
  164. package/dist/components/kritzel-color-palette.js +1 -1
  165. package/dist/components/kritzel-color.js +1 -1
  166. package/dist/components/kritzel-context-menu.js +1 -1
  167. package/dist/components/kritzel-control-brush-config.js +1 -1
  168. package/dist/components/kritzel-control-text-config.js +1 -1
  169. package/dist/components/kritzel-controls.js +1 -1
  170. package/dist/components/kritzel-cursor-trail.js +1 -1
  171. package/dist/components/kritzel-dropdown.js +1 -1
  172. package/dist/components/kritzel-editor.js +80 -37
  173. package/dist/components/kritzel-editor.js.map +1 -1
  174. package/dist/components/kritzel-engine.js +1 -1
  175. package/dist/components/kritzel-font-family.js +1 -1
  176. package/dist/components/kritzel-font-size.js +1 -1
  177. package/dist/components/kritzel-font.js +1 -1
  178. package/dist/components/kritzel-icon.js +1 -1
  179. package/dist/components/kritzel-menu-item.js +1 -1
  180. package/dist/components/kritzel-menu.js +1 -1
  181. package/dist/components/kritzel-portal.js +1 -1
  182. package/dist/components/kritzel-split-button.js +1 -1
  183. package/dist/components/kritzel-stroke-size.js +1 -1
  184. package/dist/components/kritzel-tooltip.js +1 -1
  185. package/dist/components/kritzel-utility-panel.js +1 -1
  186. package/dist/components/kritzel-workspace-manager.js +1 -1
  187. package/dist/components/{p-CMJ3P0Vw.js → p-0iJh9Z6m.js} +5 -5
  188. package/dist/components/p-0iJh9Z6m.js.map +1 -0
  189. package/dist/components/{p-DHSEK3rF.js → p-B3VQubt_.js} +164 -153
  190. package/dist/components/p-B3VQubt_.js.map +1 -0
  191. package/dist/components/{p-BB0_-X42.js → p-B7kZ1_RH.js} +4 -4
  192. package/dist/components/{p-BB0_-X42.js.map → p-B7kZ1_RH.js.map} +1 -1
  193. package/dist/components/{p-t4NIsuX9.js → p-B7w19kIk.js} +15 -27
  194. package/dist/components/p-B7w19kIk.js.map +1 -0
  195. package/dist/components/{p-B1BLgWL1.js → p-BGdsAz54.js} +27 -18
  196. package/dist/components/p-BGdsAz54.js.map +1 -0
  197. package/dist/components/{p-BhiYvSBc.js → p-BM9IjvnD.js} +3 -3
  198. package/dist/components/p-BM9IjvnD.js.map +1 -0
  199. package/dist/components/{p-BrBQUN0Q.js → p-BPsQrpzN.js} +40 -11
  200. package/dist/components/p-BPsQrpzN.js.map +1 -0
  201. package/dist/components/{p-BB5R2k1o.js → p-BiCgeOiJ.js} +41 -31
  202. package/dist/components/p-BiCgeOiJ.js.map +1 -0
  203. package/dist/components/{p-CGmS8wnN.js → p-C1-nvBx9.js} +26 -16
  204. package/dist/components/p-C1-nvBx9.js.map +1 -0
  205. package/dist/components/p-C6qB08BS.js +68 -0
  206. package/dist/components/p-C6qB08BS.js.map +1 -0
  207. package/dist/components/{p-DxTu1aoJ.js → p-CTvJDYFQ.js} +7 -45
  208. package/dist/components/p-CTvJDYFQ.js.map +1 -0
  209. package/dist/components/{p-DMrtdhBD.js → p-CsyM5q2M.js} +7 -7
  210. package/dist/components/p-CsyM5q2M.js.map +1 -0
  211. package/dist/components/{p-BPz_H-EG.js → p-CvmWmUK9.js} +28 -16
  212. package/dist/components/p-CvmWmUK9.js.map +1 -0
  213. package/dist/components/{p-BgmKrd5Z.js → p-DCx3703u.js} +5 -5
  214. package/dist/components/p-DCx3703u.js.map +1 -0
  215. package/dist/components/{p-trncBp_6.js → p-DFO-6kuA.js} +15 -15
  216. package/dist/components/p-DFO-6kuA.js.map +1 -0
  217. package/dist/components/{p-BeljsQ-8.js → p-D_907-Wd.js} +32 -17
  218. package/dist/components/p-D_907-Wd.js.map +1 -0
  219. package/dist/components/{p-BuewJQNl.js → p-Davd1R_4.js} +1111 -1085
  220. package/dist/components/p-Davd1R_4.js.map +1 -0
  221. package/dist/components/{p-BubxwvMA.js → p-Db3kxVe2.js} +24 -24
  222. package/dist/components/p-Db3kxVe2.js.map +1 -0
  223. package/dist/components/{p-BexTdWaX.js → p-Ddlbt3Bj.js} +4 -4
  224. package/dist/components/p-Ddlbt3Bj.js.map +1 -0
  225. package/dist/components/{p-CHxPWeZd.js → p-DjU7p3od.js} +11 -11
  226. package/dist/components/{p-CHxPWeZd.js.map → p-DjU7p3od.js.map} +1 -1
  227. package/dist/components/{p-DnUKql15.js → p-EXPChOF6.js} +3 -3
  228. package/dist/components/{p-DnUKql15.js.map → p-EXPChOF6.js.map} +1 -1
  229. package/dist/components/p-YqK8ch2R.js +46 -0
  230. package/dist/components/p-YqK8ch2R.js.map +1 -0
  231. package/dist/components/p-l10It7Nm.js +30 -0
  232. package/dist/components/p-l10It7Nm.js.map +1 -0
  233. package/dist/components/{p-p1Jkec_q.js → p-sq9jgfX0.js} +3 -3
  234. package/dist/components/p-sq9jgfX0.js.map +1 -0
  235. package/dist/components/{p-yZ48g7-u.js → p-sreNwi0N.js} +4 -4
  236. package/dist/components/{p-yZ48g7-u.js.map → p-sreNwi0N.js.map} +1 -1
  237. package/dist/esm/{index-B-oSk-v8.js → index-C_uHp-ur.js} +716 -677
  238. package/dist/esm/index-C_uHp-ur.js.map +1 -0
  239. package/dist/esm/index-oCOlsFCN.js +6 -2
  240. package/dist/esm/index.js +1 -1
  241. package/dist/esm/kritzel-brush-style.entry.js +30 -0
  242. package/dist/esm/kritzel-brush-style.entry.js.map +1 -0
  243. package/dist/esm/{kritzel-brush-style_23.entry.js → kritzel-color_22.entry.js} +1046 -874
  244. package/dist/esm/loader.js +1 -1
  245. package/dist/esm/stencil.js +1 -1
  246. package/dist/stencil/index.esm.js +1 -1
  247. package/dist/stencil/kritzel-brush-style.entry.esm.js.map +1 -0
  248. package/dist/stencil/p-25d1e040.entry.js +2 -0
  249. package/dist/stencil/p-25d1e040.entry.js.map +1 -0
  250. package/dist/stencil/p-C_uHp-ur.js +2 -0
  251. package/dist/stencil/p-C_uHp-ur.js.map +1 -0
  252. package/dist/stencil/p-a6f8283e.entry.js +2 -0
  253. package/dist/stencil/p-a6f8283e.entry.js.map +1 -0
  254. package/dist/stencil/stencil.esm.js +1 -1
  255. package/dist/types/classes/commands/add-object.command.d.ts +2 -2
  256. package/dist/types/classes/commands/add-selection-group.command.d.ts +2 -1
  257. package/dist/types/classes/commands/base.command.d.ts +3 -3
  258. package/dist/types/classes/commands/batch.command.d.ts +2 -1
  259. package/dist/types/classes/commands/move-selection-group.command.d.ts +2 -1
  260. package/dist/types/classes/commands/remove-object.command.d.ts +2 -2
  261. package/dist/types/classes/commands/remove-selection-group.command.d.ts +2 -2
  262. package/dist/types/classes/commands/resize-selection-group.command.d.ts +2 -1
  263. package/dist/types/classes/commands/rotate-selection-group.command.d.ts +2 -1
  264. package/dist/types/classes/commands/update-object.command.d.ts +2 -2
  265. package/dist/types/classes/commands/update-viewport.command.d.ts +2 -1
  266. package/dist/types/classes/{store.class.d.ts → core/core.class.d.ts} +9 -19
  267. package/dist/types/classes/{database.class.d.ts → core/database.class.d.ts} +3 -2
  268. package/dist/types/classes/{history.class.d.ts → core/history.class.d.ts} +5 -5
  269. package/dist/types/classes/core/reviver.class.d.ts +6 -0
  270. package/dist/types/classes/core/store.class.d.ts +17 -0
  271. package/dist/types/classes/{viewport.class.d.ts → core/viewport.class.d.ts} +3 -3
  272. package/dist/types/classes/core/workspace.class.d.ts +24 -0
  273. package/dist/types/classes/handlers/base.handler.d.ts +3 -3
  274. package/dist/types/classes/handlers/context-menu.handler.d.ts +2 -2
  275. package/dist/types/classes/handlers/hover.handler.d.ts +2 -2
  276. package/dist/types/classes/handlers/key.handler.d.ts +2 -2
  277. package/dist/types/classes/handlers/move.handler.d.ts +2 -2
  278. package/dist/types/classes/handlers/resize.handler.d.ts +2 -2
  279. package/dist/types/classes/handlers/rotation.handler.d.ts +2 -2
  280. package/dist/types/classes/handlers/selection.handler.d.ts +2 -2
  281. package/dist/types/classes/objects/base-object.class.d.ts +5 -4
  282. package/dist/types/classes/objects/custom-element.class.d.ts +2 -2
  283. package/dist/types/classes/objects/image.class.d.ts +2 -2
  284. package/dist/types/classes/objects/path.class.d.ts +2 -2
  285. package/dist/types/classes/objects/selection-box.class.d.ts +2 -2
  286. package/dist/types/classes/objects/selection-group.class.d.ts +2 -2
  287. package/dist/types/classes/objects/text.class.d.ts +2 -2
  288. package/dist/types/classes/registries/tool.registry.d.ts +2 -2
  289. package/dist/types/classes/tools/base-tool.class.d.ts +8 -4
  290. package/dist/types/classes/tools/brush-tool.class.d.ts +2 -2
  291. package/dist/types/classes/tools/eraser-tool.class.d.ts +2 -2
  292. package/dist/types/classes/tools/image-tool.class.d.ts +2 -2
  293. package/dist/types/classes/tools/selection-tool.class.d.ts +2 -2
  294. package/dist/types/classes/tools/text-tool.class.d.ts +2 -2
  295. package/dist/types/components/core/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +5 -5
  296. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +13 -3
  297. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +21 -22
  298. package/dist/types/components/shared/kritzel-dropdown/kritzel-dropdown.d.ts +2 -2
  299. package/dist/types/components/shared/kritzel-menu-item/kritzel-menu-item.d.ts +2 -0
  300. package/dist/types/components/shared/kritzel-portal/kritzel-portal.d.ts +0 -1
  301. package/dist/types/components/shared/kritzel-split-button/kritzel-split-button.d.ts +4 -2
  302. package/dist/types/components/shared/kritzel-tooltip/kritzel-tooltip.d.ts +8 -2
  303. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +5 -3
  304. package/dist/types/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.d.ts +1 -1
  305. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +3 -1
  306. package/dist/types/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +3 -2
  307. package/dist/types/components.d.ts +41 -12
  308. package/dist/types/helpers/devices.helper.d.ts +4 -0
  309. package/dist/types/helpers/event.helper.d.ts +1 -1
  310. package/dist/types/helpers/html.helper.d.ts +1 -0
  311. package/dist/types/index.d.ts +1 -1
  312. package/dist/types/interfaces/engine-state.interface.d.ts +1 -2
  313. package/dist/types/interfaces/serializable.interface.d.ts +2 -1
  314. package/dist/types/types/deep-readonly.type.d.ts +7 -0
  315. package/package.json +64 -63
  316. package/dist/cjs/index-BwINBV6L.js.map +0 -1
  317. package/dist/collection/classes/database.class.js.map +0 -1
  318. package/dist/collection/classes/history.class.js +0 -88
  319. package/dist/collection/classes/history.class.js.map +0 -1
  320. package/dist/collection/classes/reviver.class.js.map +0 -1
  321. package/dist/collection/classes/store.class.js.map +0 -1
  322. package/dist/collection/classes/viewport.class.js +0 -153
  323. package/dist/collection/classes/viewport.class.js.map +0 -1
  324. package/dist/collection/classes/workspace.class.js +0 -15
  325. package/dist/collection/classes/workspace.class.js.map +0 -1
  326. package/dist/components/p-B1BLgWL1.js.map +0 -1
  327. package/dist/components/p-BB5R2k1o.js.map +0 -1
  328. package/dist/components/p-BPz_H-EG.js.map +0 -1
  329. package/dist/components/p-B_lb1FGi.js +0 -19
  330. package/dist/components/p-B_lb1FGi.js.map +0 -1
  331. package/dist/components/p-BeljsQ-8.js.map +0 -1
  332. package/dist/components/p-BexTdWaX.js.map +0 -1
  333. package/dist/components/p-BgmKrd5Z.js.map +0 -1
  334. package/dist/components/p-BhiYvSBc.js.map +0 -1
  335. package/dist/components/p-BrBQUN0Q.js.map +0 -1
  336. package/dist/components/p-BubxwvMA.js.map +0 -1
  337. package/dist/components/p-BuewJQNl.js.map +0 -1
  338. package/dist/components/p-CGmS8wnN.js.map +0 -1
  339. package/dist/components/p-CJKA5zIE.js +0 -10
  340. package/dist/components/p-CJKA5zIE.js.map +0 -1
  341. package/dist/components/p-CMJ3P0Vw.js.map +0 -1
  342. package/dist/components/p-DHSEK3rF.js.map +0 -1
  343. package/dist/components/p-DMrtdhBD.js.map +0 -1
  344. package/dist/components/p-DxTu1aoJ.js.map +0 -1
  345. package/dist/components/p-p1Jkec_q.js.map +0 -1
  346. package/dist/components/p-rIRXQdie.js +0 -64
  347. package/dist/components/p-rIRXQdie.js.map +0 -1
  348. package/dist/components/p-t4NIsuX9.js.map +0 -1
  349. package/dist/components/p-trncBp_6.js.map +0 -1
  350. package/dist/esm/index-B-oSk-v8.js.map +0 -1
  351. package/dist/stencil/p-3bb80782.entry.js +0 -2
  352. package/dist/stencil/p-3bb80782.entry.js.map +0 -1
  353. package/dist/stencil/p-B-oSk-v8.js +0 -2
  354. package/dist/stencil/p-B-oSk-v8.js.map +0 -1
  355. package/dist/types/classes/reviver.class.d.ts +0 -6
  356. package/dist/types/classes/workspace.class.d.ts +0 -16
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  class KritzelBaseCommand {
4
- _store;
4
+ _core;
5
5
  initiator;
6
6
  skipHistory;
7
- constructor(store, initiator, skipHistory = false) {
8
- this._store = store;
7
+ constructor(core, initiator, skipHistory = false) {
8
+ this._core = core;
9
9
  this.initiator = initiator?.constructor?.name ?? 'Unknown';
10
10
  this.skipHistory = skipHistory;
11
11
  }
@@ -17,38 +17,12 @@ class KritzelBaseCommand {
17
17
  }
18
18
  }
19
19
 
20
- class ObjectHelper {
21
- static generateUUID() {
22
- return Math.random().toString(36).substr(2, 9);
23
- }
24
- static clone(objOrObjs) {
25
- const cloneObject = (obj) => {
26
- const { _store, _elementRef, totalWidth, totalHeight, element, ...remainingProps } = obj;
27
- const clonedProps = structuredClone(remainingProps);
28
- if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
29
- clonedProps.element = element.cloneNode(true);
30
- }
31
- return clonedProps;
32
- };
33
- if (Array.isArray(objOrObjs)) {
34
- return objOrObjs.map(cloneObject);
35
- }
36
- return cloneObject(objOrObjs);
37
- }
38
- static isEmpty(obj) {
39
- if (obj === null || obj === undefined) {
40
- return true;
41
- }
42
- return Object?.keys(obj).length === 0 && obj?.constructor === Object;
43
- }
44
- }
45
-
46
20
  class UpdateObjectCommand extends KritzelBaseCommand {
47
21
  object;
48
22
  updatedProperties;
49
23
  previousProperties;
50
- constructor(store, initiator, object, updatedProperties, skipHistory = false) {
51
- super(store, initiator, skipHistory);
24
+ constructor(core, initiator, object, updatedProperties, skipHistory = false) {
25
+ super(core, initiator, skipHistory);
52
26
  this.object = object;
53
27
  this.updatedProperties = updatedProperties;
54
28
  this.previousProperties = {};
@@ -64,7 +38,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
64
38
  this.object[key] = this.updatedProperties[key];
65
39
  }
66
40
  }
67
- this._store.updateObjectInDatabase(ObjectHelper.clone(this.object));
41
+ this._core.updateObjectInDatabase(this.object);
68
42
  }
69
43
  undo() {
70
44
  for (const key in this.previousProperties) {
@@ -72,14 +46,14 @@ class UpdateObjectCommand extends KritzelBaseCommand {
72
46
  this.object[key] = this.previousProperties[key];
73
47
  }
74
48
  }
75
- this._store.updateObjectInDatabase(ObjectHelper.clone(this.object));
49
+ this._core.updateObjectInDatabase(this.object);
76
50
  }
77
51
  }
78
52
 
79
53
  class KritzelToolRegistry {
80
54
  static registry = {};
81
- static registerTool(toolName, constructor, store) {
82
- const toolInstance = new constructor(store);
55
+ static registerTool(toolName, constructor, core) {
56
+ const toolInstance = new constructor(core);
83
57
  toolInstance.name = toolName;
84
58
  this.registry[toolName] = toolInstance;
85
59
  return toolInstance;
@@ -97,9 +71,9 @@ class KritzelToolRegistry {
97
71
  class KritzelBaseTool {
98
72
  __class__ = this.constructor.name;
99
73
  name = 'base-tool';
100
- _store;
101
- constructor(store) {
102
- this._store = store;
74
+ _core;
75
+ constructor(core) {
76
+ this._core = core;
103
77
  }
104
78
  onActivate() {
105
79
  // default implementation
@@ -119,7 +93,13 @@ class KritzelBaseTool {
119
93
  handleWheel(_event) {
120
94
  // default implementation
121
95
  }
122
- revive(object) {
96
+ serialize() {
97
+ return {
98
+ __class__: this.__class__,
99
+ name: this.name,
100
+ };
101
+ }
102
+ deserialize(object) {
123
103
  Object.assign(this, object);
124
104
  return this;
125
105
  }
@@ -127,17 +107,17 @@ class KritzelBaseTool {
127
107
 
128
108
  class AddObjectCommand extends KritzelBaseCommand {
129
109
  object;
130
- constructor(store, initiator, object, skipHistory = false) {
131
- super(store, initiator, skipHistory);
110
+ constructor(core, initiator, object, skipHistory = false) {
111
+ super(core, initiator, skipHistory);
132
112
  this.object = object;
133
113
  }
134
114
  execute() {
135
- this._store.state.objectsMap.insert(this.object);
136
- this._store.addObjectToDatabase(ObjectHelper.clone(this.object));
115
+ this._core.store.state.objectsMap.insert(this.object);
116
+ this._core.addObjectToDatabase(this.object);
137
117
  }
138
118
  undo() {
139
- this._store.state.objectsMap.remove(object => object.id === this.object.id);
140
- this._store.deleteObjectFromDatabase(this.object.id);
119
+ this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
120
+ this._core.deleteObjectFromDatabase(this.object.id);
141
121
  }
142
122
  }
143
123
 
@@ -163,11 +143,7 @@ class KritzelEventHelper {
163
143
  const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
164
144
  return !!contextMenu;
165
145
  }
166
- static onLongTouchPress(event, onSuccess, onCancel) {
167
- if (event.pointerType !== 'touch') {
168
- onCancel?.();
169
- return () => { };
170
- }
146
+ static onLongPress(event, onSuccess, onCancel) {
171
147
  const longPressTimeout = 400;
172
148
  const moveThreshold = 10;
173
149
  const startX = event.clientX;
@@ -275,8 +251,8 @@ class KritzelTextTool extends KritzelBaseTool {
275
251
  '#808000',
276
252
  '#800080',
277
253
  ];
278
- constructor(store) {
279
- super(store);
254
+ constructor(core) {
255
+ super(core);
280
256
  }
281
257
  handlePointerDown(event) {
282
258
  if (event.cancelable) {
@@ -285,66 +261,66 @@ class KritzelTextTool extends KritzelBaseTool {
285
261
  if (event.pointerType === 'mouse') {
286
262
  const path = event.composedPath().slice(1);
287
263
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
288
- const object = this._store.findObjectById(objectElement?.id);
289
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
290
- this._store.state.activeText = object;
264
+ const object = this._core.findObjectById(objectElement?.id);
265
+ if (this._core.store.state.activeText === null && object && object instanceof KritzelText) {
266
+ this._core.store.setState('activeText', object);
291
267
  object.focus();
292
268
  return;
293
269
  }
294
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
270
+ if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
295
271
  object.focus();
296
272
  return;
297
273
  }
298
- if (this._store.state.activeText !== null) {
299
- this._store.resetActiveText();
300
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
274
+ if (this._core.store.state.activeText !== null) {
275
+ this._core.resetActiveText();
276
+ this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
301
277
  return;
302
278
  }
303
279
  if (KritzelEventHelper.isLeftClick(event) === false) {
304
280
  return;
305
281
  }
306
- const clientX = event.clientX - this._store.offsetX;
307
- const clientY = event.clientY - this._store.offsetY;
308
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
282
+ const clientX = event.clientX - this._core.store.offsetX;
283
+ const clientY = event.clientY - this._core.store.offsetY;
284
+ const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
309
285
  text.fontColor = this.fontColor;
310
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
311
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
312
- text.zIndex = this._store.currentZIndex;
313
- this._store.state.activeText = text;
314
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
286
+ text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
287
+ text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
288
+ text.zIndex = this._core.store.currentZIndex;
289
+ this._core.store.setState('activeText', text);
290
+ this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
315
291
  }
316
292
  if (event.pointerType === 'touch') {
317
- const activePointers = Array.from(this._store.state.pointers.values());
293
+ const activePointers = Array.from(this._core.store.state.pointers.values());
318
294
  const path = event.composedPath().slice(1);
319
295
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
320
- const object = this._store.findObjectById(objectElement?.id);
321
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
322
- this._store.state.activeText = object;
296
+ const object = this._core.findObjectById(objectElement?.id);
297
+ if (this._core.store.state.activeText === null && object && object instanceof KritzelText) {
298
+ this._core.store.setState('activeText', object);
323
299
  object.focus();
324
300
  return;
325
301
  }
326
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
302
+ if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
327
303
  object.focus();
328
304
  return;
329
305
  }
330
- if (this._store.state.activeText !== null) {
331
- this._store.resetActiveText();
332
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
306
+ if (this._core.store.state.activeText !== null) {
307
+ this._core.resetActiveText();
308
+ this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
333
309
  return;
334
310
  }
335
311
  if (activePointers.length > 1) {
336
312
  return;
337
313
  }
338
314
  KritzelKeyboardHelper.disableInteractiveWidget();
339
- const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
340
- const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
341
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
315
+ const clientX = Math.round(activePointers[0].clientX - this._core.store.offsetX);
316
+ const clientY = Math.round(activePointers[0].clientY - this._core.store.offsetY);
317
+ const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
342
318
  text.fontColor = this.fontColor;
343
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
344
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
345
- text.zIndex = this._store.currentZIndex;
346
- this._store.state.activeText = text;
347
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
319
+ text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
320
+ text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
321
+ text.zIndex = this._core.store.currentZIndex;
322
+ this._core.store.setState('activeText', text);
323
+ this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
348
324
  }
349
325
  }
350
326
  handlePointerUp(event) {
@@ -352,17 +328,43 @@ class KritzelTextTool extends KritzelBaseTool {
352
328
  event.preventDefault();
353
329
  }
354
330
  if (event.pointerType === 'mouse') {
355
- this._store.state.activeText?.updateTextareaDimensions();
356
- this._store.state.activeText?.focus();
331
+ this._core.store.state.activeText?.updateTextareaDimensions();
332
+ this._core.store.state.activeText?.focus();
357
333
  }
358
334
  if (event.pointerType === 'touch') {
359
- this._store.state.activeText?.updateTextareaDimensions();
360
- this._store.state.activeText?.focus();
335
+ this._core.store.state.activeText?.updateTextareaDimensions();
336
+ this._core.store.state.activeText?.focus();
361
337
  KritzelKeyboardHelper.enableInteractiveWidget();
362
338
  }
363
339
  }
364
340
  }
365
341
 
342
+ class ObjectHelper {
343
+ static generateUUID() {
344
+ return Math.random().toString(36).substr(2, 9);
345
+ }
346
+ static clone(objOrObjs) {
347
+ const cloneObject = (obj) => {
348
+ const { _core, _elementRef, totalWidth, totalHeight, element, ...remainingProps } = obj;
349
+ const clonedProps = structuredClone(remainingProps);
350
+ if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
351
+ clonedProps.element = element.cloneNode(true);
352
+ }
353
+ return clonedProps;
354
+ };
355
+ if (Array.isArray(objOrObjs)) {
356
+ return objOrObjs.map(cloneObject);
357
+ }
358
+ return cloneObject(objOrObjs);
359
+ }
360
+ static isEmpty(obj) {
361
+ if (obj === null || obj === undefined) {
362
+ return true;
363
+ }
364
+ return Object?.keys(obj).length === 0 && obj?.constructor === Object;
365
+ }
366
+ }
367
+
366
368
  class KritzelGeometryHelper {
367
369
  static doPolygonsIntersect(polygon1, polygon2) {
368
370
  // 1. Convert polygons to array of points for easier processing
@@ -418,7 +420,7 @@ class KritzelGeometryHelper {
418
420
 
419
421
  class KritzelBaseObject {
420
422
  __class__ = 'KritzelBaseObject';
421
- _store;
423
+ _core;
422
424
  _elementRef;
423
425
  id;
424
426
  workspaceId;
@@ -532,11 +534,11 @@ class KritzelBaseObject {
532
534
  constructor() {
533
535
  this.id = this.generateId();
534
536
  }
535
- static create(store) {
537
+ static create(core) {
536
538
  const object = new KritzelBaseObject();
537
- object._store = store;
538
- object.zIndex = store.currentZIndex;
539
- object.workspaceId = store.state.activeWorkspace.id;
539
+ object._core = core;
540
+ object.zIndex = core.store.currentZIndex;
541
+ object.workspaceId = core.store.state.activeWorkspace.id;
540
542
  return object;
541
543
  }
542
544
  mount(element) {
@@ -563,23 +565,23 @@ class KritzelBaseObject {
563
565
  }
564
566
  isInViewport() {
565
567
  const viewportBounds = {
566
- x: -this._store.state.translateX / this._store.state.scale,
567
- y: -this._store.state.translateY / this._store.state.scale,
568
- width: this._store.state.viewportWidth / this._store.state.scale,
569
- height: this._store.state.viewportHeight / this._store.state.scale};
568
+ x: -this._core.store.state.translateX / this._core.store.state.scale,
569
+ y: -this._core.store.state.translateY / this._core.store.state.scale,
570
+ width: this._core.store.state.viewportWidth / this._core.store.state.scale,
571
+ height: this._core.store.state.viewportHeight / this._core.store.state.scale};
570
572
  return (this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
571
573
  this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&
572
574
  this.boundingBox.y < viewportBounds.y + viewportBounds.height &&
573
575
  this.boundingBox.y + this.boundingBox.height > viewportBounds.y);
574
576
  }
575
577
  centerInViewport() {
576
- const scale = this._store.state.scale;
577
- this.translateX = (this._store.state.viewportWidth / 2 - this.totalWidth / 2 - this._store.state.translateX) / scale;
578
- this.translateY = (this._store.state.viewportHeight / 2 - this.totalHeight / 2 - this._store.state.translateY) / scale;
578
+ const scale = this._core.store.state.scale;
579
+ this.translateX = (this._core.store.state.viewportWidth / 2 - this.totalWidth / 2 - this._core.store.state.translateX) / scale;
580
+ this.translateY = (this._core.store.state.viewportHeight / 2 - this.totalHeight / 2 - this._core.store.state.translateY) / scale;
579
581
  }
580
582
  move(startX, startY, endX, endY) {
581
- const deltaX = (startX - endX) / this._store.state.scale;
582
- const deltaY = (startY - endY) / this._store.state.scale;
583
+ const deltaX = (startX - endX) / this._core.store.state.scale;
584
+ const deltaY = (startY - endY) / this._core.store.state.scale;
583
585
  this.translateX += deltaX;
584
586
  this.translateY += deltaY;
585
587
  }
@@ -605,7 +607,12 @@ class KritzelBaseObject {
605
607
  onSelectedClick() {
606
608
  // This method can be overridden by subclasses to handle click events when the object is selected.
607
609
  }
608
- revive(object) {
610
+ serialize() {
611
+ return {
612
+ ...ObjectHelper.clone(this)
613
+ };
614
+ }
615
+ deserialize(object) {
609
616
  Object.assign(this, object);
610
617
  return this;
611
618
  }
@@ -625,7 +632,7 @@ class KritzelBaseObject {
625
632
  updatePosition(x, y) {
626
633
  this.translateX = x;
627
634
  this.translateY = y;
628
- this._store.state.objectsMap.update(this);
635
+ this._core.store.state.objectsMap.update(this);
629
636
  }
630
637
  }
631
638
 
@@ -641,7 +648,7 @@ class KritzelText extends KritzelBaseObject {
641
648
  isEditable = true;
642
649
  rows = 1;
643
650
  get isReadonly() {
644
- return !(this._store.state.activeTool instanceof KritzelTextTool);
651
+ return !(this._core.store.state.activeTool instanceof KritzelTextTool);
645
652
  }
646
653
  constructor(config) {
647
654
  super();
@@ -657,22 +664,22 @@ class KritzelText extends KritzelBaseObject {
657
664
  this.scale = config.scale || 1;
658
665
  }
659
666
  }
660
- static create(store, fontSize, fontFamily) {
667
+ static create(core, fontSize, fontFamily) {
661
668
  const object = new KritzelText();
662
- object._store = store;
669
+ object._core = core;
663
670
  object.id = object.generateId();
664
- object.workspaceId = store.state.activeWorkspace.id;
671
+ object.workspaceId = core.store.state.activeWorkspace.id;
665
672
  object.fontSize = fontSize;
666
673
  object.fontFamily = fontFamily;
667
674
  object.translateX = 0;
668
675
  object.translateY = 0;
669
- object.width = object.initialWidth / (object._store.state.scale < 0 ? object._store.state.scale : 1);
670
- object.height = (object.fontSize * 1.2) / (object._store.state.scale < 0 ? object._store.state.scale : 1);
676
+ object.width = object.initialWidth / (object._core.store.state.scale < 0 ? object._core.store.state.scale : 1);
677
+ object.height = (object.fontSize * 1.2) / (object._core.store.state.scale < 0 ? object._core.store.state.scale : 1);
671
678
  object.padding = 5;
672
679
  object.backgroundColor = 'transparent';
673
- object.scale = object._store.state.scale;
680
+ object.scale = object._core.store.state.scale;
674
681
  object.value = ' ';
675
- object.zIndex = store.currentZIndex;
682
+ object.zIndex = core.store.currentZIndex;
676
683
  return object;
677
684
  }
678
685
  mount(element) {
@@ -726,7 +733,7 @@ class KritzelText extends KritzelBaseObject {
726
733
  document.body.removeChild(span);
727
734
  this.width = textWidth;
728
735
  this.height = textHeight;
729
- this._store.history.executeCommand(new UpdateObjectCommand(this._store, this, this, { ...this }));
736
+ this._core.history.executeCommand(new UpdateObjectCommand(this._core, this, this, { ...this }));
730
737
  }
731
738
  }
732
739
  focus() {
@@ -759,10 +766,10 @@ class KritzelText extends KritzelBaseObject {
759
766
  }
760
767
  }
761
768
  edit() {
762
- this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
763
- this._store.state.selectionGroup = null;
764
- this._store.state.selectionBox = null;
765
- this._store.state.activeText = this;
769
+ this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
770
+ this._core.store.setState('selectionGroup', null);
771
+ this._core.store.setState('selectionBox', null);
772
+ this._core.store.setState('activeText', this);
766
773
  setTimeout(() => {
767
774
  this.focus();
768
775
  }, 300);
@@ -822,11 +829,11 @@ class KritzelPath extends KritzelBaseObject {
822
829
  this.d = this.generateSvgPath();
823
830
  this.updateDimensions();
824
831
  }
825
- static create(store, options) {
832
+ static create(core, options) {
826
833
  const object = new KritzelPath();
827
- object._store = store;
834
+ object._core = core;
828
835
  object.id = object.generateId();
829
- object.workspaceId = store.state.activeWorkspace.id;
836
+ object.workspaceId = core.store.state.activeWorkspace.id;
830
837
  object.options = options;
831
838
  object.points = options?.points ?? [];
832
839
  object.translateX = options?.translateX ?? 0;
@@ -834,7 +841,7 @@ class KritzelPath extends KritzelBaseObject {
834
841
  object.scale = options?.scale ?? 1;
835
842
  object.strokeWidth = options?.strokeWidth ?? 8;
836
843
  object.fill = options?.fill ?? '#000000';
837
- object.zIndex = store.currentZIndex;
844
+ object.zIndex = core.store.currentZIndex;
838
845
  object.d = object.generateSvgPath();
839
846
  object.updateDimensions();
840
847
  return object;
@@ -862,8 +869,8 @@ class KritzelPath extends KritzelBaseObject {
862
869
  this._adjustedPoints = null;
863
870
  }
864
871
  move(startX, startY, endX, endY) {
865
- const deltaX = (startX - endX) / this._store.state.scale;
866
- const deltaY = (startY - endY) / this._store.state.scale;
872
+ const deltaX = (startX - endX) / this._core.store.state.scale;
873
+ const deltaY = (startY - endY) / this._core.store.state.scale;
867
874
  this.translateX += deltaX;
868
875
  this.translateY += deltaY;
869
876
  this._adjustedPoints = null;
@@ -942,7 +949,7 @@ class KritzelPath extends KritzelBaseObject {
942
949
  this.translateX = x;
943
950
  this.translateY = y;
944
951
  this._adjustedPoints = null;
945
- this._store.state.objectsMap.update(this);
952
+ this._core.store.state.objectsMap.update(this);
946
953
  }
947
954
  computeAdjustedPoints() {
948
955
  if (!this.points?.length) {
@@ -1073,17 +1080,17 @@ class KritzelImage extends KritzelBaseObject {
1073
1080
  this.translateY = config?.translateY || 0;
1074
1081
  this.scale = config?.scale || 1;
1075
1082
  }
1076
- static create(store) {
1083
+ static create(core) {
1077
1084
  const object = new KritzelImage();
1078
- object._store = store;
1085
+ object._core = core;
1079
1086
  object.id = object.generateId();
1080
- object.workspaceId = store.state.activeWorkspace.id;
1087
+ object.workspaceId = core.store.state.activeWorkspace.id;
1081
1088
  object.x = 0;
1082
1089
  object.y = 0;
1083
1090
  object.translateX = 0;
1084
1091
  object.translateY = 0;
1085
- object.scale = object._store.state.scale;
1086
- object.zIndex = store.currentZIndex;
1092
+ object.scale = object._core.store.state.scale;
1093
+ object.zIndex = core.store.currentZIndex;
1087
1094
  return object;
1088
1095
  }
1089
1096
  resize(x, y, width, height) {
@@ -1118,8 +1125,8 @@ class KritzelBrushTool extends KritzelBaseTool {
1118
1125
  pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],
1119
1126
  highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
1120
1127
  };
1121
- constructor(store) {
1122
- super(store);
1128
+ constructor(core) {
1129
+ super(core);
1123
1130
  }
1124
1131
  handlePointerDown(event) {
1125
1132
  if (event.cancelable) {
@@ -1127,34 +1134,34 @@ class KritzelBrushTool extends KritzelBaseTool {
1127
1134
  }
1128
1135
  if (event.pointerType === 'mouse') {
1129
1136
  if (KritzelEventHelper.isLeftClick(event)) {
1130
- this._store.state.isDrawing = true;
1131
- const x = event.clientX - this._store.offsetX;
1132
- const y = event.clientY - this._store.offsetY;
1133
- this._store.state.currentPath = KritzelPath.create(this._store, {
1137
+ this._core.store.setState('isDrawing', true);
1138
+ const x = event.clientX - this._core.store.offsetX;
1139
+ const y = event.clientY - this._core.store.offsetY;
1140
+ this._core.store.setState('currentPath', KritzelPath.create(this._core, {
1134
1141
  points: [[x, y]],
1135
- translateX: -this._store.state.translateX,
1136
- translateY: -this._store.state.translateY,
1137
- scale: this._store.state.scale,
1142
+ translateX: -this._core.store.state.translateX,
1143
+ translateY: -this._core.store.state.translateY,
1144
+ scale: this._core.store.state.scale,
1138
1145
  fill: this.color,
1139
1146
  strokeWidth: this.size,
1140
- });
1147
+ }));
1141
1148
  }
1142
1149
  }
1143
1150
  if (event.pointerType === 'touch') {
1144
- const activePointers = Array.from(this._store.state.pointers.values());
1151
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1145
1152
  if (activePointers.length === 1) {
1146
- const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1147
- const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1148
- this._store.state.isDrawing = true;
1149
- this._store.state.currentPath = KritzelPath.create(this._store, {
1153
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
1154
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
1155
+ this._core.store.setState('isDrawing', true);
1156
+ this._core.store.setState('currentPath', KritzelPath.create(this._core, {
1150
1157
  points: [[x, y]],
1151
- translateX: -this._store.state.translateX,
1152
- translateY: -this._store.state.translateY,
1153
- scale: this._store.state.scale,
1158
+ translateX: -this._core.store.state.translateX,
1159
+ translateY: -this._core.store.state.translateY,
1160
+ scale: this._core.store.state.scale,
1154
1161
  fill: this.color,
1155
1162
  strokeWidth: this.size,
1156
- });
1157
- this._store.rerender();
1163
+ }));
1164
+ this._core.rerender();
1158
1165
  }
1159
1166
  }
1160
1167
  }
@@ -1163,34 +1170,34 @@ class KritzelBrushTool extends KritzelBaseTool {
1163
1170
  event.preventDefault();
1164
1171
  }
1165
1172
  if (event.pointerType === 'mouse') {
1166
- if (this._store.state.isDrawing) {
1167
- const x = event.clientX - this._store.offsetX;
1168
- const y = event.clientY - this._store.offsetY;
1169
- this._store.state.currentPath = KritzelPath.create(this._store, {
1170
- points: [...this._store.state.currentPath.points, [x, y]],
1171
- translateX: -this._store.state.translateX,
1172
- translateY: -this._store.state.translateY,
1173
- scale: this._store.state.scale,
1173
+ if (this._core.store.state.isDrawing) {
1174
+ const x = event.clientX - this._core.store.offsetX;
1175
+ const y = event.clientY - this._core.store.offsetY;
1176
+ this._core.store.setState('currentPath', KritzelPath.create(this._core, {
1177
+ points: [...this._core.store.state.currentPath.points, [x, y]],
1178
+ translateX: -this._core.store.state.translateX,
1179
+ translateY: -this._core.store.state.translateY,
1180
+ scale: this._core.store.state.scale,
1174
1181
  fill: this.color,
1175
1182
  strokeWidth: this.size,
1176
- });
1177
- this._store.rerender();
1183
+ }));
1184
+ this._core.rerender();
1178
1185
  }
1179
1186
  }
1180
1187
  if (event.pointerType === 'touch') {
1181
- const activePointers = Array.from(this._store.state.pointers.values());
1188
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1182
1189
  if (activePointers.length === 1) {
1183
- const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1184
- const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1185
- this._store.state.currentPath = KritzelPath.create(this._store, {
1186
- points: [...this._store.state.currentPath.points, [x, y]],
1187
- translateX: -this._store.state.translateX,
1188
- translateY: -this._store.state.translateY,
1189
- scale: this._store.state.scale,
1190
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
1191
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
1192
+ this._core.store.setState('currentPath', KritzelPath.create(this._core, {
1193
+ points: [...this._core.store.state.currentPath.points, [x, y]],
1194
+ translateX: -this._core.store.state.translateX,
1195
+ translateY: -this._core.store.state.translateY,
1196
+ scale: this._core.store.state.scale,
1190
1197
  fill: this.color,
1191
1198
  strokeWidth: this.size,
1192
- });
1193
- this._store.rerender();
1199
+ }));
1200
+ this._core.rerender();
1194
1201
  }
1195
1202
  }
1196
1203
  }
@@ -1199,24 +1206,28 @@ class KritzelBrushTool extends KritzelBaseTool {
1199
1206
  event.preventDefault();
1200
1207
  }
1201
1208
  if (event.pointerType === 'mouse') {
1202
- if (this._store.state.isDrawing) {
1203
- this._store.state.isDrawing = false;
1204
- if (this._store.state.currentPath) {
1205
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
1206
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
1209
+ if (this._core.store.state.isDrawing) {
1210
+ this._core.store.setState('isDrawing', false);
1211
+ if (this._core.store.state.currentPath) {
1212
+ const currentPath = this._core.store.state.currentPath;
1213
+ currentPath.zIndex = this._core.store.currentZIndex;
1214
+ this._core.store.setState('currentPath', currentPath);
1215
+ this._core.history.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
1207
1216
  }
1208
- this._store.state.currentPath = undefined;
1217
+ this._core.store.setState('currentPath', undefined);
1209
1218
  }
1210
1219
  }
1211
1220
  if (event.pointerType === 'touch') {
1212
- if (this._store.state.isDrawing) {
1213
- this._store.state.isDrawing = false;
1214
- if (this._store.state.currentPath) {
1215
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
1216
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
1221
+ if (this._core.store.state.isDrawing) {
1222
+ this._core.store.setState('isDrawing', false);
1223
+ if (this._core.store.state.currentPath) {
1224
+ const currentPath = this._core.store.state.currentPath;
1225
+ currentPath.zIndex = this._core.store.currentZIndex;
1226
+ this._core.store.setState('currentPath', currentPath);
1227
+ this._core.history.executeCommand(new AddObjectCommand(this._core, this, currentPath));
1217
1228
  }
1218
- this._store.state.currentPath = undefined;
1219
- this._store.rerender();
1229
+ this._core.store.setState('currentPath', undefined);
1230
+ this._core.rerender();
1220
1231
  }
1221
1232
  }
1222
1233
  }
@@ -1224,8 +1235,8 @@ class KritzelBrushTool extends KritzelBaseTool {
1224
1235
 
1225
1236
  class BatchCommand extends KritzelBaseCommand {
1226
1237
  commands;
1227
- constructor(store, initiator, commands, skipHistory = false) {
1228
- super(store, initiator, skipHistory);
1238
+ constructor(core, initiator, commands, skipHistory = false) {
1239
+ super(core, initiator, skipHistory);
1229
1240
  this.commands = commands;
1230
1241
  }
1231
1242
  execute() {
@@ -1251,11 +1262,11 @@ class KritzelCustomElement extends KritzelBaseObject {
1251
1262
  this.width = config.width || 0;
1252
1263
  }
1253
1264
  }
1254
- static create(store, config) {
1265
+ static create(core, config) {
1255
1266
  const object = new KritzelCustomElement(config);
1256
- object._store = store;
1267
+ object._core = core;
1257
1268
  object.id = object.generateId();
1258
- object.workspaceId = store.state.activeWorkspace.id;
1269
+ object.workspaceId = core.store.state.activeWorkspace.id;
1259
1270
  return object;
1260
1271
  }
1261
1272
  mount(element) {
@@ -1291,98 +1302,98 @@ class KritzelCustomElement extends KritzelBaseObject {
1291
1302
 
1292
1303
  class RemoveObjectCommand extends KritzelBaseCommand {
1293
1304
  object;
1294
- constructor(store, initiator, object, skipHistory = false) {
1295
- super(store, initiator, skipHistory);
1305
+ constructor(core, initiator, object, skipHistory = false) {
1306
+ super(core, initiator, skipHistory);
1296
1307
  this.object = object;
1297
1308
  }
1298
1309
  execute() {
1299
- this._store.state.objectsMap.remove(object => object.id === this.object.id);
1300
- this._store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
1301
- this._store.deleteObjectFromDatabase(this.object.id);
1310
+ this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
1311
+ this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
1312
+ this._core.deleteObjectFromDatabase(this.object.id);
1302
1313
  }
1303
1314
  undo() {
1304
- this._store.state.objectsMap.insert(this.object);
1305
- this._store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
1306
- this._store.addObjectToDatabase(ObjectHelper.clone(this.object));
1315
+ this._core.store.state.objectsMap.insert(this.object);
1316
+ this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
1317
+ this._core.addObjectToDatabase(this.object);
1307
1318
  }
1308
1319
  }
1309
1320
 
1310
1321
  class KritzelEraserTool extends KritzelBaseTool {
1311
1322
  touchStartTimeout = null;
1312
- constructor(store) {
1313
- super(store);
1323
+ constructor(core) {
1324
+ super(core);
1314
1325
  }
1315
1326
  handlePointerDown(event) {
1316
1327
  if (event.pointerType === 'mouse') {
1317
1328
  if (KritzelEventHelper.isLeftClick(event)) {
1318
- this._store.state.isErasing = true;
1329
+ this._core.store.setState('isErasing', true);
1319
1330
  }
1320
1331
  }
1321
1332
  if (event.pointerType === 'touch') {
1322
1333
  this.touchStartTimeout = setTimeout(() => {
1323
- if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
1324
- this._store.state.isErasing = true;
1334
+ if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
1335
+ this._core.store.setState('isErasing', true);
1325
1336
  }
1326
1337
  }, 80);
1327
1338
  }
1328
1339
  }
1329
1340
  handlePointerMove(event) {
1330
1341
  if (event.pointerType === 'mouse') {
1331
- if (this._store.state.isErasing) {
1332
- const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1342
+ if (this._core.store.state.isErasing) {
1343
+ const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
1333
1344
  if (selectedObjects.length === 0)
1334
1345
  return;
1335
- const x = this._store.state.pointerX;
1336
- const y = this._store.state.pointerY;
1346
+ const x = this._core.store.state.pointerX;
1347
+ const y = this._core.store.state.pointerY;
1337
1348
  selectedObjects.forEach(selectedObject => {
1338
1349
  selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1339
1350
  });
1340
- this._store.rerender();
1351
+ this._core.rerender();
1341
1352
  }
1342
1353
  }
1343
1354
  if (event.pointerType === 'touch') {
1344
- if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
1345
- const shadowRoot = this._store.state.host?.shadowRoot;
1355
+ if (this._core.store.state.pointers.size === 1 && this._core.store.state.isErasing) {
1356
+ const shadowRoot = this._core.store.state.host?.shadowRoot;
1346
1357
  if (!shadowRoot)
1347
1358
  return;
1348
- const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1359
+ const selectedObjects = this._core.getObjectsFromPointerEvent(event, '.object');
1349
1360
  if (selectedObjects.length === 0)
1350
1361
  return;
1351
- const x = this._store.state.pointerX;
1352
- const y = this._store.state.pointerY;
1362
+ const x = this._core.store.state.pointerX;
1363
+ const y = this._core.store.state.pointerY;
1353
1364
  selectedObjects.forEach(selectedObject => {
1354
1365
  selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1355
1366
  });
1356
- this._store.rerender();
1367
+ this._core.rerender();
1357
1368
  }
1358
1369
  }
1359
1370
  }
1360
1371
  handlePointerUp(event) {
1361
1372
  if (event.pointerType === 'mouse') {
1362
- if (this._store.state.isErasing) {
1363
- const removeCommands = this._store.allObjects.filter(object => object.markedForRemoval).map(object => {
1373
+ if (this._core.store.state.isErasing) {
1374
+ const removeCommands = this._core.store.allObjects.filter(object => object.markedForRemoval).map(object => {
1364
1375
  object.markedForRemoval = false;
1365
- return new RemoveObjectCommand(this._store, this, object);
1376
+ return new RemoveObjectCommand(this._core, this, object);
1366
1377
  });
1367
1378
  if (removeCommands.length > 0) {
1368
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1379
+ this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
1369
1380
  }
1370
- this._store.state.isErasing = false;
1381
+ this._core.store.setState('isErasing', false);
1371
1382
  }
1372
1383
  }
1373
1384
  if (event.pointerType === 'touch') {
1374
1385
  clearTimeout(this.touchStartTimeout);
1375
- if (this._store.state.isErasing) {
1376
- const removeCommands = this._store.allObjects
1386
+ if (this._core.store.state.isErasing) {
1387
+ const removeCommands = this._core.store.allObjects
1377
1388
  .filter(object => object.markedForRemoval)
1378
1389
  .map(object => {
1379
1390
  object.markedForRemoval = false;
1380
- return new RemoveObjectCommand(this._store, this, object);
1391
+ return new RemoveObjectCommand(this._core, this, object);
1381
1392
  });
1382
1393
  if (removeCommands.length > 0) {
1383
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1394
+ this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
1384
1395
  }
1385
- this._store.state.isErasing = false;
1396
+ this._core.store.setState('isErasing', false);
1386
1397
  }
1387
1398
  }
1388
1399
  }
@@ -1390,18 +1401,18 @@ class KritzelEraserTool extends KritzelBaseTool {
1390
1401
 
1391
1402
  class RemoveSelectionGroupCommand extends KritzelBaseCommand {
1392
1403
  previousSelectionGroup;
1393
- constructor(store, initiator, skipHistory = false) {
1394
- super(store, initiator, skipHistory);
1395
- this.previousSelectionGroup = this._store.state.selectionGroup;
1404
+ constructor(core, initiator, skipHistory = false) {
1405
+ super(core, initiator, skipHistory);
1406
+ this.previousSelectionGroup = this._core.store.state.selectionGroup;
1396
1407
  }
1397
1408
  execute() {
1398
- this._store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
1399
- this._store.state.selectionGroup = null;
1409
+ this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
1410
+ this._core.store.setState('selectionGroup', null);
1400
1411
  }
1401
1412
  undo() {
1402
1413
  if (this.previousSelectionGroup) {
1403
- this._store.state.objectsMap.insert(this.previousSelectionGroup);
1404
- this._store.state.selectionGroup = this.previousSelectionGroup;
1414
+ this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
1415
+ this._core.store.setState('selectionGroup', this.previousSelectionGroup);
1405
1416
  }
1406
1417
  }
1407
1418
  }
@@ -1413,33 +1424,33 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
1413
1424
  endX;
1414
1425
  endY;
1415
1426
  skipExecution;
1416
- constructor(store, initiator, startX, startY, endX, endY, skipFirstExecution = false, skipHistory = false) {
1417
- super(store, initiator, skipHistory);
1427
+ constructor(core, initiator, startX, startY, endX, endY, skipFirstExecution = false, skipHistory = false) {
1428
+ super(core, initiator, skipHistory);
1418
1429
  this.startX = startX;
1419
1430
  this.startY = startY;
1420
1431
  this.endX = endX;
1421
1432
  this.endY = endY;
1422
1433
  this.skipExecution = skipFirstExecution;
1423
- this.selectionGroup = this._store.state.selectionGroup;
1434
+ this.selectionGroup = this._core.store.state.selectionGroup;
1424
1435
  }
1425
1436
  execute() {
1426
1437
  if (this.skipExecution) {
1427
1438
  this.skipExecution = false;
1428
1439
  return;
1429
1440
  }
1430
- this._store.state.selectionGroup = this.selectionGroup;
1431
- this._store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
1441
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1442
+ this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
1432
1443
  }
1433
1444
  undo() {
1434
- this._store.state.selectionGroup = this.selectionGroup;
1435
- this._store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
1445
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1446
+ this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
1436
1447
  }
1437
1448
  }
1438
1449
 
1439
1450
  class KritzelBaseHandler {
1440
- _store;
1441
- constructor(store) {
1442
- this._store = store;
1451
+ _core;
1452
+ constructor(core) {
1453
+ this._core = core;
1443
1454
  }
1444
1455
  }
1445
1456
 
@@ -1450,16 +1461,16 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1450
1461
  startY;
1451
1462
  endX;
1452
1463
  endY;
1453
- constructor(store) {
1454
- super(store);
1464
+ constructor(core) {
1465
+ super(core);
1455
1466
  }
1456
1467
  handlePointerDown(event) {
1457
1468
  if (event.pointerType === 'mouse') {
1458
1469
  if (KritzelEventHelper.isLeftClick(event)) {
1459
- if (this._store.state.selectionGroup?.isSelected && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1460
- const clientX = event.clientX - this._store.offsetX;
1461
- const clientY = event.clientY - this._store.offsetY;
1462
- this._store.state.isDragging = true;
1470
+ if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
1471
+ const clientX = event.clientX - this._core.store.offsetX;
1472
+ const clientY = event.clientY - this._core.store.offsetY;
1473
+ this._core.store.setState('isDragging', true);
1463
1474
  this.dragStartX = clientX;
1464
1475
  this.dragStartY = clientY;
1465
1476
  this.startX = this.dragStartX;
@@ -1468,11 +1479,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1468
1479
  }
1469
1480
  }
1470
1481
  if (event.pointerType === 'touch') {
1471
- const activePointers = Array.from(this._store.state.pointers.values());
1472
- if (this._store.state.pointers.size === 1) {
1473
- if (this._store.state.selectionGroup?.isSelected && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1474
- const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1475
- const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1482
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1483
+ if (this._core.store.state.pointers.size === 1) {
1484
+ if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
1485
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
1486
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
1476
1487
  this.dragStartX = x;
1477
1488
  this.dragStartY = y;
1478
1489
  this.startX = x;
@@ -1483,30 +1494,30 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1483
1494
  }
1484
1495
  handlePointerMove(event) {
1485
1496
  if (event.pointerType === 'mouse') {
1486
- if (this._store.state.isDragging && this._store.state.selectionGroup) {
1487
- const clientX = event.clientX - this._store.offsetX;
1488
- const clientY = event.clientY - this._store.offsetY;
1497
+ if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
1498
+ const clientX = event.clientX - this._core.store.offsetX;
1499
+ const clientY = event.clientY - this._core.store.offsetY;
1489
1500
  this.endX = clientX;
1490
1501
  this.endY = clientY;
1491
- this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1502
+ this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1492
1503
  this.dragStartX = clientX;
1493
1504
  this.dragStartY = clientY;
1494
1505
  }
1495
1506
  }
1496
1507
  if (event.pointerType === 'touch') {
1497
- const activePointers = Array.from(this._store.state.pointers.values());
1498
- if (this._store.state.pointers.size === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1499
- const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1500
- const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1501
- this._store.state.isDragging = true;
1508
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1509
+ if (this._core.store.state.pointers.size === 1 && this._core.store.state.selectionGroup && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
1510
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
1511
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
1512
+ this._core.store.setState('isDragging', true);
1502
1513
  this.endX = x;
1503
1514
  this.endY = y;
1504
1515
  const moveDeltaX = Math.abs(x - this.startX);
1505
1516
  const moveDeltaY = Math.abs(y - this.startY);
1506
1517
  const moveThreshold = 5;
1507
1518
  if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
1508
- clearTimeout(this._store.state.longTouchTimeout);
1509
- this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1519
+ clearTimeout(this._core.store.state.longTouchTimeout);
1520
+ this._core.store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1510
1521
  this.dragStartX = x;
1511
1522
  this.dragStartY = y;
1512
1523
  }
@@ -1515,29 +1526,29 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1515
1526
  }
1516
1527
  handlePointerUp(event) {
1517
1528
  if (event.pointerType === 'mouse') {
1518
- if (this._store.state.isDragging) {
1519
- this._store.state.isDragging = false;
1520
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true);
1521
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1522
- return new UpdateObjectCommand(this._store, this, object, {
1529
+ if (this._core.store.state.isDragging) {
1530
+ this._core.store.setState('isDragging', false);
1531
+ const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
1532
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1533
+ return new UpdateObjectCommand(this._core, this, object, {
1523
1534
  translateX: object.translateX,
1524
1535
  translateY: object.translateY
1525
1536
  });
1526
1537
  });
1527
- this._store.history.executeCommand(new BatchCommand(this._store, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
1538
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
1528
1539
  }
1529
1540
  }
1530
1541
  if (event.pointerType === 'touch') {
1531
- if (this._store.state.isDragging) {
1532
- this._store.state.isDragging = false;
1533
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true);
1534
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1535
- return new UpdateObjectCommand(this._store, this, object, {
1542
+ if (this._core.store.state.isDragging) {
1543
+ this._core.store.setState('isDragging', false);
1544
+ const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
1545
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1546
+ return new UpdateObjectCommand(this._core, this, object, {
1536
1547
  translateX: object.translateX,
1537
1548
  translateY: object.translateY
1538
1549
  });
1539
1550
  });
1540
- this._store.history.executeCommand(new BatchCommand(this._store, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
1551
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
1541
1552
  }
1542
1553
  }
1543
1554
  }
@@ -1555,19 +1566,19 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
1555
1566
  newSize;
1556
1567
  previousSize;
1557
1568
  selectionGroup;
1558
- constructor(store, initiator, previousSize, newSize, skipHistory = false) {
1559
- super(store, initiator, skipHistory);
1569
+ constructor(core, initiator, previousSize, newSize, skipHistory = false) {
1570
+ super(core, initiator, skipHistory);
1560
1571
  this.previousSize = previousSize;
1561
1572
  this.newSize = newSize;
1562
- this.selectionGroup = this._store.state.selectionGroup;
1573
+ this.selectionGroup = this._core.store.state.selectionGroup;
1563
1574
  }
1564
1575
  execute() {
1565
- this._store.state.selectionGroup = this.selectionGroup;
1566
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1576
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1577
+ this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1567
1578
  }
1568
1579
  undo() {
1569
- this._store.state.selectionGroup = this.selectionGroup;
1570
- this._store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
1580
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1581
+ this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
1571
1582
  }
1572
1583
  }
1573
1584
 
@@ -1576,71 +1587,71 @@ class KritzelResizeHandler extends KritzelBaseHandler {
1576
1587
  initialMouseY = 0;
1577
1588
  initialSize = { x: 0, y: 0, width: 0, height: 0 };
1578
1589
  newSize = { x: 0, y: 0, width: 0, height: 0 };
1579
- constructor(store) {
1580
- super(store);
1590
+ constructor(core) {
1591
+ super(core);
1581
1592
  }
1582
1593
  handlePointerDown(event) {
1583
1594
  if (event.pointerType === 'mouse') {
1584
1595
  if (KritzelEventHelper.isLeftClick(event)) {
1585
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1586
- const clientX = event.clientX - this._store.offsetX;
1587
- const clientY = event.clientY - this._store.offsetY;
1588
- this._store.state.isResizing = true;
1596
+ if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
1597
+ const clientX = event.clientX - this._core.store.offsetX;
1598
+ const clientY = event.clientY - this._core.store.offsetY;
1599
+ this._core.store.setState('isResizing', true);
1589
1600
  this.initialMouseX = clientX;
1590
1601
  this.initialMouseY = clientY;
1591
- this.initialSize.width = this._store.state.selectionGroup.width;
1592
- this.initialSize.height = this._store.state.selectionGroup.height;
1593
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1594
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1602
+ this.initialSize.width = this._core.store.state.selectionGroup.width;
1603
+ this.initialSize.height = this._core.store.state.selectionGroup.height;
1604
+ this.initialSize.x = this._core.store.state.selectionGroup.translateX;
1605
+ this.initialSize.y = this._core.store.state.selectionGroup.translateY;
1595
1606
  }
1596
1607
  }
1597
1608
  }
1598
1609
  if (event.pointerType === 'touch') {
1599
- const activePointers = Array.from(this._store.state.pointers.values());
1610
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1600
1611
  const firstTouch = activePointers[0];
1601
1612
  if (!firstTouch) {
1602
1613
  return;
1603
1614
  }
1604
1615
  if (activePointers.length === 1) {
1605
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1606
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1607
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1608
- this._store.state.isResizing = true;
1616
+ if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
1617
+ const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
1618
+ const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
1619
+ this._core.store.setState('isResizing', true);
1609
1620
  this.initialMouseX = clientX;
1610
1621
  this.initialMouseY = clientY;
1611
- this.initialSize.width = this._store.state.selectionGroup.width;
1612
- this.initialSize.height = this._store.state.selectionGroup.height;
1613
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1614
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1615
- clearTimeout(this._store.state.longTouchTimeout);
1622
+ this.initialSize.width = this._core.store.state.selectionGroup.width;
1623
+ this.initialSize.height = this._core.store.state.selectionGroup.height;
1624
+ this.initialSize.x = this._core.store.state.selectionGroup.translateX;
1625
+ this.initialSize.y = this._core.store.state.selectionGroup.translateY;
1626
+ clearTimeout(this._core.store.state.longTouchTimeout);
1616
1627
  }
1617
1628
  }
1618
1629
  }
1619
1630
  }
1620
1631
  handlePointerMove(event) {
1621
1632
  if (event.pointerType === 'mouse') {
1622
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1623
- const clientX = event.clientX - this._store.offsetX;
1624
- const clientY = event.clientY - this._store.offsetY;
1633
+ if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
1634
+ const clientX = event.clientX - this._core.store.offsetX;
1635
+ const clientY = event.clientY - this._core.store.offsetY;
1625
1636
  const dx = clientX - this.initialMouseX;
1626
1637
  const dy = clientY - this.initialMouseY;
1627
- switch (this._store.state.resizeHandleType) {
1638
+ switch (this._core.store.state.resizeHandleType) {
1628
1639
  case KritzelHandleType.TopLeft:
1629
1640
  this.newSize.width = this.initialSize.width - dx;
1630
1641
  this.newSize.height = this.initialSize.height - dy;
1631
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1632
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1642
+ this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
1643
+ this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
1633
1644
  break;
1634
1645
  case KritzelHandleType.TopRight:
1635
1646
  this.newSize.width = this.initialSize.width + dx;
1636
1647
  this.newSize.height = this.initialSize.height - dy;
1637
1648
  this.newSize.x = this.initialSize.x;
1638
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1649
+ this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
1639
1650
  break;
1640
1651
  case KritzelHandleType.BottomLeft:
1641
1652
  this.newSize.width = this.initialSize.width - dx;
1642
1653
  this.newSize.height = this.initialSize.height + dy;
1643
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1654
+ this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
1644
1655
  this.newSize.y = this.initialSize.y;
1645
1656
  break;
1646
1657
  case KritzelHandleType.BottomRight:
@@ -1650,38 +1661,37 @@ class KritzelResizeHandler extends KritzelBaseHandler {
1650
1661
  this.newSize.y = this.initialSize.y;
1651
1662
  break;
1652
1663
  }
1653
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1654
- this._store.rerender();
1664
+ this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1655
1665
  }
1656
1666
  }
1657
1667
  if (event.pointerType === 'touch') {
1658
- const activePointers = Array.from(this._store.state.pointers.values());
1668
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1659
1669
  const oneFingerTouch = activePointers[0];
1660
1670
  if (!oneFingerTouch) {
1661
1671
  return;
1662
1672
  }
1663
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1664
- const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
1665
- const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
1673
+ if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
1674
+ const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);
1675
+ const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);
1666
1676
  const dx = clientX - this.initialMouseX;
1667
1677
  const dy = clientY - this.initialMouseY;
1668
- switch (this._store.state.resizeHandleType) {
1678
+ switch (this._core.store.state.resizeHandleType) {
1669
1679
  case KritzelHandleType.TopLeft:
1670
1680
  this.newSize.width = this.initialSize.width - dx;
1671
1681
  this.newSize.height = this.initialSize.height - dy;
1672
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1673
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1682
+ this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
1683
+ this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
1674
1684
  break;
1675
1685
  case KritzelHandleType.TopRight:
1676
1686
  this.newSize.width = this.initialSize.width + dx;
1677
1687
  this.newSize.height = this.initialSize.height - dy;
1678
1688
  this.newSize.x = this.initialSize.x;
1679
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1689
+ this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
1680
1690
  break;
1681
1691
  case KritzelHandleType.BottomLeft:
1682
1692
  this.newSize.width = this.initialSize.width - dx;
1683
1693
  this.newSize.height = this.initialSize.height + dy;
1684
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1694
+ this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
1685
1695
  this.newSize.y = this.initialSize.y;
1686
1696
  break;
1687
1697
  case KritzelHandleType.BottomRight:
@@ -1691,33 +1701,31 @@ class KritzelResizeHandler extends KritzelBaseHandler {
1691
1701
  this.newSize.y = this.initialSize.y;
1692
1702
  break;
1693
1703
  }
1694
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1695
- clearTimeout(this._store.state.longTouchTimeout);
1704
+ this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1705
+ clearTimeout(this._core.store.state.longTouchTimeout);
1696
1706
  }
1697
1707
  }
1698
1708
  }
1699
1709
  handlePointerUp(event) {
1700
1710
  if (event.pointerType === 'mouse') {
1701
- if (this._store.state.isResizing) {
1702
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1703
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1704
- return new UpdateObjectCommand(this._store, this, object, { ...object });
1711
+ if (this._core.store.state.isResizing) {
1712
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1713
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1714
+ return new UpdateObjectCommand(this._core, this, object, { ...object });
1705
1715
  });
1706
- this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
1707
- this._store.state.isResizing = false;
1708
- this._store.rerender();
1716
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
1717
+ this._core.store.setState('isResizing', false);
1709
1718
  }
1710
1719
  }
1711
1720
  if (event.pointerType === 'touch') {
1712
- if (this._store.state.isResizing) {
1713
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1714
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1715
- return new UpdateObjectCommand(this._store, this, object, { ...object });
1721
+ if (this._core.store.state.isResizing) {
1722
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1723
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1724
+ return new UpdateObjectCommand(this._core, this, object, { ...object });
1716
1725
  });
1717
- this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
1718
- this._store.state.isResizing = false;
1719
- this._store.rerender();
1720
- clearTimeout(this._store.state.longTouchTimeout);
1726
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
1727
+ this._core.store.setState('isResizing', false);
1728
+ clearTimeout(this._core.store.state.longTouchTimeout);
1721
1729
  }
1722
1730
  }
1723
1731
  }
@@ -1727,24 +1735,24 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
1727
1735
  rotation;
1728
1736
  initialRotation;
1729
1737
  selectionGroup;
1730
- constructor(store, initiator, rotation, skipHistory = false) {
1731
- super(store, initiator, skipHistory);
1738
+ constructor(core, initiator, rotation, skipHistory = false) {
1739
+ super(core, initiator, skipHistory);
1732
1740
  this.rotation = rotation;
1733
- this.initialRotation = this._store.state.selectionGroup.rotation;
1734
- this.selectionGroup = this._store.state.selectionGroup;
1741
+ this.initialRotation = this._core.store.state.selectionGroup.rotation;
1742
+ this.selectionGroup = this._core.store.state.selectionGroup;
1735
1743
  }
1736
1744
  execute() {
1737
- this._store.state.selectionGroup = this.selectionGroup;
1738
- this._store.state.selectionGroup.rotate(this.rotation);
1739
- this._store.state.selectionGroup.objects.forEach(object => {
1740
- this._store.state.objectsMap.update(object);
1745
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1746
+ this._core.store.state.selectionGroup.rotate(this.rotation);
1747
+ this._core.store.state.selectionGroup.objects.forEach(object => {
1748
+ this._core.store.state.objectsMap.update(object);
1741
1749
  });
1742
1750
  }
1743
1751
  undo() {
1744
- this._store.state.selectionGroup = this.selectionGroup;
1745
- this._store.state.selectionGroup.rotate(this.rotation - this.initialRotation);
1746
- this._store.state.selectionGroup.objects.forEach(object => {
1747
- this._store.state.objectsMap.update(object);
1752
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1753
+ this._core.store.state.selectionGroup.rotate(this.rotation - this.initialRotation);
1754
+ this._core.store.state.selectionGroup.objects.forEach(object => {
1755
+ this._core.store.state.objectsMap.update(object);
1748
1756
  });
1749
1757
  }
1750
1758
  }
@@ -1752,111 +1760,109 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
1752
1760
  class KritzelRotationHandler extends KritzelBaseHandler {
1753
1761
  initialRotation = 0;
1754
1762
  rotation = 0;
1755
- constructor(store) {
1756
- super(store);
1763
+ constructor(core) {
1764
+ super(core);
1757
1765
  }
1758
1766
  handlePointerDown(event) {
1759
1767
  if (event.pointerType === 'mouse') {
1760
1768
  if (KritzelEventHelper.isLeftClick(event)) {
1761
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1762
- const clientX = event.clientX - this._store.offsetX;
1763
- const clientY = event.clientY - this._store.offsetY;
1764
- this._store.state.isRotating = true;
1765
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1766
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1767
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1768
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1769
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1769
+ if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
1770
+ const clientX = event.clientX - this._core.store.offsetX;
1771
+ const clientY = event.clientY - this._core.store.offsetY;
1772
+ this._core.store.setState('isRotating', true);
1773
+ const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
1774
+ const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
1775
+ const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
1776
+ const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
1777
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
1770
1778
  }
1771
1779
  }
1772
1780
  }
1773
1781
  if (event.pointerType === 'touch') {
1774
- const activePointers = Array.from(this._store.state.pointers.values());
1782
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1775
1783
  const firstTouch = activePointers[0];
1776
1784
  if (!firstTouch) {
1777
1785
  return;
1778
1786
  }
1779
1787
  if (activePointers.length === 1) {
1780
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1781
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1782
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1783
- this._store.state.isRotating = true;
1784
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1785
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1786
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1787
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1788
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1789
- clearTimeout(this._store.state.longTouchTimeout);
1788
+ if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
1789
+ const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
1790
+ const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
1791
+ this._core.store.setState('isRotating', true);
1792
+ const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
1793
+ const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
1794
+ const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
1795
+ const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
1796
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
1797
+ clearTimeout(this._core.store.state.longTouchTimeout);
1790
1798
  }
1791
1799
  }
1792
1800
  }
1793
1801
  }
1794
1802
  handlePointerMove(event) {
1795
1803
  if (event.pointerType === 'mouse') {
1796
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1797
- const clientX = event.clientX - this._store.offsetX;
1798
- const clientY = event.clientY - this._store.offsetY;
1799
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1800
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1801
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1802
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1804
+ if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
1805
+ const clientX = event.clientX - this._core.store.offsetX;
1806
+ const clientY = event.clientY - this._core.store.offsetY;
1807
+ const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
1808
+ const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
1809
+ const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
1810
+ const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
1803
1811
  const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1804
1812
  this.rotation = currentRotation - this.initialRotation;
1805
- this._store.state.selectionGroup.rotate(this.rotation);
1806
- this._store.rerender();
1813
+ this._core.store.state.selectionGroup.rotate(this.rotation);
1807
1814
  }
1808
1815
  }
1809
1816
  if (event.pointerType === 'touch') {
1810
- const activePointers = Array.from(this._store.state.pointers.values());
1817
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1811
1818
  const firstTouch = activePointers[0];
1812
1819
  if (!firstTouch) {
1813
1820
  return;
1814
1821
  }
1815
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1816
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1817
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1818
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1819
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1820
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1821
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1822
+ if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
1823
+ const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
1824
+ const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
1825
+ const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
1826
+ const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
1827
+ const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
1828
+ const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
1822
1829
  const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1823
1830
  this.rotation = currentRotation - this.initialRotation;
1824
- this._store.state.selectionGroup.rotate(this.rotation);
1825
- this._store.rerender();
1826
- clearTimeout(this._store.state.longTouchTimeout);
1831
+ this._core.store.state.selectionGroup.rotate(this.rotation);
1832
+ clearTimeout(this._core.store.state.longTouchTimeout);
1827
1833
  }
1828
1834
  }
1829
1835
  }
1830
1836
  handlePointerUp(event) {
1831
1837
  if (event.pointerType === 'mouse') {
1832
- if (this._store.state.isRotating) {
1833
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._store, this, this.rotation);
1834
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1835
- return new UpdateObjectCommand(this._store, this, object, {
1838
+ if (this._core.store.state.isRotating) {
1839
+ const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
1840
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1841
+ return new UpdateObjectCommand(this._core, this, object, {
1836
1842
  rotation: object.rotation,
1837
1843
  translateX: object.translateX,
1838
1844
  translateY: object.translateY,
1839
1845
  });
1840
1846
  });
1841
- this._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
1842
- this._store.state.isRotating = false;
1847
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
1848
+ this._core.store.setState('isRotating', false);
1843
1849
  this.initialRotation = 0;
1844
1850
  this.rotation = 0;
1845
1851
  }
1846
1852
  }
1847
1853
  if (event.pointerType === 'touch') {
1848
- if (this._store.state.isRotating) {
1849
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._store, this, this.rotation);
1850
- const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {
1851
- return new UpdateObjectCommand(this._store, this, object, {
1854
+ if (this._core.store.state.isRotating) {
1855
+ const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
1856
+ const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
1857
+ return new UpdateObjectCommand(this._core, this, object, {
1852
1858
  rotation: object.rotation,
1853
1859
  });
1854
1860
  });
1855
- this._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
1856
- this._store.state.isRotating = false;
1861
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
1862
+ this._core.store.setState('isRotating', false);
1857
1863
  this.initialRotation = 0;
1858
1864
  this.rotation = 0;
1859
- clearTimeout(this._store.state.longTouchTimeout);
1865
+ clearTimeout(this._core.store.state.longTouchTimeout);
1860
1866
  }
1861
1867
  }
1862
1868
  }
@@ -1865,12 +1871,12 @@ class KritzelRotationHandler extends KritzelBaseHandler {
1865
1871
  class KrtizelSelectionBox extends KritzelBaseObject {
1866
1872
  __class__ = 'KrtizelSelectionBox';
1867
1873
  objects = [];
1868
- static create(store) {
1874
+ static create(core) {
1869
1875
  const object = new KrtizelSelectionBox();
1870
- object._store = store;
1876
+ object._core = core;
1871
1877
  object.id = object.generateId();
1872
- object.workspaceId = store.state.activeWorkspace.id;
1873
- object.scale = store.state.scale;
1878
+ object.workspaceId = core.store.state.activeWorkspace.id;
1879
+ object.scale = core.store.state.scale;
1874
1880
  object.zIndex = 99999;
1875
1881
  object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(0, 122, 255, 0.2))';
1876
1882
  object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(0, 122, 255, 0.5))';
@@ -1883,20 +1889,20 @@ class KrtizelSelectionBox extends KritzelBaseObject {
1883
1889
 
1884
1890
  class AddSelectionGroupCommand extends KritzelBaseCommand {
1885
1891
  selectionGroup;
1886
- constructor(store, initiator, selectionGroup, skipHistory = false) {
1887
- super(store, initiator, skipHistory);
1892
+ constructor(core, initiator, selectionGroup, skipHistory = false) {
1893
+ super(core, initiator, skipHistory);
1888
1894
  this.selectionGroup = selectionGroup;
1889
1895
  }
1890
1896
  execute() {
1891
- this._store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
1892
- this._store.state.objectsMap.insert(this.selectionGroup);
1893
- this._store.state.selectionGroup = this.selectionGroup;
1894
- this._store.state.selectionBox = null;
1897
+ this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
1898
+ this._core.store.state.objectsMap.insert(this.selectionGroup);
1899
+ this._core.store.setState('selectionGroup', this.selectionGroup);
1900
+ this._core.store.setState('selectionBox', null);
1895
1901
  }
1896
1902
  undo() {
1897
- this._store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
1898
- this._store.state.selectionGroup = null;
1899
- this._store.state.selectionBox = null;
1903
+ this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
1904
+ this._core.store.setState('selectionGroup', null);
1905
+ this._core.store.setState('selectionBox', null);
1900
1906
  }
1901
1907
  }
1902
1908
 
@@ -1907,23 +1913,23 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1907
1913
  touchStartY = 0;
1908
1914
  touchStartTimeout = null;
1909
1915
  get isSelectionClick() {
1910
- return this._store.state.selectionBox && this._store.state.selectionBox.width === 0 && this._store.state.selectionBox.height === 0;
1916
+ return this._core.store.state.selectionBox && this._core.store.state.selectionBox.width === 0 && this._core.store.state.selectionBox.height === 0;
1911
1917
  }
1912
1918
  get isSelectionDrag() {
1913
- return this._store.state.selectionBox && (this._store.state.selectionBox.width > 0 || this._store.state.selectionBox.height > 0);
1919
+ return this._core.store.state.selectionBox && (this._core.store.state.selectionBox.width > 0 || this._core.store.state.selectionBox.height > 0);
1914
1920
  }
1915
- constructor(store) {
1916
- super(store);
1921
+ constructor(core) {
1922
+ super(core);
1917
1923
  }
1918
1924
  handlePointerDown(event) {
1919
1925
  if (event.pointerType === 'mouse') {
1920
- if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
1926
+ if (KritzelEventHelper.isLeftClick(event) && !this._core.store.state.selectionGroup) {
1921
1927
  this.startMouseSelection(event);
1922
1928
  }
1923
1929
  }
1924
1930
  if (event.pointerType === 'touch') {
1925
1931
  this.touchStartTimeout = setTimeout(() => {
1926
- if (this._store.state.pointers.size === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
1932
+ if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling && !this._core.store.state.selectionGroup) {
1927
1933
  this.startTouchSelection();
1928
1934
  this.updateTouchSelection();
1929
1935
  }
@@ -1932,30 +1938,30 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1932
1938
  }
1933
1939
  handlePointerMove(event) {
1934
1940
  if (event.pointerType === 'mouse') {
1935
- if (this._store.state.isSelecting) {
1941
+ if (this._core.store.state.isSelecting) {
1936
1942
  this.updateMouseSelection(event);
1937
1943
  }
1938
1944
  }
1939
1945
  if (event.pointerType === 'touch') {
1940
- const activePointers = Array.from(this._store.state.pointers.values());
1941
- const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1942
- const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1946
+ const activePointers = Array.from(this._core.store.state.pointers.values());
1947
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
1948
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
1943
1949
  const moveDeltaX = Math.abs(x - this.touchStartX);
1944
1950
  const moveDeltaY = Math.abs(y - this.touchStartY);
1945
1951
  const moveThreshold = 5;
1946
- if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
1952
+ if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._core.store.state.isSelecting) {
1947
1953
  this.updateTouchSelection();
1948
- clearTimeout(this._store.state.longTouchTimeout);
1954
+ clearTimeout(this._core.store.state.longTouchTimeout);
1949
1955
  }
1950
1956
  }
1951
1957
  }
1952
1958
  handlePointerUp(event) {
1953
1959
  if (event.pointerType === 'mouse') {
1954
- if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
1960
+ if (KritzelEventHelper.isLeftClick(event) && this._core.store.state.isSelecting) {
1955
1961
  if (this.isSelectionClick) {
1956
- const x = this._store.state.pointerX;
1957
- const y = this._store.state.pointerY;
1958
- const selectedObject = this._store.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1962
+ const x = this._core.store.state.pointerX;
1963
+ const y = this._core.store.state.pointerY;
1964
+ const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1959
1965
  this.addObjectToSelectionGroup(selectedObject);
1960
1966
  this.removeSelectionBox();
1961
1967
  }
@@ -1968,11 +1974,11 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1968
1974
  }
1969
1975
  if (event.pointerType === 'touch') {
1970
1976
  clearTimeout(this.touchStartTimeout);
1971
- if (this._store.state.isSelecting) {
1977
+ if (this._core.store.state.isSelecting) {
1972
1978
  if (this.isSelectionClick) {
1973
- const x = this._store.state.pointerX;
1974
- const y = this._store.state.pointerY;
1975
- const selectedObject = this._store.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1979
+ const x = this._core.store.state.pointerX;
1980
+ const y = this._core.store.state.pointerY;
1981
+ const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1976
1982
  this.addObjectToSelectionGroup(selectedObject);
1977
1983
  this.removeSelectionBox();
1978
1984
  }
@@ -1981,82 +1987,80 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1981
1987
  this.addSelectedObjectsToSelectionGroup();
1982
1988
  this.removeSelectionBox();
1983
1989
  }
1984
- this._store.state.skipContextMenu = false;
1990
+ this._core.store.setState('skipContextMenu', false);
1985
1991
  }
1986
1992
  }
1987
1993
  }
1988
1994
  removeSelectionBox() {
1989
- this._store.state.selectionBox = null;
1990
- this._store.state.isSelecting = false;
1991
- this._store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
1992
- this._store.rerender();
1995
+ this._core.store.setState('selectionBox', null);
1996
+ this._core.store.setState('isSelecting', false);
1997
+ this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
1993
1998
  }
1994
1999
  startMouseSelection(event) {
1995
2000
  let clientX, clientY;
1996
- clientX = event.clientX - this._store.offsetX;
1997
- clientY = event.clientY - this._store.offsetY;
1998
- const selectionBox = KrtizelSelectionBox.create(this._store);
1999
- this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
2000
- this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
2001
+ clientX = event.clientX - this._core.store.offsetX;
2002
+ clientY = event.clientY - this._core.store.offsetY;
2003
+ const selectionBox = KrtizelSelectionBox.create(this._core);
2004
+ this.startX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
2005
+ this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
2001
2006
  selectionBox.translateX = this.startX;
2002
2007
  selectionBox.translateY = this.startY;
2003
- this._store.state.selectionGroup = null;
2004
- this._store.state.selectionBox = selectionBox;
2005
- this._store.state.isSelecting = true;
2006
- this._store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2007
- this._store.state.objectsMap.insert(selectionBox);
2008
+ this._core.store.setState('selectionGroup', null);
2009
+ this._core.store.setState('selectionBox', selectionBox);
2010
+ this._core.store.setState('isSelecting', true);
2011
+ this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2012
+ this._core.store.state.objectsMap.insert(selectionBox);
2008
2013
  }
2009
2014
  startTouchSelection() {
2010
- const activePointers = Array.from(this._store.state.pointers.values());
2015
+ const activePointers = Array.from(this._core.store.state.pointers.values());
2011
2016
  const firstTouch = activePointers[0];
2012
2017
  if (!firstTouch) {
2013
2018
  return;
2014
2019
  }
2015
2020
  let clientX, clientY;
2016
- clientX = Math.round(firstTouch.clientX - this._store.offsetX);
2017
- clientY = Math.round(firstTouch.clientY - this._store.offsetY);
2021
+ clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
2022
+ clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
2018
2023
  this.touchStartX = clientX;
2019
2024
  this.touchStartY = clientY;
2020
- const selectionBox = KrtizelSelectionBox.create(this._store);
2021
- this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
2022
- this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
2025
+ const selectionBox = KrtizelSelectionBox.create(this._core);
2026
+ this.startX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
2027
+ this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
2023
2028
  selectionBox.translateX = this.startX;
2024
2029
  selectionBox.translateY = this.startY;
2025
- this._store.state.selectionGroup = null;
2026
- this._store.state.selectionBox = selectionBox;
2027
- this._store.state.isSelecting = true;
2028
- this._store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2029
- this._store.state.objectsMap.insert(selectionBox);
2030
+ this._core.store.setState('selectionGroup', null);
2031
+ this._core.store.setState('selectionBox', selectionBox);
2032
+ this._core.store.setState('isSelecting', true);
2033
+ this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2034
+ this._core.store.state.objectsMap.insert(selectionBox);
2030
2035
  }
2031
2036
  updateMouseSelection(event) {
2032
2037
  let clientX, clientY;
2033
- clientX = event.clientX - this._store.offsetX;
2034
- clientY = event.clientY - this._store.offsetY;
2035
- const selectionBox = this._store.state.selectionBox;
2038
+ clientX = event.clientX - this._core.store.offsetX;
2039
+ clientY = event.clientY - this._core.store.offsetY;
2040
+ const selectionBox = this._core.store.state.selectionBox;
2036
2041
  if (selectionBox) {
2037
- const currentX = (clientX - this._store.state.translateX) / selectionBox.scale;
2038
- const currentY = (clientY - this._store.state.translateY) / selectionBox.scale;
2042
+ const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
2043
+ const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
2039
2044
  selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
2040
2045
  selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
2041
2046
  selectionBox.translateX = Math.min(currentX, this.startX);
2042
2047
  selectionBox.translateY = Math.min(currentY, this.startY);
2043
2048
  this.updateSelectedObjects();
2044
- this._store.rerender();
2045
2049
  }
2046
2050
  }
2047
2051
  updateTouchSelection() {
2048
- const activePointers = Array.from(this._store.state.pointers.values());
2052
+ const activePointers = Array.from(this._core.store.state.pointers.values());
2049
2053
  const firstTouch = activePointers[0];
2050
2054
  if (!firstTouch) {
2051
2055
  return;
2052
2056
  }
2053
2057
  let clientX, clientY;
2054
- clientX = Math.round(firstTouch.clientX - this._store.offsetX);
2055
- clientY = Math.round(firstTouch.clientY - this._store.offsetY);
2056
- const selectionBox = this._store.state.selectionBox;
2058
+ clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
2059
+ clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
2060
+ const selectionBox = this._core.store.state.selectionBox;
2057
2061
  if (selectionBox) {
2058
- const currentX = (clientX - this._store.state.translateX) / selectionBox.scale;
2059
- const currentY = (clientY - this._store.state.translateY) / selectionBox.scale;
2062
+ const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
2063
+ const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
2060
2064
  selectionBox.width = Math.abs(currentX - this.startX) * selectionBox.scale;
2061
2065
  selectionBox.height = Math.abs(currentY - this.startY) * selectionBox.scale;
2062
2066
  selectionBox.translateX = Math.min(currentX, this.startX);
@@ -2065,49 +2069,52 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2065
2069
  }
2066
2070
  }
2067
2071
  updateSelectedObjects() {
2068
- this._store.allObjects
2072
+ this._core.store.allObjects
2069
2073
  .filter(o => !(o instanceof KrtizelSelectionBox))
2070
- .forEach(object => (object.isSelected = object.hitTestPolygon(this._store.state.selectionBox.rotatedPolygon)));
2074
+ .forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
2071
2075
  }
2072
2076
  addObjectToSelectionGroup(object) {
2073
2077
  if (!object) {
2074
2078
  return;
2075
2079
  }
2076
- this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
2077
- this._store.state.selectionGroup.addOrRemove(object);
2078
- this._store.state.selectionGroup.isSelected = true;
2079
- this._store.state.selectionGroup.rotation = object.rotation;
2080
- this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
2080
+ const selectionGroup = KritzelSelectionGroup.create(this._core);
2081
+ selectionGroup.addOrRemove(object);
2082
+ selectionGroup.isSelected = true;
2083
+ selectionGroup.rotation = object.rotation;
2084
+ this._core.store.setState('selectionGroup', selectionGroup);
2085
+ this._core.history.executeCommand(new AddSelectionGroupCommand(this._core, this, this._core.store.state.selectionGroup));
2081
2086
  }
2082
2087
  addSelectedObjectsToSelectionGroup() {
2083
- const selectedObjects = this._store.selectedObjects;
2088
+ const selectedObjects = this._core.store.selectedObjects;
2084
2089
  if (selectedObjects.length === 0) {
2085
2090
  return;
2086
2091
  }
2087
- this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
2092
+ this._core.store.setState('selectionGroup', KritzelSelectionGroup.create(this._core));
2088
2093
  selectedObjects.forEach(o => {
2089
2094
  o.isSelected = false;
2090
- this._store.state.selectionGroup.addOrRemove(o);
2095
+ this._core.store.state.selectionGroup.addOrRemove(o);
2091
2096
  });
2092
- this._store.state.selectionGroup.isSelected = true;
2093
- if (this._store.state.selectionGroup.length === 1) {
2094
- this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
2097
+ const selectionGroup = this._core.store.state.selectionGroup;
2098
+ selectionGroup.isSelected = true;
2099
+ if (selectionGroup.length === 1) {
2100
+ selectionGroup.rotation = selectionGroup.objects[0].rotation;
2095
2101
  }
2096
- this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
2102
+ this._core.store.setState('selectionGroup', selectionGroup);
2103
+ this._core.history.executeCommand(new AddSelectionGroupCommand(this._core, this, this._core.store.state.selectionGroup));
2097
2104
  }
2098
2105
  }
2099
2106
 
2100
2107
  class KritzelHoverHandler extends KritzelBaseHandler {
2101
- constructor(store) {
2102
- super(store);
2108
+ constructor(core) {
2109
+ super(core);
2103
2110
  }
2104
2111
  handlePointerMove(event) {
2105
2112
  if (event.pointerType === 'mouse') {
2106
- const hoveredObject = this._store.getObjectFromPointerEvent(event, '.object');
2113
+ const hoveredObject = this._core.getObjectFromPointerEvent(event, '.object');
2107
2114
  if (!hoveredObject)
2108
2115
  return;
2109
- const x = this._store.state.pointerX;
2110
- const y = this._store.state.pointerY;
2116
+ const x = this._core.store.state.pointerX;
2117
+ const y = this._core.store.state.pointerY;
2111
2118
  hoveredObject.isHovered = hoveredObject.hitTest(x, y);
2112
2119
  }
2113
2120
  }
@@ -2119,13 +2126,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
2119
2126
  hoverHandler;
2120
2127
  resizeHandler;
2121
2128
  rotationHandler;
2122
- constructor(store) {
2123
- super(store);
2124
- this.selectionHandler = new KritzelSelectionHandler(this._store);
2125
- this.moveHandler = new KritzelMoveHandler(this._store);
2126
- this.hoverHandler = new KritzelHoverHandler(this._store);
2127
- this.resizeHandler = new KritzelResizeHandler(this._store);
2128
- this.rotationHandler = new KritzelRotationHandler(this._store);
2129
+ constructor(core) {
2130
+ super(core);
2131
+ this.selectionHandler = new KritzelSelectionHandler(this._core);
2132
+ this.moveHandler = new KritzelMoveHandler(this._core);
2133
+ this.hoverHandler = new KritzelHoverHandler(this._core);
2134
+ this.resizeHandler = new KritzelResizeHandler(this._core);
2135
+ this.rotationHandler = new KritzelRotationHandler(this._core);
2129
2136
  }
2130
2137
  handlePointerDown(event) {
2131
2138
  if (event.cancelable) {
@@ -2133,16 +2140,16 @@ class KritzelSelectionTool extends KritzelBaseTool {
2133
2140
  }
2134
2141
  if (event.pointerType === 'mouse') {
2135
2142
  if (KritzelEventHelper.isLeftClick(event)) {
2136
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2137
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2138
- this._store.state.resizeHandleType = this.getHandleType(event);
2143
+ this._core.store.setState('isResizeHandleSelected', this.isHandleSelected(event));
2144
+ this._core.store.setState('isRotationHandleSelected', this.isRotationHandleSelected(event));
2145
+ this._core.store.setState('resizeHandleType', this.getHandleType(event));
2139
2146
  const selectedObject = this.getSelectedObject(event);
2140
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2147
+ const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
2141
2148
  if ((selectedObject === null || isDifferentObject) &&
2142
- this._store.state.selectionGroup &&
2143
- !this._store.state.isResizeHandleSelected &&
2144
- !this._store.state.isRotationHandleSelected) {
2145
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2149
+ this._core.store.state.selectionGroup &&
2150
+ !this._core.store.state.isResizeHandleSelected &&
2151
+ !this._core.store.state.isRotationHandleSelected) {
2152
+ this._core.history.executeCommand(new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup));
2146
2153
  }
2147
2154
  if (selectedObject && selectedObject.isSelected === false && selectedObject?.objects.length === 1 && selectedObject.objects[0].isInteractive) {
2148
2155
  return;
@@ -2152,32 +2159,33 @@ class KritzelSelectionTool extends KritzelBaseTool {
2152
2159
  this.selectionHandler.handlePointerDown(event);
2153
2160
  this.resizeHandler.handlePointerDown(event);
2154
2161
  this.rotationHandler.handlePointerDown(event);
2155
- this._store.rerender();
2162
+ this._core.rerender();
2156
2163
  }
2157
2164
  if (event.pointerType === 'touch') {
2158
- if (this._store.state.isScaling === true) {
2165
+ if (this._core.store.state.isScaling === true) {
2159
2166
  return;
2160
2167
  }
2161
- if (this._store.state.pointers.size === 1) {
2162
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2163
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2164
- this._store.state.resizeHandleType = this.getHandleType(event);
2168
+ if (this._core.store.state.pointers.size === 1) {
2169
+ this._core.store.setState('isResizeHandleSelected', this.isHandleSelected(event));
2170
+ this._core.store.setState('isRotationHandleSelected', this.isRotationHandleSelected(event));
2171
+ this._core.store.setState('resizeHandleType', this.getHandleType(event));
2165
2172
  const selectedObject = this.getSelectedObject(event);
2166
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2167
- if (!this._store.state.selectionGroup && selectedObject) {
2168
- this._store.state.skipContextMenu = true;
2173
+ const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
2174
+ if (!this._core.store.state.selectionGroup && selectedObject) {
2175
+ this._core.store.setState('skipContextMenu', true);
2169
2176
  }
2170
2177
  if ((selectedObject === null || isDifferentObject) &&
2171
- this._store.state.selectionGroup &&
2172
- !this._store.state.isResizeHandleSelected &&
2173
- !this._store.state.isRotationHandleSelected) {
2174
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2178
+ this._core.store.state.selectionGroup &&
2179
+ !this._core.store.state.isResizeHandleSelected &&
2180
+ !this._core.store.state.isRotationHandleSelected) {
2181
+ this._core.history.executeCommand(new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup));
2175
2182
  }
2176
2183
  }
2177
2184
  this.rotationHandler.handlePointerDown(event);
2178
2185
  this.resizeHandler.handlePointerDown(event);
2179
2186
  this.moveHandler.handlePointerDown(event);
2180
2187
  this.selectionHandler.handlePointerDown(event);
2188
+ this._core.rerender();
2181
2189
  }
2182
2190
  }
2183
2191
  handlePointerMove(event) {
@@ -2190,17 +2198,17 @@ class KritzelSelectionTool extends KritzelBaseTool {
2190
2198
  this.selectionHandler.handlePointerMove(event);
2191
2199
  this.resizeHandler.handlePointerMove(event);
2192
2200
  this.rotationHandler.handlePointerMove(event);
2193
- this._store.rerender();
2201
+ this._core.rerender();
2194
2202
  }
2195
2203
  if (event.pointerType === 'touch') {
2196
- if (this._store.state.isScaling === true) {
2204
+ if (this._core.store.state.isScaling === true) {
2197
2205
  return;
2198
2206
  }
2199
2207
  this.rotationHandler.handlePointerMove(event);
2200
2208
  this.resizeHandler.handlePointerMove(event);
2201
2209
  this.moveHandler.handlePointerMove(event);
2202
2210
  this.selectionHandler.handlePointerMove(event);
2203
- this._store.rerender();
2211
+ this._core.rerender();
2204
2212
  }
2205
2213
  }
2206
2214
  handlePointerUp(event) {
@@ -2212,22 +2220,23 @@ class KritzelSelectionTool extends KritzelBaseTool {
2212
2220
  this.selectionHandler.handlePointerUp(event);
2213
2221
  this.resizeHandler.handlePointerUp(event);
2214
2222
  this.rotationHandler.handlePointerUp(event);
2215
- this._store.rerender();
2223
+ this._core.rerender();
2216
2224
  }
2217
2225
  if (event.pointerType === 'touch') {
2218
- if (this._store.state.isScaling === true) {
2226
+ if (this._core.store.state.isScaling === true) {
2219
2227
  return;
2220
2228
  }
2221
2229
  this.rotationHandler.handlePointerUp(event);
2222
2230
  this.resizeHandler.handlePointerUp(event);
2223
2231
  this.moveHandler.handlePointerUp(event);
2224
2232
  this.selectionHandler.handlePointerUp(event);
2233
+ this._core.rerender();
2225
2234
  }
2226
2235
  }
2227
2236
  getSelectedObject(event) {
2228
2237
  const path = event.composedPath().slice(1);
2229
2238
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
2230
- const object = this._store.findObjectById(objectElement?.id);
2239
+ const object = this._core.findObjectById(objectElement?.id);
2231
2240
  if (!object) {
2232
2241
  return null;
2233
2242
  }
@@ -2235,7 +2244,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
2235
2244
  return object;
2236
2245
  }
2237
2246
  else {
2238
- const group = KritzelSelectionGroup.create(this._store);
2247
+ const group = KritzelSelectionGroup.create(this._core);
2239
2248
  group.translateX = 0;
2240
2249
  group.translateY = 0;
2241
2250
  group.addOrRemove(object);
@@ -2243,7 +2252,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
2243
2252
  }
2244
2253
  }
2245
2254
  getHandleType(event) {
2246
- const shadowRoot = this._store.state.host?.shadowRoot;
2255
+ const shadowRoot = this._core.store.state.host?.shadowRoot;
2247
2256
  if (!shadowRoot)
2248
2257
  return;
2249
2258
  const elementAtPoint = shadowRoot.elementFromPoint(event.clientX, event.clientY);
@@ -2251,7 +2260,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
2251
2260
  return handle?.classList[1];
2252
2261
  }
2253
2262
  isHandleSelected(event) {
2254
- const shadowRoot = this._store.state.host?.shadowRoot;
2263
+ const shadowRoot = this._core.store.state.host?.shadowRoot;
2255
2264
  if (!shadowRoot)
2256
2265
  return false;
2257
2266
  const elementAtPoint = shadowRoot.elementFromPoint(event.clientX, event.clientY);
@@ -2263,10 +2272,144 @@ class KritzelSelectionTool extends KritzelBaseTool {
2263
2272
  }
2264
2273
  }
2265
2274
 
2275
+ const DEFAULT_BRUSH_CONFIG = {
2276
+ type: 'pen',
2277
+ color: '#000000',
2278
+ size: 16,
2279
+ palettes: {
2280
+ pen: [
2281
+ '#000000',
2282
+ '#ff5252',
2283
+ '#ffbc00',
2284
+ '#00c853',
2285
+ '#0000FF',
2286
+ '#d500f9',
2287
+ '#fafafa',
2288
+ '#a52714',
2289
+ '#ee8100',
2290
+ '#558b2f',
2291
+ '#01579b',
2292
+ '#8e24aa',
2293
+ '#90a4ae',
2294
+ '#ff4081',
2295
+ '#ff6e40',
2296
+ '#aeea00',
2297
+ '#304ffe',
2298
+ '#7c4dff',
2299
+ '#cfd8dc',
2300
+ '#f8bbd0',
2301
+ '#ffccbc',
2302
+ '#f0f4c3',
2303
+ '#9fa8da',
2304
+ '#d1c4e9',
2305
+ ],
2306
+ highlighter: [
2307
+ '#0000006e',
2308
+ '#ff52526e',
2309
+ '#ffbb006e',
2310
+ '#00c8536e',
2311
+ '#0000FF6e',
2312
+ '#d500f96e',
2313
+ '#fafafa6e',
2314
+ '#a527146e',
2315
+ '#ee81006e',
2316
+ '#558b2f6e',
2317
+ '#01579b6e',
2318
+ '#8e24aa6e',
2319
+ '#90a4ae6e',
2320
+ '#ff40816e',
2321
+ '#ff6e406e',
2322
+ '#aeea006e',
2323
+ '#304ffe6e',
2324
+ '#7c4dff6e',
2325
+ '#cfd8dc6e',
2326
+ '#f8bbd06e',
2327
+ '#ffccbc6e',
2328
+ '#f0f4c36e',
2329
+ '#9fa8da6e',
2330
+ '#d1c4e96e',
2331
+ ],
2332
+ },
2333
+ };
2334
+
2335
+ const DEFAULT_TEXT_CONFIG = {
2336
+ color: '#000000',
2337
+ size: 8,
2338
+ fontFamily: 'Arial',
2339
+ palette: [
2340
+ '#000000',
2341
+ '#ff5252',
2342
+ '#ffbc00',
2343
+ '#00c853',
2344
+ '#0000FF',
2345
+ '#d500f9',
2346
+ '#fafafa',
2347
+ '#a52714',
2348
+ '#ee8100',
2349
+ '#558b2f',
2350
+ '#01579b',
2351
+ '#8e24aa',
2352
+ '#90a4ae',
2353
+ '#ff4081',
2354
+ '#ff6e40',
2355
+ '#aeea00',
2356
+ '#304ffe',
2357
+ '#7c4dff',
2358
+ '#cfd8dc',
2359
+ '#f8bbd0',
2360
+ '#ffccbc',
2361
+ '#f0f4c3',
2362
+ '#9fa8da',
2363
+ '#d1c4e9',
2364
+ ],
2365
+ };
2366
+
2367
+ class KritzelWorkspace {
2368
+ __class__ = 'KritzelWorkspace';
2369
+ id;
2370
+ name;
2371
+ createdAt;
2372
+ updatedAt;
2373
+ viewport;
2374
+ _core;
2375
+ constructor(id, name, viewport = { translateX: 0, translateY: 0, scale: 1 }) {
2376
+ this.id = id;
2377
+ this.name = name;
2378
+ this.createdAt = new Date();
2379
+ this.updatedAt = new Date();
2380
+ this.viewport = viewport;
2381
+ }
2382
+ static create(core, obj) {
2383
+ const workspace = new KritzelWorkspace(obj.id, obj.name, obj.viewport);
2384
+ workspace._core = core;
2385
+ Object.assign(workspace, obj);
2386
+ return workspace;
2387
+ }
2388
+ addObject(obj) {
2389
+ this._core.engine.addObject(obj);
2390
+ }
2391
+ serialize() {
2392
+ return {
2393
+ __class__: this.__class__,
2394
+ id: this.id,
2395
+ name: this.name,
2396
+ createdAt: this.createdAt,
2397
+ updatedAt: this.updatedAt,
2398
+ viewport: this.viewport,
2399
+ };
2400
+ }
2401
+ deserialize(object) {
2402
+ Object.assign(this, object);
2403
+ this.createdAt = new Date(object.createdAt);
2404
+ this.updatedAt = new Date(object.updatedAt);
2405
+ return this;
2406
+ }
2407
+ }
2408
+
2266
2409
  class KritzelReviver {
2267
- _store;
2268
- constructor(store) {
2269
- this._store = store;
2410
+ _core;
2411
+ constructor(core) {
2412
+ this._core = core;
2270
2413
  }
2271
2414
  revive(obj) {
2272
2415
  if (obj && typeof obj === 'object') {
@@ -2274,34 +2417,37 @@ class KritzelReviver {
2274
2417
  let revivedObj;
2275
2418
  switch (obj.__class__) {
2276
2419
  case 'KritzelPath':
2277
- revivedObj = KritzelPath.create(this._store).revive(obj);
2420
+ revivedObj = KritzelPath.create(this._core).deserialize(obj);
2278
2421
  break;
2279
2422
  case 'KritzelText':
2280
- revivedObj = KritzelText.create(this._store, obj.fontSize, obj.fontFamily).revive(obj);
2423
+ revivedObj = KritzelText.create(this._core, obj.fontSize, obj.fontFamily).deserialize(obj);
2281
2424
  break;
2282
2425
  case 'KritzelImage':
2283
- revivedObj = KritzelImage.create(this._store).revive(obj);
2426
+ revivedObj = KritzelImage.create(this._core).deserialize(obj);
2284
2427
  break;
2285
2428
  case 'KritzelCustomElement':
2286
- revivedObj = KritzelCustomElement.create(this._store).revive(obj);
2429
+ revivedObj = KritzelCustomElement.create(this._core).deserialize(obj);
2287
2430
  break;
2288
2431
  case 'KritzelSelectionGroup':
2289
- revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
2432
+ revivedObj = KritzelSelectionGroup.create(this._core).deserialize(obj);
2433
+ break;
2434
+ case 'KritzelWorkspace':
2435
+ revivedObj = KritzelWorkspace.create(this._core, obj).deserialize(obj);
2290
2436
  break;
2291
2437
  case 'KritzelBrushTool':
2292
- revivedObj = new KritzelBrushTool(this._store);
2438
+ revivedObj = new KritzelBrushTool(this._core);
2293
2439
  break;
2294
2440
  case 'KritzelEraserTool':
2295
- revivedObj = new KritzelEraserTool(this._store);
2441
+ revivedObj = new KritzelEraserTool(this._core);
2296
2442
  break;
2297
2443
  case 'KritzelImageTool':
2298
- revivedObj = new KritzelImageTool(this._store);
2444
+ revivedObj = new KritzelImageTool(this._core);
2299
2445
  break;
2300
2446
  case 'KritzelSelectionTool':
2301
- revivedObj = new KritzelSelectionTool(this._store);
2447
+ revivedObj = new KritzelSelectionTool(this._core);
2302
2448
  break;
2303
2449
  case 'KritzelTextTool':
2304
- revivedObj = new KritzelTextTool(this._store);
2450
+ revivedObj = new KritzelTextTool(this._core);
2305
2451
  break;
2306
2452
  default:
2307
2453
  revivedObj = obj;
@@ -2331,12 +2477,12 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2331
2477
  get length() {
2332
2478
  return this.objects.length;
2333
2479
  }
2334
- static create(store) {
2480
+ static create(core) {
2335
2481
  const object = new KritzelSelectionGroup();
2336
- object._store = store;
2482
+ object._core = core;
2337
2483
  object.id = object.generateId();
2338
- object.workspaceId = store.state.activeWorkspace.id;
2339
- object.scale = store.state.scale;
2484
+ object.workspaceId = core.store.state.activeWorkspace.id;
2485
+ object.scale = core.store.state.scale;
2340
2486
  object.zIndex = 99999;
2341
2487
  return object;
2342
2488
  }
@@ -2368,17 +2514,17 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2368
2514
  });
2369
2515
  this.translateX = x;
2370
2516
  this.translateY = y;
2371
- this._store.state.objectsMap.update(this);
2517
+ this._core.store.state.objectsMap.update(this);
2372
2518
  }
2373
2519
  move(startX, startY, endX, endY) {
2374
- const deltaX = (startX - endX) / this._store.state.scale;
2375
- const deltaY = (startY - endY) / this._store.state.scale;
2520
+ const deltaX = (startX - endX) / this._core.store.state.scale;
2521
+ const deltaY = (startY - endY) / this._core.store.state.scale;
2376
2522
  this.translateX += deltaX;
2377
2523
  this.translateY += deltaY;
2378
- this._store.state.objectsMap.update(this);
2524
+ this._core.store.state.objectsMap.update(this);
2379
2525
  this.objects.forEach(obj => {
2380
2526
  obj.move(startX, startY, endX, endY);
2381
- this._store.state.objectsMap.update(obj);
2527
+ this._core.store.state.objectsMap.update(obj);
2382
2528
  });
2383
2529
  this.unchangedObjects.forEach(obj => {
2384
2530
  obj.translateX += deltaX;
@@ -2396,7 +2542,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2396
2542
  const updatedX = child.translateX + deltaX + (child.translateX - this.translateX) * (widthScaleFactor - 1);
2397
2543
  const updatedY = child.translateY + deltaY + (child.translateY - this.translateY) * (heightScaleFactor - 1);
2398
2544
  child.resize(updatedX, updatedY, updatedWidth, updatedHeight);
2399
- this._store.state.objectsMap.update(child);
2545
+ this._core.store.state.objectsMap.update(child);
2400
2546
  });
2401
2547
  this.refreshObjectDimensions();
2402
2548
  this.unchangedObjects = ObjectHelper.clone(this.objects);
@@ -2417,12 +2563,12 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2417
2563
  child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
2418
2564
  child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
2419
2565
  child.rotate(this.objects.length === 1 ? value : value + unchangedChild.rotation);
2420
- this._store.state.objectsMap.update(child);
2566
+ this._core.store.state.objectsMap.update(child);
2421
2567
  });
2422
2568
  }
2423
2569
  copy() {
2424
- const selectionGroup = KritzelSelectionGroup.create(this._store);
2425
- let currentZIndex = this._store.currentZIndex;
2570
+ const selectionGroup = KritzelSelectionGroup.create(this._core);
2571
+ let currentZIndex = this._core.store.currentZIndex;
2426
2572
  this.objects.sort((a, b) => a.zIndex - b.zIndex).forEach(obj => {
2427
2573
  const copiedObject = obj.copy();
2428
2574
  copiedObject.zIndex = currentZIndex;
@@ -2457,7 +2603,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2457
2603
  this.width = (this.maxX - this.minX - this.padding) * this.scale;
2458
2604
  this.height = (this.maxY - this.minY - this.padding) * this.scale;
2459
2605
  }
2460
- this._store.state.objectsMap.update(this);
2606
+ this._core.store.state.objectsMap.update(this);
2461
2607
  }
2462
2608
  getOffsetXToCenter(obj) {
2463
2609
  const objCenterX = obj.translateX + obj.totalWidth / obj.scale / 2;
@@ -2471,7 +2617,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2471
2617
  }
2472
2618
  getUnchangedObject(objectId) {
2473
2619
  const obj = this.unchangedObjects.find(obj => obj.id === objectId);
2474
- const reviver = new KritzelReviver(this._store);
2620
+ const reviver = new KritzelReviver(this._core);
2475
2621
  return reviver.revive(obj);
2476
2622
  }
2477
2623
  }
@@ -2488,15 +2634,15 @@ function _mergeNamespaces$1(e,t){return t.forEach((function(t){t&&"string"!=type
2488
2634
  class KritzelImageTool extends KritzelBaseTool {
2489
2635
  fileInput = null;
2490
2636
  maxCompressionSize = 300;
2491
- constructor(store) {
2492
- super(store);
2637
+ constructor(core) {
2638
+ super(core);
2493
2639
  this.setupFileInput();
2494
2640
  }
2495
2641
  onActivate() {
2496
2642
  this.openFilePicker();
2497
2643
  }
2498
2644
  openFilePicker() {
2499
- if (this._store.isDisabled) {
2645
+ if (this._core.store.isDisabled) {
2500
2646
  return;
2501
2647
  }
2502
2648
  this.fileInput.click();
@@ -2543,134 +2689,27 @@ class KritzelImageTool extends KritzelBaseTool {
2543
2689
  reader.readAsDataURL(file);
2544
2690
  }
2545
2691
  createKritzelImage(img) {
2546
- const image = KritzelImage.create(this._store);
2692
+ const image = KritzelImage.create(this._core);
2547
2693
  const { scaledWidth, scaledHeight } = image.calculateScaledDimensions(img);
2548
2694
  image.src = img.src;
2549
2695
  image.width = scaledWidth;
2550
2696
  image.height = scaledHeight;
2551
- image.zIndex = this._store.currentZIndex;
2697
+ image.zIndex = this._core.store.currentZIndex;
2552
2698
  image.centerInViewport();
2553
2699
  this.addImageToStore(image);
2554
2700
  return image;
2555
2701
  }
2556
2702
  addImageToStore(image) {
2557
- const selectionGroup = KritzelSelectionGroup.create(this._store);
2703
+ const selectionGroup = KritzelSelectionGroup.create(this._core);
2558
2704
  selectionGroup.addOrRemove(image);
2559
2705
  selectionGroup.isSelected = true;
2560
- const addImageCommand = new AddObjectCommand(this._store, this, image);
2561
- const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);
2562
- this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));
2563
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
2706
+ const addImageCommand = new AddObjectCommand(this._core, this, image);
2707
+ const addSelectionGroupCommand = new AddSelectionGroupCommand(this._core, this, selectionGroup);
2708
+ this._core.history.executeCommand(new BatchCommand(this._core, this, [addImageCommand, addSelectionGroupCommand]));
2709
+ this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
2564
2710
  }
2565
2711
  handleCancel() {
2566
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
2567
- }
2568
- }
2569
-
2570
- const DEFAULT_BRUSH_CONFIG = {
2571
- type: 'pen',
2572
- color: '#000000',
2573
- size: 16,
2574
- palettes: {
2575
- pen: [
2576
- '#000000',
2577
- '#ff5252',
2578
- '#ffbc00',
2579
- '#00c853',
2580
- '#0000FF',
2581
- '#d500f9',
2582
- '#fafafa',
2583
- '#a52714',
2584
- '#ee8100',
2585
- '#558b2f',
2586
- '#01579b',
2587
- '#8e24aa',
2588
- '#90a4ae',
2589
- '#ff4081',
2590
- '#ff6e40',
2591
- '#aeea00',
2592
- '#304ffe',
2593
- '#7c4dff',
2594
- '#cfd8dc',
2595
- '#f8bbd0',
2596
- '#ffccbc',
2597
- '#f0f4c3',
2598
- '#9fa8da',
2599
- '#d1c4e9',
2600
- ],
2601
- highlighter: [
2602
- '#0000006e',
2603
- '#ff52526e',
2604
- '#ffbb006e',
2605
- '#00c8536e',
2606
- '#0000FF6e',
2607
- '#d500f96e',
2608
- '#fafafa6e',
2609
- '#a527146e',
2610
- '#ee81006e',
2611
- '#558b2f6e',
2612
- '#01579b6e',
2613
- '#8e24aa6e',
2614
- '#90a4ae6e',
2615
- '#ff40816e',
2616
- '#ff6e406e',
2617
- '#aeea006e',
2618
- '#304ffe6e',
2619
- '#7c4dff6e',
2620
- '#cfd8dc6e',
2621
- '#f8bbd06e',
2622
- '#ffccbc6e',
2623
- '#f0f4c36e',
2624
- '#9fa8da6e',
2625
- '#d1c4e96e',
2626
- ],
2627
- },
2628
- };
2629
-
2630
- const DEFAULT_TEXT_CONFIG = {
2631
- color: '#000000',
2632
- size: 8,
2633
- fontFamily: 'Arial',
2634
- palette: [
2635
- '#000000',
2636
- '#ff5252',
2637
- '#ffbc00',
2638
- '#00c853',
2639
- '#0000FF',
2640
- '#d500f9',
2641
- '#fafafa',
2642
- '#a52714',
2643
- '#ee8100',
2644
- '#558b2f',
2645
- '#01579b',
2646
- '#8e24aa',
2647
- '#90a4ae',
2648
- '#ff4081',
2649
- '#ff6e40',
2650
- '#aeea00',
2651
- '#304ffe',
2652
- '#7c4dff',
2653
- '#cfd8dc',
2654
- '#f8bbd0',
2655
- '#ffccbc',
2656
- '#f0f4c3',
2657
- '#9fa8da',
2658
- '#d1c4e9',
2659
- ],
2660
- };
2661
-
2662
- class KritzelWorkspace {
2663
- id;
2664
- name;
2665
- createdAt;
2666
- updatedAt;
2667
- viewport;
2668
- constructor(id, name, viewport = { translateX: 0, translateY: 0, scale: 1 }) {
2669
- this.id = id;
2670
- this.name = name;
2671
- this.createdAt = new Date();
2672
- this.updatedAt = new Date();
2673
- this.viewport = viewport;
2712
+ this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
2674
2713
  }
2675
2714
  }
2676
2715
 
@@ -2701,6 +2740,6 @@ exports.ObjectHelper = ObjectHelper;
2701
2740
  exports.RemoveObjectCommand = RemoveObjectCommand;
2702
2741
  exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
2703
2742
  exports.UpdateObjectCommand = UpdateObjectCommand;
2704
- //# sourceMappingURL=index-BwINBV6L.js.map
2743
+ //# sourceMappingURL=index-ouFX0OVi.js.map
2705
2744
 
2706
- //# sourceMappingURL=index-BwINBV6L.js.map
2745
+ //# sourceMappingURL=index-ouFX0OVi.js.map