kritzel-stencil 0.0.132 → 0.0.133

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 (85) hide show
  1. package/dist/cjs/{index-ouFX0OVi.js → index-DCHCVnOl.js} +87 -72
  2. package/dist/cjs/index-DCHCVnOl.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-color_22.cjs.entry.js +16 -15
  5. package/dist/collection/classes/commands/move-selection-group.command.js +8 -0
  6. package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
  7. package/dist/collection/classes/commands/resize-selection-group.command.js +8 -0
  8. package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
  9. package/dist/collection/classes/commands/rotate-selection-group.command.js +5 -3
  10. package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
  11. package/dist/collection/classes/commands/update-object.command.js +2 -0
  12. package/dist/collection/classes/commands/update-object.command.js.map +1 -1
  13. package/dist/collection/classes/core/core.class.js +4 -8
  14. package/dist/collection/classes/core/core.class.js.map +1 -1
  15. package/dist/collection/classes/handlers/context-menu.handler.js +7 -2
  16. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  17. package/dist/collection/classes/handlers/move.handler.js +24 -19
  18. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  19. package/dist/collection/classes/handlers/resize.handler.js +10 -12
  20. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  21. package/dist/collection/classes/handlers/rotation.handler.js +14 -22
  22. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  23. package/dist/collection/classes/objects/base-object.class.js +11 -3
  24. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js +3 -4
  26. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  27. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +6 -4
  28. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  29. package/dist/collection/helpers/object.helper.js +0 -14
  30. package/dist/collection/helpers/object.helper.js.map +1 -1
  31. package/dist/collection/interfaces/clonable.interface.js +2 -0
  32. package/dist/collection/interfaces/clonable.interface.js.map +1 -0
  33. package/dist/components/index.js +2 -2
  34. package/dist/components/kritzel-controls.js +1 -1
  35. package/dist/components/kritzel-editor.js +7 -7
  36. package/dist/components/kritzel-engine.js +1 -1
  37. package/dist/components/kritzel-menu-item.js +1 -1
  38. package/dist/components/kritzel-menu.js +1 -1
  39. package/dist/components/kritzel-portal.js +1 -1
  40. package/dist/components/kritzel-split-button.js +1 -1
  41. package/dist/components/kritzel-workspace-manager.js +1 -1
  42. package/dist/components/p-B0kd2rUI.js +16 -0
  43. package/dist/components/p-B0kd2rUI.js.map +1 -0
  44. package/dist/components/{p-BiCgeOiJ.js → p-B3LGnqFz.js} +3 -3
  45. package/dist/components/{p-BiCgeOiJ.js.map → p-B3LGnqFz.js.map} +1 -1
  46. package/dist/components/{p-C1-nvBx9.js → p-BKvOO7NT.js} +6 -6
  47. package/dist/components/{p-C1-nvBx9.js.map → p-BKvOO7NT.js.map} +1 -1
  48. package/dist/components/{p-CvmWmUK9.js → p-CM8KdFZI.js} +4 -4
  49. package/dist/components/{p-CvmWmUK9.js.map → p-CM8KdFZI.js.map} +1 -1
  50. package/dist/components/{p-B3VQubt_.js → p-CNTK3JOp.js} +16 -6
  51. package/dist/components/p-CNTK3JOp.js.map +1 -0
  52. package/dist/components/{p-Davd1R_4.js → p-CwH-bwjb.js} +91 -71
  53. package/dist/components/p-CwH-bwjb.js.map +1 -0
  54. package/dist/components/{p-D_907-Wd.js → p-Dw4n-4zp.js} +3 -3
  55. package/dist/components/{p-D_907-Wd.js.map → p-Dw4n-4zp.js.map} +1 -1
  56. package/dist/components/{p-CTvJDYFQ.js → p-NP1Htol7.js} +3 -3
  57. package/dist/components/{p-CTvJDYFQ.js.map → p-NP1Htol7.js.map} +1 -1
  58. package/dist/esm/{index-C_uHp-ur.js → index-DY3KqYWc.js} +87 -72
  59. package/dist/esm/index-DY3KqYWc.js.map +1 -0
  60. package/dist/esm/index.js +1 -1
  61. package/dist/esm/kritzel-color_22.entry.js +16 -15
  62. package/dist/stencil/index.esm.js +1 -1
  63. package/dist/stencil/p-DY3KqYWc.js +2 -0
  64. package/dist/stencil/p-DY3KqYWc.js.map +1 -0
  65. package/dist/stencil/p-dc534b01.entry.js +2 -0
  66. package/dist/stencil/p-dc534b01.entry.js.map +1 -0
  67. package/dist/stencil/stencil.esm.js +1 -1
  68. package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
  69. package/dist/types/classes/handlers/move.handler.d.ts +2 -0
  70. package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
  71. package/dist/types/classes/handlers/rotation.handler.d.ts +4 -0
  72. package/dist/types/classes/objects/base-object.class.d.ts +3 -1
  73. package/dist/types/helpers/object.helper.d.ts +0 -2
  74. package/dist/types/interfaces/clonable.interface.d.ts +3 -0
  75. package/package.json +64 -64
  76. package/dist/cjs/index-ouFX0OVi.js.map +0 -1
  77. package/dist/components/p-B3VQubt_.js.map +0 -1
  78. package/dist/components/p-Davd1R_4.js.map +0 -1
  79. package/dist/components/p-EXPChOF6.js +0 -30
  80. package/dist/components/p-EXPChOF6.js.map +0 -1
  81. package/dist/esm/index-C_uHp-ur.js.map +0 -1
  82. package/dist/stencil/p-C_uHp-ur.js +0 -2
  83. package/dist/stencil/p-C_uHp-ur.js.map +0 -1
  84. package/dist/stencil/p-a6f8283e.entry.js +0 -2
  85. package/dist/stencil/p-a6f8283e.entry.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-BYanlgdq.js';
