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
|
@@ -263,12 +263,12 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
263
263
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
264
264
|
const object = this._core.findObjectById(objectElement?.id);
|
|
265
265
|
if (object instanceof KritzelText) {
|
|
266
|
-
this._core.store.
|
|
266
|
+
this._core.store.state.activeText = object;
|
|
267
267
|
object.focus();
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
271
|
-
this._core.store.
|
|
271
|
+
this._core.store.state.activeText = object;
|
|
272
272
|
object.focus();
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
@@ -287,7 +287,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
287
287
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
288
288
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
289
289
|
text.zIndex = this._core.store.currentZIndex;
|
|
290
|
-
this._core.store.
|
|
290
|
+
this._core.store.state.activeText = text;
|
|
291
291
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
292
292
|
}
|
|
293
293
|
if (event.pointerType === 'touch') {
|
|
@@ -296,12 +296,12 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
296
296
|
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
297
297
|
const object = this._core.findObjectById(objectElement?.id);
|
|
298
298
|
if (object instanceof KritzelText) {
|
|
299
|
-
this._core.store.
|
|
299
|
+
this._core.store.state.activeText = object;
|
|
300
300
|
object.focus();
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
303
|
if (this._core.store.state.activeText !== null && object instanceof KritzelText) {
|
|
304
|
-
this._core.store.
|
|
304
|
+
this._core.store.state.activeText = object;
|
|
305
305
|
object.focus();
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
@@ -321,7 +321,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
321
321
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
322
322
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
323
323
|
text.zIndex = this._core.store.currentZIndex;
|
|
324
|
-
this._core.store.
|
|
324
|
+
this._core.store.state.activeText = text;
|
|
325
325
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, text));
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -562,9 +562,15 @@ class KritzelBaseObject {
|
|
|
562
562
|
this.rotatedBoundingBox.y + this.rotatedBoundingBox.height > viewportBounds.y);
|
|
563
563
|
}
|
|
564
564
|
centerInViewport() {
|
|
565
|
-
const scale = this._core.store.state
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
const { viewportWidth, viewportHeight, translateX: viewportTranslateX, translateY: viewportTranslateY, scale: viewportScale } = this._core.store.state;
|
|
566
|
+
const { x, y, width, height } = this.rotatedBoundingBox;
|
|
567
|
+
const objectCenterX = x + width / 2;
|
|
568
|
+
const objectCenterY = y + height / 2;
|
|
569
|
+
const targetCenterX = (viewportWidth / 2 - viewportTranslateX) / viewportScale;
|
|
570
|
+
const targetCenterY = (viewportHeight / 2 - viewportTranslateY) / viewportScale;
|
|
571
|
+
const deltaX = targetCenterX - objectCenterX;
|
|
572
|
+
const deltaY = targetCenterY - objectCenterY;
|
|
573
|
+
this.updatePosition(this.translateX + deltaX, this.translateY + deltaY);
|
|
568
574
|
}
|
|
569
575
|
move(startX, startY, endX, endY) {
|
|
570
576
|
const deltaX = (startX - endX) / this._core.store.state.scale;
|
|
@@ -749,9 +755,10 @@ class KritzelText extends KritzelBaseObject {
|
|
|
749
755
|
const start = this.elementRef.selectionStart;
|
|
750
756
|
const end = this.elementRef.selectionEnd;
|
|
751
757
|
const value = this.elementRef.value;
|
|
752
|
-
this.
|
|
753
|
-
this.elementRef.
|
|
754
|
-
|
|
758
|
+
this.value = (value.substring(0, start) + text + value.substring(end)).trim();
|
|
759
|
+
this.elementRef.value = this.value;
|
|
760
|
+
const length = this.elementRef.value.length;
|
|
761
|
+
this.elementRef.setSelectionRange(length, length);
|
|
755
762
|
this.updateTextareaDimensions();
|
|
756
763
|
});
|
|
757
764
|
}
|
|
@@ -763,7 +770,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
763
770
|
edit() {
|
|
764
771
|
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
765
772
|
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
766
|
-
this._core.store.
|
|
773
|
+
this._core.store.state.activeText = this;
|
|
767
774
|
this._core.clearSelection();
|
|
768
775
|
this.focus();
|
|
769
776
|
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
@@ -1128,17 +1135,17 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1128
1135
|
}
|
|
1129
1136
|
if (event.pointerType === 'mouse') {
|
|
1130
1137
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1131
|
-
this._core.store.
|
|
1138
|
+
this._core.store.state.isDrawing = true;
|
|
1132
1139
|
const x = event.clientX - this._core.store.offsetX;
|
|
1133
1140
|
const y = event.clientY - this._core.store.offsetY;
|
|
1134
|
-
this._core.store.
|
|
1141
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1135
1142
|
points: [[x, y]],
|
|
1136
1143
|
translateX: -this._core.store.state.translateX,
|
|
1137
1144
|
translateY: -this._core.store.state.translateY,
|
|
1138
1145
|
scale: this._core.store.state.scale,
|
|
1139
1146
|
fill: this.color,
|
|
1140
1147
|
strokeWidth: this.size,
|
|
1141
|
-
})
|
|
1148
|
+
});
|
|
1142
1149
|
}
|
|
1143
1150
|
}
|
|
1144
1151
|
if (event.pointerType === 'touch') {
|
|
@@ -1146,15 +1153,15 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1146
1153
|
if (activePointers.length === 1) {
|
|
1147
1154
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1148
1155
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1149
|
-
this._core.store.
|
|
1150
|
-
this._core.store.
|
|
1156
|
+
this._core.store.state.isDrawing = true;
|
|
1157
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1151
1158
|
points: [[x, y]],
|
|
1152
1159
|
translateX: -this._core.store.state.translateX,
|
|
1153
1160
|
translateY: -this._core.store.state.translateY,
|
|
1154
1161
|
scale: this._core.store.state.scale,
|
|
1155
1162
|
fill: this.color,
|
|
1156
1163
|
strokeWidth: this.size,
|
|
1157
|
-
})
|
|
1164
|
+
});
|
|
1158
1165
|
this._core.rerender();
|
|
1159
1166
|
}
|
|
1160
1167
|
}
|
|
@@ -1167,14 +1174,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1167
1174
|
if (this._core.store.state.isDrawing) {
|
|
1168
1175
|
const x = event.clientX - this._core.store.offsetX;
|
|
1169
1176
|
const y = event.clientY - this._core.store.offsetY;
|
|
1170
|
-
this._core.store.
|
|
1177
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1171
1178
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1172
1179
|
translateX: -this._core.store.state.translateX,
|
|
1173
1180
|
translateY: -this._core.store.state.translateY,
|
|
1174
1181
|
scale: this._core.store.state.scale,
|
|
1175
1182
|
fill: this.color,
|
|
1176
1183
|
strokeWidth: this.size,
|
|
1177
|
-
})
|
|
1184
|
+
});
|
|
1178
1185
|
this._core.rerender();
|
|
1179
1186
|
}
|
|
1180
1187
|
}
|
|
@@ -1183,14 +1190,14 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1183
1190
|
if (activePointers.length === 1) {
|
|
1184
1191
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1185
1192
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1186
|
-
this._core.store.
|
|
1193
|
+
this._core.store.state.currentPath = KritzelPath.create(this._core, {
|
|
1187
1194
|
points: [...this._core.store.state.currentPath.points, [x, y]],
|
|
1188
1195
|
translateX: -this._core.store.state.translateX,
|
|
1189
1196
|
translateY: -this._core.store.state.translateY,
|
|
1190
1197
|
scale: this._core.store.state.scale,
|
|
1191
1198
|
fill: this.color,
|
|
1192
1199
|
strokeWidth: this.size,
|
|
1193
|
-
})
|
|
1200
|
+
});
|
|
1194
1201
|
this._core.rerender();
|
|
1195
1202
|
}
|
|
1196
1203
|
}
|
|
@@ -1201,26 +1208,26 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
1201
1208
|
}
|
|
1202
1209
|
if (event.pointerType === 'mouse') {
|
|
1203
1210
|
if (this._core.store.state.isDrawing) {
|
|
1204
|
-
this._core.store.
|
|
1211
|
+
this._core.store.state.isDrawing = false;
|
|
1205
1212
|
if (this._core.store.state.currentPath) {
|
|
1206
1213
|
const currentPath = this._core.store.state.currentPath;
|
|
1207
1214
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1208
|
-
this._core.store.
|
|
1215
|
+
this._core.store.state.currentPath = currentPath;
|
|
1209
1216
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, this._core.store.state.currentPath));
|
|
1210
1217
|
}
|
|
1211
|
-
this._core.store.
|
|
1218
|
+
this._core.store.state.currentPath = undefined;
|
|
1212
1219
|
}
|
|
1213
1220
|
}
|
|
1214
1221
|
if (event.pointerType === 'touch') {
|
|
1215
1222
|
if (this._core.store.state.isDrawing) {
|
|
1216
|
-
this._core.store.
|
|
1223
|
+
this._core.store.state.isDrawing = false;
|
|
1217
1224
|
if (this._core.store.state.currentPath) {
|
|
1218
1225
|
const currentPath = this._core.store.state.currentPath;
|
|
1219
1226
|
currentPath.zIndex = this._core.store.currentZIndex;
|
|
1220
|
-
this._core.store.
|
|
1227
|
+
this._core.store.state.currentPath = currentPath;
|
|
1221
1228
|
this._core.history.executeCommand(new AddObjectCommand(this._core, this, currentPath));
|
|
1222
1229
|
}
|
|
1223
|
-
this._core.store.
|
|
1230
|
+
this._core.store.state.currentPath = undefined;
|
|
1224
1231
|
this._core.rerender();
|
|
1225
1232
|
}
|
|
1226
1233
|
}
|
|
@@ -1320,13 +1327,13 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1320
1327
|
handlePointerDown(event) {
|
|
1321
1328
|
if (event.pointerType === 'mouse') {
|
|
1322
1329
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1323
|
-
this._core.store.
|
|
1330
|
+
this._core.store.state.isErasing = true;
|
|
1324
1331
|
}
|
|
1325
1332
|
}
|
|
1326
1333
|
if (event.pointerType === 'touch') {
|
|
1327
1334
|
this.touchStartTimeout = setTimeout(() => {
|
|
1328
1335
|
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
1329
|
-
this._core.store.
|
|
1336
|
+
this._core.store.state.isErasing = true;
|
|
1330
1337
|
}
|
|
1331
1338
|
}, 80);
|
|
1332
1339
|
}
|
|
@@ -1372,7 +1379,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1372
1379
|
if (removeCommands.length > 0) {
|
|
1373
1380
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1374
1381
|
}
|
|
1375
|
-
this._core.store.
|
|
1382
|
+
this._core.store.state.isErasing = false;
|
|
1376
1383
|
}
|
|
1377
1384
|
}
|
|
1378
1385
|
if (event.pointerType === 'touch') {
|
|
@@ -1387,7 +1394,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1387
1394
|
if (removeCommands.length > 0) {
|
|
1388
1395
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
1389
1396
|
}
|
|
1390
|
-
this._core.store.
|
|
1397
|
+
this._core.store.state.isErasing = false;
|
|
1391
1398
|
}
|
|
1392
1399
|
}
|
|
1393
1400
|
}
|
|
@@ -1401,12 +1408,12 @@ class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1401
1408
|
}
|
|
1402
1409
|
execute() {
|
|
1403
1410
|
this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
|
|
1404
|
-
this._core.store.
|
|
1411
|
+
this._core.store.state.selectionGroup = null;
|
|
1405
1412
|
}
|
|
1406
1413
|
undo() {
|
|
1407
1414
|
if (this.previousSelectionGroup) {
|
|
1408
1415
|
this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
|
|
1409
|
-
this._core.store.
|
|
1416
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1410
1417
|
}
|
|
1411
1418
|
}
|
|
1412
1419
|
}
|
|
@@ -1437,7 +1444,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1437
1444
|
});
|
|
1438
1445
|
return;
|
|
1439
1446
|
}
|
|
1440
|
-
this._core.store.
|
|
1447
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1441
1448
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1442
1449
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1443
1450
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1445,7 +1452,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1445
1452
|
});
|
|
1446
1453
|
}
|
|
1447
1454
|
undo() {
|
|
1448
|
-
this._core.store.
|
|
1455
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1449
1456
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1450
1457
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1451
1458
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1469,6 +1476,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1469
1476
|
endX;
|
|
1470
1477
|
endY;
|
|
1471
1478
|
hasMoved = false;
|
|
1479
|
+
trackedPointerId = null;
|
|
1472
1480
|
constructor(core) {
|
|
1473
1481
|
super(core);
|
|
1474
1482
|
}
|
|
@@ -1480,6 +1488,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1480
1488
|
this.endX = 0;
|
|
1481
1489
|
this.endY = 0;
|
|
1482
1490
|
this.hasMoved = false;
|
|
1491
|
+
this.trackedPointerId = null;
|
|
1492
|
+
}
|
|
1493
|
+
cancelPendingDrag() {
|
|
1494
|
+
this._core.store.state.isDragging = false;
|
|
1495
|
+
this.reset();
|
|
1483
1496
|
}
|
|
1484
1497
|
handlePointerDown(event) {
|
|
1485
1498
|
if (event.pointerType === 'mouse') {
|
|
@@ -1487,13 +1500,20 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1487
1500
|
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
1488
1501
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1489
1502
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1490
|
-
this._core.store.
|
|
1503
|
+
this._core.store.state.isDragging = true;
|
|
1491
1504
|
this.dragStartX = clientX;
|
|
1492
1505
|
this.dragStartY = clientY;
|
|
1493
1506
|
this.startX = this.dragStartX;
|
|
1494
1507
|
this.startY = this.dragStartY;
|
|
1508
|
+
this.trackedPointerId = event.pointerId;
|
|
1509
|
+
}
|
|
1510
|
+
else {
|
|
1511
|
+
this.trackedPointerId = null;
|
|
1495
1512
|
}
|
|
1496
1513
|
}
|
|
1514
|
+
else {
|
|
1515
|
+
this.trackedPointerId = null;
|
|
1516
|
+
}
|
|
1497
1517
|
}
|
|
1498
1518
|
if (event.pointerType === 'touch') {
|
|
1499
1519
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
@@ -1505,11 +1525,18 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1505
1525
|
this.dragStartY = y;
|
|
1506
1526
|
this.startX = x;
|
|
1507
1527
|
this.startY = y;
|
|
1528
|
+
this.trackedPointerId = event.pointerId;
|
|
1529
|
+
}
|
|
1530
|
+
else {
|
|
1531
|
+
this.trackedPointerId = null;
|
|
1508
1532
|
}
|
|
1509
1533
|
}
|
|
1510
1534
|
}
|
|
1511
1535
|
}
|
|
1512
1536
|
handlePointerMove(event) {
|
|
1537
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1513
1540
|
if (event.pointerType === 'mouse') {
|
|
1514
1541
|
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
1515
1542
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
@@ -1530,7 +1557,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1530
1557
|
!this._core.store.state.isRotationHandleSelected) {
|
|
1531
1558
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1532
1559
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1533
|
-
this._core.store.
|
|
1560
|
+
this._core.store.state.isDragging = true;
|
|
1534
1561
|
this.endX = x;
|
|
1535
1562
|
this.endY = y;
|
|
1536
1563
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
@@ -1547,26 +1574,28 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1547
1574
|
}
|
|
1548
1575
|
}
|
|
1549
1576
|
handlePointerUp(event) {
|
|
1577
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1550
1580
|
if (event.pointerType === 'mouse') {
|
|
1551
1581
|
if (this._core.store.state.isDragging) {
|
|
1552
|
-
this._core.store.
|
|
1582
|
+
this._core.store.state.isDragging = false;
|
|
1553
1583
|
if (this.hasMoved) {
|
|
1554
1584
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1555
|
-
this._core.store.
|
|
1585
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1556
1586
|
}
|
|
1557
|
-
this.reset();
|
|
1558
1587
|
}
|
|
1559
1588
|
}
|
|
1560
1589
|
if (event.pointerType === 'touch') {
|
|
1561
1590
|
if (this._core.store.state.isDragging) {
|
|
1562
|
-
this._core.store.
|
|
1591
|
+
this._core.store.state.isDragging = false;
|
|
1563
1592
|
if (this.hasMoved) {
|
|
1564
1593
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1565
|
-
this._core.store.
|
|
1594
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1566
1595
|
}
|
|
1567
|
-
this.reset();
|
|
1568
1596
|
}
|
|
1569
1597
|
}
|
|
1598
|
+
this.reset();
|
|
1570
1599
|
}
|
|
1571
1600
|
}
|
|
1572
1601
|
|
|
@@ -1589,7 +1618,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1589
1618
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1590
1619
|
}
|
|
1591
1620
|
execute() {
|
|
1592
|
-
this._core.store.
|
|
1621
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1593
1622
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1594
1623
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1595
1624
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1597,7 +1626,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1597
1626
|
});
|
|
1598
1627
|
}
|
|
1599
1628
|
undo() {
|
|
1600
|
-
this._core.store.
|
|
1629
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1601
1630
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1602
1631
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1603
1632
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1626,7 +1655,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1626
1655
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1627
1656
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1628
1657
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1629
|
-
this._core.store.
|
|
1658
|
+
this._core.store.state.isResizing = true;
|
|
1630
1659
|
this.initialMouseX = clientX;
|
|
1631
1660
|
this.initialMouseY = clientY;
|
|
1632
1661
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1646,7 +1675,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1646
1675
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
1647
1676
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1648
1677
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1649
|
-
this._core.store.
|
|
1678
|
+
this._core.store.state.isResizing = true;
|
|
1650
1679
|
this.initialMouseX = clientX;
|
|
1651
1680
|
this.initialMouseY = clientY;
|
|
1652
1681
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -1740,16 +1769,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1740
1769
|
if (event.pointerType === 'mouse') {
|
|
1741
1770
|
if (this._core.store.state.isResizing) {
|
|
1742
1771
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1743
|
-
this._core.store.
|
|
1744
|
-
this._core.store.
|
|
1772
|
+
this._core.store.state.isResizing = false;
|
|
1773
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1745
1774
|
this.reset();
|
|
1746
1775
|
}
|
|
1747
1776
|
}
|
|
1748
1777
|
if (event.pointerType === 'touch') {
|
|
1749
1778
|
if (this._core.store.state.isResizing) {
|
|
1750
1779
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1751
|
-
this._core.store.
|
|
1752
|
-
this._core.store.
|
|
1780
|
+
this._core.store.state.isResizing = false;
|
|
1781
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1753
1782
|
this.reset();
|
|
1754
1783
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1755
1784
|
}
|
|
@@ -1768,7 +1797,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1768
1797
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1769
1798
|
}
|
|
1770
1799
|
execute() {
|
|
1771
|
-
this._core.store.
|
|
1800
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1772
1801
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1773
1802
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1774
1803
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1776,7 +1805,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1776
1805
|
});
|
|
1777
1806
|
}
|
|
1778
1807
|
undo() {
|
|
1779
|
-
this._core.store.
|
|
1808
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1780
1809
|
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1781
1810
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1782
1811
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -1804,7 +1833,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1804
1833
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1805
1834
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
1806
1835
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
1807
|
-
this._core.store.
|
|
1836
|
+
this._core.store.state.isRotating = true;
|
|
1808
1837
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1809
1838
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1810
1839
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1825,7 +1854,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1825
1854
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
1826
1855
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
1827
1856
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
1828
|
-
this._core.store.
|
|
1857
|
+
this._core.store.state.isRotating = true;
|
|
1829
1858
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
1830
1859
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1831
1860
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -1876,16 +1905,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1876
1905
|
if (event.pointerType === 'mouse') {
|
|
1877
1906
|
if (this._core.store.state.isRotating) {
|
|
1878
1907
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1879
|
-
this._core.store.
|
|
1880
|
-
this._core.store.
|
|
1908
|
+
this._core.store.state.isRotating = false;
|
|
1909
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1881
1910
|
this.reset();
|
|
1882
1911
|
}
|
|
1883
1912
|
}
|
|
1884
1913
|
if (event.pointerType === 'touch') {
|
|
1885
1914
|
if (this._core.store.state.isRotating) {
|
|
1886
1915
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1887
|
-
this._core.store.
|
|
1888
|
-
this._core.store.
|
|
1916
|
+
this._core.store.state.isRotating = false;
|
|
1917
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
1889
1918
|
this.reset();
|
|
1890
1919
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1891
1920
|
}
|
|
@@ -1923,13 +1952,13 @@ class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1923
1952
|
execute() {
|
|
1924
1953
|
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox || object instanceof KritzelSelectionGroup);
|
|
1925
1954
|
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
1926
|
-
this._core.store.
|
|
1927
|
-
this._core.store.
|
|
1955
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
1956
|
+
this._core.store.state.selectionBox = null;
|
|
1928
1957
|
}
|
|
1929
1958
|
undo() {
|
|
1930
1959
|
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
1931
|
-
this._core.store.
|
|
1932
|
-
this._core.store.
|
|
1960
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
1961
|
+
this._core.store.state.selectionBox = null;
|
|
1933
1962
|
}
|
|
1934
1963
|
}
|
|
1935
1964
|
|
|
@@ -1989,14 +2018,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
1989
2018
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
1990
2019
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
1991
2020
|
}
|
|
1992
|
-
this._core.store.
|
|
2021
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
1993
2022
|
if (this._core.store.state.isSelecting) {
|
|
1994
2023
|
if (this.isSelectionClick) {
|
|
1995
|
-
|
|
1996
|
-
const y = this._core.store.state.pointerY;
|
|
1997
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
1998
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
1999
|
-
this.removeSelectionBox();
|
|
2024
|
+
this.handleSelectionClick(event);
|
|
2000
2025
|
}
|
|
2001
2026
|
if (this.isSelectionDrag) {
|
|
2002
2027
|
this.updateMouseSelection(event);
|
|
@@ -2012,27 +2037,23 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2012
2037
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
2013
2038
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
2014
2039
|
}
|
|
2015
|
-
this._core.store.
|
|
2040
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
2016
2041
|
if (this._core.store.state.isSelecting) {
|
|
2017
2042
|
if (this.isSelectionClick) {
|
|
2018
|
-
|
|
2019
|
-
const y = this._core.store.state.pointerY;
|
|
2020
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
2021
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
2022
|
-
this.removeSelectionBox();
|
|
2043
|
+
this.handleSelectionClick(event);
|
|
2023
2044
|
}
|
|
2024
2045
|
if (this.isSelectionDrag) {
|
|
2025
2046
|
this.updateTouchSelection();
|
|
2026
2047
|
this.addSelectedObjectsToSelectionGroup();
|
|
2027
2048
|
this.removeSelectionBox();
|
|
2028
2049
|
}
|
|
2029
|
-
this._core.store.
|
|
2050
|
+
this._core.store.state.skipContextMenu = false;
|
|
2030
2051
|
}
|
|
2031
2052
|
}
|
|
2032
2053
|
}
|
|
2033
2054
|
removeSelectionBox() {
|
|
2034
|
-
this._core.store.
|
|
2035
|
-
this._core.store.
|
|
2055
|
+
this._core.store.state.selectionBox = null;
|
|
2056
|
+
this._core.store.state.isSelecting = false;
|
|
2036
2057
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
|
|
2037
2058
|
}
|
|
2038
2059
|
startMouseSelection(event) {
|
|
@@ -2044,9 +2065,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2044
2065
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2045
2066
|
selectionBox.translateX = this.startX;
|
|
2046
2067
|
selectionBox.translateY = this.startY;
|
|
2047
|
-
this._core.store.
|
|
2048
|
-
this._core.store.
|
|
2049
|
-
this._core.store.
|
|
2068
|
+
this._core.store.state.selectionGroup = null;
|
|
2069
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2070
|
+
this._core.store.state.isSelecting = true;
|
|
2050
2071
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2051
2072
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2052
2073
|
}
|
|
@@ -2066,9 +2087,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2066
2087
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
2067
2088
|
selectionBox.translateX = this.startX;
|
|
2068
2089
|
selectionBox.translateY = this.startY;
|
|
2069
|
-
this._core.store.
|
|
2070
|
-
this._core.store.
|
|
2071
|
-
this._core.store.
|
|
2090
|
+
this._core.store.state.selectionGroup = null;
|
|
2091
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
2092
|
+
this._core.store.state.isSelecting = true;
|
|
2072
2093
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
2073
2094
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
2074
2095
|
}
|
|
@@ -2080,11 +2101,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2080
2101
|
if (selectionBox) {
|
|
2081
2102
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2082
2103
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2083
|
-
|
|
2084
|
-
|
|
2104
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2105
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2106
|
+
selectionBox.width = width;
|
|
2107
|
+
selectionBox.height = height;
|
|
2085
2108
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2086
2109
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2087
|
-
|
|
2110
|
+
if (width > 0 || height > 0) {
|
|
2111
|
+
this.updateSelectedObjects();
|
|
2112
|
+
}
|
|
2113
|
+
else {
|
|
2114
|
+
this.clearSelectionPreview();
|
|
2115
|
+
}
|
|
2088
2116
|
}
|
|
2089
2117
|
}
|
|
2090
2118
|
updateTouchSelection() {
|
|
@@ -2100,11 +2128,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2100
2128
|
if (selectionBox) {
|
|
2101
2129
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
2102
2130
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
2103
|
-
|
|
2104
|
-
|
|
2131
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
2132
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
2133
|
+
selectionBox.width = width;
|
|
2134
|
+
selectionBox.height = height;
|
|
2105
2135
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
2106
2136
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
2107
|
-
|
|
2137
|
+
if (width > 0 || height > 0) {
|
|
2138
|
+
this.updateSelectedObjects();
|
|
2139
|
+
}
|
|
2140
|
+
else {
|
|
2141
|
+
this.clearSelectionPreview();
|
|
2142
|
+
}
|
|
2108
2143
|
}
|
|
2109
2144
|
}
|
|
2110
2145
|
updateSelectedObjects() {
|
|
@@ -2112,6 +2147,28 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2112
2147
|
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
2113
2148
|
.forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
|
|
2114
2149
|
}
|
|
2150
|
+
handleSelectionClick(event) {
|
|
2151
|
+
const selectedObject = this.getTopmostHitObject(event);
|
|
2152
|
+
this.clearSelectionPreview();
|
|
2153
|
+
this.addObjectToSelectionGroup(selectedObject);
|
|
2154
|
+
this.removeSelectionBox();
|
|
2155
|
+
}
|
|
2156
|
+
getTopmostHitObject(event) {
|
|
2157
|
+
const pointerX = this._core.store.state.pointerX;
|
|
2158
|
+
const pointerY = this._core.store.state.pointerY;
|
|
2159
|
+
const overlappingObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
2160
|
+
for (const object of overlappingObjects) {
|
|
2161
|
+
if (object.hitTest(pointerX, pointerY)) {
|
|
2162
|
+
return object;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
return null;
|
|
2166
|
+
}
|
|
2167
|
+
clearSelectionPreview() {
|
|
2168
|
+
this._core.store.allNonSelectionObjects.forEach(object => {
|
|
2169
|
+
object.isSelected = false;
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2115
2172
|
addObjectToSelectionGroup(object) {
|
|
2116
2173
|
if (!object) {
|
|
2117
2174
|
return;
|
|
@@ -2128,7 +2185,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2128
2185
|
if (selectedObjects.length === 0) {
|
|
2129
2186
|
return;
|
|
2130
2187
|
}
|
|
2131
|
-
this._core.store.
|
|
2188
|
+
this._core.store.state.selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2132
2189
|
selectedObjects.forEach(o => {
|
|
2133
2190
|
this._core.store.state.selectionGroup.addOrRemove(o);
|
|
2134
2191
|
o.isSelected = false;
|
|
@@ -2178,9 +2235,9 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2178
2235
|
}
|
|
2179
2236
|
if (event.pointerType === 'mouse') {
|
|
2180
2237
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
2181
|
-
this._core.store.
|
|
2182
|
-
this._core.store.
|
|
2183
|
-
this._core.store.
|
|
2238
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
2239
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
2240
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
2184
2241
|
const selectedObject = this.getSelectedObject(event);
|
|
2185
2242
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2186
2243
|
if ((selectedObject === null || isDifferentObject) &&
|
|
@@ -2204,13 +2261,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2204
2261
|
return;
|
|
2205
2262
|
}
|
|
2206
2263
|
if (this._core.store.state.pointers.size === 1) {
|
|
2207
|
-
this._core.store.
|
|
2208
|
-
this._core.store.
|
|
2209
|
-
this._core.store.
|
|
2264
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
2265
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
2266
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
2210
2267
|
const selectedObject = this.getSelectedObject(event);
|
|
2211
2268
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
2212
2269
|
if (!this._core.store.state.selectionGroup && selectedObject) {
|
|
2213
|
-
this._core.store.
|
|
2270
|
+
this._core.store.state.skipContextMenu = true;
|
|
2214
2271
|
}
|
|
2215
2272
|
if ((selectedObject === null || isDifferentObject) &&
|
|
2216
2273
|
this._core.store.state.selectionGroup &&
|
|
@@ -2615,7 +2672,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2615
2672
|
}
|
|
2616
2673
|
copy() {
|
|
2617
2674
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
2618
|
-
this.objects
|
|
2675
|
+
this.objects
|
|
2676
|
+
.sort((a, b) => a.zIndex - b.zIndex)
|
|
2677
|
+
.forEach(obj => {
|
|
2619
2678
|
const copiedObject = obj.copy();
|
|
2620
2679
|
selectionGroup.addOrRemove(copiedObject);
|
|
2621
2680
|
});
|
|
@@ -2757,7 +2816,7 @@ class KritzelImageTool extends KritzelBaseTool {
|
|
|
2757
2816
|
}
|
|
2758
2817
|
}
|
|
2759
2818
|
|
|
2760
|
-
export { AddSelectionGroupCommand as A, BatchCommand as B, DEFAULT_BRUSH_CONFIG as D, KritzelBrushTool as K, ObjectHelper as O, RemoveSelectionGroupCommand as R, UpdateObjectCommand as U, KritzelTextTool as a, KritzelMouseButton as b, KritzelSelectionTool as c, KritzelEraserTool as d, DEFAULT_TEXT_CONFIG as e, KritzelImageTool as f, KritzelWorkspace as g, KritzelKeyboardHelper as h, KritzelEventHelper as i, KritzelBaseHandler as j, KritzelToolRegistry as k,
|
|
2761
|
-
//# sourceMappingURL=index-
|
|
2819
|
+
export { AddSelectionGroupCommand as A, BatchCommand as B, DEFAULT_BRUSH_CONFIG as D, KritzelBrushTool as K, ObjectHelper as O, RemoveSelectionGroupCommand as R, UpdateObjectCommand as U, KritzelTextTool as a, KritzelMouseButton as b, KritzelSelectionTool as c, KritzelEraserTool as d, DEFAULT_TEXT_CONFIG as e, KritzelImageTool as f, KritzelWorkspace as g, KritzelKeyboardHelper as h, KritzelEventHelper as i, KritzelBaseHandler as j, KritzelToolRegistry as k, KrtizelSelectionBox as l, KritzelSelectionGroup as m, KritzelBaseCommand as n, KritzelReviver as o, RemoveObjectCommand as p, AddObjectCommand as q, KritzelBaseTool as r, KritzelText as s, KritzelPath as t, KritzelImage as u };
|
|
2820
|
+
//# sourceMappingURL=index-BAbkwyRx.js.map
|
|
2762
2821
|
|
|
2763
|
-
//# sourceMappingURL=index-
|
|
2822
|
+
//# sourceMappingURL=index-BAbkwyRx.js.map
|