kritzel-stencil 0.0.132 → 0.0.134
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.
- package/dist/cjs/{index-ouFX0OVi.js → index-DILpAbYp.js} +97 -75
- package/dist/cjs/index-DILpAbYp.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +70 -82
- package/dist/collection/classes/commands/add-selection-group.command.js +6 -3
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +13 -0
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +8 -0
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +5 -3
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +2 -0
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +7 -9
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/history.class.js +1 -0
- package/dist/collection/classes/core/history.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +0 -6
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +7 -2
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +42 -58
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +24 -19
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +10 -12
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +14 -22
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +11 -3
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +3 -4
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +13 -4
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -2
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +0 -14
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/interfaces/clonable.interface.js +2 -0
- package/dist/collection/interfaces/clonable.interface.js.map +1 -0
- package/dist/collection/interfaces/shortcut.interface.js +2 -0
- package/dist/collection/interfaces/shortcut.interface.js.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +8 -8
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/p-B0kd2rUI.js +16 -0
- package/dist/components/p-B0kd2rUI.js.map +1 -0
- package/dist/components/{p-BiCgeOiJ.js → p-B3LGnqFz.js} +3 -3
- package/dist/components/{p-BiCgeOiJ.js.map → p-B3LGnqFz.js.map} +1 -1
- package/dist/components/{p-C1-nvBx9.js → p-BKvOO7NT.js} +6 -6
- package/dist/components/{p-C1-nvBx9.js.map → p-BKvOO7NT.js.map} +1 -1
- package/dist/components/{p-CvmWmUK9.js → p-CM8KdFZI.js} +4 -4
- package/dist/components/{p-CvmWmUK9.js.map → p-CM8KdFZI.js.map} +1 -1
- package/dist/components/{p-B3VQubt_.js → p-CNTK3JOp.js} +16 -6
- package/dist/components/p-CNTK3JOp.js.map +1 -0
- package/dist/components/{p-Davd1R_4.js → p-CZzYv_iN.js} +155 -140
- package/dist/components/p-CZzYv_iN.js.map +1 -0
- package/dist/components/{p-BGdsAz54.js → p-DOPuq6gn.js} +3 -4
- package/dist/components/p-DOPuq6gn.js.map +1 -0
- package/dist/components/{p-D_907-Wd.js → p-Dw4n-4zp.js} +3 -3
- package/dist/components/{p-D_907-Wd.js.map → p-Dw4n-4zp.js.map} +1 -1
- package/dist/components/{p-CTvJDYFQ.js → p-NP1Htol7.js} +3 -3
- package/dist/components/{p-CTvJDYFQ.js.map → p-NP1Htol7.js.map} +1 -1
- package/dist/esm/{index-C_uHp-ur.js → index-BrCE-Ctm.js} +97 -75
- package/dist/esm/index-BrCE-Ctm.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +70 -82
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-092c9a05.entry.js +2 -0
- package/dist/stencil/p-092c9a05.entry.js.map +1 -0
- package/dist/stencil/p-BrCE-Ctm.js +2 -0
- package/dist/stencil/p-BrCE-Ctm.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/add-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
- package/dist/types/classes/handlers/key.handler.d.ts +2 -0
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
- package/dist/types/classes/handlers/rotation.handler.d.ts +4 -0
- package/dist/types/classes/objects/base-object.class.d.ts +3 -1
- package/dist/types/helpers/object.helper.d.ts +0 -2
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/dist/types/interfaces/shortcut.interface.d.ts +8 -0
- package/package.json +64 -64
- package/dist/cjs/index-ouFX0OVi.js.map +0 -1
- package/dist/components/p-B3VQubt_.js.map +0 -1
- package/dist/components/p-BGdsAz54.js.map +0 -1
- package/dist/components/p-Davd1R_4.js.map +0 -1
- package/dist/components/p-EXPChOF6.js +0 -30
- package/dist/components/p-EXPChOF6.js.map +0 -1
- package/dist/esm/index-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-C_uHp-ur.js +0 -2
- package/dist/stencil/p-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-a6f8283e.entry.js +0 -2
- package/dist/stencil/p-a6f8283e.entry.js.map +0 -1
|
@@ -38,6 +38,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
38
38
|
this.object[key] = this.updatedProperties[key];
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
41
42
|
this._core.updateObjectInDatabase(this.object);
|
|
42
43
|
}
|
|
43
44
|
undo() {
|
|
@@ -46,6 +47,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
46
47
|
this.object[key] = this.previousProperties[key];
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
49
51
|
this._core.updateObjectInDatabase(this.object);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -343,20 +345,6 @@ class ObjectHelper {
|
|
|
343
345
|
static generateUUID() {
|
|
344
346
|
return Math.random().toString(36).substr(2, 9);
|
|
345
347
|
}
|
|
346
|
-
static clone(objOrObjs) {
|
|
347
|
-
const cloneObject = (obj) => {
|
|
348
|
-
const { _core, _elementRef, totalWidth, totalHeight, element, ...remainingProps } = obj;
|
|
349
|
-
const clonedProps = structuredClone(remainingProps);
|
|
350
|
-
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
351
|
-
clonedProps.element = element.cloneNode(true);
|
|
352
|
-
}
|
|
353
|
-
return clonedProps;
|
|
354
|
-
};
|
|
355
|
-
if (Array.isArray(objOrObjs)) {
|
|
356
|
-
return objOrObjs.map(cloneObject);
|
|
357
|
-
}
|
|
358
|
-
return cloneObject(objOrObjs);
|
|
359
|
-
}
|
|
360
348
|
static isEmpty(obj) {
|
|
361
349
|
if (obj === null || obj === undefined) {
|
|
362
350
|
return true;
|
|
@@ -597,6 +585,11 @@ class KritzelBaseObject {
|
|
|
597
585
|
rotate(value) {
|
|
598
586
|
this.rotation = value;
|
|
599
587
|
}
|
|
588
|
+
clone() {
|
|
589
|
+
const clone = new KritzelBaseObject();
|
|
590
|
+
Object.assign(clone, this);
|
|
591
|
+
return clone;
|
|
592
|
+
}
|
|
600
593
|
copy() {
|
|
601
594
|
const copiedObject = Object.create(Object.getPrototypeOf(this));
|
|
602
595
|
Object.assign(copiedObject, this);
|
|
@@ -608,9 +601,12 @@ class KritzelBaseObject {
|
|
|
608
601
|
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
609
602
|
}
|
|
610
603
|
serialize() {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
604
|
+
const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this;
|
|
605
|
+
const clonedProps = structuredClone(remainingProps);
|
|
606
|
+
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
607
|
+
clonedProps.element = element.cloneNode(true);
|
|
608
|
+
}
|
|
609
|
+
return clonedProps;
|
|
614
610
|
}
|
|
615
611
|
deserialize(object) {
|
|
616
612
|
Object.assign(this, object);
|
|
@@ -1436,14 +1432,27 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1436
1432
|
execute() {
|
|
1437
1433
|
if (this.skipExecution) {
|
|
1438
1434
|
this.skipExecution = false;
|
|
1435
|
+
// Skip execution, but still update objects
|
|
1436
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1437
|
+
this._core.store.state.objectsMap.update(object);
|
|
1438
|
+
this._core.updateObjectInDatabase(object);
|
|
1439
|
+
});
|
|
1439
1440
|
return;
|
|
1440
1441
|
}
|
|
1441
1442
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1442
1443
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1444
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1445
|
+
this._core.store.state.objectsMap.update(object);
|
|
1446
|
+
this._core.updateObjectInDatabase(object);
|
|
1447
|
+
});
|
|
1443
1448
|
}
|
|
1444
1449
|
undo() {
|
|
1445
1450
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1446
1451
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1452
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1453
|
+
this._core.store.state.objectsMap.update(object);
|
|
1454
|
+
this._core.updateObjectInDatabase(object);
|
|
1455
|
+
});
|
|
1447
1456
|
}
|
|
1448
1457
|
}
|
|
1449
1458
|
|
|
@@ -1461,9 +1470,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1461
1470
|
startY;
|
|
1462
1471
|
endX;
|
|
1463
1472
|
endY;
|
|
1473
|
+
hasMoved = false;
|
|
1464
1474
|
constructor(core) {
|
|
1465
1475
|
super(core);
|
|
1466
1476
|
}
|
|
1477
|
+
reset() {
|
|
1478
|
+
this.dragStartX = 0;
|
|
1479
|
+
this.dragStartY = 0;
|
|
1480
|
+
this.startX = 0;
|
|
1481
|
+
this.startY = 0;
|
|
1482
|
+
this.endX = 0;
|
|
1483
|
+
this.endY = 0;
|
|
1484
|
+
this.hasMoved = false;
|
|
1485
|
+
}
|
|
1467
1486
|
handlePointerDown(event) {
|
|
1468
1487
|
if (event.pointerType === 'mouse') {
|
|
1469
1488
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1502,16 +1521,21 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1502
1521
|
this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
|
|
1503
1522
|
this.dragStartX = clientX;
|
|
1504
1523
|
this.dragStartY = clientY;
|
|
1524
|
+
this.hasMoved = true;
|
|
1505
1525
|
}
|
|
1506
1526
|
}
|
|
1507
1527
|
if (event.pointerType === 'touch') {
|
|
1508
1528
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1509
|
-
if (this._core.store.state.pointers.size === 1 &&
|
|
1529
|
+
if (this._core.store.state.pointers.size === 1 &&
|
|
1530
|
+
this._core.store.state.selectionGroup &&
|
|
1531
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
1532
|
+
!this._core.store.state.isRotationHandleSelected) {
|
|
1510
1533
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1511
1534
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1512
1535
|
this._core.store.setState('isDragging', true);
|
|
1513
1536
|
this.endX = x;
|
|
1514
1537
|
this.endY = y;
|
|
1538
|
+
this.hasMoved = true;
|
|
1515
1539
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
1516
1540
|
const moveDeltaY = Math.abs(y - this.startY);
|
|
1517
1541
|
const moveThreshold = 5;
|
|
@@ -1528,27 +1552,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1528
1552
|
if (event.pointerType === 'mouse') {
|
|
1529
1553
|
if (this._core.store.state.isDragging) {
|
|
1530
1554
|
this._core.store.setState('isDragging', false);
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
translateY: object.translateY
|
|
1536
|
-
});
|
|
1537
|
-
});
|
|
1538
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1555
|
+
if (this.hasMoved) {
|
|
1556
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1557
|
+
}
|
|
1558
|
+
this.reset();
|
|
1539
1559
|
}
|
|
1540
1560
|
}
|
|
1541
1561
|
if (event.pointerType === 'touch') {
|
|
1542
1562
|
if (this._core.store.state.isDragging) {
|
|
1543
1563
|
this._core.store.setState('isDragging', false);
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
translateY: object.translateY
|
|
1549
|
-
});
|
|
1550
|
-
});
|
|
1551
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1564
|
+
if (this.hasMoved) {
|
|
1565
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1566
|
+
}
|
|
1567
|
+
this.reset();
|
|
1552
1568
|
}
|
|
1553
1569
|
}
|
|
1554
1570
|
}
|
|
@@ -1575,10 +1591,18 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1575
1591
|
execute() {
|
|
1576
1592
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1577
1593
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1594
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1595
|
+
this._core.store.state.objectsMap.update(object);
|
|
1596
|
+
this._core.updateObjectInDatabase(object);
|
|
1597
|
+
});
|
|
1578
1598
|
}
|
|
1579
1599
|
undo() {
|
|
1580
1600
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1581
1601
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1602
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1603
|
+
this._core.store.state.objectsMap.update(object);
|
|
1604
|
+
this._core.updateObjectInDatabase(object);
|
|
1605
|
+
});
|
|
1582
1606
|
}
|
|
1583
1607
|
}
|
|
1584
1608
|
|
|
@@ -1590,6 +1614,12 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1590
1614
|
constructor(core) {
|
|
1591
1615
|
super(core);
|
|
1592
1616
|
}
|
|
1617
|
+
reset() {
|
|
1618
|
+
this.initialMouseX = 0;
|
|
1619
|
+
this.initialMouseY = 0;
|
|
1620
|
+
this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1621
|
+
this.newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1622
|
+
}
|
|
1593
1623
|
handlePointerDown(event) {
|
|
1594
1624
|
if (event.pointerType === 'mouse') {
|
|
1595
1625
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1709,22 +1739,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1709
1739
|
handlePointerUp(event) {
|
|
1710
1740
|
if (event.pointerType === 'mouse') {
|
|
1711
1741
|
if (this._core.store.state.isResizing) {
|
|
1712
|
-
|
|
1713
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1714
|
-
return new UpdateObjectCommand(this._core, this, object, { ...object });
|
|
1715
|
-
});
|
|
1716
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1742
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1717
1743
|
this._core.store.setState('isResizing', false);
|
|
1744
|
+
this.reset();
|
|
1718
1745
|
}
|
|
1719
1746
|
}
|
|
1720
1747
|
if (event.pointerType === 'touch') {
|
|
1721
1748
|
if (this._core.store.state.isResizing) {
|
|
1722
|
-
|
|
1723
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1724
|
-
return new UpdateObjectCommand(this._core, this, object, { ...object });
|
|
1725
|
-
});
|
|
1726
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1749
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1727
1750
|
this._core.store.setState('isResizing', false);
|
|
1751
|
+
this.reset();
|
|
1728
1752
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1729
1753
|
}
|
|
1730
1754
|
}
|
|
@@ -1735,10 +1759,10 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1735
1759
|
rotation;
|
|
1736
1760
|
initialRotation;
|
|
1737
1761
|
selectionGroup;
|
|
1738
|
-
constructor(core, initiator, rotation, skipHistory = false) {
|
|
1762
|
+
constructor(core, initiator, rotation, initialRotation, skipHistory = false) {
|
|
1739
1763
|
super(core, initiator, skipHistory);
|
|
1740
1764
|
this.rotation = rotation;
|
|
1741
|
-
this.initialRotation =
|
|
1765
|
+
this.initialRotation = initialRotation;
|
|
1742
1766
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1743
1767
|
}
|
|
1744
1768
|
execute() {
|
|
@@ -1746,13 +1770,15 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1746
1770
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1747
1771
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1748
1772
|
this._core.store.state.objectsMap.update(object);
|
|
1773
|
+
this._core.updateObjectInDatabase(object);
|
|
1749
1774
|
});
|
|
1750
1775
|
}
|
|
1751
1776
|
undo() {
|
|
1752
1777
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1753
|
-
this._core.store.state.selectionGroup.rotate(this.
|
|
1778
|
+
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1754
1779
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1755
1780
|
this._core.store.state.objectsMap.update(object);
|
|
1781
|
+
this._core.updateObjectInDatabase(object);
|
|
1756
1782
|
});
|
|
1757
1783
|
}
|
|
1758
1784
|
}
|
|
@@ -1760,9 +1786,16 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1760
1786
|
class KritzelRotationHandler extends KritzelBaseHandler {
|
|
1761
1787
|
initialRotation = 0;
|
|
1762
1788
|
rotation = 0;
|
|
1789
|
+
unchangedObjects = [];
|
|
1790
|
+
initialSelectionGroupRotation = 0;
|
|
1763
1791
|
constructor(core) {
|
|
1764
1792
|
super(core);
|
|
1765
1793
|
}
|
|
1794
|
+
reset() {
|
|
1795
|
+
this.initialRotation = 0;
|
|
1796
|
+
this.rotation = 0;
|
|
1797
|
+
this.unchangedObjects = [];
|
|
1798
|
+
}
|
|
1766
1799
|
handlePointerDown(event) {
|
|
1767
1800
|
if (event.pointerType === 'mouse') {
|
|
1768
1801
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1774,7 +1807,9 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1774
1807
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1775
1808
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1776
1809
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1810
|
+
this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;
|
|
1777
1811
|
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1812
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1778
1813
|
}
|
|
1779
1814
|
}
|
|
1780
1815
|
}
|
|
@@ -1794,6 +1829,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1794
1829
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1795
1830
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1796
1831
|
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1832
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1797
1833
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1798
1834
|
}
|
|
1799
1835
|
}
|
|
@@ -1836,32 +1872,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1836
1872
|
handlePointerUp(event) {
|
|
1837
1873
|
if (event.pointerType === 'mouse') {
|
|
1838
1874
|
if (this._core.store.state.isRotating) {
|
|
1839
|
-
|
|
1840
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1841
|
-
return new UpdateObjectCommand(this._core, this, object, {
|
|
1842
|
-
rotation: object.rotation,
|
|
1843
|
-
translateX: object.translateX,
|
|
1844
|
-
translateY: object.translateY,
|
|
1845
|
-
});
|
|
1846
|
-
});
|
|
1847
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1875
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1848
1876
|
this._core.store.setState('isRotating', false);
|
|
1849
|
-
this.
|
|
1850
|
-
this.rotation = 0;
|
|
1877
|
+
this.reset();
|
|
1851
1878
|
}
|
|
1852
1879
|
}
|
|
1853
1880
|
if (event.pointerType === 'touch') {
|
|
1854
1881
|
if (this._core.store.state.isRotating) {
|
|
1855
|
-
|
|
1856
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1857
|
-
return new UpdateObjectCommand(this._core, this, object, {
|
|
1858
|
-
rotation: object.rotation,
|
|
1859
|
-
});
|
|
1860
|
-
});
|
|
1861
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1882
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1862
1883
|
this._core.store.setState('isRotating', false);
|
|
1863
|
-
this.
|
|
1864
|
-
this.rotation = 0;
|
|
1884
|
+
this.reset();
|
|
1865
1885
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1866
1886
|
}
|
|
1867
1887
|
}
|
|
@@ -1889,19 +1909,21 @@ class KrtizelSelectionBox extends KritzelBaseObject {
|
|
|
1889
1909
|
|
|
1890
1910
|
class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
1891
1911
|
selectionGroup;
|
|
1892
|
-
|
|
1912
|
+
previousSelectionGroup;
|
|
1913
|
+
constructor(core, initiator, selectionGroup, previousSelectionGroup, skipHistory = false) {
|
|
1893
1914
|
super(core, initiator, skipHistory);
|
|
1894
1915
|
this.selectionGroup = selectionGroup;
|
|
1916
|
+
this.previousSelectionGroup = previousSelectionGroup || null;
|
|
1895
1917
|
}
|
|
1896
1918
|
execute() {
|
|
1897
|
-
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
|
|
1919
|
+
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox || object instanceof KritzelSelectionGroup);
|
|
1898
1920
|
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
1899
1921
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1900
1922
|
this._core.store.setState('selectionBox', null);
|
|
1901
1923
|
}
|
|
1902
1924
|
undo() {
|
|
1903
1925
|
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
1904
|
-
this._core.store.setState('selectionGroup',
|
|
1926
|
+
this._core.store.setState('selectionGroup', this.previousSelectionGroup);
|
|
1905
1927
|
this._core.store.setState('selectionBox', null);
|
|
1906
1928
|
}
|
|
1907
1929
|
}
|
|
@@ -2494,7 +2516,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2494
2516
|
else {
|
|
2495
2517
|
this.objects.splice(index, 1);
|
|
2496
2518
|
}
|
|
2497
|
-
this.unchangedObjects =
|
|
2519
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2498
2520
|
this.refreshObjectDimensions();
|
|
2499
2521
|
}
|
|
2500
2522
|
deselectAllChildren() {
|
|
@@ -2545,7 +2567,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2545
2567
|
this._core.store.state.objectsMap.update(child);
|
|
2546
2568
|
});
|
|
2547
2569
|
this.refreshObjectDimensions();
|
|
2548
|
-
this.unchangedObjects =
|
|
2570
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2549
2571
|
}
|
|
2550
2572
|
rotate(value) {
|
|
2551
2573
|
this.rotation = value;
|
|
@@ -2575,7 +2597,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2575
2597
|
selectionGroup.addOrRemove(copiedObject);
|
|
2576
2598
|
currentZIndex++;
|
|
2577
2599
|
});
|
|
2578
|
-
selectionGroup.unchangedObjects =
|
|
2600
|
+
selectionGroup.unchangedObjects = selectionGroup.objects.map(obj => obj.clone());
|
|
2579
2601
|
if (this.objects.length === 1) {
|
|
2580
2602
|
selectionGroup.rotation = this.objects[0].rotation;
|
|
2581
2603
|
}
|
|
@@ -2740,6 +2762,6 @@ exports.ObjectHelper = ObjectHelper;
|
|
|
2740
2762
|
exports.RemoveObjectCommand = RemoveObjectCommand;
|
|
2741
2763
|
exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
|
|
2742
2764
|
exports.UpdateObjectCommand = UpdateObjectCommand;
|
|
2743
|
-
//# sourceMappingURL=index-
|
|
2765
|
+
//# sourceMappingURL=index-DILpAbYp.js.map
|
|
2744
2766
|
|
|
2745
|
-
//# sourceMappingURL=index-
|
|
2767
|
+
//# sourceMappingURL=index-DILpAbYp.js.map
|