2
2
  import { K as KritzelMouseButton } from './p-D8W6LE-c.js';
3
- import { e as KritzelBaseObject, f as KritzelBaseCommand, g as KritzelBaseTool, h as KritzelEventHelper, U as UpdateObjectCommand, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, A as AddObjectCommand, i as KritzelToolRegistry, d as KritzelKeyboardHelper } from './p-B3VQubt_.js';
4
- import { O as ObjectHelper } from './p-EXPChOF6.js';
3
+ import { e as KritzelBaseObject, f as KritzelBaseCommand, g as KritzelBaseTool, h as KritzelEventHelper, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, A as AddObjectCommand, i as KritzelToolRegistry, U as UpdateObjectCommand, d as KritzelKeyboardHelper } from './p-CNTK3JOp.js';
5
4
  import { K as KritzelWorkspace } from './p-YqK8ch2R.js';
6
5
  import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-BGdsAz54.js';
6
+ import { O as ObjectHelper } from './p-B0kd2rUI.js';
7
7
  import { K as KritzelDevicesHelper } from './p-l10It7Nm.js';
8
8
  import { d as defineCustomElement$2 } from './p-Db3kxVe2.js';
9
9
  import { d as defineCustomElement$1 } from './p-sq9jgfX0.js';
@@ -268,10 +268,18 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
268
268
  }
269
269
  this._core.store.setState('selectionGroup', this.selectionGroup);
270
270
  this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
271
+ this._core.store.state.selectionGroup.objects.forEach(object => {
272
+ this._core.store.state.objectsMap.update(object);
273
+ this._core.updateObjectInDatabase(object);
274
+ });
271
275
  }
272
276
  undo() {
273
277
  this._core.store.setState('selectionGroup', this.selectionGroup);
274
278
  this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
279
+ this._core.store.state.selectionGroup.objects.forEach(object => {
280
+ this._core.store.state.objectsMap.update(object);
281
+ this._core.updateObjectInDatabase(object);
282
+ });
275
283
  }
276
284
  }
277
285
 
@@ -289,9 +297,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
289
297
  startY;
290
298
  endX;
291
299
  endY;
300
+ hasMoved = false;
292
301
  constructor(core) {
293
302
  super(core);
294
303
  }
