kritzel-stencil 0.0.139 → 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-DgZMn9B_.js → index-Clh2g9JM.js} +162 -103
- 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 +182 -135
- 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 -8
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +6 -6
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +6 -6
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +56 -28
- 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 +5 -4
- 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 +7 -7
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +6 -6
- 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 +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +18 -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/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 -20
- 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-KudVTtHk.js → p-BV5iL9W6.js} +283 -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-BbGgijCS.js → p-C5sTCwe3.js} +38 -31
- 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-CHdJi6b4.js → p-SKH0G2nM.js} +16 -16
- package/dist/components/{p-CHdJi6b4.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-CxieEK_G.js → index-BAbkwyRx.js} +163 -104
- package/dist/esm/index-BAbkwyRx.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +182 -135
- 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/package.json +1 -1
- package/dist/cjs/index-DgZMn9B_.js.map +0 -1
- package/dist/components/p-BbGgijCS.js.map +0 -1
- package/dist/components/p-BgpsMYcw.js.map +0 -1
- package/dist/components/p-KudVTtHk.js.map +0 -1
- package/dist/esm/index-CxieEK_G.js.map +0 -1
- package/dist/stencil/p-CxieEK_G.js +0 -2
- package/dist/stencil/p-CxieEK_G.js.map +0 -1
- package/dist/stencil/p-ab074e87.entry.js +0 -2
- package/dist/stencil/p-ab074e87.entry.js.map +0 -1
|
@@ -265,12 +265,12 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
265
265
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
266
266
|
const object = this._core.findObjectById(objectElement?.id);
|
|
267
267
|
if (object instanceof KritzelText) {
|
|
268
|
-
this._core.store.
|
|
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.
|
|
273
|
+
this._core.store.state.activeText = object;
|
|
274
274
|
object.focus();
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
@@ -289,7 +289,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
289
289
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
290
290
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
291
291
|
text.zIndex = this._core.store.currentZIndex;
|
|
292
|
-
this._core.store.
|
|
292
|
+
this._core.store.state.activeText = text;
|
|
293
293
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
294
294
|
}
|
|
295
295
|
if (event.pointerType === 'touch') {
|
|
@@ -298,12 +298,12 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
298
298
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
299
299
|
const object = this._core.findObjectById(objectElement?.id);
|
|
300
300
|
if (object instanceof KritzelText) {
|
|
301
|
-
this._core.store.
|
|
301
|
+
this._core.store.state.activeText = object;
|
|
302
302
|
object.focus();
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
305
|
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
306
|
-
this._core.store.
|
|
306
|
+
this._core.store.state.activeText = object;
|
|
307
307
|
object.focus();
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
@@ -323,7 +323,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
323
323
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
324
324
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
325
325
|
text.zIndex = this._core.store.currentZIndex;
|
|
326
|
-
this._core.store.
|
|
326
|
+
this._core.store.state.activeText = text;
|
|
327
327
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
328
328
|
}
|
|
329
329
|
}
|
|
@@ -564,9 +564,15 @@ class KritzelBaseObject {
|
|
|
564
564
|
this.rotatedBoundingBox.y + this.rotatedBoundingBox.height > viewportBounds.y);
|
|
565
565
|
}
|
|
566
566
|
centerInViewport() {
|
|
567
|
-
const scale = this._core.store.state
|
|
568
|
-
|
|
569
|
-
|
|
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);
|
|
570
576
|
}
|
|
571
577
|
move(startX, startY, endX, endY) {
|
|
572
578
|
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
@@ -751,9 +757,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
751
757
|
const start = this.elementRef.selectionStart;
|
|
752
758
|
const end = this.elementRef.selectionEnd;
|
|
753
759
|
const value = this.elementRef.value;
|
|
754
|
-
this.
|
|
755
|
-
this.elementRef.
|
|
756
|
-
|
|
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);
|
|
757
764
|
this.updateTextareaDimensions();
|
|
758
765
|
});
|
|
759
766
|
}
|
|
@@ -765,7 +772,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
765
772
|
edit() {
|
|
766
773
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
767
774
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
768
|
-
this._core.store.
|
|
775
|
+
this._core.store.state.activeText = this;
|
|
769
776
|
this._core.clearSelection();
|
|
770
777
|
this.focus();
|
|
771
778
|
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
@@ -1130,17 +1137,17 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1130
1137
|
}
|
|
1131
1138
|
if (event.pointerType === 'mouse') {
|
|
1132
1139
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1133
|
-
this._core.store.
|
|
1140
|
+
this._core.store.state.isDrawing = true;
|
|
1134
1141
|
const x = event.clientX - this._core.store.offsetX;
|
|
1135
1142
|
const y = event.clientY - this._core.store.offsetY;
|
|
1136
|
-
this._core.store.
|
|
1143
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1137
1144
|
points: [[x, y]],
|
|
1138
1145
|
translateX: -this._core.store.state.translateX,
|
|
1139
1146
|
translateY: -this._core.store.state.translateY,
|
|
1140
1147
|
scale: this._core.store.state.scale,
|
|
1141
1148
|
fill: this.color,
|
|
1142
1149
|
strokeWidth: this.size,
|
|
1143
|
-
})
|
|
1150
|
+
});
|
|
1144
1151
|
}
|
|
1145
1152
|
}
|
|
1146
1153
|
if (event.pointerType === 'touch') {
|
|
@@ -1148,15 +1155,15 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1148
1155
|
if (activePointers.length === 1) {
|
|
1149
1156
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1150
1157
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1151
|
-
this._core.store.
|
|
1152
|
-
this._core.store.
|
|
1158
|
+
this._core.store.state.isDrawing = true;
|
|
1159
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1153
1160
|
points: [[x, y]],
|
|
1154
1161
|
translateX: -this._core.store.state.translateX,
|
|
1155
1162
|
translateY: -this._core.store.state.translateY,
|
|
1156
1163
|
scale: this._core.store.state.scale,
|
|
1157
1164
|
fill: this.color,
|
|
1158
1165
|
strokeWidth: this.size,
|
|
1159
|
-
})
|
|
1166
|
+
});
|
|
1160
1167
|
this._core.rerender();
|
|
1161
1168
|
}
|
|
1162
1169
|
}
|
|
@@ -1169,14 +1176,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1169
1176
|
if (this._core.store.state.isDrawing) {
|
|
1170
1177
|
const x = event.clientX - this._core.store.offsetX;
|
|
1171
1178
|
const y = event.clientY - this._core.store.offsetY;
|
|
1172
|
-
this._core.store.
|
|
1179
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1173
1180
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1174
1181
|
translateX: -this._core.store.state.translateX,
|
|
1175
1182
|
translateY: -this._core.store.state.translateY,
|
|
1176
1183
|
scale: this._core.store.state.scale,
|
|
1177
1184
|
fill: this.color,
|
|
1178
1185
|
strokeWidth: this.size,
|
|
1179
|
-
})
|
|
1186
|
+
});
|
|
1180
1187
|
this._core.rerender();
|
|
1181
1188
|
}
|
|
1182
1189
|
}
|
|
@@ -1185,14 +1192,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1185
1192
|
if (activePointers.length === 1) {
|
|
1186
1193
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1187
1194
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1188
|
-
this._core.store.
|
|
1195
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1189
1196
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1190
1197
|
translateX: -this._core.store.state.translateX,
|
|
1191
1198
|
translateY: -this._core.store.state.translateY,
|
|
1192
1199
|
scale: this._core.store.state.scale,
|
|
1193
1200
|
fill: this.color,
|
|
1194
1201
|
strokeWidth: this.size,
|
|
1195
|
-
})
|
|
1202
|
+
});
|
|
1196
1203
|
this._core.rerender();
|
|
1197
1204
|
}
|
|
1198
1205
|
}
|
|
@@ -1203,26 +1210,26 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1203
1210
|
}
|
|
1204
1211
|
if (event.pointerType === 'mouse') {
|
|
1205
1212
|
if (this._core.store.state.isDrawing) {
|
|
1206
|
-
this._core.store.
|
|
1213
|
+
this._core.store.state.isDrawing = false;
|
|
1207
1214
|
if (this._core.store.state.currentPath) {
|
|
1208
1215
|
const currentPath = this._core.store.state.currentPath;
|
|
1209
1216
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1210
|
-
this._core.store.
|
|
1217
|
+
this._core.store.state.currentPath = currentPath;
|
|
1211
1218
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
|
|
1212
1219
|
}
|
|
1213
|
-
this._core.store.
|
|
1220
|
+
this._core.store.state.currentPath = undefined;
|
|
1214
1221
|
}
|
|
1215
1222
|
}
|
|
1216
1223
|
if (event.pointerType === 'touch') {
|
|
1217
1224
|
if (this._core.store.state.isDrawing) {
|
|
1218
|
-
this._core.store.
|
|
1225
|
+
this._core.store.state.isDrawing = false;
|
|
1219
1226
|
if (this._core.store.state.currentPath) {
|
|
1220
1227
|
const currentPath = this._core.store.state.currentPath;
|
|
1221
1228
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1222
|
-
this._core.store.
|
|
1229
|
+
this._core.store.state.currentPath = currentPath;
|
|
1223
1230
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, currentPath));
|
|
1224
1231
|
}
|
|
1225
|
-
this._core.store.
|
|
1232
|
+
this._core.store.state.currentPath = undefined;
|
|
1226
1233
|
this._core.rerender();
|
|
1227
1234
|
}
|
|
1228
1235
|
}
|
|
@@ -1322,13 +1329,13 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1322
1329
|
handlePointerDown(event) {
|
|
1323
1330
|
if (event.pointerType === 'mouse') {
|
|
1324
1331
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1325
|
-
this._core.store.
|
|
1332
|
+
this._core.store.state.isErasing = true;
|
|
1326
1333
|
}
|
|
1327
1334
|
}
|
|
1328
1335
|
if (event.pointerType === 'touch') {
|
|
1329
1336
|
this.touchStartTimeout = setTimeout(() => {
|
|
1330
1337
|
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
1331
|
-
this._core.store.
|
|
1338
|
+
this._core.store.state.isErasing = true;
|
|
1332
1339
|
}
|
|
1333
1340
|
}, 80);
|
|
1334
1341
|
}
|
|
@@ -1374,7 +1381,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1374
1381
|
if (removeCommands.length > 0) {
|
|
1375
1382
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1376
1383
|
}
|
|
1377
|
-
this._core.store.
|
|
1384
|
+
this._core.store.state.isErasing = false;
|
|
1378
1385
|
}
|
|
1379
1386
|
}
|
|
1380
1387
|
if (event.pointerType === 'touch') {
|
|
@@ -1389,7 +1396,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1389
1396
|
if (removeCommands.length > 0) {
|
|
1390
1397
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1391
1398
|
}
|
|
1392
|
-
this._core.store.
|
|
1399
|
+
this._core.store.state.isErasing = false;
|
|
1393
1400
|
}
|
|
1394
1401
|
}
|
|
1395
1402
|
}
|
|
@@ -1403,12 +1410,12 @@ class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1403
1410
|
}
|
|
1404
1411
|
execute() {
|
|
1405
1412
|
this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
|
|
1406
|
-
this._core.store.
|
|
1413
|
+
this._core.store.state.selectionGroup = null;
|
|
1407
1414
|
}
|
|
1408
1415
|
undo() {
|
|
1409
1416
|
if (this.previousSelectionGroup) {
|
|
1410
1417
|
this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
|
|
1411
|
-
this._core.store.
|
|
1418
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1412
1419
|
}
|
|
1413
1420
|
}
|
|
1414
1421
|
}
|
|
@@ -1439,7 +1446,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1439
1446
|
});
|
|
1440
1447
|
return;
|
|
1441
1448
|
}
|
|
1442
|
-
this._core.store.
|
|
1449
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1443
1450
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1444
1451
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1445
1452
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1447,7 +1454,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1447
1454
|
});
|
|
1448
1455
|
}
|
|
1449
1456
|
undo() {
|
|
1450
|
-
this._core.store.
|
|
1457
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1451
1458
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1452
1459
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1453
1460
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1471,6 +1478,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1471
1478
|
endX;
|
|
1472
1479
|
endY;
|
|
1473
1480
|
hasMoved = false;
|
|
1481
|
+
trackedPointerId = null;
|
|
1474
1482
|
constructor(core) {
|
|
1475
1483
|
super(core);
|
|
1476
1484
|
}
|
|
@@ -1482,6 +1490,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1482
1490
|
this.endX = 0;
|
|
1483
1491
|
this.endY = 0;
|
|
1484
1492
|
this.hasMoved = false;
|
|
1493
|
+
this.trackedPointerId = null;
|
|
1494
|
+
}
|
|
1495
|
+
cancelPendingDrag() {
|
|
1496
|
+
this._core.store.state.isDragging = false;
|
|
1497
|
+
this.reset();
|
|
1485
1498
|
}
|
|
1486
1499
|
handlePointerDown(event) {
|
|
1487
1500
|
if (event.pointerType === 'mouse') {
|
|
@@ -1489,13 +1502,20 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1489
1502
|
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
1490
1503
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1491
1504
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1492
|
-
this._core.store.
|
|
1505
|
+
this._core.store.state.isDragging = true;
|
|
1493
1506
|
this.dragStartX = clientX;
|
|
1494
1507
|
this.dragStartY = clientY;
|
|
1495
1508
|
this.startX = this.dragStartX;
|
|
1496
1509
|
this.startY = this.dragStartY;
|
|
1510
|
+
this.trackedPointerId = event.pointerId;
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
this.trackedPointerId = null;
|
|
1497
1514
|
}
|
|
1498
1515
|
}
|
|
1516
|
+
else {
|
|
1517
|
+
this.trackedPointerId = null;
|
|
1518
|
+
}
|
|
1499
1519
|
}
|
|
1500
1520
|
if (event.pointerType === 'touch') {
|
|
1501
1521
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
@@ -1507,11 +1527,18 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1507
1527
|
this.dragStartY = y;
|
|
1508
1528
|
this.startX = x;
|
|
1509
1529
|
this.startY = y;
|
|
1530
|
+
this.trackedPointerId = event.pointerId;
|
|
1531
|
+
}
|
|
1532
|
+
else {
|
|
1533
|
+
this.trackedPointerId = null;
|
|
1510
1534
|
}
|
|
1511
1535
|
}
|
|
1512
1536
|
}
|
|
1513
1537
|
}
|
|
1514
1538
|
handlePointerMove(event) {
|
|
1539
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1515
1542
|
if (event.pointerType === 'mouse') {
|
|
1516
1543
|
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
1517
1544
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
@@ -1532,7 +1559,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1532
1559
|
!this._core.store.state.isRotationHandleSelected) {
|
|
1533
1560
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1534
1561
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1535
|
-
this._core.store.
|
|
1562
|
+
this._core.store.state.isDragging = true;
|
|
1536
1563
|
this.endX = x;
|
|
1537
1564
|
this.endY = y;
|
|
1538
1565
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
@@ -1549,26 +1576,28 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1549
1576
|
}
|
|
1550
1577
|
}
|
|
1551
1578
|
handlePointerUp(event) {
|
|
1579
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1552
1582
|
if (event.pointerType === 'mouse') {
|
|
1553
1583
|
if (this._core.store.state.isDragging) {
|
|
1554
|
-
this._core.store.
|
|
1584
|
+
this._core.store.state.isDragging = false;
|
|
1555
1585
|
if (this.hasMoved) {
|
|
1556
1586
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1557
|
-
this._core.store.
|
|
1587
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1558
1588
|
}
|
|
1559
|
-
this.reset();
|
|
1560
1589
|
}
|
|
1561
1590
|
}
|
|
1562
1591
|
if (event.pointerType === 'touch') {
|
|
1563
1592
|
if (this._core.store.state.isDragging) {
|
|
1564
|
-
this._core.store.
|
|
1593
|
+
this._core.store.state.isDragging = false;
|
|
1565
1594
|
if (this.hasMoved) {
|
|
1566
1595
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1567
|
-
this._core.store.
|
|
1596
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1568
1597
|
}
|
|
1569
|
-
this.reset();
|
|
1570
1598
|
}
|
|
1571
1599
|
}
|
|
1600
|
+
this.reset();
|
|
1572
1601
|
}
|
|
1573
1602
|
}
|
|
1574
1603
|
|
|
@@ -1591,7 +1620,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1591
1620
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1592
1621
|
}
|
|
1593
1622
|
execute() {
|
|
1594
|
-
this._core.store.
|
|
1623
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1595
1624
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1596
1625
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1597
1626
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1599,7 +1628,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1599
1628
|
});
|
|
1600
1629
|
}
|
|
1601
1630
|
undo() {
|
|
1602
|
-
this._core.store.
|
|
1631
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1603
1632
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1604
1633
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1605
1634
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1628,7 +1657,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1628
1657
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1629
1658
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1630
1659
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1631
|
-
this._core.store.
|
|
1660
|
+
this._core.store.state.isResizing = true;
|
|
1632
1661
|
this.initialMouseX = clientX;
|
|
1633
1662
|
this.initialMouseY = clientY;
|
|
1634
1663
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1648,7 +1677,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1648
1677
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1649
1678
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1650
1679
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1651
|
-
this._core.store.
|
|
1680
|
+
this._core.store.state.isResizing = true;
|
|
1652
1681
|
this.initialMouseX = clientX;
|
|
1653
1682
|
this.initialMouseY = clientY;
|
|
1654
1683
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1742,16 +1771,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1742
1771
|
if (event.pointerType === 'mouse') {
|
|
1743
1772
|
if (this._core.store.state.isResizing) {
|
|
1744
1773
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1745
|
-
this._core.store.
|
|
1746
|
-
this._core.store.
|
|
1774
|
+
this._core.store.state.isResizing = false;
|
|
1775
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1747
1776
|
this.reset();
|
|
1748
1777
|
}
|
|
1749
1778
|
}
|
|
1750
1779
|
if (event.pointerType === 'touch') {
|
|
1751
1780
|
if (this._core.store.state.isResizing) {
|
|
1752
1781
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1753
|
-
this._core.store.
|
|
1754
|
-
this._core.store.
|
|
1782
|
+
this._core.store.state.isResizing = false;
|
|
1783
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1755
1784
|
this.reset();
|
|
1756
1785
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1757
1786
|
}
|
|
@@ -1770,7 +1799,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1770
1799
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1771
1800
|
}
|
|
1772
1801
|
execute() {
|
|
1773
|
-
this._core.store.
|
|
1802
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1774
1803
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1775
1804
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1776
1805
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1778,7 +1807,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1778
1807
|
});
|
|
1779
1808
|
}
|
|
1780
1809
|
undo() {
|
|
1781
|
-
this._core.store.
|
|
1810
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1782
1811
|
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1783
1812
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1784
1813
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1806,7 +1835,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1806
1835
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1807
1836
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1808
1837
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1809
|
-
this._core.store.
|
|
1838
|
+
this._core.store.state.isRotating = true;
|
|
1810
1839
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1811
1840
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1812
1841
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1827,7 +1856,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1827
1856
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1828
1857
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1829
1858
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1830
|
-
this._core.store.
|
|
1859
|
+
this._core.store.state.isRotating = true;
|
|
1831
1860
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1832
1861
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1833
1862
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1878,16 +1907,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1878
1907
|
if (event.pointerType === 'mouse') {
|
|
1879
1908
|
if (this._core.store.state.isRotating) {
|
|
1880
1909
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1881
|
-
this._core.store.
|
|
1882
|
-
this._core.store.
|
|
1910
|
+
this._core.store.state.isRotating = false;
|
|
1911
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1883
1912
|
this.reset();
|
|
1884
1913
|
}
|
|
1885
1914
|
}
|
|
1886
1915
|
if (event.pointerType === 'touch') {
|
|
1887
1916
|
if (this._core.store.state.isRotating) {
|
|
1888
1917
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1889
|
-
this._core.store.
|
|
1890
|
-
this._core.store.
|
|
1918
|
+
this._core.store.state.isRotating = false;
|
|
1919
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1891
1920
|
this.reset();
|
|
1892
1921
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1893
1922
|
}
|
|
@@ -1925,13 +1954,13 @@ class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1925
1954
|
execute() {
|
|
1926
1955
|
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox || object instanceof KritzelSelectionGroup);
|
|
1927
1956
|
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
1928
|
-
this._core.store.
|
|
1929
|
-
this._core.store.
|
|
1957
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1958
|
+
this._core.store.state.selectionBox = null;
|
|
1930
1959
|
}
|
|
1931
1960
|
undo() {
|
|
1932
1961
|
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
1933
|
-
this._core.store.
|
|
1934
|
-
this._core.store.
|
|
1962
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1963
|
+
this._core.store.state.selectionBox = null;
|
|
1935
1964
|
}
|
|
1936
1965
|
}
|
|
1937
1966
|
|
|
@@ -1991,14 +2020,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1991
2020
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
1992
2021
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
1993
2022
|
}
|
|
1994
|
-
this._core.store.
|
|
2023
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
1995
2024
|
if (this._core.store.state.isSelecting) {
|
|
1996
2025
|
if (this.isSelectionClick) {
|
|
1997
|
-
|
|
1998
|
-
const y = this._core.store.state.pointerY;
|
|
1999
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
2000
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
2001
|
-
this.removeSelectionBox();
|
|
2026
|
+
this.handleSelectionClick(event);
|
|
2002
2027
|
}
|
|
2003
2028
|
if (this.isSelectionDrag) {
|
|
2004
2029
|
this.updateMouseSelection(event);
|
|
@@ -2014,27 +2039,23 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2014
2039
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
2015
2040
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
2016
2041
|
}
|
|
2017
|
-
this._core.store.
|
|
2042
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
2018
2043
|
if (this._core.store.state.isSelecting) {
|
|
2019
2044
|
if (this.isSelectionClick) {
|
|
2020
|
-
|
|
2021
|
-
const y = this._core.store.state.pointerY;
|
|
2022
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
2023
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
2024
|
-
this.removeSelectionBox();
|
|
2045
|
+
this.handleSelectionClick(event);
|
|
2025
2046
|
}
|
|
2026
2047
|
if (this.isSelectionDrag) {
|
|
2027
2048
|
this.updateTouchSelection();
|
|
2028
2049
|
this.addSelectedObjectsToSelectionGroup();
|
|
2029
2050
|
this.removeSelectionBox();
|
|
2030
2051
|
}
|
|
2031
|
-
this._core.store.
|
|
2052
|
+
this._core.store.state.skipContextMenu = false;
|
|
2032
2053
|
}
|
|
2033
2054
|
}
|
|
2034
2055
|
}
|
|
2035
2056
|
removeSelectionBox() {
|
|
2036
|
-
this._core.store.
|
|
2037
|
-
this._core.store.
|
|
2057
|
+
this._core.store.state.selectionBox = null;
|
|
2058
|
+
this._core.store.state.isSelecting = false;
|
|
2038
2059
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
|
|
2039
2060
|
}
|
|
2040
2061
|
startMouseSelection(event) {
|
|
@@ -2046,9 +2067,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2046
2067
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2047
2068
|
selectionBox.translateX = this.startX;
|
|
2048
2069
|
selectionBox.translateY = this.startY;
|
|
2049
|
-
this._core.store.
|
|
2050
|
-
this._core.store.
|
|
2051
|
-
this._core.store.
|
|
2070
|
+
this._core.store.state.selectionGroup = null;
|
|
2071
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2072
|
+
this._core.store.state.isSelecting = true;
|
|
2052
2073
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2053
2074
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2054
2075
|
}
|
|
@@ -2068,9 +2089,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2068
2089
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2069
2090
|
selectionBox.translateX = this.startX;
|
|
2070
2091
|
selectionBox.translateY = this.startY;
|
|
2071
|
-
this._core.store.
|
|
2072
|
-
this._core.store.
|
|
2073
|
-
this._core.store.
|
|
2092
|
+
this._core.store.state.selectionGroup = null;
|
|
2093
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2094
|
+
this._core.store.state.isSelecting = true;
|
|
2074
2095
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2075
2096
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2076
2097
|
}
|
|
@@ -2082,11 +2103,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2082
2103
|
if (selectionBox) {
|
|
2083
2104
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2084
2105
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2085
|
-
|
|
2086
|
-
|
|
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;
|
|
2087
2110
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2088
2111
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2089
|
-
|
|
2112
|
+
if (width > 0 || height > 0) {
|
|
2113
|
+
this.updateSelectedObjects();
|
|
2114
|
+
}
|
|
2115
|
+
else {
|
|
2116
|
+
this.clearSelectionPreview();
|
|
2117
|
+
}
|
|
2090
2118
|
}
|
|
2091
2119
|
}
|
|
2092
2120
|
updateTouchSelection() {
|
|
@@ -2102,11 +2130,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2102
2130
|
if (selectionBox) {
|
|
2103
2131
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2104
2132
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2105
|
-
|
|
2106
|
-
|
|
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;
|
|
2107
2137
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2108
2138
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2109
|
-
|
|
2139
|
+
if (width > 0 || height > 0) {
|
|
2140
|
+
this.updateSelectedObjects();
|
|
2141
|
+
}
|
|
2142
|
+
else {
|
|
2143
|
+
this.clearSelectionPreview();
|
|
2144
|
+
}
|
|
2110
2145
|
}
|
|
2111
2146
|
}
|
|
2112
2147
|
updateSelectedObjects() {
|
|
@@ -2114,6 +2149,28 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2114
2149
|
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
2115
2150
|
.forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
|
|
2116
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
|
+
}
|
|
2117
2174
|
addObjectToSelectionGroup(object) {
|
|
2118
2175
|
if (!object) {
|
|
2119
2176
|
return;
|
|
@@ -2130,7 +2187,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2130
2187
|
if (selectedObjects.length === 0) {
|
|
2131
2188
|
return;
|
|
2132
2189
|
}
|
|
2133
|
-
this._core.store.
|
|
2190
|
+
this._core.store.state.selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2134
2191
|
selectedObjects.forEach(o => {
|
|
2135
2192
|
this._core.store.state.selectionGroup.addOrRemove(o);
|
|
2136
2193
|
o.isSelected = false;
|
|
@@ -2180,9 +2237,9 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2180
2237
|
}
|
|
2181
2238
|
if (event.pointerType === 'mouse') {
|
|
2182
2239
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
2183
|
-
this._core.store.
|
|
2184
|
-
this._core.store.
|
|
2185
|
-
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);
|
|
2186
2243
|
const selectedObject = this.getSelectedObject(event);
|
|
2187
2244
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2188
2245
|
if ((selectedObject === null || isDifferentObject) &&
|
|
@@ -2206,13 +2263,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2206
2263
|
return;
|
|
2207
2264
|
}
|
|
2208
2265
|
if (this._core.store.state.pointers.size === 1) {
|
|
2209
|
-
this._core.store.
|
|
2210
|
-
this._core.store.
|
|
2211
|
-
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);
|
|
2212
2269
|
const selectedObject = this.getSelectedObject(event);
|
|
2213
2270
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2214
2271
|
if (!this._core.store.state.selectionGroup && selectedObject) {
|
|
2215
|
-
this._core.store.
|
|
2272
|
+
this._core.store.state.skipContextMenu = true;
|
|
2216
2273
|
}
|
|
2217
2274
|
if ((selectedObject === null || isDifferentObject) &&
|
|
2218
2275
|
this._core.store.state.selectionGroup &&
|
|
@@ -2617,7 +2674,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2617
2674
|
}
|
|
2618
2675
|
copy() {
|
|
2619
2676
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2620
|
-
this.objects
|
|
2677
|
+
this.objects
|
|
2678
|
+
.sort((a, b) => a.zIndex - b.zIndex)
|
|
2679
|
+
.forEach(obj => {
|
|
2621
2680
|
const copiedObject = obj.copy();
|
|
2622
2681
|
selectionGroup.addOrRemove(copiedObject);
|
|
2623
2682
|
});
|
|
@@ -2786,6 +2845,6 @@ exports.ObjectHelper = ObjectHelper;
|
|
|
2786
2845
|
exports.RemoveObjectCommand = RemoveObjectCommand;
|
|
2787
2846
|
exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
|
|
2788
2847
|
exports.UpdateObjectCommand = UpdateObjectCommand;
|
|
2789
|
-
//# sourceMappingURL=index-
|
|
2848
|
+
//# sourceMappingURL=index-Clh2g9JM.js.map
|
|
2790
2849
|
|
|
2791
|
-
//# sourceMappingURL=index-
|
|
2850
|
+
//# sourceMappingURL=index-Clh2g9JM.js.map
|