kritzel-stencil 0.0.120 → 0.0.122

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 (93) hide show
  1. package/dist/cjs/{index-BjLSiQIM.js → index-CFCyVs0_.js} +185 -69
  2. package/dist/cjs/index-CFCyVs0_.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +129 -72
  5. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  6. package/dist/collection/classes/commands/remove-object.command.js +3 -0
  7. package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
  8. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  9. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  10. package/dist/collection/classes/handlers/move.handler.js +2 -2
  11. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  12. package/dist/collection/classes/handlers/selection.handler.js +5 -5
  13. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  14. package/dist/collection/classes/history.class.js +16 -13
  15. package/dist/collection/classes/history.class.js.map +1 -1
  16. package/dist/collection/classes/objects/base-object.class.js +28 -32
  17. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  18. package/dist/collection/classes/objects/custom-element.class.js +52 -0
  19. package/dist/collection/classes/objects/custom-element.class.js.map +1 -0
  20. package/dist/collection/classes/objects/image.class.js +1 -1
  21. package/dist/collection/classes/objects/image.class.js.map +1 -1
  22. package/dist/collection/classes/objects/path.class.js +62 -2
  23. package/dist/collection/classes/objects/path.class.js.map +1 -1
  24. package/dist/collection/classes/objects/selection-group.class.js +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  26. package/dist/collection/classes/objects/text.class.js +1 -1
  27. package/dist/collection/classes/objects/text.class.js.map +1 -1
  28. package/dist/collection/classes/reviver.class.js +4 -0
  29. package/dist/collection/classes/reviver.class.js.map +1 -1
  30. package/dist/collection/classes/store.class.js +45 -6
  31. package/dist/collection/classes/store.class.js.map +1 -1
  32. package/dist/collection/classes/tools/eraser-tool.class.js +18 -14
  33. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  34. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  35. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  36. package/dist/collection/classes/tools/selection-tool.class.js +2 -6
  37. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  38. package/dist/collection/classes/viewport.class.js +20 -12
  39. package/dist/collection/classes/viewport.class.js.map +1 -1
  40. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +6 -6
  41. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  42. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +40 -33
  43. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  44. package/dist/collection/configs/default-engine-state.js +2 -2
  45. package/dist/collection/configs/default-engine-state.js.map +1 -1
  46. package/dist/collection/helpers/html.helper.js +7 -0
  47. package/dist/collection/helpers/html.helper.js.map +1 -0
  48. package/dist/collection/helpers/object.helper.js +6 -2
  49. package/dist/collection/helpers/object.helper.js.map +1 -1
  50. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  51. package/dist/collection/interfaces/object.interface.js.map +1 -1
  52. package/dist/components/index.js +2 -2
  53. package/dist/components/kritzel-controls.js +1 -1
  54. package/dist/components/kritzel-editor.js +7 -7
  55. package/dist/components/kritzel-editor.js.map +1 -1
  56. package/dist/components/kritzel-engine.js +1 -1
  57. package/dist/components/{p-eS30Bqrc.js → p-COPOzWCn.js} +213 -100
  58. package/dist/components/p-COPOzWCn.js.map +1 -0
  59. package/dist/components/{p-DC3j4P1n.js → p-Ch8eM2R8.js} +99 -39
  60. package/dist/components/p-Ch8eM2R8.js.map +1 -0
  61. package/dist/components/{p-BAMl2Ww6.js → p-DIu9OTyP.js} +3 -3
  62. package/dist/components/{p-BAMl2Ww6.js.map → p-DIu9OTyP.js.map} +1 -1
  63. package/dist/esm/{index-DsUDklEm.js → index-DYLW4hYm.js} +185 -69
  64. package/dist/esm/index-DYLW4hYm.js.map +1 -0
  65. package/dist/esm/index.js +1 -1
  66. package/dist/esm/kritzel-brush-style_18.entry.js +129 -72
  67. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  68. package/dist/stencil/index.esm.js +1 -1
  69. package/dist/stencil/p-DYLW4hYm.js +2 -0
  70. package/dist/stencil/p-DYLW4hYm.js.map +1 -0
  71. package/dist/stencil/p-fa584641.entry.js +2 -0
  72. package/dist/stencil/p-fa584641.entry.js.map +1 -0
  73. package/dist/stencil/stencil.esm.js +1 -1
  74. package/dist/types/classes/history.class.d.ts +1 -0
  75. package/dist/types/classes/objects/base-object.class.d.ts +10 -6
  76. package/dist/types/classes/objects/custom-element.class.d.ts +26 -0
  77. package/dist/types/classes/objects/image.class.d.ts +1 -1
  78. package/dist/types/classes/objects/path.class.d.ts +5 -2
  79. package/dist/types/classes/objects/text.class.d.ts +1 -1
  80. package/dist/types/classes/store.class.d.ts +5 -0
  81. package/dist/types/components.d.ts +4 -4
  82. package/dist/types/helpers/html.helper.d.ts +3 -0
  83. package/dist/types/interfaces/engine-state.interface.d.ts +2 -2
  84. package/dist/types/interfaces/object.interface.d.ts +9 -4
  85. package/package.json +1 -1
  86. package/dist/cjs/index-BjLSiQIM.js.map +0 -1
  87. package/dist/components/p-DC3j4P1n.js.map +0 -1
  88. package/dist/components/p-eS30Bqrc.js.map +0 -1
  89. package/dist/esm/index-DsUDklEm.js.map +0 -1
  90. package/dist/stencil/p-0ae72b0d.entry.js +0 -2
  91. package/dist/stencil/p-0ae72b0d.entry.js.map +0 -1
  92. package/dist/stencil/p-DsUDklEm.js +0 -2
  93. package/dist/stencil/p-DsUDklEm.js.map +0 -1