304
+ reset() {
305
+ this.dragStartX = 0;
306
+ this.dragStartY = 0;
307
+ this.startX = 0;
308
+ this.startY = 0;
309
+ this.endX = 0;
310
+ this.endY = 0;
311
+ this.hasMoved = false;
312
+ }
295
313
  handlePointerDown(event) {
296
314
  if (event.pointerType === 'mouse') {
297
315
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -330,16 +348,21 @@ class KritzelMoveHandler extends KritzelBaseHandler {
330
348
  this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
331
349
  this.dragStartX = clientX;
332
350
  this.dragStartY = clientY;
351
+ this.hasMoved = true;
333
352
  }
334
353
  }
335
354
  if (event.pointerType === 'touch') {
336
355
  const activePointers = Array.from(this._core.store.state.pointers.values());
337
- if (this._core.store.state.pointers.size === 1 && this._core.store.state.selectionGroup && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
356
+ if (this._core.store.state.pointers.size === 1 &&
357
+ this._core.store.state.selectionGroup &&
358
+ !this._core.store.state.isResizeHandleSelected &&
359
+ !this._core.store.state.isRotationHandleSelected) {
338
360
  const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
339
361
  const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
340
362
  this._core.store.setState('isDragging', true);
341
363
  this.endX = x;
342
364
  this.endY = y;
365
+ this.hasMoved = true;
343
366
  const moveDeltaX = Math.abs(x - this.startX);
344
367
  const moveDeltaY = Math.abs(y - this.startY);
345
368
  const moveThreshold = 5;
@@ -356,27 +379,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
356
379
  if (event.pointerType === 'mouse') {
357
380
  if (this._core.store.state.isDragging) {
358
381
  this._core.store.setState('isDragging', false);
359
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
360
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
361
- return new UpdateObjectCommand(this._core, this, object, {
362
- translateX: object.translateX,
363
- translateY: object.translateY
364
- });
365
- });
366
- this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
382
+ if (this.hasMoved) {
383
+ this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
384
+ }
385
+ this.reset();
367
386
  }
368
387
  }
369
388
  if (event.pointerType === 'touch') {
370
389
  if (this._core.store.state.isDragging) {
371
390
  this._core.store.setState('isDragging', false);
372
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
373
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
374
- return new UpdateObjectCommand(this._core, this, object, {
375
- translateX: object.translateX,
376
- translateY: object.translateY
377
- });
378
- });
379
- this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
391
+ if (this.hasMoved) {
392
+ this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
393
+ }
394
+ this.reset();
380
395
  }
381
396
  }
382
397
  }
@@ -403,10 +418,18 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
403
418
  execute() {
404
419
  this._core.store.setState('selectionGroup', this.selectionGroup);
405
420
  this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
421
+ this._core.store.state.selectionGroup.objects.forEach(object => {
422
+ this._core.store.state.objectsMap.update(object);
423
+ this._core.updateObjectInDatabase(object);
424
+ });
406
425
  }
407
426
  undo() {
408
427
  this._core.store.setState('selectionGroup', this.selectionGroup);
409
428
  this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
429
+ this._core.store.state.selectionGroup.objects.forEach(object => {
430
+ this._core.store.state.objectsMap.update(object);
431
+ this._core.updateObjectInDatabase(object);
432
+ });
410
433
  }
411
434
  }
412
435
 
@@ -418,6 +441,12 @@ class KritzelResizeHandler extends KritzelBaseHandler {
418
441
  constructor(core) {
419
442
  super(core);
420
443
  }
444
+ reset() {
445
+ this.initialMouseX = 0;
446
+ this.initialMouseY = 0;
447
+ this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
448
+ this.newSize = { x: 0, y: 0, width: 0, height: 0 };
449
+ }
421
450
  handlePointerDown(event) {
422
451
  if (event.pointerType === 'mouse') {
423
452
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -537,22 +566,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
537
566
  handlePointerUp(event) {
538
567
  if (event.pointerType === 'mouse') {
539
568
  if (this._core.store.state.isResizing) {
540
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
541
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
542
- return new UpdateObjectCommand(this._core, this, object, { ...object });
543
- });
544
- this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
569
+ this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
545
570
  this._core.store.setState('isResizing', false);
571
+ this.reset();
546
572
  }
547
573
  }
548
574
  if (event.pointerType === 'touch') {
549
575
  if (this._core.store.state.isResizing) {
550
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
551
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
552
- return new UpdateObjectCommand(this._core, this, object, { ...object });
553
- });
554
- this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
576
+ this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
555
577
  this._core.store.setState('isResizing', false);
578
+ this.reset();
556
579
  clearTimeout(this._core.store.state.longTouchTimeout);
557
580
  }
558
581
  }
