kritzel-stencil 0.0.139 → 0.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index-BKstgWru.js +16981 -0
- package/dist/cjs/index-BKstgWru.js.map +1 -0
- package/dist/cjs/{index-nzUNdMPh.js → index-DcTwXs_q.js} +47 -22
- package/dist/cjs/index-DcTwXs_q.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +205 -157
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/cjs/stencil.cjs.js.map +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 +52 -29
- 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 +4 -4
- 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 +123 -75
- 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 +8 -10
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +5 -9
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -8
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +30 -38
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -2
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +5 -5
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +4 -5
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +5 -6
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +4 -4
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +3 -4
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +3 -4
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +5 -5
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -3
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -4
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +6 -7
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +5 -6
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +2 -3
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +7 -8
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -3
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +3 -4
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +3 -4
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +4 -6
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- 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 -3
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-brush-style.js +4 -4
- 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-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +26 -26
- 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-icon.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-BlPlPpUy.js → p-BEKicPnH.js} +4 -4
- package/dist/components/{p-BlPlPpUy.js.map → p-BEKicPnH.js.map} +1 -1
- package/dist/components/{p-DCx3703u.js → p-BFNwskCY.js} +5 -5
- package/dist/components/{p-DCx3703u.js.map → p-BFNwskCY.js.map} +1 -1
- package/dist/components/{p-BorT6g39.js → p-BJbN3vca.js} +7 -7
- package/dist/components/{p-BorT6g39.js.map → p-BJbN3vca.js.map} +1 -1
- package/dist/components/p-BuDVaqTF.js +15302 -0
- package/dist/components/p-BuDVaqTF.js.map +1 -0
- package/dist/components/{p-Db3kxVe2.js → p-ByAzDzS5.js} +4 -4
- package/dist/components/{p-Db3kxVe2.js.map → p-ByAzDzS5.js.map} +1 -1
- package/dist/components/{p-sreNwi0N.js → p-BycHaC-9.js} +5 -5
- package/dist/components/{p-sreNwi0N.js.map → p-BycHaC-9.js.map} +1 -1
- package/dist/components/{p-KudVTtHk.js → p-C4nj29RW.js} +310 -210
- package/dist/components/p-C4nj29RW.js.map +1 -0
- package/dist/components/{p-BYanlgdq.js → p-C9hrbrUN.js} +27 -14
- package/dist/components/p-C9hrbrUN.js.map +1 -0
- package/dist/components/{p-BgpsMYcw.js → p-CEn1WeG3.js} +8 -8
- package/dist/components/p-CEn1WeG3.js.map +1 -0
- package/dist/components/{p-BM9IjvnD.js → p-CGb-8cK4.js} +4 -4
- package/dist/components/{p-BM9IjvnD.js.map → p-CGb-8cK4.js.map} +1 -1
- package/dist/components/{p-B7kZ1_RH.js → p-C_hSH2nN.js} +5 -5
- package/dist/components/{p-B7kZ1_RH.js.map → p-C_hSH2nN.js.map} +1 -1
- package/dist/components/{p-CHdJi6b4.js → p-ChLi4Ufe.js} +20 -20
- package/dist/components/{p-CHdJi6b4.js.map → p-ChLi4Ufe.js.map} +1 -1
- package/dist/components/{p-BPsQrpzN.js → p-CieOx1XL.js} +8 -8
- package/dist/components/{p-BPsQrpzN.js.map → p-CieOx1XL.js.map} +1 -1
- package/dist/components/{p-DjU7p3od.js → p-Co5lU_7h.js} +12 -12
- package/dist/components/{p-DjU7p3od.js.map → p-Co5lU_7h.js.map} +1 -1
- package/dist/components/{p-sq9jgfX0.js → p-D27d2rKT.js} +3 -3
- package/dist/components/{p-sq9jgfX0.js.map → p-D27d2rKT.js.map} +1 -1
- package/dist/components/{p-DFO-6kuA.js → p-DPxzgBs0.js} +3 -3
- package/dist/components/{p-DFO-6kuA.js.map → p-DPxzgBs0.js.map} +1 -1
- package/dist/components/{p-0iJh9Z6m.js → p-D_RcVGj0.js} +5 -5
- package/dist/components/{p-0iJh9Z6m.js.map → p-D_RcVGj0.js.map} +1 -1
- package/dist/components/{p-DOPuq6gn.js → p-DqsgZIHC.js} +5 -5
- package/dist/components/{p-DOPuq6gn.js.map → p-DqsgZIHC.js.map} +1 -1
- package/dist/components/{p-BehchtaT.js → p-DzyZA2GT.js} +8 -8
- package/dist/components/{p-BehchtaT.js.map → p-DzyZA2GT.js.map} +1 -1
- package/dist/components/{p-Ddlbt3Bj.js → p-dcR2uxM3.js} +6 -6
- package/dist/components/{p-Ddlbt3Bj.js.map → p-dcR2uxM3.js.map} +1 -1
- package/dist/components/{p-B7w19kIk.js → p-fiFoOjv0.js} +9 -9
- package/dist/components/{p-B7w19kIk.js.map → p-fiFoOjv0.js.map} +1 -1
- package/dist/components/{p-CsyM5q2M.js → p-gCHmJzc2.js} +5 -5
- package/dist/components/{p-CsyM5q2M.js.map → p-gCHmJzc2.js.map} +1 -1
- package/dist/esm/{index-oCOlsFCN.js → index-Cw77zP6g.js} +47 -22
- package/dist/esm/index-Cw77zP6g.js.map +1 -0
- package/dist/esm/index-D0Q2MKPn.js +16953 -0
- package/dist/esm/index-D0Q2MKPn.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +205 -157
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-73784709.entry.js +2 -0
- package/dist/stencil/p-73784709.entry.js.map +1 -0
- package/dist/stencil/{p-25d1e040.entry.js → p-8b831c94.entry.js} +2 -2
- package/dist/stencil/p-Cw77zP6g.js +3 -0
- package/dist/stencil/p-Cw77zP6g.js.map +1 -0
- package/dist/stencil/p-D0Q2MKPn.js +2 -0
- package/dist/stencil/p-D0Q2MKPn.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/core/store.class.d.ts +2 -1
- package/dist/types/classes/core/viewport.class.d.ts +3 -0
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/selection.handler.d.ts +3 -0
- package/dist/types/classes/objects/text.class.d.ts +20 -10
- package/dist/types/stencil-public-runtime.d.ts +36 -12
- package/package.json +7 -2
- package/dist/cjs/index-DgZMn9B_.js +0 -2791
- package/dist/cjs/index-DgZMn9B_.js.map +0 -1
- package/dist/cjs/index-nzUNdMPh.js.map +0 -1
- package/dist/components/p-BYanlgdq.js.map +0 -1
- package/dist/components/p-BbGgijCS.js +0 -1164
- 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 +0 -2763
- package/dist/esm/index-CxieEK_G.js.map +0 -1
- package/dist/esm/index-oCOlsFCN.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
- package/dist/stencil/p-oCOlsFCN.js +0 -3
- package/dist/stencil/p-oCOlsFCN.js.map +0 -1
- /package/dist/stencil/{p-25d1e040.entry.js.map → p-8b831c94.entry.js.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-C9hrbrUN.js';
|
|
2
2
|
import { K as KritzelMouseButton } from './p-D8W6LE-c.js';
|
|
3
|
-
import { e as KritzelBaseObject, f as KritzelBaseCommand, g as KritzelBaseTool, h as KritzelEventHelper, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, A as AddObjectCommand, i as KritzelToolRegistry, U as UpdateObjectCommand, d as KritzelKeyboardHelper } from './p-
|
|
3
|
+
import { e as KritzelBaseObject, f as KritzelBaseCommand, g as KritzelBaseTool, h as KritzelEventHelper, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, A as AddObjectCommand, i as KritzelToolRegistry, U as UpdateObjectCommand, d as KritzelKeyboardHelper } from './p-BuDVaqTF.js';
|
|
4
4
|
import { K as KritzelWorkspace } from './p-YqK8ch2R.js';
|
|
5
|
-
import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-
|
|
5
|
+
import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-DqsgZIHC.js';
|
|
6
6
|
import { O as ObjectHelper } from './p-B0kd2rUI.js';
|
|
7
7
|
import { K as KritzelDevicesHelper } from './p-l10It7Nm.js';
|
|
8
|
-
import { d as defineCustomElement$2 } from './p-
|
|
9
|
-
import { d as defineCustomElement$1 } from './p-
|
|
8
|
+
import { d as defineCustomElement$2 } from './p-ByAzDzS5.js';
|
|
9
|
+
import { d as defineCustomElement$1 } from './p-D27d2rKT.js';
|
|
10
10
|
|
|
11
11
|
class KritzelImage extends KritzelBaseObject {
|
|
12
12
|
__class__ = 'KritzelImage';
|
|
@@ -154,13 +154,13 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
154
154
|
handlePointerDown(event) {
|
|
155
155
|
if (event.pointerType === 'mouse') {
|
|
156
156
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
157
|
-
this._core.store.
|
|
157
|
+
this._core.store.state.isErasing = true;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
if (event.pointerType === 'touch') {
|
|
161
161
|
this.touchStartTimeout = setTimeout(() => {
|
|
162
162
|
if (this._core.store.state.pointers.size === 1 && !this._core.store.state.isScaling) {
|
|
163
|
-
this._core.store.
|
|
163
|
+
this._core.store.state.isErasing = true;
|
|
164
164
|
}
|
|
165
165
|
}, 80);
|
|
166
166
|
}
|
|
@@ -206,7 +206,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
206
206
|
if (removeCommands.length > 0) {
|
|
207
207
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
208
208
|
}
|
|
209
|
-
this._core.store.
|
|
209
|
+
this._core.store.state.isErasing = false;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
if (event.pointerType === 'touch') {
|
|
@@ -221,7 +221,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
221
221
|
if (removeCommands.length > 0) {
|
|
222
222
|
this._core.history.executeCommand(new BatchCommand(this._core, this, removeCommands));
|
|
223
223
|
}
|
|
224
|
-
this._core.store.
|
|
224
|
+
this._core.store.state.isErasing = false;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -235,12 +235,12 @@ class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
235
235
|
}
|
|
236
236
|
execute() {
|
|
237
237
|
this._core.store.state.objectsMap.remove(object => object.id === this.previousSelectionGroup?.id);
|
|
238
|
-
this._core.store.
|
|
238
|
+
this._core.store.state.selectionGroup = null;
|
|
239
239
|
}
|
|
240
240
|
undo() {
|
|
241
241
|
if (this.previousSelectionGroup) {
|
|
242
242
|
this._core.store.state.objectsMap.insert(this.previousSelectionGroup);
|
|
243
|
-
this._core.store.
|
|
243
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
@@ -271,7 +271,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
271
271
|
});
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
this._core.store.
|
|
274
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
275
275
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
276
276
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
277
277
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -279,7 +279,7 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
undo() {
|
|
282
|
-
this._core.store.
|
|
282
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
283
283
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
284
284
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
285
285
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -303,6 +303,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
303
303
|
endX;
|
|
304
304
|
endY;
|
|
305
305
|
hasMoved = false;
|
|
306
|
+
trackedPointerId = null;
|
|
306
307
|
constructor(core) {
|
|
307
308
|
super(core);
|
|
308
309
|
}
|
|
@@ -314,6 +315,11 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
314
315
|
this.endX = 0;
|
|
315
316
|
this.endY = 0;
|
|
316
317
|
this.hasMoved = false;
|
|
318
|
+
this.trackedPointerId = null;
|
|
319
|
+
}
|
|
320
|
+
cancelPendingDrag() {
|
|
321
|
+
this._core.store.state.isDragging = false;
|
|
322
|
+
this.reset();
|
|
317
323
|
}
|
|
318
324
|
handlePointerDown(event) {
|
|
319
325
|
if (event.pointerType === 'mouse') {
|
|
@@ -321,13 +327,20 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
321
327
|
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
322
328
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
323
329
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
324
|
-
this._core.store.
|
|
330
|
+
this._core.store.state.isDragging = true;
|
|
325
331
|
this.dragStartX = clientX;
|
|
326
332
|
this.dragStartY = clientY;
|
|
327
333
|
this.startX = this.dragStartX;
|
|
328
334
|
this.startY = this.dragStartY;
|
|
335
|
+
this.trackedPointerId = event.pointerId;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
this.trackedPointerId = null;
|
|
329
339
|
}
|
|
330
340
|
}
|
|
341
|
+
else {
|
|
342
|
+
this.trackedPointerId = null;
|
|
343
|
+
}
|
|
331
344
|
}
|
|
332
345
|
if (event.pointerType === 'touch') {
|
|
333
346
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
@@ -339,11 +352,18 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
339
352
|
this.dragStartY = y;
|
|
340
353
|
this.startX = x;
|
|
341
354
|
this.startY = y;
|
|
355
|
+
this.trackedPointerId = event.pointerId;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
this.trackedPointerId = null;
|
|
342
359
|
}
|
|
343
360
|
}
|
|
344
361
|
}
|
|
345
362
|
}
|
|
346
363
|
handlePointerMove(event) {
|
|
364
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
347
367
|
if (event.pointerType === 'mouse') {
|
|
348
368
|
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
349
369
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
@@ -364,7 +384,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
364
384
|
!this._core.store.state.isRotationHandleSelected) {
|
|
365
385
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
366
386
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
367
|
-
this._core.store.
|
|
387
|
+
this._core.store.state.isDragging = true;
|
|
368
388
|
this.endX = x;
|
|
369
389
|
this.endY = y;
|
|
370
390
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
@@ -381,26 +401,28 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
381
401
|
}
|
|
382
402
|
}
|
|
383
403
|
handlePointerUp(event) {
|
|
404
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
384
407
|
if (event.pointerType === 'mouse') {
|
|
385
408
|
if (this._core.store.state.isDragging) {
|
|
386
|
-
this._core.store.
|
|
409
|
+
this._core.store.state.isDragging = false;
|
|
387
410
|
if (this.hasMoved) {
|
|
388
411
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
389
|
-
this._core.store.
|
|
412
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
390
413
|
}
|
|
391
|
-
this.reset();
|
|
392
414
|
}
|
|
393
415
|
}
|
|
394
416
|
if (event.pointerType === 'touch') {
|
|
395
417
|
if (this._core.store.state.isDragging) {
|
|
396
|
-
this._core.store.
|
|
418
|
+
this._core.store.state.isDragging = false;
|
|
397
419
|
if (this.hasMoved) {
|
|
398
420
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
399
|
-
this._core.store.
|
|
421
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
400
422
|
}
|
|
401
|
-
this.reset();
|
|
402
423
|
}
|
|
403
424
|
}
|
|
425
|
+
this.reset();
|
|
404
426
|
}
|
|
405
427
|
}
|
|
406
428
|
|
|
@@ -423,7 +445,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
423
445
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
424
446
|
}
|
|
425
447
|
execute() {
|
|
426
|
-
this._core.store.
|
|
448
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
427
449
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
428
450
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
429
451
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -431,7 +453,7 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
431
453
|
});
|
|
432
454
|
}
|
|
433
455
|
undo() {
|
|
434
|
-
this._core.store.
|
|
456
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
435
457
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
436
458
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
437
459
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -460,7 +482,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
460
482
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
461
483
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
462
484
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
463
|
-
this._core.store.
|
|
485
|
+
this._core.store.state.isResizing = true;
|
|
464
486
|
this.initialMouseX = clientX;
|
|
465
487
|
this.initialMouseY = clientY;
|
|
466
488
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -480,7 +502,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
480
502
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
481
503
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
482
504
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
483
|
-
this._core.store.
|
|
505
|
+
this._core.store.state.isResizing = true;
|
|
484
506
|
this.initialMouseX = clientX;
|
|
485
507
|
this.initialMouseY = clientY;
|
|
486
508
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -574,16 +596,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
574
596
|
if (event.pointerType === 'mouse') {
|
|
575
597
|
if (this._core.store.state.isResizing) {
|
|
576
598
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
577
|
-
this._core.store.
|
|
578
|
-
this._core.store.
|
|
599
|
+
this._core.store.state.isResizing = false;
|
|
600
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
579
601
|
this.reset();
|
|
580
602
|
}
|
|
581
603
|
}
|
|
582
604
|
if (event.pointerType === 'touch') {
|
|
583
605
|
if (this._core.store.state.isResizing) {
|
|
584
606
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
585
|
-
this._core.store.
|
|
586
|
-
this._core.store.
|
|
607
|
+
this._core.store.state.isResizing = false;
|
|
608
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
587
609
|
this.reset();
|
|
588
610
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
589
611
|
}
|
|
@@ -602,7 +624,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
602
624
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
603
625
|
}
|
|
604
626
|
execute() {
|
|
605
|
-
this._core.store.
|
|
627
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
606
628
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
607
629
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
608
630
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -610,7 +632,7 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
610
632
|
});
|
|
611
633
|
}
|
|
612
634
|
undo() {
|
|
613
|
-
this._core.store.
|
|
635
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
614
636
|
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
615
637
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
616
638
|
this._core.store.state.objectsMap.update(object);
|
|
@@ -638,7 +660,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
638
660
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
639
661
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
640
662
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
641
|
-
this._core.store.
|
|
663
|
+
this._core.store.state.isRotating = true;
|
|
642
664
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
643
665
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
644
666
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -659,7 +681,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
659
681
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
660
682
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
661
683
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
662
|
-
this._core.store.
|
|
684
|
+
this._core.store.state.isRotating = true;
|
|
663
685
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
664
686
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
665
687
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -710,16 +732,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
710
732
|
if (event.pointerType === 'mouse') {
|
|
711
733
|
if (this._core.store.state.isRotating) {
|
|
712
734
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
713
|
-
this._core.store.
|
|
714
|
-
this._core.store.
|
|
735
|
+
this._core.store.state.isRotating = false;
|
|
736
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
715
737
|
this.reset();
|
|
716
738
|
}
|
|
717
739
|
}
|
|
718
740
|
if (event.pointerType === 'touch') {
|
|
719
741
|
if (this._core.store.state.isRotating) {
|
|
720
742
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
721
|
-
this._core.store.
|
|
722
|
-
this._core.store.
|
|
743
|
+
this._core.store.state.isRotating = false;
|
|
744
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
723
745
|
this.reset();
|
|
724
746
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
725
747
|
}
|
|
@@ -757,13 +779,13 @@ class AddSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
757
779
|
execute() {
|
|
758
780
|
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox || object instanceof KritzelSelectionGroup);
|
|
759
781
|
this._core.store.state.objectsMap.insert(this.selectionGroup);
|
|
760
|
-
this._core.store.
|
|
761
|
-
this._core.store.
|
|
782
|
+
this._core.store.state.selectionGroup = this.selectionGroup;
|
|
783
|
+
this._core.store.state.selectionBox = null;
|
|
762
784
|
}
|
|
763
785
|
undo() {
|
|
764
786
|
this._core.store.state.objectsMap.remove(object => object.id === this.selectionGroup.id);
|
|
765
|
-
this._core.store.
|
|
766
|
-
this._core.store.
|
|
787
|
+
this._core.store.state.selectionGroup = this.previousSelectionGroup;
|
|
788
|
+
this._core.store.state.selectionBox = null;
|
|
767
789
|
}
|
|
768
790
|
}
|
|
769
791
|
|
|
@@ -823,14 +845,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
823
845
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
824
846
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
825
847
|
}
|
|
826
|
-
this._core.store.
|
|
848
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
827
849
|
if (this._core.store.state.isSelecting) {
|
|
828
850
|
if (this.isSelectionClick) {
|
|
829
|
-
|
|
830
|
-
const y = this._core.store.state.pointerY;
|
|
831
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
832
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
833
|
-
this.removeSelectionBox();
|
|
851
|
+
this.handleSelectionClick(event);
|
|
834
852
|
}
|
|
835
853
|
if (this.isSelectionDrag) {
|
|
836
854
|
this.updateMouseSelection(event);
|
|
@@ -846,27 +864,23 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
846
864
|
if (this._core.store.state.selectionGroup?.objects.length === 1 && hasObjectsMoved === false) {
|
|
847
865
|
this._core.store.state.selectionGroup.objects[0].edit();
|
|
848
866
|
}
|
|
849
|
-
this._core.store.
|
|
867
|
+
this._core.store.state.hasObjectsChanged = false;
|
|
850
868
|
if (this._core.store.state.isSelecting) {
|
|
851
869
|
if (this.isSelectionClick) {
|
|
852
|
-
|
|
853
|
-
const y = this._core.store.state.pointerY;
|
|
854
|
-
const selectedObject = this._core.getObjectsFromPointerEvent(event, '.object').find(obj => obj.hitTest(x, y));
|
|
855
|
-
this.addObjectToSelectionGroup(selectedObject);
|
|
856
|
-
this.removeSelectionBox();
|
|
870
|
+
this.handleSelectionClick(event);
|
|
857
871
|
}
|
|
858
872
|
if (this.isSelectionDrag) {
|
|
859
873
|
this.updateTouchSelection();
|
|
860
874
|
this.addSelectedObjectsToSelectionGroup();
|
|
861
875
|
this.removeSelectionBox();
|
|
862
876
|
}
|
|
863
|
-
this._core.store.
|
|
877
|
+
this._core.store.state.skipContextMenu = false;
|
|
864
878
|
}
|
|
865
879
|
}
|
|
866
880
|
}
|
|
867
881
|
removeSelectionBox() {
|
|
868
|
-
this._core.store.
|
|
869
|
-
this._core.store.
|
|
882
|
+
this._core.store.state.selectionBox = null;
|
|
883
|
+
this._core.store.state.isSelecting = false;
|
|
870
884
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox);
|
|
871
885
|
}
|
|
872
886
|
startMouseSelection(event) {
|
|
@@ -878,9 +892,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
878
892
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
879
893
|
selectionBox.translateX = this.startX;
|
|
880
894
|
selectionBox.translateY = this.startY;
|
|
881
|
-
this._core.store.
|
|
882
|
-
this._core.store.
|
|
883
|
-
this._core.store.
|
|
895
|
+
this._core.store.state.selectionGroup = null;
|
|
896
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
897
|
+
this._core.store.state.isSelecting = true;
|
|
884
898
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
885
899
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
886
900
|
}
|
|
@@ -900,9 +914,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
900
914
|
this.startY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
901
915
|
selectionBox.translateX = this.startX;
|
|
902
916
|
selectionBox.translateY = this.startY;
|
|
903
|
-
this._core.store.
|
|
904
|
-
this._core.store.
|
|
905
|
-
this._core.store.
|
|
917
|
+
this._core.store.state.selectionGroup = null;
|
|
918
|
+
this._core.store.state.selectionBox = selectionBox;
|
|
919
|
+
this._core.store.state.isSelecting = true;
|
|
906
920
|
this._core.store.state.objectsMap.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
|
|
907
921
|
this._core.store.state.objectsMap.insert(selectionBox);
|
|
908
922
|
}
|
|
@@ -914,11 +928,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
914
928
|
if (selectionBox) {
|
|
915
929
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
916
930
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
917
|
-
|
|
918
|
-
|
|
931
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
932
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
933
|
+
selectionBox.width = width;
|
|
934
|
+
selectionBox.height = height;
|
|
919
935
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
920
936
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
921
|
-
|
|
937
|
+
if (width > 0 || height > 0) {
|
|
938
|
+
this.updateSelectedObjects();
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
this.clearSelectionPreview();
|
|
942
|
+
}
|
|
922
943
|
}
|
|
923
944
|
}
|
|
924
945
|
updateTouchSelection() {
|
|
@@ -934,11 +955,18 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
934
955
|
if (selectionBox) {
|
|
935
956
|
const currentX = (clientX - this._core.store.state.translateX) / selectionBox.scale;
|
|
936
957
|
const currentY = (clientY - this._core.store.state.translateY) / selectionBox.scale;
|
|
937
|
-
|
|
938
|
-
|
|
958
|
+
const width = Math.abs(currentX - this.startX) * selectionBox.scale;
|
|
959
|
+
const height = Math.abs(currentY - this.startY) * selectionBox.scale;
|
|
960
|
+
selectionBox.width = width;
|
|
961
|
+
selectionBox.height = height;
|
|
939
962
|
selectionBox.translateX = Math.min(currentX, this.startX);
|
|
940
963
|
selectionBox.translateY = Math.min(currentY, this.startY);
|
|
941
|
-
|
|
964
|
+
if (width > 0 || height > 0) {
|
|
965
|
+
this.updateSelectedObjects();
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
this.clearSelectionPreview();
|
|
969
|
+
}
|
|
942
970
|
}
|
|
943
971
|
}
|
|
944
972
|
updateSelectedObjects() {
|
|
@@ -946,6 +974,28 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
946
974
|
.filter(o => !(o instanceof KrtizelSelectionBox))
|
|
947
975
|
.forEach(object => (object.isSelected = object.hitTestPolygon(this._core.store.state.selectionBox.rotatedPolygon)));
|
|
948
976
|
}
|
|
977
|
+
handleSelectionClick(event) {
|
|
978
|
+
const selectedObject = this.getTopmostHitObject(event);
|
|
979
|
+
this.clearSelectionPreview();
|
|
980
|
+
this.addObjectToSelectionGroup(selectedObject);
|
|
981
|
+
this.removeSelectionBox();
|
|
982
|
+
}
|
|
983
|
+
getTopmostHitObject(event) {
|
|
984
|
+
const pointerX = this._core.store.state.pointerX;
|
|
985
|
+
const pointerY = this._core.store.state.pointerY;
|
|
986
|
+
const overlappingObjects = this._core.getObjectsFromPointerEvent(event, '.object');
|
|
987
|
+
for (const object of overlappingObjects) {
|
|
988
|
+
if (object.hitTest(pointerX, pointerY)) {
|
|
989
|
+
return object;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
clearSelectionPreview() {
|
|
995
|
+
this._core.store.allNonSelectionObjects.forEach(object => {
|
|
996
|
+
object.isSelected = false;
|
|
997
|
+
});
|
|
998
|
+
}
|
|
949
999
|
addObjectToSelectionGroup(object) {
|
|
950
1000
|
if (!object) {
|
|
951
1001
|
return;
|
|
@@ -962,7 +1012,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
962
1012
|
if (selectedObjects.length === 0) {
|
|
963
1013
|
return;
|
|
964
1014
|
}
|
|
965
|
-
this._core.store.
|
|
1015
|
+
this._core.store.state.selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
966
1016
|
selectedObjects.forEach(o => {
|
|
967
1017
|
this._core.store.state.selectionGroup.addOrRemove(o);
|
|
968
1018
|
o.isSelected = false;
|
|
@@ -1012,9 +1062,9 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
1012
1062
|
}
|
|
1013
1063
|
if (event.pointerType === 'mouse') {
|
|
1014
1064
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
1015
|
-
this._core.store.
|
|
1016
|
-
this._core.store.
|
|
1017
|
-
this._core.store.
|
|
1065
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
1066
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
1067
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
1018
1068
|
const selectedObject = this.getSelectedObject(event);
|
|
1019
1069
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
1020
1070
|
if ((selectedObject === null || isDifferentObject) &&
|
|
@@ -1038,13 +1088,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
1038
1088
|
return;
|
|
1039
1089
|
}
|
|
1040
1090
|
if (this._core.store.state.pointers.size === 1) {
|
|
1041
|
-
this._core.store.
|
|
1042
|
-
this._core.store.
|
|
1043
|
-
this._core.store.
|
|
1091
|
+
this._core.store.state.isResizeHandleSelected = this.isHandleSelected(event);
|
|
1092
|
+
this._core.store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
|
|
1093
|
+
this._core.store.state.resizeHandleType = this.getHandleType(event);
|
|
1044
1094
|
const selectedObject = this.getSelectedObject(event);
|
|
1045
1095
|
const isDifferentObject = selectedObject && this._core.store.state.selectionGroup && selectedObject.id !== this._core.store.state.selectionGroup.id;
|
|
1046
1096
|
if (!this._core.store.state.selectionGroup && selectedObject) {
|
|
1047
|
-
this._core.store.
|
|
1097
|
+
this._core.store.state.skipContextMenu = true;
|
|
1048
1098
|
}
|
|
1049
1099
|
if ((selectedObject === null || isDifferentObject) &&
|
|
1050
1100
|
this._core.store.state.selectionGroup &&
|
|
@@ -1315,7 +1365,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
1315
1365
|
}
|
|
1316
1366
|
copy() {
|
|
1317
1367
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
1318
|
-
this.objects
|
|
1368
|
+
this.objects
|
|
1369
|
+
.sort((a, b) => a.zIndex - b.zIndex)
|
|
1370
|
+
.forEach(obj => {
|
|
1319
1371
|
const copiedObject = obj.copy();
|
|
1320
1372
|
selectionGroup.addOrRemove(copiedObject);
|
|
1321
1373
|
});
|
|
@@ -1467,18 +1519,18 @@ class KritzelViewport {
|
|
|
1467
1519
|
startY = 0;
|
|
1468
1520
|
constructor(core, host) {
|
|
1469
1521
|
this._core = core;
|
|
1470
|
-
this._core.store.
|
|
1471
|
-
this._core.store.
|
|
1472
|
-
this._core.store.
|
|
1473
|
-
this._core.store.
|
|
1474
|
-
this._core.store.
|
|
1475
|
-
this._core.store.
|
|
1476
|
-
this._core.store.
|
|
1522
|
+
this._core.store.state.host = host;
|
|
1523
|
+
this._core.store.state.viewportWidth = host.clientWidth;
|
|
1524
|
+
this._core.store.state.viewportHeight = host.clientHeight;
|
|
1525
|
+
this._core.store.state.startX = 0;
|
|
1526
|
+
this._core.store.state.startY = 0;
|
|
1527
|
+
this._core.store.state.translateX = 0;
|
|
1528
|
+
this._core.store.state.translateY = 0;
|
|
1477
1529
|
}
|
|
1478
1530
|
handleResize() {
|
|
1479
|
-
this._core.store.
|
|
1480
|
-
this._core.store.
|
|
1481
|
-
this._core.store.
|
|
1531
|
+
this._core.store.state.viewportWidth = this._core.store.state.host.clientWidth;
|
|
1532
|
+
this._core.store.state.viewportHeight = this._core.store.state.host.clientHeight;
|
|
1533
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1482
1534
|
this._core.rerender();
|
|
1483
1535
|
}
|
|
1484
1536
|
handlePointerDown(event) {
|
|
@@ -1486,16 +1538,16 @@ class KritzelViewport {
|
|
|
1486
1538
|
const adjustedClientX = event.clientX - this._core.store.offsetX;
|
|
1487
1539
|
const adjustedClientY = event.clientY - this._core.store.offsetY;
|
|
1488
1540
|
if (event.button === KritzelMouseButton.Right) {
|
|
1489
|
-
this._core.store.
|
|
1490
|
-
this._core.store.
|
|
1491
|
-
this._core.store.
|
|
1541
|
+
this._core.store.state.isPanning = true;
|
|
1542
|
+
this._core.store.state.startX = adjustedClientX;
|
|
1543
|
+
this._core.store.state.startY = adjustedClientY;
|
|
1492
1544
|
}
|
|
1493
1545
|
}
|
|
1494
1546
|
if (event.pointerType === 'touch') {
|
|
1495
1547
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1496
1548
|
if (activePointers.length === 2) {
|
|
1497
|
-
this._core.store.
|
|
1498
|
-
this._core.store.
|
|
1549
|
+
this._core.store.state.currentPath = null;
|
|
1550
|
+
this._core.store.state.isScaling = true;
|
|
1499
1551
|
const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;
|
|
1500
1552
|
const firstTouchY = activePointers[0].clientY - this._core.store.offsetY;
|
|
1501
1553
|
const secondTouchX = activePointers[1].clientX - this._core.store.offsetX;
|
|
@@ -1512,17 +1564,17 @@ class KritzelViewport {
|
|
|
1512
1564
|
const hostRect = this._core.store.state.host.getBoundingClientRect();
|
|
1513
1565
|
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1514
1566
|
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1515
|
-
this._core.store.
|
|
1516
|
-
this._core.store.
|
|
1567
|
+
this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1568
|
+
this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1517
1569
|
if (this._core.store.state.isPanning) {
|
|
1518
1570
|
const dx = xRelativeToHost - this._core.store.state.startX;
|
|
1519
1571
|
const dy = yRelativeToHost - this._core.store.state.startY;
|
|
1520
|
-
this._core.store.
|
|
1521
|
-
this._core.store.
|
|
1522
|
-
this._core.store.
|
|
1523
|
-
this._core.store.
|
|
1524
|
-
this._core.store.
|
|
1525
|
-
this._core.store.
|
|
1572
|
+
this._core.store.state.translateX += dx;
|
|
1573
|
+
this._core.store.state.translateY += dy;
|
|
1574
|
+
this._core.store.state.startX = xRelativeToHost;
|
|
1575
|
+
this._core.store.state.startY = yRelativeToHost;
|
|
1576
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1577
|
+
this._core.store.state.skipContextMenu = true;
|
|
1526
1578
|
this._core.rerender();
|
|
1527
1579
|
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
1528
1580
|
}
|
|
@@ -1531,8 +1583,8 @@ class KritzelViewport {
|
|
|
1531
1583
|
const hostRect = this._core.store.state.host.getBoundingClientRect();
|
|
1532
1584
|
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1533
1585
|
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1534
|
-
this._core.store.
|
|
1535
|
-
this._core.store.
|
|
1586
|
+
this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1587
|
+
this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1536
1588
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1537
1589
|
if (activePointers.length === 2) {
|
|
1538
1590
|
const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;
|
|
@@ -1545,20 +1597,20 @@ class KritzelViewport {
|
|
|
1545
1597
|
const scaleRatio = currentTouchDistance / this.initialTouchDistance;
|
|
1546
1598
|
const newScale = this._core.store.state.scale * scaleRatio;
|
|
1547
1599
|
if (newScale > this._core.store.state.scaleMax || newScale < this._core.store.state.scaleMin) {
|
|
1548
|
-
this._core.store.
|
|
1549
|
-
this._core.store.
|
|
1600
|
+
this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX;
|
|
1601
|
+
this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY;
|
|
1550
1602
|
}
|
|
1551
1603
|
else {
|
|
1552
1604
|
const translateXAdjustment = (midpointX - this._core.store.state.translateX) * (scaleRatio - 1);
|
|
1553
1605
|
const translateYAdjustment = (midpointY - this._core.store.state.translateY) * (scaleRatio - 1);
|
|
1554
|
-
this._core.store.
|
|
1555
|
-
this._core.store.
|
|
1556
|
-
this._core.store.
|
|
1606
|
+
this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX - translateXAdjustment;
|
|
1607
|
+
this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY - translateYAdjustment;
|
|
1608
|
+
this._core.store.state.scale = newScale;
|
|
1557
1609
|
this.initialTouchDistance = currentTouchDistance;
|
|
1558
1610
|
}
|
|
1559
1611
|
this.startX = midpointX;
|
|
1560
1612
|
this.startY = midpointY;
|
|
1561
|
-
this._core.store.
|
|
1613
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1562
1614
|
this._core.rerender();
|
|
1563
1615
|
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
1564
1616
|
}
|
|
@@ -1567,12 +1619,12 @@ class KritzelViewport {
|
|
|
1567
1619
|
handlePointerUp(event) {
|
|
1568
1620
|
if (event.pointerType === 'mouse') {
|
|
1569
1621
|
if (this._core.store.state.isPanning) {
|
|
1570
|
-
this._core.store.
|
|
1622
|
+
this._core.store.state.isPanning = false;
|
|
1571
1623
|
this._core.rerender();
|
|
1572
1624
|
}
|
|
1573
1625
|
}
|
|
1574
1626
|
if (event.pointerType === 'touch') {
|
|
1575
|
-
this._core.store.
|
|
1627
|
+
this._core.store.state.isScaling = false;
|
|
1576
1628
|
this._core.rerender();
|
|
1577
1629
|
}
|
|
1578
1630
|
}
|
|
@@ -1585,33 +1637,52 @@ class KritzelViewport {
|
|
|
1585
1637
|
this.handlePan(event);
|
|
1586
1638
|
}
|
|
1587
1639
|
}
|
|
1640
|
+
centerInViewport(object) {
|
|
1641
|
+
const { scale, viewportWidth, viewportHeight } = this._core.store.state;
|
|
1642
|
+
const { x, y, width, height } = object.rotatedBoundingBox;
|
|
1643
|
+
const objectCenterX = x + width / 2;
|
|
1644
|
+
const objectCenterY = y + height / 2;
|
|
1645
|
+
this._core.store.state.translateX = viewportWidth / 2 - objectCenterX * scale;
|
|
1646
|
+
this._core.store.state.translateY = viewportHeight / 2 - objectCenterY * scale;
|
|
1647
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1648
|
+
this._core.rerender();
|
|
1649
|
+
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
1650
|
+
}
|
|
1651
|
+
centerFitInViewport(object) {
|
|
1652
|
+
const scaleX = this._core.store.state.viewportWidth / (object.rotatedBoundingBox.width * 1.1);
|
|
1653
|
+
const scaleY = this._core.store.state.viewportHeight / (object.rotatedBoundingBox.height * 1.1);
|
|
1654
|
+
const newScale = Math.min(scaleX, scaleY, this._core.store.state.scaleMax);
|
|
1655
|
+
const clampedScale = Math.max(newScale, this._core.store.state.scaleMin);
|
|
1656
|
+
this._core.store.state.scale = clampedScale;
|
|
1657
|
+
this.centerInViewport(object);
|
|
1658
|
+
}
|
|
1588
1659
|
handleZoom(event) {
|
|
1589
|
-
this._core.store.
|
|
1660
|
+
this._core.store.state.isScaling = true;
|
|
1590
1661
|
const rect = this._core.store.state.host.getBoundingClientRect();
|
|
1591
1662
|
const xRelativeToHost = event.clientX - rect.left;
|
|
1592
1663
|
const yRelativeToHost = event.clientY - rect.top;
|
|
1593
|
-
this._core.store.
|
|
1594
|
-
this._core.store.
|
|
1664
|
+
this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1665
|
+
this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1595
1666
|
const delta = event.deltaY > 0 ? -this._core.store.state.scaleStep * this._core.store.state.scale : this._core.store.state.scaleStep * this._core.store.state.scale;
|
|
1596
1667
|
const newScale = Math.min(this._core.store.state.scaleMax, Math.max(this._core.store.state.scaleMin, this._core.store.state.scale + delta));
|
|
1597
1668
|
const scaleRatio = newScale / this._core.store.state.scale;
|
|
1598
1669
|
const translateXAdjustment = (xRelativeToHost - this._core.store.state.translateX) * (scaleRatio - 1);
|
|
1599
1670
|
const translateYAdjustment = (yRelativeToHost - this._core.store.state.translateY) * (scaleRatio - 1);
|
|
1600
|
-
this._core.store.
|
|
1601
|
-
this._core.store.
|
|
1602
|
-
this._core.store.
|
|
1603
|
-
this._core.store.
|
|
1671
|
+
this._core.store.state.scale = newScale;
|
|
1672
|
+
this._core.store.state.translateX = this._core.store.state.translateX - translateXAdjustment;
|
|
1673
|
+
this._core.store.state.translateY = this._core.store.state.translateY - translateYAdjustment;
|
|
1674
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1604
1675
|
this._core.rerender();
|
|
1605
1676
|
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
1606
1677
|
setTimeout(() => {
|
|
1607
|
-
this._core.store.
|
|
1678
|
+
this._core.store.state.isScaling = false;
|
|
1608
1679
|
}, 300);
|
|
1609
1680
|
}
|
|
1610
1681
|
handlePan(event) {
|
|
1611
1682
|
const panSpeed = 0.8;
|
|
1612
|
-
this._core.store.
|
|
1613
|
-
this._core.store.
|
|
1614
|
-
this._core.store.
|
|
1683
|
+
this._core.store.state.translateX = this._core.store.state.translateX - event.deltaX * panSpeed;
|
|
1684
|
+
this._core.store.state.translateY = this._core.store.state.translateY - event.deltaY * panSpeed;
|
|
1685
|
+
this._core.store.state.hasViewportChanged = true;
|
|
1615
1686
|
this._core.rerender();
|
|
1616
1687
|
this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
|
|
1617
1688
|
}
|
|
@@ -1643,8 +1714,8 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
1643
1714
|
},
|
|
1644
1715
|
{ key: 'v', ctrl: true, condition: c => !!c.store.state.copiedObjects && !c.store.state.activeText, action: c => c.paste() },
|
|
1645
1716
|
// Text editing
|
|
1646
|
-
{ key: 'a', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.selectAll() },
|
|
1647
|
-
{ key: 'v', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.insertFromClipboard() },
|
|
1717
|
+
// { key: 'a', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.selectAll() },
|
|
1718
|
+
// { key: 'v', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.insertFromClipboard() },
|
|
1648
1719
|
// Object layering
|
|
1649
1720
|
{ key: '+', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.bringForward() },
|
|
1650
1721
|
{ key: '-', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.sendBackward() },
|
|
@@ -1661,7 +1732,7 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
1661
1732
|
toolInstance.onActivate();
|
|
1662
1733
|
}
|
|
1663
1734
|
handleKeyDown(event) {
|
|
1664
|
-
this._core.store.
|
|
1735
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
1665
1736
|
const shortcut = this.shortcuts.find(s => s.key === event.key && !!s.ctrl === event.ctrlKey && !!s.shift === event.shiftKey && (!s.condition || s.condition(this._core)));
|
|
1666
1737
|
if (shortcut) {
|
|
1667
1738
|
event.preventDefault();
|
|
@@ -1669,7 +1740,7 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
1669
1740
|
}
|
|
1670
1741
|
}
|
|
1671
1742
|
handleKeyUp(event) {
|
|
1672
|
-
this._core.store.
|
|
1743
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
1673
1744
|
}
|
|
1674
1745
|
}
|
|
1675
1746
|
|
|
@@ -1686,23 +1757,30 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
1686
1757
|
return;
|
|
1687
1758
|
}
|
|
1688
1759
|
if (this._core.store.state.skipContextMenu) {
|
|
1689
|
-
this._core.store.
|
|
1760
|
+
this._core.store.state.skipContextMenu = false;
|
|
1690
1761
|
return;
|
|
1691
1762
|
}
|
|
1763
|
+
const selectionTool = this._core.store.state.activeTool;
|
|
1764
|
+
selectionTool?.moveHandler?.cancelPendingDrag();
|
|
1765
|
+
if (this._core.store.state.selectionBox) {
|
|
1766
|
+
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
|
|
1767
|
+
this._core.store.state.selectionBox = null;
|
|
1768
|
+
this._core.store.state.isSelecting = false;
|
|
1769
|
+
}
|
|
1692
1770
|
const selectedObject = this._core.getObjectFromPointerEvent(event, '.object');
|
|
1693
|
-
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
1771
|
+
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup) && !(selectedObject instanceof KrtizelSelectionBox)) {
|
|
1694
1772
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
1695
1773
|
selectionGroup.addOrRemove(selectedObject);
|
|
1696
1774
|
selectionGroup.isSelected = true;
|
|
1697
1775
|
selectionGroup.rotation = selectedObject.rotation;
|
|
1698
|
-
this._core.store.
|
|
1776
|
+
this._core.store.state.isSelecting = false;
|
|
1699
1777
|
const batch = new BatchCommand(this._core, this, [
|
|
1700
1778
|
new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),
|
|
1701
1779
|
new AddSelectionGroupCommand(this._core, this, selectionGroup),
|
|
1702
1780
|
]);
|
|
1703
1781
|
this._core.history.executeCommand(batch);
|
|
1704
1782
|
}
|
|
1705
|
-
this._core.store.
|
|
1783
|
+
this._core.store.state.contextMenuItems = this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
1706
1784
|
let x = event.clientX - this._core.store.offsetX;
|
|
1707
1785
|
let y = event.clientY - this._core.store.offsetY;
|
|
1708
1786
|
const menuWidthEstimate = 150;
|
|
@@ -1716,10 +1794,10 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
1716
1794
|
}
|
|
1717
1795
|
x = Math.max(margin, x);
|
|
1718
1796
|
y = Math.max(margin, y);
|
|
1719
|
-
this._core.store.
|
|
1720
|
-
this._core.store.
|
|
1721
|
-
this._core.store.
|
|
1722
|
-
this._core.store.
|
|
1797
|
+
this._core.store.state.contextMenuX = x;
|
|
1798
|
+
this._core.store.state.contextMenuY = y;
|
|
1799
|
+
this._core.store.state.isContextMenuVisible = true;
|
|
1800
|
+
this._core.store.state.isEnabled = false;
|
|
1723
1801
|
this._core.rerender();
|
|
1724
1802
|
}
|
|
1725
1803
|
}
|
|
@@ -2040,14 +2118,14 @@ class UpdateViewportCommand extends KritzelBaseCommand {
|
|
|
2040
2118
|
};
|
|
2041
2119
|
}
|
|
2042
2120
|
execute() {
|
|
2043
|
-
this._core.store.
|
|
2044
|
-
this._core.store.
|
|
2045
|
-
this._core.store.
|
|
2121
|
+
this._core.store.state.scale = this.currentViewport.scale;
|
|
2122
|
+
this._core.store.state.translateX = this.currentViewport.translateX;
|
|
2123
|
+
this._core.store.state.translateY = this.currentViewport.translateY;
|
|
2046
2124
|
}
|
|
2047
2125
|
undo() {
|
|
2048
|
-
this._core.store.
|
|
2049
|
-
this._core.store.
|
|
2050
|
-
this._core.store.
|
|
2126
|
+
this._core.store.state.scale = this.previousViewport.scale;
|
|
2127
|
+
this._core.store.state.translateX = this.previousViewport.translateX;
|
|
2128
|
+
this._core.store.state.translateY = this.previousViewport.translateY;
|
|
2051
2129
|
}
|
|
2052
2130
|
}
|
|
2053
2131
|
|
|
@@ -2145,7 +2223,7 @@ class KritzelHistory {
|
|
|
2145
2223
|
if (this._core.store.state.hasViewportChanged) {
|
|
2146
2224
|
const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
|
|
2147
2225
|
command.undo();
|
|
2148
|
-
this._core.store.
|
|
2226
|
+
this._core.store.state.hasViewportChanged = false;
|
|
2149
2227
|
this._core.rerender();
|
|
2150
2228
|
return;
|
|
2151
2229
|
}
|
|
@@ -2156,7 +2234,7 @@ class KritzelHistory {
|
|
|
2156
2234
|
console.info('undo', command);
|
|
2157
2235
|
this.redoStack.add(command);
|
|
2158
2236
|
}
|
|
2159
|
-
this._core.store.
|
|
2237
|
+
this._core.store.state.copiedObjects = null;
|
|
2160
2238
|
this._core.rerender();
|
|
2161
2239
|
}
|
|
2162
2240
|
redo() {
|
|
@@ -2176,7 +2254,7 @@ class KritzelHistory {
|
|
|
2176
2254
|
if (this.redoStack.isEmpty() === false) {
|
|
2177
2255
|
this.redoStack.clear();
|
|
2178
2256
|
}
|
|
2179
|
-
this._core.store.
|
|
2257
|
+
this._core.store.state.hasViewportChanged = false;
|
|
2180
2258
|
this.previousViewport = {
|
|
2181
2259
|
scale: this._core.store.state.scale,
|
|
2182
2260
|
scaleStep: this._core.store.state.scaleStep,
|
|
@@ -2236,11 +2314,14 @@ class KritzelStore {
|
|
|
2236
2314
|
return this._state;
|
|
2237
2315
|
}
|
|
2238
2316
|
get currentZIndex() {
|
|
2239
|
-
return this._state.objectsMap.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).
|
|
2317
|
+
return Math.max(0, ...this._state.objectsMap.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox)).map(o => o.zIndex)) + 1;
|
|
2240
2318
|
}
|
|
2241
2319
|
get allObjects() {
|
|
2242
2320
|
return this._state.objectsMap.allObjects();
|
|
2243
2321
|
}
|
|
2322
|
+
get allNonSelectionObjects() {
|
|
2323
|
+
return this._state.objectsMap.allObjects().filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox));
|
|
2324
|
+
}
|
|
2244
2325
|
get selectedObjects() {
|
|
2245
2326
|
return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.isSelected);
|
|
2246
2327
|
}
|
|
@@ -2314,18 +2395,21 @@ class KritzelCore {
|
|
|
2314
2395
|
const workspaces = await this.getWorkspaces();
|
|
2315
2396
|
const mostRecentWorkspace = [...workspaces].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0];
|
|
2316
2397
|
const fallbackWorkspace = new KritzelWorkspace(ObjectHelper.generateUUID(), 'New Workspace');
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
if (
|
|
2398
|
+
const candidateWorkspace = workspace ?? mostRecentWorkspace ?? fallbackWorkspace;
|
|
2399
|
+
const existingWorkspace = await this.getWorkspace(candidateWorkspace.id);
|
|
2400
|
+
if (existingWorkspace) {
|
|
2401
|
+
this._store.state.activeWorkspace = existingWorkspace;
|
|
2320
2402
|
await this.updateWorkspace(this._store.state.activeWorkspace);
|
|
2321
2403
|
}
|
|
2322
2404
|
else {
|
|
2405
|
+
this._store.state.activeWorkspace = candidateWorkspace;
|
|
2323
2406
|
await this.createWorkspace(this._store.state.activeWorkspace);
|
|
2324
2407
|
}
|
|
2325
|
-
this._store.
|
|
2326
|
-
|
|
2327
|
-
this._store.
|
|
2328
|
-
this._store.
|
|
2408
|
+
this._store.state.workspaces = await this.getWorkspaces();
|
|
2409
|
+
const viewport = this._store.state.activeWorkspace.viewport ?? { translateX: 0, translateY: 0, scale: 1 };
|
|
2410
|
+
this._store.state.translateX = viewport.translateX ?? 0;
|
|
2411
|
+
this._store.state.translateY = viewport.translateY ?? 0;
|
|
2412
|
+
this._store.state.scale = viewport.scale ?? 1;
|
|
2329
2413
|
await this.initializeWorkspaceObjects(this._store.state.activeWorkspace.id);
|
|
2330
2414
|
}
|
|
2331
2415
|
async initializeWorkspaceObjects(workspaceId) {
|
|
@@ -2420,7 +2504,7 @@ class KritzelCore {
|
|
|
2420
2504
|
const index = workspaces.findIndex(w => w.id === workspace.id);
|
|
2421
2505
|
if (index !== -1) {
|
|
2422
2506
|
workspaces[index] = workspace;
|
|
2423
|
-
this._store.
|
|
2507
|
+
this._store.state.workspaces = workspaces;
|
|
2424
2508
|
}
|
|
2425
2509
|
}
|
|
2426
2510
|
async deleteWorkspace(workspace) {
|
|
@@ -2430,7 +2514,7 @@ class KritzelCore {
|
|
|
2430
2514
|
const objectRange = IDBKeyRange.bound([workspace.id], [workspace.id, '\uffff']);
|
|
2431
2515
|
await this._database.deleteByRange('objects', objectRange);
|
|
2432
2516
|
await this._database.delete('workspaces', workspace.id);
|
|
2433
|
-
this._store.
|
|
2517
|
+
this._store.state.workspaces = this._store.state.workspaces.filter(ws => ws.id !== workspace.id);
|
|
2434
2518
|
}
|
|
2435
2519
|
rerender() {
|
|
2436
2520
|
if (this._kritzelEngine) {
|
|
@@ -2467,18 +2551,27 @@ class KritzelCore {
|
|
|
2467
2551
|
}
|
|
2468
2552
|
}
|
|
2469
2553
|
copy() {
|
|
2470
|
-
this._store.
|
|
2554
|
+
this._store.state.copiedObjects = this._store.state.selectionGroup.copy();
|
|
2471
2555
|
}
|
|
2472
2556
|
paste(x, y) {
|
|
2473
2557
|
const copiedObjects = this._store.state.copiedObjects;
|
|
2474
2558
|
copiedObjects.isSelected = true;
|
|
2475
|
-
this._store.
|
|
2559
|
+
this._store.state.copiedObjects = copiedObjects;
|
|
2476
2560
|
const adjustedX = x !== undefined ? x : this._store.state.copiedObjects.translateX + 25 / this._store.state.scale;
|
|
2477
2561
|
const adjustedY = y !== undefined ? y : this._store.state.copiedObjects.translateY + 25 / this._store.state.scale;
|
|
2478
2562
|
this._store.state.copiedObjects.updatePosition(adjustedX, adjustedY);
|
|
2563
|
+
this._store.state.copiedObjects.updateZIndices(this._store.currentZIndex);
|
|
2479
2564
|
const activeWorkspace = this._store.state.activeWorkspace;
|
|
2480
|
-
this.store.state.copiedObjects.
|
|
2481
|
-
|
|
2565
|
+
if (this.store.state.copiedObjects.workspaceId !== activeWorkspace.id) {
|
|
2566
|
+
this.store.state.copiedObjects.updateWorkspaceId(activeWorkspace.id);
|
|
2567
|
+
if (x !== undefined && y !== undefined) {
|
|
2568
|
+
this._store.state.copiedObjects.updatePosition(x, y);
|
|
2569
|
+
}
|
|
2570
|
+
else {
|
|
2571
|
+
this.store.state.copiedObjects.centerInViewport();
|
|
2572
|
+
}
|
|
2573
|
+
this.engine.viewport.centerFitInViewport(copiedObjects);
|
|
2574
|
+
}
|
|
2482
2575
|
const commands = [];
|
|
2483
2576
|
let previousSelectionGroup = null;
|
|
2484
2577
|
if (this._store.state.selectionGroup !== null) {
|
|
@@ -2489,13 +2582,14 @@ class KritzelCore {
|
|
|
2489
2582
|
const addCopiedObjectsAsSelectionGroupCommand = new AddSelectionGroupCommand(this, this, this._store.state.copiedObjects, previousSelectionGroup);
|
|
2490
2583
|
commands.push(...addCopiedObjectsCommands, addCopiedObjectsAsSelectionGroupCommand);
|
|
2491
2584
|
this.history.executeCommand(new BatchCommand(this, this, commands));
|
|
2492
|
-
this._store.
|
|
2493
|
-
this._store.
|
|
2585
|
+
this._store.state.isSelecting = false;
|
|
2586
|
+
this._store.state.copiedObjects = this._store.state.selectionGroup.copy();
|
|
2494
2587
|
this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
2495
2588
|
}
|
|
2496
2589
|
bringForward(object) {
|
|
2497
|
-
const max = this._store.allObjects.length + 1;
|
|
2498
2590
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
2591
|
+
const allNonSelectionObjectsWithoutCurrent = this._store.allNonSelectionObjects.filter(o => objects.findIndex(obj => obj.id === o.id) === -1);
|
|
2592
|
+
const max = allNonSelectionObjectsWithoutCurrent.length > 0 ? Math.max(...allNonSelectionObjectsWithoutCurrent.map(obj => obj.zIndex)) + 1 : 0;
|
|
2499
2593
|
const increaseZIndexCommands = objects.map(obj => {
|
|
2500
2594
|
if (obj.zIndex === max) {
|
|
2501
2595
|
return;
|
|
@@ -2505,8 +2599,9 @@ class KritzelCore {
|
|
|
2505
2599
|
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
2506
2600
|
}
|
|
2507
2601
|
sendBackward(object) {
|
|
2508
|
-
const min = 0;
|
|
2509
2602
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
2603
|
+
const allNonSelectionObjectsWithoutCurrent = this._store.allNonSelectionObjects.filter(o => objects.findIndex(obj => obj.id === o.id) === -1);
|
|
2604
|
+
const min = allNonSelectionObjectsWithoutCurrent.length > 0 ? Math.min(...allNonSelectionObjectsWithoutCurrent.map(obj => obj.zIndex)) - 1 : 0;
|
|
2510
2605
|
const decreaseZIndexCommands = objects.map(obj => {
|
|
2511
2606
|
if (obj.zIndex === min) {
|
|
2512
2607
|
return;
|
|
@@ -2516,16 +2611,18 @@ class KritzelCore {
|
|
|
2516
2611
|
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
2517
2612
|
}
|
|
2518
2613
|
bringToFront(object) {
|
|
2519
|
-
const max = Math.max(...this._store.allObjects.map(obj => obj.zIndex)) + 1;
|
|
2520
2614
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
2615
|
+
const allNonSelectionObjectsWithoutCurrent = this._store.allNonSelectionObjects.filter(o => objects.findIndex(obj => obj.id === o.id) === -1);
|
|
2616
|
+
const max = Math.max(...allNonSelectionObjectsWithoutCurrent.map(obj => obj.zIndex)) + 1;
|
|
2521
2617
|
const increaseZIndexCommands = objects.map(obj => {
|
|
2522
2618
|
return new UpdateObjectCommand(this, this, obj, { zIndex: max });
|
|
2523
2619
|
});
|
|
2524
2620
|
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
2525
2621
|
}
|
|
2526
2622
|
sendToBack(object) {
|
|
2527
|
-
const min = Math.min(...this._store.allObjects.map(obj => obj.zIndex)) - 1;
|
|
2528
2623
|
const objects = object ? [object] : this._store.state.selectionGroup.objects;
|
|
2624
|
+
const allNonSelectionObjectsWithoutCurrent = this._store.allNonSelectionObjects.filter(o => objects.findIndex(obj => obj.id === o.id) === -1);
|
|
2625
|
+
const min = Math.min(...allNonSelectionObjectsWithoutCurrent.map(obj => obj.zIndex)) - 1;
|
|
2529
2626
|
const decreaseZIndexCommands = objects.map(obj => {
|
|
2530
2627
|
return new UpdateObjectCommand(this, this, obj, { zIndex: min });
|
|
2531
2628
|
});
|
|
@@ -2541,7 +2638,7 @@ class KritzelCore {
|
|
|
2541
2638
|
selectionGroup.addOrRemove(obj);
|
|
2542
2639
|
});
|
|
2543
2640
|
selectionGroup.isSelected = true;
|
|
2544
|
-
this._store.
|
|
2641
|
+
this._store.state.selectionBox = selectionGroup;
|
|
2545
2642
|
if (objects.length === 1) {
|
|
2546
2643
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2547
2644
|
}
|
|
@@ -2558,7 +2655,7 @@ class KritzelCore {
|
|
|
2558
2655
|
selectionGroup.addOrRemove(obj);
|
|
2559
2656
|
});
|
|
2560
2657
|
selectionGroup.isSelected = true;
|
|
2561
|
-
this._store.
|
|
2658
|
+
this._store.state.isSelecting = false;
|
|
2562
2659
|
if (objectsInViewport.length === 1) {
|
|
2563
2660
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
2564
2661
|
}
|
|
@@ -2569,18 +2666,25 @@ class KritzelCore {
|
|
|
2569
2666
|
clearSelection() {
|
|
2570
2667
|
const command = new RemoveSelectionGroupCommand(this, this._store.state.selectionGroup);
|
|
2571
2668
|
this.history.executeCommand(command);
|
|
2572
|
-
this._store.
|
|
2573
|
-
this._store.
|
|
2574
|
-
this._store.
|
|
2575
|
-
this._store.
|
|
2576
|
-
this._store.
|
|
2669
|
+
this._store.state.selectionGroup = null;
|
|
2670
|
+
this._store.state.selectionBox = null;
|
|
2671
|
+
this._store.state.isSelecting = false;
|
|
2672
|
+
this._store.state.isResizeHandleSelected = false;
|
|
2673
|
+
this._store.state.isRotationHandleSelected = false;
|
|
2577
2674
|
this.rerender();
|
|
2578
2675
|
}
|
|
2579
2676
|
resetActiveText() {
|
|
2580
|
-
if (this._store.state.activeText
|
|
2581
|
-
|
|
2677
|
+
if (this._store.state.activeText) {
|
|
2678
|
+
if (this._store.state.activeText.isEmpty) {
|
|
2679
|
+
console.log('Deleting empty text object', this._store.state.activeText.id);
|
|
2680
|
+
this.deleteObject(this._store.state.activeText.id, true);
|
|
2681
|
+
}
|
|
2682
|
+
else {
|
|
2683
|
+
console.log('Saving active text object before resetting', this._store.state.activeText.id);
|
|
2684
|
+
this._store.state.activeText.save();
|
|
2685
|
+
}
|
|
2582
2686
|
}
|
|
2583
|
-
this._store.
|
|
2687
|
+
this._store.state.activeText = null;
|
|
2584
2688
|
}
|
|
2585
2689
|
getObjectFromPointerEvent(event, selector = '.object') {
|
|
2586
2690
|
const shadowRoot = this._store.state.host?.shadowRoot;
|
|
@@ -2635,7 +2739,7 @@ class KritzelCore {
|
|
|
2635
2739
|
}
|
|
2636
2740
|
}
|
|
2637
2741
|
|
|
2638
|
-
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}
|
|
2742
|
+
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p{margin:0;padding:0}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}";
|
|
2639
2743
|
|
|
2640
2744
|
const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine extends H {
|
|
2641
2745
|
get host() { return this; }
|
|
@@ -2653,10 +2757,10 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2653
2757
|
if (newValue > ABSOLUTE_SCALE_MAX) {
|
|
2654
2758
|
console.warn(`scaleMax cannot be greater than ${ABSOLUTE_SCALE_MAX}.`);
|
|
2655
2759
|
this.scaleMax = ABSOLUTE_SCALE_MAX;
|
|
2656
|
-
this.core.store.
|
|
2760
|
+
this.core.store.state.scaleMax = this.scaleMax;
|
|
2657
2761
|
}
|
|
2658
2762
|
else {
|
|
2659
|
-
this.core.store.
|
|
2763
|
+
this.core.store.state.scaleMax = newValue;
|
|
2660
2764
|
}
|
|
2661
2765
|
}
|
|
2662
2766
|
scaleMin = ABSOLUTE_SCALE_MIN;
|
|
@@ -2664,10 +2768,10 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2664
2768
|
if (newValue < ABSOLUTE_SCALE_MIN) {
|
|
2665
2769
|
console.warn(`scaleMin cannot be less than ${ABSOLUTE_SCALE_MIN}.`);
|
|
2666
2770
|
this.scaleMin = ABSOLUTE_SCALE_MIN;
|
|
2667
|
-
this.core.store.
|
|
2771
|
+
this.core.store.state.scaleMin = this.scaleMin;
|
|
2668
2772
|
}
|
|
2669
2773
|
else {
|
|
2670
|
-
this.core.store.
|
|
2774
|
+
this.core.store.state.scaleMin = newValue;
|
|
2671
2775
|
}
|
|
2672
2776
|
}
|
|
2673
2777
|
isEngineReady;
|
|
@@ -2774,11 +2878,11 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2774
2878
|
tool?.onActivate();
|
|
2775
2879
|
}
|
|
2776
2880
|
async disable() {
|
|
2777
|
-
this.core.store.
|
|
2881
|
+
this.core.store.state.isEnabled = false;
|
|
2778
2882
|
this.core.rerender();
|
|
2779
2883
|
}
|
|
2780
2884
|
async enable() {
|
|
2781
|
-
this.core.store.
|
|
2885
|
+
this.core.store.state.isEnabled = true;
|
|
2782
2886
|
this.core.rerender();
|
|
2783
2887
|
}
|
|
2784
2888
|
async delete() {
|
|
@@ -2810,10 +2914,10 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2810
2914
|
}
|
|
2811
2915
|
async hideContextMenu() {
|
|
2812
2916
|
this.core.store.state.pointers.clear();
|
|
2813
|
-
this.core.store.
|
|
2814
|
-
this.core.store.
|
|
2815
|
-
this.core.store.
|
|
2816
|
-
this.core.store.
|
|
2917
|
+
this.core.store.state.isContextMenuVisible = false;
|
|
2918
|
+
this.core.store.state.selectionBox = null;
|
|
2919
|
+
this.core.store.state.isSelecting = false;
|
|
2920
|
+
this.core.store.state.isEnabled = true;
|
|
2817
2921
|
this.core.rerender();
|
|
2818
2922
|
}
|
|
2819
2923
|
async getObjectById(id) {
|
|
@@ -2924,7 +3028,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2924
3028
|
await this.core.initializeWorkspace(this.workspace);
|
|
2925
3029
|
this._registerStateChangeListeners();
|
|
2926
3030
|
if (this.core.store.state.isReady === false) {
|
|
2927
|
-
this.core.store.
|
|
3031
|
+
this.core.store.state.isReady = true;
|
|
2928
3032
|
this.isEngineReady.emit(this.core.store.state);
|
|
2929
3033
|
}
|
|
2930
3034
|
}
|
|
@@ -2935,8 +3039,8 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2935
3039
|
if (!(activeTool instanceof KritzelSelectionTool)) {
|
|
2936
3040
|
this.core.clearSelection();
|
|
2937
3041
|
}
|
|
2938
|
-
this.core.store.
|
|
2939
|
-
this.core.store.
|
|
3042
|
+
this.core.store.state.skipContextMenu = false;
|
|
3043
|
+
this.core.store.state.copiedObjects = null;
|
|
2940
3044
|
this.activeToolChange.emit(activeTool);
|
|
2941
3045
|
KritzelKeyboardHelper.forceHideKeyboard();
|
|
2942
3046
|
}
|
|
@@ -2945,7 +3049,9 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2945
3049
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
2946
3050
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
2947
3051
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
2948
|
-
|
|
3052
|
+
const viewportCenterX = this.core.store.state.viewportWidth / 2 + this.core.store.state.translateX;
|
|
3053
|
+
const viewportCenterY = this.core.store.state.viewportHeight / 2 + this.core.store.state.translateY;
|
|
3054
|
+
return (h(Host, { key: 'caabd1ecbf2faccdf7fa50d087a8957df4dd1039' }, h("div", { key: 'd757e7133ed9dd190c17c383fb716f760f2b3906', class: "debug-panel", style: { display: this.core.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '00ced12dd956b6eecff7ac80429c0fd05cc7d1c3' }, "ActiveWorkspaceId: ", this.core.store.state?.activeWorkspace?.id), h("div", { key: '771f3269627fbe1ef962027f017cf6bdec7bcf8f' }, "ActiveWorkspaceName: ", this.core.store.state?.activeWorkspace?.name), h("div", { key: '0e49a60afdfb776a61f46b53bd6488786778bf77' }, "TranslateX: ", this.core.store.state?.translateX), h("div", { key: 'e0438479bc9e950ef2cbe88ed0aa0b8ec1888890' }, "TranslateY: ", this.core.store.state?.translateY), h("div", { key: '41d7261ed6b893a97fefb4bb6b199ffea51bd5fe' }, "ViewportWidth: ", this.core.store.state?.viewportWidth), h("div", { key: '7b6470008968eeebc5097252b3b9e3d172fd5d22' }, "ViewportHeight: ", this.core.store.state?.viewportHeight), h("div", { key: '4012ebdc3234ee2775021b38f385dfa0917736cb' }, "Scale: ", this.core.store.state?.scale), h("div", { key: '964d26a0ff4ff93dfa1cc928330c4fbdb0ec9b3d' }, "ActiveTool: ", this.core.store.state?.activeTool?.name), h("div", { key: 'cd68a81778d3e0f83f9453cd813538b2223541e8' }, "HasViewportChanged: ", this.core.store.state?.hasViewportChanged ? 'true' : 'false'), h("div", { key: '2ea80f3b4216a5e3d727c6c94d8b1782fbde80eb' }, "IsEnabled: ", this.core.store.state?.isEnabled ? 'true' : 'false'), h("div", { key: '02966d69182e95a8e91d5252f3dcfc19237caafd' }, "IsScaling: ", this.core.store.state?.isScaling ? 'true' : 'false'), h("div", { key: '85c06265f3af2b793d1827a40bb74b8837690ce3' }, "IsPanning: ", this.core.store.state?.isPanning ? 'true' : 'false'), h("div", { key: '1a2847a815fabc37cae3b7659844975df0c79a81' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: 'd1482aa165ed6b430ec0e640971c47e233103e87' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '3534e455918183d822374edbc80b621939100bd1' }, "IsResizeHandleSelected: ", this.core.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '7b061a4b08956660ee305316eea2e1d13d66d5de' }, "IsRotationHandleSelected: ", this.core.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '61998d0f4ffc65f5bb155dfe434a3a07667ca5ee' }, "IsDrawing: ", this.core.store.state.isDrawing ? 'true' : 'false'), h("div", { key: 'bdaeb0af59e844351eb46caf7bbe7e246174ccfe' }, "IsWriting: ", this.core.store.state.isWriting ? 'true' : 'false'), h("div", { key: '47518514eb67c486583ee61e6747104b4720924a' }, "PointerX: ", this.core.store.state?.pointerX), h("div", { key: '9b2ef1c30ecb09bc7df7f765e099f87ea836d697' }, "PointerY: ", this.core.store.state?.pointerY), h("div", { key: '72a65218942809918fb5fa1978af83f9442c3ed8' }, "SelectedObjects: ", this.core.store.state.selectionGroup?.objects.length || 0), h("div", { key: '1f2ad6b79f28306becd7e83f21ca877c7d15941d' }, "ViewportCenter: (", viewportCenterX.toFixed(2), ", ", viewportCenterY.toFixed(2), ")")), h("div", { key: 'ae8afa17ce2a1c0a06a3579091d6f1616fe9b9a7', id: "origin", class: "origin", style: {
|
|
2949
3055
|
transform: `matrix(${this.core.store.state?.scale}, 0, 0, ${this.core.store.state?.scale}, ${this.core.store.state?.translateX}, ${this.core.store.state?.translateY})`,
|
|
2950
3056
|
} }, this.core.store.state.objectsMap.allObjects()?.map(object => {
|
|
2951
3057
|
return (h("div", { key: object.id, style: {
|
|
@@ -2983,22 +3089,16 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2983
3089
|
height: '100%',
|
|
2984
3090
|
userSelect: 'none',
|
|
2985
3091
|
pointerEvents: 'none',
|
|
2986
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
overflow: '
|
|
2996
|
-
display: 'block',
|
|
2997
|
-
padding: '1px',
|
|
2998
|
-
whiteSpace: 'nowrap',
|
|
2999
|
-
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
3000
|
-
cursor: object.isReadonly ? 'default' : 'text',
|
|
3001
|
-
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
3092
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("div", { ref: el => (el ? object.mount(el) : object.unmount()), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
|
|
3093
|
+
minWidth: object.initialWidth + 'px',
|
|
3094
|
+
minHeight: object.initialHeight + 'px',
|
|
3095
|
+
maxWidth: '500px',
|
|
3096
|
+
height: 'auto',
|
|
3097
|
+
width: 'max-content',
|
|
3098
|
+
transformOrigin: 'top left',
|
|
3099
|
+
transform: `scale(${object.scaleFactor})`,
|
|
3100
|
+
backgroundColor: object.backgroundColor,
|
|
3101
|
+
overflow: 'visible'
|
|
3002
3102
|
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => (el ? object.mount(el) : object.unmount()), style: {
|
|
3003
3103
|
width: '100%',
|
|
3004
3104
|
height: '100%',
|
|
@@ -3064,7 +3164,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
3064
3164
|
transform: this.core.store.state.currentPath?.transformationMatrix,
|
|
3065
3165
|
transformOrigin: 'top left',
|
|
3066
3166
|
overflow: 'visible',
|
|
3067
|
-
}, viewBox: this.core.store.state.currentPath?.viewBox }, h("path", { key: '
|
|
3167
|
+
}, viewBox: this.core.store.state.currentPath?.viewBox }, h("path", { key: '9428a1401021b38b8b811fd68af9e24d53301c08', d: this.core.store.state.currentPath?.d, fill: this.core.store.state.currentPath?.fill, stroke: this.core.store.state.currentPath?.stroke }))), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '1ccc963df66e4210886717644503be6304c6c99f', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.state.selectionGroup?.objects || [], style: {
|
|
3068
3168
|
position: 'fixed',
|
|
3069
3169
|
left: `${this.core.store.state.contextMenuX}px`,
|
|
3070
3170
|
top: `${this.core.store.state.contextMenuY}px`,
|
|
@@ -3075,7 +3175,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
3075
3175
|
y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
|
|
3076
3176
|
}, this.core.store.state.selectionGroup?.objects);
|
|
3077
3177
|
this.hideContextMenu();
|
|
3078
|
-
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
3178
|
+
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '9b51e52c76f21be679491c21d1921d389d6619fc', core: this.core })));
|
|
3079
3179
|
}
|
|
3080
3180
|
static get watchers() { return {
|
|
3081
3181
|
"workspace": ["onWorkspaceChange"],
|
|
@@ -3085,9 +3185,9 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
3085
3185
|
static get style() { return kritzelEngineCss; }
|
|
3086
3186
|
}, [257, "kritzel-engine", {
|
|
3087
3187
|
"workspace": [16],
|
|
3088
|
-
"activeTool": [16
|
|
3089
|
-
"globalContextMenuItems": [16
|
|
3090
|
-
"objectContextMenuItems": [16
|
|
3188
|
+
"activeTool": [16],
|
|
3189
|
+
"globalContextMenuItems": [16],
|
|
3190
|
+
"objectContextMenuItems": [16],
|
|
3091
3191
|
"scaleMax": [1026, "scale-max"],
|
|
3092
3192
|
"scaleMin": [1026, "scale-min"],
|
|
3093
3193
|
"forceUpdate": [32],
|
|
@@ -3155,6 +3255,6 @@ function defineCustomElement() {
|
|
|
3155
3255
|
}
|
|
3156
3256
|
|
|
3157
3257
|
export { ABSOLUTE_SCALE_MAX as A, KritzelImage as K, KritzelEraserTool as a, KritzelImageTool as b, KritzelSelectionTool as c, KritzelEngine as d, defineCustomElement as e, ABSOLUTE_SCALE_MIN as f };
|
|
3158
|
-
//# sourceMappingURL=p-
|
|
3258
|
+
//# sourceMappingURL=p-C4nj29RW.js.map
|
|
3159
3259
|
|
|
3160
|
-
//# sourceMappingURL=p-
|
|
3260
|
+
//# sourceMappingURL=p-C4nj29RW.js.map
|