kritzel-stencil 0.0.113 → 0.0.115

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 (124) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
  3. package/dist/cjs/index-C2M4eyxF.js +652 -0
  4. package/dist/cjs/index-C2M4eyxF.js.map +1 -0
  5. package/dist/cjs/{index-D62tBCuq.js → index-CXT94beA.js} +111 -109
  6. package/dist/cjs/index-CXT94beA.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +5 -0
  8. package/dist/cjs/index.cjs.js.map +1 -1
  9. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +120 -725
  10. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  11. package/dist/cjs/loader.cjs.js +4 -3
  12. package/dist/cjs/loader.cjs.js.map +1 -1
  13. package/dist/cjs/stencil.cjs.js +5 -4
  14. package/dist/cjs/stencil.cjs.js.map +1 -1
  15. package/dist/collection/classes/handlers/key.handler.js +4 -4
  16. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  17. package/dist/collection/classes/store.class.js +12 -8
  18. package/dist/collection/classes/store.class.js.map +1 -1
  19. package/dist/collection/collection-manifest.json +1 -1
  20. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +214 -1
  21. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  22. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +96 -20
  23. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  24. package/dist/collection/index.js +10 -1
  25. package/dist/collection/index.js.map +1 -1
  26. package/dist/components/index.js +2 -1
  27. package/dist/components/index.js.map +1 -1
  28. package/dist/components/kritzel-brush-style.js +1 -1
  29. package/dist/components/kritzel-color-palette.js +1 -1
  30. package/dist/components/kritzel-color.js +1 -1
  31. package/dist/components/kritzel-context-menu.js +1 -1
  32. package/dist/components/kritzel-control-brush-config.js +1 -1
  33. package/dist/components/kritzel-control-text-config.js +1 -1
  34. package/dist/components/kritzel-controls.js +1 -1
  35. package/dist/components/kritzel-cursor-trail.js +1 -1
  36. package/dist/components/kritzel-dropdown.js +1 -1
  37. package/dist/components/kritzel-editor.js +49 -21
  38. package/dist/components/kritzel-editor.js.map +1 -1
  39. package/dist/components/kritzel-engine.js +1 -1
  40. package/dist/components/kritzel-font-family.js +1 -1
  41. package/dist/components/kritzel-font-size.js +1 -1
  42. package/dist/components/kritzel-font.js +1 -1
  43. package/dist/components/kritzel-icon.js +1 -1
  44. package/dist/components/kritzel-stroke-size.js +1 -1
  45. package/dist/components/kritzel-tooltip.js +1 -1
  46. package/dist/components/kritzel-utility-panel.js +1 -1
  47. package/dist/components/{p-CmckGlXt.js → p-B57pFHwJ.js} +3 -3
  48. package/dist/components/{p-CmckGlXt.js.map → p-B57pFHwJ.js.map} +1 -1
  49. package/dist/components/{p-Ddfewfv9.js → p-B94Na1ee.js} +4 -4
  50. package/dist/components/{p-Ddfewfv9.js.map → p-B94Na1ee.js.map} +1 -1
  51. package/dist/components/{p-Ck2d5Wd1.js → p-BH1Tkwyh.js} +5 -5
  52. package/dist/components/{p-Ck2d5Wd1.js.map → p-BH1Tkwyh.js.map} +1 -1
  53. package/dist/components/{p-DqZOaMbq.js → p-BIlVkMTU.js} +378 -378
  54. package/dist/components/p-BIlVkMTU.js.map +1 -0
  55. package/dist/components/{p-BXJ8s30N.js → p-BtjtAfGW.js} +10 -10
  56. package/dist/components/{p-BXJ8s30N.js.map → p-BtjtAfGW.js.map} +1 -1
  57. package/dist/components/{p-DInF8Iby.js → p-C9FTWNZY.js} +3 -3
  58. package/dist/components/{p-DInF8Iby.js.map → p-C9FTWNZY.js.map} +1 -1
  59. package/dist/components/{p-B7P9QBiE.js → p-C9ZagG9K.js} +4 -4
  60. package/dist/components/{p-B7P9QBiE.js.map → p-C9ZagG9K.js.map} +1 -1
  61. package/dist/components/{p-BmAloSfd.js → p-CRiUM-tD.js} +4 -4
  62. package/dist/components/{p-BmAloSfd.js.map → p-CRiUM-tD.js.map} +1 -1
  63. package/dist/components/{p-BvPTbq7F.js → p-CSSrNLad.js} +3 -3
  64. package/dist/components/{p-BvPTbq7F.js.map → p-CSSrNLad.js.map} +1 -1
  65. package/dist/components/{p-DFhbw-Fr.js → p-CaQ7Iei7.js} +3 -3
  66. package/dist/components/{p-DFhbw-Fr.js.map → p-CaQ7Iei7.js.map} +1 -1
  67. package/dist/components/{p-CPjl7Inl.js → p-D04aTZsR.js} +4 -4
  68. package/dist/components/{p-CPjl7Inl.js.map → p-D04aTZsR.js.map} +1 -1
  69. package/dist/components/{p-maiDeBe9.js → p-DLV-5gE_.js} +9 -9
  70. package/dist/components/{p-maiDeBe9.js.map → p-DLV-5gE_.js.map} +1 -1
  71. package/dist/components/{p-DC8SDK2U.js → p-DoQOtXjT.js} +111 -107
  72. package/dist/components/p-DoQOtXjT.js.map +1 -0
  73. package/dist/components/{p-DieKGjdj.js → p-aZgXbW1r.js} +47 -35
  74. package/dist/components/{p-DieKGjdj.js.map → p-aZgXbW1r.js.map} +1 -1
  75. package/dist/components/{p-DfMdBA8L.js → p-fmNiA3Yr.js} +4 -4
  76. package/dist/components/{p-DfMdBA8L.js.map → p-fmNiA3Yr.js.map} +1 -1
  77. package/dist/components/{p-c6tIpE_t.js → p-h3bqYufZ.js} +3 -3
  78. package/dist/components/{p-c6tIpE_t.js.map → p-h3bqYufZ.js.map} +1 -1
  79. package/dist/components/{p-CZkSABuJ.js → p-ksTCzgsY.js} +3 -3
  80. package/dist/components/{p-CZkSABuJ.js.map → p-ksTCzgsY.js.map} +1 -1
  81. package/dist/components/{p-CFwf2KYj.js → p-mz1ayKXG.js} +17 -17
  82. package/dist/components/{p-CFwf2KYj.js.map → p-mz1ayKXG.js.map} +1 -1
  83. package/dist/components/{p-DHT5gK0E.js → p-yBnfPxIa.js} +4 -4
  84. package/dist/components/{p-DHT5gK0E.js.map → p-yBnfPxIa.js.map} +1 -1
  85. package/dist/esm/app-globals-DQuL1Twl.js +6 -0
  86. package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
  87. package/dist/esm/{index-BOJOOWaP.js → index-CGHvfMWF.js} +112 -109
  88. package/dist/esm/index-CGHvfMWF.js.map +1 -0
  89. package/dist/esm/index-rckCSz7Y.js +641 -0
  90. package/dist/esm/index-rckCSz7Y.js.map +1 -0
  91. package/dist/esm/index.js +1 -1
  92. package/dist/esm/kritzel-brush-style_18.entry.js +62 -667
  93. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  94. package/dist/esm/loader.js +4 -3
  95. package/dist/esm/loader.js.map +1 -1
  96. package/dist/esm/stencil.js +5 -4
  97. package/dist/esm/stencil.js.map +1 -1
  98. package/dist/stencil/index.esm.js +1 -1
  99. package/dist/stencil/loader.esm.js.map +1 -1
  100. package/dist/stencil/p-9394d74e.entry.js +2 -0
  101. package/dist/stencil/p-9394d74e.entry.js.map +1 -0
  102. package/dist/stencil/p-CGHvfMWF.js +3 -0
  103. package/dist/stencil/p-CGHvfMWF.js.map +1 -0
  104. package/dist/stencil/p-DQuL1Twl.js +2 -0
  105. package/dist/stencil/p-DQuL1Twl.js.map +1 -0
  106. package/dist/stencil/p-rckCSz7Y.js +2 -0
  107. package/dist/stencil/p-rckCSz7Y.js.map +1 -0
  108. package/dist/stencil/stencil.esm.js +1 -1
  109. package/dist/stencil/stencil.esm.js.map +1 -1
  110. package/dist/types/classes/store.class.d.ts +4 -4
  111. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +10 -2
  112. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +4 -2
  113. package/dist/types/components.d.ts +13 -4
  114. package/dist/types/index.d.ts +1 -0
  115. package/dist/types/stencil-public-runtime.d.ts +12 -5
  116. package/package.json +1 -1
  117. package/dist/cjs/index-D62tBCuq.js.map +0 -1
  118. package/dist/components/p-DC8SDK2U.js.map +0 -1
  119. package/dist/components/p-DqZOaMbq.js.map +0 -1
  120. package/dist/esm/index-BOJOOWaP.js.map +0 -1
  121. package/dist/stencil/p-BOJOOWaP.js +0 -3
  122. package/dist/stencil/p-BOJOOWaP.js.map +0 -1
  123. package/dist/stencil/p-dc26eb80.entry.js +0 -2
  124. package/dist/stencil/p-dc26eb80.entry.js.map +0 -1
