kritzel-stencil 0.0.121 → 0.0.123

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 (170) hide show
  1. package/dist/cjs/{index-BcrLbdO1.js → index-C05uAr89.js} +10 -4
  2. package/dist/cjs/index-C05uAr89.js.map +1 -0
  3. package/dist/cjs/{index-BjLSiQIM.js → index-UcX3pzju.js} +348 -141
  4. package/dist/cjs/index-UcX3pzju.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +1 -1
  6. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +137 -81
  7. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/stencil.cjs.js +2 -2
  10. package/dist/cjs/stencil.cjs.js.map +1 -1
  11. package/dist/collection/classes/commands/remove-object.command.js +3 -0
  12. package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
  13. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  14. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  15. package/dist/collection/classes/handlers/hover.handler.js +22 -0
  16. package/dist/collection/classes/handlers/hover.handler.js.map +1 -0
  17. package/dist/collection/classes/handlers/move.handler.js +2 -2
  18. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  19. package/dist/collection/classes/handlers/selection.handler.js +16 -20
  20. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  21. package/dist/collection/classes/history.class.js +16 -13
  22. package/dist/collection/classes/history.class.js.map +1 -1
  23. package/dist/collection/classes/objects/base-object.class.js +34 -32
  24. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  25. package/dist/collection/classes/objects/custom-element.class.js +52 -0
  26. package/dist/collection/classes/objects/custom-element.class.js.map +1 -0
  27. package/dist/collection/classes/objects/image.class.js +1 -1
  28. package/dist/collection/classes/objects/image.class.js.map +1 -1
  29. package/dist/collection/classes/objects/path.class.js +133 -4
  30. package/dist/collection/classes/objects/path.class.js.map +1 -1
  31. package/dist/collection/classes/objects/selection-box.class.js +2 -2
  32. package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
  33. package/dist/collection/classes/objects/selection-group.class.js +3 -2
  34. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  35. package/dist/collection/classes/objects/text.class.js +1 -1
  36. package/dist/collection/classes/objects/text.class.js.map +1 -1
  37. package/dist/collection/classes/reviver.class.js +4 -0
  38. package/dist/collection/classes/reviver.class.js.map +1 -1
  39. package/dist/collection/classes/store.class.js +45 -6
  40. package/dist/collection/classes/store.class.js.map +1 -1
  41. package/dist/collection/classes/tools/eraser-tool.class.js +17 -14
  42. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  43. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  44. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  45. package/dist/collection/classes/tools/selection-tool.class.js +5 -6
  46. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  47. package/dist/collection/classes/viewport.class.js +20 -12
  48. package/dist/collection/classes/viewport.class.js.map +1 -1
  49. package/dist/collection/collection-manifest.json +1 -1
  50. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +6 -6
  51. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  52. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +43 -37
  53. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  54. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +1 -1
  55. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +1 -1
  56. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +1 -1
  57. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +1 -1
  58. package/dist/collection/configs/default-engine-state.js +2 -2
  59. package/dist/collection/configs/default-engine-state.js.map +1 -1
  60. package/dist/collection/helpers/html.helper.js +7 -0
  61. package/dist/collection/helpers/html.helper.js.map +1 -0
  62. package/dist/collection/helpers/object.helper.js +6 -2
  63. package/dist/collection/helpers/object.helper.js.map +1 -1
  64. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  65. package/dist/collection/interfaces/object.interface.js.map +1 -1
  66. package/dist/components/index.js +3 -3
  67. package/dist/components/kritzel-brush-style.js +1 -1
  68. package/dist/components/kritzel-color-palette.js +1 -1
  69. package/dist/components/kritzel-color.js +1 -1
  70. package/dist/components/kritzel-context-menu.js +1 -1
  71. package/dist/components/kritzel-control-brush-config.js +1 -1
  72. package/dist/components/kritzel-control-text-config.js +1 -1
  73. package/dist/components/kritzel-controls.js +1 -1
  74. package/dist/components/kritzel-cursor-trail.js +1 -1
  75. package/dist/components/kritzel-dropdown.js +1 -1
  76. package/dist/components/kritzel-editor.js +23 -23
  77. package/dist/components/kritzel-editor.js.map +1 -1
  78. package/dist/components/kritzel-engine.js +1 -1
  79. package/dist/components/kritzel-font-family.js +1 -1
  80. package/dist/components/kritzel-font-size.js +1 -1
  81. package/dist/components/kritzel-font.js +1 -1
  82. package/dist/components/kritzel-icon.js +1 -1
  83. package/dist/components/kritzel-stroke-size.js +1 -1
  84. package/dist/components/kritzel-tooltip.js +1 -1
  85. package/dist/components/kritzel-utility-panel.js +1 -1
  86. package/dist/components/{p-CqPrOhzi.js → p-BOj_wqdw.js} +4 -4
  87. package/dist/components/{p-CqPrOhzi.js.map → p-BOj_wqdw.js.map} +1 -1
  88. package/dist/components/{p-CEYRFk55.js → p-BY8BWGge.js} +4 -4
  89. package/dist/components/{p-CEYRFk55.js.map → p-BY8BWGge.js.map} +1 -1
  90. package/dist/components/{p-D-Rf05Ov.js → p-Bn5P7YQn.js} +5 -5
  91. package/dist/components/{p-D-Rf05Ov.js.map → p-Bn5P7YQn.js.map} +1 -1
  92. package/dist/components/{p-CIb4IA9u.js → p-C9usqwb5.js} +5 -5
  93. package/dist/components/{p-CIb4IA9u.js.map → p-C9usqwb5.js.map} +1 -1
  94. package/dist/components/{p-gDLg_PJJ.js → p-CF8ziFc4.js} +4 -4
  95. package/dist/components/{p-gDLg_PJJ.js.map → p-CF8ziFc4.js.map} +1 -1
  96. package/dist/components/{p-CDpq9L_H.js → p-CiT5gBDh.js} +3 -3
  97. package/dist/components/{p-CDpq9L_H.js.map → p-CiT5gBDh.js.map} +1 -1
  98. package/dist/components/{p-D1oFXBAp.js → p-Cn_kantt.js} +5 -5
  99. package/dist/components/{p-D1oFXBAp.js.map → p-Cn_kantt.js.map} +1 -1
  100. package/dist/components/{p-DC3j4P1n.js → p-Cnc43o9b.js} +227 -41
  101. package/dist/components/p-Cnc43o9b.js.map +1 -0
  102. package/dist/components/{p-BAMl2Ww6.js → p-CneTqrgt.js} +18 -18
  103. package/dist/components/{p-BAMl2Ww6.js.map → p-CneTqrgt.js.map} +1 -1
  104. package/dist/components/{p-B2wWYPH8.js → p-CtiROna-.js} +3 -3
  105. package/dist/components/{p-B2wWYPH8.js.map → p-CtiROna-.js.map} +1 -1
  106. package/dist/components/{p-D0L3GqSK.js → p-Cw2ATHMj.js} +3 -3
  107. package/dist/components/{p-D0L3GqSK.js.map → p-Cw2ATHMj.js.map} +1 -1
  108. package/dist/components/{p-CxmkJbeV.js → p-D0sLslUq.js} +3 -3
  109. package/dist/components/{p-CxmkJbeV.js.map → p-D0sLslUq.js.map} +1 -1
  110. package/dist/components/{p-dCaxwGmu.js → p-DJN0U8pI.js} +10 -4
  111. package/dist/components/p-DJN0U8pI.js.map +1 -0
  112. package/dist/components/{p-q-xqpmae.js → p-DJaVT2yR.js} +255 -178
  113. package/dist/components/p-DJaVT2yR.js.map +1 -0
  114. package/dist/components/{p-C3E9PtD3.js → p-DMAzUKo6.js} +10 -10
  115. package/dist/components/{p-C3E9PtD3.js.map → p-DMAzUKo6.js.map} +1 -1
  116. package/dist/components/{p-DbPbyRLO.js → p-DSLY0tr5.js} +5 -5
  117. package/dist/components/{p-DbPbyRLO.js.map → p-DSLY0tr5.js.map} +1 -1
  118. package/dist/components/{p--2FkikYE.js → p-DpiklJU9.js} +3 -3
  119. package/dist/components/{p--2FkikYE.js.map → p-DpiklJU9.js.map} +1 -1
  120. package/dist/components/{p--tElassI.js → p-NZJPrwJV.js} +3 -3
  121. package/dist/components/{p--tElassI.js.map → p-NZJPrwJV.js.map} +1 -1
  122. package/dist/components/{p-BSS4UREq.js → p-ubNAWsY_.js} +9 -9
  123. package/dist/components/{p-BSS4UREq.js.map → p-ubNAWsY_.js.map} +1 -1
  124. package/dist/esm/{index-BPFXWTBp.js → index-BGl8znzE.js} +10 -4
  125. package/dist/esm/index-BGl8znzE.js.map +1 -0
  126. package/dist/esm/{index-DsUDklEm.js → index-DO2IiM_o.js} +348 -141
  127. package/dist/esm/index-DO2IiM_o.js.map +1 -0
  128. package/dist/esm/index.js +1 -1
  129. package/dist/esm/kritzel-brush-style_18.entry.js +137 -81
  130. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  131. package/dist/esm/loader.js +2 -2
  132. package/dist/esm/stencil.js +3 -3
  133. package/dist/esm/stencil.js.map +1 -1
  134. package/dist/stencil/index.esm.js +1 -1
  135. package/dist/stencil/p-BGl8znzE.js +3 -0
  136. package/dist/stencil/p-BGl8znzE.js.map +1 -0
  137. package/dist/stencil/p-DO2IiM_o.js +2 -0
  138. package/dist/stencil/p-DO2IiM_o.js.map +1 -0
  139. package/dist/stencil/p-c64f6589.entry.js +2 -0
  140. package/dist/stencil/p-c64f6589.entry.js.map +1 -0
  141. package/dist/stencil/stencil.esm.js +1 -1
  142. package/dist/stencil/stencil.esm.js.map +1 -1
  143. package/dist/types/classes/handlers/hover.handler.d.ts +6 -0
  144. package/dist/types/classes/handlers/selection.handler.d.ts +1 -1
  145. package/dist/types/classes/history.class.d.ts +1 -0
  146. package/dist/types/classes/objects/base-object.class.d.ts +12 -6
  147. package/dist/types/classes/objects/custom-element.class.d.ts +26 -0
  148. package/dist/types/classes/objects/image.class.d.ts +1 -1
  149. package/dist/types/classes/objects/path.class.d.ts +9 -2
  150. package/dist/types/classes/objects/text.class.d.ts +1 -1
  151. package/dist/types/classes/store.class.d.ts +5 -0
  152. package/dist/types/classes/tools/selection-tool.class.d.ts +2 -0
  153. package/dist/types/components.d.ts +4 -4
  154. package/dist/types/helpers/html.helper.d.ts +3 -0
  155. package/dist/types/interfaces/engine-state.interface.d.ts +2 -2
  156. package/dist/types/interfaces/object.interface.d.ts +12 -4
  157. package/package.json +5 -5
  158. package/dist/cjs/index-BcrLbdO1.js.map +0 -1
  159. package/dist/cjs/index-BjLSiQIM.js.map +0 -1
  160. package/dist/components/p-DC3j4P1n.js.map +0 -1
  161. package/dist/components/p-dCaxwGmu.js.map +0 -1
  162. package/dist/components/p-q-xqpmae.js.map +0 -1
  163. package/dist/esm/index-BPFXWTBp.js.map +0 -1
  164. package/dist/esm/index-DsUDklEm.js.map +0 -1
  165. package/dist/stencil/p-3797c300.entry.js +0 -2
  166. package/dist/stencil/p-3797c300.entry.js.map +0 -1
  167. package/dist/stencil/p-BPFXWTBp.js +0 -3
  168. package/dist/stencil/p-BPFXWTBp.js.map +0 -1
  169. package/dist/stencil/p-DsUDklEm.js +0 -2
  170. package/dist/stencil/p-DsUDklEm.js.map +0 -1
