kritzel-stencil 0.0.161 → 0.0.163

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 (155) hide show
  1. package/dist/cjs/{default-text-tool.config-zB3FPuXq.js → default-line-tool.config-DJMYrkSu.js} +6301 -3866
  2. package/dist/cjs/default-line-tool.config-DJMYrkSu.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +131 -127
  4. package/dist/cjs/index.cjs.js.map +1 -1
  5. package/dist/cjs/kritzel-color_22.cjs.entry.js +1233 -167
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/stencil.cjs.js +1 -1
  8. package/dist/collection/classes/core/core.class.js +159 -6
  9. package/dist/collection/classes/core/core.class.js.map +1 -1
  10. package/dist/collection/classes/core/reviver.class.js +24 -0
  11. package/dist/collection/classes/core/reviver.class.js.map +1 -1
  12. package/dist/collection/classes/core/store.class.js +10 -0
  13. package/dist/collection/classes/core/store.class.js.map +1 -1
  14. package/dist/collection/classes/core/viewport.class.js +8 -0
  15. package/dist/collection/classes/core/viewport.class.js.map +1 -1
  16. package/dist/collection/classes/handlers/line-handle.handler.js +383 -0
  17. package/dist/collection/classes/handlers/line-handle.handler.js.map +1 -0
  18. package/dist/collection/classes/handlers/move.handler.js +2 -2
  19. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  20. package/dist/collection/classes/managers/anchor.manager.js +1052 -0
  21. package/dist/collection/classes/managers/anchor.manager.js.map +1 -0
  22. package/dist/collection/classes/managers/cursor.manager.js +117 -0
  23. package/dist/collection/classes/managers/cursor.manager.js.map +1 -0
  24. package/dist/collection/classes/objects/base-object.class.js +4 -2
  25. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  26. package/dist/collection/classes/objects/line.class.js +564 -0
  27. package/dist/collection/classes/objects/line.class.js.map +1 -0
  28. package/dist/collection/classes/objects/path.class.js +85 -0
  29. package/dist/collection/classes/objects/path.class.js.map +1 -1
  30. package/dist/collection/classes/objects/selection-group.class.js +4 -0
  31. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  32. package/dist/collection/classes/objects/shape.class.js +372 -0
  33. package/dist/collection/classes/objects/shape.class.js.map +1 -0
  34. package/dist/collection/classes/registries/icon-registry.class.js +5 -0
  35. package/dist/collection/classes/registries/icon-registry.class.js.map +1 -1
  36. package/dist/collection/classes/tools/brush-tool.class.js +2 -2
  37. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  38. package/dist/collection/classes/tools/line-tool.class.js +172 -0
  39. package/dist/collection/classes/tools/line-tool.class.js.map +1 -0
  40. package/dist/collection/classes/tools/selection-tool.class.js +41 -8
  41. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  42. package/dist/collection/classes/tools/shape-tool.class.js +204 -0
  43. package/dist/collection/classes/tools/shape-tool.class.js.map +1 -0
  44. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +26 -6
  45. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  46. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +168 -60
  47. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  48. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +143 -5
  49. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +76 -12
  50. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  51. package/dist/collection/configs/default-engine-config.js +5 -1
  52. package/dist/collection/configs/default-engine-config.js.map +1 -1
  53. package/dist/collection/configs/default-line-tool.config.js +34 -0
  54. package/dist/collection/configs/default-line-tool.config.js.map +1 -0
  55. package/dist/collection/configs/default-shape-tool.config.js +26 -0
  56. package/dist/collection/configs/default-shape-tool.config.js.map +1 -0
  57. package/dist/collection/enums/shape-type.enum.js +7 -0
  58. package/dist/collection/enums/shape-type.enum.js.map +1 -0
  59. package/dist/collection/helpers/geometry.helper.js +97 -0
  60. package/dist/collection/helpers/geometry.helper.js.map +1 -1
  61. package/dist/collection/index.js +5 -0
  62. package/dist/collection/index.js.map +1 -1
  63. package/dist/collection/interfaces/anchor.interface.js +2 -0
  64. package/dist/collection/interfaces/anchor.interface.js.map +1 -0
  65. package/dist/collection/interfaces/arrow-head.interface.js +2 -0
  66. package/dist/collection/interfaces/arrow-head.interface.js.map +1 -0
  67. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  68. package/dist/collection/interfaces/line-options.interface.js +2 -0
  69. package/dist/collection/interfaces/line-options.interface.js.map +1 -0
  70. package/dist/collection/interfaces/toolbar-control.interface.js.map +1 -1
  71. package/dist/components/index.js +4 -4
  72. package/dist/components/kritzel-brush-style.js +1 -1
  73. package/dist/components/kritzel-context-menu.js +1 -1
  74. package/dist/components/kritzel-control-brush-config.js +1 -1
  75. package/dist/components/kritzel-control-text-config.js +1 -1
  76. package/dist/components/kritzel-controls.js +1 -1
  77. package/dist/components/kritzel-editor.js +91 -17
  78. package/dist/components/kritzel-editor.js.map +1 -1
  79. package/dist/components/kritzel-engine.js +1 -1
  80. package/dist/components/kritzel-icon.js +1 -1
  81. package/dist/components/kritzel-menu-item.js +1 -1
  82. package/dist/components/kritzel-menu.js +1 -1
  83. package/dist/components/kritzel-split-button.js +1 -1
  84. package/dist/components/kritzel-utility-panel.js +1 -1
  85. package/dist/components/kritzel-workspace-manager.js +1 -1
  86. package/dist/components/{p-DxNbcUzt.js → p-5OECjGHq.js} +3 -3
  87. package/dist/components/{p-DxNbcUzt.js.map → p-5OECjGHq.js.map} +1 -1
  88. package/dist/components/{p-i0IlGLv2.js → p-BSBMBjhq.js} +3 -3
  89. package/dist/components/{p-i0IlGLv2.js.map → p-BSBMBjhq.js.map} +1 -1
  90. package/dist/components/{p-BdZKPKnx.js → p-BuS7MM1j.js} +4 -4
  91. package/dist/components/{p-BdZKPKnx.js.map → p-BuS7MM1j.js.map} +1 -1
  92. package/dist/components/{p-D7BLVRXX.js → p-CnRfQsIC.js} +3716 -554
  93. package/dist/components/p-CnRfQsIC.js.map +1 -0
  94. package/dist/components/{p-DbKKCHKd.js → p-Cv4BGNPb.js} +7 -2
  95. package/dist/components/p-Cv4BGNPb.js.map +1 -0
  96. package/dist/components/{p-D_ygcWSz.js → p-D1YAsWrL.js} +3 -3
  97. package/dist/components/{p-D_ygcWSz.js.map → p-D1YAsWrL.js.map} +1 -1
  98. package/dist/components/{p-Doixm8-N.js → p-D8L0t-Ro.js} +3 -3
  99. package/dist/components/{p-Doixm8-N.js.map → p-D8L0t-Ro.js.map} +1 -1
  100. package/dist/components/{p-CC8KFHSe.js → p-DguzZn_x.js} +3 -3
  101. package/dist/components/{p-CC8KFHSe.js.map → p-DguzZn_x.js.map} +1 -1
  102. package/dist/components/{p-CBYBurdY.js → p-Dz2XHHqa.js} +191 -7
  103. package/dist/components/p-Dz2XHHqa.js.map +1 -0
  104. package/dist/components/{p-58y59Acb.js → p-I3iPEDpx.js} +5 -5
  105. package/dist/components/{p-58y59Acb.js.map → p-I3iPEDpx.js.map} +1 -1
  106. package/dist/components/{p-BpXgwgnV.js → p-tp96UZ0l.js} +83 -19
  107. package/dist/components/p-tp96UZ0l.js.map +1 -0
  108. package/dist/esm/{default-text-tool.config-BvCgOiKA.js → default-line-tool.config-C35P3XfD.js} +6288 -3867
  109. package/dist/esm/default-line-tool.config-C35P3XfD.js.map +1 -0
  110. package/dist/esm/index.js +2 -2
  111. package/dist/esm/kritzel-color_22.entry.js +1154 -88
  112. package/dist/esm/loader.js +1 -1
  113. package/dist/esm/stencil.js +1 -1
  114. package/dist/stencil/index.esm.js +1 -1
  115. package/dist/stencil/p-9d43b708.entry.js +10 -0
  116. package/dist/stencil/p-9d43b708.entry.js.map +1 -0
  117. package/dist/stencil/p-C35P3XfD.js +2 -0
  118. package/dist/stencil/p-C35P3XfD.js.map +1 -0
  119. package/dist/stencil/stencil.esm.js +1 -1
  120. package/dist/types/classes/core/core.class.d.ts +19 -0
  121. package/dist/types/classes/core/store.class.d.ts +4 -0
  122. package/dist/types/classes/core/viewport.class.d.ts +6 -0
  123. package/dist/types/classes/handlers/line-handle.handler.d.ts +34 -0
  124. package/dist/types/classes/managers/anchor.manager.d.ts +180 -0
  125. package/dist/types/classes/managers/cursor.manager.d.ts +43 -0
  126. package/dist/types/classes/objects/line.class.d.ts +98 -0
  127. package/dist/types/classes/objects/path.class.d.ts +7 -0
  128. package/dist/types/classes/objects/shape.class.d.ts +116 -0
  129. package/dist/types/classes/tools/line-tool.class.d.ts +17 -0
  130. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -0
  131. package/dist/types/classes/tools/shape-tool.class.d.ts +37 -0
  132. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +2 -4
  133. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +16 -1
  134. package/dist/types/components.d.ts +5 -5
  135. package/dist/types/configs/default-line-tool.config.d.ts +2 -0
  136. package/dist/types/configs/default-shape-tool.config.d.ts +2 -0
  137. package/dist/types/enums/shape-type.enum.d.ts +5 -0
  138. package/dist/types/helpers/geometry.helper.d.ts +31 -0
  139. package/dist/types/index.d.ts +5 -0
  140. package/dist/types/interfaces/anchor.interface.d.ts +137 -0
  141. package/dist/types/interfaces/arrow-head.interface.d.ts +26 -0
  142. package/dist/types/interfaces/engine-state.interface.d.ts +8 -0
  143. package/dist/types/interfaces/line-options.interface.d.ts +21 -0
  144. package/dist/types/interfaces/toolbar-control.interface.d.ts +36 -2
  145. package/package.json +1 -1
  146. package/dist/cjs/default-text-tool.config-zB3FPuXq.js.map +0 -1
  147. package/dist/components/p-BpXgwgnV.js.map +0 -1
  148. package/dist/components/p-CBYBurdY.js.map +0 -1
  149. package/dist/components/p-D7BLVRXX.js.map +0 -1
  150. package/dist/components/p-DbKKCHKd.js.map +0 -1
  151. package/dist/esm/default-text-tool.config-BvCgOiKA.js.map +0 -1
  152. package/dist/stencil/p-6d9756d9.entry.js +0 -10
  153. package/dist/stencil/p-6d9756d9.entry.js.map +0 -1
  154. package/dist/stencil/p-BvCgOiKA.js +0 -2
  155. package/dist/stencil/p-BvCgOiKA.js.map +0 -1