@@ -563,10 +586,10 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
563
586
  rotation;
564
587
  initialRotation;
565
588
  selectionGroup;
566
- constructor(core, initiator, rotation, skipHistory = false) {
589
+ constructor(core, initiator, rotation, initialRotation, skipHistory = false) {
567
590
  super(core, initiator, skipHistory);
568
591
  this.rotation = rotation;
569
- this.initialRotation = this._core.store.state.selectionGroup.rotation;
592
+ this.initialRotation = initialRotation;
570
593
  this.selectionGroup = this._core.store.state.selectionGroup;
571
594
  }
572
595
  execute() {
@@ -574,13 +597,15 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
574
597
  this._core.store.state.selectionGroup.rotate(this.rotation);
575
598
  this._core.store.state.selectionGroup.objects.forEach(object => {
576
599
  this._core.store.state.objectsMap.update(object);
600
+ this._core.updateObjectInDatabase(object);
577
601
  });
578
602
  }
579
603
  undo() {
580
604
  this._core.store.setState('selectionGroup', this.selectionGroup);
581
- this._core.store.state.selectionGroup.rotate(this.rotation - this.initialRotation);
605
+ this._core.store.state.selectionGroup.rotate(this.initialRotation);
582
606
  this._core.store.state.selectionGroup.objects.forEach(object => {
583
607
  this._core.store.state.objectsMap.update(object);
608
+ this._core.updateObjectInDatabase(object);
584
609
  });
585
610
  }
586
611
  }
@@ -588,9 +613,16 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
588
613
  class KritzelRotationHandler extends KritzelBaseHandler {
589
614
  initialRotation = 0;
590
615
  rotation = 0;
616
+ unchangedObjects = [];
617
+ initialSelectionGroupRotation = 0;
591
618
  constructor(core) {
592
619
  super(core);
593
620
  }
621
+ reset() {
622
+ this.initialRotation = 0;
623
+ this.rotation = 0;
624
+ this.unchangedObjects = [];
625
+ }
594
626
  handlePointerDown(event) {
595
627
  if (event.pointerType === 'mouse') {
596
628
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -602,7 +634,9 @@ class KritzelRotationHandler extends KritzelBaseHandler {
602
634
  const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
603
635
  const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
604
636
  const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
637
+ this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;
605
638
  this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
639
+ this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
606
640
  }
607
641
  }
608
642
  }
@@ -622,6 +656,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
622
656
  const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
623
657
  const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
624
658
  this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
659
+ this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
625
660
  clearTimeout(this._core.store.state.longTouchTimeout);
626
661
  }
627
662
  }
@@ -664,32 +699,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
664
699
  handlePointerUp(event) {
665
700
  if (event.pointerType === 'mouse') {
666
701
  if (this._core.store.state.isRotating) {
667
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
668
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
669
- return new UpdateObjectCommand(this._core, this, object, {
670
- rotation: object.rotation,
671
- translateX: object.translateX,
672
- translateY: object.translateY,
673
- });
674
- });
675
- this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
702
+ this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
676
703
  this._core.store.setState('isRotating', false);
677
- this.initialRotation = 0;
678
- this.rotation = 0;
704
+ this.reset();
679
705
  }
680
706
  }
681
707
  if (event.pointerType === 'touch') {
682
708
  if (this._core.store.state.isRotating) {
683
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
684
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
685
- return new UpdateObjectCommand(this._core, this, object, {
686
- rotation: object.rotation,
687
- });
688
- });
689
- this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
709
+ this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
690
710
  this._core.store.setState('isRotating', false);
691
- this.initialRotation = 0;
692
- this.rotation = 0;
711
+ this.reset();
693
712
  clearTimeout(this._core.store.state.longTouchTimeout);
694
713
  }
695
714
  }
@@ -1188,7 +1207,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
1188
1207
  else {
1189
1208
  this.objects.splice(index, 1);
1190
1209
  }
1191
- this.unchangedObjects = ObjectHelper.clone(this.objects);
1210
+ this.unchangedObjects = this.objects.map(obj => obj.clone());
1192
1211
  this.refreshObjectDimensions();