@@ -296,8 +296,12 @@ class ObjectHelper {
296
296
  }
297
297
  static clone(objOrObjs) {
298
298
  const cloneObject = (obj) => {
299
- const remainingProps = __rest(obj, ["_store", "_elementRef", "totalWidth", "totalHeight"]);
300
- return structuredClone(remainingProps);
299
+ const _a = obj, { element } = _a, remainingProps = __rest(_a, ["_store", "_elementRef", "totalWidth", "totalHeight", "element"]);
300
+ const clonedProps = structuredClone(remainingProps);
301
+ if (element && element instanceof HTMLElement) {
302
+ clonedProps.element = element.cloneNode(true);
303
+ }
304
+ return clonedProps;
301
305
  };
302
306
  if (Array.isArray(objOrObjs)) {
303
307
  return objOrObjs.map(cloneObject);
@@ -346,8 +350,8 @@ class KritzelBaseObject {
346
350
  };
347
351
  }
348
352
  get rotatedPolygon() {
349
- const cx = (this.translateX + this.totalWidth / 2 / this.scale);
350
- const cy = (this.translateY + this.totalHeight / 2 / this.scale);
353
+ const cx = this.translateX + this.totalWidth / 2 / this.scale;
354
+ const cy = this.translateY + this.totalHeight / 2 / this.scale;
351
355
  const angle = this.rotation;
352
356
  const adjustedWidth = this.totalWidth / this.scale;
353
357
  const adjustedHeight = this.totalHeight / this.scale;
@@ -367,39 +371,19 @@ class KritzelBaseObject {
367
371
  return rotatedCorners;
368
372
  }
369
373
  get minXRotated() {
370
- const corners = [
371
- this.rotatedPolygon.topLeft.x,
372
- this.rotatedPolygon.topRight.x,
373
- this.rotatedPolygon.bottomRight.x,
374
- this.rotatedPolygon.bottomLeft.x,
375
- ];
374
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
376
375
  return Math.min(...corners);
377
376
  }
378
377
  get minYRotated() {
379
- const corners = [
380
- this.rotatedPolygon.topLeft.y,
381
- this.rotatedPolygon.topRight.y,
382
- this.rotatedPolygon.bottomRight.y,
383
- this.rotatedPolygon.bottomLeft.y,
384
- ];
378
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
385
379
  return Math.min(...corners);
386
380
  }
387
381
  get maxXRotated() {
388
- const corners = [
389
- this.rotatedPolygon.topLeft.x,
390
- this.rotatedPolygon.topRight.x,
391
- this.rotatedPolygon.bottomRight.x,
392
- this.rotatedPolygon.bottomLeft.x,
393
- ];
382
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
394
383
  return Math.max(...corners);
395
384
  }
396
385
  get maxYRotated() {
397
- const corners = [
398
- this.rotatedPolygon.topLeft.y,
399
- this.rotatedPolygon.topRight.y,
400
- this.rotatedPolygon.bottomRight.y,
401
- this.rotatedPolygon.bottomLeft.y,
402
- ];
386
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
403
387
  return Math.max(...corners);
404
388
  }
405
389
  get transformationMatrix() {
@@ -419,18 +403,19 @@ class KritzelBaseObject {
419
403
  }
420
404
  constructor() {
421
405
  this.__class__ = 'KritzelBaseObject';
422
- this.visible = true;
423
406
  this.borderWidth = 0;
424
407
  this.opacity = 1;
425
408
  this.padding = 0;
426
- this.selected = false;
427
409
  this.resizing = false;
428
410
  this.rotation = 0;
429
411
  this.markedForRemoval = false;
430
- this.isMounted = false;
431
412
  this.zIndex = 0;
413
+ this.isVisible = true;
414
+ this.isSelected = false;
415
+ this.isMounted = false;
432
416
  this.isEditable = false;
433
- this.debugInfoVisible = false;
417
+ this.isInteractive = false;
418
+ this.isDebugInfoVisible = false;
434
419
  this.id = this.generateId();
435
420
  }
436
421
  static create(store) {
@@ -446,6 +431,18 @@ class KritzelBaseObject {
446
431
  this.elementRef = element;
447
432
  this.isMounted = true;
448
433
  }
434
+ unmount() {
435
+ if (!this.isMounted) {
436
+ return;
437
+ }
438
+ this.isMounted = false;
439
+ }
440
+ remount() {
441
+ if (!this.isMounted) {
442
+ return;
443
+ }
444
+ this.isMounted = false;
445
+ }
449
446
  generateId() {
450
447
  return ObjectHelper.generateUUID();
451
448
  }
@@ -455,10 +452,10 @@ class KritzelBaseObject {
455
452
  y: -this._store.state.translateY / this._store.state.scale,
456
453
  width: this._store.state.viewportWidth / this._store.state.scale,
457
454
  height: this._store.state.viewportHeight / this._store.state.scale};
458
- return this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
455
+ return (this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
459
456
  this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&
460
457
  this.boundingBox.y < viewportBounds.y + viewportBounds.height &&
461
- this.boundingBox.y + this.boundingBox.height > viewportBounds.y;
458
+ this.boundingBox.y + this.boundingBox.height > viewportBounds.y);
462
459
  }
463
460
  centerInViewport() {
464
461
  const scale = this._store.state.scale;
@@ -503,6 +500,9 @@ class KritzelBaseObject {
503
500
  edit() {
504
501
  // This method can be overridden by subclasses to handle edit actions.
505
502
  }
503
+ hitTest(_x, _y) {
504
+ return true; // Default implementation, can be overridden by subclasses
505
+ }
506
506
  }
507
507
 
508
508
  class KritzelText extends KritzelBaseObject {
@@ -518,7 +518,7 @@ class KritzelText extends KritzelBaseObject {
518
518
  this.fontColor = '#000000';
519
519
  this.initialWidth = 3;
520
520
  this.isNew = true;
521
- this.debugInfoVisible = true;
521
+ this.isDebugInfoVisible = true;
522
522
  this.isEditable = true;
523
523
  this.rows = 1;
524
524
  if (config) {
@@ -679,10 +679,14 @@ class KritzelPath extends KritzelBaseObject {
679
679
  this.height = 0;
680
680
  this.width = 0;
681
681
  this.scale = 1;
682
- this.visible = true;
683
- this.debugInfoVisible = true;
682
+ this.isVisible = true;
683
+ this.isDebugInfoVisible = true;
684
684
  this.options = config;
685
685
  this.points = (_a = config === null || config === void 0 ? void 0 : config.points) !== null && _a !== void 0 ? _a : [];
686
+ this.adjustedPoints = this.points.map(([px, py]) => [
687
+ (px + this.options.translateX) / this.scale,
688
+ (py + this.options.translateY) / this.scale,
689
+ ]);
686
690
  this.translateX = (_b = config === null || config === void 0 ? void 0 : config.translateX) !== null && _b !== void 0 ? _b : 0;
687
691
  this.translateY = (_c = config === null || config === void 0 ? void 0 : config.translateY) !== null && _c !== void 0 ? _c : 0;
688
692
  this.scale = (_d = config === null || config === void 0 ? void 0 : config.scale) !== null && _d !== void 0 ? _d : 1;
@@ -698,6 +702,13 @@ class KritzelPath extends KritzelBaseObject {
698
702
  object.id = object.generateId();
699
703
  object.options = options;
700
704
  object.points = (_a = options === null || options === void 0 ? void 0 : options.points) !== null && _a !== void 0 ? _a : [];
705
+ object.adjustedPoints = object.points.map(([px, py]) => {
706
+ var _a, _b;
707
+ return [
708
+ (px + (options === null || options === void 0 ? void 0 : options.translateX)) / ((_a = options === null || options === void 0 ? void 0 : options.scale) !== null && _a !== void 0 ? _a : 1),
709
+ (py + (options === null || options === void 0 ? void 0 : options.translateY)) / ((_b = options === null || options === void 0 ? void 0 : options.scale) !== null && _b !== void 0 ? _b : 1),
710
+ ];
711
+ });
701
712
  object.translateX = (_b = options === null || options === void 0 ? void 0 : options.translateX) !== null && _b !== void 0 ? _b : 0;
702
713
  object.translateY = (_c = options === null || options === void 0 ? void 0 : options.translateY) !== null && _c !== void 0 ? _c : 0;
703
714
  object.scale = (_d = options === null || options === void 0 ? void 0 : options.scale) !== null && _d !== void 0 ? _d : 1;
@@ -717,6 +728,10 @@ class KritzelPath extends KritzelBaseObject {
717
728
  this.width = width;
718
729
  this.height = height;
719
730
  this.points = this.points.map(([x, y]) => [x * scaleX, y * scaleY]);
731
+ this.adjustedPoints = this.points.map(([px, py]) => [
732
+ (px + this.options.translateX) / this.scale,
733
+ (py + this.options.translateY) / this.scale,
734
+ ]);
720
735
  this.d = this.generateSvgPath();
721
736
  this.width = Math.max(...this.points.map(p => p[0])) - Math.min(...this.points.map(p => p[0])) + this.strokeWidth;
722
737
  this.height = Math.max(...this.points.map(p => p[1])) - Math.min(...this.points.map(p => p[1])) + this.strokeWidth;
@@ -729,6 +744,51 @@ class KritzelPath extends KritzelBaseObject {
729
744
  super.rotate(value);
730
745
  this.updateDimensions();
731
746
  }
747
+ hitTest(x, y) {
748
+ const halfStroke = this.strokeWidth / this.scale / 2;
749
+ if (this.adjustedPoints.length === 1) {
750
+ const p1 = this.adjustedPoints[0];
751
+ const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p1[0], p1[1]);
752
+ return distance <= halfStroke;
753
+ }
754
+ for (let i = 0; i < this.adjustedPoints.length - 1; i++) {
755
+ const p1 = this.adjustedPoints[i];
756
+ const p2 = this.adjustedPoints[i + 1];
757
+ const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p2[0], p2[1]);
758
+ if (distance <= halfStroke) {
759
+ return true;
760
+ }
761
+ }
762
+ return false;
763
+ }
764
+ pointToLineSegmentDistance(x, y, x1, y1, x2, y2) {
765
+ const A = x - x1;
766
+ const B = y - y1;
767
+ const C = x2 - x1;
768
+ const D = y2 - y1;
769
+ const dot = A * C + B * D;
770
+ const len_sq = C * C + D * D;
771
+ let param = -1;
772
+ if (len_sq !== 0) { // in case of 0 length line
773
+ param = dot / len_sq;
774
+ }
775
+ let xx, yy;
776
+ if (param < 0) {
777
+ xx = x1;
778
+ yy = y1;
779
+ }
780
+ else if (param > 1) {
781
+ xx = x2;
782
+ yy = y2;
783
+ }
784
+ else {
785
+ xx = x1 + param * C;
786
+ yy = y1 + param * D;
787
+ }
788
+ const dx = x - xx;
789
+ const dy = y - yy;
790
+ return Math.sqrt(dx * dx + dy * dy);
791
+ }
732
792
  updateDimensions() {
733
793
  const rotatedPoints = this.points.map(([x, y]) => {
734
794
  const rotatedX = x * Math.cos(this.rotation) - y * Math.sin(this.rotation);
@@ -800,7 +860,7 @@ class KritzelImage extends KritzelBaseObject {
800
860
  this.maxWidth = 300;
801
861
  this.maxHeight = 300;
802
862
  this.maxCompressionSize = 300;
803
- this.debugInfoVisible = true;
863
+ this.isDebugInfoVisible = true;
804
864
  this.src = (config === null || config === void 0 ? void 0 : config.src) || '';
805
865
  this.x = (config === null || config === void 0 ? void 0 : config.x) || 0;
806
866
  this.y = (config === null || config === void 0 ? void 0 : config.y) || 0;
@@ -969,6 +1029,57 @@ class BatchCommand extends KritzelBaseCommand {
969
1029
  }
970
1030
  }
971
1031
 
1032
+ class KritzelCustomElement extends KritzelBaseObject {
1033
+ constructor(config) {
1034
+ super();
1035
+ this.__class__ = 'KritzelCustomElement';
1036
+ this.isInteractive = true;
1037
+ if (config) {
1038
+ this.translateX = config.translateX || 0;
1039
+ this.translateY = config.translateY || 0;
1040
+ this.scale = config.scale || 1;
1041
+ this.element = config.element;
1042
+ this.height = config.height || 0;
1043
+ this.width = config.width || 0;
1044
+ }
1045
+ }
1046
+ static create(store, config) {
1047
+ const object = new KritzelCustomElement(config);
1048
+ object._store = store;
1049
+ object.id = object.generateId();
1050
+ return object;
1051
+ }
1052
+ mount(element) {
1053
+ if (this.isMounted) {
1054
+ return;
1055
+ }
1056
+ this.elementRef = element;
1057
+ this.isMounted = true;
1058
+ this.elementRef.appendChild(this.element);
1059
+ }
1060
+ resize(x, y, width, height) {
1061
+ if (width <= 1 || height <= 1) {
1062
+ return;
1063
+ }
1064
+ this.width = width;
1065
+ this.height = height;
1066
+ this.translateX = x;
1067
+ this.translateY = y;
1068
+ if (this.element) {
1069
+ this.element.style.width = `${width}px`;
1070
+ this.element.style.height = `${height}px`;
1071
+ }
1072
+ }
1073
+ copy() {
1074
+ const copiedObject = Object.create(Object.getPrototypeOf(this));
1075
+ Object.assign(copiedObject, this);
1076
+ copiedObject.id = this.generateId();
1077
+ copiedObject.isMounted = false;
1078
+ copiedObject.element = this.element.cloneNode(true);
1079
+ return copiedObject;
1080
+ }
1081
+ }
1082
+
972
1083
  class RemoveObjectCommand extends KritzelBaseCommand {
973
1084
  constructor(store, initiator, object) {
974
1085
  super(store, initiator);
@@ -976,9 +1087,11 @@ class RemoveObjectCommand extends KritzelBaseCommand {
976
1087
  }
977
1088
  execute() {
978
1089
  this._store.state.objectsOctree.remove(object => object.id === this.object.id);
1090
+ this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
979
1091
  }
980
1092
  undo() {
981
1093
  this._store.state.objectsOctree.insert(this.object);
1094
+ this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
982
1095
  }
983
1096
  }
984
1097
 
@@ -1002,28 +1115,34 @@ class KritzelEraserTool extends KritzelBaseTool {
1002
1115
  }
1003
1116
  }
1004
1117
  handlePointerMove(event) {
1005
- var _a, _b;
1118
+ var _a;
1006
1119
  if (event.pointerType === 'mouse') {
1007
1120
  if (this._store.state.isErasing) {
1008
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1009
- if (!shadowRoot)
1121
+ const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1122
+ if (selectedObjects.length === 0)
1010
1123
  return;
1011
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1012
- if (!selectedObject)
1013
- return;
1014
- selectedObject.markedForRemoval = true;
1124
+ console.log('selectedObjects', selectedObjects);
1125
+ const x = this._store.state.pointerX;
1126
+ const y = this._store.state.pointerY;
1127
+ selectedObjects.forEach(selectedObject => {
1128
+ selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1129
+ });
1015
1130
  this._store.rerender();
1016
1131
  }
1017
1132
  }
1018
1133
  if (event.pointerType === 'touch') {
1019
1134
  if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
1020
- const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
1135
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1021
1136
  if (!shadowRoot)
1022
1137
  return;
1023
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1024
- if (!selectedObject)
1138
+ const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1139
+ if (selectedObjects.length === 0)
1025
1140
  return;
1026
- selectedObject.markedForRemoval = true;
1141
+ const x = this._store.state.pointerX;
1142
+ const y = this._store.state.pointerY;
1143
+ selectedObjects.forEach(selectedObject => {
1144
+ selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1145
+ });
1027
1146
  this._store.rerender();
1028
1147
  }
1029
1148
  }
@@ -1031,9 +1150,7 @@ class KritzelEraserTool extends KritzelBaseTool {
1031
1150
  handlePointerUp(event) {
1032
1151
  if (event.pointerType === 'mouse') {
1033
1152
  if (this._store.state.isErasing) {
1034
- const removeCommands = this._store.allObjects
1035
- .filter(object => object.markedForRemoval)
1036
- .map(object => {
1153
+ const removeCommands = this._store.allObjects.filter(object => object.markedForRemoval).map(object => {
1037
1154
  object.markedForRemoval = false;
1038
1155
  return new RemoveObjectCommand(this._store, this, object);
1039
1156
  });
@@ -1116,7 +1233,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1116
1233
  var _a, _b;
1117
1234
  if (event.pointerType === 'mouse') {
1118
1235
  if (KritzelEventHelper.isLeftClick(event)) {
1119
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1236
+ if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1120
1237
  const clientX = event.clientX - this._store.offsetX;
1121
1238
  const clientY = event.clientY - this._store.offsetY;
1122
1239
  this._store.state.isDragging = true;
@@ -1130,7 +1247,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1130
1247
  if (event.pointerType === 'touch') {
1131
1248
  const activePointers = Array.from(this._store.state.pointers.values());
1132
1249
  if (this._store.state.pointers.size === 1) {
1133
- if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1250
+ if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1134
1251
  const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1135
1252
  const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1136
1253
  this.dragStartX = x;
@@ -1738,7 +1855,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1738
1855
  .forEach(object => {
1739
1856
  const objectPolygon = object.rotatedPolygon;
1740
1857
  const selectionBoxPolygon = this._store.state.selectionBox.rotatedPolygon;
1741
- object.selected = KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, selectionBoxPolygon);
1858
+ object.isSelected = KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, selectionBoxPolygon);
1742
1859
  });
1743
1860
  }
1744
1861
  addSelectedObjectAtIndexToSelectionGroup(index) {
@@ -1747,10 +1864,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1747
1864
  if (!selectedObject) {
1748
1865
  return;
1749
1866
  }
1750
- selectedObjects.forEach(o => (o.selected = false));
1867
+ selectedObjects.forEach(o => (o.isSelected = false));
1751
1868
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
1752
1869
  this._store.state.selectionGroup.addOrRemove(selectedObject);
1753
- this._store.state.selectionGroup.selected = true;
1870
+ this._store.state.selectionGroup.isSelected = true;
1754
1871
  this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
1755
1872
  this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
1756
1873
  }
@@ -1761,10 +1878,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1761
1878
  }
1762
1879
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
1763
1880
  selectedObjects.forEach(o => {
1764
- o.selected = false;
1881
+ o.isSelected = false;
1765
1882
  this._store.state.selectionGroup.addOrRemove(o);
1766
1883
  });
1767
- this._store.state.selectionGroup.selected = true;
1884
+ this._store.state.selectionGroup.isSelected = true;
1768
1885
  if (this._store.state.selectionGroup.length === 1) {
1769
1886
  this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
1770
1887
  }
@@ -1797,12 +1914,8 @@ class KritzelSelectionTool extends KritzelBaseTool {
1797
1914
  !this._store.state.isRotationHandleSelected) {
1798
1915
  this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
1799
1916
  }
1800
- if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
1801
- setTimeout(() => {
1802
- if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
1803
- selectedObject.objects[0].onSelectedClick();
1804
- }
1805
- }, 100);
1917
+ if (selectedObject && selectedObject.isSelected === false && (selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.objects.length) === 1 && selectedObject.objects[0].isInteractive) {
1918
+ return;
1806
1919
  }
1807
1920
  }
1808
1921
  this.moveHandler.handlePointerDown(event);
@@ -1939,6 +2052,9 @@ class KritzelReviver {
1939
2052
  case 'KritzelImage':
1940
2053
  revivedObj = KritzelImage.create(this._store).revive(obj);
1941
2054
  break;
2055
+ case 'KritzelCustomElement':
2056
+ revivedObj = KritzelCustomElement.create(this._store).revive(obj);
2057
+ break;
1942
2058
  case 'KritzelSelectionGroup':
1943
2059
  revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
1944
2060
  break;
@@ -2004,7 +2120,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2004
2120
  this.refreshObjectDimensions();
2005
2121
  }
2006
2122
  deselectAllChildren() {
2007
- this.objects.forEach(obj => (obj.selected = false));
2123
+ this.objects.forEach(obj => (obj.isSelected = false));
2008
2124
  }
2009
2125
  updatePosition(x, y) {
2010
2126
  this.objects.forEach(obj => {
@@ -2209,7 +2325,7 @@ class KritzelImageTool extends KritzelBaseTool {
2209
2325
  addImageToStore(image) {
2210
2326
  const selectionGroup = KritzelSelectionGroup.create(this._store);
2211
2327
  selectionGroup.addOrRemove(image);
2212
- selectionGroup.selected = true;
2328
+ selectionGroup.isSelected = true;
2213
2329
  const addImageCommand = new AddObjectCommand(this._store, this, image);
2214
2330
  const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);
2215
2331
  this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));
@@ -2313,6 +2429,6 @@ const DEFAULT_TEXT_CONFIG = {
2313
2429
  };
2314
2430
 
2315
2431
  export { AddObjectCommand as A, BatchCommand as B, DEFAULT_BRUSH_CONFIG as D, KritzelBrushTool as K, RemoveSelectionGroupCommand as R, KritzelTextTool as a, KritzelMouseButton as b, KritzelSelectionTool as c, KritzelEraserTool as d, DEFAULT_TEXT_CONFIG as e, KritzelImageTool as f, KritzelEventHelper as g, KritzelBaseCommand as h, KritzelSelectionGroup as i, KrtizelSelectionBox as j, RemoveObjectCommand as k, AddSelectionGroupCommand as l, KritzelToolRegistry as m, KritzelBaseHandler as n, KritzelBaseTool as o, KritzelKeyboardHelper as p, KritzelText as q, KritzelPath as r, KritzelImage as s };
2316
- //# sourceMappingURL=index-DsUDklEm.js.map
2432
+ //# sourceMappingURL=index-DYLW4hYm.js.map
2317
2433
 
2318
- //# sourceMappingURL=index-DsUDklEm.js.map
2434
+ //# sourceMappingURL=index-DYLW4hYm.js.map