kritzel-react 0.1.30 → 0.1.32

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 (209) hide show
  1. package/dist/kritzel-react/lib/components/stencil-generated/components.js +122 -0
  2. package/dist/kritzel-react/lib/index.js +2 -0
  3. package/dist/kritzel-stencil/src/classes/core/core.class.js +797 -0
  4. package/dist/kritzel-stencil/src/classes/core/reviver.class.js +97 -0
  5. package/dist/kritzel-stencil/src/classes/core/store.class.js +153 -0
  6. package/dist/kritzel-stencil/src/classes/core/viewport.class.js +311 -0
  7. package/dist/kritzel-stencil/src/classes/core/workspace.class.js +34 -0
  8. package/dist/kritzel-stencil/src/classes/handlers/base.handler.js +6 -0
  9. package/dist/kritzel-stencil/src/classes/handlers/context-menu.handler.js +63 -0
  10. package/dist/kritzel-stencil/src/classes/handlers/hover.handler.js +18 -0
  11. package/dist/kritzel-stencil/src/classes/handlers/key.handler.js +76 -0
  12. package/dist/kritzel-stencil/src/classes/handlers/line-handle.handler.js +382 -0
  13. package/dist/kritzel-stencil/src/classes/handlers/move.handler.js +213 -0
  14. package/dist/kritzel-stencil/src/classes/handlers/resize.handler.js +205 -0
  15. package/dist/kritzel-stencil/src/classes/handlers/rotation.handler.js +117 -0
  16. package/dist/kritzel-stencil/src/classes/handlers/selection.handler.js +313 -0
  17. package/dist/kritzel-stencil/src/classes/managers/anchor.manager.js +1056 -0
  18. package/dist/kritzel-stencil/src/classes/managers/cursor.manager.js +117 -0
  19. package/dist/kritzel-stencil/src/classes/managers/theme.manager.js +103 -0
  20. package/dist/kritzel-stencil/src/classes/objects/base-object.class.js +249 -0
  21. package/dist/kritzel-stencil/src/classes/objects/custom-element.class.js +60 -0
  22. package/dist/kritzel-stencil/src/classes/objects/group.class.js +407 -0
  23. package/dist/kritzel-stencil/src/classes/objects/image.class.js +55 -0
  24. package/dist/kritzel-stencil/src/classes/objects/line.class.js +608 -0
  25. package/dist/kritzel-stencil/src/classes/objects/path.class.js +401 -0
  26. package/dist/kritzel-stencil/src/classes/objects/selection-box.class.js +21 -0
  27. package/dist/kritzel-stencil/src/classes/objects/selection-group.class.js +409 -0
  28. package/dist/kritzel-stencil/src/classes/objects/shape.class.js +412 -0
  29. package/dist/kritzel-stencil/src/classes/objects/text.class.js +292 -0
  30. package/dist/kritzel-stencil/src/classes/providers/broadcast-sync-provider.class.js +101 -0
  31. package/dist/kritzel-stencil/src/classes/providers/hocuspocus-sync-provider.class.js +241 -0
  32. package/dist/kritzel-stencil/src/classes/providers/indexeddb-sync-provider.class.js +43 -0
  33. package/dist/kritzel-stencil/src/classes/providers/websocket-sync-provider.class.js +98 -0
  34. package/dist/kritzel-stencil/src/classes/registries/icon-registry.class.js +66 -0
  35. package/dist/kritzel-stencil/src/classes/registries/tool.registry.js +21 -0
  36. package/dist/kritzel-stencil/src/classes/structures/app-state-map.structure.js +212 -0
  37. package/dist/kritzel-stencil/src/classes/structures/object-map.structure.js +414 -0
  38. package/dist/kritzel-stencil/src/classes/structures/quadtree.structure.js +151 -0
  39. package/dist/kritzel-stencil/src/classes/tools/base-tool.class.js +36 -0
  40. package/dist/kritzel-stencil/src/classes/tools/brush-tool.class.js +161 -0
  41. package/dist/kritzel-stencil/src/classes/tools/eraser-tool.class.js +85 -0
  42. package/dist/kritzel-stencil/src/classes/tools/image-tool.class.js +83 -0
  43. package/dist/kritzel-stencil/src/classes/tools/line-tool.class.js +187 -0
  44. package/dist/kritzel-stencil/src/classes/tools/selection-tool.class.js +429 -0
  45. package/dist/kritzel-stencil/src/classes/tools/shape-tool.class.js +196 -0
  46. package/dist/kritzel-stencil/src/classes/tools/text-tool.class.js +100 -0
  47. package/dist/kritzel-stencil/src/components/core/kritzel-engine/kritzel-engine.js +1343 -0
  48. package/dist/kritzel-stencil/src/components/shared/kritzel-brush-style/kritzel-brush-style.js +46 -0
  49. package/dist/kritzel-stencil/src/components/shared/kritzel-dropdown/kritzel-dropdown.js +312 -0
  50. package/dist/kritzel-stencil/src/components/shared/kritzel-font-family/kritzel-font-family.js +60 -0
  51. package/dist/kritzel-stencil/src/components/shared/kritzel-line-endings/kritzel-line-endings.js +105 -0
  52. package/dist/kritzel-stencil/src/components/shared/kritzel-shape-fill/kritzel-shape-fill.js +53 -0
  53. package/dist/kritzel-stencil/src/components/ui/kritzel-context-menu/kritzel-context-menu.js +137 -0
  54. package/dist/kritzel-stencil/src/configs/default-brush-tool.config.js +9 -0
  55. package/dist/kritzel-stencil/src/configs/default-engine-config.js +63 -0
  56. package/dist/kritzel-stencil/src/configs/default-line-tool.config.js +9 -0
  57. package/dist/kritzel-stencil/src/configs/default-sync.config.js +9 -0
  58. package/dist/kritzel-stencil/src/configs/default-text-tool.config.js +7 -0
  59. package/dist/kritzel-stencil/src/constants/color-palette.constants.js +37 -0
  60. package/dist/kritzel-stencil/src/constants/engine.constants.js +2 -0
  61. package/dist/kritzel-stencil/src/enums/event-button.enum.js +6 -0
  62. package/dist/kritzel-stencil/src/enums/handle-type.enum.js +7 -0
  63. package/dist/kritzel-stencil/src/enums/shape-type.enum.js +6 -0
  64. package/dist/kritzel-stencil/src/helpers/class.helper.js +5 -0
  65. package/dist/kritzel-stencil/src/helpers/color.helper.js +106 -0
  66. package/dist/kritzel-stencil/src/helpers/cursor.helper.js +57 -0
  67. package/dist/kritzel-stencil/src/helpers/devices.helper.js +28 -0
  68. package/dist/kritzel-stencil/src/helpers/event.helper.js +58 -0
  69. package/dist/kritzel-stencil/src/helpers/geometry.helper.js +149 -0
  70. package/dist/kritzel-stencil/src/helpers/keyboard.helper.js +51 -0
  71. package/dist/kritzel-stencil/src/helpers/math.helper.js +5 -0
  72. package/dist/kritzel-stencil/src/helpers/object.helper.js +11 -0
  73. package/dist/kritzel-stencil/src/helpers/theme.helper.js +69 -0
  74. package/dist/kritzel-stencil/src/index.js +41 -0
  75. package/dist/kritzel-stencil/src/interfaces/anchor.interface.js +1 -0
  76. package/dist/kritzel-stencil/src/interfaces/arrow-head.interface.js +1 -0
  77. package/dist/kritzel-stencil/src/interfaces/bounding-box.interface.js +1 -0
  78. package/dist/kritzel-stencil/src/interfaces/clonable.interface.js +1 -0
  79. package/dist/kritzel-stencil/src/interfaces/context-menu-item.interface.js +1 -0
  80. package/dist/kritzel-stencil/src/interfaces/debug-info.interface.js +1 -0
  81. package/dist/kritzel-stencil/src/interfaces/dialog.interface.js +1 -0
  82. package/dist/kritzel-stencil/src/interfaces/displayable-shortcut.interface.js +1 -0
  83. package/dist/kritzel-stencil/src/interfaces/engine-state.interface.js +1 -0
  84. package/dist/kritzel-stencil/src/interfaces/line-options.interface.js +1 -0
  85. package/dist/kritzel-stencil/src/interfaces/master-detail.interface.js +1 -0
  86. package/dist/kritzel-stencil/src/interfaces/menu-item.interface.js +1 -0
  87. package/dist/kritzel-stencil/src/interfaces/object.interface.js +1 -0
  88. package/dist/kritzel-stencil/src/interfaces/path-options.interface.js +1 -0
  89. package/dist/kritzel-stencil/src/interfaces/point.interface.js +1 -0
  90. package/dist/kritzel-stencil/src/interfaces/polygon.interface.js +1 -0
  91. package/dist/kritzel-stencil/src/interfaces/serializable.interface.js +1 -0
  92. package/dist/kritzel-stencil/src/interfaces/settings.interface.js +1 -0
  93. package/dist/kritzel-stencil/src/interfaces/shortcut.interface.js +1 -0
  94. package/dist/kritzel-stencil/src/interfaces/sync-config.interface.js +1 -0
  95. package/dist/kritzel-stencil/src/interfaces/sync-provider.interface.js +1 -0
  96. package/dist/kritzel-stencil/src/interfaces/theme.interface.js +1 -0
  97. package/dist/kritzel-stencil/src/interfaces/tool-config.interface.js +1 -0
  98. package/dist/kritzel-stencil/src/interfaces/tool.interface.js +1 -0
  99. package/dist/kritzel-stencil/src/interfaces/toolbar-control.interface.js +1 -0
  100. package/dist/kritzel-stencil/src/interfaces/undo-state.interface.js +1 -0
  101. package/dist/kritzel-stencil/src/themes/dark-theme.js +198 -0
  102. package/dist/kritzel-stencil/src/themes/light-theme.js +199 -0
  103. package/dist/kritzel-stencil/src/types/shortcut.type.js +1 -0
  104. package/dist/kritzel-stencil/src/types/state.types.js +1 -0
  105. package/dist/types/kritzel-react/lib/components/stencil-generated/components.d.ts +74 -0
  106. package/dist/types/kritzel-react/lib/index.d.ts +2 -0
  107. package/dist/types/kritzel-stencil/src/classes/core/core.class.d.ts +101 -0
  108. package/dist/types/kritzel-stencil/src/classes/core/reviver.class.d.ts +6 -0
  109. package/dist/types/kritzel-stencil/src/classes/core/store.class.d.ts +53 -0
  110. package/dist/types/kritzel-stencil/src/classes/core/viewport.class.d.ts +48 -0
  111. package/dist/types/kritzel-stencil/src/classes/core/workspace.class.d.ts +24 -0
  112. package/dist/types/kritzel-stencil/src/classes/handlers/base.handler.d.ts +5 -0
  113. package/dist/types/kritzel-stencil/src/classes/handlers/context-menu.handler.d.ts +8 -0
  114. package/dist/types/kritzel-stencil/src/classes/handlers/hover.handler.d.ts +6 -0
  115. package/dist/types/kritzel-stencil/src/classes/handlers/key.handler.d.ts +11 -0
  116. package/dist/types/kritzel-stencil/src/classes/handlers/line-handle.handler.d.ts +34 -0
  117. package/dist/types/kritzel-stencil/src/classes/handlers/move.handler.d.ts +29 -0
  118. package/dist/types/kritzel-stencil/src/classes/handlers/resize.handler.d.ts +24 -0
  119. package/dist/types/kritzel-stencil/src/classes/handlers/rotation.handler.d.ts +12 -0
  120. package/dist/types/kritzel-stencil/src/classes/handlers/selection.handler.d.ts +27 -0
  121. package/dist/types/kritzel-stencil/src/classes/managers/anchor.manager.d.ts +180 -0
  122. package/dist/types/kritzel-stencil/src/classes/managers/cursor.manager.d.ts +43 -0
  123. package/dist/types/kritzel-stencil/src/classes/managers/theme.manager.d.ts +56 -0
  124. package/dist/types/kritzel-stencil/src/classes/objects/base-object.class.d.ts +76 -0
  125. package/dist/types/kritzel-stencil/src/classes/objects/custom-element.class.d.ts +26 -0
  126. package/dist/types/kritzel-stencil/src/classes/objects/group.class.d.ts +97 -0
  127. package/dist/types/kritzel-stencil/src/classes/objects/image.class.d.ts +17 -0
  128. package/dist/types/kritzel-stencil/src/classes/objects/line.class.d.ts +101 -0
  129. package/dist/types/kritzel-stencil/src/classes/objects/path.class.d.ts +62 -0
  130. package/dist/types/kritzel-stencil/src/classes/objects/selection-box.class.d.ts +6 -0
  131. package/dist/types/kritzel-stencil/src/classes/objects/selection-group.class.d.ts +67 -0
  132. package/dist/types/kritzel-stencil/src/classes/objects/shape.class.d.ts +124 -0
  133. package/dist/types/kritzel-stencil/src/classes/objects/text.class.d.ts +56 -0
  134. package/dist/types/kritzel-stencil/src/classes/providers/broadcast-sync-provider.class.d.ts +18 -0
  135. package/dist/types/kritzel-stencil/src/classes/providers/hocuspocus-sync-provider.class.d.ts +120 -0
  136. package/dist/types/kritzel-stencil/src/classes/providers/indexeddb-sync-provider.class.d.ts +22 -0
  137. package/dist/types/kritzel-stencil/src/classes/providers/websocket-sync-provider.class.d.ts +52 -0
  138. package/dist/types/kritzel-stencil/src/classes/registries/icon-registry.class.d.ts +9 -0
  139. package/dist/types/kritzel-stencil/src/classes/registries/tool.registry.d.ts +8 -0
  140. package/dist/types/kritzel-stencil/src/classes/structures/app-state-map.structure.d.ts +31 -0
  141. package/dist/types/kritzel-stencil/src/classes/structures/object-map.structure.d.ts +63 -0
  142. package/dist/types/kritzel-stencil/src/classes/structures/quadtree.structure.d.ts +36 -0
  143. package/dist/types/kritzel-stencil/src/classes/tools/base-tool.class.d.ts +20 -0
  144. package/dist/types/kritzel-stencil/src/classes/tools/brush-tool.class.d.ts +14 -0
  145. package/dist/types/kritzel-stencil/src/classes/tools/eraser-tool.class.d.ts +9 -0
  146. package/dist/types/kritzel-stencil/src/classes/tools/image-tool.class.d.ts +15 -0
  147. package/dist/types/kritzel-stencil/src/classes/tools/line-tool.class.d.ts +19 -0
  148. package/dist/types/kritzel-stencil/src/classes/tools/selection-tool.class.d.ts +54 -0
  149. package/dist/types/kritzel-stencil/src/classes/tools/shape-tool.class.d.ts +39 -0
  150. package/dist/types/kritzel-stencil/src/classes/tools/text-tool.class.d.ts +13 -0
  151. package/dist/types/kritzel-stencil/src/components/core/kritzel-engine/kritzel-engine.d.ts +111 -0
  152. package/dist/types/kritzel-stencil/src/components/shared/kritzel-brush-style/kritzel-brush-style.d.ts +11 -0
  153. package/dist/types/kritzel-stencil/src/components/shared/kritzel-dropdown/kritzel-dropdown.d.ts +46 -0
  154. package/dist/types/kritzel-stencil/src/components/shared/kritzel-font-family/kritzel-font-family.d.ts +13 -0
  155. package/dist/types/kritzel-stencil/src/components/shared/kritzel-line-endings/kritzel-line-endings.d.ts +21 -0
  156. package/dist/types/kritzel-stencil/src/components/shared/kritzel-shape-fill/kritzel-shape-fill.d.ts +10 -0
  157. package/dist/types/kritzel-stencil/src/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +21 -0
  158. package/dist/types/kritzel-stencil/src/configs/default-brush-tool.config.d.ts +2 -0
  159. package/dist/types/kritzel-stencil/src/configs/default-engine-config.d.ts +2 -0
  160. package/dist/types/kritzel-stencil/src/configs/default-line-tool.config.d.ts +2 -0
  161. package/dist/types/kritzel-stencil/src/configs/default-sync.config.d.ts +5 -0
  162. package/dist/types/kritzel-stencil/src/configs/default-text-tool.config.d.ts +2 -0
  163. package/dist/types/kritzel-stencil/src/constants/color-palette.constants.d.ts +29 -0
  164. package/dist/types/kritzel-stencil/src/constants/engine.constants.d.ts +2 -0
  165. package/dist/types/kritzel-stencil/src/enums/event-button.enum.d.ts +5 -0
  166. package/dist/types/kritzel-stencil/src/enums/handle-type.enum.d.ts +6 -0
  167. package/dist/types/kritzel-stencil/src/enums/shape-type.enum.d.ts +5 -0
  168. package/dist/types/kritzel-stencil/src/helpers/class.helper.d.ts +3 -0
  169. package/dist/types/kritzel-stencil/src/helpers/color.helper.d.ts +33 -0
  170. package/dist/types/kritzel-stencil/src/helpers/cursor.helper.d.ts +22 -0
  171. package/dist/types/kritzel-stencil/src/helpers/devices.helper.d.ts +8 -0
  172. package/dist/types/kritzel-stencil/src/helpers/event.helper.d.ts +6 -0
  173. package/dist/types/kritzel-stencil/src/helpers/geometry.helper.d.ts +38 -0
  174. package/dist/types/kritzel-stencil/src/helpers/keyboard.helper.d.ts +6 -0
  175. package/dist/types/kritzel-stencil/src/helpers/math.helper.d.ts +3 -0
  176. package/dist/types/kritzel-stencil/src/helpers/object.helper.d.ts +4 -0
  177. package/dist/types/kritzel-stencil/src/helpers/theme.helper.d.ts +41 -0
  178. package/dist/types/kritzel-stencil/src/index.d.ts +42 -0
  179. package/dist/types/kritzel-stencil/src/interfaces/anchor.interface.d.ts +137 -0
  180. package/dist/types/kritzel-stencil/src/interfaces/arrow-head.interface.d.ts +27 -0
  181. package/dist/types/kritzel-stencil/src/interfaces/bounding-box.interface.d.ts +8 -0
  182. package/dist/types/kritzel-stencil/src/interfaces/clonable.interface.d.ts +3 -0
  183. package/dist/types/kritzel-stencil/src/interfaces/context-menu-item.interface.d.ts +17 -0
  184. package/dist/types/kritzel-stencil/src/interfaces/debug-info.interface.d.ts +4 -0
  185. package/dist/types/kritzel-stencil/src/interfaces/dialog.interface.d.ts +4 -0
  186. package/dist/types/kritzel-stencil/src/interfaces/displayable-shortcut.interface.d.ts +5 -0
  187. package/dist/types/kritzel-stencil/src/interfaces/engine-state.interface.d.ts +73 -0
  188. package/dist/types/kritzel-stencil/src/interfaces/line-options.interface.d.ts +23 -0
  189. package/dist/types/kritzel-stencil/src/interfaces/master-detail.interface.d.ts +14 -0
  190. package/dist/types/kritzel-stencil/src/interfaces/menu-item.interface.d.ts +24 -0
  191. package/dist/types/kritzel-stencil/src/interfaces/object.interface.d.ts +53 -0
  192. package/dist/types/kritzel-stencil/src/interfaces/path-options.interface.d.ts +11 -0
  193. package/dist/types/kritzel-stencil/src/interfaces/point.interface.d.ts +4 -0
  194. package/dist/types/kritzel-stencil/src/interfaces/polygon.interface.d.ts +7 -0
  195. package/dist/types/kritzel-stencil/src/interfaces/serializable.interface.d.ts +5 -0
  196. package/dist/types/kritzel-stencil/src/interfaces/settings.interface.d.ts +11 -0
  197. package/dist/types/kritzel-stencil/src/interfaces/shortcut.interface.d.ts +10 -0
  198. package/dist/types/kritzel-stencil/src/interfaces/sync-config.interface.d.ts +22 -0
  199. package/dist/types/kritzel-stencil/src/interfaces/sync-provider.interface.d.ts +29 -0
  200. package/dist/types/kritzel-stencil/src/interfaces/theme.interface.d.ts +330 -0
  201. package/dist/types/kritzel-stencil/src/interfaces/tool-config.interface.d.ts +26 -0
  202. package/dist/types/kritzel-stencil/src/interfaces/tool.interface.d.ts +7 -0
  203. package/dist/types/kritzel-stencil/src/interfaces/toolbar-control.interface.d.ts +58 -0
  204. package/dist/types/kritzel-stencil/src/interfaces/undo-state.interface.d.ts +6 -0
  205. package/dist/types/kritzel-stencil/src/themes/dark-theme.d.ts +5 -0
  206. package/dist/types/kritzel-stencil/src/themes/light-theme.d.ts +5 -0
  207. package/dist/types/kritzel-stencil/src/types/shortcut.type.d.ts +1 -0
  208. package/dist/types/kritzel-stencil/src/types/state.types.d.ts +3 -0
  209. package/package.json +2 -2