@@ -298,8 +298,12 @@ class ObjectHelper {
298
298
  }
299
299
  static clone(objOrObjs) {
300
300
  const cloneObject = (obj) => {
301
- const remainingProps = __rest(obj, ["_store", "_elementRef", "totalWidth", "totalHeight"]);
302
- return structuredClone(remainingProps);
301
+ const _a = obj, { element } = _a, remainingProps = __rest(_a, ["_store", "_elementRef", "totalWidth", "totalHeight", "element"]);
302
+ const clonedProps = structuredClone(remainingProps);
303
+ if (element && element instanceof HTMLElement) {
304
+ clonedProps.element = element.cloneNode(true);
305
+ }
306
+ return clonedProps;
303
307
  };
304
308
  if (Array.isArray(objOrObjs)) {
305
309
  return objOrObjs.map(cloneObject);
@@ -314,6 +318,59 @@ class ObjectHelper {
314
318
  }
315
319
  }
316
320
 
321
+ class KritzelGeometryHelper {
322
+ static doPolygonsIntersect(polygon1, polygon2) {
323
+ // 1. Convert polygons to array of points for easier processing
324
+ const points1 = [polygon1.bottomLeft, polygon1.bottomRight, polygon1.topRight, polygon1.topLeft];
325
+ const points2 = [polygon2.bottomLeft, polygon2.bottomRight, polygon2.topRight, polygon2.topLeft];
326
+ // 2. Check if any point of polygon1 is inside polygon2
327
+ for (const point of points1) {
328
+ if (this.isPointInPolygon(point, points2)) {
329
+ return true;
330
+ }
331
+ }
332
+ // 3. Check if any point of polygon2 is inside polygon1
333
+ for (const point of points2) {
334
+ if (this.isPointInPolygon(point, points1)) {
335
+ return true;
336
+ }
337
+ }
338
+ // 4. Check for edge intersections (more complex)
339
+ for (let i = 0; i < points1.length; i++) {
340
+ const p1a = points1[i];
341
+ const p1b = points1[(i + 1) % points1.length]; // Wrap around to the first point
342
+ for (let j = 0; j < points2.length; j++) {
343
+ const p2a = points2[j];
344
+ const p2b = points2[(j + 1) % points2.length];
345
+ if (this.intersectLines(p1a, p1b, p2a, p2b)) {
346
+ return true;
347
+ }
348
+ }
349
+ }
350
+ return false; // No intersection found
351
+ }
352
+ static isPointInPolygon(point, polygon) {
353
+ let inside = false;
354
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
355
+ const xi = polygon[i].x, yi = polygon[i].y;
356
+ const xj = polygon[j].x, yj = polygon[j].y;
357
+ const intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;
358
+ if (intersect)
359
+ inside = !inside;
360
+ }
361
+ return inside;
362
+ }
363
+ static intersectLines(p1a, p1b, p2a, p2b) {
364
+ const det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);
365
+ if (det === 0) {
366
+ return false; // Lines are parallel
367
+ }
368
+ const t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;
369
+ const u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;
370
+ return t >= 0 && t <= 1 && u >= 0 && u <= 1;
371
+ }
372
+ }
373
+
317
374
  class KritzelBaseObject {
318
375
  get totalWidth() {
319
376
  return this.width + this.padding * 2;
@@ -348,8 +405,8 @@ class KritzelBaseObject {
348
405
  };
349
406
  }
350
407
  get rotatedPolygon() {
351
- const cx = (this.translateX + this.totalWidth / 2 / this.scale);
352
- const cy = (this.translateY + this.totalHeight / 2 / this.scale);
408
+ const cx = this.translateX + this.totalWidth / 2 / this.scale;
409
+ const cy = this.translateY + this.totalHeight / 2 / this.scale;
353
410
  const angle = this.rotation;
354
411
  const adjustedWidth = this.totalWidth / this.scale;
355
412
  const adjustedHeight = this.totalHeight / this.scale;
@@ -369,39 +426,19 @@ class KritzelBaseObject {
369
426
  return rotatedCorners;
370
427
  }
371
428
  get minXRotated() {
372
- const corners = [
373
- this.rotatedPolygon.topLeft.x,
374
- this.rotatedPolygon.topRight.x,
375
- this.rotatedPolygon.bottomRight.x,
376
- this.rotatedPolygon.bottomLeft.x,
377
- ];
429
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
378
430
  return Math.min(...corners);
379
431
  }
380
432
  get minYRotated() {
381
- const corners = [
382
- this.rotatedPolygon.topLeft.y,
383
- this.rotatedPolygon.topRight.y,
384
- this.rotatedPolygon.bottomRight.y,
385
- this.rotatedPolygon.bottomLeft.y,
386
- ];
433
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
387
434
  return Math.min(...corners);
388
435
  }
389
436
  get maxXRotated() {
390
- const corners = [
391
- this.rotatedPolygon.topLeft.x,
392
- this.rotatedPolygon.topRight.x,
393
- this.rotatedPolygon.bottomRight.x,
394
- this.rotatedPolygon.bottomLeft.x,
395
- ];
437
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
396
438
  return Math.max(...corners);
397
439
  }
398
440
  get maxYRotated() {
399
- const corners = [
400
- this.rotatedPolygon.topLeft.y,
401
- this.rotatedPolygon.topRight.y,
402
- this.rotatedPolygon.bottomRight.y,
403
- this.rotatedPolygon.bottomLeft.y,
404
- ];
441
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
405
442
  return Math.max(...corners);
406
443
  }
407
444
  get transformationMatrix() {
@@ -421,18 +458,20 @@ class KritzelBaseObject {
421
458
  }
422
459
  constructor() {
423
460
  this.__class__ = 'KritzelBaseObject';
424
- this.visible = true;
425
461
  this.borderWidth = 0;
426
462
  this.opacity = 1;
427
463
  this.padding = 0;
428
- this.selected = false;
429
464
  this.resizing = false;
430
465
  this.rotation = 0;
431
466
  this.markedForRemoval = false;
432
- this.isMounted = false;
433
467
  this.zIndex = 0;
468
+ this.isVisible = true;
469
+ this.isSelected = false;
470
+ this.isHovered = false;
471
+ this.isMounted = false;
434
472
  this.isEditable = false;
435
- this.debugInfoVisible = false;
473
+ this.isInteractive = false;
474
+ this.isDebugInfoVisible = false;
436
475
  this.id = this.generateId();
437
476
  }
438
477
  static create(store) {
@@ -448,6 +487,18 @@ class KritzelBaseObject {
448
487
  this.elementRef = element;
449
488
  this.isMounted = true;
450
489
  }
490
+ unmount() {
491
+ if (!this.isMounted) {
492
+ return;
493
+ }
494
+ this.isMounted = false;
495
+ }
496
+ remount() {
497
+ if (!this.isMounted) {
498
+ return;
499
+ }
500
+ this.isMounted = false;
501
+ }
451
502
  generateId() {
452
503
  return ObjectHelper.generateUUID();
453
504
  }
@@ -457,10 +508,10 @@ class KritzelBaseObject {
457
508
  y: -this._store.state.translateY / this._store.state.scale,
458
509
  width: this._store.state.viewportWidth / this._store.state.scale,
459
510
  height: this._store.state.viewportHeight / this._store.state.scale};
460
- return this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
511
+ return (this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
461
512
  this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&
462
513
  this.boundingBox.y < viewportBounds.y + viewportBounds.height &&
463
- this.boundingBox.y + this.boundingBox.height > viewportBounds.y;
514
+ this.boundingBox.y + this.boundingBox.height > viewportBounds.y);
464
515
  }
465
516
  centerInViewport() {
466
517
  const scale = this._store.state.scale;
@@ -505,6 +556,13 @@ class KritzelBaseObject {
505
556
  edit() {
506
557
  // This method can be overridden by subclasses to handle edit actions.
507
558
  }
559
+ hitTest(_x, _y) {
560
+ return true; // Default implementation, can be overridden by subclasses
561
+ }
562
+ hitTestPolygon(polygon) {
563
+ const objectPolygon = this.rotatedPolygon;
564
+ return KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, polygon);
565
+ }
508
566
  }
509
567
 
510
568
  class KritzelText extends KritzelBaseObject {
@@ -520,7 +578,7 @@ class KritzelText extends KritzelBaseObject {
520
578
  this.fontColor = '#000000';
521
579
  this.initialWidth = 3;
522
580
  this.isNew = true;
523
- this.debugInfoVisible = true;
581
+ this.isDebugInfoVisible = true;
524
582
  this.isEditable = true;
525
583
  this.rows = 1;
526
584
  if (config) {
@@ -681,8 +739,9 @@ class KritzelPath extends KritzelBaseObject {
681
739
  this.height = 0;
682
740
  this.width = 0;
683
741
  this.scale = 1;
684
- this.visible = true;
685
- this.debugInfoVisible = true;
742
+ this.isVisible = true;
743
+ this.isDebugInfoVisible = true;
744
+ this._adjustedPoints = null;
686
745
  this.options = config;
687
746
  this.points = (_a = config === null || config === void 0 ? void 0 : config.points) !== null && _a !== void 0 ? _a : [];
688
747
  this.translateX = (_b = config === null || config === void 0 ? void 0 : config.translateX) !== null && _b !== void 0 ? _b : 0;
@@ -726,10 +785,137 @@ class KritzelPath extends KritzelBaseObject {
726
785
  this.y = Math.min(...this.points.map(p => p[1])) - this.strokeWidth / 2;
727
786
  this.translateX = x;
728
787
  this.translateY = y;
788
+ this._adjustedPoints = null;
729
789
  }
730
790
  rotate(value) {
731
- super.rotate(value);
732
- this.updateDimensions();
791
+ this.rotation = value;
792
+ this._adjustedPoints = null;
793
+ }
794
+ move(_startX, _startY, _endX, _endY) {
795
+ this._adjustedPoints = null;
796
+ }
797
+ hitTest(x, y) {
798
+ const halfStroke = this.strokeWidth / this.scale / 2;
799
+ if (this._adjustedPoints === null) {
800
+ this._adjustedPoints = this.computeAdjustedPoints();
801
+ }
802
+ if (this._adjustedPoints.length === 1) {
803
+ const p1 = this._adjustedPoints[0];
804
+ const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p1[0], p1[1]);
805
+ return distance <= halfStroke;
806
+ }
807
+ for (let i = 0; i < this._adjustedPoints.length - 1; i++) {
808
+ const p1 = this._adjustedPoints[i];
809
+ const p2 = this._adjustedPoints[i + 1];
810
+ const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p2[0], p2[1]);
811
+ if (distance <= halfStroke) {
812
+ return true;
813
+ }
814
+ }
815
+ return false;
816
+ }
817
+ hitTestPolygon(polygon) {
818
+ const halfStroke = this.strokeWidth / this.scale / 2;
819
+ if (this._adjustedPoints === null) {
820
+ this._adjustedPoints = this.computeAdjustedPoints();
821
+ }
822
+ const polyPoints = [
823
+ { x: polygon.bottomLeft.x, y: polygon.bottomLeft.y },
824
+ { x: polygon.bottomRight.x, y: polygon.bottomRight.y },
825
+ { x: polygon.topRight.x, y: polygon.topRight.y },
826
+ { x: polygon.topLeft.x, y: polygon.topLeft.y },
827
+ ];
828
+ for (const [px, py] of this._adjustedPoints) {
829
+ if (KritzelGeometryHelper.isPointInPolygon({ x: px, y: py }, polyPoints)) {
830
+ return true;
831
+ }
832
+ }
833
+ for (const pt of polyPoints) {
834
+ if (this.hitTest(pt.x, pt.y)) {
835
+ return true;
836
+ }
837
+ }
838
+ for (let i = 0; i < this._adjustedPoints.length - 1; i++) {
839
+ const p1 = { x: this._adjustedPoints[i][0], y: this._adjustedPoints[i][1] };
840
+ const p2 = { x: this._adjustedPoints[i + 1][0], y: this._adjustedPoints[i + 1][1] };
841
+ for (let j = 0; j < polyPoints.length; j++) {
842
+ const q1 = polyPoints[j];
843
+ const q2 = polyPoints[(j + 1) % polyPoints.length];
844
+ if (KritzelGeometryHelper.intersectLines(p1, p2, q1, q2)) {
845
+ return true;
846
+ }
847
+ }
848
+ }
849
+ for (let i = 0; i < this._adjustedPoints.length - 1; i++) {
850
+ const p1 = this._adjustedPoints[i];
851
+ const p2 = this._adjustedPoints[i + 1];
852
+ for (let j = 0; j < polyPoints.length; j++) {
853
+ const q1 = polyPoints[j];
854
+ const q2 = polyPoints[(j + 1) % polyPoints.length];
855
+ const d1 = this.pointToLineSegmentDistance(q1.x, q1.y, p1[0], p1[1], p2[0], p2[1]);
856
+ const d2 = this.pointToLineSegmentDistance(q2.x, q2.y, p1[0], p1[1], p2[0], p2[1]);
857
+ const d3 = this.pointToLineSegmentDistance(p1[0], p1[1], q1.x, q1.y, q2.x, q2.y);
858
+ const d4 = this.pointToLineSegmentDistance(p2[0], p2[1], q1.x, q1.y, q2.x, q2.y);
859
+ const minD = Math.min(d1, d2, d3, d4);
860
+ if (minD <= halfStroke) {
861
+ return true;
862
+ }
863
+ }
864
+ }
865
+ return false;
866
+ }
867
+ computeAdjustedPoints() {
868
+ var _a;
869
+ if (!((_a = this.points) === null || _a === void 0 ? void 0 : _a.length)) {
870
+ return [];
871
+ }
872
+ const angle = this.rotation;
873
+ const cos = Math.cos(angle);
874
+ const sin = Math.sin(angle);
875
+ const xs = this.points.map(p => p[0]);
876
+ const ys = this.points.map(p => p[1]);
877
+ const pivot = {
878
+ x: (Math.min(...xs) + Math.max(...xs)) / 2,
879
+ y: (Math.min(...ys) + Math.max(...ys)) / 2,
880
+ };
881
+ const { x: cx, y: cy } = pivot;
882
+ const rotatedPoints = this.points.map(([x, y]) => {
883
+ const dx = x - cx;
884
+ const dy = y - cy;
885
+ return [cx + dx * cos - dy * sin, cy + dx * sin + dy * cos];
886
+ });
887
+ const deltaX = this.x - this.translateX;
888
+ const deltaY = this.y - this.translateY;
889
+ return rotatedPoints.map(([px, py]) => [(px + this.options.translateX - deltaX) / this.scale, (py + this.options.translateY - deltaY) / this.scale]);
890
+ }
891
+ pointToLineSegmentDistance(x, y, x1, y1, x2, y2) {
892
+ const A = x - x1;
893
+ const B = y - y1;
894
+ const C = x2 - x1;
895
+ const D = y2 - y1;
896
+ const dot = A * C + B * D;
897
+ const len_sq = C * C + D * D;
898
+ let param = -1;
899
+ if (len_sq !== 0) {
900
+ // in case of 0 length line
901
+ param = dot / len_sq;
902
+ }
903
+ let xx, yy;
904
+ if (param < 0) {
905
+ xx = x1;
906
+ yy = y1;
907
+ }
908
+ else if (param > 1) {
909
+ xx = x2;
910
+ yy = y2;
911
+ }
912
+ else {
913
+ xx = x1 + param * C;
914
+ yy = y1 + param * D;
915
+ }
916
+ const dx = x - xx;
917
+ const dy = y - yy;
918
+ return Math.sqrt(dx * dx + dy * dy);
733
919
  }
734
920
  updateDimensions() {
735
921
  const rotatedPoints = this.points.map(([x, y]) => {
@@ -802,7 +988,7 @@ class KritzelImage extends KritzelBaseObject {
802
988
  this.maxWidth = 300;
803
989
  this.maxHeight = 300;
804
990
  this.maxCompressionSize = 300;
805
- this.debugInfoVisible = true;
991
+ this.isDebugInfoVisible = true;
806
992
  this.src = (config === null || config === void 0 ? void 0 : config.src) || '';
807
993
  this.x = (config === null || config === void 0 ? void 0 : config.x) || 0;
808
994
  this.y = (config === null || config === void 0 ? void 0 : config.y) || 0;
@@ -971,6 +1157,57 @@ class BatchCommand extends KritzelBaseCommand {
971
1157
  }
972
1158
  }
973
1159
 
1160
+ class KritzelCustomElement extends KritzelBaseObject {
1161
+ constructor(config) {
1162
+ super();
1163
+ this.__class__ = 'KritzelCustomElement';
1164
+ this.isInteractive = true;
1165
+ if (config) {
1166
+ this.translateX = config.translateX || 0;
1167
+ this.translateY = config.translateY || 0;
1168
+ this.scale = config.scale || 1;
1169
+ this.element = config.element;
1170
+ this.height = config.height || 0;
1171
+ this.width = config.width || 0;
1172
+ }
1173
+ }
1174
+ static create(store, config) {
1175
+ const object = new KritzelCustomElement(config);
1176
+ object._store = store;
1177
+ object.id = object.generateId();
1178
+ return object;
1179
+ }
1180
+ mount(element) {
1181
+ if (this.isMounted) {
1182
+ return;
1183
+ }
1184
+ this.elementRef = element;
1185
+ this.isMounted = true;
1186
+ this.elementRef.appendChild(this.element);
1187
+ }
1188
+ resize(x, y, width, height) {
1189
+ if (width <= 1 || height <= 1) {
1190
+ return;
1191
+ }
1192
+ this.width = width;
1193
+ this.height = height;
1194
+ this.translateX = x;
1195
+ this.translateY = y;
1196
+ if (this.element) {
1197
+ this.element.style.width = `${width}px`;
1198
+ this.element.style.height = `${height}px`;
1199
+ }
1200
+ }
1201
+ copy() {
1202
+ const copiedObject = Object.create(Object.getPrototypeOf(this));
1203
+ Object.assign(copiedObject, this);
1204
+ copiedObject.id = this.generateId();
1205
+ copiedObject.isMounted = false;
1206
+ copiedObject.element = this.element.cloneNode(true);
1207
+ return copiedObject;
1208
+ }
1209
+ }
1210
+
974
1211
  class RemoveObjectCommand extends KritzelBaseCommand {
975
1212
  constructor(store, initiator, object) {
976
1213
  super(store, initiator);
@@ -978,9 +1215,11 @@ class RemoveObjectCommand extends KritzelBaseCommand {
978
1215
  }
979
1216
  execute() {
980
1217
  this._store.state.objectsOctree.remove(object => object.id === this.object.id);
1218
+ this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
981
1219
  }
982
1220
  undo() {
983
1221
  this._store.state.objectsOctree.insert(this.object);
1222
+ this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
984
1223
  }
985
1224
  }
986
1225
 
@@ -1004,28 +1243,33 @@ class KritzelEraserTool extends KritzelBaseTool {
1004
1243
  }
1005
1244
  }
1006
1245
  handlePointerMove(event) {
1007
- var _a, _b;
1246
+ var _a;
1008
1247
  if (event.pointerType === 'mouse') {
1009
1248
  if (this._store.state.isErasing) {
1010
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1011
- if (!shadowRoot)
1249
+ const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1250
+ if (selectedObjects.length === 0)
1012
1251
  return;
1013
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1014
- if (!selectedObject)
1015
- return;
1016
- selectedObject.markedForRemoval = true;
1252
+ const x = this._store.state.pointerX;
1253
+ const y = this._store.state.pointerY;
1254
+ selectedObjects.forEach(selectedObject => {
1255
+ selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1256
+ });
1017
1257
  this._store.rerender();
1018
1258
  }
1019
1259
  }
1020
1260
  if (event.pointerType === 'touch') {
1021
1261
  if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
1022
- const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
1262
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
1023
1263
  if (!shadowRoot)
1024
1264
  return;
1025
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
1026
- if (!selectedObject)
1265
+ const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
1266
+ if (selectedObjects.length === 0)
1027
1267
  return;
1028
- selectedObject.markedForRemoval = true;
1268
+ const x = this._store.state.pointerX;
1269
+ const y = this._store.state.pointerY;
1270
+ selectedObjects.forEach(selectedObject => {
1271
+ selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
1272
+ });
1029
1273
  this._store.rerender();
1030
1274
  }
1031
1275
  }
@@ -1033,9 +1277,7 @@ class KritzelEraserTool extends KritzelBaseTool {
1033
1277
  handlePointerUp(event) {
1034
1278
  if (event.pointerType === 'mouse') {
1035
1279
  if (this._store.state.isErasing) {
1036
- const removeCommands = this._store.allObjects
1037
- .filter(object => object.markedForRemoval)
1038
- .map(object => {
1280
+ const removeCommands = this._store.allObjects.filter(object => object.markedForRemoval).map(object => {
1039
1281
  object.markedForRemoval = false;
1040
1282
  return new RemoveObjectCommand(this._store, this, object);
1041
1283
  });
@@ -1118,7 +1360,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1118
1360
  var _a, _b;
1119
1361
  if (event.pointerType === 'mouse') {
1120
1362
  if (KritzelEventHelper.isLeftClick(event)) {
1121
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1363
+ if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1122
1364
  const clientX = event.clientX - this._store.offsetX;
1123
1365
  const clientY = event.clientY - this._store.offsetY;
1124
1366
  this._store.state.isDragging = true;
@@ -1132,7 +1374,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
1132
1374
  if (event.pointerType === 'touch') {
1133
1375
  const activePointers = Array.from(this._store.state.pointers.values());
1134
1376
  if (this._store.state.pointers.size === 1) {
1135
- if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1377
+ if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
1136
1378
  const x = Math.round(activePointers[0].clientX - this._store.offsetX);
1137
1379
  const y = Math.round(activePointers[0].clientY - this._store.offsetY);
1138
1380
  this.dragStartX = x;
@@ -1484,59 +1726,6 @@ class KritzelRotationHandler extends KritzelBaseHandler {
1484
1726
  }
1485
1727
  }
1486
1728
 
1487
- class KritzelGeometryHelper {
1488
- static doPolygonsIntersect(polygon1, polygon2) {
1489
- // 1. Convert polygons to array of points for easier processing
1490
- const points1 = [polygon1.bottomLeft, polygon1.bottomRight, polygon1.topRight, polygon1.topLeft];
1491
- const points2 = [polygon2.bottomLeft, polygon2.bottomRight, polygon2.topRight, polygon2.topLeft];
1492
- // 2. Check if any point of polygon1 is inside polygon2
1493
- for (const point of points1) {
1494
- if (this.isPointInPolygon(point, points2)) {
1495
- return true;
1496
- }
1497
- }
1498
- // 3. Check if any point of polygon2 is inside polygon1
1499
- for (const point of points2) {
1500
- if (this.isPointInPolygon(point, points1)) {
1501
- return true;
1502
- }
1503
- }
1504
- // 4. Check for edge intersections (more complex)
1505
- for (let i = 0; i < points1.length; i++) {
1506
- const p1a = points1[i];
1507
- const p1b = points1[(i + 1) % points1.length]; // Wrap around to the first point
1508
- for (let j = 0; j < points2.length; j++) {
1509
- const p2a = points2[j];
1510
- const p2b = points2[(j + 1) % points2.length];
1511
- if (this.intersectLines(p1a, p1b, p2a, p2b)) {
1512
- return true;
1513
- }
1514
- }
1515
- }
1516
- return false; // No intersection found
1517
- }
1518
- static isPointInPolygon(point, polygon) {
1519
- let inside = false;
1520
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
1521
- const xi = polygon[i].x, yi = polygon[i].y;
1522
- const xj = polygon[j].x, yj = polygon[j].y;
1523
- const intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;
1524
- if (intersect)
1525
- inside = !inside;
1526
- }
1527
- return inside;
1528
- }
1529
- static intersectLines(p1a, p1b, p2a, p2b) {
1530
- const det = (p1b.x - p1a.x) * (p2b.y - p2a.y) - (p1b.y - p1a.y) * (p2b.x - p2a.x);
1531
- if (det === 0) {
1532
- return false; // Lines are parallel
1533
- }
1534
- const t = ((p2a.x - p1a.x) * (p2b.y - p2a.y) - (p2a.y - p1a.y) * (p2b.x - p2a.x)) / det;
1535
- const u = -((p1a.x - p2a.x) * (p1b.y - p1a.y) - (p1a.y - p2a.y) * (p1b.x - p1a.x)) / det;
1536
- return t >= 0 && t <= 1 && u >= 0 && u <= 1;
1537
- }
1538
- }
1539
-
1540
1729
  class KrtizelSelectionBox extends KritzelBaseObject {
1541
1730
  constructor() {
1542
1731
  super(...arguments);
@@ -1549,8 +1738,8 @@ class KrtizelSelectionBox extends KritzelBaseObject {
1549
1738
  object.id = object.generateId();
1550
1739
  object.scale = store.state.scale;
1551
1740
  object.zIndex = 99999;
1552
- object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(14, 17, 17, 0.2))';
1553
- object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(14, 17, 17, 0.5))';
1741
+ object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(0, 122, 255, 0.2))';
1742
+ object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(0, 122, 255, 0.5))';
1554
1743
  object.borderWidth = 2;
1555
1744
  object.height = 0;
1556
1745
  object.width = 0;
@@ -1627,8 +1816,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1627
1816
  if (event.pointerType === 'mouse') {
1628
1817
  if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
1629
1818
  if (this.isSelectionClick) {
1630
- this.updateMouseSelection(event);
1631
- this.addSelectedObjectAtIndexToSelectionGroup(0);
1819
+ const x = this._store.state.pointerX;
1820
+ const y = this._store.state.pointerY;
1821
+ const selectedObject = this._store.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1822
+ this.addObjectToSelectionGroup(selectedObject);
1632
1823
  this.removeSelectionBox();
1633
1824
  }
1634
1825
  if (this.isSelectionDrag) {
@@ -1642,8 +1833,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1642
1833
  clearTimeout(this.touchStartTimeout);
1643
1834
  if (this._store.state.isSelecting) {
1644
1835
  if (this.isSelectionClick) {
1645
- this.updateTouchSelection();
1646
- this.addSelectedObjectAtIndexToSelectionGroup(0);
1836
+ const x = this._store.state.pointerX;
1837
+ const y = this._store.state.pointerY;
1838
+ const selectedObject = this._store.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
1839
+ this.addObjectToSelectionGroup(selectedObject);
1647
1840
  this.removeSelectionBox();
1648
1841
  }
1649
1842
  if (this.isSelectionDrag) {
@@ -1737,23 +1930,16 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1737
1930
  updateSelectedObjects() {
1738
1931
  this._store.allObjects
1739
1932
  .filter(o => !(o instanceof KrtizelSelectionBox))
1740
- .forEach(object => {
1741
- const objectPolygon = object.rotatedPolygon;
1742
- const selectionBoxPolygon = this._store.state.selectionBox.rotatedPolygon;
1743
- object.selected = KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, selectionBoxPolygon);
1744
- });
1933
+ .forEach(object => (object.isSelected = object.hitTestPolygon(this._store.state.selectionBox.rotatedPolygon)));
1745
1934
  }
1746
- addSelectedObjectAtIndexToSelectionGroup(index) {
1747
- const selectedObjects = this._store.selectedObjects.sort((a, b) => b.zIndex - a.zIndex);
1748
- const selectedObject = selectedObjects[index];
1749
- if (!selectedObject) {
1935
+ addObjectToSelectionGroup(object) {
1936
+ if (!object) {
1750
1937
  return;
1751
1938
  }
1752
- selectedObjects.forEach(o => (o.selected = false));
1753
1939
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
1754
- this._store.state.selectionGroup.addOrRemove(selectedObject);
1755
- this._store.state.selectionGroup.selected = true;
1756
- this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
1940
+ this._store.state.selectionGroup.addOrRemove(object);
1941
+ this._store.state.selectionGroup.isSelected = true;
1942
+ this._store.state.selectionGroup.rotation = object.rotation;
1757
1943
  this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
1758
1944
  }
1759
1945
  addSelectedObjectsToSelectionGroup() {
@@ -1763,10 +1949,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1763
1949
  }
1764
1950
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
1765
1951
  selectedObjects.forEach(o => {
1766
- o.selected = false;
1952
+ o.isSelected = false;
1767
1953
  this._store.state.selectionGroup.addOrRemove(o);
1768
1954
  });
1769
- this._store.state.selectionGroup.selected = true;
1955
+ this._store.state.selectionGroup.isSelected = true;
1770
1956
  if (this._store.state.selectionGroup.length === 1) {
1771
1957
  this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
1772
1958
  }
@@ -1774,11 +1960,31 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
1774
1960
  }
1775
1961
  }
1776
1962
 
1963
+ class KritzelHoverHandler extends KritzelBaseHandler {
1964
+ constructor(store) {
1965
+ super(store);
1966
+ }
1967
+ handlePointerMove(event) {
1968
+ if (event.pointerType === 'mouse') {
1969
+ const hoveredObject = this._store.getObjectFromPointerEvent(event, '.object');
1970
+ if (!hoveredObject)
1971
+ return;
1972
+ const x = this._store.state.pointerX;
1973
+ const y = this._store.state.pointerY;
1974
+ hoveredObject.isHovered = hoveredObject.hitTest(x, y);
1975
+ if (hoveredObject.isHovered) {
1976
+ console.log(hoveredObject.id);
1977
+ }
1978
+ }
1979
+ }
1980
+ }
1981
+
1777
1982
  class KritzelSelectionTool extends KritzelBaseTool {
1778
1983
  constructor(store) {
1779
1984
  super(store);
1780
1985
  this.selectionHandler = new KritzelSelectionHandler(this._store);
1781
1986
  this.moveHandler = new KritzelMoveHandler(this._store);
1987
+ this.hoverHandler = new KritzelHoverHandler(this._store);
1782
1988
  this.resizeHandler = new KritzelResizeHandler(this._store);
1783
1989
  this.rotationHandler = new KritzelRotationHandler(this._store);
1784
1990
  }
@@ -1799,12 +2005,8 @@ class KritzelSelectionTool extends KritzelBaseTool {
1799
2005
  !this._store.state.isRotationHandleSelected) {
1800
2006
  this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
1801
2007
  }
1802
- if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
1803
- setTimeout(() => {
1804
- if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
1805
- selectedObject.objects[0].onSelectedClick();
1806
- }
1807
- }, 100);
2008
+ if (selectedObject && selectedObject.isSelected === false && (selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.objects.length) === 1 && selectedObject.objects[0].isInteractive) {
2009
+ return;
1808
2010
  }
1809
2011
  }
1810
2012
  this.moveHandler.handlePointerDown(event);
@@ -1845,6 +2047,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
1845
2047
  }
1846
2048
  if (event.pointerType === 'mouse') {
1847
2049
  this.moveHandler.handlePointerMove(event);
2050
+ this.hoverHandler.handlePointerMove(event);
1848
2051
  this.selectionHandler.handlePointerMove(event);
1849
2052
  this.resizeHandler.handlePointerMove(event);
1850
2053
  this.rotationHandler.handlePointerMove(event);
@@ -1941,6 +2144,9 @@ class KritzelReviver {
1941
2144
  case 'KritzelImage':
1942
2145
  revivedObj = KritzelImage.create(this._store).revive(obj);
1943
2146
  break;
2147
+ case 'KritzelCustomElement':
2148
+ revivedObj = KritzelCustomElement.create(this._store).revive(obj);
2149
+ break;
1944
2150
  case 'KritzelSelectionGroup':
1945
2151
  revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
1946
2152
  break;
@@ -2006,7 +2212,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2006
2212
  this.refreshObjectDimensions();
2007
2213
  }
2008
2214
  deselectAllChildren() {
2009
- this.objects.forEach(obj => (obj.selected = false));
2215
+ this.objects.forEach(obj => (obj.isSelected = false));
2010
2216
  }
2011
2217
  updatePosition(x, y) {
2012
2218
  this.objects.forEach(obj => {
@@ -2035,6 +2241,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2035
2241
  this.objects.forEach(obj => {
2036
2242
  obj.translateX += deltaX;
2037
2243
  obj.translateY += deltaY;
2244
+ obj.move(startX, startY, endX, endY);
2038
2245
  this._store.state.objectsOctree.update(obj);
2039
2246
  });
2040
2247
  this.unchangedObjects.forEach(obj => {
@@ -2073,7 +2280,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
2073
2280
  const rotatedY = sin * offsetX + cos * offsetY;
2074
2281
  child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
2075
2282
  child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
2076
- child.rotation = this.objects.length === 1 ? value : value + unchangedChild.rotation;
2283
+ child.rotate(this.objects.length === 1 ? value : value + unchangedChild.rotation);
2077
2284
  this._store.state.objectsOctree.update(child);
2078
2285
  });
2079
2286
  }
@@ -2211,7 +2418,7 @@ class KritzelImageTool extends KritzelBaseTool {
2211
2418
  addImageToStore(image) {
2212
2419
  const selectionGroup = KritzelSelectionGroup.create(this._store);
2213
2420
  selectionGroup.addOrRemove(image);
2214
- selectionGroup.selected = true;
2421
+ selectionGroup.isSelected = true;
2215
2422
  const addImageCommand = new AddObjectCommand(this._store, this, image);
2216
2423
  const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);
2217
2424
  this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));
@@ -2337,6 +2544,6 @@ exports.KritzelToolRegistry = KritzelToolRegistry;
2337
2544
  exports.KrtizelSelectionBox = KrtizelSelectionBox;
2338
2545
  exports.RemoveObjectCommand = RemoveObjectCommand;
2339
2546
  exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
2340
- //# sourceMappingURL=index-BjLSiQIM.js.map
2547
+ //# sourceMappingURL=index-UcX3pzju.js.map
2341
2548
 
2342
- //# sourceMappingURL=index-BjLSiQIM.js.map
2549
+ //# sourceMappingURL=index-UcX3pzju.js.map