1193
1212
  }
1194
1213
  deselectAllChildren() {
@@ -1239,7 +1258,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
1239
1258
  this._core.store.state.objectsMap.update(child);
1240
1259
  });
1241
1260
  this.refreshObjectDimensions();
1242
- this.unchangedObjects = ObjectHelper.clone(this.objects);
1261
+ this.unchangedObjects = this.objects.map(obj => obj.clone());
1243
1262
  }
1244
1263
  rotate(value) {
1245
1264
  this.rotation = value;
@@ -1269,7 +1288,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
1269
1288
  selectionGroup.addOrRemove(copiedObject);
1270
1289
  currentZIndex++;
1271
1290
  });
1272
- selectionGroup.unchangedObjects = ObjectHelper.clone(selectionGroup.objects);
1291
+ selectionGroup.unchangedObjects = selectionGroup.objects.map(obj => obj.clone());
1273
1292
  if (this.objects.length === 1) {
1274
1293
  selectionGroup.rotation = this.objects[0].rotation;
1275
1294
  }
@@ -1667,9 +1686,12 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
1667
1686
  selectionGroup.addOrRemove(selectedObject);
1668
1687
  selectionGroup.isSelected = true;
1669
1688
  selectionGroup.rotation = selectedObject.rotation;
1670
- this._core.store.setState('selectionGroup', selectionGroup);
1671
1689
  this._core.store.setState('isSelecting', false);
1672
- this._core.history.executeCommand(new AddSelectionGroupCommand(this._core, this, this._core.store.state.selectionGroup));
1690
+ const batch = new BatchCommand(this._core, this, [
1691
+ new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),
1692
+ new AddSelectionGroupCommand(this._core, this, selectionGroup),
1693
+ ]);
1694
+ this._core.history.executeCommand(batch);
1673
1695
  }
1674
1696
  this._core.store.setState('contextMenuItems', this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems);
1675
1697
  let x = event.clientX - this._core.store.offsetX;
@@ -2359,18 +2381,14 @@ class KritzelCore {
2359
2381
  throw new Error('Database not initialized');
2360
2382
  }
2361
2383
  const reviver = new KritzelReviver(this);
2362
- return this._database
2363
- .get('workspaces', id)
2364
- .then(rawWorkspace => rawWorkspace ? reviver.revive(rawWorkspace) : null);
2384
+ return this._database.get('workspaces', id).then(rawWorkspace => (rawWorkspace ? reviver.revive(rawWorkspace) : null));
2365
2385
  }
2366
2386
  async getWorkspaces() {
2367
2387
  if (!this._database) {
2368
2388
  throw new Error('Database not initialized');
2369
2389
  }
2370
2390
  const reviver = new KritzelReviver(this);
2371
- return this._database
2372
- .getAll('workspaces')
2373
- .then(rawWorkspaces => rawWorkspaces.map(ws => reviver.revive(ws)));
2391
+ return this._database.getAll('workspaces').then(rawWorkspaces => rawWorkspaces.map(ws => reviver.revive(ws)));
2374
2392
  }