@@ -0,0 +1,27 @@
1
+ import { KritzelBaseHandler } from './base.handler';
2
+ import { KritzelCore } from '../core/core.class';
3
+ export declare class KritzelSelectionHandler extends KritzelBaseHandler {
4
+ startX: number;
5
+ startY: number;
6
+ touchStartX: number;
7
+ touchStartY: number;
8
+ touchStartTimeout: any;
9
+ private _previouslySelectedObjects;
10
+ get isSelectionClick(): boolean | null;
11
+ get isSelectionDrag(): boolean | null;
12
+ constructor(core: KritzelCore);
13
+ handlePointerDown(event: PointerEvent): void;
14
+ handlePointerMove(event: PointerEvent): void;
15
+ handlePointerUp(event: PointerEvent): void;
16
+ private removeSelectionBox;
17
+ private startMouseSelection;
18
+ private startTouchSelection;
19
+ private updateMouseSelection;
20
+ private updateTouchSelection;
21
+ private updateSelectedObjects;
22
+ private handleSelectionClick;
23
+ private getTopmostHitObject;
24
+ private clearSelectionPreview;
25
+ private addObjectToSelectionGroup;
26
+ private addSelectedObjectsToSelectionGroup;
27
+ }
@@ -0,0 +1,180 @@
1
+ import { AnchorIndexEntry, AnchorLinesRenderData, AnchorVisualization, LineAnchor, SnapCandidate, SnapIndicatorRenderData, SnapTarget } from '../../interfaces/anchor.interface';
2
+ import { KritzelCore } from '../core/core.class';
3
+ import { KritzelLine } from '../objects/line.class';
4
+ import { KritzelBaseObject } from '../objects/base-object.class';
5
+ type AnchorClipInfo = {
6
+ localX: number;
7
+ localY: number;
8
+ worldX: number;
9
+ worldY: number;
10
+ t?: number;
11
+ };
12
+ /**
13
+ * Manages anchor connections between line endpoints and other objects.
14
+ * Maintains a runtime index for efficient reverse lookups and handles
15
+ * snap detection during line endpoint dragging.
16
+ */
17
+ export declare class KritzelAnchorManager {
18
+ private readonly _core;
19
+ /**
20
+ * Runtime index mapping objectId to the lines anchored to it.
21
+ * This is derived from the anchor properties on lines and rebuilt as needed.
22
+ */
23
+ private readonly _anchorIndex;
24
+ constructor(core: KritzelCore);
25
+ /**
26
+ * Sets an anchor from a line endpoint to a target object's center.
27
+ * Updates both the line's anchor property and the internal index.
28
+ */
29
+ setAnchor(lineId: string, endpoint: 'start' | 'end', targetObjectId: string): void;
30
+ /**
31
+ * Removes an anchor from a line endpoint.
32
+ * Updates both the line's anchor property and the internal index.
33
+ */
34
+ removeAnchor(lineId: string, endpoint: 'start' | 'end'): void;
35
+ /**
36
+ * Gets the anchor for a specific line endpoint.
37
+ */
38
+ getAnchor(lineId: string, endpoint: 'start' | 'end'): LineAnchor | null;
39
+ /**
40
+ * Gets all lines that have an endpoint anchored to the specified object.
41
+ */
42
+ getLinesAnchoredTo(objectId: string): AnchorIndexEntry[];
43
+ /**
44
+ * Updates all line endpoints that are anchored to the specified object.
45
+ * Should be called when an object moves.
46
+ */
47
+ updateAnchorsForObject(objectId: string): void;
48
+ /**
49
+ * Snaps a line endpoint to an object's center.
50
+ */
51
+ private snapEndpointToObject;
52
+ /**
53
+ * Converts world coordinates to a line's local coordinate system.
54
+ */
55
+ private worldToLineLocal;
56
+ /**
57
+ * Finds the nearest object that can be snapped to within the snap threshold.
58
+ * Returns null if no suitable snap target is found.
59
+ *
60
+ * @param worldX - X coordinate in world space
61
+ * @param worldY - Y coordinate in world space
62
+ * @param excludeLineId - ID of the line being edited (to exclude from snap targets)
63
+ * @param otherEndpointAnchorId - ID of object anchored to the other endpoint (to prevent same-object anchoring)
64
+ */
65
+ findSnapTarget(worldX: number, worldY: number, excludeLineId: string, otherEndpointAnchorId?: string): SnapTarget | null;
66
+ /**
67
+ * Sets the current snap candidate for visual feedback.
68
+ */
69
+ setSnapCandidate(candidate: SnapCandidate | null): void;
70
+ /**
71
+ * Gets the current snap candidate.
72
+ */
73
+ getSnapCandidate(): SnapCandidate | null;
74
+ /**
75
+ * Clears the snap candidate.
76
+ */
77
+ clearSnapCandidate(): void;
78
+ /**
79
+ * Gets render data for anchor lines visualization.
80
+ * Returns null if there's no selected line with anchors or if snap is in progress.
81
+ */
82
+ getAnchorLinesRenderData(): AnchorLinesRenderData | null;
83
+ /**
84
+ * Gets render data for snap indicator visualization.
85
+ * Returns null if there's no snap candidate.
86
+ */
87
+ getSnapIndicatorRenderData(): SnapIndicatorRenderData | null;
88
+ /**
89
+ * Handles cleanup when an object is deleted.
90
+ * Detaches all lines that were anchored to the deleted object.
91
+ */
92
+ handleObjectDeleted(objectId: string): void;
93
+ /**
94
+ * Handles cleanup when a line is deleted.
95
+ * Removes all anchor index entries for the line.
96
+ */
97
+ handleLineDeleted(lineId: string): void;
98
+ /**
99
+ * Rebuilds the anchor index from all lines in the object map.
100
+ * Should be called after loading/deserializing objects.
101
+ */
102
+ rebuildIndex(): void;
103
+ /**
104
+ * Adds an entry to the anchor index.
105
+ */
106
+ private addToIndex;
107
+ /**
108
+ * Removes an entry from the anchor index.
109
+ */
110
+ private removeFromIndex;
111
+ /**
112
+ * Gets a line by its ID.
113
+ */
114
+ private getLineById;
115
+ /**
116
+ * Gets an object by its ID.
117
+ */
118
+ private getObjectById;
119
+ findAnchorTarget(line: KritzelLine, endpoint: 'start' | 'end'): KritzelBaseObject<Element> | null;
120
+ /**
121
+ * Computes anchor visualization data for a line with anchors.
122
+ * Returns edge intersection points for rendering dashed lines from edge to center.
123
+ */
124
+ computeAnchorVisualization(line: KritzelLine, endpoint: 'start' | 'end'): AnchorVisualization | null;
125
+ /**
126
+ * Computes a clipped line path that stops at anchor edges instead of going to anchor centers.
127
+ * When arrows are present on anchored ends, the line is shortened so the arrow tip appears at the edge.
128
+ * Returns the SVG path 'd' attribute string, or the original path if no clipping is needed.
129
+ * @param line The line object
130
+ * @param offsetByViewBox If true, subtracts line.x and line.y from coordinates (for selection UI)
131
+ */
132
+ computeClippedLinePath(line: KritzelLine, offsetByViewBox?: boolean): string;
133
+ computeAnchorClipInfo(line: KritzelLine, endpoint: 'start' | 'end', targetObject: KritzelBaseObject<Element>): AnchorClipInfo | null;
134
+ private computeStraightClipInfo;
135
+ private computeCurvedClipInfo;
136
+ private findCurveExitPoint;
137
+ /**
138
+ * Finds the exit point for a curved line going to a Path object.
139
+ * Uses distance-to-stroke sampling instead of polygon containment.
140
+ */
141
+ private findCurveExitPointForPath;
142
+ private refineCurveExitParameterForPath;
143
+ private getPathAdjustedPoints;
144
+ private computePathAdjustedPoints;
145
+ private isPointInPathStroke;
146
+ private pointToSegmentDistance;
147
+ private refineCurveExitParameter;
148
+ private approximateParameterForWorldPoint;
149
+ private evaluateLineAtT;
150
+ private evaluateDerivativeSpeedAtT;
151
+ private extractQuadraticSegment;
152
+ private splitQuadraticSegment;
153
+ private lerpPoint;
154
+ private buildAnchorPath;
155
+ private buildWorldQuadraticPath;
156
+ private getPolygonPoints;
157
+ /**
158
+ * Gets the custom clip polygon for an object if it has one.
159
+ * Returns null for objects that should use the default rotatedPolygon.
160
+ */
161
+ private getClipPolygonForObject;
162
+ /**
163
+ * Gets the clip point for a Path object (stroke edge intersection).
164
+ * Returns null if the object is not a Path or no intersection found.
165
+ */
166
+ private getPathClipPoint;
167
+ /**
168
+ * Converts local line coordinates to world coordinates.
169
+ */
170
+ private lineLocalToWorld;
171
+ /**
172
+ * Converts world coordinates to line's local SVG coordinates.
173
+ */
174
+ private lineWorldToLocal;
175
+ /**
176
+ * Checks if an object can be used as an anchor target.
177
+ */
178
+ private isAnchorable;
179
+ }
180
+ export {};
@@ -0,0 +1,43 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ /**
3
+ * Manages cursor state and updates across the application.
4
+ * Handles cursor changes based on handle hovers, tool states, and interactions.
5
+ */
6
+ export declare class KritzelCursorManager {
7
+ private readonly _core;
8
+ private _targetElement;
9
+ private _shadowRoot;
10
+ constructor(core: KritzelCore);
11
+ /**
12
+ * Sets the target element where cursor styles will be applied.
13
+ * Also sets the pointer cursor CSS variable for child components.
14
+ */
15
+ setTargetElement(element: HTMLElement | null): void;
16
+ /**
17
+ * Gets the current cursor target element.
18
+ */
19
+ getTargetElement(): HTMLElement | null;
20
+ /**
21
+ * Sets the shadow root for element detection.
22
+ */
23
+ setShadowRoot(shadowRoot: ShadowRoot): void;
24
+ /**
25
+ * Resets cursor to default state.
26
+ * Should be called when all pointers are released.
27
+ */
28
+ resetToDefault(): void;
29
+ /**
30
+ * Detects handle hover states using elementsFromPoint() to work with overlapped elements.
31
+ * This approach finds all elements at the pointer position instead of relying on pointerenter/pointerleave.
32
+ */
33
+ updateHoverState(ev: PointerEvent): void;
34
+ /**
35
+ * Applies the current cursor state to the target element.
36
+ * Should be called in the render loop.
37
+ */
38
+ applyCursor(): void;
39
+ /**
40
+ * Cleans up cursor state when the component is disconnected.
41
+ */
42
+ cleanup(): void;
43
+ }
@@ -0,0 +1,56 @@
1
+ import { KritzelTheme, ThemeName } from '../../interfaces/theme.interface';
2
+ import { KritzelCore } from '../core/core.class';
3
+ /**
4
+ * Manages theme state and application across the Kritzel editor.
5
+ * Handles theme persistence, retrieval, and CSS variable application.
6
+ */
7
+ export declare class KritzelThemeManager {
8
+ private readonly _core;
9
+ private _currentTheme;
10
+ private _targetElement;
11
+ constructor(core: KritzelCore);
12
+ /**
13
+ * Gets the current active theme name.
14
+ */
15
+ get currentTheme(): ThemeName;
16
+ /**
17
+ * Sets the target element where theme CSS variables will be applied.
18
+ */
19
+ setTargetElement(element: HTMLElement | null): void;
20
+ /**
21
+ * Gets the current target element.
22
+ */
23
+ getTargetElement(): HTMLElement | null;
24
+ /**
25
+ * Gets the theme object by name.
26
+ */
27
+ getThemeByName(themeName: ThemeName): KritzelTheme;
28
+ /**
29
+ * Gets the stored theme name from localStorage.
30
+ * Can be called statically without a manager instance.
31
+ * @returns The stored theme name, or 'light' as default
32
+ */
33
+ static getStoredTheme(): ThemeName;
34
+ /**
35
+ * Saves the theme name to localStorage.
36
+ */
37
+ saveTheme(themeName: ThemeName): void;
38
+ /**
39
+ * Sets the current theme, saves it to storage, and applies it to the target element.
40
+ */
41
+ setTheme(themeName: ThemeName): void;
42
+ /**
43
+ * Checks if the current theme is dark.
44
+ */
45
+ isDarkTheme(): boolean;
46
+ /**
47
+ * Applies a theme to the target element by setting CSS custom properties.
48
+ * Uses the generic theme utility to automatically derive CSS variable names
49
+ * from the theme interface structure.
50
+ */
51
+ applyTheme(themeName: ThemeName): void;
52
+ /**
53
+ * Cleans up theme manager state.
54
+ */
55
+ cleanup(): void;
56
+ }
@@ -0,0 +1,76 @@
1
+ import { KritzelBoundingBox } from '../../interfaces/bounding-box.interface';
2
+ import { KritzelObject } from '../../interfaces/object.interface';
3
+ import { KritzelPolygon } from '../../interfaces/polygon.interface';
4
+ import { KritzelSerializable } from '../../interfaces/serializable.interface';
5
+ import { KritzelCore } from '../core/core.class';
6
+ import { KritzelClonable } from '../../interfaces/clonable.interface';
7
+ import { ThemeAwareColor } from '../../constants/color-palette.constants';
8
+ export declare class KritzelBaseObject<T extends Element = HTMLElement | SVGElement> implements KritzelObject<T>, KritzelSerializable, KritzelClonable<KritzelBaseObject<T>> {
9
+ __class__: string;
10
+ _core: KritzelCore;
11
+ _elementRef: T;
12
+ id: string;
13
+ workspaceId: string;
14
+ x: number;
15
+ y: number;
16
+ translateX: number;
17
+ translateY: number;
18
+ height: number;
19
+ width: number;
20
+ backgroundColor?: ThemeAwareColor;
21
+ borderColor?: ThemeAwareColor;
22
+ borderWidth: number;
23
+ opacity: number;
24
+ padding: number;
25
+ scale: number;
26
+ resizing: boolean;
27
+ rotation: number;
28
+ markedForRemoval: boolean;
29
+ zIndex: number;
30
+ isVisible: boolean;
31
+ isSelected: boolean;
32
+ isHovered: boolean;
33
+ isMounted: boolean;
34
+ isEditable: boolean;
35
+ isInteractive: boolean;
36
+ isDebugInfoVisible: boolean;
37
+ get totalWidth(): number;
38
+ get totalHeight(): number;
39
+ set elementRef(element: T);
40
+ get elementRef(): T;
41
+ get boundingBox(): KritzelBoundingBox;
42
+ get rotatedBoundingBox(): KritzelBoundingBox;
43
+ get rotatedPolygon(): KritzelPolygon;
44
+ get minXRotated(): number;
45
+ get minYRotated(): number;
46
+ get maxXRotated(): number;
47
+ get maxYRotated(): number;
48
+ get transformationMatrix(): string;
49
+ get rotationDegrees(): number;
50
+ get centerX(): number;
51
+ get centerY(): number;
52
+ constructor();
53
+ static create(core: KritzelCore): KritzelBaseObject<Element>;
54
+ mount(element: T): void;
55
+ generateId(): string;
56
+ isInViewport(): boolean;
57
+ centerInViewport(): void;
58
+ update(): void;
59
+ move(startX: number, startY: number, endX: number, endY: number): void;
60
+ resize(x: number, y: number, width: number, height: number): void;
61
+ rotate(value: number): void;
62
+ clone(): KritzelBaseObject<T>;
63
+ copy(): KritzelBaseObject<T>;
64
+ serialize(): any;
65
+ deserialize<T>(object: any): T;
66
+ isClass<T extends KritzelBaseObject>(this: T, className: string): this is T;
67
+ edit(_event?: PointerEvent): void;
68
+ /**
69
+ * Called after properties are updated via updateObject.
70
+ * Override in subclasses to perform custom logic when specific properties change.
71
+ */
72
+ onAfterUpdate(_changedProperties: string[]): void;
73
+ hitTest(_x: number, _y: number): boolean;
74
+ hitTestPolygon(polygon: KritzelPolygon): boolean;
75
+ updatePosition(x: number, y: number): void;
76
+ }
@@ -0,0 +1,26 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ export declare class KritzelCustomElement extends KritzelBaseObject<HTMLElement> {
4
+ __class__: string;
5
+ element: HTMLElement;
6
+ isInteractive: boolean;
7
+ constructor(config?: {
8
+ element: HTMLElement;
9
+ translateX?: number;
10
+ translateY?: number;
11
+ scale?: number;
12
+ height?: number;
13
+ width?: number;
14
+ });
15
+ static create(core: KritzelCore, config?: {
16
+ element: HTMLElement;
17
+ translateX?: number;
18
+ translateY?: number;
19
+ scale?: number;
20
+ height?: number;
21
+ width?: number;
22
+ }): KritzelBaseObject<Element>;
23
+ mount(element: HTMLElement): void;
24
+ resize(x: number, y: number, width: number, height: number): void;
25
+ copy(): KritzelCustomElement;
26
+ }
@@ -0,0 +1,97 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ import { KritzelPolygon } from '../../interfaces/polygon.interface';
4
+ /**
5
+ * KritzelGroup represents a permanent grouping of objects that act as a single unit.
6
+ *
7
+ * Unlike KritzelSelectionGroup (which is ephemeral and used for temporary multi-selection),
8
+ * KritzelGroup is persisted and saved with the workspace. Grouped objects move, resize,
9
+ * rotate, copy, and delete together as one unit.
10
+ *
11
+ * Key features:
12
+ * - Supports nested groups (groups can contain other groups)
13
+ * - Clicking any child selects the entire group
14
+ * - Can be ungrouped to restore children to top-level objects
15
+ */
16
+ export declare class KritzelGroup extends KritzelBaseObject<HTMLElement> {
17
+ __class__: string;
18
+ /**
19
+ * IDs of child objects within this group.
20
+ * Children can be any KritzelBaseObject, including other KritzelGroups for nesting.
21
+ */
22
+ childIds: string[];
23
+ /**
24
+ * Snapshots of child states for transformation operations (resize, rotate).
25
+ * Similar pattern to KritzelSelectionGroup.
26
+ */
27
+ private unchangedChildSnapshots;
28
+ private snapshotRotation;
29
+ private snapshotTranslateX;
30
+ private snapshotTranslateY;
31
+ private snapshotTotalWidth;
32
+ private snapshotTotalHeight;
33
+ private snapshotScale;
34
+ /**
35
+ * Retrieves the actual child objects from the store by their IDs.
36
+ */
37
+ get children(): KritzelBaseObject<any>[];
38
+ /**
39
+ * Returns the number of children in this group.
40
+ */
41
+ get length(): number;
42
+ /**
43
+ * Creates a new empty KritzelGroup.
44
+ */
45
+ static create(core: KritzelCore): KritzelGroup;
46
+ /**
47
+ * Creates a KritzelGroup from an array of objects.
48
+ * The objects are added as children and their bounding box is calculated.
49
+ */
50
+ static createFromObjects(core: KritzelCore, objects: KritzelBaseObject<any>[]): KritzelGroup;
51
+ /**
52
+ * Finds the parent KritzelGroup that contains the given object as a child.
53
+ * Returns null if the object is not a child of any group.
54
+ */
55
+ static findParentGroup(core: KritzelCore, objectId: string): KritzelGroup | null;
56
+ /**
57
+ * Adds a child object to this group.
58
+ */
59
+ addChild(object: KritzelBaseObject<any>): void;
60
+ /**
61
+ * Removes a child object from this group.
62
+ */
63
+ removeChild(objectId: string): void;
64
+ /**
65
+ * Ungroups this group, returning all children to top-level objects.
66
+ * The group itself should be removed after calling this.
67
+ */
68
+ ungroup(): KritzelBaseObject<any>[];
69
+ /**
70
+ * Finalizes the group after children have been positioned (e.g., after paste).
71
+ * Refreshes the bounding box and captures child snapshots.
72
+ */
73
+ finalize(): void;
74
+ /**
75
+ * Recalculates the group's bounding box based on its children.
76
+ */
77
+ refreshBoundingBox(): void;
78
+ /**
79
+ * Captures snapshots of child states for transformation operations.
80
+ */
81
+ private captureChildSnapshots;
82
+ move(startX: number, startY: number, endX: number, endY: number): void;
83
+ resize(x: number, y: number, width: number, height: number): void;
84
+ rotate(value: number): void;
85
+ private getOffsetXToCenterFromSnapshot;
86
+ private getOffsetYToCenterFromSnapshot;
87
+ hitTest(x: number, y: number): boolean;
88
+ hitTestPolygon(polygon: KritzelPolygon): boolean;
89
+ copy(): KritzelGroup;
90
+ serialize(): any;
91
+ deserialize<T>(object: any): T;
92
+ update(): void;
93
+ /**
94
+ * Updates the workspace ID for this group and all its children.
95
+ */
96
+ updateWorkspaceId(workspaceId: string): void;
97
+ }
@@ -0,0 +1,17 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ export declare class KritzelImage extends KritzelBaseObject<HTMLImageElement> {
4
+ __class__: string;
5
+ src: string;
6
+ maxWidth: number;
7
+ maxHeight: number;
8
+ maxCompressionSize: number;
9
+ isDebugInfoVisible: boolean;
10
+ constructor(config?: Partial<KritzelImage>);
11
+ static create(core: KritzelCore): KritzelImage;
12
+ resize(x: number, y: number, width: number, height: number): void;
13
+ calculateScaledDimensions(img: HTMLImageElement): {
14
+ scaledWidth: number;
15
+ scaledHeight: number;
16
+ };
17
+ }
@@ -0,0 +1,101 @@
1
+ import { KritzelLineOptions } from '../../interfaces/line-options.interface';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ import { KritzelPolygon } from '../../interfaces/polygon.interface';
4
+ import { KritzelCore } from '../core/core.class';
5
+ import { LineAnchor } from '../../interfaces/anchor.interface';
6
+ import { ArrowHeadStyle, LineArrowConfig } from '../../interfaces/arrow-head.interface';
7
+ import { ThemeAwareColor } from '../../constants/color-palette.constants';
8
+ export declare class KritzelLine extends KritzelBaseObject<SVGElement> {
9
+ __class__: string;
10
+ startX: number;
11
+ startY: number;
12
+ endX: number;
13
+ endY: number;
14
+ controlX?: number;
15
+ controlY?: number;
16
+ stroke: ThemeAwareColor;
17
+ strokeWidth: number;
18
+ scale: number;
19
+ options: KritzelLineOptions | undefined;
20
+ /** Anchor connection for the start point of the line */
21
+ startAnchor?: LineAnchor;
22
+ /** Anchor connection for the end point of the line */
23
+ endAnchor?: LineAnchor;
24
+ /** Arrow head configuration for start and end of line */
25
+ arrows?: LineArrowConfig;
26
+ isVisible: boolean;
27
+ isDebugInfoVisible: boolean;
28
+ isCompleted: boolean;
29
+ private _adjustedPoints?;
30
+ private _clipInfo;
31
+ get d(): string;
32
+ get viewBox(): string;
33
+ constructor(config?: KritzelLineOptions);
34
+ static create(core: KritzelCore, options?: KritzelLineOptions): KritzelLine;
35
+ resize(x: number | null, y: number | null, width: number, height: number): void;
36
+ rotate(value: number): void;
37
+ move(startX: number, startY: number, endX: number, endY: number): void;
38
+ hitTest(x: number, y: number): boolean;
39
+ hitTestPolygon(polygon: KritzelPolygon): boolean;
40
+ updatePosition(x: number, y: number): void;
41
+ /**
42
+ * Updates a specific endpoint of the line (start or end).
43
+ * The coordinates are in viewBox-local space (relative to x, y origin).
44
+ * This method recalculates the bounding box dimensions.
45
+ *
46
+ * @param handleType - Which endpoint to update: 'start' or 'end'
47
+ * @param newX - New X coordinate in viewBox-local space
48
+ * @param newY - New Y coordinate in viewBox-local space
49
+ */
50
+ updateEndpoint(handleType: 'start' | 'end', newX: number, newY: number): void;
51
+ updateControlPoint(newX: number | undefined, newY: number | undefined): void;
52
+ private computeAdjustedPoints;
53
+ private pointToLineSegmentDistance;
54
+ /**
55
+ * Calculates the minimum distance from a point to a quadratic Bezier curve.
56
+ * Uses sampling along the curve to find the closest point.
57
+ */
58
+ private pointToBezierDistance;
59
+ private getClipInfo;
60
+ /**
61
+ * Computes the adjusted control point in world coordinates, accounting for rotation and translation.
62
+ */
63
+ private computeAdjustedControlPoint;
64
+ get rotatedPolygon(): KritzelPolygon;
65
+ /**
66
+ * Calculates the tight bounding box for a quadratic Bezier curve or straight line.
67
+ * For curves, it finds the extrema points where the derivative equals zero.
68
+ */
69
+ static calculateBoundingBox(startX: number, startY: number, endX: number, endY: number, controlX: number | undefined, controlY: number | undefined, strokeWidth: number): {
70
+ minX: number;
71
+ minY: number;
72
+ maxX: number;
73
+ maxY: number;
74
+ };
75
+ calculateBoundingBox(): {
76
+ minX: number;
77
+ minY: number;
78
+ maxX: number;
79
+ maxY: number;
80
+ };
81
+ private updateDimensions;
82
+ /** Get unique marker ID for SVG defs at the start of the line */
83
+ get startMarkerId(): string;
84
+ /** Get unique marker ID for SVG defs at the end of the line */
85
+ get endMarkerId(): string;
86
+ /** Get the arrow size for start or end, defaulting to strokeWidth * 3 */
87
+ getArrowSize(end: 'start' | 'end'): number;
88
+ /** Get the arrow fill color for start or end, defaulting to stroke color */
89
+ getArrowFill(end: 'start' | 'end'): string;
90
+ /**
91
+ * Generate SVG path data for an arrow head based on the given style.
92
+ * The path is designed to fit in a 10x10 viewBox with the tip at (10, 5).
93
+ * @param style The arrow head style
94
+ * @returns SVG path data string
95
+ */
96
+ getArrowPath(style?: ArrowHeadStyle): string;
97
+ /** Check if start arrow is enabled */
98
+ get hasStartArrow(): boolean;
99
+ /** Check if end arrow is enabled */
100
+ get hasEndArrow(): boolean;
101
+ }