@@ -1,5 +1,81 @@
1
1
  import { K as KritzelMouseButton } from './p-D8W6LE-c.js';
2
2
 
3
+ class KritzelToolRegistry {
4
+ static registerTool(toolName, constructor, store) {
5
+ const toolInstance = new constructor(store);
6
+ toolInstance.name = toolName;
7
+ this.registry[toolName] = toolInstance;
8
+ return toolInstance;
9
+ }
10
+ static getTool(toolName) {
11
+ const toolInstance = this.registry[toolName];
12
+ if (!toolInstance) {
13
+ console.warn(`Unknown tool: ${toolName}`);
14
+ return null;
15
+ }
16
+ return toolInstance;
17
+ }
18
+ }
19
+ KritzelToolRegistry.registry = {};
20
+
21
+ class KritzelBaseTool {
22
+ constructor(store) {
23
+ this.__class__ = this.constructor.name;
24
+ this.name = 'base-tool';
25
+ this._store = store;
26
+ }
27
+ onActivate() {
28
+ // default implementation
29
+ }
30
+ onDeactivate() {
31
+ // default implementation
32
+ }
33
+ handlePointerDown(_event) {
34
+ // default implementation
35
+ }
36
+ handlePointerMove(_event) {
37
+ // default implementation
38
+ }
39
+ handlePointerUp(_event) {
40
+ // default implementation
41
+ }
42
+ handleWheel(_event) {
43
+ // default implementation
44
+ }
45
+ revive(object) {
46
+ Object.assign(this, object);
47
+ return this;
48
+ }
49
+ }
50
+
51
+ class KritzelBaseCommand {
52
+ constructor(store, initiator) {
53
+ var _a, _b;
54
+ this._store = store;
55
+ this.initiator = (_b = (_a = initiator === null || initiator === void 0 ? void 0 : initiator.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'Unknown';
56
+ this.isUndoable = true;
57
+ }
58
+ execute() {
59
+ throw new Error('Method not implemented.');
60
+ }
61
+ undo() {
62
+ throw new Error('Method not implemented.');
63
+ }
64
+ }
65
+
66
+ class AddObjectCommand extends KritzelBaseCommand {
67
+ constructor(store, initiator, object) {
68
+ super(store, initiator);
69
+ this.object = object;
70
+ }
71
+ execute() {
72
+ this._store.state.objectsOctree.insert(this.object);
73
+ }
74
+ undo() {
75
+ this._store.state.objectsOctree.remove(object => object.id === this.object.id);
76
+ }
77
+ }
78
+
3
79
  class KritzelEventHelper {
4
80
  static isRightClick(ev) {
5
81
  return ev.button === KritzelMouseButton.Right;
@@ -57,52 +133,144 @@ class KritzelEventHelper {
57
133
  }
58
134
  }
59
135
 
60
- class KritzelBaseCommand {
61
- constructor(store, initiator) {
62
- var _a, _b;
63
- this._store = store;
64
- this.initiator = (_b = (_a = initiator === null || initiator === void 0 ? void 0 : initiator.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'Unknown';
65
- this.isUndoable = true;
136
+ class KritzelKeyboardHelper {
137
+ static forceHideKeyboard() {
138
+ if (document.activeElement instanceof HTMLElement) {
139
+ document.activeElement.blur();
140
+ }
66
141
  }
67
- execute() {
68
- throw new Error('Method not implemented.');
142
+ static enableInteractiveWidget() {
143
+ const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
144
+ if (meta) {
145
+ let currentContent = meta.getAttribute('content');
146
+ if (!currentContent.includes('interactive-widget=resizes-content')) {
147
+ currentContent += ', interactive-widget=resizes-content';
148
+ }
149
+ meta.setAttribute('content', currentContent);
150
+ }
69
151
  }
70
- undo() {
71
- throw new Error('Method not implemented.');
152
+ static disableInteractiveWidget() {
153
+ const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
154
+ if (meta) {
155
+ let currentContent = meta.getAttribute('content');
156
+ let newContent = currentContent.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g, '');
157
+ newContent = newContent
158
+ .replace(/,(\s*,)+/g, ',')
159
+ .replace(/^,/, '')
160
+ .replace(/,$/, '')
161
+ .trim();
162
+ meta.setAttribute('content', newContent);
163
+ }
72
164
  }
73
165
  }
74
166
 
75
- class AddObjectCommand extends KritzelBaseCommand {
76
- constructor(store, initiator, object) {
77
- super(store, initiator);
78
- this.object = object;
79
- }
80
- execute() {
81
- this._store.state.objectsOctree.insert(this.object);
167
+ class KritzelTextTool extends KritzelBaseTool {
168
+ constructor(store) {
169
+ super(store);
170
+ this.fontFamily = 'Arial';
171
+ this.fontSize = 16;
172
+ this.fontColor = '#000000';
173
+ this.palette = [
174
+ '#000000',
175
+ '#FFFFFF',
176
+ '#FF0000',
177
+ '#00FF00',
178
+ '#0000FF',
179
+ '#FFFF00',
180
+ '#FF00FF',
181
+ '#00FFFF',
182
+ '#808080',
183
+ '#C0C0C0',
184
+ '#800000',
185
+ '#008000',
186
+ '#000080',
187
+ '#808000',
188
+ '#800080',
189
+ ];
82
190
  }
83
- undo() {
84
- this._store.state.objectsOctree.remove(object => object.id === this.object.id);
191
+ handlePointerDown(event) {
192
+ if (event.cancelable) {
193
+ event.preventDefault();
194
+ }
195
+ if (event.pointerType === 'mouse') {
196
+ const path = event.composedPath().slice(1);
197
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
198
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
199
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
200
+ this._store.state.activeText = object;
201
+ object.focus();
202
+ return;
203
+ }
204
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
205
+ object.focus();
206
+ return;
207
+ }
208
+ if (this._store.state.activeText !== null) {
209
+ this._store.resetActiveText();
210
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
211
+ return;
212
+ }
213
+ if (KritzelEventHelper.isLeftClick(event) === false) {
214
+ return;
215
+ }
216
+ const clientX = event.clientX - this._store.offsetX;
217
+ const clientY = event.clientY - this._store.offsetY;
218
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
219
+ text.fontColor = this.fontColor;
220
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
221
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
222
+ text.zIndex = this._store.currentZIndex;
223
+ this._store.state.activeText = text;
224
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
225
+ }
226
+ if (event.pointerType === 'touch') {
227
+ const activePointers = Array.from(this._store.state.pointers.values());
228
+ const path = event.composedPath().slice(1);
229
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
230
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
231
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
232
+ this._store.state.activeText = object;
233
+ object.focus();
234
+ return;
235
+ }
236
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
237
+ object.focus();
238
+ return;
239
+ }
240
+ if (this._store.state.activeText !== null) {
241
+ this._store.resetActiveText();
242
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
243
+ return;
244
+ }
245
+ if (activePointers.length > 1) {
246
+ return;
247
+ }
248
+ KritzelKeyboardHelper.disableInteractiveWidget();
249
+ const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
250
+ const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
251
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
252
+ text.fontColor = this.fontColor;
253
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
254
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
255
+ text.zIndex = this._store.currentZIndex;
256
+ this._store.state.activeText = text;
257
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
258
+ }
85
259
  }
86
- }
87
-
88
- var cjs = {};
89
-
90
- var hasRequiredCjs;
91
-
92
- function requireCjs () {
93
- if (hasRequiredCjs) return cjs;
94
- hasRequiredCjs = 1;
95
- (function (exports) {
96
- var pe=Object.defineProperty;var ge=e=>pe(e,"__esModule",{value:true});var de=(e,t)=>{ge(e);for(var s in t)pe(e,s,{get:t[s],enumerable:true});};de(exports,{default:()=>ve,getStroke:()=>ne,getStrokeOutlinePoints:()=>te,getStrokePoints:()=>re});function $(e,t,s,x=h=>h){return e*x(.5-t*(.5-s))}function ce(e){return [-e[0],-e[1]]}function l(e,t){return [e[0]+t[0],e[1]+t[1]]}function a(e,t){return [e[0]-t[0],e[1]-t[1]]}function b(e,t){return [e[0]*t,e[1]*t]}function xe(e,t){return [e[0]/t,e[1]/t]}function R(e){return [e[1],-e[0]]}function B(e,t){return e[0]*t[0]+e[1]*t[1]}function me(e,t){return e[0]===t[0]&&e[1]===t[1]}function Se(e){return Math.hypot(e[0],e[1])}function Pe(e){return e[0]*e[0]+e[1]*e[1]}function A(e,t){return Pe(a(e,t))}function G(e){return xe(e,Se(e))}function ae(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function L(e,t,s){let x=Math.sin(s),h=Math.cos(s),y=e[0]-t[0],n=e[1]-t[1],f=y*h-n*x,d=y*x+n*h;return [f+t[0],d+t[1]]}function K(e,t,s){return l(e,b(a(t,e),s))}function ee(e,t,s){return l(e,b(t,s))}var{min:C,PI:ke}=Math,le=.275,V=ke+1e-4;function te(e,t={}){let{size:s=16,smoothing:x=.5,thinning:h=.5,simulatePressure:y=true,easing:n=r=>r,start:f={},end:d={},last:D=false}=t,{cap:S=true,easing:j=r=>r*(2-r)}=f,{cap:q=true,easing:c=r=>--r*r*r+1}=d;if(e.length===0||s<=0)return [];let p=e[e.length-1].runningLength,g=f.taper===false?0:f.taper===true?Math.max(s,p):f.taper,T=d.taper===false?0:d.taper===true?Math.max(s,p):d.taper,oe=Math.pow(s*x,2),_=[],M=[],H=e.slice(0,10).reduce((r,i)=>{let o=i.pressure;if(y){let u=C(1,i.distance/s),W=C(1,1-u);o=C(1,r+(W-r)*(u*le));}return (r+o)/2},e[0].pressure),m=$(s,h,e[e.length-1].pressure,n),U,X=e[0].vector,z=e[0].point,F=z,O=z,E=F,J=false;for(let r=0;r<e.length;r++){let{pressure:i}=e[r],{point:o,vector:u,distance:W,runningLength:I}=e[r];if(r<e.length-1&&p-I<3)continue;if(h){if(y){let v=C(1,W/s),Z=C(1,1-v);i=C(1,H+(Z-H)*(v*le));}m=$(s,h,i,n);}else m=s/2;U===void 0&&(U=m);let fe=I<g?j(I/g):1,be=p-I<T?c((p-I)/T):1;m=Math.max(.01,m*Math.min(fe,be));let se=(r<e.length-1?e[r+1]:e[r]).vector,Y=r<e.length-1?B(u,se):1,he=B(u,X)<0&&!J,ue=Y!==null&&Y<0;if(he||ue){let v=b(R(X),m);for(let Z=1/13,w=0;w<=1;w+=Z)O=L(a(o,v),o,V*w),_.push(O),E=L(l(o,v),o,V*-w),M.push(E);z=O,F=E,ue&&(J=true);continue}if(J=false,r===e.length-1){let v=b(R(u),m);_.push(a(o,v)),M.push(l(o,v));continue}let ie=b(R(K(se,u,Y)),m);O=a(o,ie),(r<=1||A(z,O)>oe)&&(_.push(O),z=O),E=l(o,ie),(r<=1||A(F,E)>oe)&&(M.push(E),F=E),H=i,X=u;}let P=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):l(e[0].point,[1,1]),Q=[],N=[];if(e.length===1){if(!(g||T)||D){let r=ee(P,G(R(a(P,k))),-(U||m)),i=[];for(let o=1/13,u=o;u<=1;u+=o)i.push(L(r,P,V*2*u));return i}}else {if(!(g||T&&e.length===1))if(S)for(let i=1/13,o=i;o<=1;o+=i){let u=L(M[0],P,V*o);Q.push(u);}else {let i=a(_[0],M[0]),o=b(i,.5),u=b(i,.51);Q.push(a(P,o),a(P,u),l(P,u),l(P,o));}let r=R(ce(e[e.length-1].vector));if(T||g&&e.length===1)N.push(k);else if(q){let i=ee(k,r,m);for(let o=1/29,u=o;u<1;u+=o)N.push(L(i,k,V*3*u));}else N.push(l(k,b(r,m)),l(k,b(r,m*.99)),a(k,b(r,m*.99)),a(k,b(r,m)));}return _.concat(N,M.reverse(),Q)}function re(e,t={}){var q;let{streamline:s=.5,size:x=16,last:h=false}=t;if(e.length===0)return [];let y=.15+(1-s)*.85,n=Array.isArray(e[0])?e:e.map(({x:c,y:p,pressure:g=.5})=>[c,p,g]);if(n.length===2){let c=n[1];n=n.slice(0,-1);for(let p=1;p<5;p++)n.push(K(n[0],c,p/4));}n.length===1&&(n=[...n,[...l(n[0],[1,1]),...n[0].slice(2)]]);let f=[{point:[n[0][0],n[0][1]],pressure:n[0][2]>=0?n[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=false,D=0,S=f[0],j=n.length-1;for(let c=1;c<n.length;c++){let p=h&&c===j?n[c].slice(0,2):K(S.point,n[c],y);if(me(S.point,p))continue;let g=ae(p,S.point);if(D+=g,c<j&&!d){if(D<x)continue;d=true;}S={point:p,pressure:n[c][2]>=0?n[c][2]:.5,vector:G(a(S.point,p)),distance:g,runningLength:D},f.push(S);}return f[0].vector=((q=f[1])==null?void 0:q.vector)||[0,0],f}function ne(e,t={}){return te(re(e,t),t)}var ve=ne;
97
- } (cjs));
98
- return cjs;
99
- }
100
-
101
- var cjsExports = requireCjs();
102
-
103
- class KritzelMathHelper {
104
- static average(a, b) {
105
- return (a + b) / 2;
260
+ handlePointerUp(event) {
261
+ var _a, _b, _c, _d;
262
+ if (event.cancelable) {
263
+ event.preventDefault();
264
+ }
265
+ if (event.pointerType === 'mouse') {
266
+ (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
267
+ (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
268
+ }
269
+ if (event.pointerType === 'touch') {
270
+ (_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
271
+ (_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
272
+ KritzelKeyboardHelper.enableInteractiveWidget();
273
+ }
106
274
  }
107
275
  }
108
276
 
@@ -325,16 +493,174 @@ class KritzelBaseObject {
325
493
  }
326
494
  }
327
495
 
328
- class KritzelPath extends KritzelBaseObject {
329
- constructor() {
330
- super(...arguments);
331
- this.__class__ = 'KritzelPath';
332
- this.stroke = 'none';
333
- this.lineSlack = 0.5;
334
- this.x = 0;
335
- this.y = 0;
336
- this.height = 0;
337
- this.width = 0;
496
+ class KritzelText extends KritzelBaseObject {
497
+ get isReadonly() {
498
+ return !(this._store.state.activeTool instanceof KritzelTextTool);
499
+ }
500
+ constructor(config) {
501
+ super();
502
+ this.__class__ = 'KritzelText';
503
+ this.value = '';
504
+ this.fontFamily = 'Arial';
505
+ this.fontSize = 8;
506
+ this.fontColor = '#000000';
507
+ this.initialWidth = 3;
508
+ this.isNew = true;
509
+ this.debugInfoVisible = true;
510
+ this.rows = 1;
511
+ if (config) {
512
+ this.value = config.value || ' ';
513
+ this.translateX = config.translateX || 0;
514
+ this.translateY = config.translateY || 0;
515
+ this.fontSize = config.fontSize || 8;
516
+ this.fontFamily = config.fontFamily || 'Arial';
517
+ this.fontColor = config.fontColor || '#000000';
518
+ this.height = config.height || this.fontSize * 1.2;
519
+ this.width = config.width || 0;
520
+ this.scale = config.scale || 1;
521
+ }
522
+ }
523
+ static create(store, fontSize, fontFamily) {
524
+ const object = new KritzelText();
525
+ object._store = store;
526
+ object.fontSize = fontSize;
527
+ object.fontFamily = fontFamily;
528
+ object.translateX = 0;
529
+ object.translateY = 0;
530
+ object.width = object.initialWidth / (object._store.state.scale < 0 ? object._store.state.scale : 1);
531
+ object.height = (object.fontSize * 1.2) / (object._store.state.scale < 0 ? object._store.state.scale : 1);
532
+ object.padding = 5;
533
+ object.backgroundColor = 'transparent';
534
+ object.scale = object._store.state.scale;
535
+ object.value = ' ';
536
+ object.zIndex = store.currentZIndex;
537
+ return object;
538
+ }
539
+ mount(element) {
540
+ if ((this.isMounted && this.elementRef === element) || this.isInViewport() === false) {
541
+ return;
542
+ }
543
+ this.elementRef = element;
544
+ this.isMounted = true;
545
+ }
546
+ resize(x, y, width, height) {
547
+ if (width <= 1 || height <= 1) {
548
+ return;
549
+ }
550
+ const scaleFactor = height / this.height;
551
+ this.fontSize = this.fontSize * scaleFactor;
552
+ this.width = this.width * scaleFactor;
553
+ this.height = height;
554
+ this.translateX = x;
555
+ this.translateY = y;
556
+ }
557
+ handleKeyDown(event) {
558
+ if (this.isReadonly) {
559
+ event.preventDefault();
560
+ event.stopPropagation();
561
+ }
562
+ }
563
+ handleInput(event) {
564
+ const target = event.target;
565
+ if (target.value === '') {
566
+ this.value = ' ';
567
+ target.value = ' ';
568
+ target.selectionStart = target.selectionEnd = target.value.length;
569
+ }
570
+ else {
571
+ this.value = target.value.trim();
572
+ }
573
+ this.adjustTextareaSize();
574
+ }
575
+ adjustTextareaSize() {
576
+ if (this.elementRef) {
577
+ const span = document.createElement('span');
578
+ span.style.position = 'absolute';
579
+ span.style.whiteSpace = 'pre-wrap';
580
+ span.style.visibility = 'hidden';
581
+ span.style.fontSize = window.getComputedStyle(this.elementRef).fontSize;
582
+ span.style.fontFamily = window.getComputedStyle(this.elementRef).fontFamily;
583
+ span.innerHTML = this.elementRef.value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>') + '<br>';
584
+ document.body.appendChild(span);
585
+ const textWidth = span.offsetWidth;
586
+ const textHeight = span.offsetHeight;
587
+ document.body.removeChild(span);
588
+ this.width = textWidth;
589
+ this.height = textHeight;
590
+ this._store.rerender();
591
+ }
592
+ }
593
+ focus() {
594
+ if (this.elementRef) {
595
+ this.elementRef.focus();
596
+ }
597
+ }
598
+ selectAll() {
599
+ if (this.elementRef) {
600
+ this.elementRef.select();
601
+ }
602
+ }
603
+ insertFromClipboard() {
604
+ if (this.elementRef) {
605
+ this.elementRef.focus();
606
+ try {
607
+ navigator.clipboard.readText().then(text => {
608
+ const start = this.elementRef.selectionStart;
609
+ const end = this.elementRef.selectionEnd;
610
+ const value = this.elementRef.value;
611
+ this.elementRef.value = value.substring(0, start) + text + value.substring(end);
612
+ this.elementRef.selectionStart = this.elementRef.selectionEnd = start + text.length;
613
+ this.value = this.elementRef.value;
614
+ this.adjustTextareaSize();
615
+ });
616
+ }
617
+ catch (err) {
618
+ console.error('Failed to read clipboard contents:', err);
619
+ }
620
+ }
621
+ }
622
+ onSelectedClick() {
623
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
624
+ this._store.state.selectionGroup = null;
625
+ this._store.state.selectionBox = null;
626
+ this._store.state.activeText = this;
627
+ setTimeout(() => {
628
+ this.focus();
629
+ }, 300);
630
+ }
631
+ }
632
+
633
+ var cjs = {};
634
+
635
+ var hasRequiredCjs;
636
+
637
+ function requireCjs () {
638
+ if (hasRequiredCjs) return cjs;
639
+ hasRequiredCjs = 1;
640
+ (function (exports) {
641
+ var pe=Object.defineProperty;var ge=e=>pe(e,"__esModule",{value:true});var de=(e,t)=>{ge(e);for(var s in t)pe(e,s,{get:t[s],enumerable:true});};de(exports,{default:()=>ve,getStroke:()=>ne,getStrokeOutlinePoints:()=>te,getStrokePoints:()=>re});function $(e,t,s,x=h=>h){return e*x(.5-t*(.5-s))}function ce(e){return [-e[0],-e[1]]}function l(e,t){return [e[0]+t[0],e[1]+t[1]]}function a(e,t){return [e[0]-t[0],e[1]-t[1]]}function b(e,t){return [e[0]*t,e[1]*t]}function xe(e,t){return [e[0]/t,e[1]/t]}function R(e){return [e[1],-e[0]]}function B(e,t){return e[0]*t[0]+e[1]*t[1]}function me(e,t){return e[0]===t[0]&&e[1]===t[1]}function Se(e){return Math.hypot(e[0],e[1])}function Pe(e){return e[0]*e[0]+e[1]*e[1]}function A(e,t){return Pe(a(e,t))}function G(e){return xe(e,Se(e))}function ae(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function L(e,t,s){let x=Math.sin(s),h=Math.cos(s),y=e[0]-t[0],n=e[1]-t[1],f=y*h-n*x,d=y*x+n*h;return [f+t[0],d+t[1]]}function K(e,t,s){return l(e,b(a(t,e),s))}function ee(e,t,s){return l(e,b(t,s))}var{min:C,PI:ke}=Math,le=.275,V=ke+1e-4;function te(e,t={}){let{size:s=16,smoothing:x=.5,thinning:h=.5,simulatePressure:y=true,easing:n=r=>r,start:f={},end:d={},last:D=false}=t,{cap:S=true,easing:j=r=>r*(2-r)}=f,{cap:q=true,easing:c=r=>--r*r*r+1}=d;if(e.length===0||s<=0)return [];let p=e[e.length-1].runningLength,g=f.taper===false?0:f.taper===true?Math.max(s,p):f.taper,T=d.taper===false?0:d.taper===true?Math.max(s,p):d.taper,oe=Math.pow(s*x,2),_=[],M=[],H=e.slice(0,10).reduce((r,i)=>{let o=i.pressure;if(y){let u=C(1,i.distance/s),W=C(1,1-u);o=C(1,r+(W-r)*(u*le));}return (r+o)/2},e[0].pressure),m=$(s,h,e[e.length-1].pressure,n),U,X=e[0].vector,z=e[0].point,F=z,O=z,E=F,J=false;for(let r=0;r<e.length;r++){let{pressure:i}=e[r],{point:o,vector:u,distance:W,runningLength:I}=e[r];if(r<e.length-1&&p-I<3)continue;if(h){if(y){let v=C(1,W/s),Z=C(1,1-v);i=C(1,H+(Z-H)*(v*le));}m=$(s,h,i,n);}else m=s/2;U===void 0&&(U=m);let fe=I<g?j(I/g):1,be=p-I<T?c((p-I)/T):1;m=Math.max(.01,m*Math.min(fe,be));let se=(r<e.length-1?e[r+1]:e[r]).vector,Y=r<e.length-1?B(u,se):1,he=B(u,X)<0&&!J,ue=Y!==null&&Y<0;if(he||ue){let v=b(R(X),m);for(let Z=1/13,w=0;w<=1;w+=Z)O=L(a(o,v),o,V*w),_.push(O),E=L(l(o,v),o,V*-w),M.push(E);z=O,F=E,ue&&(J=true);continue}if(J=false,r===e.length-1){let v=b(R(u),m);_.push(a(o,v)),M.push(l(o,v));continue}let ie=b(R(K(se,u,Y)),m);O=a(o,ie),(r<=1||A(z,O)>oe)&&(_.push(O),z=O),E=l(o,ie),(r<=1||A(F,E)>oe)&&(M.push(E),F=E),H=i,X=u;}let P=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):l(e[0].point,[1,1]),Q=[],N=[];if(e.length===1){if(!(g||T)||D){let r=ee(P,G(R(a(P,k))),-(U||m)),i=[];for(let o=1/13,u=o;u<=1;u+=o)i.push(L(r,P,V*2*u));return i}}else {if(!(g||T&&e.length===1))if(S)for(let i=1/13,o=i;o<=1;o+=i){let u=L(M[0],P,V*o);Q.push(u);}else {let i=a(_[0],M[0]),o=b(i,.5),u=b(i,.51);Q.push(a(P,o),a(P,u),l(P,u),l(P,o));}let r=R(ce(e[e.length-1].vector));if(T||g&&e.length===1)N.push(k);else if(q){let i=ee(k,r,m);for(let o=1/29,u=o;u<1;u+=o)N.push(L(i,k,V*3*u));}else N.push(l(k,b(r,m)),l(k,b(r,m*.99)),a(k,b(r,m*.99)),a(k,b(r,m)));}return _.concat(N,M.reverse(),Q)}function re(e,t={}){var q;let{streamline:s=.5,size:x=16,last:h=false}=t;if(e.length===0)return [];let y=.15+(1-s)*.85,n=Array.isArray(e[0])?e:e.map(({x:c,y:p,pressure:g=.5})=>[c,p,g]);if(n.length===2){let c=n[1];n=n.slice(0,-1);for(let p=1;p<5;p++)n.push(K(n[0],c,p/4));}n.length===1&&(n=[...n,[...l(n[0],[1,1]),...n[0].slice(2)]]);let f=[{point:[n[0][0],n[0][1]],pressure:n[0][2]>=0?n[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=false,D=0,S=f[0],j=n.length-1;for(let c=1;c<n.length;c++){let p=h&&c===j?n[c].slice(0,2):K(S.point,n[c],y);if(me(S.point,p))continue;let g=ae(p,S.point);if(D+=g,c<j&&!d){if(D<x)continue;d=true;}S={point:p,pressure:n[c][2]>=0?n[c][2]:.5,vector:G(a(S.point,p)),distance:g,runningLength:D},f.push(S);}return f[0].vector=((q=f[1])==null?void 0:q.vector)||[0,0],f}function ne(e,t={}){return te(re(e,t),t)}var ve=ne;
642
+ } (cjs));
643
+ return cjs;
644
+ }
645
+
646
+ var cjsExports = requireCjs();
647
+
648
+ class KritzelMathHelper {
649
+ static average(a, b) {
650
+ return (a + b) / 2;
651
+ }
652
+ }
653
+
654
+ class KritzelPath extends KritzelBaseObject {
655
+ constructor() {
656
+ super(...arguments);
657
+ this.__class__ = 'KritzelPath';
658
+ this.stroke = 'none';
659
+ this.lineSlack = 0.5;
660
+ this.x = 0;
661
+ this.y = 0;
662
+ this.height = 0;
663
+ this.width = 0;
338
664
  this.scale = 1;
339
665
  this.visible = true;
340
666
  this.debugInfoVisible = true;
@@ -443,36 +769,6 @@ class KritzelPath extends KritzelBaseObject {
443
769
  }
444
770
  }
445
771
 
446
- class KritzelBaseTool {
447
- constructor(store) {
448
- this.__class__ = this.constructor.name;
449
- this.name = 'base-tool';
450
- this._store = store;
451
- }
452
- onActivate() {
453
- // default implementation
454
- }
455
- onDeactivate() {
456
- // default implementation
457
- }
458
- handlePointerDown(_event) {
459
- // default implementation
460
- }
461
- handlePointerMove(_event) {
462
- // default implementation
463
- }
464
- handlePointerUp(_event) {
465
- // default implementation
466
- }
467
- handleWheel(_event) {
468
- // default implementation
469
- }
470
- revive(object) {
471
- Object.assign(this, object);
472
- return this;
473
- }
474
- }
475
-
476
772
  class KritzelBrushTool extends KritzelBaseTool {
477
773
  constructor(store) {
478
774
  super(store);
@@ -585,303 +881,7 @@ class KritzelBrushTool extends KritzelBaseTool {
585
881
  }
586
882
  }
587
883
 
588
- class KritzelToolRegistry {
589
- static registerTool(toolName, constructor, store) {
590
- const toolInstance = new constructor(store);
591
- toolInstance.name = toolName;
592
- this.registry[toolName] = toolInstance;
593
- return toolInstance;
594
- }
595
- static getTool(toolName) {
596
- const toolInstance = this.registry[toolName];
597
- if (!toolInstance) {
598
- console.warn(`Unknown tool: ${toolName}`);
599
- return null;
600
- }
601
- return toolInstance;
602
- }
603
- }
604
- KritzelToolRegistry.registry = {};
605
-
606
- class KritzelText extends KritzelBaseObject {
607
- get isReadonly() {
608
- return !(this._store.state.activeTool instanceof KritzelTextTool);
609
- }
610
- constructor(config) {
611
- super();
612
- this.__class__ = 'KritzelText';
613
- this.value = '';
614
- this.fontFamily = 'Arial';
615
- this.fontSize = 8;
616
- this.fontColor = '#000000';
617
- this.initialWidth = 3;
618
- this.isNew = true;
619
- this.debugInfoVisible = true;
620
- this.rows = 1;
621
- if (config) {
622
- this.value = config.value || ' ';
623
- this.translateX = config.translateX || 0;
624
- this.translateY = config.translateY || 0;
625
- this.fontSize = config.fontSize || 8;
626
- this.fontFamily = config.fontFamily || 'Arial';
627
- this.fontColor = config.fontColor || '#000000';
628
- this.height = config.height || this.fontSize * 1.2;
629
- this.width = config.width || 0;
630
- this.scale = config.scale || 1;
631
- }
632
- }
633
- static create(store, fontSize, fontFamily) {
634
- const object = new KritzelText();
635
- object._store = store;
636
- object.fontSize = fontSize;
637
- object.fontFamily = fontFamily;
638
- object.translateX = 0;
639
- object.translateY = 0;
640
- object.width = object.initialWidth / (object._store.state.scale < 0 ? object._store.state.scale : 1);
641
- object.height = (object.fontSize * 1.2) / (object._store.state.scale < 0 ? object._store.state.scale : 1);
642
- object.padding = 5;
643
- object.backgroundColor = 'transparent';
644
- object.scale = object._store.state.scale;
645
- object.value = ' ';
646
- object.zIndex = store.currentZIndex;
647
- return object;
648
- }
649
- mount(element) {
650
- if ((this.isMounted && this.elementRef === element) || this.isInViewport() === false) {
651
- return;
652
- }
653
- this.elementRef = element;
654
- this.isMounted = true;
655
- }
656
- resize(x, y, width, height) {
657
- if (width <= 1 || height <= 1) {
658
- return;
659
- }
660
- const scaleFactor = height / this.height;
661
- this.fontSize = this.fontSize * scaleFactor;
662
- this.width = this.width * scaleFactor;
663
- this.height = height;
664
- this.translateX = x;
665
- this.translateY = y;
666
- }
667
- handleKeyDown(event) {
668
- if (this.isReadonly) {
669
- event.preventDefault();
670
- event.stopPropagation();
671
- }
672
- }
673
- handleInput(event) {
674
- const target = event.target;
675
- if (target.value === '') {
676
- this.value = ' ';
677
- target.value = ' ';
678
- target.selectionStart = target.selectionEnd = target.value.length;
679
- }
680
- else {
681
- this.value = target.value.trim();
682
- }
683
- this.adjustTextareaSize();
684
- }
685
- adjustTextareaSize() {
686
- if (this.elementRef) {
687
- const span = document.createElement('span');
688
- span.style.position = 'absolute';
689
- span.style.whiteSpace = 'pre-wrap';
690
- span.style.visibility = 'hidden';
691
- span.style.fontSize = window.getComputedStyle(this.elementRef).fontSize;
692
- span.style.fontFamily = window.getComputedStyle(this.elementRef).fontFamily;
693
- span.innerHTML = this.elementRef.value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>') + '<br>';
694
- document.body.appendChild(span);
695
- const textWidth = span.offsetWidth;
696
- const textHeight = span.offsetHeight;
697
- document.body.removeChild(span);
698
- this.width = textWidth;
699
- this.height = textHeight;
700
- this._store.rerender();
701
- }
702
- }
703
- focus() {
704
- if (this.elementRef) {
705
- this.elementRef.focus();
706
- }
707
- }
708
- selectAll() {
709
- if (this.elementRef) {
710
- this.elementRef.select();
711
- }
712
- }
713
- insertFromClipboard() {
714
- if (this.elementRef) {
715
- this.elementRef.focus();
716
- try {
717
- navigator.clipboard.readText().then(text => {
718
- const start = this.elementRef.selectionStart;
719
- const end = this.elementRef.selectionEnd;
720
- const value = this.elementRef.value;
721
- this.elementRef.value = value.substring(0, start) + text + value.substring(end);
722
- this.elementRef.selectionStart = this.elementRef.selectionEnd = start + text.length;
723
- this.value = this.elementRef.value;
724
- this.adjustTextareaSize();
725
- });
726
- }
727
- catch (err) {
728
- console.error('Failed to read clipboard contents:', err);
729
- }
730
- }
731
- }
732
- onSelectedClick() {
733
- this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
734
- this._store.state.selectionGroup = null;
735
- this._store.state.selectionBox = null;
736
- this._store.state.activeText = this;
737
- setTimeout(() => {
738
- this.focus();
739
- }, 300);
740
- }
741
- }
742
-
743
- class KritzelKeyboardHelper {
744
- static forceHideKeyboard() {
745
- if (document.activeElement instanceof HTMLElement) {
746
- document.activeElement.blur();
747
- }
748
- }
749
- static enableInteractiveWidget() {
750
- const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
751
- if (meta) {
752
- let currentContent = meta.getAttribute('content');
753
- if (!currentContent.includes('interactive-widget=resizes-content')) {
754
- currentContent += ', interactive-widget=resizes-content';
755
- }
756
- meta.setAttribute('content', currentContent);
757
- }
758
- }
759
- static disableInteractiveWidget() {
760
- const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
761
- if (meta) {
762
- let currentContent = meta.getAttribute('content');
763
- let newContent = currentContent.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g, '');
764
- newContent = newContent
765
- .replace(/,(\s*,)+/g, ',')
766
- .replace(/^,/, '')
767
- .replace(/,$/, '')
768
- .trim();
769
- meta.setAttribute('content', newContent);
770
- }
771
- }
772
- }
773
-
774
- class KritzelTextTool extends KritzelBaseTool {
775
- constructor(store) {
776
- super(store);
777
- this.fontFamily = 'Arial';
778
- this.fontSize = 16;
779
- this.fontColor = '#000000';
780
- this.palette = [
781
- '#000000',
782
- '#FFFFFF',
783
- '#FF0000',
784
- '#00FF00',
785
- '#0000FF',
786
- '#FFFF00',
787
- '#FF00FF',
788
- '#00FFFF',
789
- '#808080',
790
- '#C0C0C0',
791
- '#800000',
792
- '#008000',
793
- '#000080',
794
- '#808000',
795
- '#800080',
796
- ];
797
- }
798
- handlePointerDown(event) {
799
- if (event.cancelable) {
800
- event.preventDefault();
801
- }
802
- if (event.pointerType === 'mouse') {
803
- const path = event.composedPath().slice(1);
804
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
805
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
806
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
807
- this._store.state.activeText = object;
808
- object.focus();
809
- return;
810
- }
811
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
812
- object.focus();
813
- return;
814
- }
815
- if (this._store.state.activeText !== null) {
816
- this._store.resetActiveText();
817
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
818
- return;
819
- }
820
- if (KritzelEventHelper.isLeftClick(event) === false) {
821
- return;
822
- }
823
- const clientX = event.clientX - this._store.offsetX;
824
- const clientY = event.clientY - this._store.offsetY;
825
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
826
- text.fontColor = this.fontColor;
827
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
828
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
829
- text.zIndex = this._store.currentZIndex;
830
- this._store.state.activeText = text;
831
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
832
- }
833
- if (event.pointerType === 'touch') {
834
- const activePointers = Array.from(this._store.state.pointers.values());
835
- const path = event.composedPath().slice(1);
836
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
837
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
838
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
839
- this._store.state.activeText = object;
840
- object.focus();
841
- return;
842
- }
843
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
844
- object.focus();
845
- return;
846
- }
847
- if (this._store.state.activeText !== null) {
848
- this._store.resetActiveText();
849
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
850
- return;
851
- }
852
- if (activePointers.length > 1) {
853
- return;
854
- }
855
- KritzelKeyboardHelper.disableInteractiveWidget();
856
- const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
857
- const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
858
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
859
- text.fontColor = this.fontColor;
860
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
861
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
862
- text.zIndex = this._store.currentZIndex;
863
- this._store.state.activeText = text;
864
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
865
- }
866
- }
867
- handlePointerUp(event) {
868
- var _a, _b, _c, _d;
869
- if (event.cancelable) {
870
- event.preventDefault();
871
- }
872
- if (event.pointerType === 'mouse') {
873
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
874
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
875
- }
876
- if (event.pointerType === 'touch') {
877
- (_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
878
- (_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
879
- KritzelKeyboardHelper.enableInteractiveWidget();
880
- }
881
- }
882
- }
883
-
884
- export { AddObjectCommand as A, KritzelBrushTool as K, ObjectHelper as O, KritzelTextTool as a, KritzelBaseCommand as b, KritzelBaseTool as c, KritzelEventHelper as d, KritzelBaseObject as e, KritzelText as f, KritzelPath as g, KritzelToolRegistry as h, KritzelKeyboardHelper as i };
885
- //# sourceMappingURL=p-DqZOaMbq.js.map
884
+ export { AddObjectCommand as A, KritzelText as K, ObjectHelper as O, KritzelBrushTool as a, KritzelTextTool as b, KritzelBaseCommand as c, KritzelBaseTool as d, KritzelEventHelper as e, KritzelBaseObject as f, KritzelPath as g, KritzelToolRegistry as h, KritzelKeyboardHelper as i };
885
+ //# sourceMappingURL=p-BIlVkMTU.js.map
886
886
 
887
- //# sourceMappingURL=p-DqZOaMbq.js.map
887
+ //# sourceMappingURL=p-BIlVkMTU.js.map