@@ -12,17 +12,24 @@ export class KritzelControls {
12
12
  firstConfig = null;
13
13
  isTooltipVisible = false;
14
14
  isTouchDevice = KritzelDevicesHelper.isTouchDevice();
15
+ selectedSubOptions = new Map();
16
+ openSubMenuControl = null;
15
17
  handleDocumentClick(event) {
16
18
  const element = event.target;
17
19
  if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {
18
20
  return;
19
21
  }
20
22
  this.isTooltipVisible = false;
23
+ // Close submenu when clicking outside
24
+ if (!element.closest('.kritzel-control-split') && !element.closest('.kritzel-submenu')) {
25
+ this.openSubMenuControl = null;
26
+ }
21
27
  }
22
28
  handleKeyDown(event) {
23
29
  if (event.key === 'Escape') {
24
30
  event.preventDefault();
25
31
  this.closeTooltip();
32
+ this.openSubMenuControl = null;
26
33
  this.kritzelEngine?.enable();
27
34
  }
28
35
  }
@@ -98,36 +105,91 @@ export class KritzelControls {
98
105
  this.isTooltipVisible = false;
99
106
  this.kritzelEngine?.enable();
100
107
  }
108
+ /**
109
+ * Get the currently selected sub-option for a control.
110
+ * Returns the first sub-option as default if none is selected.
111
+ */
112
+ getSelectedSubOption(control) {
113
+ if (!control.subOptions?.length)
114
+ return undefined;
115
+ return this.selectedSubOptions.get(control.name) || control.subOptions[0];
116
+ }
117
+ /**
118
+ * Toggle the submenu for a split-button control
119
+ */
120
+ toggleSubMenu(event, control) {
121
+ event.stopPropagation();
122
+ if (this.openSubMenuControl?.name === control.name) {
123
+ this.openSubMenuControl = null;
124
+ }
125
+ else {
126
+ this.openSubMenuControl = control;
127
+ }
128
+ }
129
+ /**
130
+ * Select a sub-option and update the tool property
131
+ */
132
+ async selectSubOption(control, option) {
133
+ // Update the selected sub-options map (create new Map for reactivity)
134
+ const newMap = new Map(this.selectedSubOptions);
135
+ newMap.set(control.name, option);
136
+ this.selectedSubOptions = newMap;
137
+ // Update the tool property if the tool is instantiated
138
+ if (control.tool && typeof control.tool !== 'function') {
139
+ control.tool[option.toolProperty] = option.value;
140
+ }
141
+ // Close the submenu
142
+ this.openSubMenuControl = null;
143
+ // Activate this control
144
+ await this.handleControlClick(control);
145
+ }
101
146
  render() {
102
- const hasNoConfig = this.activeControl?.config === undefined || this.activeControl?.config === null;
103
- return (h(Host, { key: 'c01351cbf438f2e36249b2ef3ef8725edcabd57b', class: {
147
+ const hasConfigUI = this.activeControl?.tool instanceof KritzelBrushTool ||
148
+ this.activeControl?.tool instanceof KritzelTextTool;
149
+ return (h(Host, { key: '34a8a81224f1714a30a0d6e03fb81ed031fe36a0', class: {
104
150
  mobile: this.isTouchDevice,
105
- } }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '3c14cf25dd51f123dc8d33be92992e2f2c18ac40', style: {
151
+ } }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '8ddfe7b4872d59b08b0561dbd61c67b9c245dcc9', style: {
106
152
  position: 'absolute',
107
153
  bottom: '56px',
108
154
  left: '12px',
109
- }, undoState: this.undoState, onUndo: () => this.kritzelEngine?.undo(), onRedo: () => this.kritzelEngine?.redo(), onDelete: () => this.kritzelEngine?.delete() })), h("div", { key: '05719acfe12d1770bf49fb7d9989619f2e27ee0f', class: "kritzel-controls" }, this.controls.map(control => {
155
+ }, undoState: this.undoState, onUndo: () => this.kritzelEngine?.undo(), onRedo: () => this.kritzelEngine?.redo(), onDelete: () => this.kritzelEngine?.delete() })), h("div", { key: '370229830b9a6c0ae5704d9fb0ce35d130fcf049', class: "kritzel-controls" }, this.controls.map(control => {
110
156
  if (control.type === 'tool') {
157
+ // Check if this control has sub-options (split-button)
158
+ if (control.subOptions?.length) {
159
+ const selectedSubOption = this.getSelectedSubOption(control);
160
+ const isActive = this.activeControl?.name === control.name;
161
+ const isSubMenuOpen = this.openSubMenuControl?.name === control.name;
162
+ return (h("div", { class: {
163
+ 'kritzel-control-split': true,
164
+ 'selected': isActive,
165
+ }, key: control.name }, h("button", { class: "kritzel-control-main", onClick: () => this.handleControlClick(control), title: selectedSubOption?.label }, h("kritzel-icon", { name: selectedSubOption?.icon || control.icon })), h("button", { class: {
166
+ 'kritzel-control-dropdown': true,
167
+ 'visible': isActive,
168
+ }, onClick: (e) => this.toggleSubMenu(e, control), "aria-label": "Select shape type", "aria-expanded": isSubMenuOpen ? 'true' : 'false', tabIndex: isActive ? 0 : -1 }, h("kritzel-icon", { name: "chevron-down", size: 12 })), isSubMenuOpen && (h("div", { class: "kritzel-submenu" }, control.subOptions.map(option => (h("button", { class: {
169
+ 'kritzel-submenu-item': true,
170
+ 'active': option.id === selectedSubOption?.id,
171
+ }, key: option.id, onClick: () => this.selectSubOption(control, option) }, h("kritzel-icon", { name: option.icon, size: 20 }), h("span", null, option.label))))))));
172
+ }
173
+ // Regular tool control (no sub-options)
111
174
  return (h("button", { class: {
112
175
  'kritzel-control': true,
113
176
  'selected': this.activeControl?.name === control?.name,
114
177
  }, key: control.name, onClick: _event => this.handleControlClick?.(control) }, h("kritzel-icon", { name: control.icon })));
115
178
  }
116
- if (control.type === 'divider') {
117
- return h("div", { class: "kritzel-divider", key: control.name });
118
- }
119
179
  if (control.type === 'config' && control.name === this.firstConfig?.name && this.activeControl) {
120
- return (h("div", { class: "kritzel-config-container", key: control.name }, h("kritzel-tooltip", { ref: el => (this.tooltipRef = el), isVisible: this.isTooltipVisible, anchorElement: this.host.shadowRoot?.querySelector('.kritzel-config-container'), onTooltipClosed: () => this.handleTooltipClosed() }, h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => this.handleToolChange?.(event) })), this.activeControl.name === 'text' && (h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => this.handleToolChange?.(event) })))), h("div", { tabIndex: 0, class: "kritzel-config", onClick: event => this.handleConfigClick?.(event), onKeyDown: event => {
180
+ return (h("div", { class: {
181
+ 'kritzel-config-container': true,
182
+ 'visible': hasConfigUI,
183
+ }, key: control.name }, h("kritzel-tooltip", { ref: el => (this.tooltipRef = el), isVisible: this.isTooltipVisible, anchorElement: this.host.shadowRoot?.querySelector('.kritzel-config-container'), onTooltipClosed: () => this.handleTooltipClosed() }, h("div", { style: { width: '294px', height: '100%' } }, this.activeControl.name === 'brush' && (h("kritzel-control-brush-config", { tool: this.activeToolAsBrushTool, onToolChange: event => this.handleToolChange?.(event) })), this.activeControl.name === 'text' && (h("kritzel-control-text-config", { tool: this.activeToolAsTextTool, onToolChange: event => this.handleToolChange?.(event) })))), h("div", { tabIndex: hasConfigUI ? 0 : -1, class: "kritzel-config", onClick: event => this.handleConfigClick?.(event), onKeyDown: event => {
121
184
  if (event.key === 'Enter') {
122
185
  this.handleConfigClick?.(event);
123
186
  }
124
187
  }, style: {
125
- cursor: this.activeControl.config ? 'pointer' : 'default',
126
- pointerEvents: hasNoConfig ? 'none' : 'auto',
188
+ cursor: 'pointer',
127
189
  } }, this.activeControl.tool instanceof KritzelBrushTool && (h("div", { class: "color-container" }, h("kritzel-color", { value: this.activeToolAsBrushTool?.color, size: this.activeToolAsBrushTool?.size, style: {
128
190
  borderRadius: '50%',
129
191
  border: 'none',
130
- } }))), this.activeControl.tool instanceof KritzelTextTool && (h("div", { class: "font-container" }, h("kritzel-font", { fontFamily: this.activeToolAsTextTool?.fontFamily, size: this.activeToolAsTextTool?.fontSize, color: this.activeToolAsTextTool?.fontColor }))), hasNoConfig && h("div", { class: "no-config" }))));
192
+ } }))), this.activeControl.tool instanceof KritzelTextTool && (h("div", { class: "font-container" }, h("kritzel-font", { fontFamily: this.activeToolAsTextTool?.fontFamily, size: this.activeToolAsTextTool?.fontSize, color: this.activeToolAsTextTool?.fontColor }))))));
131
193
  }
132
194
  }))));
133
195
  }
@@ -244,7 +306,9 @@ export class KritzelControls {
244
306
  return {
245
307
  "firstConfig": {},
246
308
  "isTooltipVisible": {},
247
- "isTouchDevice": {}
309
+ "isTouchDevice": {},
310
+ "selectedSubOptions": {},
311
+ "openSubMenuControl": {}
248
312
  };
249
313
  }
