kritzel-stencil 0.0.108 → 0.0.109

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 (97) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +853 -832
  2. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/move.handler.js +62 -55
  8. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  10. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  12. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  14. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  15. package/dist/collection/classes/objects/base-object.class.js +3 -0
  16. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  17. package/dist/collection/classes/objects/text.class.js +11 -1
  18. package/dist/collection/classes/objects/text.class.js.map +1 -1
  19. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  20. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  21. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  22. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  23. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  24. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  25. package/dist/collection/classes/tools/selection-tool.class.js +93 -73
  26. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  28. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  29. package/dist/collection/classes/viewport.class.js +76 -69
  30. package/dist/collection/classes/viewport.class.js.map +1 -1
  31. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  32. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  33. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +66 -120
  34. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  35. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  36. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  37. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  38. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  39. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  40. package/dist/collection/configs/default-engine-state.js +1 -1
  41. package/dist/collection/configs/default-engine-state.js.map +1 -1
  42. package/dist/collection/helpers/devices.helper.js +6 -0
  43. package/dist/collection/helpers/devices.helper.js.map +1 -0
  44. package/dist/collection/helpers/event.helper.js +43 -34
  45. package/dist/collection/helpers/event.helper.js.map +1 -1
  46. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  47. package/dist/collection/interfaces/object.interface.js.map +1 -1
  48. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  49. package/dist/components/kritzel-context-menu.js +1 -1
  50. package/dist/components/kritzel-controls.js +1 -1
  51. package/dist/components/kritzel-editor.js +5 -5
  52. package/dist/components/kritzel-editor.js.map +1 -1
  53. package/dist/components/kritzel-engine.js +1 -1
  54. package/dist/components/{p-BNfHRlWL.js → p-7Ns73-wN.js} +237 -220
  55. package/dist/components/p-7Ns73-wN.js.map +1 -0
  56. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  57. package/dist/components/p-BmAloSfd.js.map +1 -0
  58. package/dist/components/{p-CqJr3YCp.js → p-BmrZipyu.js} +617 -621
  59. package/dist/components/p-BmrZipyu.js.map +1 -0
  60. package/dist/components/{p-Box62paJ.js → p-Ch6TgHX3.js} +18 -8
  61. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  62. package/dist/esm/kritzel-brush-style_18.entry.js +853 -832
  63. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  64. package/dist/esm/loader.js +1 -1
  65. package/dist/esm/stencil.js +1 -1
  66. package/dist/stencil/p-c976660c.entry.js +2 -0
  67. package/dist/stencil/p-c976660c.entry.js.map +1 -0
  68. package/dist/stencil/stencil.esm.js +1 -1
  69. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  70. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  71. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  72. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  73. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  74. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  75. package/dist/types/classes/objects/text.class.d.ts +1 -0
  76. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  77. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  78. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  79. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  80. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  81. package/dist/types/classes/viewport.class.d.ts +3 -6
  82. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  83. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  84. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  85. package/dist/types/components.d.ts +0 -2
  86. package/dist/types/helpers/devices.helper.d.ts +3 -0
  87. package/dist/types/helpers/event.helper.d.ts +2 -6
  88. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  89. package/dist/types/interfaces/object.interface.d.ts +1 -0
  90. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  91. package/package.json +1 -1
  92. package/dist/components/p-BNfHRlWL.js.map +0 -1
  93. package/dist/components/p-Box62paJ.js.map +0 -1
  94. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  95. package/dist/components/p-CqJr3YCp.js.map +0 -1
  96. package/dist/stencil/p-3a7d7b58.entry.js +0 -2
  97. package/dist/stencil/p-3a7d7b58.entry.js.map +0 -1
@@ -125,7 +125,6 @@ const KritzelContextMenu = class {
125
125
  constructor(hostRef) {
126
126
  registerInstance(this, hostRef);
127
127
  this.actionSelected = createEvent(this, "actionSelected");
128
- this.close = createEvent(this, "close");
129
128
  }
130
129
  handleItemClick(item) {
131
130
  const isDisabled = typeof item.disabled === 'function' ? item.disabled() : item.disabled;
@@ -134,7 +133,7 @@ const KritzelContextMenu = class {
134
133
  }
135
134
  }
136
135
  render() {
137
- return (h(Host, { key: 'db318a0936f89f202ef5101447b723c0ba7aa139' }, h("div", { key: '53da01021464f605e08c5f910997bb8f21d481a1', class: "menu-container" }, this.items.map(item => (h("button", { key: `${item.label}-${this.items.indexOf(item)}`, class: { 'menu-item': true, 'disabled': typeof item.disabled === 'function' ? item.disabled() : item.disabled }, onClick: () => this.handleItemClick(item), onTouchStart: () => this.handleItemClick(item), disabled: typeof item.disabled === 'function' ? item.disabled() : item.disabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)))))));
136
+ return (h(Host, { key: '92cf80d71faae3e33bc29d9e9b3a81b4b6ee6c87' }, h("div", { key: '838734ed3f1e3af86a5db7312c2206e90835a8f0', class: "menu-container" }, this.items.map(item => (h("button", { key: `${item.label}-${this.items.indexOf(item)}`, class: { 'menu-item': true, 'disabled': typeof item.disabled === 'function' ? item.disabled() : item.disabled }, onClick: () => this.handleItemClick(item), onTouchStart: () => this.handleItemClick(item), disabled: typeof item.disabled === 'function' ? item.disabled() : item.disabled }, item.icon && h("kritzel-icon", { name: item.icon, size: 16 }), h("span", { class: "label" }, item.label)))))));
138
137
  }
139
138
  get hostElement() { return getElement(this); }
140
139
  };
