kritzel-stencil 0.0.121 → 0.0.122
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-BjLSiQIM.js → index-CFCyVs0_.js} +185 -69
- package/dist/cjs/index-CFCyVs0_.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +127 -71
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +3 -0
- package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +2 -2
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +5 -5
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/history.class.js +16 -13
- package/dist/collection/classes/history.class.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +28 -32
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +52 -0
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -0
- package/dist/collection/classes/objects/image.class.js +1 -1
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +62 -2
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +1 -1
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +1 -1
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/reviver.class.js +4 -0
- package/dist/collection/classes/reviver.class.js.map +1 -1
- package/dist/collection/classes/store.class.js +45 -6
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +18 -14
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +1 -1
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +2 -6
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/viewport.class.js +20 -12
- package/dist/collection/classes/viewport.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +6 -6
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +38 -32
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +2 -2
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/html.helper.js +7 -0
- package/dist/collection/helpers/html.helper.js.map +1 -0
- package/dist/collection/helpers/object.helper.js +6 -2
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +7 -7
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-q-xqpmae.js → p-COPOzWCn.js} +211 -99
- package/dist/components/p-COPOzWCn.js.map +1 -0
- package/dist/components/{p-DC3j4P1n.js → p-Ch8eM2R8.js} +99 -39
- package/dist/components/p-Ch8eM2R8.js.map +1 -0
- package/dist/components/{p-BAMl2Ww6.js → p-DIu9OTyP.js} +3 -3
- package/dist/components/{p-BAMl2Ww6.js.map → p-DIu9OTyP.js.map} +1 -1
- package/dist/esm/{index-DsUDklEm.js → index-DYLW4hYm.js} +185 -69
- package/dist/esm/index-DYLW4hYm.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +127 -71
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-DYLW4hYm.js +2 -0
- package/dist/stencil/p-DYLW4hYm.js.map +1 -0
- package/dist/stencil/p-fa584641.entry.js +2 -0
- package/dist/stencil/p-fa584641.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/history.class.d.ts +1 -0
- package/dist/types/classes/objects/base-object.class.d.ts +10 -6
- package/dist/types/classes/objects/custom-element.class.d.ts +26 -0
- package/dist/types/classes/objects/image.class.d.ts +1 -1
- package/dist/types/classes/objects/path.class.d.ts +5 -2
- package/dist/types/classes/objects/text.class.d.ts +1 -1
- package/dist/types/classes/store.class.d.ts +5 -0
- package/dist/types/components.d.ts +4 -4
- package/dist/types/helpers/html.helper.d.ts +3 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +2 -2
- package/dist/types/interfaces/object.interface.d.ts +9 -4
- package/package.json +1 -1
- package/dist/cjs/index-BjLSiQIM.js.map +0 -1
- package/dist/components/p-DC3j4P1n.js.map +0 -1
- package/dist/components/p-q-xqpmae.js.map +0 -1
- package/dist/esm/index-DsUDklEm.js.map +0 -1
- package/dist/stencil/p-3797c300.entry.js +0 -2
- package/dist/stencil/p-3797c300.entry.js.map +0 -1
- package/dist/stencil/p-DsUDklEm.js +0 -2
- package/dist/stencil/p-DsUDklEm.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-dCaxwGmu.js';
|
|
2
2
|
import { K as KritzelMouseButton } from './p-D8W6LE-c.js';
|
|
3
|
-
import { d as KritzelBaseObject, e as KritzelBaseCommand, f as KritzelBaseTool, g as KritzelEventHelper, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, O as ObjectHelper, A as AddObjectCommand, h as KritzelToolRegistry, i as KritzelKeyboardHelper } from './p-
|
|
3
|
+
import { d as KritzelBaseObject, e as KritzelBaseCommand, f as KritzelBaseTool, g as KritzelEventHelper, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath, O as ObjectHelper, A as AddObjectCommand, h as KritzelToolRegistry, i as KritzelKeyboardHelper } from './p-Ch8eM2R8.js';
|
|
4
4
|
import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-CEYRFk55.js';
|
|
5
5
|
import { d as defineCustomElement$2 } from './p-D0L3GqSK.js';
|
|
6
6
|
import { d as defineCustomElement$1 } from './p-B2wWYPH8.js';
|
|
@@ -13,7 +13,7 @@ class KritzelImage extends KritzelBaseObject {
|
|
|
13
13
|
this.maxWidth = 300;
|
|
14
14
|
this.maxHeight = 300;
|
|
15
15
|
this.maxCompressionSize = 300;
|
|
16
|
-
this.
|
|
16
|
+
this.isDebugInfoVisible = true;
|
|
17
17
|
this.src = (config === null || config === void 0 ? void 0 : config.src) || '';
|
|
18
18
|
this.x = (config === null || config === void 0 ? void 0 : config.x) || 0;
|
|
19
19
|
this.y = (config === null || config === void 0 ? void 0 : config.y) || 0;
|
|
@@ -70,6 +70,57 @@ class BatchCommand extends KritzelBaseCommand {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
class KritzelCustomElement extends KritzelBaseObject {
|
|
74
|
+
constructor(config) {
|
|
75
|
+
super();
|
|
76
|
+
this.__class__ = 'KritzelCustomElement';
|
|
77
|
+
this.isInteractive = true;
|
|
78
|
+
if (config) {
|
|
79
|
+
this.translateX = config.translateX || 0;
|
|
80
|
+
this.translateY = config.translateY || 0;
|
|
81
|
+
this.scale = config.scale || 1;
|
|
82
|
+
this.element = config.element;
|
|
83
|
+
this.height = config.height || 0;
|
|
84
|
+
this.width = config.width || 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static create(store, config) {
|
|
88
|
+
const object = new KritzelCustomElement(config);
|
|
89
|
+
object._store = store;
|
|
90
|
+
object.id = object.generateId();
|
|
91
|
+
return object;
|
|
92
|
+
}
|
|
93
|
+
mount(element) {
|
|
94
|
+
if (this.isMounted) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.elementRef = element;
|
|
98
|
+
this.isMounted = true;
|
|
99
|
+
this.elementRef.appendChild(this.element);
|
|
100
|
+
}
|
|
101
|
+
resize(x, y, width, height) {
|
|
102
|
+
if (width <= 1 || height <= 1) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.width = width;
|
|
106
|
+
this.height = height;
|
|
107
|
+
this.translateX = x;
|
|
108
|
+
this.translateY = y;
|
|
109
|
+
if (this.element) {
|
|
110
|
+
this.element.style.width = `${width}px`;
|
|
111
|
+
this.element.style.height = `${height}px`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
copy() {
|
|
115
|
+
const copiedObject = Object.create(Object.getPrototypeOf(this));
|
|
116
|
+
Object.assign(copiedObject, this);
|
|
117
|
+
copiedObject.id = this.generateId();
|
|
118
|
+
copiedObject.isMounted = false;
|
|
119
|
+
copiedObject.element = this.element.cloneNode(true);
|
|
120
|
+
return copiedObject;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
73
124
|
class RemoveObjectCommand extends KritzelBaseCommand {
|
|
74
125
|
constructor(store, initiator, object) {
|
|
75
126
|
super(store, initiator);
|
|
@@ -77,9 +128,11 @@ class RemoveObjectCommand extends KritzelBaseCommand {
|
|
|
77
128
|
}
|
|
78
129
|
execute() {
|
|
79
130
|
this._store.state.objectsOctree.remove(object => object.id === this.object.id);
|
|
131
|
+
this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
80
132
|
}
|
|
81
133
|
undo() {
|
|
82
134
|
this._store.state.objectsOctree.insert(this.object);
|
|
135
|
+
this._store.state.objectsOctree.filter(object => object instanceof KritzelCustomElement).forEach(object => object.remount());
|
|
83
136
|
}
|
|
84
137
|
}
|
|
85
138
|
|
|
@@ -103,28 +156,34 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
103
156
|
}
|
|
104
157
|
}
|
|
105
158
|
handlePointerMove(event) {
|
|
106
|
-
var _a
|
|
159
|
+
var _a;
|
|
107
160
|
if (event.pointerType === 'mouse') {
|
|
108
161
|
if (this._store.state.isErasing) {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
return;
|
|
112
|
-
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
113
|
-
if (!selectedObject)
|
|
162
|
+
const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
|
|
163
|
+
if (selectedObjects.length === 0)
|
|
114
164
|
return;
|
|
115
|
-
|
|
165
|
+
console.log('selectedObjects', selectedObjects);
|
|
166
|
+
const x = this._store.state.pointerX;
|
|
167
|
+
const y = this._store.state.pointerY;
|
|
168
|
+
selectedObjects.forEach(selectedObject => {
|
|
169
|
+
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
170
|
+
});
|
|
116
171
|
this._store.rerender();
|
|
117
172
|
}
|
|
118
173
|
}
|
|
119
174
|
if (event.pointerType === 'touch') {
|
|
120
175
|
if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
|
|
121
|
-
const shadowRoot = (
|
|
176
|
+
const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
122
177
|
if (!shadowRoot)
|
|
123
178
|
return;
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
179
|
+
const selectedObjects = this._store.getObjectsFromPointerEvent(event, '.object');
|
|
180
|
+
if (selectedObjects.length === 0)
|
|
126
181
|
return;
|
|
127
|
-
|
|
182
|
+
const x = this._store.state.pointerX;
|
|
183
|
+
const y = this._store.state.pointerY;
|
|
184
|
+
selectedObjects.forEach(selectedObject => {
|
|
185
|
+
selectedObject.markedForRemoval = selectedObject.hitTest(x, y);
|
|
186
|
+
});
|
|
128
187
|
this._store.rerender();
|
|
129
188
|
}
|
|
130
189
|
}
|
|
@@ -132,9 +191,7 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
132
191
|
handlePointerUp(event) {
|
|
133
192
|
if (event.pointerType === 'mouse') {
|
|
134
193
|
if (this._store.state.isErasing) {
|
|
135
|
-
const removeCommands = this._store.allObjects
|
|
136
|
-
.filter(object => object.markedForRemoval)
|
|
137
|
-
.map(object => {
|
|
194
|
+
const removeCommands = this._store.allObjects.filter(object => object.markedForRemoval).map(object => {
|
|
138
195
|
object.markedForRemoval = false;
|
|
139
196
|
return new RemoveObjectCommand(this._store, this, object);
|
|
140
197
|
});
|
|
@@ -217,7 +274,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
217
274
|
var _a, _b;
|
|
218
275
|
if (event.pointerType === 'mouse') {
|
|
219
276
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
220
|
-
if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.
|
|
277
|
+
if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
|
|
221
278
|
const clientX = event.clientX - this._store.offsetX;
|
|
222
279
|
const clientY = event.clientY - this._store.offsetY;
|
|
223
280
|
this._store.state.isDragging = true;
|
|
@@ -231,7 +288,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
231
288
|
if (event.pointerType === 'touch') {
|
|
232
289
|
const activePointers = Array.from(this._store.state.pointers.values());
|
|
233
290
|
if (this._store.state.pointers.size === 1) {
|
|
234
|
-
if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.
|
|
291
|
+
if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.isSelected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
|
|
235
292
|
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
236
293
|
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
237
294
|
this.dragStartX = x;
|
|
@@ -839,7 +896,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
839
896
|
.forEach(object => {
|
|
840
897
|
const objectPolygon = object.rotatedPolygon;
|
|
841
898
|
const selectionBoxPolygon = this._store.state.selectionBox.rotatedPolygon;
|
|
842
|
-
object.
|
|
899
|
+
object.isSelected = KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, selectionBoxPolygon);
|
|
843
900
|
});
|
|
844
901
|
}
|
|
845
902
|
addSelectedObjectAtIndexToSelectionGroup(index) {
|
|
@@ -848,10 +905,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
848
905
|
if (!selectedObject) {
|
|
849
906
|
return;
|
|
850
907
|
}
|
|
851
|
-
selectedObjects.forEach(o => (o.
|
|
908
|
+
selectedObjects.forEach(o => (o.isSelected = false));
|
|
852
909
|
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
853
910
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
854
|
-
this._store.state.selectionGroup.
|
|
911
|
+
this._store.state.selectionGroup.isSelected = true;
|
|
855
912
|
this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
|
|
856
913
|
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
857
914
|
}
|
|
@@ -862,10 +919,10 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
862
919
|
}
|
|
863
920
|
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
864
921
|
selectedObjects.forEach(o => {
|
|
865
|
-
o.
|
|
922
|
+
o.isSelected = false;
|
|
866
923
|
this._store.state.selectionGroup.addOrRemove(o);
|
|
867
924
|
});
|
|
868
|
-
this._store.state.selectionGroup.
|
|
925
|
+
this._store.state.selectionGroup.isSelected = true;
|
|
869
926
|
if (this._store.state.selectionGroup.length === 1) {
|
|
870
927
|
this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
|
|
871
928
|
}
|
|
@@ -898,12 +955,8 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
898
955
|
!this._store.state.isRotationHandleSelected) {
|
|
899
956
|
this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
|
|
900
957
|
}
|
|
901
|
-
if (selectedObject && selectedObject.
|
|
902
|
-
|
|
903
|
-
if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
|
|
904
|
-
selectedObject.objects[0].onSelectedClick();
|
|
905
|
-
}
|
|
906
|
-
}, 100);
|
|
958
|
+
if (selectedObject && selectedObject.isSelected === false && (selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.objects.length) === 1 && selectedObject.objects[0].isInteractive) {
|
|
959
|
+
return;
|
|
907
960
|
}
|
|
908
961
|
}
|
|
909
962
|
this.moveHandler.handlePointerDown(event);
|
|
@@ -1040,6 +1093,9 @@ class KritzelReviver {
|
|
|
1040
1093
|
case 'KritzelImage':
|
|
1041
1094
|
revivedObj = KritzelImage.create(this._store).revive(obj);
|
|
1042
1095
|
break;
|
|
1096
|
+
case 'KritzelCustomElement':
|
|
1097
|
+
revivedObj = KritzelCustomElement.create(this._store).revive(obj);
|
|
1098
|
+
break;
|
|
1043
1099
|
case 'KritzelSelectionGroup':
|
|
1044
1100
|
revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
|
|
1045
1101
|
break;
|
|
@@ -1105,7 +1161,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
1105
1161
|
this.refreshObjectDimensions();
|
|
1106
1162
|
}
|
|
1107
1163
|
deselectAllChildren() {
|
|
1108
|
-
this.objects.forEach(obj => (obj.
|
|
1164
|
+
this.objects.forEach(obj => (obj.isSelected = false));
|
|
1109
1165
|
}
|
|
1110
1166
|
updatePosition(x, y) {
|
|
1111
1167
|
this.objects.forEach(obj => {
|
|
@@ -1310,7 +1366,7 @@ class KritzelImageTool extends KritzelBaseTool {
|
|
|
1310
1366
|
addImageToStore(image) {
|
|
1311
1367
|
const selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
1312
1368
|
selectionGroup.addOrRemove(image);
|
|
1313
|
-
selectionGroup.
|
|
1369
|
+
selectionGroup.isSelected = true;
|
|
1314
1370
|
const addImageCommand = new AddObjectCommand(this._store, this, image);
|
|
1315
1371
|
const addSelectionGroupCommand = new AddSelectionGroupCommand(this._store, this, selectionGroup);
|
|
1316
1372
|
this._store.history.executeCommand(new BatchCommand(this._store, this, [addImageCommand, addSelectionGroupCommand]));
|
|
@@ -1372,21 +1428,27 @@ class KritzelViewport {
|
|
|
1372
1428
|
}
|
|
1373
1429
|
handlePointerMove(event) {
|
|
1374
1430
|
if (event.pointerType === 'mouse') {
|
|
1375
|
-
const
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
this._store.state.
|
|
1431
|
+
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
1432
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1433
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1434
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
1435
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
1379
1436
|
if (this._store.state.isPanning) {
|
|
1380
|
-
this._store.state.translateX -= this._store.state.startX -
|
|
1381
|
-
this._store.state.translateY -= this._store.state.startY -
|
|
1382
|
-
this._store.state.startX =
|
|
1383
|
-
this._store.state.startY =
|
|
1437
|
+
this._store.state.translateX -= this._store.state.startX - xRelativeToHost;
|
|
1438
|
+
this._store.state.translateY -= this._store.state.startY - yRelativeToHost;
|
|
1439
|
+
this._store.state.startX = xRelativeToHost;
|
|
1440
|
+
this._store.state.startY = yRelativeToHost;
|
|
1384
1441
|
this._store.state.hasViewportChanged = true;
|
|
1385
1442
|
this._store.state.skipContextMenu = true;
|
|
1386
1443
|
this._store.rerender();
|
|
1387
1444
|
}
|
|
1388
1445
|
}
|
|
1389
1446
|
if (event.pointerType === 'touch') {
|
|
1447
|
+
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
1448
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1449
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1450
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
1451
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
1390
1452
|
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1391
1453
|
if (activePointers.length === 2) {
|
|
1392
1454
|
const firstTouchX = activePointers[0].clientX - this._store.offsetX;
|
|
@@ -1440,13 +1502,15 @@ class KritzelViewport {
|
|
|
1440
1502
|
}
|
|
1441
1503
|
handleZoom(event) {
|
|
1442
1504
|
const rect = this._store.state.host.getBoundingClientRect();
|
|
1443
|
-
|
|
1444
|
-
|
|
1505
|
+
const xRelativeToHost = event.clientX - rect.left;
|
|
1506
|
+
const yRelativeToHost = event.clientY - rect.top;
|
|
1507
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
1508
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
1445
1509
|
const delta = event.deltaY > 0 ? -this._store.state.scaleStep * this._store.state.scale : this._store.state.scaleStep * this._store.state.scale;
|
|
1446
1510
|
const newScale = Math.min(this._store.state.scaleMax, Math.max(this._store.state.scaleMin, this._store.state.scale + delta));
|
|
1447
1511
|
const scaleRatio = newScale / this._store.state.scale;
|
|
1448
|
-
const translateXAdjustment = (
|
|
1449
|
-
const translateYAdjustment = (
|
|
1512
|
+
const translateXAdjustment = (xRelativeToHost - this._store.state.translateX) * (scaleRatio - 1);
|
|
1513
|
+
const translateYAdjustment = (yRelativeToHost - this._store.state.translateY) * (scaleRatio - 1);
|
|
1450
1514
|
this._store.state.scale = newScale;
|
|
1451
1515
|
this._store.state.translateX -= translateXAdjustment;
|
|
1452
1516
|
this._store.state.translateY -= translateYAdjustment;
|
|
@@ -1544,19 +1608,7 @@ class KritzelHistory {
|
|
|
1544
1608
|
}
|
|
1545
1609
|
executeCommand(command) {
|
|
1546
1610
|
if (this._store.state.hasViewportChanged) {
|
|
1547
|
-
|
|
1548
|
-
command.execute();
|
|
1549
|
-
this.undoStack.add(command);
|
|
1550
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1551
|
-
this.redoStack.clear();
|
|
1552
|
-
}
|
|
1553
|
-
this._store.state.hasViewportChanged = false;
|
|
1554
|
-
this.previousViewport = {
|
|
1555
|
-
scale: this._store.state.scale,
|
|
1556
|
-
scaleStep: this._store.state.scaleStep,
|
|
1557
|
-
translateX: this._store.state.translateX,
|
|
1558
|
-
translateY: this._store.state.translateY,
|
|
1559
|
-
};
|
|
1611
|
+
this.addUpdateViewportCommand();
|
|
1560
1612
|
}
|
|
1561
1613
|
command.execute();
|
|
1562
1614
|
if (this._store.state.debugInfo.logCommands)
|
|
@@ -1594,6 +1646,21 @@ class KritzelHistory {
|
|
|
1594
1646
|
}
|
|
1595
1647
|
this._store.rerender();
|
|
1596
1648
|
}
|
|
1649
|
+
addUpdateViewportCommand() {
|
|
1650
|
+
const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
|
|
1651
|
+
command.execute();
|
|
1652
|
+
this.undoStack.add(command);
|
|
1653
|
+
if (this.redoStack.isEmpty() === false) {
|
|
1654
|
+
this.redoStack.clear();
|
|
1655
|
+
}
|
|
1656
|
+
this._store.state.hasViewportChanged = false;
|
|
1657
|
+
this.previousViewport = {
|
|
1658
|
+
scale: this._store.state.scale,
|
|
1659
|
+
scaleStep: this._store.state.scaleStep,
|
|
1660
|
+
translateX: this._store.state.translateX,
|
|
1661
|
+
translateY: this._store.state.translateY,
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1597
1664
|
}
|
|
1598
1665
|
|
|
1599
1666
|
class KritzelOctree {
|
|
@@ -1771,8 +1838,8 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
1771
1838
|
logCommands: false,
|
|
1772
1839
|
},
|
|
1773
1840
|
host: null,
|
|
1774
|
-
|
|
1775
|
-
|
|
1841
|
+
pointerX: 0,
|
|
1842
|
+
pointerY: 0,
|
|
1776
1843
|
scale: 1,
|
|
1777
1844
|
scaleMax: 1,
|
|
1778
1845
|
scaleMin: 1,
|
|
@@ -1807,7 +1874,7 @@ class KritzelStore {
|
|
|
1807
1874
|
return this._state.objectsOctree.allObjects();
|
|
1808
1875
|
}
|
|
1809
1876
|
get selectedObjects() {
|
|
1810
|
-
return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.
|
|
1877
|
+
return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup)).filter(o => o.isSelected);
|
|
1811
1878
|
}
|
|
1812
1879
|
get offsetX() {
|
|
1813
1880
|
return this._state.host.getBoundingClientRect().left;
|
|
@@ -1898,7 +1965,7 @@ class KritzelStore {
|
|
|
1898
1965
|
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
1899
1966
|
}
|
|
1900
1967
|
paste(x, y) {
|
|
1901
|
-
this.state.copiedObjects.
|
|
1968
|
+
this.state.copiedObjects.isSelected = true;
|
|
1902
1969
|
const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;
|
|
1903
1970
|
const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;
|
|
1904
1971
|
this.state.copiedObjects.updatePosition(adjustedX, adjustedY);
|
|
@@ -1958,10 +2025,10 @@ class KritzelStore {
|
|
|
1958
2025
|
}
|
|
1959
2026
|
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
1960
2027
|
objects.forEach(obj => {
|
|
1961
|
-
obj.
|
|
2028
|
+
obj.isSelected = false;
|
|
1962
2029
|
selectionGroup.addOrRemove(obj);
|
|
1963
2030
|
});
|
|
1964
|
-
selectionGroup.
|
|
2031
|
+
selectionGroup.isSelected = true;
|
|
1965
2032
|
this.state.selectionGroup = selectionGroup;
|
|
1966
2033
|
if (objects.length === 1) {
|
|
1967
2034
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
@@ -1982,10 +2049,10 @@ class KritzelStore {
|
|
|
1982
2049
|
if (objectsInViewport.length > 0) {
|
|
1983
2050
|
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
1984
2051
|
objectsInViewport.forEach(obj => {
|
|
1985
|
-
obj.
|
|
2052
|
+
obj.isSelected = false;
|
|
1986
2053
|
selectionGroup.addOrRemove(obj);
|
|
1987
2054
|
});
|
|
1988
|
-
selectionGroup.
|
|
2055
|
+
selectionGroup.isSelected = true;
|
|
1989
2056
|
this.state.isSelecting = false;
|
|
1990
2057
|
if (objectsInViewport.length === 1) {
|
|
1991
2058
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
@@ -2026,6 +2093,45 @@ class KritzelStore {
|
|
|
2026
2093
|
}
|
|
2027
2094
|
return null;
|
|
2028
2095
|
}
|
|
2096
|
+
getObjectsFromPointerEvent(event, selector = '.object') {
|
|
2097
|
+
var _a;
|
|
2098
|
+
const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
2099
|
+
if (!shadowRoot)
|
|
2100
|
+
return [];
|
|
2101
|
+
const clientX = event.clientX;
|
|
2102
|
+
const clientY = event.clientY;
|
|
2103
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(clientX, clientY);
|
|
2104
|
+
if (!elementsAtPoint || elementsAtPoint.length === 0)
|
|
2105
|
+
return [];
|
|
2106
|
+
const objectIds = new Set();
|
|
2107
|
+
elementsAtPoint.forEach(element => {
|
|
2108
|
+
const selectedObject = element.closest(selector);
|
|
2109
|
+
if (selectedObject && selectedObject.id) {
|
|
2110
|
+
objectIds.add(selectedObject.id);
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
if (objectIds.size > 0) {
|
|
2114
|
+
return this.allObjects.filter(object => objectIds.has(object.id)).sort((a, b) => b.zIndex - a.zIndex);
|
|
2115
|
+
}
|
|
2116
|
+
return [];
|
|
2117
|
+
}
|
|
2118
|
+
getCanvasPoint(event) {
|
|
2119
|
+
if (!this.state.host) {
|
|
2120
|
+
return { x: 0, y: 0 };
|
|
2121
|
+
}
|
|
2122
|
+
// Get the position of the kritzel-engine host element relative to the viewport
|
|
2123
|
+
const hostRect = this.state.host.getBoundingClientRect();
|
|
2124
|
+
// 1. Make the pointer coordinates relative to the host element
|
|
2125
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
2126
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
2127
|
+
// 2. Reverse the translation applied to the #origin div
|
|
2128
|
+
const xWithoutTranslate = xRelativeToHost - this.state.translateX;
|
|
2129
|
+
const yWithoutTranslate = yRelativeToHost - this.state.translateY;
|
|
2130
|
+
// 3. Reverse the scaling to get the final world coordinates
|
|
2131
|
+
const worldX = xWithoutTranslate / this.state.scale;
|
|
2132
|
+
const worldY = yWithoutTranslate / this.state.scale;
|
|
2133
|
+
return { x: worldX, y: worldY };
|
|
2134
|
+
}
|
|
2029
2135
|
}
|
|
2030
2136
|
|
|
2031
2137
|
class KritzelKeyHandler extends KritzelBaseHandler {
|
|
@@ -2124,7 +2230,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
2124
2230
|
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
2125
2231
|
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
2126
2232
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
2127
|
-
this._store.state.selectionGroup.
|
|
2233
|
+
this._store.state.selectionGroup.isSelected = true;
|
|
2128
2234
|
this._store.state.selectionGroup.rotation = selectedObject.rotation;
|
|
2129
2235
|
this._store.state.isSelecting = false;
|
|
2130
2236
|
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
@@ -2441,15 +2547,15 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2441
2547
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
2442
2548
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
2443
2549
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
2444
|
-
return (h(Host, { key: '
|
|
2445
|
-
_a.translateX), h("div", { key: '
|
|
2446
|
-
_b.translateY), h("div", { key: '
|
|
2447
|
-
_c.viewportWidth), h("div", { key: '
|
|
2448
|
-
_d.viewportHeight), h("div", { key: '
|
|
2449
|
-
_e.scale), h("div", { key: '
|
|
2450
|
-
_g.name), h("div", { key: '
|
|
2451
|
-
_m.
|
|
2452
|
-
_o.
|
|
2550
|
+
return (h(Host, { key: 'a8e6c284c98509ddd158686887d656d3907d40a2' }, h("div", { key: '3935b658e8859f746a5faef0bb91a527b68fcd3e', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '12c190c7ea99ac69310b27e719e7df8392b2b46e' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
2551
|
+
_a.translateX), h("div", { key: '4c98deccc2a029dab06ed76e5af426f4a05c7b66' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
2552
|
+
_b.translateY), h("div", { key: '1330191a39c7795f17a6adcc4fbd05e2d6a24d43' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
2553
|
+
_c.viewportWidth), h("div", { key: '1ee59427037357ee6bf746a094285426eb0e6a58' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
2554
|
+
_d.viewportHeight), h("div", { key: '1e68312e8516f25dcff34e9f9f70b90f426b8711' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '1d7cea9e21d9b744d8eaac29286528829143b4fa' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
2555
|
+
_e.scale), h("div", { key: '0b60168fbd55aefa3714067bace80f167b8bcac0' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
2556
|
+
_g.name), h("div", { key: '109752df6a77633d89929f325d296f96d27d7aa9' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: 'b35466caf465b490c5d448d694353186ff902f09' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '5df20e47f3bf234f04eea001b0a0abaf57946498' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '9d1ec8b8268488821a968e109fa279393977fdf8' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: '92fa98b7fa3bf877c4fffaca70683d2d908f5177' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '708d02459c1e3907dd88a2f2fd8916c1ee684cf1' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '27f45c1b6ee0b6bd0b3301a9c09b9198de722ac4' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '50d4476aecfc00d12bae7d8a3880ccb8de82fe68' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '0c582e97ee1535b4a14b75b7ef15373c43f21c4b' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '7a8378ac991d17d0eaaba5fbd519875197903a39' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '00b56f11ffd16f7b9049d2857f5f7effceba1294' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: '3b7773194bd6bc8b8b2d024afc768f4e9fbb54c6' }, "PointerX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
2557
|
+
_m.pointerX), h("div", { key: 'a2b2c96f6180591082a5aee20cc3e82236dac520' }, "PointerY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
2558
|
+
_o.pointerY)), h("div", { key: '309eb61fff5182b5076cb3886bbd79006efc30b1', id: "origin", class: "origin", style: {
|
|
2453
2559
|
transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
|
|
2454
2560
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
2455
2561
|
_t.map(object => {
|
|
@@ -2473,17 +2579,17 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2473
2579
|
borderStyle: 'solid',
|
|
2474
2580
|
padding: object.padding + 'px',
|
|
2475
2581
|
overflow: 'visible',
|
|
2476
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2582
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => el ? object.mount(el) : object.unmount(), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2477
2583
|
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
2478
2584
|
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
2479
2585
|
position: 'absolute',
|
|
2480
2586
|
overflow: 'visible',
|
|
2481
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => object.mount(el), src: object.src, style: {
|
|
2587
|
+
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => el ? object.mount(el) : object.unmount(), src: object.src, style: {
|
|
2482
2588
|
width: '100%',
|
|
2483
2589
|
height: '100%',
|
|
2484
2590
|
userSelect: 'none',
|
|
2485
2591
|
pointerEvents: 'none',
|
|
2486
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => object.mount(el), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
2592
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => el ? object.mount(el) : object.unmount(), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
2487
2593
|
width: '100%',
|
|
2488
2594
|
height: '100%',
|
|
2489
2595
|
color: object.fontColor,
|
|
@@ -2499,54 +2605,60 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2499
2605
|
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
2500
2606
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
2501
2607
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
2502
|
-
} })), KritzelClassHelper.isInstanceOf(object, '
|
|
2608
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2609
|
+
width: '100%',
|
|
2610
|
+
height: '100%',
|
|
2611
|
+
pointerEvents: 'auto',
|
|
2612
|
+
overflow: 'hidden',
|
|
2613
|
+
display: 'block',
|
|
2614
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2503
2615
|
width: '100%',
|
|
2504
2616
|
height: '100%',
|
|
2505
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => object.mount(el), style: {
|
|
2617
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2506
2618
|
width: '100%',
|
|
2507
2619
|
height: '100%',
|
|
2508
2620
|
} }))), h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
2509
2621
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2510
2622
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_b = this.store.state) === null || _b === void 0 ? void 0 : _b.scale})`,
|
|
2511
2623
|
strokeLinecap: 'square',
|
|
2512
|
-
}, visibility: object.
|
|
2624
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: "0", y1: "0", x2: "0", y2: object.totalHeight, style: {
|
|
2513
2625
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2514
2626
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_c = this.store.state) === null || _c === void 0 ? void 0 : _c.scale})`,
|
|
2515
2627
|
strokeLinecap: 'square',
|
|
2516
|
-
}, visibility: object.
|
|
2628
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: "0", y1: object.totalHeight, x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2517
2629
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2518
2630
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_d = this.store.state) === null || _d === void 0 ? void 0 : _d.scale})`,
|
|
2519
2631
|
strokeLinecap: 'square',
|
|
2520
|
-
}, visibility: object.
|
|
2632
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), h("line", { x1: object.totalWidth, y1: "0", x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2521
2633
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2522
2634
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_e = this.store.state) === null || _e === void 0 ? void 0 : _e.scale})`,
|
|
2523
2635
|
strokeLinecap: 'square',
|
|
2524
|
-
}, visibility: object.
|
|
2636
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle top-left", cx: "0", cy: "0", r: `${(baseHandleSize * object.scale) / ((_f = this.store.state) === null || _f === void 0 ? void 0 : _f.scale)}`, style: {
|
|
2525
2637
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2526
|
-
}, visibility: object.
|
|
2638
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay top-left", cx: "0", cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_g = this.store.state) === null || _g === void 0 ? void 0 : _g.scale)}`, style: {
|
|
2527
2639
|
fill: 'transparent',
|
|
2528
|
-
}, visibility: object.
|
|
2640
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleSize * object.scale) / ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.scale)}`, style: {
|
|
2529
2641
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2530
|
-
}, visibility: object.
|
|
2642
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay top-right", cx: object.totalWidth, cy: "0", r: `${(baseHandleTouchSize * object.scale) / ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.scale)}`, style: {
|
|
2531
2643
|
fill: 'transparent',
|
|
2532
|
-
}, visibility: object.
|
|
2644
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.scale)}`, style: {
|
|
2533
2645
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2534
|
-
}, visibility: object.
|
|
2646
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay bottom-left", cx: "0", cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.scale)}`, style: {
|
|
2535
2647
|
fill: 'transparent',
|
|
2536
|
-
}, visibility: object.
|
|
2648
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleSize * object.scale) / ((_m = this.store.state) === null || _m === void 0 ? void 0 : _m.scale)}`, style: {
|
|
2537
2649
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2538
|
-
}, visibility: object.
|
|
2650
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "resize-handle-overlay bottom-right", cx: object.totalWidth, cy: object.totalHeight, r: `${(baseHandleTouchSize * object.scale) / ((_o = this.store.state) === null || _o === void 0 ? void 0 : _o.scale)}`, style: {
|
|
2539
2651
|
fill: 'transparent',
|
|
2540
|
-
}, visibility: object.
|
|
2652
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("line", { x1: object.totalWidth / 2, y1: "0", x2: object.totalWidth / 2, y2: -((15 * object.scale) / ((_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale)), style: {
|
|
2541
2653
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2542
2654
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale})`,
|
|
2543
|
-
}, visibility: object.
|
|
2655
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "rotation-handle", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_r = this.store.state) === null || _r === void 0 ? void 0 : _r.scale)), r: `${(baseHandleSize * object.scale) / ((_s = this.store.state) === null || _s === void 0 ? void 0 : _s.scale)}`, style: {
|
|
2544
2656
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2545
|
-
}, visibility: object.
|
|
2657
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("circle", { class: "rotation-handle-overlay", cx: object.totalWidth / 2, cy: -((15 * object.scale) / ((_t = this.store.state) === null || _t === void 0 ? void 0 : _t.scale)), r: `${(baseHandleTouchSize * object.scale) / ((_u = this.store.state) === null || _u === void 0 ? void 0 : _u.scale)}`, style: {
|
|
2546
2658
|
fill: 'transparent',
|
|
2547
2659
|
cursor: 'grab',
|
|
2548
|
-
}, visibility: object.
|
|
2549
|
-
}), h("svg", { key: '
|
|
2660
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
|
|
2661
|
+
}), h("svg", { key: '2bd19129a4d4d8334273c221aaa039c562240883', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2550
2662
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
2551
2663
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
2552
2664
|
left: '0',
|
|
@@ -2556,7 +2668,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2556
2668
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
2557
2669
|
transformOrigin: 'top left',
|
|
2558
2670
|
overflow: 'visible',
|
|
2559
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '
|
|
2671
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '327c40e8bd4f838172808fb6ffc6a4f7971ebd63', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '933c55feabc4ae7ac13dffab763c931763e88a7f', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, objects: ((_2 = this.store.state.selectionGroup) === null || _2 === void 0 ? void 0 : _2.objects) || [], style: {
|
|
2560
2672
|
position: 'fixed',
|
|
2561
2673
|
left: `${this.store.state.contextMenuX}px`,
|
|
2562
2674
|
top: `${this.store.state.contextMenuY}px`,
|
|
@@ -2568,7 +2680,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2568
2680
|
y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
|
|
2569
2681
|
}, (_a = this.store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects);
|
|
2570
2682
|
this.hideContextMenu();
|
|
2571
|
-
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
2683
|
+
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '0fa1c51dd63156d26b21b9b443c471cf2014351c', store: this.store })));
|
|
2572
2684
|
}
|
|
2573
2685
|
get host() { return this; }
|
|
2574
2686
|
static get watchers() { return {
|
|
@@ -2642,6 +2754,6 @@ function defineCustomElement() {
|
|
|
2642
2754
|
}
|
|
2643
2755
|
|
|
2644
2756
|
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 };
|
|
2645
|
-
//# sourceMappingURL=p-
|
|
2757
|
+
//# sourceMappingURL=p-COPOzWCn.js.map
|
|
2646
2758
|
|
|
2647
|
-
//# sourceMappingURL=p-
|
|
2759
|
+
//# sourceMappingURL=p-COPOzWCn.js.map
|