kritzel-stencil 0.0.141 → 0.0.142
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-BKstgWru.js → index-SaGfCHX3.js} +276 -805
- package/dist/cjs/index-SaGfCHX3.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +114 -77
- package/dist/collection/classes/commands/add-object.command.js +1 -0
- package/dist/collection/classes/commands/add-object.command.js.map +1 -1
- package/dist/collection/classes/commands/base.command.js +2 -0
- package/dist/collection/classes/commands/base.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +1 -3
- package/dist/collection/classes/commands/remove-object.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/command-manager.class.js +51 -0
- package/dist/collection/classes/core/command-manager.class.js.map +1 -0
- package/dist/collection/classes/core/core.class.js +23 -14
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/history.class.js +2 -40
- package/dist/collection/classes/core/history.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +16 -5
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +11 -6
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +29 -5
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +2 -2
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +4 -4
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +15 -14
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +7 -1
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +109 -49
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +2 -2
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +2 -2
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +1 -1
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +2 -2
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +17 -11
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +21 -15
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +3 -3
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-ChLi4Ufe.js → p-C8calcQF.js} +3 -3
- package/dist/components/{p-ChLi4Ufe.js.map → p-C8calcQF.js.map} +1 -1
- package/dist/components/{p-BuDVaqTF.js → p-CZk591FE.js} +165 -728
- package/dist/components/p-CZk591FE.js.map +1 -0
- package/dist/components/{p-C4nj29RW.js → p-CziwfEQh.js} +227 -156
- package/dist/components/p-CziwfEQh.js.map +1 -0
- package/dist/esm/{index-D0Q2MKPn.js → index-SIM_s7ed.js} +276 -805
- package/dist/esm/index-SIM_s7ed.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +114 -77
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-SIM_s7ed.js +2 -0
- package/dist/stencil/p-SIM_s7ed.js.map +1 -0
- package/dist/stencil/p-b697b2c1.entry.js +2 -0
- package/dist/stencil/p-b697b2c1.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/add-object.command.d.ts +2 -2
- package/dist/types/classes/commands/base.command.d.ts +2 -1
- package/dist/types/classes/commands/remove-object.command.d.ts +2 -2
- package/dist/types/classes/commands/update-object.command.d.ts +2 -2
- package/dist/types/classes/core/command-manager.class.d.ts +16 -0
- package/dist/types/classes/core/core.class.d.ts +4 -0
- package/dist/types/classes/core/history.class.d.ts +0 -8
- package/dist/types/classes/core/viewport.class.d.ts +2 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
- package/dist/types/classes/objects/base-object.class.d.ts +6 -4
- package/dist/types/classes/objects/text.class.d.ts +13 -2
- package/dist/types/interfaces/object.interface.d.ts +1 -3
- package/package.json +1 -1
- package/dist/cjs/index-BKstgWru.js.map +0 -1
- package/dist/components/p-BuDVaqTF.js.map +0 -1
- package/dist/components/p-C4nj29RW.js.map +0 -1
- package/dist/esm/index-D0Q2MKPn.js.map +0 -1
- package/dist/stencil/p-73784709.entry.js +0 -2
- package/dist/stencil/p-73784709.entry.js.map +0 -1
- package/dist/stencil/p-D0Q2MKPn.js +0 -2
- package/dist/stencil/p-D0Q2MKPn.js.map +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-DcTwXs_q.js');
|
|
4
|
-
var index$1 = require('./index-
|
|
4
|
+
var index$1 = require('./index-SaGfCHX3.js');
|
|
5
5
|
|
|
6
6
|
const kritzelColorCss = ":host{display:flex}.checkerboard-bg{background:repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;position:relative;overflow:hidden}.color-circle{width:24px;height:24px;border-radius:50%;box-sizing:border-box;display:block}.color-circle.white{border:1px solid var(--kritzel-color-palette-circle-border-color, #dddcdc)}";
|
|
7
7
|
|
|
@@ -861,6 +861,7 @@ KritzelEditor.style = kritzelEditorCss;
|
|
|
861
861
|
|
|
862
862
|
class KritzelViewport {
|
|
863
863
|
_core;
|
|
864
|
+
_debounceUpdate;
|
|
864
865
|
initialTouchDistance = 0;
|
|
865
866
|
startX = 0;
|
|
866
867
|
startY = 0;
|
|
@@ -873,6 +874,16 @@ class KritzelViewport {
|
|
|
873
874
|
this._core.store.state.startY = 0;
|
|
874
875
|
this._core.store.state.translateX = 0;
|
|
875
876
|
this._core.store.state.translateY = 0;
|
|
877
|
+
this._debounceUpdate = this.debounce(() => {
|
|
878
|
+
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
879
|
+
}, 0);
|
|
880
|
+
}
|
|
881
|
+
debounce(func, delay) {
|
|
882
|
+
let timeoutId;
|
|
883
|
+
return () => {
|
|
884
|
+
clearTimeout(timeoutId);
|
|
885
|
+
timeoutId = setTimeout(func, delay);
|
|
886
|
+
};
|
|
876
887
|
}
|
|
877
888
|
handleResize() {
|
|
878
889
|
this._core.store.state.viewportWidth = this._core.store.state.host.clientWidth;
|
|
@@ -923,7 +934,7 @@ class KritzelViewport {
|
|
|
923
934
|
this._core.store.state.hasViewportChanged = true;
|
|
924
935
|
this._core.store.state.skipContextMenu = true;
|
|
925
936
|
this._core.rerender();
|
|
926
|
-
this.
|
|
937
|
+
this._debounceUpdate();
|
|
927
938
|
}
|
|
928
939
|
}
|
|
929
940
|
if (event.pointerType === 'touch') {
|
|
@@ -959,7 +970,7 @@ class KritzelViewport {
|
|
|
959
970
|
this.startY = midpointY;
|
|
960
971
|
this._core.store.state.hasViewportChanged = true;
|
|
961
972
|
this._core.rerender();
|
|
962
|
-
this.
|
|
973
|
+
this._debounceUpdate();
|
|
963
974
|
}
|
|
964
975
|
}
|
|
965
976
|
}
|
|
@@ -993,7 +1004,7 @@ class KritzelViewport {
|
|
|
993
1004
|
this._core.store.state.translateY = viewportHeight / 2 - objectCenterY * scale;
|
|
994
1005
|
this._core.store.state.hasViewportChanged = true;
|
|
995
1006
|
this._core.rerender();
|
|
996
|
-
this.
|
|
1007
|
+
this._debounceUpdate();
|
|
997
1008
|
}
|
|
998
1009
|
centerFitInViewport(object) {
|
|
999
1010
|
const scaleX = this._core.store.state.viewportWidth / (object.rotatedBoundingBox.width * 1.1);
|
|
@@ -1020,7 +1031,7 @@ class KritzelViewport {
|
|
|
1020
1031
|
this._core.store.state.translateY = this._core.store.state.translateY - translateYAdjustment;
|
|
1021
1032
|
this._core.store.state.hasViewportChanged = true;
|
|
1022
1033
|
this._core.rerender();
|
|
1023
|
-
this.
|
|
1034
|
+
this._debounceUpdate();
|
|
1024
1035
|
setTimeout(() => {
|
|
1025
1036
|
this._core.store.state.isScaling = false;
|
|
1026
1037
|
}, 300);
|
|
@@ -1031,7 +1042,7 @@ class KritzelViewport {
|
|
|
1031
1042
|
this._core.store.state.translateY = this._core.store.state.translateY - event.deltaY * panSpeed;
|
|
1032
1043
|
this._core.store.state.hasViewportChanged = true;
|
|
1033
1044
|
this._core.rerender();
|
|
1034
|
-
this.
|
|
1045
|
+
this._debounceUpdate();
|
|
1035
1046
|
}
|
|
1036
1047
|
}
|
|
1037
1048
|
|
|
@@ -1125,7 +1136,7 @@ class KritzelContextMenuHandler extends index$1.KritzelBaseHandler {
|
|
|
1125
1136
|
new index$1.RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),
|
|
1126
1137
|
new index$1.AddSelectionGroupCommand(this._core, this, selectionGroup),
|
|
1127
1138
|
]);
|
|
1128
|
-
this._core.
|
|
1139
|
+
this._core.commandManager.executeCommand(batch);
|
|
1129
1140
|
}
|
|
1130
1141
|
this._core.store.state.contextMenuItems = this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
1131
1142
|
let x = event.clientX - this._core.store.offsetX;
|
|
@@ -1528,47 +1539,24 @@ class KritzelHistory {
|
|
|
1528
1539
|
_core;
|
|
1529
1540
|
undoStack;
|
|
1530
1541
|
redoStack;
|
|
1531
|
-
previousViewport;
|
|
1532
1542
|
constructor(core) {
|
|
1533
1543
|
this._core = core;
|
|
1534
1544
|
this.undoStack = new KritzelCircularBuffer(this._core.store.state.historyBufferSize);
|
|
1535
1545
|
this.redoStack = new KritzelCircularBuffer(this._core.store.state.historyBufferSize);
|
|
1536
|
-
this.previousViewport = {
|
|
1537
|
-
scale: this._core.store.state.scale,
|
|
1538
|
-
scaleStep: this._core.store.state.scaleStep,
|
|
1539
|
-
translateX: this._core.store.state.translateX,
|
|
1540
|
-
translateY: this._core.store.state.translateY,
|
|
1541
|
-
};
|
|
1542
1546
|
}
|
|
1543
1547
|
reset() {
|
|
1544
1548
|
this.undoStack.clear();
|
|
1545
1549
|
this.redoStack.clear();
|
|
1546
|
-
this.previousViewport = {
|
|
1550
|
+
this._core.commandManager.previousViewport = {
|
|
1547
1551
|
scale: this._core.store.state.scale,
|
|
1548
1552
|
scaleStep: this._core.store.state.scaleStep,
|
|
1549
1553
|
translateX: this._core.store.state.translateX,
|
|
1550
1554
|
translateY: this._core.store.state.translateY
|
|
1551
1555
|
};
|
|
1552
1556
|
}
|
|
1553
|
-
executeCommand(command) {
|
|
1554
|
-
if (this._core.store.state.hasViewportChanged) {
|
|
1555
|
-
this.addUpdateViewportCommand();
|
|
1556
|
-
}
|
|
1557
|
-
command.execute();
|
|
1558
|
-
if (command.skipHistory === false) {
|
|
1559
|
-
if (this._core.store.state.debugInfo.logCommands) {
|
|
1560
|
-
console.info('add', command);
|
|
1561
|
-
}
|
|
1562
|
-
this.undoStack.add(command);
|
|
1563
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1564
|
-
this.redoStack.clear();
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
this._core.rerender();
|
|
1568
|
-
}
|
|
1569
1557
|
undo() {
|
|
1570
1558
|
if (this._core.store.state.hasViewportChanged) {
|
|
1571
|
-
const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
|
|
1559
|
+
const command = new UpdateViewportCommand(this._core, this, this._core.commandManager.previousViewport);
|
|
1572
1560
|
command.undo();
|
|
1573
1561
|
this._core.store.state.hasViewportChanged = false;
|
|
1574
1562
|
this._core.rerender();
|
|
@@ -1594,21 +1582,6 @@ class KritzelHistory {
|
|
|
1594
1582
|
}
|
|
1595
1583
|
this._core.rerender();
|
|
1596
1584
|
}
|
|
1597
|
-
addUpdateViewportCommand() {
|
|
1598
|
-
const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
|
|
1599
|
-
command.execute();
|
|
1600
|
-
this.undoStack.add(command);
|
|
1601
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1602
|
-
this.redoStack.clear();
|
|
1603
|
-
}
|
|
1604
|
-
this._core.store.state.hasViewportChanged = false;
|
|
1605
|
-
this.previousViewport = {
|
|
1606
|
-
scale: this._core.store.state.scale,
|
|
1607
|
-
scaleStep: this._core.store.state.scaleStep,
|
|
1608
|
-
translateX: this._core.store.state.translateX,
|
|
1609
|
-
translateY: this._core.store.state.translateY,
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
1585
|
}
|
|
1613
1586
|
|
|
1614
1587
|
class KritzelObjectMap {
|
|
@@ -1705,10 +1678,61 @@ class KritzelStore {
|
|
|
1705
1678
|
}
|
|
1706
1679
|
}
|
|
1707
1680
|
|
|
1681
|
+
class KritzelCommandManager {
|
|
1682
|
+
_core;
|
|
1683
|
+
_history;
|
|
1684
|
+
previousViewport;
|
|
1685
|
+
constructor(core) {
|
|
1686
|
+
this._core = core;
|
|
1687
|
+
this._history = this._core.history;
|
|
1688
|
+
this.previousViewport = {
|
|
1689
|
+
scale: this._core.store.state.scale,
|
|
1690
|
+
scaleStep: this._core.store.state.scaleStep,
|
|
1691
|
+
translateX: this._core.store.state.translateX,
|
|
1692
|
+
translateY: this._core.store.state.translateY,
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
executeCommand(command) {
|
|
1696
|
+
if (this._core.store.state.hasViewportChanged) {
|
|
1697
|
+
this.addUpdateViewportCommand();
|
|
1698
|
+
}
|
|
1699
|
+
command.execute();
|
|
1700
|
+
if (this.isSkipped(command) === false) {
|
|
1701
|
+
if (this._core.store.state.debugInfo.logCommands) {
|
|
1702
|
+
console.log('execute', command);
|
|
1703
|
+
}
|
|
1704
|
+
this._history.undoStack.add(command);
|
|
1705
|
+
if (this._history.redoStack.isEmpty() === false) {
|
|
1706
|
+
this._history.redoStack.clear();
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
this._core.rerender();
|
|
1710
|
+
}
|
|
1711
|
+
isSkipped(command) {
|
|
1712
|
+
return command.skipHistory === true;
|
|
1713
|
+
}
|
|
1714
|
+
addUpdateViewportCommand() {
|
|
1715
|
+
const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
|
|
1716
|
+
command.execute();
|
|
1717
|
+
this._history.undoStack.add(command);
|
|
1718
|
+
if (this._history.redoStack.isEmpty() === false) {
|
|
1719
|
+
this._history.redoStack.clear();
|
|
1720
|
+
}
|
|
1721
|
+
this._core.store.state.hasViewportChanged = false;
|
|
1722
|
+
this.previousViewport = {
|
|
1723
|
+
scale: this._core.store.state.scale,
|
|
1724
|
+
scaleStep: this._core.store.state.scaleStep,
|
|
1725
|
+
translateX: this._core.store.state.translateX,
|
|
1726
|
+
translateY: this._core.store.state.translateY,
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1708
1731
|
class KritzelCore {
|
|
1709
1732
|
_kritzelEngine;
|
|
1710
1733
|
_store;
|
|
1711
1734
|
_history;
|
|
1735
|
+
_commandManager;
|
|
1712
1736
|
_database;
|
|
1713
1737
|
get engine() {
|
|
1714
1738
|
return this._kritzelEngine;
|
|
@@ -1716,6 +1740,9 @@ class KritzelCore {
|
|
|
1716
1740
|
get history() {
|
|
1717
1741
|
return this._history;
|
|
1718
1742
|
}
|
|
1743
|
+
get commandManager() {
|
|
1744
|
+
return this._commandManager;
|
|
1745
|
+
}
|
|
1719
1746
|
get database() {
|
|
1720
1747
|
return this._database;
|
|
1721
1748
|
}
|
|
@@ -1726,6 +1753,7 @@ class KritzelCore {
|
|
|
1726
1753
|
this._kritzelEngine = kritzelEngine;
|
|
1727
1754
|
this._store = new KritzelStore(DEFAULT_ENGINE_STATE);
|
|
1728
1755
|
this._history = new KritzelHistory(this);
|
|
1756
|
+
this._commandManager = new KritzelCommandManager(this);
|
|
1729
1757
|
this._database = new KritzelDatabase('kritzelDB', 1, this._store.state.debugInfo.logDatabase);
|
|
1730
1758
|
}
|
|
1731
1759
|
async initializeDatabase() {
|
|
@@ -1878,7 +1906,7 @@ class KritzelCore {
|
|
|
1878
1906
|
}
|
|
1879
1907
|
deselectAllObjects() {
|
|
1880
1908
|
if (this._store.state.selectionGroup) {
|
|
1881
|
-
this.
|
|
1909
|
+
this.commandManager.executeCommand(new index$1.RemoveSelectionGroupCommand(this, this, true));
|
|
1882
1910
|
}
|
|
1883
1911
|
}
|
|
1884
1912
|
delete() {
|
|
@@ -1888,13 +1916,13 @@ class KritzelCore {
|
|
|
1888
1916
|
const deleteSelectedObjectsCommand = this._store.state.selectionGroup.objects.map(obj => new index$1.RemoveObjectCommand(this, this._store.state.selectionGroup, obj));
|
|
1889
1917
|
const removeSelectionGroupCommand = new index$1.RemoveSelectionGroupCommand(this, this._store.state.selectionGroup);
|
|
1890
1918
|
const commands = [...deleteSelectedObjectsCommand, removeSelectionGroupCommand];
|
|
1891
|
-
this.
|
|
1919
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this._store.state.selectionGroup, commands));
|
|
1892
1920
|
}
|
|
1893
1921
|
deleteObject(id, skipHistory = false) {
|
|
1894
1922
|
const object = this.findObjectById(id);
|
|
1895
1923
|
if (object) {
|
|
1896
1924
|
const removeObjectCommand = new index$1.RemoveObjectCommand(this, this, object, skipHistory);
|
|
1897
|
-
this.
|
|
1925
|
+
this.commandManager.executeCommand(removeObjectCommand);
|
|
1898
1926
|
}
|
|
1899
1927
|
}
|
|
1900
1928
|
copy() {
|
|
@@ -1928,7 +1956,7 @@ class KritzelCore {
|
|
|
1928
1956
|
const addCopiedObjectsCommands = this._store.state.copiedObjects.objects.map(obj => new index$1.AddObjectCommand(this, this, obj));
|
|
1929
1957
|
const addCopiedObjectsAsSelectionGroupCommand = new index$1.AddSelectionGroupCommand(this, this, this._store.state.copiedObjects, previousSelectionGroup);
|
|
1930
1958
|
commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);
|
|
1931
|
-
this.
|
|
1959
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this, commands));
|
|
1932
1960
|
this._store.state.isSelecting = false;
|
|
1933
1961
|
this._store.state.copiedObjects = this._store.state.selectionGroup.copy();
|
|
1934
1962
|
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
@@ -1943,7 +1971,7 @@ class KritzelCore {
|
|
|
1943
1971
|
}
|
|
1944
1972
|
return new index$1.UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex + 1 });
|
|
1945
1973
|
});
|
|
1946
|
-
this.
|
|
1974
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
1947
1975
|
}
|
|
1948
1976
|
sendBackward(object) {
|
|
1949
1977
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
@@ -1955,7 +1983,7 @@ class KritzelCore {
|
|
|
1955
1983
|
}
|
|
1956
1984
|
return new index$1.UpdateObjectCommand(this, this, obj, { zIndex: obj.zIndex - 1 });
|
|
1957
1985
|
});
|
|
1958
|
-
this.
|
|
1986
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
1959
1987
|
}
|
|
1960
1988
|
bringToFront(object) {
|
|
1961
1989
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
@@ -1964,7 +1992,7 @@ class KritzelCore {
|
|
|
1964
1992
|
const increaseZIndexCommands = objects.map(obj => {
|
|
1965
1993
|
return new index$1.UpdateObjectCommand(this, this, obj, { zIndex: max });
|
|
1966
1994
|
});
|
|
1967
|
-
this.
|
|
1995
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this, increaseZIndexCommands));
|
|
1968
1996
|
}
|
|
1969
1997
|
sendToBack(object) {
|
|
1970
1998
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
@@ -1973,7 +2001,7 @@ class KritzelCore {
|
|
|
1973
2001
|
const decreaseZIndexCommands = objects.map(obj => {
|
|
1974
2002
|
return new index$1.UpdateObjectCommand(this, this, obj, { zIndex: min });
|
|
1975
2003
|
});
|
|
1976
|
-
this.
|
|
2004
|
+
this.commandManager.executeCommand(new index$1.BatchCommand(this, this, decreaseZIndexCommands));
|
|
1977
2005
|
}
|
|
1978
2006
|
selectObjects(objects) {
|
|
1979
2007
|
if (objects.length === 0) {
|
|
@@ -1989,7 +2017,7 @@ class KritzelCore {
|
|
|
1989
2017
|
if (objects.length === 1) {
|
|
1990
2018
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
1991
2019
|
}
|
|
1992
|
-
this.
|
|
2020
|
+
this.commandManager.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
1993
2021
|
}
|
|
1994
2022
|
selectAllObjectsInViewport() {
|
|
1995
2023
|
const objectsInViewport = this._store.state.objectsMap
|
|
@@ -2006,13 +2034,13 @@ class KritzelCore {
|
|
|
2006
2034
|
if (objectsInViewport.length === 1) {
|
|
2007
2035
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2008
2036
|
}
|
|
2009
|
-
this.
|
|
2037
|
+
this.commandManager.executeCommand(new index$1.AddSelectionGroupCommand(this, this, selectionGroup));
|
|
2010
2038
|
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
2011
2039
|
}
|
|
2012
2040
|
}
|
|
2013
2041
|
clearSelection() {
|
|
2014
|
-
const command = new index$1.RemoveSelectionGroupCommand(this, this
|
|
2015
|
-
this.
|
|
2042
|
+
const command = new index$1.RemoveSelectionGroupCommand(this, this);
|
|
2043
|
+
this.commandManager.executeCommand(command);
|
|
2016
2044
|
this._store.state.selectionGroup = null;
|
|
2017
2045
|
this._store.state.selectionBox = null;
|
|
2018
2046
|
this._store.state.isSelecting = false;
|
|
@@ -2023,11 +2051,9 @@ class KritzelCore {
|
|
|
2023
2051
|
resetActiveText() {
|
|
2024
2052
|
if (this._store.state.activeText) {
|
|
2025
2053
|
if (this._store.state.activeText.isEmpty) {
|
|
2026
|
-
console.log('Deleting empty text object', this._store.state.activeText.id);
|
|
2027
2054
|
this.deleteObject(this._store.state.activeText.id, true);
|
|
2028
2055
|
}
|
|
2029
2056
|
else {
|
|
2030
|
-
console.log('Saving active text object before resetting', this._store.state.activeText.id);
|
|
2031
2057
|
this._store.state.activeText.save();
|
|
2032
2058
|
}
|
|
2033
2059
|
}
|
|
@@ -2084,15 +2110,21 @@ class KritzelCore {
|
|
|
2084
2110
|
const worldY = yWithoutTranslate / this._store.state.scale;
|
|
2085
2111
|
return { x: worldX, y: worldY };
|
|
2086
2112
|
}
|
|
2113
|
+
beforeWorkspaceChange() {
|
|
2114
|
+
this.resetActiveText();
|
|
2115
|
+
this.clearSelection();
|
|
2116
|
+
this._store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
2117
|
+
}
|
|
2087
2118
|
}
|
|
2088
2119
|
|
|
2089
|
-
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p{margin:0;padding:0}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}";
|
|
2120
|
+
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}";
|
|
2090
2121
|
|
|
2091
2122
|
const KritzelEngine = class {
|
|
2092
2123
|
get host() { return index.getElement(this); }
|
|
2093
2124
|
workspace;
|
|
2094
2125
|
onWorkspaceChange(newWorkspace) {
|
|
2095
2126
|
if (this.core.store.state.activeWorkspace !== newWorkspace) {
|
|
2127
|
+
this.core.beforeWorkspaceChange();
|
|
2096
2128
|
this.core.initializeWorkspace(newWorkspace);
|
|
2097
2129
|
}
|
|
2098
2130
|
}
|
|
@@ -2278,19 +2310,19 @@ const KritzelEngine = class {
|
|
|
2278
2310
|
object.scale = object.scale ? object.scale : this.core.store.state.scale;
|
|
2279
2311
|
object.zIndex = this.core.store.currentZIndex;
|
|
2280
2312
|
const command = new index$1.AddObjectCommand(this.core, this, object);
|
|
2281
|
-
this.core.
|
|
2313
|
+
this.core.commandManager.executeCommand(command);
|
|
2282
2314
|
return object;
|
|
2283
2315
|
}
|
|
2284
2316
|
async updateObject(object, updatedProperties) {
|
|
2285
2317
|
this.core.deselectAllObjects();
|
|
2286
2318
|
const command = new index$1.UpdateObjectCommand(this.core, this, object, updatedProperties);
|
|
2287
|
-
this.core.
|
|
2319
|
+
this.core.commandManager.executeCommand(command);
|
|
2288
2320
|
return object;
|
|
2289
2321
|
}
|
|
2290
2322
|
async removeObject(object) {
|
|
2291
2323
|
this.core.deselectAllObjects();
|
|
2292
2324
|
const command = new index$1.RemoveObjectCommand(this.core, this, object);
|
|
2293
|
-
this.core.
|
|
2325
|
+
this.core.commandManager.executeCommand(command);
|
|
2294
2326
|
return object;
|
|
2295
2327
|
}
|
|
2296
2328
|
async getSelectedObjects() {
|
|
@@ -2314,7 +2346,7 @@ const KritzelEngine = class {
|
|
|
2314
2346
|
async centerObjectInViewport(object) {
|
|
2315
2347
|
object.centerInViewport();
|
|
2316
2348
|
const command = new index$1.UpdateObjectCommand(this.core, this, object, object);
|
|
2317
|
-
this.core.
|
|
2349
|
+
this.core.commandManager.executeCommand(command);
|
|
2318
2350
|
return object;
|
|
2319
2351
|
}
|
|
2320
2352
|
async getCopiedObjects() {
|
|
@@ -2381,11 +2413,16 @@ const KritzelEngine = class {
|
|
|
2381
2413
|
_handleActiveToolChange(activeTool) {
|
|
2382
2414
|
if (!(activeTool instanceof index$1.KritzelSelectionTool)) {
|
|
2383
2415
|
this.core.clearSelection();
|
|
2416
|
+
this.core.store.state.selectionBox = null;
|
|
2417
|
+
this.core.store.state.isSelecting = false;
|
|
2418
|
+
this.core.store.state.isResizeHandleSelected = false;
|
|
2419
|
+
this.core.store.state.isRotationHandleSelected = false;
|
|
2384
2420
|
}
|
|
2385
2421
|
this.core.store.state.skipContextMenu = false;
|
|
2386
2422
|
this.core.store.state.copiedObjects = null;
|
|
2387
2423
|
this.activeToolChange.emit(activeTool);
|
|
2388
2424
|
index$1.KritzelKeyboardHelper.forceHideKeyboard();
|
|
2425
|
+
this.core.rerender();
|
|
2389
2426
|
}
|
|
2390
2427
|
render() {
|
|
2391
2428
|
const computedStyle = window.getComputedStyle(this.host);
|
|
@@ -2394,7 +2431,7 @@ const KritzelEngine = class {
|
|
|
2394
2431
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
2395
2432
|
const viewportCenterX = this.core.store.state.viewportWidth / 2 + this.core.store.state.translateX;
|
|
2396
2433
|
const viewportCenterY = this.core.store.state.viewportHeight / 2 + this.core.store.state.translateY;
|
|
2397
|
-
return (index.h(index.Host, { key: '
|
|
2434
|
+
return (index.h(index.Host, { key: 'f7fc3c4c6a91ccdabb83832671e36ebf49ce56c0' }, index.h("div", { key: 'f6a2ce9e78a1d0e9ea0590035f5b8811f62c8633', class: "debug-panel", style: { display: this.core.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '5752045746f275223bd42c16dd7e848adaaae9f2' }, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), index.h("div", { key: 'd99595b135243a7b69a583be33f7b195908ec716' }, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), index.h("div", { key: '7cecdccad47d3957370ea923f3dfbcd618b5d28e' }, "TranslateX: ", this.core.store.state?.translateX), index.h("div", { key: '3a5ed989f2343eda92c7c81855c785dbf58fa770' }, "TranslateY: ", this.core.store.state?.translateY), index.h("div", { key: 'b78074a29463276300ce498b2ddb328cef9026cd' }, "ViewportWidth: ", this.core.store.state?.viewportWidth), index.h("div", { key: 'd4c8dcfddfa1984eedf695d74f9401fc3284c60b' }, "ViewportHeight: ", this.core.store.state?.viewportHeight), index.h("div", { key: '566b6dc9afd904ee49e59587ed664e5f46decead' }, "Scale: ", this.core.store.state?.scale), index.h("div", { key: 'd3feb7a11727c4337ca75a26b3275a0b5d639961' }, "ActiveTool: ", this.core.store.state?.activeTool?.name), index.h("div", { key: '3991c34df53c7d6fd97c83b0d4b8c9fb438c88fc' }, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), index.h("div", { key: '5a4244b43871f96d08144483352064804f04e538' }, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), index.h("div", { key: '197655c09e24d624ea4dcd312169aeb449ed57ce' }, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), index.h("div", { key: 'a3e4a75a9853c8cee1485cbf8621377466babf90' }, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), index.h("div", { key: '171e0df3e1856e9fe8cd18be5c258c7472317453' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '66f5a56333dbac1da34e01f5ee1f577e1a964701' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: 'b869e07b76c2fa21ab5383788e81a40ffdad1b2c' }, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: 'd936326f8ea675e170d418f4e97a5d46057bc385' }, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: '8594489402204ae4a9cd1bc7795169dbfa2d633d' }, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: 'f7a254dc35bfe6d42c32d25d0f277b211d86b03f' }, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '053ebd21504bfa3622e4b3e965e39f707c19794d' }, "PointerX: ", this.core.store.state?.pointerX), index.h("div", { key: 'f330c65821326062874441355352134927760d61' }, "PointerY: ", this.core.store.state?.pointerY), index.h("div", { key: 'f6c6902562f3e74afa3a0426e72b0c803977250b' }, "SelectedObjects: ", this.core.store.state.selectionGroup?.objects.length || 0), index.h("div", { key: '99a2d4280d5e79d7dd9a7a27d809e70f90eac38b' }, "ViewportCenter: (", viewportCenterX.toFixed(2), ", ", viewportCenterY.toFixed(2), ")")), index.h("div", { key: 'dac21fa0ac9487b74c89ac7408e80d9fb89b4558', id: "origin", class: "origin", style: {
|
|
2398
2435
|
transform: `matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`,
|
|
2399
2436
|
} }, this.core.store.state.objectsMap.allObjects()?.map(object => {
|
|
2400
2437
|
return (index.h("div", { key: object.id, style: {
|
|
@@ -2422,17 +2459,17 @@ const KritzelEngine = class {
|
|
|
2422
2459
|
borderStyle: 'solid',
|
|
2423
2460
|
padding: object.padding + 'px',
|
|
2424
2461
|
overflow: 'visible',
|
|
2425
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el =>
|
|
2462
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2426
2463
|
height: object?.height.toString(),
|
|
2427
2464
|
width: object?.width.toString(),
|
|
2428
2465
|
position: 'absolute',
|
|
2429
2466
|
overflow: 'visible',
|
|
2430
|
-
}, viewBox: object?.viewBox }, index.h("path", { d: object?.d, fill: object.fill, stroke: object?.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (index.h("img", { ref: el =>
|
|
2467
|
+
}, viewBox: object?.viewBox }, index.h("path", { d: object?.d, fill: object.fill, stroke: object?.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (index.h("img", { ref: el => object.mount(el), src: object.src, style: {
|
|
2431
2468
|
width: '100%',
|
|
2432
2469
|
height: '100%',
|
|
2433
2470
|
userSelect: 'none',
|
|
2434
2471
|
pointerEvents: 'none',
|
|
2435
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.h("div", { ref: el =>
|
|
2472
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.h("div", { ref: el => object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
|
|
2436
2473
|
minWidth: object.initialWidth + 'px',
|
|
2437
2474
|
minHeight: object.initialHeight + 'px',
|
|
2438
2475
|
maxWidth: '500px',
|
|
@@ -2441,17 +2478,17 @@ const KritzelEngine = class {
|
|
|
2441
2478
|
transformOrigin: 'top left',
|
|
2442
2479
|
transform: `scale(${object.scaleFactor})`,
|
|
2443
2480
|
backgroundColor: object.backgroundColor,
|
|
2444
|
-
overflow: 'visible'
|
|
2445
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (index.h("div", { ref: el =>
|
|
2481
|
+
overflow: 'visible',
|
|
2482
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
2446
2483
|
width: '100%',
|
|
2447
2484
|
height: '100%',
|
|
2448
2485
|
pointerEvents: 'auto',
|
|
2449
2486
|
overflow: 'hidden',
|
|
2450
2487
|
display: 'block',
|
|
2451
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (index.h("div", { ref: el =>
|
|
2488
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
2452
2489
|
width: '100%',
|
|
2453
2490
|
height: '100%',
|
|
2454
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el =>
|
|
2491
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
2455
2492
|
width: '100%',
|
|
2456
2493
|
height: '100%',
|
|
2457
2494
|
backgroundColor: KritzelDevicesHelper.isFirefox() ? object.backgroundColor : 'transparent',
|
|
@@ -2498,7 +2535,7 @@ const KritzelEngine = class {
|
|
|
2498
2535
|
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("circle", { class: "rotation-handle-overlay", cx: object.totalWidth / 2, cy: -((15 * object.scale) / this.core.store.state?.scale), r: `${(baseHandleTouchSize * object.scale) / this.core.store.state?.scale}`, style: {
|
|
2499
2536
|
fill: 'transparent',
|
|
2500
2537
|
cursor: 'grab',
|
|
2501
|
-
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.core.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: {
|
|
2538
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.core.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: { whitespace: 'nowrap' } }, "Id: ", object.id), index.h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), index.h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height)))))));
|
|
2502
2539
|
}), index.h("svg", { key: "current-path", class: "object", xmlns: "http://www.w3.org/2000/svg", width: this.core.store.state.currentPath?.width, height: this.core.store.state.currentPath?.height, style: {
|
|
2503
2540
|
left: '0',
|
|
2504
2541
|
top: '0',
|
|
@@ -2507,7 +2544,7 @@ const KritzelEngine = class {
|
|
|
2507
2544
|
transform: this.core.store.state.currentPath?.transformationMatrix,
|
|
2508
2545
|
transformOrigin: 'top left',
|
|
2509
2546
|
overflow: 'visible',
|
|
2510
|
-
}, viewBox: this.core.store.state.currentPath?.viewBox }, index.h("path", { key: '
|
|
2547
|
+
}, viewBox: this.core.store.state.currentPath?.viewBox }, index.h("path", { key: 'f3aaf24804430eeb0308a15ae4a38df302d0566f', 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 && (index.h("kritzel-context-menu", { key: 'd99a76a11b613167d5723d1c16e9289e45eee8a3', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.state.selectionGroup?.objects || [], style: {
|
|
2511
2548
|
position: 'fixed',
|
|
2512
2549
|
left: `${this.core.store.state.contextMenuX}px`,
|
|
2513
2550
|
top: `${this.core.store.state.contextMenuY}px`,
|
|
@@ -2518,7 +2555,7 @@ const KritzelEngine = class {
|
|
|
2518
2555
|
y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
|
|
2519
2556
|
}, this.core.store.state.selectionGroup?.objects);
|
|
2520
2557
|
this.hideContextMenu();
|
|
2521
|
-
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof index$1.KritzelEraserTool && !this.core.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '
|
|
2558
|
+
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof index$1.KritzelEraserTool && !this.core.store.state.isScaling && index.h("kritzel-cursor-trail", { key: 'fc7c474156442dfb5c057ef4ed4f0e5f015c2502', core: this.core })));
|
|
2522
2559
|
}
|
|
2523
2560
|
static get watchers() { return {
|
|
2524
2561
|
"workspace": ["onWorkspaceChange"],
|
|
@@ -10,6 +10,7 @@ export class AddObjectCommand extends KritzelBaseCommand {
|
|
|
10
10
|
this._core.addObjectToDatabase(this.object);
|
|
11
11
|
}
|
|
12
12
|
undo() {
|
|
13
|
+
this.object.isMounted = false;
|
|
13
14
|
this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
|
|
14
15
|
this._core.deleteObjectFromDatabase(this.object.id);
|
|
15
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/add-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"add-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/add-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,gBAAmD,SAAQ,kBAAkB;IAChF,MAAM,CAAI;IAElB,YAAY,IAAiB,EAAE,SAAc,EAAG,MAAS,EAAE,WAAW,GAAG,KAAK;QAC5E,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from '../objects/base-object.class';\r\nimport { KritzelBaseCommand } from './base.command';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class AddObjectCommand<T extends KritzelBaseObject<any>> extends KritzelBaseCommand {\r\n private object: T;\r\n\r\n constructor(core: KritzelCore, initiator: any, object: T, skipHistory = false) {\r\n super(core, initiator, skipHistory);\r\n this.object = object;\r\n }\r\n\r\n execute(): void {\r\n this._core.store.state.objectsMap.insert(this.object);\r\n this._core.addObjectToDatabase(this.object);\r\n }\r\n\r\n undo(): void {\r\n this.object.isMounted = false;\r\n this._core.store.state.objectsMap.remove(object => object.id === this.object.id);\r\n this._core.deleteObjectFromDatabase(this.object.id);\r\n }\r\n}\r\n"]}
|
|
@@ -2,10 +2,12 @@ export class KritzelBaseCommand {
|
|
|
2
2
|
_core;
|
|
3
3
|
initiator;
|
|
4
4
|
skipHistory;
|
|
5
|
+
timestamp;
|
|
5
6
|
constructor(core, initiator, skipHistory = false) {
|
|
6
7
|
this._core = core;
|
|
7
8
|
this.initiator = initiator?.constructor?.name ?? 'Unknown';
|
|
8
9
|
this.skipHistory = skipHistory;
|
|
10
|
+
this.timestamp = new Date();
|
|
9
11
|
}
|
|
10
12
|
execute() {
|
|
11
13
|
throw new Error('Method not implemented.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.command.js","sourceRoot":"","sources":["../../../src/classes/commands/base.command.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IACnB,KAAK,CAAc;IAE7B,SAAS,CAAS;IAClB,WAAW,
|
|
1
|
+
{"version":3,"file":"base.command.js","sourceRoot":"","sources":["../../../src/classes/commands/base.command.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IACnB,KAAK,CAAc;IAE7B,SAAS,CAAS;IAClB,WAAW,CAAU;IACrB,SAAS,CAAO;IAEhB,YAAY,IAAiB,EAAE,SAAc,EAAE,WAAW,GAAG,KAAK;QAChE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,SAAS,EAAE,WAAW,EAAE,IAAI,IAAI,SAAS,CAAC;QAC3D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI;QACF,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { KritzelCommand } from '../../interfaces/command.interface';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class KritzelBaseCommand implements KritzelCommand {\r\n protected _core: KritzelCore;\r\n\r\n initiator: string;\r\n skipHistory: boolean;\r\n timestamp: Date;\r\n\r\n constructor(core: KritzelCore, initiator: any, skipHistory = false) {\r\n this._core = core;\r\n this.initiator = initiator?.constructor?.name ?? 'Unknown';\r\n this.skipHistory = skipHistory;\r\n this.timestamp = new Date();\r\n }\r\n\r\n execute(): void {\r\n throw new Error('Method not implemented.');\r\n }\r\n\r\n undo(): void {\r\n throw new Error('Method not implemented.');\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { KritzelBaseCommand } from "./base.command";
|
|
2
|
-
import { KritzelCustomElement } from "../objects/custom-element.class";
|
|
3
2
|
export class RemoveObjectCommand extends KritzelBaseCommand {
|
|
4
3
|
object;
|
|
5
4
|
constructor(core, initiator, object, skipHistory = false) {
|
|
@@ -7,13 +6,12 @@ export class RemoveObjectCommand extends KritzelBaseCommand {
|
|
|
7
6
|
this.object = object;
|
|
8
7
|
}
|
|
9
8
|
execute() {
|
|
9
|
+
this.object.isMounted = false;
|
|
10
10
|
this._core.store.state.objectsMap.remove(object => object.id === this.object.id);
|
|
11
|
-
this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
12
11
|
this._core.deleteObjectFromDatabase(this.object.id);
|
|
13
12
|
}
|
|
14
13
|
undo() {
|
|
15
14
|
this._core.store.state.objectsMap.insert(this.object);
|
|
16
|
-
this._core.store.state.objectsMap.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
17
15
|
this._core.addObjectToDatabase(this.object);
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/remove-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"remove-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/remove-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,mBAAsD,SAAQ,kBAAkB;IACnF,MAAM,CAAI;IAElB,YAAY,IAAiB,EAAE,SAAc,EAAG,MAAS,EAAE,WAAW,GAAG,KAAK;QAC5E,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,IAAI;QACF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from '../objects/base-object.class';\r\nimport { KritzelBaseCommand } from './base.command';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class RemoveObjectCommand<T extends KritzelBaseObject<any>> extends KritzelBaseCommand {\r\n private object: T;\r\n\r\n constructor(core: KritzelCore, initiator: any, object: T, skipHistory = false) {\r\n super(core, initiator, skipHistory);\r\n this.object = object;\r\n }\r\n\r\n execute(): void {\r\n this.object.isMounted = false;\r\n this._core.store.state.objectsMap.remove(object => object.id === this.object.id);\r\n this._core.deleteObjectFromDatabase(this.object.id);\r\n }\r\n\r\n undo(): void {\r\n this._core.store.state.objectsMap.insert(this.object);\r\n this._core.addObjectToDatabase(this.object);\r\n }\r\n}\r\n"]}
|
|
@@ -20,6 +20,7 @@ export class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
20
20
|
this.object[key] = this.updatedProperties[key];
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
this.object.onExecuteUpdateCommand(this.updatedProperties);
|
|
23
24
|
this._core.store.state.objectsMap.update(this.object);
|
|
24
25
|
this._core.updateObjectInDatabase(this.object);
|
|
25
26
|
}
|
|
@@ -29,6 +30,7 @@ export class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
29
30
|
this.object[key] = this.previousProperties[key];
|
|
30
31
|
}
|
|
31
32
|
}
|
|
33
|
+
this.object.onUndoUpdateCommand(this.previousProperties);
|
|
32
34
|
this._core.store.state.objectsMap.update(this.object);
|
|
33
35
|
this._core.updateObjectInDatabase(this.object);
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/update-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"update-object.command.js","sourceRoot":"","sources":["../../../src/classes/commands/update-object.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,mBAAsD,SAAQ,kBAAkB;IACnF,MAAM,CAAI;IACV,iBAAiB,CAAa;IAC9B,kBAAkB,CAAa;IAEvC,YAAY,IAAiB,EAAE,SAAc,EAAE,MAAS,EAAE,iBAA6B,EAAE,WAAW,GAAG,KAAK;QAC1G,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAE3C,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;YACpC,IAAI,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAE3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,IAAI;QACF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEzD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from '../objects/base-object.class';\r\nimport { KritzelBaseCommand } from './base.command';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class UpdateObjectCommand<T extends KritzelBaseObject<any>> extends KritzelBaseCommand {\r\n private object: T;\r\n private updatedProperties: Partial<T>;\r\n private previousProperties: Partial<T>;\r\n\r\n constructor(core: KritzelCore, initiator: any, object: T, updatedProperties: Partial<T>, skipHistory = false) {\r\n super(core, initiator, skipHistory);\r\n this.object = object;\r\n this.updatedProperties = updatedProperties;\r\n\r\n this.previousProperties = {};\r\n for (const key in updatedProperties) {\r\n if (updatedProperties.hasOwnProperty(key)) {\r\n this.previousProperties[key] = this.object[key];\r\n }\r\n }\r\n }\r\n\r\n execute(): void {\r\n for (const key in this.updatedProperties) {\r\n if (this.updatedProperties.hasOwnProperty(key)) {\r\n this.object[key] = this.updatedProperties[key];\r\n }\r\n }\r\n\r\n this.object.onExecuteUpdateCommand(this.updatedProperties);\r\n\r\n this._core.store.state.objectsMap.update(this.object);\r\n this._core.updateObjectInDatabase(this.object);\r\n }\r\n\r\n undo(): void {\r\n for (const key in this.previousProperties) {\r\n if (this.previousProperties.hasOwnProperty(key)) {\r\n this.object[key] = this.previousProperties[key];\r\n }\r\n }\r\n\r\n this.object.onUndoUpdateCommand(this.previousProperties);\r\n\r\n this._core.store.state.objectsMap.update(this.object);\r\n this._core.updateObjectInDatabase(this.object);\r\n }\r\n}\r\n"]}
|