250
314
  static get events() {
@@ -1 +1 @@
1
- {"version":3,"file":"kritzel-controls.js","sourceRoot":"","sources":["../../../../src/components/ui/kritzel-controls/kritzel-controls.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAGzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAWvE,MAAM,OAAO,eAAe;IACf,IAAI,CAAe;IAEtB,QAAQ,GAA4B,EAAE,CAAC;IACtB,aAAa,GAAiC,IAAI,CAAC;IACpE,qBAAqB,GAAY,IAAI,CAAC;IACtC,SAAS,GAAqB,IAAI,CAAC;IAElC,eAAe,CAAqB;IAEpC,WAAW,GAAsB,IAAI,CAAC;IACtC,gBAAgB,GAAY,KAAK,CAAC;IAClC,aAAa,GAAY,oBAAoB,CAAC,aAAa,EAAE,CAAC;IAGvE,mBAAmB,CAAC,KAAiB;QACnC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAqB,CAAC;QAE5C,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC/D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAGD,aAAa,CAAC,KAAK;QACjB,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAGD,KA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I,CAAC,oBAAoB,EAAE,QAAQ,EACzC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAC7B,CACZ,CACP;4BAEA,WAAW,IAAI,WAAK,KAAK,EAAC,WAAW,GAAO,CACzC,CACF,CACP,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Element, Host, Listen, Event, EventEmitter, Method } from '@stencil/core';\r\nimport { KritzelBrushTool } from '../../../classes/tools/brush-tool.class';\r\nimport { KritzelTextTool } from '../../../classes/tools/text-tool.class';\r\nimport { KritzelToolbarControl } from '../../../interfaces/toolbar-control.interface';\r\nimport { KritzelBaseTool } from '../../../classes/tools/base-tool.class';\r\nimport { KritzelDevicesHelper } from '../../../helpers/devices.helper';\r\nimport { KritzelUndoState } from '../../../interfaces/undo-state.interface';\r\n\r\ntype ToolConfig = Record<string, any>;\r\n\r\n@Component({\r\n tag: 'kritzel-controls',\r\n styleUrl: 'kritzel-controls.css',\r\n shadow: true,\r\n assetsDirs: ['../assets'],\r\n})\r\nexport class KritzelControls {\r\n @Element() host!: HTMLElement;\r\n\r\n @Prop() controls: KritzelToolbarControl[] = [];\r\n @Prop({ mutable: true }) activeControl: KritzelToolbarControl | null = null;\r\n @Prop() isUtilityPanelVisible: boolean = true;\r\n @Prop() undoState: KritzelUndoState = null;\r\n\r\n @Event() isControlsReady: EventEmitter<void>;\r\n\r\n @State() firstConfig: ToolConfig | null = null;\r\n @State() isTooltipVisible: boolean = false;\r\n @State() isTouchDevice: boolean = KritzelDevicesHelper.isTouchDevice();\r\n\r\n @Listen('click', { target: 'document' })\r\n handleDocumentClick(event: MouseEvent) {\r\n const element = event.target as HTMLElement;\r\n\r\n if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {\r\n return;\r\n }\r\n\r\n this.isTooltipVisible = false;\r\n }\r\n\r\n @Listen('keydown', { target: 'window' })\r\n handleKeyDown(event) {\r\n if (event.key === 'Escape') {\r\n event.preventDefault();\r\n this.closeTooltip();\r\n this.kritzelEngine?.enable();\r\n }\r\n }\r\n\r\n @Listen('activeToolChange', { target: 'document' })\r\n async handleActiveToolChange(event: CustomEvent) {\r\n this.activeControl = this.controls.find(control => control.tool === event.detail) || null;\r\n }\r\n\r\n @Method()\r\n async closeTooltip() {\r\n this.isTooltipVisible = false;\r\n }\r\n\r\n kritzelEngine: HTMLKritzelEngineElement | null = null;\r\n tooltipRef: HTMLKritzelTooltipElement | null = null;\r\n\r\n get activeToolAsTextTool() {\r\n return this.activeControl?.tool as KritzelTextTool;\r\n }\r\n\r\n get activeToolAsBrushTool() {\r\n return this.activeControl?.tool as KritzelBrushTool;\r\n }\r\n\r\n async componentWillLoad() {\r\n await this.initializeEngine();\r\n await this.initializeTools();\r\n this.isControlsReady.emit();\r\n }\r\n\r\n private async initializeEngine() {\r\n await customElements.whenDefined('kritzel-engine');\r\n this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');\r\n\r\n if (!this.kritzelEngine) {\r\n throw new Error('kritzel-engine not found in parent element.');\r\n }\r\n }\r\n\r\n private async initializeTools() {\r\n for (const c of this.controls) {\r\n if (c.type === 'tool' && c.tool) {\r\n c.tool = await this.kritzelEngine.registerTool(c.name, c.tool, c.config);\r\n }\r\n\r\n if (c.type === 'tool' && c.isDefault && c.tool) {\r\n await this.kritzelEngine.changeActiveTool(c.tool as KritzelBaseTool);\r\n this.activeControl = c;\r\n }\r\n\r\n if (c.type === 'config') {\r\n if (this.firstConfig === null) {\r\n this.firstConfig = c;\r\n } else {\r\n console.warn('Only one config control is allowed. The first one will be used.');\r\n }\r\n }\r\n }\r\n }\r\n\r\n private async handleControlClick(control: KritzelToolbarControl) {\r\n this.activeControl = control;\r\n\r\n if (this.activeControl.type === 'tool') {\r\n await this.kritzelEngine.changeActiveTool(this.activeControl.tool as KritzelBaseTool);\r\n }\r\n }\r\n\r\n private handleConfigClick(event: MouseEvent) {\r\n event.stopPropagation();\r\n this.isTooltipVisible = !this.isTooltipVisible;\r\n if(this.isTooltipVisible){\r\n this.kritzelEngine?.disable();\r\n } else {\r\n this.kritzelEngine?.enable();\r\n }\r\n\r\n setTimeout(() => {\r\n this.tooltipRef?.focusContent();\r\n }, 100);\r\n }\r\n\r\n private async handleToolChange(event: CustomEvent) {\r\n this.activeControl = { ...this.activeControl, tool: event.detail };\r\n await this.kritzelEngine.changeActiveTool((this.activeControl as any).tool);\r\n }\r\n\r\n private handleTooltipClosed() {\r\n this.isTooltipVisible = false;\r\n this.kritzelEngine?.enable();\r\n }\r\n\r\n render() {\r\n const hasNoConfig = this.activeControl?.config === undefined || this.activeControl?.config === null;\r\n\r\n return (\r\n <Host\r\n class={{\r\n mobile: this.isTouchDevice,\r\n }}\r\n >\r\n {this.isUtilityPanelVisible && (\r\n <kritzel-utility-panel\r\n style={{\r\n position: 'absolute',\r\n bottom: '56px',\r\n left: '12px',\r\n }}\r\n undoState={this.undoState}\r\n onUndo={() => this.kritzelEngine?.undo()}\r\n onRedo={() => this.kritzelEngine?.redo()}\r\n onDelete={() => this.kritzelEngine?.delete()}\r\n ></kritzel-utility-panel>\r\n )}\r\n\r\n <div class=\"kritzel-controls\">\r\n {this.controls.map(control => {\r\n if (control.type === 'tool') {\r\n return (\r\n <button\r\n class={{\r\n 'kritzel-control': true,\r\n 'selected': this.activeControl?.name === control?.name,\r\n }}\r\n key={control.name}\r\n onClick={_event => this.handleControlClick?.(control)}\r\n >\r\n <kritzel-icon name={control.icon}></kritzel-icon>\r\n </button>\r\n );\r\n }\r\n\r\n if (control.type === 'divider') {\r\n return <div class=\"kritzel-divider\" key={control.name}></div>;\r\n }\r\n\r\n if (control.type === 'config' && control.name === this.firstConfig?.name && this.activeControl) {\r\n return (\r\n <div class=\"kritzel-config-container\" key={control.name}>\r\n <kritzel-tooltip\r\n ref={el => (this.tooltipRef = el)}\r\n isVisible={this.isTooltipVisible}\r\n anchorElement={this.host.shadowRoot?.querySelector('.kritzel-config-container') as HTMLElement}\r\n onTooltipClosed={() => this.handleTooltipClosed()}\r\n >\r\n <div style={{ width: '294px', height: '100%' }}>\r\n {this.activeControl.name === 'brush' && (\r\n <kritzel-control-brush-config tool={this.activeToolAsBrushTool} onToolChange={event => this.handleToolChange?.(event)}></kritzel-control-brush-config>\r\n )}\r\n\r\n {this.activeControl.name === 'text' && (\r\n <kritzel-control-text-config tool={this.activeToolAsTextTool} onToolChange={event => this.handleToolChange?.(event)}></kritzel-control-text-config>\r\n )}\r\n </div>\r\n </kritzel-tooltip>\r\n\r\n <div\r\n tabIndex={0}\r\n class=\"kritzel-config\"\r\n onClick={event => this.handleConfigClick?.(event)}\r\n onKeyDown={event => {\r\n if (event.key === 'Enter') {\r\n this.handleConfigClick?.(event as any);\r\n }\r\n }}\r\n style={{\r\n cursor: this.activeControl.config ? 'pointer' : 'default',\r\n pointerEvents: hasNoConfig ? 'none' : 'auto',\r\n }}\r\n >\r\n {this.activeControl.tool instanceof KritzelBrushTool && (\r\n <div class=\"color-container\">\r\n <kritzel-color\r\n value={this.activeToolAsBrushTool?.color}\r\n size={this.activeToolAsBrushTool?.size}\r\n style={{\r\n borderRadius: '50%',\r\n border: 'none',\r\n }}\r\n ></kritzel-color>\r\n </div>\r\n )}\r\n\r\n {this.activeControl.tool instanceof KritzelTextTool && (\r\n <div class=\"font-container\">\r\n <kritzel-font\r\n fontFamily={this.activeToolAsTextTool?.fontFamily}\r\n size={this.activeToolAsTextTool?.fontSize}\r\n color={this.activeToolAsTextTool?.fontColor}\r\n ></kritzel-font>\r\n </div>\r\n )}\r\n\r\n {hasNoConfig && <div class=\"no-config\"></div>}\r\n </div>\r\n </div>\r\n );\r\n }\r\n })}\r\n </div>\r\n </Host>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"kritzel-controls.js","sourceRoot":"","sources":["../../../../src/components/ui/kritzel-controls/kritzel-controls.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAGzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAWvE,MAAM,OAAO,eAAe;IACf,IAAI,CAAe;IAEtB,QAAQ,GAA4B,EAAE,CAAC;IACtB,aAAa,GAAiC,IAAI,CAAC;IACpE,qBAAqB,GAAY,IAAI,CAAC;IACtC,SAAS,GAAqB,IAAI,CAAC;IAElC,eAAe,CAAqB;IAEpC,WAAW,GAAsB,IAAI,CAAC;IACtC,gBAAgB,GAAY,KAAK,CAAC;IAClC,aAAa,GAAY,oBAAoB,CAAC,aAAa,EAAE,CAAC;IAC9D,kBAAkB,GAAyC,IAAI,GAAG,EAAE,CAAC;IACrE,kBAAkB,GAAiC,IAAI,CAAC;IAGjE,mBAAmB,CAAC,KAAiB;QACnC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAqB,CAAC;QAE5C,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC/D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAE9B,sCAAsC;QACtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACvF,IAAI,CA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AAS;6BAClB;4BAEA,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,gBAAgB,IAAI,CACtD,WAAK,KAAK,EAAC,iBAAiB;gCAC1B,qBACE,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,EACxC,IAAI,EAAE,IAAI,CAAC,qBAAqB,EAAE,IAAI,EACtC,KAAK,EAAE;wCACL,YAAY,EAAE,KAAK;wCACnB,MAAM,EAAE,MAAM;qCACf,GACc,CACb,CACP;4BAEA,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,eAAe,IAAI,CACrD,WAAK,KAAK,EAAC,gBAAgB;gCACzB,oBACE,UAAU,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,EACjD,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,EACzC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAC7B,CACZ,CACP,CACG,CACF,CACP,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Element, Host, Listen, Event, EventEmitter, Method } from '@stencil/core';\r\nimport { KritzelBrushTool } from '../../../classes/tools/brush-tool.class';\r\nimport { KritzelTextTool } from '../../../classes/tools/text-tool.class';\r\nimport { KritzelToolbarControl, KritzelToolbarSubOption } from '../../../interfaces/toolbar-control.interface';\r\nimport { KritzelBaseTool } from '../../../classes/tools/base-tool.class';\r\nimport { KritzelDevicesHelper } from '../../../helpers/devices.helper';\r\nimport { KritzelUndoState } from '../../../interfaces/undo-state.interface';\r\n\r\ntype ToolConfig = Record<string, any>;\r\n\r\n@Component({\r\n tag: 'kritzel-controls',\r\n styleUrl: 'kritzel-controls.css',\r\n shadow: true,\r\n assetsDirs: ['../assets'],\r\n})\r\nexport class KritzelControls {\r\n @Element() host!: HTMLElement;\r\n\r\n @Prop() controls: KritzelToolbarControl[] = [];\r\n @Prop({ mutable: true }) activeControl: KritzelToolbarControl | null = null;\r\n @Prop() isUtilityPanelVisible: boolean = true;\r\n @Prop() undoState: KritzelUndoState = null;\r\n\r\n @Event() isControlsReady: EventEmitter<void>;\r\n\r\n @State() firstConfig: ToolConfig | null = null;\r\n @State() isTooltipVisible: boolean = false;\r\n @State() isTouchDevice: boolean = KritzelDevicesHelper.isTouchDevice();\r\n @State() selectedSubOptions: Map<string, KritzelToolbarSubOption> = new Map();\r\n @State() openSubMenuControl: KritzelToolbarControl | null = null;\r\n\r\n @Listen('click', { target: 'document' })\r\n handleDocumentClick(event: MouseEvent) {\r\n const element = event.target as HTMLElement;\r\n\r\n if (!this.kritzelEngine || element.closest('.kritzel-tooltip')) {\r\n return;\r\n }\r\n\r\n this.isTooltipVisible = false;\r\n\r\n // Close submenu when clicking outside\r\n if (!element.closest('.kritzel-control-split') && !element.closest('.kritzel-submenu')) {\r\n this.openSubMenuControl = null;\r\n }\r\n }\r\n\r\n @Listen('keydown', { target: 'window' })\r\n handleKeyDown(event) {\r\n if (event.key === 'Escape') {\r\n event.preventDefault();\r\n this.closeTooltip();\r\n this.openSubMenuControl = null;\r\n this.kritzelEngine?.enable();\r\n }\r\n }\r\n\r\n @Listen('activeToolChange', { target: 'document' })\r\n async handleActiveToolChange(event: CustomEvent) {\r\n this.activeControl = this.controls.find(control => control.tool === event.detail) || null;\r\n }\r\n\r\n @Method()\r\n async closeTooltip() {\r\n this.isTooltipVisible = false;\r\n }\r\n\r\n kritzelEngine: HTMLKritzelEngineElement | null = null;\r\n tooltipRef: HTMLKritzelTooltipElement | null = null;\r\n\r\n get activeToolAsTextTool() {\r\n return this.activeControl?.tool as KritzelTextTool;\r\n }\r\n\r\n get activeToolAsBrushTool() {\r\n return this.activeControl?.tool as KritzelBrushTool;\r\n }\r\n\r\n async componentWillLoad() {\r\n await this.initializeEngine();\r\n await this.initializeTools();\r\n this.isControlsReady.emit();\r\n }\r\n\r\n private async initializeEngine() {\r\n await customElements.whenDefined('kritzel-engine');\r\n this.kritzelEngine = this.host.parentElement.querySelector('kritzel-engine');\r\n\r\n if (!this.kritzelEngine) {\r\n throw new Error('kritzel-engine not found in parent element.');\r\n }\r\n }\r\n\r\n private async initializeTools() {\r\n for (const c of this.controls) {\r\n if (c.type === 'tool' && c.tool) {\r\n c.tool = await this.kritzelEngine.registerTool(c.name, c.tool, c.config);\r\n }\r\n\r\n if (c.type === 'tool' && c.isDefault && c.tool) {\r\n await this.kritzelEngine.changeActiveTool(c.tool as KritzelBaseTool);\r\n this.activeControl = c;\r\n }\r\n\r\n if (c.type === 'config') {\r\n if (this.firstConfig === null) {\r\n this.firstConfig = c;\r\n } else {\r\n console.warn('Only one config control is allowed. The first one will be used.');\r\n }\r\n }\r\n }\r\n }\r\n\r\n private async handleControlClick(control: KritzelToolbarControl) {\r\n this.activeControl = control;\r\n\r\n if (this.activeControl.type === 'tool') {\r\n await this.kritzelEngine.changeActiveTool(this.activeControl.tool as KritzelBaseTool);\r\n }\r\n }\r\n\r\n private handleConfigClick(event: MouseEvent) {\r\n event.stopPropagation();\r\n this.isTooltipVisible = !this.isTooltipVisible;\r\n if(this.isTooltipVisible){\r\n this.kritzelEngine?.disable();\r\n } else {\r\n this.kritzelEngine?.enable();\r\n }\r\n\r\n setTimeout(() => {\r\n this.tooltipRef?.focusContent();\r\n }, 100);\r\n }\r\n\r\n private async handleToolChange(event: CustomEvent) {\r\n this.activeControl = { ...this.activeControl, tool: event.detail };\r\n await this.kritzelEngine.changeActiveTool((this.activeControl as any).tool);\r\n }\r\n\r\n private handleTooltipClosed() {\r\n this.isTooltipVisible = false;\r\n this.kritzelEngine?.enable();\r\n }\r\n\r\n /**\r\n * Get the currently selected sub-option for a control.\r\n * Returns the first sub-option as default if none is selected.\r\n */\r\n private getSelectedSubOption(control: KritzelToolbarControl): KritzelToolbarSubOption | undefined {\r\n if (!control.subOptions?.length) return undefined;\r\n return this.selectedSubOptions.get(control.name) || control.subOptions[0];\r\n }\r\n\r\n /**\r\n * Toggle the submenu for a split-button control\r\n */\r\n private toggleSubMenu(event: MouseEvent, control: KritzelToolbarControl) {\r\n event.stopPropagation();\r\n if (this.openSubMenuControl?.name === control.name) {\r\n this.openSubMenuControl = null;\r\n } else {\r\n this.openSubMenuControl = control;\r\n }\r\n }\r\n\r\n /**\r\n * Select a sub-option and update the tool property\r\n */\r\n private async selectSubOption(control: KritzelToolbarControl, option: KritzelToolbarSubOption) {\r\n // Update the selected sub-options map (create new Map for reactivity)\r\n const newMap = new Map(this.selectedSubOptions);\r\n newMap.set(control.name, option);\r\n this.selectedSubOptions = newMap;\r\n\r\n // Update the tool property if the tool is instantiated\r\n if (control.tool && typeof control.tool !== 'function') {\r\n (control.tool as any)[option.toolProperty] = option.value;\r\n }\r\n\r\n // Close the submenu\r\n this.openSubMenuControl = null;\r\n\r\n // Activate this control\r\n await this.handleControlClick(control);\r\n }\r\n\r\n render() {\r\n const hasConfigUI = this.activeControl?.tool instanceof KritzelBrushTool || \r\n this.activeControl?.tool instanceof KritzelTextTool;\r\n\r\n return (\r\n <Host\r\n class={{\r\n mobile: this.isTouchDevice,\r\n }}\r\n >\r\n {this.isUtilityPanelVisible && (\r\n <kritzel-utility-panel\r\n style={{\r\n position: 'absolute',\r\n bottom: '56px',\r\n left: '12px',\r\n }}\r\n undoState={this.undoState}\r\n onUndo={() => this.kritzelEngine?.undo()}\r\n onRedo={() => this.kritzelEngine?.redo()}\r\n onDelete={() => this.kritzelEngine?.delete()}\r\n ></kritzel-utility-panel>\r\n )}\r\n\r\n <div class=\"kritzel-controls\">\r\n {this.controls.map(control => {\r\n if (control.type === 'tool') {\r\n // Check if this control has sub-options (split-button)\r\n if (control.subOptions?.length) {\r\n const selectedSubOption = this.getSelectedSubOption(control);\r\n const isActive = this.activeControl?.name === control.name;\r\n const isSubMenuOpen = this.openSubMenuControl?.name === control.name;\r\n\r\n return (\r\n <div\r\n class={{\r\n 'kritzel-control-split': true,\r\n 'selected': isActive,\r\n }}\r\n key={control.name}\r\n >\r\n <button\r\n class=\"kritzel-control-main\"\r\n onClick={() => this.handleControlClick(control)}\r\n title={selectedSubOption?.label}\r\n >\r\n <kritzel-icon name={selectedSubOption?.icon || control.icon}></kritzel-icon>\r\n </button>\r\n <button\r\n class={{\r\n 'kritzel-control-dropdown': true,\r\n 'visible': isActive,\r\n }}\r\n onClick={(e) => this.toggleSubMenu(e, control)}\r\n aria-label=\"Select shape type\"\r\n aria-expanded={isSubMenuOpen ? 'true' : 'false'}\r\n tabIndex={isActive ? 0 : -1}\r\n >\r\n <kritzel-icon name=\"chevron-down\" size={12}></kritzel-icon>\r\n </button>\r\n\r\n {isSubMenuOpen && (\r\n <div class=\"kritzel-submenu\">\r\n {control.subOptions.map(option => (\r\n <button\r\n class={{\r\n 'kritzel-submenu-item': true,\r\n 'active': option.id === selectedSubOption?.id,\r\n }}\r\n key={option.id}\r\n onClick={() => this.selectSubOption(control, option)}\r\n >\r\n <kritzel-icon name={option.icon} size={20}></kritzel-icon>\r\n <span>{option.label}</span>\r\n </button>\r\n ))}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n\r\n // Regular tool control (no sub-options)\r\n return (\r\n <button\r\n class={{\r\n 'kritzel-control': true,\r\n 'selected': this.activeControl?.name === control?.name,\r\n }}\r\n key={control.name}\r\n onClick={_event => this.handleControlClick?.(control)}\r\n >\r\n <kritzel-icon name={control.icon}></kritzel-icon>\r\n </button>\r\n );\r\n }\r\n\r\n if (control.type === 'config' && control.name === this.firstConfig?.name && this.activeControl) {\r\n return (\r\n <div \r\n class={{\r\n 'kritzel-config-container': true,\r\n 'visible': hasConfigUI,\r\n }}\r\n key={control.name}\r\n >\r\n <kritzel-tooltip\r\n ref={el => (this.tooltipRef = el)}\r\n isVisible={this.isTooltipVisible}\r\n anchorElement={this.host.shadowRoot?.querySelector('.kritzel-config-container') as HTMLElement}\r\n onTooltipClosed={() => this.handleTooltipClosed()}\r\n >\r\n <div style={{ width: '294px', height: '100%' }}>\r\n {this.activeControl.name === 'brush' && (\r\n <kritzel-control-brush-config tool={this.activeToolAsBrushTool} onToolChange={event => this.handleToolChange?.(event)}></kritzel-control-brush-config>\r\n )}\r\n\r\n {this.activeControl.name === 'text' && (\r\n <kritzel-control-text-config tool={this.activeToolAsTextTool} onToolChange={event => this.handleToolChange?.(event)}></kritzel-control-text-config>\r\n )}\r\n </div>\r\n </kritzel-tooltip>\r\n\r\n <div\r\n tabIndex={hasConfigUI ? 0 : -1}\r\n class=\"kritzel-config\"\r\n onClick={event => this.handleConfigClick?.(event)}\r\n onKeyDown={event => {\r\n if (event.key === 'Enter') {\r\n this.handleConfigClick?.(event as any);\r\n }\r\n }}\r\n style={{\r\n cursor: 'pointer',\r\n }}\r\n >\r\n {this.activeControl.tool instanceof KritzelBrushTool && (\r\n <div class=\"color-container\">\r\n <kritzel-color\r\n value={this.activeToolAsBrushTool?.color}\r\n size={this.activeToolAsBrushTool?.size}\r\n style={{\r\n borderRadius: '50%',\r\n border: 'none',\r\n }}\r\n ></kritzel-color>\r\n </div>\r\n )}\r\n\r\n {this.activeControl.tool instanceof KritzelTextTool && (\r\n <div class=\"font-container\">\r\n <kritzel-font\r\n fontFamily={this.activeToolAsTextTool?.fontFamily}\r\n size={this.activeToolAsTextTool?.fontSize}\r\n color={this.activeToolAsTextTool?.fontColor}\r\n ></kritzel-font>\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n );\r\n }\r\n })}\r\n </div>\r\n </Host>\r\n );\r\n }\r\n}\r\n"]}
@@ -3,7 +3,9 @@ export const DEFAULT_ENGINE_CONFIG = {
3
3
  activeTool: null,
4
4
  copiedObjects: null,
5
5
  objects: null,
6
+ snapCandidate: null,
6
7
  resizeHandleType: null,
8
+ lineHandleType: null,
7
9
  hasViewportChanged: false,
8
10
  hasObjectsChanged: false,
9
11
  isReady: false,
@@ -17,6 +19,8 @@ export const DEFAULT_ENGINE_CONFIG = {
17
19
  isRotating: false,
18
20
  isRotationHandleHovered: false,
19
21
  isRotationHandleSelected: false,
22
+ isLineHandleSelected: false,
23
+ isLineHandleDragging: false,
20
24
  isDragging: false,
21
25
  isDrawing: false,
22
26
  isErasing: false,
@@ -28,7 +32,7 @@ export const DEFAULT_ENGINE_CONFIG = {
28
32
  contextMenuY: 0,
29
33
  skipContextMenu: false,
30
34
  debugInfo: {
31
- showObjectInfo: false,
35
+ showObjectInfo: true,
32
36
  showViewportInfo: false
33
37
  },
34
38
  host: null,
@@ -1 +1 @@
1
- {"version":3,"file":"default-engine-config.js","sourceRoot":"","sources":["../../src/configs/default-engine-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAuB;IACvD,eAAe,EAAE,IAAI;IACrB,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,KAAK;IACzB,iBAAiB,EAAE,KAAK;IACxB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,qBAAqB,EAAE,KAAK;IAC5B,sBAAsB,EAAE,KAAK;IAC7B,UAAU,EAAE,KAAK;IACjB,uBAAuB,EAAE,KAAK;IAC9B,wBAAwB,EAAE,KAAK;IAC/B,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE;QACT,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;KACxB;IACD,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,GAAG;IACnB,QAAQ,EAAE,IAAI,GAAG,EAAwB;IACzC,UAAU,EAAE,EAAE;IACd,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;KACtB;CACF,CAAC","sourcesContent":["import { KritzelEngineState } from \"../interfaces/engine-state.interface\";\r\n\r\nexport const DEFAULT_ENGINE_CONFIG: KritzelEngineState = {\r\n activeWorkspace: null,\r\n activeTool: null,\r\n copiedObjects: null,\r\n objects: null,\r\n resizeHandleType: null,\r\n hasViewportChanged: false,\r\n hasObjectsChanged: false,\r\n isReady: false,\r\n isEnabled: true,\r\n isScaling: false,\r\n isPanning: false,\r\n isSelecting: false,\r\n isResizing: false,\r\n isResizeHandleHovered: false,\r\n isResizeHandleSelected: false,\r\n isRotating: false,\r\n isRotationHandleHovered: false,\r\n isRotationHandleSelected: false,\r\n isDragging: false,\r\n isDrawing: false,\r\n isErasing: false,\r\n isWriting: false,\r\n isCtrlKeyPressed: false,\r\n isContextMenuVisible: false,\r\n contextMenuItems: [],\r\n contextMenuX: 0,\r\n contextMenuY: 0,\r\n skipContextMenu: false,\r\n debugInfo: {\r\n showObjectInfo: false,\r\n showViewportInfo: false\r\n },\r\n host: null,\r\n pointerX: 0,\r\n pointerY: 0,\r\n scale: 1,\r\n scaleMax: 1,\r\n scaleMin: 1,\r\n startX: 0,\r\n startY: 0,\r\n translateX: 0,\r\n translateXMax: 400,\r\n translateXMin: 0,\r\n translateY: 0,\r\n translateYMax: 400,\r\n translateYMin: 0,\r\n viewportWidth: 0,\r\n viewportHeight: 0,\r\n longTouchTimeout: null,\r\n longTouchDelay: 300,\r\n pointers: new Map<number, PointerEvent>(),\r\n workspaces: [],\r\n cursor: {\r\n icon: 'default',\r\n iconActive: 'default'\r\n }\r\n};"]}
1
+ {"version":3,"file":"default-engine-config.js","sourceRoot":"","sources":["../../src/configs/default-engine-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAuB;IACvD,eAAe,EAAE,IAAI;IACrB,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,KAAK;IACzB,iBAAiB,EAAE,KAAK;IACxB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,qBAAqB,EAAE,KAAK;IAC5B,sBAAsB,EAAE,KAAK;IAC7B,UAAU,EAAE,KAAK;IACjB,uBAAuB,EAAE,KAAK;IAC9B,wBAAwB,EAAE,KAAK;IAC/B,oBAAoB,EAAE,KAAK;IAC3B,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE;QACT,cAAc,EAAE,IAAI;QACpB,gBAAgB,EAAE,KAAK;KACxB;IACD,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,GAAG;IACnB,QAAQ,EAAE,IAAI,GAAG,EAAwB;IACzC,UAAU,EAAE,EAAE;IACd,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;KACtB;CACF,CAAC","sourcesContent":["import { KritzelEngineState } from \"../interfaces/engine-state.interface\";\r\n\r\nexport const DEFAULT_ENGINE_CONFIG: KritzelEngineState = {\r\n activeWorkspace: null,\r\n activeTool: null,\r\n copiedObjects: null,\r\n objects: null,\r\n snapCandidate: null,\r\n resizeHandleType: null,\r\n lineHandleType: null,\r\n hasViewportChanged: false,\r\n hasObjectsChanged: false,\r\n isReady: false,\r\n isEnabled: true,\r\n isScaling: false,\r\n isPanning: false,\r\n isSelecting: false,\r\n isResizing: false,\r\n isResizeHandleHovered: false,\r\n isResizeHandleSelected: false,\r\n isRotating: false,\r\n isRotationHandleHovered: false,\r\n isRotationHandleSelected: false,\r\n isLineHandleSelected: false,\r\n isLineHandleDragging: false,\r\n isDragging: false,\r\n isDrawing: false,\r\n isErasing: false,\r\n isWriting: false,\r\n isCtrlKeyPressed: false,\r\n isContextMenuVisible: false,\r\n contextMenuItems: [],\r\n contextMenuX: 0,\r\n contextMenuY: 0,\r\n skipContextMenu: false,\r\n debugInfo: {\r\n showObjectInfo: true,\r\n showViewportInfo: false\r\n },\r\n host: null,\r\n pointerX: 0,\r\n pointerY: 0,\r\n scale: 1,\r\n scaleMax: 1,\r\n scaleMin: 1,\r\n startX: 0,\r\n startY: 0,\r\n translateX: 0,\r\n translateXMax: 400,\r\n translateXMin: 0,\r\n translateY: 0,\r\n translateYMax: 400,\r\n translateYMin: 0,\r\n viewportWidth: 0,\r\n viewportHeight: 0,\r\n longTouchTimeout: null,\r\n longTouchDelay: 300,\r\n pointers: new Map<number, PointerEvent>(),\r\n workspaces: [],\r\n cursor: {\r\n icon: 'default',\r\n iconActive: 'default'\r\n }\r\n};"]}
@@ -0,0 +1,34 @@
1
+ export const DEFAULT_LINE_TOOL_CONFIG = {
2
+ color: '#000000',
3
+ size: 4,
4
+ palette: [
5
+ '#000000',
6
+ '#ff5252',
7
+ '#ffbc00',
8
+ '#00c853',
9
+ '#0000FF',
10
+ '#d500f9',
11
+ '#fafafa',
12
+ '#a52714',
13
+ '#ee8100',
14
+ '#558b2f',
15
+ '#01579b',
16
+ '#8e24aa',
17
+ '#90a4ae',
18
+ '#ff4081',
19
+ '#ff6e40',
20
+ '#aeea00',
21
+ '#304ffe',
22
+ '#7c4dff',
23
+ '#cfd8dc',
24
+ '#f8bbd0',
25
+ '#ffccbc',
26
+ '#f0f4c3',
27
+ '#b3e5fc',
28
+ '#e1bee7',
29
+ ],
30
+ arrows: {
31
+ end: { enabled: true, style: 'triangle' },
32
+ },
33
+ };
34
+ //# sourceMappingURL=default-line-tool.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-line-tool.config.js","sourceRoot":"","sources":["../../src/configs/default-line-tool.config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAA0B;IAC7D,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,CAAC;IACP,OAAO,EAAE;QACP,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,MAAM,EAAE;QACN,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE;KAC1C;CACF,CAAC","sourcesContent":["import { KritzelLineToolConfig } from '../interfaces/toolbar-control.interface';\r\n\r\nexport const DEFAULT_LINE_TOOL_CONFIG: KritzelLineToolConfig = {\r\n color: '#000000',\r\n size: 4,\r\n palette: [\r\n '#000000',\r\n '#ff5252',\r\n '#ffbc00',\r\n '#00c853',\r\n '#0000FF',\r\n '#d500f9',\r\n '#fafafa',\r\n '#a52714',\r\n '#ee8100',\r\n '#558b2f',\r\n '#01579b',\r\n '#8e24aa',\r\n '#90a4ae',\r\n '#ff4081',\r\n '#ff6e40',\r\n '#aeea00',\r\n '#304ffe',\r\n '#7c4dff',\r\n '#cfd8dc',\r\n '#f8bbd0',\r\n '#ffccbc',\r\n '#f0f4c3',\r\n '#b3e5fc',\r\n '#e1bee7',\r\n ],\r\n arrows: {\r\n end: { enabled: true, style: 'triangle' },\r\n },\r\n};\r\n"]}
@@ -0,0 +1,26 @@
1
+ import { ShapeType } from "../enums/shape-type.enum";
2
+ export const DEFAULT_SHAPE_CONFIG = {
3
+ shapeType: ShapeType.Rectangle,
4
+ fillColor: 'transparent',
5
+ strokeColor: '#000000',
6
+ strokeWidth: 4,
7
+ fontColor: '#000000',
8
+ fontSize: 16,
9
+ fontFamily: 'Arial',
10
+ palette: [
11
+ '#000000',
12
+ '#ff5252',
13
+ '#ffbc00',
14
+ '#00c853',
15
+ '#0000FF',
16
+ '#d500f9',
17
+ '#fafafa',
18
+ '#a52714',
19
+ '#ee8100',
20
+ '#558b2f',
21
+ '#01579b',
22
+ '#8e24aa',
23
+ '#90a4ae',
24
+ ],
25
+ };
26
+ //# sourceMappingURL=default-shape-tool.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-shape-tool.config.js","sourceRoot":"","sources":["../../src/configs/default-shape-tool.config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,SAAS,EAAE,SAAS,CAAC,SAAS;IAC9B,SAAS,EAAE,aAAa;IACxB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,OAAO;IACnB,OAAO,EAAE;QACP,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;CACF,CAAC","sourcesContent":["import { KritzelShapeToolConfig } from \"../interfaces/toolbar-control.interface\";\r\nimport { ShapeType } from \"../enums/shape-type.enum\";\r\n\r\nexport const DEFAULT_SHAPE_CONFIG: KritzelShapeToolConfig = {\r\n shapeType: ShapeType.Rectangle,\r\n fillColor: 'transparent',\r\n strokeColor: '#000000',\r\n strokeWidth: 4,\r\n fontColor: '#000000',\r\n fontSize: 16,\r\n fontFamily: 'Arial',\r\n palette: [\r\n '#000000',\r\n '#ff5252',\r\n '#ffbc00',\r\n '#00c853',\r\n '#0000FF',\r\n '#d500f9',\r\n '#fafafa',\r\n '#a52714',\r\n '#ee8100',\r\n '#558b2f',\r\n '#01579b',\r\n '#8e24aa',\r\n '#90a4ae',\r\n ],\r\n};\r\n"]}
@@ -0,0 +1,7 @@
1
+ export var ShapeType;
2
+ (function (ShapeType) {
3
+ ShapeType["Rectangle"] = "rectangle";
4
+ ShapeType["Ellipse"] = "ellipse";
5
+ ShapeType["Triangle"] = "triangle";
6
+ })(ShapeType || (ShapeType = {}));
7
+ //# sourceMappingURL=shape-type.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape-type.enum.js","sourceRoot":"","sources":["../../src/enums/shape-type.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,gCAAmB,CAAA;IACnB,kCAAqB,CAAA;AACvB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB","sourcesContent":["export enum ShapeType {\r\n Rectangle = 'rectangle',\r\n Ellipse = 'ellipse',\r\n Triangle = 'triangle',\r\n}\r\n"]}
@@ -49,5 +49,102 @@ export class KritzelGeometryHelper {
49
49
  const u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;
50
50
  return t >= 0 && t <= 1 && u >= 0 && u <= 1;
51
51
  }
52
+ /**
53
+ * Finds the intersection point between a line segment and a line segment.
54
+ * Returns the intersection point or null if no intersection.
55
+ */
56
+ static getLineIntersectionPoint(p1a, p1b, p2a, p2b) {
57
+ const det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);
58
+ if (det === 0) {
59
+ return null; // Lines are parallel
60
+ }
61
+ const t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;
62
+ const u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;
63
+ if (t >= 0 && t <= 1 && u >= 0 && u <= 1) {
64
+ return {
65
+ x: p1a.x + t * (p1b.x - p1a.x),
66
+ y: p1a.y + t * (p1b.y - p1a.y)
67
+ };
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * Finds the closest intersection point between a line segment (from lineStart to lineEnd)
73
+ * and a polygon. Returns the intersection point closest to lineStart, or null if no intersection.
74
+ */
75
+ static getLinePolygonIntersection(lineStart, lineEnd, polygon) {
76
+ const points = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];
77
+ let closestIntersection = null;
78
+ let closestDistance = Infinity;
79
+ for (let i = 0; i < points.length; i++) {
80
+ const edgeStart = points[i];
81
+ const edgeEnd = points[(i + 1) % points.length];
82
+ const intersection = this.getLineIntersectionPoint(lineStart, lineEnd, edgeStart, edgeEnd);
83
+ if (intersection) {
84
+ const distance = Math.sqrt(Math.pow(intersection.x - lineStart.x, 2) +
85
+ Math.pow(intersection.y - lineStart.y, 2));
86
+ if (distance < closestDistance) {
87
+ closestDistance = distance;
88
+ closestIntersection = intersection;
89
+ }
90
+ }
91
+ }
92
+ return closestIntersection;
93
+ }
94
+ /**
95
+ * Generates a polygon approximation of an ellipse.
96
+ * @param centerX - X coordinate of ellipse center
97
+ * @param centerY - Y coordinate of ellipse center
98
+ * @param rx - Horizontal radius
99
+ * @param ry - Vertical radius
100
+ * @param segments - Number of segments (more = smoother approximation)
101
+ * @param rotation - Optional rotation angle in radians
102
+ */
103
+ static getEllipsePolygonApproximation(centerX, centerY, rx, ry, segments = 32, rotation = 0) {
104
+ const points = [];
105
+ const cos = Math.cos(rotation);
106
+ const sin = Math.sin(rotation);
107
+ for (let i = 0; i < segments; i++) {
108
+ const angle = (2 * Math.PI * i) / segments;
109
+ // Point on unrotated ellipse
110
+ const px = rx * Math.cos(angle);
111
+ const py = ry * Math.sin(angle);
112
+ // Apply rotation around center
113
+ const rotatedX = centerX + px * cos - py * sin;
114
+ const rotatedY = centerY + px * sin + py * cos;
115
+ points.push({ x: rotatedX, y: rotatedY });
116
+ }
117
+ return points;
118
+ }
119
+ /**
120
+ * Finds the closest intersection point between a line segment and a polygon
121
+ * defined as an array of points. Returns the intersection closest to lineStart,
122
+ * or null if no intersection.
123
+ */
124
+ static getLinePointsArrayIntersection(lineStart, lineEnd, polygonPoints) {
125
+ let closestIntersection = null;
126
+ let closestDistance = Infinity;
127
+ for (let i = 0; i < polygonPoints.length; i++) {
128
+ const edgeStart = polygonPoints[i];
129
+ const edgeEnd = polygonPoints[(i + 1) % polygonPoints.length];
130
+ const intersection = this.getLineIntersectionPoint(lineStart, lineEnd, edgeStart, edgeEnd);
131
+ if (intersection) {
132
+ const distance = Math.sqrt(Math.pow(intersection.x - lineStart.x, 2) +
133
+ Math.pow(intersection.y - lineStart.y, 2));
134
+ if (distance < closestDistance) {
135
+ closestDistance = distance;
136
+ closestIntersection = intersection;
137
+ }
138
+ }
139
+ }
140
+ return closestIntersection;
141
+ }
142
+ /**
143
+ * Checks if a point is inside a polygon defined as an array of points.
144
+ * This is a convenience wrapper that works with arbitrary polygon point arrays.
145
+ */
146
+ static isPointInPolygonPoints(point, polygonPoints) {
147
+ return this.isPointInPolygon(point, polygonPoints);
148
+ }
52
149
  }
53
150
  //# sourceMappingURL=geometry.helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.helper.js","sourceRoot":"","sources":["../../src/helpers/geometry.helper.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAC,mBAAmB,CAAC,QAAwB,EAAE,QAAwB;QAC7E,+DAA+D;QAC/D,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjG,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEjG,uDAAuD;QACvD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,O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G,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACxF,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAEzF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACH","sourcesContent":["import { KritzelPoint } from \"../interfaces/point.interface\";\r\nimport { KritzelPolygon } from \"../interfaces/polygon.interface\";\r\n\r\nexport class KritzelGeometryHelper {\r\n\t static doPolygonsIntersect(polygon1: KritzelPolygon, polygon2: KritzelPolygon): boolean {\r\n\t\t// 1. Convert polygons to array of points for easier processing\r\n\t\tconst points1 = [polygon1.bottomLeft, polygon1.bottomRight, polygon1.topRight, polygon1.topLeft];\r\n\t\tconst points2 = [polygon2.bottomLeft, polygon2.bottomRight, polygon2.topRight, polygon2.topLeft];\r\n\t\r\n\t\t// 2. Check if any point of polygon1 is inside polygon2\r\n\t\tfor (const point of points1) {\r\n\t\t if (this.isPointInPolygon(point, points2)) {\r\n\t\t\treturn true;\r\n\t\t }\r\n\t\t}\r\n\t\r\n\t\t// 3. Check if any point of polygon2 is inside polygon1\r\n\t\tfor (const point of points2) {\r\n\t\t if (this.isPointInPolygon(point, points1)) {\r\n\t\t\treturn true;\r\n\t\t }\r\n\t\t}\r\n\t\r\n\t\t// 4. Check for edge intersections (more complex)\r\n\t\tfor (let i = 0; i < points1.length; i++) {\r\n\t\t const p1a = points1[i];\r\n\t\t const p1b = points1[(i + 1) % points1.length]; // Wrap around to the first point\r\n\t\r\n\t\t for (let j = 0; j < points2.length; j++) {\r\n\t\t\tconst p2a = points2[j];\r\n\t\t\tconst p2b = points2[(j + 1) % points2.length];\r\n\t\r\n\t\t\tif (this.intersectLines(p1a, p1b, p2a, p2b)) {\r\n\t\t\t return true;\r\n\t\t\t}\r\n\t\t }\r\n\t\t}\r\n\t\r\n\t\treturn false; // No intersection found\r\n\t }\r\n\t\r\n\t static isPointInPolygon(point: KritzelPoint, polygon: KritzelPoint[]): boolean {\r\n\t\tlet inside = false;\r\n\t\tfor (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\r\n\t\t const xi = polygon[i].x,\r\n\t\t\tyi = polygon[i].y;\r\n\t\t const xj = polygon[j].x,\r\n\t\t\tyj = polygon[j].y;\r\n\t\r\n\t\t const intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;\r\n\t\t if (intersect) inside = !inside;\r\n\t\t}\r\n\t\treturn inside;\r\n\t }\r\n\t\r\n\t static intersectLines(p1a: KritzelPoint, p1b: KritzelPoint, p2a: KritzelPoint, p2b: KritzelPoint): boolean {\r\n\t\tconst det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);\r\n\t\tif (det === 0) {\r\n\t\t return false; // Lines are parallel\r\n\t\t}\r\n\t\r\n\t\tconst t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;\r\n\t\tconst u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;\r\n\t\r\n\t\treturn t >= 0 && t <= 1 && u >= 0 && u <= 1;\r\n\t }\r\n}\r\n"]}
1
+ {"version":3,"file":"geometry.helper.js","sourceRoot":"","sources":["../../src/helpers/geometry.helper.ts"],"names":[],"m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Aa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;YAE9D,MAAM,YAAY,GAAG,IAAI,CAAC,wBAAwB,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC3F,IAAI,YAAY,EAAE,CAAC;gBAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CACzB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;oBACzC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CACzC,CAAC;gBACF,IAAI,QAAQ,GAAG,eAAe,EAAE,CAAC;oBAChC,eAAe,GAAG,QAAQ,CAAC;oBAC3B,mBAAmB,GAAG,YAAY,CAAC;gBACpC,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,sBAAsB,CAAC,KAAmB,EAAE,aAA6B;QAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACpD,CAAC;CACD","sourcesContent":["import { KritzelPoint } from \"../interfaces/point.interface\";\r\nimport { KritzelPolygon } from \"../interfaces/polygon.interface\";\r\n\r\nexport class KritzelGeometryHelper {\r\n\tstatic doPolygonsIntersect(polygon1: KritzelPolygon, polygon2: KritzelPolygon): boolean {\r\n\t\t// 1. Convert polygons to array of points for easier processing\r\n\t\tconst points1 = [polygon1.bottomLeft, polygon1.bottomRight, polygon1.topRight, polygon1.topLeft];\r\n\t\tconst points2 = [polygon2.bottomLeft, polygon2.bottomRight, polygon2.topRight, polygon2.topLeft];\r\n\r\n\t\t// 2. Check if any point of polygon1 is inside polygon2\r\n\t\tfor (const point of points1) {\r\n\t\t\tif (this.isPointInPolygon(point, points2)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// 3. Check if any point of polygon2 is inside polygon1\r\n\t\tfor (const point of points2) {\r\n\t\t\tif (this.isPointInPolygon(point, points1)) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// 4. Check for edge intersections (more complex)\r\n\t\tfor (let i = 0; i < points1.length; i++) {\r\n\t\t\tconst p1a = points1[i];\r\n\t\t\tconst p1b = points1[(i + 1) % points1.length]; // Wrap around to the first point\r\n\r\n\t\t\tfor (let j = 0; j < points2.length; j++) {\r\n\t\t\t\tconst p2a = points2[j];\r\n\t\t\t\tconst p2b = points2[(j + 1) % points2.length];\r\n\r\n\t\t\t\tif (this.intersectLines(p1a, p1b, p2a, p2b)) {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false; // No intersection found\r\n\t}\r\n\r\n\tstatic isPointInPolygon(point: KritzelPoint, polygon: KritzelPoint[]): boolean {\r\n\t\tlet inside = false;\r\n\t\tfor (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\r\n\t\t\tconst xi = polygon[i].x,\r\n\t\t\t\tyi = polygon[i].y;\r\n\t\t\tconst xj = polygon[j].x,\r\n\t\t\t\tyj = polygon[j].y;\r\n\r\n\t\t\tconst intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;\r\n\t\t\tif (intersect) inside = !inside;\r\n\t\t}\r\n\t\treturn inside;\r\n\t}\r\n\r\n\tstatic intersectLines(p1a: KritzelPoint, p1b: KritzelPoint, p2a: KritzelPoint, p2b: KritzelPoint): boolean {\r\n\t\tconst det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);\r\n\t\tif (det === 0) {\r\n\t\t\treturn false; // Lines are parallel\r\n\t\t}\r\n\r\n\t\tconst t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;\r\n\t\tconst u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;\r\n\r\n\t\treturn t >= 0 && t <= 1 && u >= 0 && u <= 1;\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the intersection point between a line segment and a line segment.\r\n\t * Returns the intersection point or null if no intersection.\r\n\t */\r\n\tstatic getLineIntersectionPoint(p1a: KritzelPoint, p1b: KritzelPoint, p2a: KritzelPoint, p2b: KritzelPoint): KritzelPoint | null {\r\n\t\tconst det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);\r\n\t\tif (det === 0) {\r\n\t\t\treturn null; // Lines are parallel\r\n\t\t}\r\n\r\n\t\tconst t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;\r\n\t\tconst u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;\r\n\r\n\t\tif (t >= 0 && t <= 1 && u >= 0 && u <= 1) {\r\n\t\t\treturn {\r\n\t\t\t\tx: p1a.x + t * (p1b.x - p1a.x),\r\n\t\t\t\ty: p1a.y + t * (p1b.y - p1a.y)\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the closest intersection point between a line segment (from lineStart to lineEnd)\r\n\t * and a polygon. Returns the intersection point closest to lineStart, or null if no intersection.\r\n\t */\r\n\tstatic getLinePolygonIntersection(lineStart: KritzelPoint, lineEnd: KritzelPoint, polygon: KritzelPolygon): KritzelPoint | null {\r\n\t\tconst points = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];\r\n\t\tlet closestIntersection: KritzelPoint | null = null;\r\n\t\tlet closestDistance = Infinity;\r\n\r\n\t\tfor (let i = 0; i < points.length; i++) {\r\n\t\t\tconst edgeStart = points[i];\r\n\t\t\tconst edgeEnd = points[(i + 1) % points.length];\r\n\r\n\t\t\tconst intersection = this.getLineIntersectionPoint(lineStart, lineEnd, edgeStart, edgeEnd);\r\n\t\t\tif (intersection) {\r\n\t\t\t\tconst distance = Math.sqrt(\r\n\t\t\t\t\tMath.pow(intersection.x - lineStart.x, 2) +\r\n\t\t\t\t\tMath.pow(intersection.y - lineStart.y, 2)\r\n\t\t\t\t);\r\n\t\t\t\tif (distance < closestDistance) {\r\n\t\t\t\t\tclosestDistance = distance;\r\n\t\t\t\t\tclosestIntersection = intersection;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn closestIntersection;\r\n\t}\r\n\r\n\t/**\r\n\t * Generates a polygon approximation of an ellipse.\r\n\t * @param centerX - X coordinate of ellipse center\r\n\t * @param centerY - Y coordinate of ellipse center \r\n\t * @param rx - Horizontal radius\r\n\t * @param ry - Vertical radius\r\n\t * @param segments - Number of segments (more = smoother approximation)\r\n\t * @param rotation - Optional rotation angle in radians\r\n\t */\r\n\tstatic getEllipsePolygonApproximation(\r\n\t\tcenterX: number,\r\n\t\tcenterY: number,\r\n\t\trx: number,\r\n\t\try: number,\r\n\t\tsegments: number = 32,\r\n\t\trotation: number = 0\r\n\t): KritzelPoint[] {\r\n\t\tconst points: KritzelPoint[] = [];\r\n\t\tconst cos = Math.cos(rotation);\r\n\t\tconst sin = Math.sin(rotation);\r\n\r\n\t\tfor (let i = 0; i < segments; i++) {\r\n\t\t\tconst angle = (2 * Math.PI * i) / segments;\r\n\t\t\t// Point on unrotated ellipse\r\n\t\t\tconst px = rx * Math.cos(angle);\r\n\t\t\tconst py = ry * Math.sin(angle);\r\n\t\t\t// Apply rotation around center\r\n\t\t\tconst rotatedX = centerX + px * cos - py * sin;\r\n\t\t\tconst rotatedY = centerY + px * sin + py * cos;\r\n\t\t\tpoints.push({ x: rotatedX, y: rotatedY });\r\n\t\t}\r\n\r\n\t\treturn points;\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the closest intersection point between a line segment and a polygon \r\n\t * defined as an array of points. Returns the intersection closest to lineStart,\r\n\t * or null if no intersection.\r\n\t */\r\n\tstatic getLinePointsArrayIntersection(\r\n\t\tlineStart: KritzelPoint,\r\n\t\tlineEnd: KritzelPoint,\r\n\t\tpolygonPoints: KritzelPoint[]\r\n\t): KritzelPoint | null {\r\n\t\tlet closestIntersection: KritzelPoint | null = null;\r\n\t\tlet closestDistance = Infinity;\r\n\r\n\t\tfor (let i = 0; i < polygonPoints.length; i++) {\r\n\t\t\tconst edgeStart = polygonPoints[i];\r\n\t\t\tconst edgeEnd = polygonPoints[(i + 1) % polygonPoints.length];\r\n\r\n\t\t\tconst intersection = this.getLineIntersectionPoint(lineStart, lineEnd, edgeStart, edgeEnd);\r\n\t\t\tif (intersection) {\r\n\t\t\t\tconst distance = Math.sqrt(\r\n\t\t\t\t\tMath.pow(intersection.x - lineStart.x, 2) +\r\n\t\t\t\t\tMath.pow(intersection.y - lineStart.y, 2)\r\n\t\t\t\t);\r\n\t\t\t\tif (distance < closestDistance) {\r\n\t\t\t\t\tclosestDistance = distance;\r\n\t\t\t\t\tclosestIntersection = intersection;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn closestIntersection;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if a point is inside a polygon defined as an array of points.\r\n\t * This is a convenience wrapper that works with arbitrary polygon point arrays.\r\n\t */\r\n\tstatic isPointInPolygonPoints(point: KritzelPoint, polygonPoints: KritzelPoint[]): boolean {\r\n\t\treturn this.isPointInPolygon(point, polygonPoints);\r\n\t}\r\n}\r\n\r\n"]}
@@ -10,7 +10,9 @@
10
10
  export * from './classes/objects/text.class';
11
11
  export * from './classes/objects/path.class';
12
12
  export * from './classes/objects/image.class';
13
+ export * from './classes/objects/line.class';
13
14
  export * from './classes/tools/brush-tool.class';
15
+ export * from './classes/tools/line-tool.class';
14
16
  export * from './classes/tools/eraser-tool.class';
15
17
  export * from './classes/tools/image-tool.class';
16
18
  export * from './classes/tools/text-tool.class';
@@ -22,10 +24,13 @@ export * from './classes/providers/websocket-sync-provider.class';
22
24
  export * from './classes/providers/hocuspocus-sync-provider.class';
23
25
  export * from './classes/structures/app-state-map.structure';
24
26
  export * from './classes/core/workspace.class';
27
+ export * from './classes/managers/anchor.manager';
25
28
  export * from './interfaces/toolbar-control.interface';
26
29
  export * from './interfaces/menu-item.interface';
27
30
  export * from './interfaces/sync-provider.interface';
28
31
  export * from './interfaces/sync-config.interface';
32
+ export * from './interfaces/anchor.interface';
29
33
  export * from './configs/default-brush-tool.config';
30
34
  export * from './configs/default-text-tool.config';
35
+ export * from './configs/default-line-tool.config';
31
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AAErD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,8CAA8C,CAAC;AAE7D,cAAc,gCAAgC,CAAC;AAE/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC","sourcesContent":["/**\r\n * @fileoverview entry point for your component library\r\n *\r\n * This is the entry point for your component library. Use this file to export utilities,\r\n * constants or data structure that accompany your components.\r\n *\r\n * DO NOT use this file to export your components. Instead, use the recommended approaches\r\n * to consume components of this package as outlined in the `README.md`.\r\n */\r\n\r\nexport type * from './components';\r\n\r\nexport * from './classes/objects/text.class';\r\nexport * from './classes/objects/path.class';\r\nexport * from './classes/objects/image.class';\r\n\r\nexport * from './classes/tools/brush-tool.class';\r\nexport * from './classes/tools/eraser-tool.class';\r\nexport * from './classes/tools/image-tool.class';\r\nexport * from './classes/tools/text-tool.class';\r\n\r\nexport * from './helpers/cursor.helper';\r\nexport * from './classes/tools/selection-tool.class';\r\n\r\nexport * from './classes/providers/broadcast-sync-provider.class';\r\nexport * from './classes/providers/indexeddb-sync-provider.class';\r\nexport * from './classes/providers/websocket-sync-provider.class';\r\nexport * from './classes/providers/hocuspocus-sync-provider.class';\r\n\r\nexport * from './classes/structures/app-state-map.structure';\r\n\r\nexport * from './classes/core/workspace.class';\r\n\r\nexport * from './interfaces/toolbar-control.interface';\r\nexport * from './interfaces/menu-item.interface';\r\nexport * from './interfaces/sync-provider.interface';\r\nexport * from './interfaces/sync-config.interface';\r\n\r\nexport * from './configs/default-brush-tool.config';\r\nexport * from './configs/default-text-tool.config';\r\n\r\n\r\n\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AAErD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AAEnE,cAAc,8CAA8C,CAAC;AAE7D,cAAc,gCAAgC,CAAC;AAE/C,cAAc,mCAAmC,CAAC;AAElD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC","sourcesContent":["/**\r\n * @fileoverview entry point for your component library\r\n *\r\n * This is the entry point for your component library. Use this file to export utilities,\r\n * constants or data structure that accompany your components.\r\n *\r\n * DO NOT use this file to export your components. Instead, use the recommended approaches\r\n * to consume components of this package as outlined in the `README.md`.\r\n */\r\n\r\nexport type * from './components';\r\n\r\nexport * from './classes/objects/text.class';\r\nexport * from './classes/objects/path.class';\r\nexport * from './classes/objects/image.class';\r\nexport * from './classes/objects/line.class';\r\n\r\nexport * from './classes/tools/brush-tool.class';\r\nexport * from './classes/tools/line-tool.class';\r\nexport * from './classes/tools/eraser-tool.class';\r\nexport * from './classes/tools/image-tool.class';\r\nexport * from './classes/tools/text-tool.class';\r\n\r\nexport * from './helpers/cursor.helper';\r\nexport * from './classes/tools/selection-tool.class';\r\n\r\nexport * from './classes/providers/broadcast-sync-provider.class';\r\nexport * from './classes/providers/indexeddb-sync-provider.class';\r\nexport * from './classes/providers/websocket-sync-provider.class';\r\nexport * from './classes/providers/hocuspocus-sync-provider.class';\r\n\r\nexport * from './classes/structures/app-state-map.structure';\r\n\r\nexport * from './classes/core/workspace.class';\r\n\r\nexport * from './classes/managers/anchor.manager';\r\n\r\nexport * from './interfaces/toolbar-control.interface';\r\nexport * from './interfaces/menu-item.interface';\r\nexport * from './interfaces/sync-provider.interface';\r\nexport * from './interfaces/sync-config.interface';\r\nexport * from './interfaces/anchor.interface';\r\n\r\nexport * from './configs/default-brush-tool.config';\r\nexport * from './configs/default-text-tool.config';\r\nexport * from './configs/default-line-tool.config';\r\n\r\n\r\n\r\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=anchor.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.interface.js","sourceRoot":"","sources":["../../src/interfaces/anchor.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Represents an anchor connection from a line endpoint to another object's center.\r\n */\r\nexport interface LineAnchor {\r\n /** The ID of the object that this line endpoint is anchored to */\r\n objectId: string;\r\n}\r\n\r\n/**\r\n * Entry in the anchor index that tracks which lines are anchored to an object.\r\n */\r\nexport interface AnchorIndexEntry {\r\n /** The ID of the line that has an anchor */\r\n lineId: string;\r\n /** Which endpoint of the line is anchored */\r\n endpoint: 'start' | 'end';\r\n}\r\n\r\n/**\r\n * Represents a potential snap target during line endpoint dragging.\r\n */\r\nexport interface SnapTarget {\r\n /** The ID of the object that can be snapped to */\r\n objectId: string;\r\n /** The center X coordinate of the snap target in world coordinates */\r\n centerX: number;\r\n /** The center Y coordinate of the snap target in world coordinates */\r\n centerY: number;\r\n}\r\n\r\n/**\r\n * Represents the current snap candidate state during dragging.\r\n */\r\nexport interface SnapCandidate {\r\n /** The ID of the object being snapped to */\r\n objectId: string;\r\n /** Which endpoint of the line is being snapped */\r\n endpoint: 'start' | 'end';\r\n /** The center X coordinate for the snap indicator */\r\n centerX: number;\r\n /** The center Y coordinate for the snap indicator */\r\n centerY: number;\r\n /** The X coordinate of the line endpoint (world coords) */\r\n lineEndpointX: number;\r\n /** The Y coordinate of the line endpoint (world coords) */\r\n lineEndpointY: number;\r\n /** The X coordinate where the line intersects the object's edge (world coords) */\r\n edgeX?: number;\r\n /** The Y coordinate where the line intersects the object's edge (world coords) */\r\n edgeY?: number;\r\n /** The stroke color of the line being snapped */\r\n lineStroke?: string;\r\n /** The stroke width of the line being snapped */\r\n lineStrokeWidth?: number;\r\n /** Arrow offset to apply to the edge point (in world coords) */\r\n arrowOffset?: number;\r\n /** Arrow style for the snapping endpoint */\r\n arrowStyle?: 'triangle' | 'open' | 'diamond' | 'circle';\r\n /** Arrow fill color */\r\n arrowFill?: string;\r\n /** The X coordinate of the control point (world coords), if any */\r\n controlX?: number;\r\n /** The Y coordinate of the control point (world coords), if any */\r\n controlY?: number;\r\n /** The t parameter on the curve where the edge intersection occurs (0-1) */\r\n t?: number;\r\n}\r\n\r\n/**\r\n * Visualization data for rendering anchor indicator lines.\r\n */\r\nexport interface AnchorVisualization {\r\n /** The X coordinate where the line intersects the object's edge */\r\n edgeX: number;\r\n /** The Y coordinate where the line intersects the object's edge */\r\n edgeY: number;\r\n /** The center X coordinate of the anchored object */\r\n centerX: number;\r\n /** The center Y coordinate of the anchored object */\r\n centerY: number;\r\n /** Optional SVG path describing the curved dashed segment */\r\n pathD?: string;\r\n}\r\n\r\n/**\r\n * Render data for anchor lines visualization (dashed lines from edge to center).\r\n */\r\nexport interface AnchorLinesRenderData {\r\n /** The stroke width of the line */\r\n lineStrokeWidth: number;\r\n /** The stroke width for the indicator circle */\r\n indicatorStrokeWidth: string;\r\n /** The dash array for the dashed line */\r\n dashArray: string;\r\n /** The radius of the indicator circle */\r\n indicatorRadius: number;\r\n /** Visualization data for the start anchor, if any */\r\n startAnchorViz: AnchorVisualization | null;\r\n /** Visualization data for the end anchor, if any */\r\n endAnchorViz: AnchorVisualization | null;\r\n}\r\n\r\n/**\r\n * Render data for snap indicator visualization.\r\n */\r\nexport interface SnapIndicatorRenderData {\r\n /** The radius of the indicator circle */\r\n indicatorRadius: number;\r\n /** The stroke width for the indicator circle */\r\n indicatorStrokeWidth: string;\r\n /** The stroke width for the line */\r\n lineStrokeWidth: string;\r\n /** The dash array for the dashed line */\r\n dashArray: string;\r\n /** The stroke color of the line */\r\n lineStroke: string;\r\n /** The center X coordinate */\r\n centerX: number;\r\n /** The center Y coordinate */\r\n centerY: number;\r\n /** The X coordinate of the line endpoint */\r\n lineEndpointX: number;\r\n /** The Y coordinate of the line endpoint */\r\n lineEndpointY: number;\r\n /** The X coordinate where the line intersects the object's edge */\r\n edgeX?: number;\r\n /** The Y coordinate where the line intersects the object's edge */\r\n edgeY?: number;\r\n /** Arrow offset to apply to the edge point */\r\n arrowOffset?: number;\r\n /** Arrow style for the snapping endpoint */\r\n arrowStyle?: 'triangle' | 'open' | 'diamond' | 'circle';\r\n /** Arrow fill color */\r\n arrowFill?: string;\r\n /** The X coordinate for the end of the solid line part (accounting for arrow offset) */\r\n solidLineEndX?: number;\r\n /** The Y coordinate for the end of the solid line part (accounting for arrow offset) */\r\n solidLineEndY?: number;\r\n /** SVG points string for the arrow head at the edge */\r\n arrowPoints?: string;\r\n /** SVG path d string for the dashed line part (if curved) */\r\n snapLinePath?: string;\r\n}\r\n\r\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=arrow-head.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrow-head.interface.js","sourceRoot":"","sources":["../../src/interfaces/arrow-head.interface.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Arrow head style types\r\n */\r\nexport type ArrowHeadStyle = 'triangle' | 'open' | 'diamond' | 'circle';\r\n\r\n/**\r\n * Configuration for a single arrow head\r\n */\r\nexport interface ArrowHeadConfig {\r\n /** Whether to display the arrow head */\r\n enabled: boolean;\r\n /** Arrow head style (defaults to 'triangle') */\r\n style?: ArrowHeadStyle;\r\n /** Size of the arrow head in pixels (defaults to strokeWidth * 3) */\r\n size?: number;\r\n /** Fill color (defaults to stroke color of the line) */\r\n fill?: string;\r\n}\r\n\r\n/**\r\n * Configuration for arrow heads at both ends of a line\r\n */\r\nexport interface LineArrowConfig {\r\n /** Arrow head at the start of the line */\r\n start?: ArrowHeadConfig;\r\n /** Arrow head at the end of the line */\r\n end?: ArrowHeadConfig;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"engine-state.interface.js","sourceRoot":"","sources":["../../src/interfaces/engine-state.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { KritzelBaseObject } from \"../classes/objects/base-object.class\";\r\nimport { KritzelObjectMap } from \"../classes/structures/object-map.structure\";\r\nimport { KritzelBaseTool } from \"../classes/tools/base-tool.class\";\r\nimport { KritzelWorkspace } from \"../classes/core/workspace.class\";\r\nimport { KritzelHandleType } from \"../enums/handle-type.enum\";\r\nimport { ContextMenuItem } from \"./context-menu-item.interface\";\r\nimport { KritzelDebugInfo } from \"./debug-info.interface\";\r\n\r\nexport interface KritzelEngineState {\r\n activeWorkspace: KritzelWorkspace;\r\n activeTool: KritzelBaseTool;\r\n copiedObjects?: KritzelBaseObject<any>[];\r\n objects: KritzelObjectMap<KritzelBaseObject<Element>>;\r\n resizeHandleType: KritzelHandleType;\r\n hasViewportChanged: boolean;\r\n hasObjectsChanged: boolean;\r\n isReady: boolean;\r\n isEnabled: boolean;\r\n isScaling: boolean;\r\n isPanning: boolean;\r\n isSelecting: boolean;\r\n isResizing: boolean;\r\n isResizeHandleHovered: boolean;\r\n isResizeHandleSelected: boolean;\r\n isRotating: boolean;\r\n isRotationHandleHovered: boolean;\r\n isRotationHandleSelected: boolean;\r\n isDragging: boolean;\r\n isDrawing: boolean;\r\n isErasing: boolean;\r\n isWriting: boolean;\r\n isCtrlKeyPressed: boolean;\r\n isContextMenuVisible: boolean;\r\n contextMenuItems: ContextMenuItem[];\r\n contextMenuX: number;\r\n contextMenuY: number;\r\n skipContextMenu: boolean;\r\n debugInfo: KritzelDebugInfo;\r\n host: HTMLElement;\r\n pointerX: number;\r\n pointerY: number;\r\n scale: number;\r\n scaleMax: number;\r\n scaleMin: number;\r\n startX: number;\r\n startY: number;\r\n translateX: number;\r\n translateXMax: number;\r\n translateXMin: number;\r\n translateY: number;\r\n translateYMax: number;\r\n translateYMin: number;\r\n viewportWidth: number;\r\n viewportHeight: number;\r\n longTouchTimeout: number;\r\n longTouchDelay: number;\r\n pointers: Map<number, PointerEvent>;\r\n workspaces: KritzelWorkspace[];\r\n cursor: {\r\n icon: string;\r\n iconActive?: string;\r\n rotation?: number;\r\n }\r\n}"]}
1
+ {"version":3,"file":"engine-state.interface.js","sourceRoot":"","sources":["../../src/interfaces/engine-state.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { KritzelBaseObject } from \"../classes/objects/base-object.class\";\r\nimport { KritzelObjectMap } from \"../classes/structures/object-map.structure\";\r\nimport { KritzelBaseTool } from \"../classes/tools/base-tool.class\";\r\nimport { KritzelWorkspace } from \"../classes/core/workspace.class\";\r\nimport { KritzelHandleType } from \"../enums/handle-type.enum\";\r\nimport { ContextMenuItem } from \"./context-menu-item.interface\";\r\nimport { KritzelDebugInfo } from \"./debug-info.interface\";\r\nimport { LineHandleType } from \"../classes/handlers/line-handle.handler\";\r\nimport { SnapCandidate } from \"./anchor.interface\";\r\n\r\nexport interface KritzelEngineState {\r\n activeWorkspace: KritzelWorkspace;\r\n activeTool: KritzelBaseTool;\r\n copiedObjects?: KritzelBaseObject<any>[];\r\n /** Maps copied object IDs to their original source object IDs (for anchor remapping during paste) */\r\n copiedObjectIdMapping?: Map<string, string>;\r\n objects: KritzelObjectMap<KritzelBaseObject<Element>>;\r\n snapCandidate?: SnapCandidate | null;\r\n resizeHandleType: KritzelHandleType;\r\n lineHandleType: LineHandleType;\r\n hasViewportChanged: boolean;\r\n hasObjectsChanged: boolean;\r\n isReady: boolean;\r\n isEnabled: boolean;\r\n isScaling: boolean;\r\n isPanning: boolean;\r\n isSelecting: boolean;\r\n isResizing: boolean;\r\n isResizeHandleHovered: boolean;\r\n isResizeHandleSelected: boolean;\r\n isRotating: boolean;\r\n isRotationHandleHovered: boolean;\r\n isRotationHandleSelected: boolean;\r\n isLineHandleSelected: boolean;\r\n isLineHandleDragging: boolean;\r\n isDragging: boolean;\r\n isDrawing: boolean;\r\n isErasing: boolean;\r\n isWriting: boolean;\r\n isCtrlKeyPressed: boolean;\r\n isContextMenuVisible: boolean;\r\n contextMenuItems: ContextMenuItem[];\r\n contextMenuX: number;\r\n contextMenuY: number;\r\n skipContextMenu: boolean;\r\n debugInfo: KritzelDebugInfo;\r\n host: HTMLElement;\r\n pointerX: number;\r\n pointerY: number;\r\n scale: number;\r\n scaleMax: number;\r\n scaleMin: number;\r\n startX: number;\r\n startY: number;\r\n translateX: number;\r\n translateXMax: number;\r\n translateXMin: number;\r\n translateY: number;\r\n translateYMax: number;\r\n translateYMin: number;\r\n viewportWidth: number;\r\n viewportHeight: number;\r\n longTouchTimeout: number;\r\n longTouchDelay: number;\r\n pointers: Map<number, PointerEvent>;\r\n workspaces: KritzelWorkspace[];\r\n cursor: {\r\n icon: string;\r\n iconActive?: string;\r\n rotation?: number;\r\n }\r\n}"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=line-options.interface.js.map