kritzel-stencil 0.0.138 → 0.0.140
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-CYkadfjX.js → index-Clh2g9JM.js} +186 -107
- package/dist/cjs/index-Clh2g9JM.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +186 -148
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +4 -4
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-viewport.command.js +6 -6
- package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +43 -27
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/history.class.js +3 -3
- package/dist/collection/classes/core/history.class.js.map +1 -1
- package/dist/collection/classes/core/store.class.js +4 -1
- package/dist/collection/classes/core/store.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +63 -44
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +16 -8
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +2 -2
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +30 -6
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +6 -4
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +6 -4
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +72 -32
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +9 -3
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +3 -1
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +9 -7
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +16 -16
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +4 -4
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +8 -8
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +10 -8
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -15
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +27 -16
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -2
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +3 -3
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +1 -0
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-editor.js +20 -33
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.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-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-DjU7p3od.js → p-BFLXutiB.js} +9 -9
- package/dist/components/{p-DjU7p3od.js.map → p-BFLXutiB.js.map} +1 -1
- package/dist/components/{p-B7kZ1_RH.js → p-BJZudenH.js} +4 -4
- package/dist/components/{p-B7kZ1_RH.js.map → p-BJZudenH.js.map} +1 -1
- package/dist/components/{p-B7w19kIk.js → p-BLc8TzcU.js} +7 -7
- package/dist/components/{p-B7w19kIk.js.map → p-BLc8TzcU.js.map} +1 -1
- package/dist/components/{p-BlPlPpUy.js → p-BQJhnpY3.js} +3 -3
- package/dist/components/{p-BlPlPpUy.js.map → p-BQJhnpY3.js.map} +1 -1
- package/dist/components/{p-D554MPA9.js → p-BV5iL9W6.js} +305 -184
- package/dist/components/p-BV5iL9W6.js.map +1 -0
- package/dist/components/{p-DOPuq6gn.js → p-C-ozL_Es.js} +3 -3
- package/dist/components/{p-DOPuq6gn.js.map → p-C-ozL_Es.js.map} +1 -1
- package/dist/components/{p-Di5CEwzQ.js → p-C5sTCwe3.js} +45 -36
- package/dist/components/p-C5sTCwe3.js.map +1 -0
- package/dist/components/{p-BM9IjvnD.js → p-C7UWRUAy.js} +3 -3
- package/dist/components/{p-BM9IjvnD.js.map → p-C7UWRUAy.js.map} +1 -1
- package/dist/components/{p-sreNwi0N.js → p-CE_sOMS2.js} +4 -4
- package/dist/components/{p-sreNwi0N.js.map → p-CE_sOMS2.js.map} +1 -1
- package/dist/components/{p-BPsQrpzN.js → p-D2eJXNMx.js} +6 -6
- package/dist/components/{p-BPsQrpzN.js.map → p-D2eJXNMx.js.map} +1 -1
- package/dist/components/{p-DCx3703u.js → p-D6FeQRzi.js} +3 -3
- package/dist/components/{p-DCx3703u.js.map → p-D6FeQRzi.js.map} +1 -1
- package/dist/components/{p-Ddlbt3Bj.js → p-DbmQ5DrU.js} +3 -3
- package/dist/components/{p-Ddlbt3Bj.js.map → p-DbmQ5DrU.js.map} +1 -1
- package/dist/components/{p-BehchtaT.js → p-Dh61W3GT.js} +6 -6
- package/dist/components/{p-BehchtaT.js.map → p-Dh61W3GT.js.map} +1 -1
- package/dist/components/{p-CsyM5q2M.js → p-IgPm36bH.js} +4 -4
- package/dist/components/{p-CsyM5q2M.js.map → p-IgPm36bH.js.map} +1 -1
- package/dist/components/{p-BgpsMYcw.js → p-JYqCBcMd.js} +6 -6
- package/dist/components/p-JYqCBcMd.js.map +1 -0
- package/dist/components/{p-PvCKCYuw.js → p-SKH0G2nM.js} +16 -16
- package/dist/components/{p-PvCKCYuw.js.map → p-SKH0G2nM.js.map} +1 -1
- package/dist/components/{p-Db3kxVe2.js → p-bC64Ng59.js} +3 -3
- package/dist/components/{p-Db3kxVe2.js.map → p-bC64Ng59.js.map} +1 -1
- package/dist/components/{p-BorT6g39.js → p-sHDCqDbD.js} +5 -5
- package/dist/components/{p-BorT6g39.js.map → p-sHDCqDbD.js.map} +1 -1
- package/dist/components/{p-0iJh9Z6m.js → p-vNnVlsJt.js} +4 -4
- package/dist/components/{p-0iJh9Z6m.js.map → p-vNnVlsJt.js.map} +1 -1
- package/dist/esm/{index-IhpPa9g4.js → index-BAbkwyRx.js} +187 -108
- package/dist/esm/index-BAbkwyRx.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +186 -148
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-BAbkwyRx.js +2 -0
- package/dist/stencil/p-BAbkwyRx.js.map +1 -0
- package/dist/stencil/p-fe465059.entry.js +2 -0
- package/dist/stencil/p-fe465059.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/store.class.d.ts +2 -1
- package/dist/types/classes/core/viewport.class.d.ts +3 -0
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/selection.handler.d.ts +3 -0
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +1 -0
- package/dist/types/components.d.ts +2 -2
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/index-CYkadfjX.js.map +0 -1
- package/dist/components/p-BgpsMYcw.js.map +0 -1
- package/dist/components/p-D554MPA9.js.map +0 -1
- package/dist/components/p-Di5CEwzQ.js.map +0 -1
- package/dist/esm/index-IhpPa9g4.js.map +0 -1
- package/dist/stencil/p-32ac435d.entry.js +0 -2
- package/dist/stencil/p-32ac435d.entry.js.map +0 -1
- package/dist/stencil/p-IhpPa9g4.js +0 -2
- package/dist/stencil/p-IhpPa9g4.js.map +0 -1
|
@@ -264,16 +264,17 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
264
264
|
const path = event.composedPath().slice(1);
|
|
265
265
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
266
266
|
const object = this._core.findObjectById(objectElement?.id);
|
|
267
|
-
if (
|
|
268
|
-
this._core.store.
|
|
267
|
+
if (object instanceof KritzelText) {
|
|
268
|
+
this._core.store.state.activeText = object;
|
|
269
269
|
object.focus();
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
272
272
|
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
273
|
+
this._core.store.state.activeText = object;
|
|
273
274
|
object.focus();
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
276
|
-
if (this._core.store.state.activeText !== null) {
|
|
277
|
+
if (this._core.store.state.activeText !== null && object instanceof KritzelText === false) {
|
|
277
278
|
this._core.resetActiveText();
|
|
278
279
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
279
280
|
return;
|
|
@@ -288,7 +289,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
288
289
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
289
290
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
290
291
|
text.zIndex = this._core.store.currentZIndex;
|
|
291
|
-
this._core.store.
|
|
292
|
+
this._core.store.state.activeText = text;
|
|
292
293
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
293
294
|
}
|
|
294
295
|
if (event.pointerType === 'touch') {
|
|
@@ -296,16 +297,17 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
296
297
|
const path = event.composedPath().slice(1);
|
|
297
298
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
298
299
|
const object = this._core.findObjectById(objectElement?.id);
|
|
299
|
-
if (
|
|
300
|
-
this._core.store.
|
|
300
|
+
if (object instanceof KritzelText) {
|
|
301
|
+
this._core.store.state.activeText = object;
|
|
301
302
|
object.focus();
|
|
302
303
|
return;
|
|
303
304
|
}
|
|
304
305
|
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
306
|
+
this._core.store.state.activeText = object;
|
|
305
307
|
object.focus();
|
|
306
308
|
return;
|
|
307
309
|
}
|
|
308
|
-
if (this._core.store.state.activeText !== null) {
|
|
310
|
+
if (this._core.store.state.activeText !== null && object instanceof KritzelText === false) {
|
|
309
311
|
this._core.resetActiveText();
|
|
310
312
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
311
313
|
return;
|
|
@@ -321,7 +323,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
321
323
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
322
324
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
323
325
|
text.zIndex = this._core.store.currentZIndex;
|
|
324
|
-
this._core.store.
|
|
326
|
+
this._core.store.state.activeText = text;
|
|
325
327
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
326
328
|
}
|
|
327
329
|
}
|
|
@@ -562,9 +564,15 @@ class KritzelBaseObject {
|
|
|
562
564
|
this.rotatedBoundingBox.y + this.rotatedBoundingBox.height > viewportBounds.y);
|
|
563
565
|
}
|
|
564
566
|
centerInViewport() {
|
|
565
|
-
const scale = this._core.store.state
|
|
566
|
-
|
|
567
|
-
|
|
567
|
+
const { viewportWidth, viewportHeight, translateX: viewportTranslateX, translateY: viewportTranslateY, scale: viewportScale } = this._core.store.state;
|
|
568
|
+
const { x, y, width, height } = this.rotatedBoundingBox;
|
|
569
|
+
const objectCenterX = x + width / 2;
|
|
570
|
+
const objectCenterY = y + height / 2;
|
|
571
|
+
const targetCenterX = (viewportWidth / 2 - viewportTranslateX) / viewportScale;
|
|
572
|
+
const targetCenterY = (viewportHeight / 2 - viewportTranslateY) / viewportScale;
|
|
573
|
+
const deltaX = targetCenterX - objectCenterX;
|
|
574
|
+
const deltaY = targetCenterY - objectCenterY;
|
|
575
|
+
this.updatePosition(this.translateX + deltaX, this.translateY + deltaY);
|
|
568
576
|
}
|
|
569
577
|
move(startX, startY, endX, endY) {
|
|
570
578
|
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
@@ -749,9 +757,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
749
757
|
const start = this.elementRef.selectionStart;
|
|
750
758
|
const end = this.elementRef.selectionEnd;
|
|
751
759
|
const value = this.elementRef.value;
|
|
752
|
-
this.
|
|
753
|
-
this.elementRef.
|
|
754
|
-
|
|
760
|
+
this.value = (value.substring(0, start) + text + value.substring(end)).trim();
|
|
761
|
+
this.elementRef.value = this.value;
|
|
762
|
+
const length = this.elementRef.value.length;
|
|
763
|
+
this.elementRef.setSelectionRange(length, length);
|
|
755
764
|
this.updateTextareaDimensions();
|
|
756
765
|
});
|
|
757
766
|
}
|
|
@@ -761,12 +770,12 @@ class KritzelText extends KritzelBaseObject {
|
|
|
761
770
|
}
|
|
762
771
|
}
|
|
763
772
|
edit() {
|
|
773
|
+
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
764
774
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
765
|
-
this._core.store.
|
|
775
|
+
this._core.store.state.activeText = this;
|
|
766
776
|
this._core.clearSelection();
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}, 300);
|
|
777
|
+
this.focus();
|
|
778
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
770
779
|
}
|
|
771
780
|
}
|
|
772
781
|
|
|
@@ -1128,17 +1137,17 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1128
1137
|
}
|
|
1129
1138
|
if (event.pointerType === 'mouse') {
|
|
1130
1139
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1131
|
-
this._core.store.
|
|
1140
|
+
this._core.store.state.isDrawing = true;
|
|
1132
1141
|
const x = event.clientX - this._core.store.offsetX;
|
|
1133
1142
|
const y = event.clientY - this._core.store.offsetY;
|
|
1134
|
-
this._core.store.
|
|
1143
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1135
1144
|
points: [[x, y]],
|
|
1136
1145
|
translateX: -this._core.store.state.translateX,
|
|
1137
1146
|
translateY: -this._core.store.state.translateY,
|
|
1138
1147
|
scale: this._core.store.state.scale,
|
|
1139
1148
|
fill: this.color,
|
|
1140
1149
|
strokeWidth: this.size,
|
|
1141
|
-
})
|
|
1150
|
+
});
|
|
1142
1151
|
}
|
|
1143
1152
|
}
|
|
1144
1153
|
if (event.pointerType === 'touch') {
|
|
@@ -1146,15 +1155,15 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1146
1155
|
if (activePointers.length === 1) {
|
|
1147
1156
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1148
1157
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1149
|
-
this._core.store.
|
|
1150
|
-
this._core.store.
|
|
1158
|
+
this._core.store.state.isDrawing = true;
|
|
1159
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1151
1160
|
points: [[x, y]],
|
|
1152
1161
|
translateX: -this._core.store.state.translateX,
|
|
1153
1162
|
translateY: -this._core.store.state.translateY,
|
|
1154
1163
|
scale: this._core.store.state.scale,
|
|
1155
1164
|
fill: this.color,
|
|
1156
1165
|
strokeWidth: this.size,
|
|
1157
|
-
})
|
|
1166
|
+
});
|
|
1158
1167
|
this._core.rerender();
|
|
1159
1168
|
}
|
|
1160
1169
|
}
|
|
@@ -1167,14 +1176,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1167
1176
|
if (this._core.store.state.isDrawing) {
|
|
1168
1177
|
const x = event.clientX - this._core.store.offsetX;
|
|
1169
1178
|
const y = event.clientY - this._core.store.offsetY;
|
|
1170
|
-
this._core.store.
|
|
1179
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1171
1180
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1172
1181
|
translateX: -this._core.store.state.translateX,
|
|
1173
1182
|
translateY: -this._core.store.state.translateY,
|
|
1174
1183
|
scale: this._core.store.state.scale,
|
|
1175
1184
|
fill: this.color,
|
|
1176
1185
|
strokeWidth: this.size,
|
|
1177
|
-
})
|
|
1186
|
+
});
|
|
1178
1187
|
this._core.rerender();
|
|
1179
1188
|
}
|
|
1180
1189
|
}
|
|
@@ -1183,14 +1192,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1183
1192
|
if (activePointers.length === 1) {
|
|
1184
1193
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1185
1194
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1186
|
-
this._core.store.
|
|
1195
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1187
1196
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1188
1197
|
translateX: -this._core.store.state.translateX,
|
|
1189
1198
|
translateY: -this._core.store.state.translateY,
|
|
1190
1199
|
scale: this._core.store.state.scale,
|
|
1191
1200
|
fill: this.color,
|
|
1192
1201
|
strokeWidth: this.size,
|
|
1193
|
-
})
|
|
1202
|
+
});
|
|
1194
1203
|
this._core.rerender();
|
|
1195
1204
|
}
|
|
1196
1205
|
}
|
|
@@ -1201,26 +1210,26 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1201
1210
|
}
|
|
1202
1211
|
if (event.pointerType === 'mouse') {
|
|
1203
1212
|
if (this._core.store.state.isDrawing) {
|
|
1204
|
-
this._core.store.
|
|
1213
|
+
this._core.store.state.isDrawing = false;
|
|
1205
1214
|
if (this._core.store.state.currentPath) {
|
|
1206
1215
|
const currentPath = this._core.store.state.currentPath;
|
|
1207
1216
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1208
|
-
this._core.store.
|
|
1217
|
+
this._core.store.state.currentPath = currentPath;
|
|
1209
1218
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
|
|
1210
1219
|
}
|
|
1211
|
-
this._core.store.
|
|
1220
|
+
this._core.store.state.currentPath = undefined;
|
|
1212
1221
|
}
|
|
1213
1222
|
}
|
|
1214
1223
|
if (event.pointerType === 'touch') {
|
|
1215
1224
|
if (this._core.store.state.isDrawing) {
|
|
1216
|
-
this._core.store.
|
|
1225
|
+
this._core.store.state.isDrawing = false;
|
|
1217
1226
|
if (this._core.store.state.currentPath) {
|
|
1218
1227
|
const currentPath = this._core.store.state.currentPath;
|
|
1219
1228
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1220
|
-
this._core.store.
|
|
1229
|
+
this._core.store.state.currentPath = currentPath;
|
|
1221
1230
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, currentPath));
|
|
1222
1231
|
}
|
|
1223
|
-
this._core.store.
|
|
1232
|
+
this._core.store.state.currentPath = undefined;
|
|
1224
1233
|
this._core.rerender();
|
|
1225
1234
|
}
|
|
1226
1235
|
}
|
|
@@ -1320,13 +1329,13 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1320
1329
|
handlePointerDown(event) {
|
|
1321
1330
|
if (event.pointerType === 'mouse') {
|
|
1322
1331
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1323
|
-
this._core.store.
|
|
1332
|
+
this._core.store.state.isErasing = true;
|
|
1324
1333
|
}
|
|
1325
1334
|
}
|
|
1326
1335
|
if (event.pointerType === 'touch') {
|
|
1327
1336
|
this.touchStartTimeout = setTimeout(() => {
|
|
1328
1337
|
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
1329
|
-
this._core.store.
|
|
1338
|
+
this._core.store.state.isErasing = true;
|
|
1330
1339
|
}
|
|
1331
1340
|
}, 80);
|
|
1332
1341
|
}
|
|
@@ -1372,7 +1381,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1372
1381
|
if (removeCommands.length > 0) {
|
|
1373
1382
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1374
1383
|
}
|
|
1375
|
-
this._core.store.
|
|
1384
|
+
this._core.store.state.isErasing = false;
|
|
1376
1385
|
}
|
|
1377
1386
|
}
|
|
1378
1387
|
if (event.pointerType === 'touch') {
|
|
@@ -1387,7 +1396,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1387
1396
|
if (removeCommands.length > 0) {
|
|
1388
1397
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1389
1398
|
}
|
|
1390
|
-
this._core.store.
|
|
1399
|
+
this._core.store.state.isErasing = false;
|
|
1391
1400
|
}
|
|
1392
1401
|
}
|
|
1393
1402
|
}
|
|
@@ -1401,12 +1410,12 @@ class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1401
1410
|
}
|
|
1402
1411
|
execute() {
|
|
1403
1412
|
this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
|
|
1404
|
-
this._core.store.
|
|
1413
|
+
this._core.store.state.selectionGroup = null;
|
|
1405
1414
|
}
|
|
1406
1415
|
undo() {
|
|
1407
1416
|
if (this.previousSelectionGroup) {
|
|
1408
1417
|
this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
|
|
1409
|
-
this._core.store.
|
|
1418
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1410
1419
|
}
|
|
1411
1420
|
}
|
|
1412
1421
|
}
|
|
@@ -1437,7 +1446,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1437
1446
|
});
|
|
1438
1447
|
return;
|
|
1439
1448
|
}
|
|
1440
|
-
this._core.store.
|
|
1449
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1441
1450
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1442
1451
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1443
1452
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1445,7 +1454,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1445
1454
|
});
|
|
1446
1455
|
}
|
|
1447
1456
|
undo() {
|
|
1448
|
-
this._core.store.
|
|
1457
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1449
1458
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1450
1459
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1451
1460
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1469,6 +1478,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1469
1478
|
endX;
|
|
1470
1479
|
endY;
|
|
1471
1480
|
hasMoved = false;
|
|
1481
|
+
trackedPointerId = null;
|
|
1472
1482
|
constructor(core) {
|
|
1473
1483
|
super(core);
|
|
1474
1484
|
}
|
|
@@ -1480,6 +1490,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1480
1490
|
this.endX = 0;
|
|
1481
1491
|
this.endY = 0;
|
|
1482
1492
|
this.hasMoved = false;
|
|
1493
|
+
this.trackedPointerId = null;
|
|
1494
|
+
}
|
|
1495
|
+
cancelPendingDrag() {
|
|
1496
|
+
this._core.store.state.isDragging = false;
|
|
1497
|
+
this.reset();
|
|
1483
1498
|
}
|
|
1484
1499
|
handlePointerDown(event) {
|
|
1485
1500
|
if (event.pointerType === 'mouse') {
|
|
@@ -1487,12 +1502,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1487
1502
|
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
1488
1503
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1489
1504
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1490
|
-
this._core.store.
|
|
1505
|
+
this._core.store.state.isDragging = true;
|
|
1491
1506
|
this.dragStartX = clientX;
|
|
1492
1507
|
this.dragStartY = clientY;
|
|
1493
1508
|
this.startX = this.dragStartX;
|
|
1494
1509
|
this.startY = this.dragStartY;
|
|
1510
|
+
this.trackedPointerId = event.pointerId;
|
|
1495
1511
|
}
|
|
1512
|
+
else {
|
|
1513
|
+
this.trackedPointerId = null;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
else {
|
|
1517
|
+
this.trackedPointerId = null;
|
|
1496
1518
|
}
|
|
1497
1519
|
}
|
|
1498
1520
|
if (event.pointerType === 'touch') {
|
|
@@ -1505,11 +1527,18 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1505
1527
|
this.dragStartY = y;
|
|
1506
1528
|
this.startX = x;
|
|
1507
1529
|
this.startY = y;
|
|
1530
|
+
this.trackedPointerId = event.pointerId;
|
|
1531
|
+
}
|
|
1532
|
+
else {
|
|
1533
|
+
this.trackedPointerId = null;
|
|
1508
1534
|
}
|
|
1509
1535
|
}
|
|
1510
1536
|
}
|
|
1511
1537
|
}
|
|
1512
1538
|
handlePointerMove(event) {
|
|
1539
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1513
1542
|
if (event.pointerType === 'mouse') {
|
|
1514
1543
|
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
1515
1544
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
@@ -1530,7 +1559,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1530
1559
|
!this._core.store.state.isRotationHandleSelected) {
|
|
1531
1560
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1532
1561
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1533
|
-
this._core.store.
|
|
1562
|
+
this._core.store.state.isDragging = true;
|
|
1534
1563
|
this.endX = x;
|
|
1535
1564
|
this.endY = y;
|
|
1536
1565
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
@@ -1547,24 +1576,28 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1547
1576
|
}
|
|
1548
1577
|
}
|
|
1549
1578
|
handlePointerUp(event) {
|
|
1579
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1550
1582
|
if (event.pointerType === 'mouse') {
|
|
1551
1583
|
if (this._core.store.state.isDragging) {
|
|
1552
|
-
this._core.store.
|
|
1584
|
+
this._core.store.state.isDragging = false;
|
|
1553
1585
|
if (this.hasMoved) {
|
|
1554
1586
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1587
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1555
1588
|
}
|
|
1556
|
-
this.reset();
|
|
1557
1589
|
}
|
|
1558
1590
|
}
|
|
1559
1591
|
if (event.pointerType === 'touch') {
|
|
1560
1592
|
if (this._core.store.state.isDragging) {
|
|
1561
|
-
this._core.store.
|
|
1593
|
+
this._core.store.state.isDragging = false;
|
|
1562
1594
|
if (this.hasMoved) {
|
|
1563
1595
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1596
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1564
1597
|
}
|
|
1565
|
-
this.reset();
|
|
1566
1598
|
}
|
|
1567
1599
|
}
|
|
1600
|
+
this.reset();
|
|
1568
1601
|
}
|
|
1569
1602
|
}
|
|
1570
1603
|
|
|
@@ -1587,7 +1620,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1587
1620
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1588
1621
|
}
|
|
1589
1622
|
execute() {
|
|
1590
|
-
this._core.store.
|
|
1623
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1591
1624
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1592
1625
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1593
1626
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1595,7 +1628,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1595
1628
|
});
|
|
1596
1629
|
}
|
|
1597
1630
|
undo() {
|
|
1598
|
-
this._core.store.
|
|
1631
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1599
1632
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1600
1633
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1601
1634
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1624,7 +1657,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1624
1657
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1625
1658
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1626
1659
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1627
|
-
this._core.store.
|
|
1660
|
+
this._core.store.state.isResizing = true;
|
|
1628
1661
|
this.initialMouseX = clientX;
|
|
1629
1662
|
this.initialMouseY = clientY;
|
|
1630
1663
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1644,7 +1677,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1644
1677
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1645
1678
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1646
1679
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1647
|
-
this._core.store.
|
|
1680
|
+
this._core.store.state.isResizing = true;
|
|
1648
1681
|
this.initialMouseX = clientX;
|
|
1649
1682
|
this.initialMouseY = clientY;
|
|
1650
1683
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1738,14 +1771,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1738
1771
|
if (event.pointerType === 'mouse') {
|
|
1739
1772
|
if (this._core.store.state.isResizing) {
|
|
1740
1773
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1741
|
-
this._core.store.
|
|
1774
|
+
this._core.store.state.isResizing = false;
|
|
1775
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1742
1776
|
this.reset();
|
|
1743
1777
|
}
|
|
1744
1778
|
}
|
|
1745
1779
|
if (event.pointerType === 'touch') {
|
|
1746
1780
|
if (this._core.store.state.isResizing) {
|
|
1747
1781
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1748
|
-
this._core.store.
|
|
1782
|
+
this._core.store.state.isResizing = false;
|
|
1783
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1749
1784
|
this.reset();
|
|
1750
1785
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1751
1786
|
}
|
|
@@ -1764,7 +1799,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1764
1799
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1765
1800
|
}
|
|
1766
1801
|
execute() {
|
|
1767
|
-
this._core.store.
|
|
1802
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1768
1803
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1769
1804
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1770
1805
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1772,7 +1807,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1772
1807
|
});
|
|
1773
1808
|
}
|
|
1774
1809
|
undo() {
|
|
1775
|
-
this._core.store.
|
|
1810
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1776
1811
|
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1777
1812
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1778
1813
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1800,7 +1835,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1800
1835
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1801
1836
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1802
1837
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1803
|
-
this._core.store.
|
|
1838
|
+
this._core.store.state.isRotating = true;
|
|
1804
1839
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1805
1840
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1806
1841
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1821,7 +1856,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1821
1856
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1822
1857
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1823
1858
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1824
|
-
this._core.store.
|
|
1859
|
+
this._core.store.state.isRotating = true;
|
|
1825
1860
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1826
1861
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1827
1862
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1872,14 +1907,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1872
1907
|
if (event.pointerType === 'mouse') {
|
|
1873
1908
|
if (this._core.store.state.isRotating) {
|
|
1874
1909
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1875
|
-
this._core.store.
|
|
1910
|
+
this._core.store.state.isRotating = false;
|
|
1911
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1876
1912
|
this.reset();
|
|
1877
1913
|
}
|
|
1878
1914
|
}
|
|
1879
1915
|
if (event.pointerType === 'touch') {
|
|
1880
1916
|
if (this._core.store.state.isRotating) {
|
|
1881
1917
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1882
|
-
this._core.store.
|
|
1918
|
+
this._core.store.state.isRotating = false;
|
|
1919
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1883
1920
|
this.reset();
|
|
1884
1921
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1885
1922
|
}
|
|
@@ -1917,13 +1954,13 @@ class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1917
1954
|
execute() {
|
|
1918
1955
|
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox || object instanceof KritzelSelectionGroup);
|
|
1919
1956
|
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
1920
|
-
this._core.store.
|
|
1921
|
-
this._core.store.
|
|
1957
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1958
|
+
this._core.store.state.selectionBox = null;
|
|
1922
1959
|
}
|
|
1923
1960
|
undo() {
|
|
1924
1961
|
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
1925
|
-
this._core.store.
|
|
1926
|
-
this._core.store.
|
|
1962
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1963
|
+
this._core.store.state.selectionBox = null;
|
|
1927
1964
|
}
|
|
1928
1965
|
}
|
|
1929
1966
|
|
|
@@ -1978,43 +2015,47 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1978
2015
|
}
|
|
1979
2016
|
handlePointerUp(event) {
|
|
1980
2017
|
if (event.pointerType === 'mouse') {
|
|
1981
|
-
if (KritzelEventHelper.isLeftClick(event)
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
1986
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
1987
|
-
this.removeSelectionBox();
|
|
2018
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
2019
|
+
const hasObjectsMoved = this._core.store.state.hasObjectsChanged;
|
|
2020
|
+
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
2021
|
+
this._core.store.state.selectionGroup.objects[0].edit();
|
|
1988
2022
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
this.
|
|
1992
|
-
|
|
2023
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
2024
|
+
if (this._core.store.state.isSelecting) {
|
|
2025
|
+
if (this.isSelectionClick) {
|
|
2026
|
+
this.handleSelectionClick(event);
|
|
2027
|
+
}
|
|
2028
|
+
if (this.isSelectionDrag) {
|
|
2029
|
+
this.updateMouseSelection(event);
|
|
2030
|
+
this.addSelectedObjectsToSelectionGroup();
|
|
2031
|
+
this.removeSelectionBox();
|
|
2032
|
+
}
|
|
1993
2033
|
}
|
|
1994
2034
|
}
|
|
1995
2035
|
}
|
|
1996
2036
|
if (event.pointerType === 'touch') {
|
|
1997
2037
|
clearTimeout(this.touchStartTimeout);
|
|
2038
|
+
const hasObjectsMoved = this._core.store.state.hasObjectsChanged;
|
|
2039
|
+
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
2040
|
+
this._core.store.state.selectionGroup.objects[0].edit();
|
|
2041
|
+
}
|
|
2042
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
1998
2043
|
if (this._core.store.state.isSelecting) {
|
|
1999
2044
|
if (this.isSelectionClick) {
|
|
2000
|
-
|
|
2001
|
-
const y = this._core.store.state.pointerY;
|
|
2002
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
2003
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
2004
|
-
this.removeSelectionBox();
|
|
2045
|
+
this.handleSelectionClick(event);
|
|
2005
2046
|
}
|
|
2006
2047
|
if (this.isSelectionDrag) {
|
|
2007
2048
|
this.updateTouchSelection();
|
|
2008
2049
|
this.addSelectedObjectsToSelectionGroup();
|
|
2009
2050
|
this.removeSelectionBox();
|
|
2010
2051
|
}
|
|
2011
|
-
this._core.store.
|
|
2052
|
+
this._core.store.state.skipContextMenu = false;
|
|
2012
2053
|
}
|
|
2013
2054
|
}
|
|
2014
2055
|
}
|
|
2015
2056
|
removeSelectionBox() {
|
|
2016
|
-
this._core.store.
|
|
2017
|
-
this._core.store.
|
|
2057
|
+
this._core.store.state.selectionBox = null;
|
|
2058
|
+
this._core.store.state.isSelecting = false;
|
|
2018
2059
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
|
|
2019
2060
|
}
|
|
2020
2061
|
startMouseSelection(event) {
|
|
@@ -2026,9 +2067,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2026
2067
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2027
2068
|
selectionBox.translateX = this.startX;
|
|
2028
2069
|
selectionBox.translateY = this.startY;
|
|
2029
|
-
this._core.store.
|
|
2030
|
-
this._core.store.
|
|
2031
|
-
this._core.store.
|
|
2070
|
+
this._core.store.state.selectionGroup = null;
|
|
2071
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2072
|
+
this._core.store.state.isSelecting = true;
|
|
2032
2073
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2033
2074
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2034
2075
|
}
|
|
@@ -2048,9 +2089,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2048
2089
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2049
2090
|
selectionBox.translateX = this.startX;
|
|
2050
2091
|
selectionBox.translateY = this.startY;
|
|
2051
|
-
this._core.store.
|
|
2052
|
-
this._core.store.
|
|
2053
|
-
this._core.store.
|
|
2092
|
+
this._core.store.state.selectionGroup = null;
|
|
2093
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2094
|
+
this._core.store.state.isSelecting = true;
|
|
2054
2095
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2055
2096
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2056
2097
|
}
|
|
@@ -2062,11 +2103,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2062
2103
|
if (selectionBox) {
|
|
2063
2104
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2064
2105
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2065
|
-
|
|
2066
|
-
|
|
2106
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2107
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2108
|
+
selectionBox.width = width;
|
|
2109
|
+
selectionBox.height = height;
|
|
2067
2110
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2068
2111
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2069
|
-
|
|
2112
|
+
if (width > 0 || height > 0) {
|
|
2113
|
+
this.updateSelectedObjects();
|
|
2114
|
+
}
|
|
2115
|
+
else {
|
|
2116
|
+
this.clearSelectionPreview();
|
|
2117
|
+
}
|
|
2070
2118
|
}
|
|
2071
2119
|
}
|
|
2072
2120
|
updateTouchSelection() {
|
|
@@ -2082,11 +2130,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2082
2130
|
if (selectionBox) {
|
|
2083
2131
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2084
2132
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2085
|
-
|
|
2086
|
-
|
|
2133
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2134
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2135
|
+
selectionBox.width = width;
|
|
2136
|
+
selectionBox.height = height;
|
|
2087
2137
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2088
2138
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2089
|
-
|
|
2139
|
+
if (width > 0 || height > 0) {
|
|
2140
|
+
this.updateSelectedObjects();
|
|
2141
|
+
}
|
|
2142
|
+
else {
|
|
2143
|
+
this.clearSelectionPreview();
|
|
2144
|
+
}
|
|
2090
2145
|
}
|
|
2091
2146
|
}
|
|
2092
2147
|
updateSelectedObjects() {
|
|
@@ -2094,6 +2149,28 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2094
2149
|
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
2095
2150
|
.forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
|
|
2096
2151
|
}
|
|
2152
|
+
handleSelectionClick(event) {
|
|
2153
|
+
const selectedObject = this.getTopmostHitObject(event);
|
|
2154
|
+
this.clearSelectionPreview();
|
|
2155
|
+
this.addObjectToSelectionGroup(selectedObject);
|
|
2156
|
+
this.removeSelectionBox();
|
|
2157
|
+
}
|
|
2158
|
+
getTopmostHitObject(event) {
|
|
2159
|
+
const pointerX = this._core.store.state.pointerX;
|
|
2160
|
+
const pointerY = this._core.store.state.pointerY;
|
|
2161
|
+
const overlappingObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
2162
|
+
for (const object of overlappingObjects) {
|
|
2163
|
+
if (object.hitTest(pointerX, pointerY)) {
|
|
2164
|
+
return object;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
return null;
|
|
2168
|
+
}
|
|
2169
|
+
clearSelectionPreview() {
|
|
2170
|
+
this._core.store.allNonSelectionObjects.forEach(object => {
|
|
2171
|
+
object.isSelected = false;
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2097
2174
|
addObjectToSelectionGroup(object) {
|
|
2098
2175
|
if (!object) {
|
|
2099
2176
|
return;
|
|
@@ -2110,7 +2187,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2110
2187
|
if (selectedObjects.length === 0) {
|
|
2111
2188
|
return;
|
|
2112
2189
|
}
|
|
2113
|
-
this._core.store.
|
|
2190
|
+
this._core.store.state.selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2114
2191
|
selectedObjects.forEach(o => {
|
|
2115
2192
|
this._core.store.state.selectionGroup.addOrRemove(o);
|
|
2116
2193
|
o.isSelected = false;
|
|
@@ -2160,9 +2237,9 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2160
2237
|
}
|
|
2161
2238
|
if (event.pointerType === 'mouse') {
|
|
2162
2239
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
2163
|
-
this._core.store.
|
|
2164
|
-
this._core.store.
|
|
2165
|
-
this._core.store.
|
|
2240
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
2241
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
2242
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
2166
2243
|
const selectedObject = this.getSelectedObject(event);
|
|
2167
2244
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2168
2245
|
if ((selectedObject === null || isDifferentObject) &&
|
|
@@ -2186,13 +2263,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2186
2263
|
return;
|
|
2187
2264
|
}
|
|
2188
2265
|
if (this._core.store.state.pointers.size === 1) {
|
|
2189
|
-
this._core.store.
|
|
2190
|
-
this._core.store.
|
|
2191
|
-
this._core.store.
|
|
2266
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
2267
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
2268
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
2192
2269
|
const selectedObject = this.getSelectedObject(event);
|
|
2193
2270
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2194
2271
|
if (!this._core.store.state.selectionGroup && selectedObject) {
|
|
2195
|
-
this._core.store.
|
|
2272
|
+
this._core.store.state.skipContextMenu = true;
|
|
2196
2273
|
}
|
|
2197
2274
|
if ((selectedObject === null || isDifferentObject) &&
|
|
2198
2275
|
this._core.store.state.selectionGroup &&
|
|
@@ -2237,9 +2314,9 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2237
2314
|
}
|
|
2238
2315
|
if (event.pointerType === 'mouse') {
|
|
2239
2316
|
this.moveHandler.handlePointerUp(event);
|
|
2240
|
-
this.selectionHandler.handlePointerUp(event);
|
|
2241
2317
|
this.resizeHandler.handlePointerUp(event);
|
|
2242
2318
|
this.rotationHandler.handlePointerUp(event);
|
|
2319
|
+
this.selectionHandler.handlePointerUp(event);
|
|
2243
2320
|
this._core.rerender();
|
|
2244
2321
|
}
|
|
2245
2322
|
if (event.pointerType === 'touch') {
|
|
@@ -2597,7 +2674,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2597
2674
|
}
|
|
2598
2675
|
copy() {
|
|
2599
2676
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2600
|
-
this.objects
|
|
2677
|
+
this.objects
|
|
2678
|
+
.sort((a, b) => a.zIndex - b.zIndex)
|
|
2679
|
+
.forEach(obj => {
|
|
2601
2680
|
const copiedObject = obj.copy();
|
|
2602
2681
|
selectionGroup.addOrRemove(copiedObject);
|
|
2603
2682
|
});
|
|
@@ -2766,6 +2845,6 @@ exports.ObjectHelper = ObjectHelper;
|
|
|
2766
2845
|
exports.RemoveObjectCommand = RemoveObjectCommand;
|
|
2767
2846
|
exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
|
|
2768
2847
|
exports.UpdateObjectCommand = UpdateObjectCommand;
|
|
2769
|
-
//# sourceMappingURL=index-
|
|
2848
|
+
//# sourceMappingURL=index-Clh2g9JM.js.map
|
|
2770
2849
|
|
|
2771
|
-
//# sourceMappingURL=index-
|
|
2850
|
+
//# sourceMappingURL=index-Clh2g9JM.js.map
|