2375
2393
  async createWorkspace(workspace) {
2376
2394
  if (!this._database) {
@@ -2444,8 +2462,8 @@ class KritzelCore {
2444
2462
  const copiedObjects = this._store.state.copiedObjects;
2445
2463
  copiedObjects.isSelected = true;
2446
2464
  this._store.setState('copiedObjects', copiedObjects);
2447
- const adjustedX = x !== undefined ? x : this._store.state.copiedObjects.translateX + 25;
2448
- const adjustedY = y !== undefined ? y : this._store.state.copiedObjects.translateY + 25;
2465
+ const adjustedX = x !== undefined ? x : this._store.state.copiedObjects.translateX + 25 / this._store.state.scale;
2466
+ const adjustedY = y !== undefined ? y : this._store.state.copiedObjects.translateY + 25 / this._store.state.scale;
2449
2467
  this._store.state.copiedObjects.updatePosition(adjustedX, adjustedY);
2450
2468
  const commands = [];
2451
2469
  if (this._store.state.selectionGroup !== null) {
@@ -2654,7 +2672,9 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2654
2672
  if (this.core.store.isDisabled) {
2655
2673
  return;
2656
2674
  }
2657
- KritzelEventHelper.onLongPress(ev, (event) => this.longpress.emit(event));
2675
+ if (KritzelDevicesHelper.isTouchDevice()) {
2676
+ KritzelEventHelper.onLongPress(ev, (event) => this.longpress.emit(event));
2677
+ }
2658
2678
  this.host.setPointerCapture(ev.pointerId);
2659
2679
  this.core.store.state.pointers.set(ev.pointerId, ev);
2660
2680
  this.viewport.handlePointerDown(ev);
@@ -2898,7 +2918,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2898
2918
  const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
2899
2919
  const baseHandleSize = parseFloat(baseHandleSizePx);
2900
2920
  const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
2901
- return (h(Host, { key: '05b345f98a4548591946d1295da4d4b288767da6' }, h("div", { key: 'c8399a8968a39448120f3123b39c755b0f9b5e49', class: "debug-panel", style: { display: this.core.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '2cedd93f88f1a1e6ddc99e648375549ca5254f04' }, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", { key: '30ed15a98512b0efd91123773963d6266fa8426a' }, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", { key: 'a0eb11088673a9e0e2e22880ae8a7a89c6705609' }, "TranslateX: ", this.core.store.state?.translateX), h("div", { key: '97c7ccfc77342d4122f85136ab4c81709046a4e4' }, "TranslateY: ", this.core.store.state?.translateY), h("div", { key: 'ff832aa8a779a4adb2fca5b7ecd8d9b992cf7b99' }, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", { key: '6867ad7ee7f4fbe8725ac6edbe1bd999942fd729' }, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", { key: 'f54768467cace934702bd3fd6f26970515f669f0' }, "Scale: ", this.core.store.state?.scale), h("div", { key: '4aaa2cec8688e42249a6f0f7e2d67a13c57fa155' }, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", { key: '0bec60557f2a1271c69226b477fde02f4c2857a1' }, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", { key: 'bd342af473102a1c2095a3a2810de25630c8a717' }, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", { key: '62477d9f931903bff3fa6fa85f1ecd3b2944884f' }, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", { key: '80fba2f64cec36d9c7b2d5f2081ef21190c61768' }, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", { key: 'da75419ac806f146a6ac69607b64095eb1f37de4' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '11b3bf816afa3d64fea468de92a351d9e96dee9e' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: 'e12cf1412d0e48a1245ae923c595e737deb4dffb' }, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: 'fa79c455e0ae7d68259003ce63a58eda4c250eba' }, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'bc7b25568bac9ef9cd6f1341a7415e4b93d8e8e9' }, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", { key: 'a62eef5e0e277b629a11bb13809a4ab211d9428c' }, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", { key: '285815884e83a3d5d8ec3726034ff4853225f216' }, "PointerX: ", this.core.store.state?.pointerX), h("div", { key: 'f267eb928ccb57736229d3a7fbc5bfdfd0d51819' }, "PointerY: ", this.core.store.state?.pointerY), h("div", { key: '55977bf82d326a128a5da8d303875603c2850aac' }, "SelectedObjects: ", this.core.store.state.selectionGroup?.objects.length || 0)), h("div", { key: '8c91eaf482ce6cbd7400ba5342ec6c866fc0a049', id: "origin", class: "origin", style: {
2921
+ return (h(Host, { key: 'da47553aad7abf8b5daab177c6933a9177b91089' }, h("div", { key: '4e64b43bfb85a61154d36ca8ecd3518d61445d50', class: "debug-panel", style: { display: this.core.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '21742da9258a2b929b81c0ca6c8f37f41b228ad4' }, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", { key: 'de31fcf57b0faf8fad2bb39336eeea35dbec35ca' }, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", { key: 'a2cb298a867f92349b5e1fb556ee5f9c6110f1c7' }, "TranslateX: ", this.core.store.state?.translateX), h("div", { key: '28697bfcecf9f8b4b1972a90cd02855767433047' }, "TranslateY: ", this.core.store.state?.translateY), h("div", { key: '7fb25f6e9c9b8dea11832dbd311d2cc0b981cbeb' }, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", { key: '92aeade312b3d28e4c9b0e1c7ca55f6932fd23d9' }, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", { key: 'a4fd8090acaf094e44fdc2e72fcc388695b412c4' }, "Scale: ", this.core.store.state?.scale), h("div", { key: '6ff28100b64bafdffcb8fe9d49cd041a6a374817' }, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", { key: '12a61ad3d070563eb721d0d4068143962914b2bc' }, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", { key: '437309daa2af1a64c9b9d3548fe12e075dd4a8bd' }, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", { key: 'e6841095c220ebf081604c548729f085ec9d17bd' }, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", { key: 'b07316a528782f7560c2e42f7bd9edd473cc256c' }, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", { key: '7160a5aa21c4cdbf2b523f620c819ad541a2e466' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '9ad29a686bc76b47d4c5040121b468428ade437a' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '68f240aa7d7188996647afd0df73d63a253e18a1' }, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '260010c089bdf0e8fd8c2406c39394ef79a85262' }, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '6b07975c781801b0a7d7727d0666a6765aa9e889' }, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '83c949c9ed26c3d445421ba1f965a742f5fc149f' }, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", { key: '1687122785d3370da5d91a975dd56f11aebc81c1' }, "PointerX: ", this.core.store.state?.pointerX), h("div", { key: 'a28e152a0510c9e3eef5624de1b5512baf45b37c' }, "PointerY: ", this.core.store.state?.pointerY), h("div", { key: '09e5a0157002fe95a46415d32a3eb17be8d959a9' }, "SelectedObjects: ", this.core.store.state.selectionGroup?.objects.length || 0)), h("div", { key: '5228fbae773f30d91b129c257ef08adca10a6a70', id: "origin", class: "origin", style: {
2902
2922
  transform: `matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`,
2903
2923
  } }, this.core.store.state.objectsMap.allObjects()?.map(object => {
2904
2924
  return (h("div", { key: object.id, style: {
@@ -3017,7 +3037,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
3017
3037
  transform: this.core.store.state.currentPath?.transformationMatrix,
3018
3038
  transformOrigin: 'top left',
3019
3039
  overflow: 'visible',
3020
- }, viewBox: this.core.store.state.currentPath?.viewBox }, h("path", { key: '1cdae549bc53dc30eb397f27702054ac6c5122f7', d: this.core.store.state.currentPath?.d, fill: this.core.store.state.currentPath?.fill, stroke: this.core.store.state.currentPath?.stroke }))), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '2428e653f61d7ac5a71da1dbf94155b02e870406', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.state.selectionGroup?.objects || [], style: {
3040
+ }, viewBox: this.core.store.state.currentPath?.viewBox }, h("path", { key: '6dedb398968d275166e042660c4718635b57da84', d: this.core.store.state.currentPath?.d, fill: this.core.store.state.currentPath?.fill, stroke: this.core.store.state.currentPath?.stroke }))), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '09ae0d7842918bcb4ae9fd16d416badc19942264', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.state.selectionGroup?.objects || [], style: {
3021
3041
  position: 'fixed',
3022
3042
  left: `${this.core.store.state.contextMenuX}px`,
3023
3043
  top: `${this.core.store.state.contextMenuY}px`,
@@ -3028,7 +3048,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
3028
3048
  y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
3029
3049
  }, this.core.store.state.selectionGroup?.objects);
3030
3050
  this.hideContextMenu();
3031
- }, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '94bdb8b137c50bb7499a37e4784ae36989258ee2', core: this.core })));
3051
+ }, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: 'e0863ccf8c52ebef822827d8eeac62d3619134ca', core: this.core })));
3032
3052
  }
3033
3053
  static get watchers() { return {
3034
3054
  "workspace": ["onWorkspaceChange"],
@@ -3108,6 +3128,6 @@ function defineCustomElement() {
3108
3128
  }
3109
3129
 
3110
3130
  export { ABSOLUTE_SCALE_MAX as A, KritzelImage as K, KritzelEraserTool as a, KritzelImageTool as b, KritzelSelectionTool as c, KritzelEngine as d, defineCustomElement as e, ABSOLUTE_SCALE_MIN as f };
3111
- //# sourceMappingURL=p-Davd1R_4.js.map
3131
+ //# sourceMappingURL=p-CwH-bwjb.js.map
3112
3132
 
3113
- //# sourceMappingURL=p-Davd1R_4.js.map
3133
+ //# sourceMappingURL=p-CwH-bwjb.js.map