@@ -241,43 +240,52 @@ class KritzelEventHelper {
241
240
  static isMainMouseWheel(event) {
242
241
  return Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0 && Number.isInteger(event.deltaY);
243
242
  }
244
- static detectDoubleTap() {
245
- const currentTime = Date.now();
246
- const tapLength = currentTime - KritzelEventHelper.lastTapTimestamp;
247
- if (KritzelEventHelper.twoFingerTouchDetected) {
248
- KritzelEventHelper.lastTapTimestamp = 0;
249
- KritzelEventHelper.twoFingerTouchDetected = false;
250
- if (KritzelEventHelper.tapTimeoutId) {
251
- clearTimeout(KritzelEventHelper.tapTimeoutId);
252
- KritzelEventHelper.tapTimeoutId = null;
243
+ static isPointerEventOnContextMenu(event) {
244
+ const path = event.composedPath();
245
+ const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
246
+ return !!contextMenu;
247
+ }
248
+ static onLongTouchPress(event, onSuccess, onCancel) {
249
+ if (event.pointerType !== 'touch') {
250
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
251
+ return () => { };
252
+ }
253
+ const longPressTimeout = 400;
254
+ const moveThreshold = 10;
255
+ const startX = event.clientX;
256
+ const startY = event.clientY;
257
+ const target = event.target;
258
+ const timer = setTimeout(() => {
259
+ removeListeners();
260
+ onSuccess(event);
261
+ }, longPressTimeout);
262
+ const cancel = () => {
263
+ clearTimeout(timer);
264
+ removeListeners();
265
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
266
+ };
267
+ const onPointerMove = (e) => {
268
+ if (Math.abs(e.clientX - startX) > moveThreshold || Math.abs(e.clientY - startY) > moveThreshold) {
269
+ cancel();
253
270
  }
254
- return false;
255
- }
256
- if (KritzelEventHelper.tapTimeoutId) {
257
- clearTimeout(KritzelEventHelper.tapTimeoutId);
258
- KritzelEventHelper.tapTimeoutId = null;
259
- }
260
- if (tapLength < KritzelEventHelper.doubleTapTimeout && tapLength > 0) {
261
- KritzelEventHelper.lastTapTimestamp = 0;
262
- return true;
263
- }
264
- else {
265
- KritzelEventHelper.lastTapTimestamp = currentTime;
266
- KritzelEventHelper.tapTimeoutId = setTimeout(() => {
267
- KritzelEventHelper.tapTimeoutId = null;
268
- KritzelEventHelper.twoFingerTouchDetected = false;
269
- }, KritzelEventHelper.doubleTapTimeout);
270
- return false;
271
- }
272
- }
273
- static notifyTwoFingerTouch() {
274
- KritzelEventHelper.twoFingerTouchDetected = true;
271
+ };
272
+ const onPointerUp = () => {
273
+ cancel();
274
+ };
275
+ const onPointerCancel = () => {
276
+ cancel();
277
+ };
278
+ const removeListeners = () => {
279
+ target.removeEventListener('pointermove', onPointerMove);
280
+ target.removeEventListener('pointerup', onPointerUp);
281
+ target.removeEventListener('pointercancel', onPointerCancel);
282
+ };
283
+ target.addEventListener('pointermove', onPointerMove, { passive: true });
284
+ target.addEventListener('pointerup', onPointerUp, { once: true });
285
+ target.addEventListener('pointercancel', onPointerCancel, { once: true });
286
+ return cancel;
275
287
  }
276
288
  }
277
- KritzelEventHelper.lastTapTimestamp = 0;
278
- KritzelEventHelper.tapTimeoutId = null;
279
- KritzelEventHelper.doubleTapTimeout = 300;
280
- KritzelEventHelper.twoFingerTouchDetected = false;
281
289
 
282
290
  class KritzelBaseCommand {
283
291
  constructor(store, initiator) {
@@ -538,6 +546,9 @@ class KritzelBaseObject {
538
546
  copiedObject.isMounted = false;
539
547
  return copiedObject;
540
548
  }
549
+ onSelectedClick() {
550
+ // This method can be overridden by subclasses to handle click events when the object is selected.
551
+ }
541
552
  revive(object) {
542
553
  Object.assign(this, object);
543
554
  return this;
@@ -674,28 +685,13 @@ class KritzelBaseTool {
674
685
  onDeactivate() {
675
686
  // default implementation
676
687
  }
677
- handleMouseDown(_event) {
678
- // default implementation
679
- }
680
- handleMouseMove(_event) {
681
- // default implementation
682
- }
683
- handleMouseUp(_event) {
684
- // default implementation
685
- }
686
- handleDoubleClick(_event) {
687
- // default implementation
688
- }
689
- handleDoubleTap(_event) {
690
- // default implementation
691
- }
692
- handleTouchStart(_event) {
688
+ handlePointerDown(_event) {
693
689
  // default implementation
694
690
  }
695
- handleTouchMove(_event) {
691
+ handlePointerMove(_event) {
696
692
  // default implementation
697
693
  }
698
- handleTouchEnd(_event) {
694
+ handlePointerUp(_event) {
699
695
  // default implementation
700
696
  }
701
697
  handleWheel(_event) {
@@ -718,90 +714,116 @@ class KritzelBrushTool extends KritzelBaseTool {
718
714
  highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
719
715
  };
720
716
  }
721
- handleMouseDown(event) {
722
- if (KritzelEventHelper.isLeftClick(event)) {
723
- this._store.state.isDrawing = true;
724
- const x = event.clientX - this._store.offsetX;
725
- const y = event.clientY - this._store.offsetY;
726
- this._store.state.currentPath = KritzelPath.create(this._store, {
727
- points: [[x, y]],
728
- translateX: -this._store.state.translateX,
729
- translateY: -this._store.state.translateY,
730
- scale: this._store.state.scale,
731
- fill: this.color,
732
- strokeWidth: this.size,
733
- });
717
+ handlePointerDown(event) {
718
+ if (event.pointerType === 'mouse') {
719
+ if (KritzelEventHelper.isLeftClick(event)) {
720
+ this._store.state.isDrawing = true;
721
+ const x = event.clientX - this._store.offsetX;
722
+ const y = event.clientY - this._store.offsetY;
723
+ this._store.state.currentPath = KritzelPath.create(this._store, {
724
+ points: [[x, y]],
725
+ translateX: -this._store.state.translateX,
726
+ translateY: -this._store.state.translateY,
727
+ scale: this._store.state.scale,
728
+ fill: this.color,
729
+ strokeWidth: this.size,
730
+ });
731
+ }
734
732
  }
735
- }
736
- handleMouseMove(event) {
737
- if (this._store.state.isDrawing) {
738
- const x = event.clientX - this._store.offsetX;
739
- const y = event.clientY - this._store.offsetY;
740
- this._store.state.currentPath = KritzelPath.create(this._store, {
741
- points: [...this._store.state.currentPath.points, [x, y]],
742
- translateX: -this._store.state.translateX,
743
- translateY: -this._store.state.translateY,
744
- scale: this._store.state.scale,
745
- fill: this.color,
746
- strokeWidth: this.size,
747
- });
748
- this._store.rerender();
733
+ if (event.pointerType === 'touch') {
734
+ const activePointers = Array.from(this._store.state.pointers.values());
735
+ if (activePointers.length === 1) {
736
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
737
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
738
+ this._store.state.isDrawing = true;
739
+ this._store.state.currentPath = KritzelPath.create(this._store, {
740
+ points: [[x, y]],
741
+ translateX: -this._store.state.translateX,
742
+ translateY: -this._store.state.translateY,
743
+ scale: this._store.state.scale,
744
+ fill: this.color,
745
+ strokeWidth: this.size,
746
+ });
747
+ this._store.rerender();
748
+ }
749
749
  }
750
750
  }
751
- handleMouseUp(_event) {
752
- if (this._store.state.isDrawing) {
753
- this._store.state.isDrawing = false;
754
- if (this._store.state.currentPath) {
755
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
756
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
751
+ handlePointerMove(event) {
752
+ if (event.pointerType === 'mouse') {
753
+ if (this._store.state.isDrawing) {
754
+ const x = event.clientX - this._store.offsetX;
755
+ const y = event.clientY - this._store.offsetY;
756
+ this._store.state.currentPath = KritzelPath.create(this._store, {
757
+ points: [...this._store.state.currentPath.points, [x, y]],
758
+ translateX: -this._store.state.translateX,
759
+ translateY: -this._store.state.translateY,
760
+ scale: this._store.state.scale,
761
+ fill: this.color,
762
+ strokeWidth: this.size,
763
+ });
764
+ this._store.rerender();
757
765
  }
758
- this._store.state.currentPath = undefined;
759
766
  }
760
- }
761
- handleTouchStart(event) {
762
- if (this._store.state.touchCount === 1) {
763
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
764
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
765
- this._store.state.isDrawing = true;
766
- this._store.state.currentPath = KritzelPath.create(this._store, {
767
- points: [[x, y]],
768
- translateX: -this._store.state.translateX,
769
- translateY: -this._store.state.translateY,
770
- scale: this._store.state.scale,
771
- fill: this.color,
772
- strokeWidth: this.size,
773
- });
774
- this._store.rerender();
767
+ if (event.pointerType === 'touch') {
768
+ const activePointers = Array.from(this._store.state.pointers.values());
769
+ if (activePointers.length === 1) {
770
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
771
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
772
+ this._store.state.currentPath = KritzelPath.create(this._store, {
773
+ points: [...this._store.state.currentPath.points, [x, y]],
774
+ translateX: -this._store.state.translateX,
775
+ translateY: -this._store.state.translateY,
776
+ scale: this._store.state.scale,
777
+ fill: this.color,
778
+ strokeWidth: this.size,
779
+ });
780
+ this._store.rerender();
781
+ }
775
782
  }
776
783
  }
777
- handleTouchMove(event) {
778
- if (this._store.state.touchCount === 1) {
779
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
780
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
781
- this._store.state.currentPath = KritzelPath.create(this._store, {
782
- points: [...this._store.state.currentPath.points, [x, y]],
783
- translateX: -this._store.state.translateX,
784
- translateY: -this._store.state.translateY,
785
- scale: this._store.state.scale,
786
- fill: this.color,
787
- strokeWidth: this.size,
788
- });
789
- this._store.rerender();
784
+ handlePointerUp(event) {
785
+ if (event.pointerType === 'mouse') {
786
+ if (this._store.state.isDrawing) {
787
+ this._store.state.isDrawing = false;
788
+ if (this._store.state.currentPath) {
789
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
790
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
791
+ }
792
+ this._store.state.currentPath = undefined;
793
+ }
790
794
  }
791
- }
792
- handleTouchEnd(_event) {
793
- if (this._store.state.isDrawing) {
794
- this._store.state.isDrawing = false;
795
- if (this._store.state.currentPath) {
796
- this._store.state.currentPath.zIndex = this._store.currentZIndex;
797
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
795
+ if (event.pointerType === 'touch') {
796
+ if (this._store.state.isDrawing) {
797
+ this._store.state.isDrawing = false;
798
+ if (this._store.state.currentPath) {
799
+ this._store.state.currentPath.zIndex = this._store.currentZIndex;
800
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
801
+ }
802
+ this._store.state.currentPath = undefined;
803
+ this._store.rerender();
798
804
  }
799
- this._store.state.currentPath = undefined;
800
- this._store.rerender();
801
805
  }
802
806
  }
803
807
  }
804
808
 
809
+ class KritzelToolRegistry {
810
+ static registerTool(toolName, constructor, store) {
811
+ const toolInstance = new constructor(store);
812
+ toolInstance.name = toolName;
813
+ this.registry[toolName] = toolInstance;
814
+ return toolInstance;
815
+ }
816
+ static getTool(toolName) {
817
+ const toolInstance = this.registry[toolName];
818
+ if (!toolInstance) {
819
+ console.warn(`Unknown tool: ${toolName}`);
820
+ return null;
821
+ }
822
+ return toolInstance;
823
+ }
824
+ }
825
+ KritzelToolRegistry.registry = {};
826
+
805
827
  class KritzelText extends KritzelBaseObject {
806
828
  get isReadonly() {
807
829
  return !(this._store.state.activeTool instanceof KritzelTextTool);
@@ -824,7 +846,7 @@ class KritzelText extends KritzelBaseObject {
824
846
  this.fontSize = config.fontSize || 8;
825
847
  this.fontFamily = config.fontFamily || 'Arial';
826
848
  this.fontColor = config.fontColor || '#000000';
827
- this.height = config.height || (this.fontSize * 1.2);
849
+ this.height = config.height || this.fontSize * 1.2;
828
850
  this.width = config.width || 0;
829
851
  this.scale = config.scale || 1;
830
852
  }
@@ -928,6 +950,15 @@ class KritzelText extends KritzelBaseObject {
928
950
  }
929
951
  }
930
952
  }
953
+ onSelectedClick() {
954
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
955
+ this._store.state.selectionGroup = null;
956
+ this._store.state.selectionBox = null;
957
+ this._store.state.activeText = this;
958
+ setTimeout(() => {
959
+ this.focus();
960
+ }, 300);
961
+ }
931
962
  }
932
963
 
933
964
  class KritzelKeyboardHelper {
@@ -961,24 +992,6 @@ class KritzelKeyboardHelper {
961
992
  }
962
993
  }
963
994
 
964
- class KritzelToolRegistry {
965
- static registerTool(toolName, constructor, store) {
966
- const toolInstance = new constructor(store);
967
- toolInstance.name = toolName;
968
- this.registry[toolName] = toolInstance;
969
- return toolInstance;
970
- }
971
- static getTool(toolName) {
972
- const toolInstance = this.registry[toolName];
973
- if (!toolInstance) {
974
- console.warn(`Unknown tool: ${toolName}`);
975
- return null;
976
- }
977
- return toolInstance;
978
- }
979
- }
980
- KritzelToolRegistry.registry = {};
981
-
982
995
  class KritzelTextTool extends KritzelBaseTool {
983
996
  constructor(store) {
984
997
  super(store);
@@ -1003,84 +1016,93 @@ class KritzelTextTool extends KritzelBaseTool {
1003
1016
  '#800080',
1004
1017
  ];
1005
1018
  }
1006
- handleMouseDown(event) {
1007
- const path = event.composedPath().slice(1);
1008
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1009
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1010
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1011
- this._store.state.activeText = object;
1012
- object.focus();
1013
- return;
1014
- }
1015
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
1016
- object.focus();
1017
- return;
1018
- }
1019
- if (this._store.state.activeText !== null) {
1020
- this._store.resetActiveText();
1021
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1022
- return;
1023
- }
1024
- if (KritzelEventHelper.isLeftClick(event) === false) {
1025
- return;
1019
+ handlePointerDown(event) {
1020
+ if (event.pointerType === 'mouse') {
1021
+ const path = event.composedPath().slice(1);
1022
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1023
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1024
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1025
+ this._store.state.activeText = object;
1026
+ object.focus();
1027
+ return;
1028
+ }
1029
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
1030
+ object.focus();
1031
+ return;
1032
+ }
1033
+ if (this._store.state.activeText !== null) {
1034
+ this._store.resetActiveText();
1035
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1036
+ return;
1037
+ }
1038
+ if (KritzelEventHelper.isLeftClick(event) === false) {
1039
+ return;
1040
+ }
1041
+ const clientX = event.clientX - this._store.offsetX;
1042
+ const clientY = event.clientY - this._store.offsetY;
1043
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1044
+ text.fontColor = this.fontColor;
1045
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1046
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1047
+ text.zIndex = this._store.currentZIndex;
1048
+ this._store.state.activeText = text;
1049
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1050
+ }
1051
+ if (event.pointerType === 'touch') {
1052
+ const activePointers = Array.from(this._store.state.pointers.values());
1053
+ const path = event.composedPath().slice(1);
1054
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1055
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1056
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1057
+ this._store.state.activeText = object;
1058
+ object.focus();
1059
+ return;
1060
+ }
1061
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
1062
+ object.focus();
1063
+ return;
1064
+ }
1065
+ if (this._store.state.activeText !== null) {
1066
+ this._store.resetActiveText();
1067
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1068
+ return;
1069
+ }
1070
+ if (activePointers.length > 1) {
1071
+ return;
1072
+ }
1073
+ KritzelKeyboardHelper.disableInteractiveWidget();
1074
+ const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
1075
+ const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
1076
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1077
+ text.fontColor = this.fontColor;
1078
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1079
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1080
+ text.zIndex = this._store.currentZIndex;
1081
+ this._store.state.activeText = text;
1082
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1083
+ }
1084
+ }
1085
+ handlePointerUp(event) {
1086
+ var _a, _b, _c, _d;
1087
+ if (event.pointerType === 'mouse') {
1088
+ (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
1089
+ (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
1090
+ }
1091
+ if (event.pointerType === 'touch') {
1092
+ (_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
1093
+ (_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
1094
+ KritzelKeyboardHelper.enableInteractiveWidget();
1026
1095
  }
1027
- const clientX = event.clientX - this._store.offsetX;
1028
- const clientY = event.clientY - this._store.offsetY;
1029
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1030
- text.fontColor = this.fontColor;
1031
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1032
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1033
- text.zIndex = this._store.currentZIndex;
1034
- text.adjustTextareaSize();
1035
- this._store.state.activeText = text;
1036
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1037
- }
1038
- handleMouseUp(_event) {
1039
- var _a, _b;
1040
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
1041
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
1042
1096
  }
1043
- handleTouchStart(event) {
1044
- const path = event.composedPath().slice(1);
1045
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
1046
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
1047
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
1048
- this._store.state.activeText = object;
1049
- object.focus();
1050
- return;
1051
- }
1052
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
1053
- object.focus();
1054
- return;
1055
- }
1056
- if (this._store.state.activeText !== null) {
1057
- this._store.resetActiveText();
1058
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
1059
- return;
1060
- }
1061
- if (this._store.state.touchCount > 1) {
1062
- return;
1063
- }
1064
- KritzelKeyboardHelper.disableInteractiveWidget();
1065
- const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);
1066
- const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);
1067
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
1068
- text.fontColor = this.fontColor;
1069
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
1070
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
1071
- text.zIndex = this._store.currentZIndex;
1072
- this._store.state.activeText = text;
1073
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
1074
- }
1075
- handleTouchEnd(_event) {
1076
- var _a, _b;
1077
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
1078
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
1079
- KritzelKeyboardHelper.enableInteractiveWidget();
1097
+ }
1098
+
1099
+ class KritzelDevicesHelper {
1100
+ static isTouchDevice() {
1101
+ return window.matchMedia('(any-pointer: coarse)').matches;
1080
1102
  }
1081
1103
  }
1082
1104
 
1083
- const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 8px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid hsl(0, 0%, 0%, 4.3%));border-radius:var(--kritzel-controls-border-radius, 8px);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 8px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #0E1111);color:var(--kritzel-controls-control-selected-color, #ffffff)}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
1105
+ const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 8px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid hsl(0, 0%, 0%, 4.3%));border-radius:var(--kritzel-controls-border-radius, 8px);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 8px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.mobile) .kritzel-control:hover{background-color:unset}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}:host(.mobile) .kritzel-control:active{background-color:unset}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #0E1111) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
1084
1106
 
1085
1107
  const KritzelControls = class {
1086
1108
  constructor(hostRef) {
@@ -1090,6 +1112,7 @@ const KritzelControls = class {
1090
1112
  this.activeControl = null;
1091
1113
  this.firstConfig = null;
1092
1114
  this.tooltipVisible = false;
1115
+ this.isTouchDevice = KritzelDevicesHelper.isTouchDevice();
1093
1116
  this.kritzelEngine = null;
1094
1117
  }
1095
1118
  get activeToolAsTextTool() {
@@ -1170,16 +1193,18 @@ const KritzelControls = class {
1170
1193
  render() {
1171
1194
  var _a, _b;
1172
1195
  const hasNoConfig = ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.config) === undefined || ((_b = this.activeControl) === null || _b === void 0 ? void 0 : _b.config) === null;
1173
- return (h(Host, { key: '2b13783ef0f1638ad76bfcef22c17c3eeb849d67' }, h("kritzel-utility-panel", { key: '1babeb88133cebc9057c85723b812b99152316c6', style: {
1196
+ return (h(Host, { key: 'e5bfc1952235cb3524849733015d14e629f36f9d', class: {
1197
+ mobile: this.isTouchDevice,
1198
+ } }, h("kritzel-utility-panel", { key: '8b89423a1d1d4d93945f774f0867b2fd8bd4b0bf', style: {
1174
1199
  position: 'absolute',
1175
1200
  bottom: '56px',
1176
1201
  left: '12px',
1177
- }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), h("div", { key: '8fafebdf6726dd2bffe85cb2b3ada5f4885a2bf8', class: "kritzel-controls" }, this.controls.map(control => {
1202
+ }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), h("div", { key: '8b58a76ff194663f312cfe55fd3e29e78b8067d1', class: "kritzel-controls" }, this.controls.map(control => {
1178
1203
  var _a, _b, _c, _d, _e, _f, _g, _h;
1179
1204
  if (control.type === 'tool') {
1180
1205
  return (h("button", { class: {
1181
1206
  'kritzel-control': true,
1182
- 'selected': ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
1207
+ selected: ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.name) === (control === null || control === void 0 ? void 0 : control.name),
1183
1208
  }, key: control.name, onClick: _event => { var _a; return (_a = this.handleControlClick) === null || _a === void 0 ? void 0 : _a.call(this, control); } }, h("kritzel-icon", { name: control.icon })));
1184
1209
  }
1185
1210
  if (control.type === 'divider') {
@@ -1464,71 +1489,76 @@ class KritzelEraserTool extends KritzelBaseTool {
1464
1489
  super(store);
1465
1490
  this.touchStartTimeout = null;
1466
1491
  }
1467
- handleMouseDown(event) {
1468
- if (KritzelEventHelper.isLeftClick(event)) {
1469
- this._store.state.isErasing = true;
1492
+ handlePointerDown(event) {
1493
+ if (event.pointerType === 'mouse') {
1494
+ if (KritzelEventHelper.isLeftClick(event)) {
1495
+ this._store.state.isErasing = true;
1496
+ }
1470
1497
  }
1471
- }
1472
- handleMouseMove(event) {
1473
- var _a;
1474
- if (this._store.state.isErasing) {
1475
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1476
- if (!shadowRoot)
1477
- return;
1478
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1479
- if (!selectedObject)
1480
- return;
1481
- selectedObject.markedForRemoval = true;
1482
- this._store.rerender();
1498
+ if (event.pointerType === 'touch') {
1499
+ this.touchStartTimeout = setTimeout(() => {
1500
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
1501
+ this._store.state.isErasing = true;
1502
+ }
1503
+ }, 80);
1483
1504
  }
1484
1505
  }
1485
- handleMouseUp(_event) {
1486
- if (this._store.state.isErasing) {
1487
- const removeCommands = this._store.allObjects
1488
- .filter(object => object.markedForRemoval)
1489
- .map(object => {
1490
- object.markedForRemoval = false;
1491
- return new RemoveObjectCommand(this._store, this, object);
1492
- });
1493
- if (removeCommands.length > 0) {
1494
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1506
+ handlePointerMove(event) {
1507
+ var _a, _b;
1508
+ if (event.pointerType === 'mouse') {
1509
+ if (this._store.state.isErasing) {
1510
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1511
+ if (!shadowRoot)
1512
+ return;
1513
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1514
+ if (!selectedObject)
1515
+ return;
1516
+ selectedObject.markedForRemoval = true;
1517
+ this._store.rerender();
1495
1518
  }
1496
- this._store.state.isErasing = false;
1497
1519
  }
1498
- }
1499
- handleTouchStart(_event) {
1500
- this.touchStartTimeout = setTimeout(() => {
1501
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling) {
1502
- this._store.state.isErasing = true;
1520
+ if (event.pointerType === 'touch') {
1521
+ if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
1522
+ const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
1523
+ if (!shadowRoot)
1524
+ return;
1525
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1526
+ if (!selectedObject)
1527
+ return;
1528
+ selectedObject.markedForRemoval = true;
1529
+ this._store.rerender();
1503
1530
  }
1504
- }, 80);
1505
- }
1506
- handleTouchMove(event) {
1507
- var _a;
1508
- if (this._store.state.touchCount === 1 && this._store.state.isErasing) {
1509
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1510
- if (!shadowRoot)
1511
- return;
1512
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1513
- if (!selectedObject)
1514
- return;
1515
- selectedObject.markedForRemoval = true;
1516
- this._store.rerender();
1517
1531
  }
1518
1532
  }
1519
- handleTouchEnd(_event) {
1520
- clearTimeout(this.touchStartTimeout);
1521
- if (this._store.state.isErasing) {
1522
- const removeCommands = this._store.allObjects
1523
- .filter(object => object.markedForRemoval)
1524
- .map(object => {
1525
- object.markedForRemoval = false;
1526
- return new RemoveObjectCommand(this._store, this, object);
1527
- });
1528
- if (removeCommands.length > 0) {
1529
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1533
+ handlePointerUp(event) {
1534
+ if (event.pointerType === 'mouse') {
1535
+ if (this._store.state.isErasing) {
1536
+ const removeCommands = this._store.allObjects
1537
+ .filter(object => object.markedForRemoval)
1538
+ .map(object => {
1539
+ object.markedForRemoval = false;
1540
+ return new RemoveObjectCommand(this._store, this, object);
1541
+ });
1542
+ if (removeCommands.length > 0) {
1543
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1544
+ }
1545
+ this._store.state.isErasing = false;
1546
+ }
1547
+ }
1548
+ if (event.pointerType === 'touch') {
1549
+ clearTimeout(this.touchStartTimeout);
1550
+ if (this._store.state.isErasing) {
1551
+ const removeCommands = this._store.allObjects
1552
+ .filter(object => object.markedForRemoval)
1553
+ .map(object => {
1554
+ object.markedForRemoval = false;
1555
+ return new RemoveObjectCommand(this._store, this, object);
1556
+ });
1557
+ if (removeCommands.length > 0) {
1558
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
1559
+ }
1560
+ this._store.state.isErasing = false;
1530
1561
  }
1531
- this._store.state.isErasing = false;
1532
1562
  }
1533
1563
  }
1534
1564
  }
@@ -1615,72 +1645,79 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1615
1645
  constructor(store) {
1616
1646
  super(store);
1617
1647
  }
1618
- handleMouseDown(event) {
1619
- var _a;
1620
- if (KritzelEventHelper.isLeftClick(event)) {
1621
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1648
+ handlePointerDown(event) {
1649
+ var _a, _b;
1650
+ if (event.pointerType === 'mouse') {
1651
+ if (KritzelEventHelper.isLeftClick(event)) {
1652
+ if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1653
+ const clientX = event.clientX - this._store.offsetX;
1654
+ const clientY = event.clientY - this._store.offsetY;
1655
+ this._store.state.isDragging = true;
1656
+ this.dragStartX = clientX;
1657
+ this.dragStartY = clientY;
1658
+ this.startX = this.dragStartX;
1659
+ this.startY = this.dragStartY;
1660
+ }
1661
+ }
1662
+ }
1663
+ if (event.pointerType === 'touch') {
1664
+ const activePointers = Array.from(this._store.state.pointers.values());
1665
+ if (this._store.state.pointers.size === 1) {
1666
+ if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1667
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1668
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1669
+ this.dragStartX = x;
1670
+ this.dragStartY = y;
1671
+ this.startX = x;
1672
+ this.startY = y;
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ handlePointerMove(event) {
1678
+ if (event.pointerType === 'mouse') {
1679
+ if (this._store.state.isDragging && this._store.state.selectionGroup) {
1622
1680
  const clientX = event.clientX - this._store.offsetX;
1623
1681
  const clientY = event.clientY - this._store.offsetY;
1624
- this._store.state.isDragging = true;
1682
+ this.endX = clientX;
1683
+ this.endY = clientY;
1684
+ this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1625
1685
  this.dragStartX = clientX;
1626
1686
  this.dragStartY = clientY;
1627
- this.startX = this.dragStartX;
1628
- this.startY = this.dragStartY;
1629
1687
  }
1630
1688
  }
1631
- }
1632
- handleMouseMove(event) {
1633
- if (this._store.state.isDragging && this._store.state.selectionGroup) {
1634
- const clientX = event.clientX - this._store.offsetX;
1635
- const clientY = event.clientY - this._store.offsetY;
1636
- this.endX = clientX;
1637
- this.endY = clientY;
1638
- this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
1639
- this.dragStartX = clientX;
1640
- this.dragStartY = clientY;
1641
- }
1642
- }
1643
- handleMouseUp(_event) {
1644
- if (this._store.state.isDragging) {
1645
- this._store.state.isDragging = false;
1646
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1647
- }
1648
- }
1649
- handleTouchStart(event) {
1650
- var _a;
1651
- if (this._store.state.touchCount === 1) {
1652
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1653
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
1654
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
1655
- this.dragStartX = x;
1656
- this.dragStartY = y;
1657
- this.startX = x;
1658
- this.startY = y;
1689
+ if (event.pointerType === 'touch') {
1690
+ const activePointers = Array.from(this._store.state.pointers.values());
1691
+ if (this._store.state.pointers.size === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1692
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1693
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1694
+ this._store.state.isDragging = true;
1695
+ this.endX = x;
1696
+ this.endY = y;
1697
+ const moveDeltaX = Math.abs(x - this.startX);
1698
+ const moveDeltaY = Math.abs(y - this.startY);
1699
+ const moveThreshold = 5;
1700
+ if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
1701
+ clearTimeout(this._store.state.longTouchTimeout);
1702
+ this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1703
+ this.dragStartX = x;
1704
+ this.dragStartY = y;
1705
+ }
1659
1706
  }
1660
1707
  }
1661
1708
  }
1662
- handleTouchMove(event) {
1663
- if (this._store.state.touchCount === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1664
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
1665
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
1666
- this._store.state.isDragging = true;
1667
- this.endX = x;
1668
- this.endY = y;
1669
- const moveDeltaX = Math.abs(x - this.startX);
1670
- const moveDeltaY = Math.abs(y - this.startY);
1671
- const moveThreshold = 5;
1672
- if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
1673
- clearTimeout(this._store.state.longTouchTimeout);
1674
- this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
1675
- this.dragStartX = x;
1676
- this.dragStartY = y;
1709
+ handlePointerUp(event) {
1710
+ if (event.pointerType === 'mouse') {
1711
+ if (this._store.state.isDragging) {
1712
+ this._store.state.isDragging = false;
1713
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1677
1714
  }
1678
1715
  }
1679
- }
1680
- handleTouchEnd(_event) {
1681
- if (this._store.state.isDragging) {
1682
- this._store.state.isDragging = false;
1683
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1716
+ if (event.pointerType === 'touch') {
1717
+ if (this._store.state.isDragging) {
1718
+ this._store.state.isDragging = false;
1719
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
1720
+ }
1684
1721
  }
1685
1722
  }
1686
1723
  }
@@ -1718,131 +1755,140 @@ class KritzelResizeHandler extends KritzelBaseHandler {
1718
1755
  this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
1719
1756
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
1720
1757
  }
1721
- handleMouseDown(event) {
1722
- if (KritzelEventHelper.isLeftClick(event)) {
1723
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1724
- const clientX = event.clientX - this._store.offsetX;
1725
- const clientY = event.clientY - this._store.offsetY;
1726
- this._store.state.isResizing = true;
1727
- this.initialMouseX = clientX;
1728
- this.initialMouseY = clientY;
1729
- this.initialSize.width = this._store.state.selectionGroup.width;
1730
- this.initialSize.height = this._store.state.selectionGroup.height;
1731
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1732
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1758
+ handlePointerDown(event) {
1759
+ if (event.pointerType === 'mouse') {
1760
+ if (KritzelEventHelper.isLeftClick(event)) {
1761
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1762
+ const clientX = event.clientX - this._store.offsetX;
1763
+ const clientY = event.clientY - this._store.offsetY;
1764
+ this._store.state.isResizing = true;
1765
+ this.initialMouseX = clientX;
1766
+ this.initialMouseY = clientY;
1767
+ this.initialSize.width = this._store.state.selectionGroup.width;
1768
+ this.initialSize.height = this._store.state.selectionGroup.height;
1769
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
1770
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
1771
+ }
1733
1772
  }
1734
1773
  }
1735
- }
1736
- handleMouseMove(event) {
1737
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1738
- const clientX = event.clientX - this._store.offsetX;
1739
- const clientY = event.clientY - this._store.offsetY;
1740
- const dx = clientX - this.initialMouseX;
1741
- const dy = clientY - this.initialMouseY;
1742
- switch (this._store.state.resizeHandleType) {
1743
- case KritzelHandleType.TopLeft:
1744
- this.newSize.width = this.initialSize.width - dx;
1745
- this.newSize.height = this.initialSize.height - dy;
1746
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1747
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1748
- break;
1749
- case KritzelHandleType.TopRight:
1750
- this.newSize.width = this.initialSize.width + dx;
1751
- this.newSize.height = this.initialSize.height - dy;
1752
- this.newSize.x = this.initialSize.x;
1753
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1754
- break;
1755
- case KritzelHandleType.BottomLeft:
1756
- this.newSize.width = this.initialSize.width - dx;
1757
- this.newSize.height = this.initialSize.height + dy;
1758
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1759
- this.newSize.y = this.initialSize.y;
1760
- break;
1761
- case KritzelHandleType.BottomRight:
1762
- this.newSize.width = this.initialSize.width + dx;
1763
- this.newSize.height = this.initialSize.height + dy;
1764
- this.newSize.x = this.initialSize.x;
1765
- this.newSize.y = this.initialSize.y;
1766
- break;
1774
+ if (event.pointerType === 'touch') {
1775
+ const activePointers = Array.from(this._store.state.pointers.values());
1776
+ const firstTouch = activePointers[0];
1777
+ if (!firstTouch) {
1778
+ return;
1779
+ }
1780
+ if (activePointers.length === 1) {
1781
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1782
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1783
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1784
+ this._store.state.isResizing = true;
1785
+ this.initialMouseX = clientX;
1786
+ this.initialMouseY = clientY;
1787
+ this.initialSize.width = this._store.state.selectionGroup.width;
1788
+ this.initialSize.height = this._store.state.selectionGroup.height;
1789
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
1790
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
1791
+ clearTimeout(this._store.state.longTouchTimeout);
1792
+ }
1767
1793
  }
1768
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1769
- this._store.rerender();
1770
- }
1771
- }
1772
- handleMouseUp(_event) {
1773
- if (this._store.state.isResizing) {
1774
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1775
- this._store.history.executeCommand(resizeSelectionGroupCommand);
1776
- this._store.state.isResizing = false;
1777
- this._store.rerender();
1778
1794
  }
1779
1795
  }
1780
- handleTouchStart(event) {
1781
- const firstTouch = event.touches[0];
1782
- if (!firstTouch) {
1783
- return;
1796
+ handlePointerMove(event) {
1797
+ if (event.pointerType === 'mouse') {
1798
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
1799
+ const clientX = event.clientX - this._store.offsetX;
1800
+ const clientY = event.clientY - this._store.offsetY;
1801
+ const dx = clientX - this.initialMouseX;
1802
+ const dy = clientY - this.initialMouseY;
1803
+ switch (this._store.state.resizeHandleType) {
1804
+ case KritzelHandleType.TopLeft:
1805
+ this.newSize.width = this.initialSize.width - dx;
1806
+ this.newSize.height = this.initialSize.height - dy;
1807
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1808
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1809
+ break;
1810
+ case KritzelHandleType.TopRight:
1811
+ this.newSize.width = this.initialSize.width + dx;
1812
+ this.newSize.height = this.initialSize.height - dy;
1813
+ this.newSize.x = this.initialSize.x;
1814
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1815
+ break;
1816
+ case KritzelHandleType.BottomLeft:
1817
+ this.newSize.width = this.initialSize.width - dx;
1818
+ this.newSize.height = this.initialSize.height + dy;
1819
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1820
+ this.newSize.y = this.initialSize.y;
1821
+ break;
1822
+ case KritzelHandleType.BottomRight:
1823
+ this.newSize.width = this.initialSize.width + dx;
1824
+ this.newSize.height = this.initialSize.height + dy;
1825
+ this.newSize.x = this.initialSize.x;
1826
+ this.newSize.y = this.initialSize.y;
1827
+ break;
1828
+ }
1829
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1830
+ this._store.rerender();
1831
+ }
1784
1832
  }
1785
- if (this._store.state.touchCount === 1) {
1786
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
1787
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1788
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1789
- this._store.state.isResizing = true;
1790
- this.initialMouseX = clientX;
1791
- this.initialMouseY = clientY;
1792
- this.initialSize.width = this._store.state.selectionGroup.width;
1793
- this.initialSize.height = this._store.state.selectionGroup.height;
1794
- this.initialSize.x = this._store.state.selectionGroup.translateX;
1795
- this.initialSize.y = this._store.state.selectionGroup.translateY;
1833
+ if (event.pointerType === 'touch') {
1834
+ const activePointers = Array.from(this._store.state.pointers.values());
1835
+ const oneFingerTouch = activePointers[0];
1836
+ if (!oneFingerTouch) {
1837
+ return;
1838
+ }
1839
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
1840
+ const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
1841
+ const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
1842
+ const dx = clientX - this.initialMouseX;
1843
+ const dy = clientY - this.initialMouseY;
1844
+ switch (this._store.state.resizeHandleType) {
1845
+ case KritzelHandleType.TopLeft:
1846
+ this.newSize.width = this.initialSize.width - dx;
1847
+ this.newSize.height = this.initialSize.height - dy;
1848
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1849
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1850
+ break;
1851
+ case KritzelHandleType.TopRight:
1852
+ this.newSize.width = this.initialSize.width + dx;
1853
+ this.newSize.height = this.initialSize.height - dy;
1854
+ this.newSize.x = this.initialSize.x;
1855
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1856
+ break;
1857
+ case KritzelHandleType.BottomLeft:
1858
+ this.newSize.width = this.initialSize.width - dx;
1859
+ this.newSize.height = this.initialSize.height + dy;
1860
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1861
+ this.newSize.y = this.initialSize.y;
1862
+ break;
1863
+ case KritzelHandleType.BottomRight:
1864
+ this.newSize.width = this.initialSize.width + dx;
1865
+ this.newSize.height = this.initialSize.height + dy;
1866
+ this.newSize.x = this.initialSize.x;
1867
+ this.newSize.y = this.initialSize.y;
1868
+ break;
1869
+ }
1870
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1796
1871
  clearTimeout(this._store.state.longTouchTimeout);
1797
1872
  }
1798
1873
  }
1799
1874
  }
1800
- handleTouchMove(event) {
1801
- const oneFingerTouch = event.touches[0];
1802
- if (!oneFingerTouch) {
1803
- return;
1804
- }
1805
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
1806
- const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
1807
- const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
1808
- const dx = clientX - this.initialMouseX;
1809
- const dy = clientY - this.initialMouseY;
1810
- switch (this._store.state.resizeHandleType) {
1811
- case KritzelHandleType.TopLeft:
1812
- this.newSize.width = this.initialSize.width - dx;
1813
- this.newSize.height = this.initialSize.height - dy;
1814
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1815
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1816
- break;
1817
- case KritzelHandleType.TopRight:
1818
- this.newSize.width = this.initialSize.width + dx;
1819
- this.newSize.height = this.initialSize.height - dy;
1820
- this.newSize.x = this.initialSize.x;
1821
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
1822
- break;
1823
- case KritzelHandleType.BottomLeft:
1824
- this.newSize.width = this.initialSize.width - dx;
1825
- this.newSize.height = this.initialSize.height + dy;
1826
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
1827
- this.newSize.y = this.initialSize.y;
1828
- break;
1829
- case KritzelHandleType.BottomRight:
1830
- this.newSize.width = this.initialSize.width + dx;
1831
- this.newSize.height = this.initialSize.height + dy;
1832
- this.newSize.x = this.initialSize.x;
1833
- this.newSize.y = this.initialSize.y;
1834
- break;
1875
+ handlePointerUp(event) {
1876
+ if (event.pointerType === 'mouse') {
1877
+ if (this._store.state.isResizing) {
1878
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1879
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
1880
+ this._store.state.isResizing = false;
1881
+ this._store.rerender();
1835
1882
  }
1836
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
1837
- clearTimeout(this._store.state.longTouchTimeout);
1838
1883
  }
1839
- }
1840
- handleTouchEnd(_event) {
1841
- if (this._store.state.isResizing) {
1842
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1843
- this._store.history.executeCommand(resizeSelectionGroupCommand);
1844
- this._store.state.isResizing = false;
1845
- clearTimeout(this._store.state.longTouchTimeout);
1884
+ if (event.pointerType === 'touch') {
1885
+ if (this._store.state.isResizing) {
1886
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
1887
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
1888
+ this._store.state.isResizing = false;
1889
+ this._store.rerender();
1890
+ clearTimeout(this._store.state.longTouchTimeout);
1891
+ }
1846
1892
  }
1847
1893
  }
1848
1894
  }
@@ -1876,87 +1922,95 @@ class KritzelRotationHandler extends KritzelBaseHandler {
1876
1922
  this.initialRotation = 0;
1877
1923
  this.rotation = 0;
1878
1924
  }
1879
- handleMouseDown(event) {
1880
- if (KritzelEventHelper.isLeftClick(event)) {
1881
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1925
+ handlePointerDown(event) {
1926
+ if (event.pointerType === 'mouse') {
1927
+ if (KritzelEventHelper.isLeftClick(event)) {
1928
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1929
+ const clientX = event.clientX - this._store.offsetX;
1930
+ const clientY = event.clientY - this._store.offsetY;
1931
+ this._store.state.isRotating = true;
1932
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1933
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1934
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1935
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1936
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1937
+ }
1938
+ }
1939
+ }
1940
+ if (event.pointerType === 'touch') {
1941
+ const activePointers = Array.from(this._store.state.pointers.values());
1942
+ const firstTouch = activePointers[0];
1943
+ if (!firstTouch) {
1944
+ return;
1945
+ }
1946
+ if (activePointers.length === 1) {
1947
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1948
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1949
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1950
+ this._store.state.isRotating = true;
1951
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1952
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1953
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1954
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1955
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1956
+ clearTimeout(this._store.state.longTouchTimeout);
1957
+ }
1958
+ }
1959
+ }
1960
+ }
1961
+ handlePointerMove(event) {
1962
+ if (event.pointerType === 'mouse') {
1963
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
1882
1964
  const clientX = event.clientX - this._store.offsetX;
1883
1965
  const clientY = event.clientY - this._store.offsetY;
1884
- this._store.state.isRotating = true;
1885
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1886
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1966
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1967
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1887
1968
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1888
1969
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1889
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1970
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1971
+ this.rotation = currentRotation - this.initialRotation;
1972
+ this._store.state.selectionGroup.rotate(this.rotation);
1973
+ this._store.rerender();
1890
1974
  }
1891
1975
  }
1892
- }
1893
- handleMouseMove(event) {
1894
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1895
- const clientX = event.clientX - this._store.offsetX;
1896
- const clientY = event.clientY - this._store.offsetY;
1897
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1898
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1899
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1900
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1901
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1902
- this.rotation = currentRotation - this.initialRotation;
1903
- this._store.state.selectionGroup.rotate(this.rotation);
1904
- this._store.rerender();
1905
- }
1906
- }
1907
- handleMouseUp(_event) {
1908
- if (this._store.state.isRotating) {
1909
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
1910
- this._store.state.isRotating = false;
1911
- this.initialRotation = 0;
1912
- this.rotation = 0;
1913
- }
1914
- }
1915
- handleTouchStart(event) {
1916
- const firstTouch = event.touches[0];
1917
- if (!firstTouch) {
1918
- return;
1919
- }
1920
- if (this._store.state.touchCount === 1) {
1921
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
1976
+ if (event.pointerType === 'touch') {
1977
+ const activePointers = Array.from(this._store.state.pointers.values());
1978
+ const firstTouch = activePointers[0];
1979
+ if (!firstTouch) {
1980
+ return;
1981
+ }
1982
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
1922
1983
  const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1923
1984
  const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1924
- this._store.state.isRotating = true;
1925
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1926
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1985
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1986
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1927
1987
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1928
1988
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1929
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
1989
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1990
+ this.rotation = currentRotation - this.initialRotation;
1991
+ this._store.state.selectionGroup.rotate(this.rotation);
1992
+ this._store.rerender();
1930
1993
  clearTimeout(this._store.state.longTouchTimeout);
1931
1994
  }
1932
1995
  }
1933
1996
  }
1934
- handleTouchMove(event) {
1935
- const firstTouch = event.touches[0];
1936
- if (!firstTouch) {
1937
- return;
1938
- }
1939
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
1940
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
1941
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
1942
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
1943
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
1944
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
1945
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
1946
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
1947
- this.rotation = currentRotation - this.initialRotation;
1948
- this._store.state.selectionGroup.rotate(this.rotation);
1949
- this._store.rerender();
1950
- clearTimeout(this._store.state.longTouchTimeout);
1997
+ handlePointerUp(event) {
1998
+ if (event.pointerType === 'mouse') {
1999
+ if (this._store.state.isRotating) {
2000
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
2001
+ this._store.state.isRotating = false;
2002
+ this.initialRotation = 0;
2003
+ this.rotation = 0;
2004
+ }
1951
2005
  }
1952
- }
1953
- handleTouchEnd(_event) {
1954
- if (this._store.state.isRotating) {
1955
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
1956
- this._store.state.isRotating = false;
1957
- this.initialRotation = 0;
1958
- this.rotation = 0;
1959
- clearTimeout(this._store.state.longTouchTimeout);
2006
+ if (event.pointerType === 'touch') {
2007
+ if (this._store.state.isRotating) {
2008
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
2009
+ this._store.state.isRotating = false;
2010
+ this.initialRotation = 0;
2011
+ this.rotation = 0;
2012
+ clearTimeout(this._store.state.longTouchTimeout);
2013
+ }
1960
2014
  }
1961
2015
  }
1962
2016
  }
@@ -2064,63 +2118,70 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2064
2118
  this.touchStartY = 0;
2065
2119
  this.touchStartTimeout = null;
2066
2120
  }
2067
- handleMouseDown(event) {
2068
- if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
2069
- this.startMouseSelection(event);
2121
+ handlePointerDown(event) {
2122
+ if (event.pointerType === 'mouse') {
2123
+ if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
2124
+ this.startMouseSelection(event);
2125
+ }
2070
2126
  }
2071
- }
2072
- handleMouseMove(event) {
2073
- if (this._store.state.isSelecting) {
2074
- this.updateMouseSelection(event);
2127
+ if (event.pointerType === 'touch') {
2128
+ this.touchStartTimeout = setTimeout(() => {
2129
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
2130
+ this.startTouchSelection();
2131
+ this.updateTouchSelection();
2132
+ }
2133
+ }, 80);
2075
2134
  }
2076
2135
  }
2077
- handleMouseUp(event) {
2078
- if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
2079
- if (this.isSelectionClick) {
2136
+ handlePointerMove(event) {
2137
+ if (event.pointerType === 'mouse') {
2138
+ if (this._store.state.isSelecting) {
2080
2139
  this.updateMouseSelection(event);
2081
- this.addSelectedObjectAtIndexToSelectionGroup(0);
2082
- this.removeSelectionBox();
2083
2140
  }
2084
- if (this.isSelectionDrag) {
2085
- this.updateMouseSelection(event);
2086
- this.addSelectedObjectsToSelectionGroup();
2087
- this.removeSelectionBox();
2141
+ }
2142
+ if (event.pointerType === 'touch') {
2143
+ const activePointers = Array.from(this._store.state.pointers.values());
2144
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
2145
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
2146
+ const moveDeltaX = Math.abs(x - this.touchStartX);
2147
+ const moveDeltaY = Math.abs(y - this.touchStartY);
2148
+ const moveThreshold = 5;
2149
+ if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
2150
+ this.updateTouchSelection();
2151
+ clearTimeout(this._store.state.longTouchTimeout);
2088
2152
  }
2089
2153
  }
2090
2154
  }
2091
- handleTouchStart(event) {
2092
- this.touchStartTimeout = setTimeout(() => {
2093
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
2094
- this.startTouchSelection(event);
2095
- this.updateTouchSelection(event);
2096
- }
2097
- }, 80);
2098
- }
2099
- handleTouchMove(event) {
2100
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
2101
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
2102
- const moveDeltaX = Math.abs(x - this.touchStartX);
2103
- const moveDeltaY = Math.abs(y - this.touchStartY);
2104
- const moveThreshold = 5;
2105
- if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
2106
- this.updateTouchSelection(event);
2107
- clearTimeout(this._store.state.longTouchTimeout);
2108
- }
2109
- }
2110
- handleTouchEnd(event) {
2111
- clearTimeout(this.touchStartTimeout);
2112
- if (this._store.state.isSelecting) {
2113
- if (this.isSelectionClick) {
2114
- this.updateTouchSelection(event);
2115
- this.addSelectedObjectAtIndexToSelectionGroup(0);
2116
- this.removeSelectionBox();
2155
+ handlePointerUp(event) {
2156
+ if (event.pointerType === 'mouse') {
2157
+ if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
2158
+ if (this.isSelectionClick) {
2159
+ this.updateMouseSelection(event);
2160
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
2161
+ this.removeSelectionBox();
2162
+ }
2163
+ if (this.isSelectionDrag) {
2164
+ this.updateMouseSelection(event);
2165
+ this.addSelectedObjectsToSelectionGroup();
2166
+ this.removeSelectionBox();
2167
+ }
2117
2168
  }
2118
- if (this.isSelectionDrag) {
2119
- this.updateTouchSelection(event);
2120
- this.addSelectedObjectsToSelectionGroup();
2121
- this.removeSelectionBox();
2169
+ }
2170
+ if (event.pointerType === 'touch') {
2171
+ clearTimeout(this.touchStartTimeout);
2172
+ if (this._store.state.isSelecting) {
2173
+ if (this.isSelectionClick) {
2174
+ this.updateTouchSelection();
2175
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
2176
+ this.removeSelectionBox();
2177
+ }
2178
+ if (this.isSelectionDrag) {
2179
+ this.updateTouchSelection();
2180
+ this.addSelectedObjectsToSelectionGroup();
2181
+ this.removeSelectionBox();
2182
+ }
2183
+ this._store.state.skipContextMenu = false;
2122
2184
  }
2123
- this._store.state.skipContextMenu = false;
2124
2185
  }
2125
2186
  }
2126
2187
  removeSelectionBox() {
@@ -2144,8 +2205,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2144
2205
  this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
2145
2206
  this._store.state.objectsOctree.insert(selectionBox);
2146
2207
  }
2147
- startTouchSelection(event) {
2148
- const firstTouch = event.touches[0];
2208
+ startTouchSelection() {
2209
+ const activePointers = Array.from(this._store.state.pointers.values());
2210
+ const firstTouch = activePointers[0];
2149
2211
  if (!firstTouch) {
2150
2212
  return;
2151
2213
  }
@@ -2181,8 +2243,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
2181
2243
  this._store.rerender();
2182
2244
  }
2183
2245
  }
2184
- updateTouchSelection(event) {
2185
- const firstTouch = event.touches[0];
2246
+ updateTouchSelection() {
2247
+ const activePointers = Array.from(this._store.state.pointers.values());
2248
+ const firstTouch = activePointers[0];
2186
2249
  if (!firstTouch) {
2187
2250
  return;
2188
2251
  }
@@ -2248,39 +2311,103 @@ class KritzelSelectionTool extends KritzelBaseTool {
2248
2311
  this.resizeHandler = new KritzelResizeHandler(this._store);
2249
2312
  this.rotationHandler = new KritzelRotationHandler(this._store);
2250
2313
  }
2251
- handleMouseDown(event) {
2252
- if (KritzelEventHelper.isLeftClick(event)) {
2253
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2254
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2255
- this._store.state.resizeHandleType = this.getHandleType(event);
2256
- const selectedObject = this.getSelectedObject(event);
2257
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2258
- if ((selectedObject === null || isDifferentObject) &&
2259
- this._store.state.selectionGroup &&
2260
- !this._store.state.isResizeHandleSelected &&
2261
- !this._store.state.isRotationHandleSelected) {
2262
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2314
+ handlePointerDown(event) {
2315
+ if (event.pointerType === 'mouse') {
2316
+ if (KritzelEventHelper.isLeftClick(event)) {
2317
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2318
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2319
+ this._store.state.resizeHandleType = this.getHandleType(event);
2320
+ const selectedObject = this.getSelectedObject(event);
2321
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2322
+ if ((selectedObject === null || isDifferentObject) &&
2323
+ this._store.state.selectionGroup &&
2324
+ !this._store.state.isResizeHandleSelected &&
2325
+ !this._store.state.isRotationHandleSelected) {
2326
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2327
+ }
2328
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
2329
+ setTimeout(() => {
2330
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
2331
+ selectedObject.objects[0].onSelectedClick();
2332
+ }
2333
+ }, 100);
2334
+ }
2263
2335
  }
2336
+ this.moveHandler.handlePointerDown(event);
2337
+ this.selectionHandler.handlePointerDown(event);
2338
+ this.resizeHandler.handlePointerDown(event);
2339
+ this.rotationHandler.handlePointerDown(event);
2340
+ this._store.rerender();
2341
+ }
2342
+ if (event.pointerType === 'touch') {
2343
+ if (this._store.state.isScaling === true) {
2344
+ return;
2345
+ }
2346
+ if (this._store.state.pointers.size === 1) {
2347
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2348
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2349
+ this._store.state.resizeHandleType = this.getHandleType(event);
2350
+ const selectedObject = this.getSelectedObject(event);
2351
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2352
+ if (!this._store.state.selectionGroup && selectedObject) {
2353
+ this._store.state.skipContextMenu = true;
2354
+ }
2355
+ if ((selectedObject === null || isDifferentObject) &&
2356
+ this._store.state.selectionGroup &&
2357
+ !this._store.state.isResizeHandleSelected &&
2358
+ !this._store.state.isRotationHandleSelected) {
2359
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2360
+ }
2361
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
2362
+ setTimeout(() => {
2363
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
2364
+ selectedObject.objects[0].onSelectedClick();
2365
+ }
2366
+ }, 100);
2367
+ }
2368
+ }
2369
+ this.rotationHandler.handlePointerDown(event);
2370
+ this.resizeHandler.handlePointerDown(event);
2371
+ this.moveHandler.handlePointerDown(event);
2372
+ this.selectionHandler.handlePointerDown(event);
2373
+ }
2374
+ }
2375
+ handlePointerMove(event) {
2376
+ if (event.pointerType === 'mouse') {
2377
+ this.moveHandler.handlePointerMove(event);
2378
+ this.selectionHandler.handlePointerMove(event);
2379
+ this.resizeHandler.handlePointerMove(event);
2380
+ this.rotationHandler.handlePointerMove(event);
2381
+ this._store.rerender();
2382
+ }
2383
+ if (event.pointerType === 'touch') {
2384
+ if (this._store.state.isScaling === true) {
2385
+ return;
2386
+ }
2387
+ this.rotationHandler.handlePointerMove(event);
2388
+ this.resizeHandler.handlePointerMove(event);
2389
+ this.moveHandler.handlePointerMove(event);
2390
+ this.selectionHandler.handlePointerMove(event);
2391
+ this._store.rerender();
2264
2392
  }
2265
- this.moveHandler.handleMouseDown(event);
2266
- this.selectionHandler.handleMouseDown(event);
2267
- this.resizeHandler.handleMouseDown(event);
2268
- this.rotationHandler.handleMouseDown(event);
2269
- this._store.rerender();
2270
- }
2271
- handleMouseMove(event) {
2272
- this.moveHandler.handleMouseMove(event);
2273
- this.selectionHandler.handleMouseMove(event);
2274
- this.resizeHandler.handleMouseMove(event);
2275
- this.rotationHandler.handleMouseMove(event);
2276
- this._store.rerender();
2277
2393
  }
2278
- handleMouseUp(event) {
2279
- this.moveHandler.handleMouseUp(event);
2280
- this.selectionHandler.handleMouseUp(event);
2281
- this.resizeHandler.handleMouseUp(event);
2282
- this.rotationHandler.handleMouseUp(event);
2283
- this._store.rerender();
2394
+ handlePointerUp(event) {
2395
+ if (event.pointerType === 'mouse') {
2396
+ this.moveHandler.handlePointerUp(event);
2397
+ this.selectionHandler.handlePointerUp(event);
2398
+ this.resizeHandler.handlePointerUp(event);
2399
+ this.rotationHandler.handlePointerUp(event);
2400
+ this._store.rerender();
2401
+ }
2402
+ if (event.pointerType === 'touch') {
2403
+ if (this._store.state.isScaling === true) {
2404
+ return;
2405
+ }
2406
+ this.rotationHandler.handlePointerUp(event);
2407
+ this.resizeHandler.handlePointerUp(event);
2408
+ this.moveHandler.handlePointerUp(event);
2409
+ this.selectionHandler.handlePointerUp(event);
2410
+ }
2284
2411
  }
2285
2412
  handleDoubleClick(event) {
2286
2413
  var _a;
@@ -2312,50 +2439,6 @@ class KritzelSelectionTool extends KritzelBaseTool {
2312
2439
  }, 300);
2313
2440
  }
2314
2441
  }
2315
- handleTouchStart(event) {
2316
- if (this._store.state.isScaling === true) {
2317
- return;
2318
- }
2319
- if (this._store.state.touchCount === 1) {
2320
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
2321
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
2322
- this._store.state.resizeHandleType = this.getHandleType(event);
2323
- const selectedObject = this.getSelectedObject(event);
2324
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
2325
- if (!this._store.state.selectionGroup && selectedObject) {
2326
- this._store.state.skipContextMenu = true;
2327
- }
2328
- if ((selectedObject === null || isDifferentObject) &&
2329
- this._store.state.selectionGroup &&
2330
- !this._store.state.isResizeHandleSelected &&
2331
- !this._store.state.isRotationHandleSelected) {
2332
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
2333
- }
2334
- }
2335
- this.rotationHandler.handleTouchStart(event);
2336
- this.resizeHandler.handleTouchStart(event);
2337
- this.moveHandler.handleTouchStart(event);
2338
- this.selectionHandler.handleTouchStart(event);
2339
- }
2340
- handleTouchMove(event) {
2341
- if (this._store.state.isScaling === true) {
2342
- return;
2343
- }
2344
- this.rotationHandler.handleTouchMove(event);
2345
- this.resizeHandler.handleTouchMove(event);
2346
- this.moveHandler.handleTouchMove(event);
2347
- this.selectionHandler.handleTouchMove(event);
2348
- this._store.rerender();
2349
- }
2350
- handleTouchEnd(event) {
2351
- if (this._store.state.isScaling === true) {
2352
- return;
2353
- }
2354
- this.rotationHandler.handleTouchEnd(event);
2355
- this.resizeHandler.handleTouchEnd(event);
2356
- this.moveHandler.handleTouchEnd(event);
2357
- this.selectionHandler.handleTouchEnd(event);
2358
- }
2359
2442
  getSelectedObject(event) {
2360
2443
  const path = event.composedPath().slice(1);
2361
2444
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
@@ -2849,7 +2932,7 @@ const DEFAULT_KRITZEL_CONTROLS = [
2849
2932
  },
2850
2933
  ];
2851
2934
 
2852
- const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none}kritzel-controls{position:absolute;bottom:28px}";
2935
+ const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:28px}";
2853
2936
 
2854
2937
  const KritzelEditor = class {
2855
2938
  constructor(hostRef) {
@@ -2898,85 +2981,91 @@ class KritzelViewport {
2898
2981
  this._store.state.hasViewportChanged = true;
2899
2982
  this._store.rerender();
2900
2983
  }
2901
- handleMouseDown(event) {
2902
- const adjustedClientX = event.clientX - this._store.offsetX;
2903
- const adjustedClientY = event.clientY - this._store.offsetY;
2904
- if (KritzelEventHelper.isRightClick(event)) {
2905
- this._store.state.isPanning = true;
2906
- this._store.state.startX = adjustedClientX;
2907
- this._store.state.startY = adjustedClientY;
2908
- }
2909
- }
2910
- handleMouseMove(event) {
2911
- const adjustedClientX = event.clientX - this._store.offsetX;
2912
- const adjustedClientY = event.clientY - this._store.offsetY;
2913
- this._store.state.cursorX = adjustedClientX;
2914
- this._store.state.cursorY = adjustedClientY;
2915
- if (this._store.state.isPanning) {
2916
- this._store.state.translateX -= this._store.state.startX - adjustedClientX;
2917
- this._store.state.translateY -= this._store.state.startY - adjustedClientY;
2918
- this._store.state.startX = adjustedClientX;
2919
- this._store.state.startY = adjustedClientY;
2920
- this._store.state.hasViewportChanged = true;
2921
- this._store.state.skipContextMenu = true;
2922
- this._store.rerender();
2984
+ handlePointerDown(event) {
2985
+ if (event.pointerType === 'mouse') {
2986
+ const adjustedClientX = event.clientX - this._store.offsetX;
2987
+ const adjustedClientY = event.clientY - this._store.offsetY;
2988
+ if (event.button === KritzelMouseButton.Right) {
2989
+ this._store.state.isPanning = true;
2990
+ this._store.state.startX = adjustedClientX;
2991
+ this._store.state.startY = adjustedClientY;
2992
+ }
2923
2993
  }
2924
- }
2925
- handleMouseUp(_event) {
2926
- if (this._store.state.isPanning) {
2927
- this._store.state.isPanning = false;
2928
- this._store.rerender();
2994
+ if (event.pointerType === 'touch') {
2995
+ const activePointers = Array.from(this._store.state.pointers.values());
2996
+ if (activePointers.length === 2) {
2997
+ this._store.state.currentPath = null;
2998
+ this._store.state.isScaling = true;
2999
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
3000
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
3001
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
3002
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
3003
+ this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
3004
+ this.startX = (firstTouchX + secondTouchX) / 2;
3005
+ this.startY = (firstTouchY + secondTouchY) / 2;
3006
+ this._store.rerender();
3007
+ }
2929
3008
  }
2930
3009
  }
2931
- handleTouchStart(event) {
2932
- this._store.state.touchCount = event.touches.length;
2933
- if (this._store.state.touchCount === 2) {
2934
- this._store.state.currentPath = null;
2935
- this._store.state.isScaling = true;
2936
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
2937
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
2938
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
2939
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
2940
- this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
2941
- this.startX = (firstTouchX + secondTouchX) / 2;
2942
- this.startY = (firstTouchY + secondTouchY) / 2;
2943
- this._store.rerender();
3010
+ handlePointerMove(event) {
3011
+ if (event.pointerType === 'mouse') {
3012
+ const adjustedClientX = event.clientX - this._store.offsetX;
3013
+ const adjustedClientY = event.clientY - this._store.offsetY;
3014
+ this._store.state.cursorX = adjustedClientX;
3015
+ this._store.state.cursorY = adjustedClientY;
3016
+ if (this._store.state.isPanning) {
3017
+ this._store.state.translateX -= this._store.state.startX - adjustedClientX;
3018
+ this._store.state.translateY -= this._store.state.startY - adjustedClientY;
3019
+ this._store.state.startX = adjustedClientX;
3020
+ this._store.state.startY = adjustedClientY;
3021
+ this._store.state.hasViewportChanged = true;
3022
+ this._store.state.skipContextMenu = true;
3023
+ this._store.rerender();
3024
+ }
2944
3025
  }
2945
- }
2946
- handleTouchMove(event) {
2947
- if (this._store.state.touchCount === 2) {
2948
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
2949
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
2950
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
2951
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
2952
- const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
2953
- const midpointX = (firstTouchX + secondTouchX) / 2;
2954
- const midpointY = (firstTouchY + secondTouchY) / 2;
2955
- const scaleRatio = currentTouchDistance / this.initialTouchDistance;
2956
- const newScale = this._store.state.scale * scaleRatio;
2957
- if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
2958
- this._store.state.translateX += midpointX - this.startX;
2959
- this._store.state.translateY += midpointY - this.startY;
3026
+ if (event.pointerType === 'touch') {
3027
+ const activePointers = Array.from(this._store.state.pointers.values());
3028
+ if (activePointers.length === 2) {
3029
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
3030
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
3031
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
3032
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
3033
+ const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
3034
+ const midpointX = (firstTouchX + secondTouchX) / 2;
3035
+ const midpointY = (firstTouchY + secondTouchY) / 2;
3036
+ const scaleRatio = currentTouchDistance / this.initialTouchDistance;
3037
+ const newScale = this._store.state.scale * scaleRatio;
3038
+ if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
3039
+ this._store.state.translateX += midpointX - this.startX;
3040
+ this._store.state.translateY += midpointY - this.startY;
3041
+ }
3042
+ else {
3043
+ const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
3044
+ const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
3045
+ this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
3046
+ this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
3047
+ this._store.state.scale = newScale;
3048
+ this.initialTouchDistance = currentTouchDistance;
3049
+ }
3050
+ this.startX = midpointX;
3051
+ this.startY = midpointY;
3052
+ this._store.state.hasViewportChanged = true;
3053
+ this._store.rerender();
2960
3054
  }
2961
- else {
2962
- const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
2963
- const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
2964
- this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
2965
- this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
2966
- this._store.state.scale = newScale;
2967
- this.initialTouchDistance = currentTouchDistance;
3055
+ }
3056
+ }
3057
+ handlePointerUp(event) {
3058
+ if (event.pointerType === 'mouse') {
3059
+ if (this._store.state.isPanning) {
3060
+ this._store.state.isPanning = false;
3061
+ this._store.rerender();
2968
3062
  }
2969
- this.startX = midpointX;
2970
- this.startY = midpointY;
2971
- this._store.state.hasViewportChanged = true;
3063
+ }
3064
+ if (event.pointerType === 'touch') {
3065
+ this._store.state.isScaling = false;
2972
3066
  this._store.rerender();
2973
3067
  }
2974
3068
  }
2975
- handleTouchEnd(_event) {
2976
- this._store.state.touchCount = 0;
2977
- this._store.state.isScaling = false;
2978
- this._store.rerender();
2979
- }
2980
3069
  handleWheel(event) {
2981
3070
  event.preventDefault();
2982
3071
  if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {
@@ -3331,9 +3420,9 @@ const DEFAULT_ENGINE_STATE = {
3331
3420
  viewportWidth: 0,
3332
3421
  viewportHeight: 0,
3333
3422
  historyBufferSize: 1000,
3334
- touchCount: 0,
3335
3423
  longTouchTimeout: null,
3336
3424
  longTouchDelay: 300,
3425
+ pointers: new Map()
3337
3426
  };
3338
3427
 
3339
3428
  class KritzelStore {
@@ -3665,46 +3754,6 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3665
3754
  this.objectContextMenuItems = objectContextMenuItems;
3666
3755
  }
3667
3756
  handleContextMenu(event) {
3668
- if (event.cancelable) {
3669
- event.preventDefault();
3670
- }
3671
- if (!(this._store.state.activeTool instanceof KritzelSelectionTool)) {
3672
- return;
3673
- }
3674
- if (this._store.state.skipContextMenu) {
3675
- this._store.state.skipContextMenu = false;
3676
- return;
3677
- }
3678
- this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
3679
- let x = event.clientX - this._store.offsetX;
3680
- let y = event.clientY - this._store.offsetY;
3681
- const menuWidthEstimate = 150;
3682
- const menuHeightEstimate = 200;
3683
- const margin = 10;
3684
- if (x + menuWidthEstimate > window.innerWidth - margin) {
3685
- x = window.innerWidth - menuWidthEstimate - margin;
3686
- }
3687
- if (y + menuHeightEstimate > window.innerHeight - margin) {
3688
- y = window.innerHeight - menuHeightEstimate - margin;
3689
- }
3690
- x = Math.max(margin, x);
3691
- y = Math.max(margin, y);
3692
- this._store.state.contextMenuX = x;
3693
- this._store.state.contextMenuY = y;
3694
- this._store.state.isContextMenuVisible = true;
3695
- this._store.state.isEnabled = false;
3696
- this._store.rerender();
3697
- }
3698
- handleContextMenuTouch(event) {
3699
- if (event.cancelable) {
3700
- event.preventDefault();
3701
- }
3702
- if (this._store.state.touchCount > 1 || !(this._store.state.activeTool instanceof KritzelSelectionTool)) {
3703
- return;
3704
- }
3705
- if ('vibrate' in navigator) {
3706
- navigator.vibrate(25);
3707
- }
3708
3757
  const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
3709
3758
  if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
3710
3759
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
@@ -3715,12 +3764,8 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3715
3764
  this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
3716
3765
  }
3717
3766
  this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
3718
- const firstTouch = event.touches[0];
3719
- if (!firstTouch) {
3720
- return;
3721
- }
3722
- let x = Math.round(firstTouch.clientX - this._store.offsetX);
3723
- let y = Math.round(firstTouch.clientY - this._store.offsetY);
3767
+ let x = event.clientX - this._store.offsetX;
3768
+ let y = event.clientY - this._store.offsetY;
3724
3769
  const menuWidthEstimate = 150;
3725
3770
  const menuHeightEstimate = 200;
3726
3771
  const margin = 10;
@@ -3740,7 +3785,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
3740
3785
  }
3741
3786
  }
3742
3787
 
3743
- const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
3788
+ const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
3744
3789
 
3745
3790
  const KritzelEngine = class {
3746
3791
  get isSelecting() {
@@ -3805,78 +3850,50 @@ const KritzelEngine = class {
3805
3850
  this.viewport = new KritzelViewport(this.store, this.host);
3806
3851
  this.engineReady.emit();
3807
3852
  }
3808
- handleContextMenu(ev) {
3809
- if (this.store.state.isEnabled === false) {
3810
- return;
3811
- }
3812
- this.contextMenuHandler.handleContextMenu(ev);
3813
- }
3814
- handleMouseDown(ev) {
3853
+ handleWheel(ev) {
3815
3854
  var _a, _b;
3816
3855
  if (this.store.state.isContextMenuVisible) {
3817
3856
  this.hideContextMenu();
3818
- return;
3819
3857
  }
3820
- if (this.store.state.isEnabled === false) {
3821
- return;
3822
- }
3823
- this.viewport.handleMouseDown(ev);
3824
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseDown(ev);
3825
- }
3826
- handleMouseMove(ev) {
3827
- var _a, _b;
3828
- if (this.store.state.isEnabled === false) {
3829
- return;
3830
- }
3831
- this.viewport.handleMouseMove(ev);
3832
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseMove(ev);
3858
+ this.viewport.handleWheel(ev);
3859
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
3833
3860
  }
3834
- handleMouseUp(ev) {
3861
+ handlePointerDown(ev) {
3835
3862
  var _a, _b;
3836
- if (this.store.state.isEnabled === false) {
3863
+ if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
3864
+ this.hideContextMenu();
3837
3865
  return;
3838
3866
  }
3839
- this.viewport.handleMouseUp(ev);
3840
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseUp(ev);
3841
- }
3842
- handleDoubleClick(ev) {
3843
- var _a, _b;
3844
3867
  if (this.store.state.isEnabled === false) {
3845
3868
  return;
3846
3869
  }
3847
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleClick(ev);
3848
- }
3849
- handleDoubleTap(ev) {
3850
- var _a, _b;
3851
- if (this.store.state.isEnabled === false) {
3852
- return;
3870
+ if (ev.cancelable) {
3871
+ ev.preventDefault();
3853
3872
  }
3854
- const touchEvent = ev instanceof CustomEvent && ev.detail ? ev.detail : ev;
3855
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleTap(touchEvent);
3873
+ KritzelEventHelper.onLongTouchPress(ev, (event) => {
3874
+ if (!(this.store.state.activeTool instanceof KritzelSelectionTool)) {
3875
+ return;
3876
+ }
3877
+ this.contextMenuHandler.handleContextMenu(event);
3878
+ });
3879
+ this.host.setPointerCapture(ev.pointerId);
3880
+ this.store.state.pointers.set(ev.pointerId, ev);
3881
+ this.viewport.handlePointerDown(ev);
3882
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerDown(ev);
3856
3883
  }
3857
- handleTouchStart(ev) {
3884
+ handlePointerMove(ev) {
3858
3885
  var _a, _b;
3859
3886
  if (this.store.state.isEnabled === false) {
3860
3887
  return;
3861
3888
  }
3862
- if (ev.touches.length === 2) {
3863
- KritzelEventHelper.notifyTwoFingerTouch();
3864
- }
3865
- if (KritzelEventHelper.detectDoubleTap()) {
3866
- const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
3867
- this.host.dispatchEvent(doubleTapEvent);
3868
- }
3869
- if (ev.touches.length > 1) {
3870
- clearTimeout(this.store.state.longTouchTimeout);
3871
- }
3872
3889
  if (ev.cancelable) {
3873
3890
  ev.preventDefault();
3874
3891
  }
3875
- this.store.state.longTouchTimeout = setTimeout(() => this.contextMenuHandler.handleContextMenuTouch(ev), this.store.state.longTouchDelay);
3876
- this.viewport.handleTouchStart(ev);
3877
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchStart(ev);
3892
+ this.store.state.pointers.set(ev.pointerId, ev);
3893
+ this.viewport.handlePointerMove(ev);
3894
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerMove(ev);
3878
3895
  }
3879
- handleTouchMove(ev) {
3896
+ handlePointerUp(ev) {
3880
3897
  var _a, _b;
3881
3898
  if (this.store.state.isEnabled === false) {
3882
3899
  return;
@@ -3884,10 +3901,12 @@ const KritzelEngine = class {
3884
3901
  if (ev.cancelable) {
3885
3902
  ev.preventDefault();
3886
3903
  }
3887
- this.viewport.handleTouchMove(ev);
3888
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchMove(ev);
3904
+ this.store.state.pointers.delete(ev.pointerId);
3905
+ this.host.releasePointerCapture(ev.pointerId);
3906
+ this.viewport.handlePointerUp(ev);
3907
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
3889
3908
  }
3890
- handleTouchEnd(ev) {
3909
+ handlePointerCancel(ev) {
3891
3910
  var _a, _b;
3892
3911
  if (this.store.state.isEnabled === false) {
3893
3912
  return;
@@ -3895,20 +3914,20 @@ const KritzelEngine = class {
3895
3914
  if (ev.cancelable) {
3896
3915
  ev.preventDefault();
3897
3916
  }
3898
- clearTimeout(this.store.state.longTouchTimeout);
3899
- this.viewport.handleTouchEnd(ev);
3900
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchEnd(ev);
3917
+ this.host.releasePointerCapture(ev.pointerId);
3918
+ this.store.state.pointers.delete(ev.pointerId);
3919
+ this.viewport.handlePointerUp(ev);
3920
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
3901
3921
  }
3902
- handleTouchCancel(_ev) {
3903
- clearTimeout(this.store.state.longTouchTimeout);
3904
- }
3905
- handleWheel(ev) {
3906
- var _a, _b;
3907
- if (this.store.state.isContextMenuVisible) {
3908
- this.hideContextMenu();
3922
+ handleContextMenu(ev) {
3923
+ ev.preventDefault();
3924
+ if (this.store.state.isEnabled === false) {
3925
+ return;
3909
3926
  }
3910
- this.viewport.handleWheel(ev);
3911
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
3927
+ if (ev.pointerType === 'touch') {
3928
+ return;
3929
+ }
3930
+ this.contextMenuHandler.handleContextMenu(ev);
3912
3931
  }
3913
3932
  handleResize() {
3914
3933
  this.viewport.handleResize();
@@ -3985,6 +4004,7 @@ const KritzelEngine = class {
3985
4004
  this.store.history.redo();
3986
4005
  }
3987
4006
  async hideContextMenu() {
4007
+ this.store.state.pointers.clear();
3988
4008
  this.store.state.isContextMenuVisible = false;
3989
4009
  this.store.state.selectionBox = null;
3990
4010
  this.store.state.isSelecting = false;
@@ -4037,15 +4057,15 @@ const KritzelEngine = class {
4037
4057
  const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
4038
4058
  const baseHandleSize = parseFloat(baseHandleSizePx);
4039
4059
  const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
4040
- return (h(Host, { key: '7592f0cc9b3c4f5c2c68b8a69151e57e254e1bcd' }, h("div", { key: '83d550a8b257c6c30915b4125633410b935df1c7', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: 'aaebf84d2344cf117d7e2b221f4675abfa3e2423' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
4041
- _a.translateX), h("div", { key: '0dff156e5b57abe1919af5a14da374ee86f62821' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
4042
- _b.translateY), h("div", { key: 'bb7fe1f8442c70e1bd7655ea222f37ed55c0cf8f' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
4043
- _c.viewportWidth), h("div", { key: 'c0399a368afa2186ba45e7be6fa69495f77912b2' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
4044
- _d.viewportHeight), h("div", { key: '2506ae215413710417a9b494dfeaa06a95381e1e' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '858e6cff62c24d97f36560ca57c59eb90d7fe253' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
4045
- _e.scale), h("div", { key: 'b7dd1926a2a374b34ccb0f1af2f5100bb256a323' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
4046
- _g.name), h("div", { key: 'e75a98de366a36b9e4a478119db1754df85ce149' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: 'c78c09fbb6efc97be8cde8bc55d2c9ca724d913e' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '7864d38c808ff8fa01fc24d150ac03ec56eb2111' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '8ce8b3522065ad221d0cac69366199fa78e6c985' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'f2dc96d374c66798ab0ec6f4759a851448375def' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '7a8642ee44c2c6d6419da80c2a27b0370c51c67d' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '9f819435c8ad8c2f836edca397918bd98e2ed34d' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '252201d35275563594bfe13ae19ded7289d4860a' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '45056c11f0733c433f9a91008d021702df660063' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'a6fedfe47aac88ffa4df90da060a28d83f8bf1cf' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '30b311e5dee2174ba0baea6e5bc9f1fca1a01fac' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'e2d1936e16dd5a268dd1efab8b7e67b567170e9b' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
4047
- _m.cursorX), h("div", { key: 'bb1e751d01b31ca727c01537927808daec4425e9' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
4048
- _o.cursorY)), h("div", { key: 'a5ccd3e025b425660a1dd9ef523db203fcbde610', class: "origin", style: {
4060
+ return (h(Host, { key: 'a797514d787c08c2cd6a2e526ace31fecddf8956' }, h("div", { key: 'd0d23c34809f26ab3c21f756923d1ef7a00ebb41', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '302b23a9028483c7dc31f4ca983c8036f6de5b25' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
4061
+ _a.translateX), h("div", { key: '2224e2bb5bd1feea8a65ac4f082342a40e8e18b5' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
4062
+ _b.translateY), h("div", { key: '02108ee26500eb97a08d8460b6b71cdc553d6c90' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
4063
+ _c.viewportWidth), h("div", { key: '8e87161155f4e2960985292be3101e9f57893381' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
4064
+ _d.viewportHeight), h("div", { key: 'aa2469bda052787a93ea615451676dba4b4fb53e' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '593aaf98bfaec8aae03bd7a3f37e46e14f454333' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
4065
+ _e.scale), h("div", { key: '6c9799e82d30236c6f1277830dec32358bfccd93' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
4066
+ _g.name), h("div", { key: '3dbbec42f8a699a97ef65b5da35f2611866797e5' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: '03a71e1efab2801e77e0d8dffc7a4814469613c7' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '7663ed6cad2ed3b9b74bad5cb238a4cf0310e9e1' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '957a1b0906ad9cecc46f470db1ad402d19f94d22' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'b73277742d0966445b6f49a0fb1433f80cab1d60' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '6a4e0ca6d868b1f8ccfe2957f352fc454b3527ea' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: 'da9dce9f4c38cd740f27ecc8de3c32edac2a7fe2' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: 'f6b0d7cc9e828cac5a65879b9973944a444be6b1' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '3ef7c46329e47a97703e49f47c8f5325f0d4b9b2' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'cab4fb21ede0b4f4925e9d7d2175ad8661f07907' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '2f4eeaa711a56e2246495fe1eee46d5629c93364' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'ee2e5edcd140da8b957b468989c71e7c247063bb' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
4067
+ _m.cursorX), h("div", { key: '1fea9888ca2f1a9fed25ad0cac065d8278c78227' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
4068
+ _o.cursorY)), h("div", { key: '226c675711317ff06f1db5165fa19794310f2e1e', class: "origin", style: {
4049
4069
  transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
4050
4070
  } }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
4051
4071
  _t.map(object => {
@@ -4092,6 +4112,7 @@ const KritzelEngine = class {
4092
4112
  display: 'block',
4093
4113
  padding: '1px',
4094
4114
  whiteSpace: 'nowrap',
4115
+ pointerEvents: object.isReadonly ? 'none' : 'auto',
4095
4116
  cursor: object.isReadonly ? 'default' : 'text',
4096
4117
  caretColor: object.isReadonly ? 'transparent' : 'auto',
4097
4118
  } })), object instanceof KritzelSelectionGroup && (h("div", { ref: el => object.mount(el), style: {
@@ -4141,7 +4162,7 @@ const KritzelEngine = class {
4141
4162
  fill: 'transparent',
4142
4163
  cursor: 'grab',
4143
4164
  }, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
4144
- }), h("svg", { key: 'c2b10893d4bea0e25c98058e640ad8eef6135a80', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
4165
+ }), h("svg", { key: '34f891f9408d3b0174c67b869f49cce7329fd84a', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
4145
4166
  height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
4146
4167
  width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
4147
4168
  left: '0',
@@ -4151,12 +4172,12 @@ const KritzelEngine = class {
4151
4172
  transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
4152
4173
  transformOrigin: 'top left',
4153
4174
  overflow: 'visible',
4154
- }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '84b018b26b93e0f382062ac2e24efbce8bc07e3f', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: 'c372bd8595656b35d7eed2e38400490e7d71808b', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
4175
+ }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '97360b7270a285a87a45459e497968a444cc83cb', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '111d7b1daccd69aaf914dfcd51f525f2ad81802e', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
4155
4176
  position: 'fixed',
4156
4177
  left: `${this.store.state.contextMenuX}px`,
4157
4178
  top: `${this.store.state.contextMenuY}px`,
4158
4179
  zIndex: '10000',
4159
- }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: 'ce67e9df4714a9585bb1a8db3780baff6faeb66d' })));
4180
+ }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '9814ec7d95a84edc8af1bff319eff5f59b8cfc86' })));
4160
4181
  }
4161
4182
  get host() { return getElement(this); }
4162
4183
  };