kritzel-stencil 0.0.120 → 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 +129 -72
- 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 +40 -33
- 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-eS30Bqrc.js → p-COPOzWCn.js} +213 -100
- 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 +129 -72
- 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-eS30Bqrc.js.map +0 -1
- package/dist/esm/index-DsUDklEm.js.map +0 -1
- package/dist/stencil/p-0ae72b0d.entry.js +0 -2
- package/dist/stencil/p-0ae72b0d.entry.js.map +0 -1
- package/dist/stencil/p-DsUDklEm.js +0 -2
- package/dist/stencil/p-DsUDklEm.js.map +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BcrLbdO1.js');
|
|
4
|
-
var index$1 = require('./index-
|
|
4
|
+
var index$1 = require('./index-CFCyVs0_.js');
|
|
5
5
|
|
|
6
6
|
const kritzelBrushStyleCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.brush-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:default;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}";
|
|
7
7
|
|
|
@@ -663,8 +663,8 @@ const KritzelEditor = class {
|
|
|
663
663
|
name: 'brush',
|
|
664
664
|
type: 'tool',
|
|
665
665
|
tool: index$1.KritzelBrushTool,
|
|
666
|
-
isDefault: true,
|
|
667
666
|
icon: 'pen',
|
|
667
|
+
isDefault: true,
|
|
668
668
|
config: index$1.DEFAULT_BRUSH_CONFIG,
|
|
669
669
|
},
|
|
670
670
|
{
|
|
@@ -716,14 +716,14 @@ const KritzelEditor = class {
|
|
|
716
716
|
object.edit();
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
|
-
}
|
|
719
|
+
},
|
|
720
720
|
},
|
|
721
721
|
{ label: 'Copy', icon: 'copy', action: () => this.engineRef.copy() },
|
|
722
722
|
{
|
|
723
723
|
label: 'Paste',
|
|
724
724
|
icon: 'paste',
|
|
725
725
|
disabled: async () => (await this.engineRef.getCopiedObjects()).length === 0,
|
|
726
|
-
action: menu => this.engineRef.paste(menu.x, menu.y),
|
|
726
|
+
action: (menu, _) => this.engineRef.paste(menu.x, menu.y),
|
|
727
727
|
},
|
|
728
728
|
{ label: 'Delete', icon: 'delete', action: () => this.engineRef.delete() },
|
|
729
729
|
{ label: 'Bring to Front', icon: 'bring-to-front', action: () => this.engineRef.moveToTop() },
|
|
@@ -802,7 +802,7 @@ const KritzelEditor = class {
|
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
804
|
render() {
|
|
805
|
-
return (index.h(index.Host, { key: '
|
|
805
|
+
return (index.h(index.Host, { key: 'f2fa7efff5baf4df8a9b2100b96e1546731b006b' }, index.h("kritzel-engine", { key: 'd4fc5d1b0827656119b14c9e2971818904f41c3f', ref: el => (this.engineRef = el), onIsEngineReady: () => (this.isEngineReady = true), scaleMax: this.scaleMax, scaleMin: this.scaleMin, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems }), index.h("kritzel-controls", { key: 'd5f3a9b3d23090bbc8f36b8f974226697868988d', ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, style: this.isControlsVisible ? { display: 'flex' } : { display: 'none' }, onIsControlsReady: () => (this.isControlsReady = true) })));
|
|
806
806
|
}
|
|
807
807
|
get host() { return index.getElement(this); }
|
|
808
808
|
static get watchers() { return {
|
|
@@ -860,21 +860,27 @@ class KritzelViewport {
|
|
|
860
860
|
}
|
|
861
861
|
handlePointerMove(event) {
|
|
862
862
|
if (event.pointerType === 'mouse') {
|
|
863
|
-
const
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
this._store.state.
|
|
863
|
+
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
864
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
865
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
866
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
867
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
867
868
|
if (this._store.state.isPanning) {
|
|
868
|
-
this._store.state.translateX -= this._store.state.startX -
|
|
869
|
-
this._store.state.translateY -= this._store.state.startY -
|
|
870
|
-
this._store.state.startX =
|
|
871
|
-
this._store.state.startY =
|
|
869
|
+
this._store.state.translateX -= this._store.state.startX - xRelativeToHost;
|
|
870
|
+
this._store.state.translateY -= this._store.state.startY - yRelativeToHost;
|
|
871
|
+
this._store.state.startX = xRelativeToHost;
|
|
872
|
+
this._store.state.startY = yRelativeToHost;
|
|
872
873
|
this._store.state.hasViewportChanged = true;
|
|
873
874
|
this._store.state.skipContextMenu = true;
|
|
874
875
|
this._store.rerender();
|
|
875
876
|
}
|
|
876
877
|
}
|
|
877
878
|
if (event.pointerType === 'touch') {
|
|
879
|
+
const hostRect = this._store.state.host.getBoundingClientRect();
|
|
880
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
881
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
882
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
883
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
878
884
|
const activePointers = Array.from(this._store.state.pointers.values());
|
|
879
885
|
if (activePointers.length === 2) {
|
|
880
886
|
const firstTouchX = activePointers[0].clientX - this._store.offsetX;
|
|
@@ -928,13 +934,15 @@ class KritzelViewport {
|
|
|
928
934
|
}
|
|
929
935
|
handleZoom(event) {
|
|
930
936
|
const rect = this._store.state.host.getBoundingClientRect();
|
|
931
|
-
|
|
932
|
-
|
|
937
|
+
const xRelativeToHost = event.clientX - rect.left;
|
|
938
|
+
const yRelativeToHost = event.clientY - rect.top;
|
|
939
|
+
this._store.state.pointerX = (xRelativeToHost - this._store.state.translateX) / this._store.state.scale;
|
|
940
|
+
this._store.state.pointerY = (yRelativeToHost - this._store.state.translateY) / this._store.state.scale;
|
|
933
941
|
const delta = event.deltaY > 0 ? -this._store.state.scaleStep * this._store.state.scale : this._store.state.scaleStep * this._store.state.scale;
|
|
934
942
|
const newScale = Math.min(this._store.state.scaleMax, Math.max(this._store.state.scaleMin, this._store.state.scale + delta));
|
|
935
943
|
const scaleRatio = newScale / this._store.state.scale;
|
|
936
|
-
const translateXAdjustment = (
|
|
937
|
-
const translateYAdjustment = (
|
|
944
|
+
const translateXAdjustment = (xRelativeToHost - this._store.state.translateX) * (scaleRatio - 1);
|
|
945
|
+
const translateYAdjustment = (yRelativeToHost - this._store.state.translateY) * (scaleRatio - 1);
|
|
938
946
|
this._store.state.scale = newScale;
|
|
939
947
|
this._store.state.translateX -= translateXAdjustment;
|
|
940
948
|
this._store.state.translateY -= translateYAdjustment;
|
|
@@ -1032,19 +1040,7 @@ class KritzelHistory {
|
|
|
1032
1040
|
}
|
|
1033
1041
|
executeCommand(command) {
|
|
1034
1042
|
if (this._store.state.hasViewportChanged) {
|
|
1035
|
-
|
|
1036
|
-
command.execute();
|
|
1037
|
-
this.undoStack.add(command);
|
|
1038
|
-
if (this.redoStack.isEmpty() === false) {
|
|
1039
|
-
this.redoStack.clear();
|
|
1040
|
-
}
|
|
1041
|
-
this._store.state.hasViewportChanged = false;
|
|
1042
|
-
this.previousViewport = {
|
|
1043
|
-
scale: this._store.state.scale,
|
|
1044
|
-
scaleStep: this._store.state.scaleStep,
|
|
1045
|
-
translateX: this._store.state.translateX,
|
|
1046
|
-
translateY: this._store.state.translateY,
|
|
1047
|
-
};
|
|
1043
|
+
this.addUpdateViewportCommand();
|
|
1048
1044
|
}
|
|
1049
1045
|
command.execute();
|
|
1050
1046
|
if (this._store.state.debugInfo.logCommands)
|
|
@@ -1082,6 +1078,21 @@ class KritzelHistory {
|
|
|
1082
1078
|
}
|
|
1083
1079
|
this._store.rerender();
|
|
1084
1080
|
}
|
|
1081
|
+
addUpdateViewportCommand() {
|
|
1082
|
+
const command = new UpdateViewportCommand(this._store, this, this.previousViewport);
|
|
1083
|
+
command.execute();
|
|
1084
|
+
this.undoStack.add(command);
|
|
1085
|
+
if (this.redoStack.isEmpty() === false) {
|
|
1086
|
+
this.redoStack.clear();
|
|
1087
|
+
}
|
|
1088
|
+
this._store.state.hasViewportChanged = false;
|
|
1089
|
+
this.previousViewport = {
|
|
1090
|
+
scale: this._store.state.scale,
|
|
1091
|
+
scaleStep: this._store.state.scaleStep,
|
|
1092
|
+
translateX: this._store.state.translateX,
|
|
1093
|
+
translateY: this._store.state.translateY,
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1085
1096
|
}
|
|
1086
1097
|
|
|
1087
1098
|
class KritzelOctree {
|
|
@@ -1259,8 +1270,8 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
1259
1270
|
logCommands: false,
|
|
1260
1271
|
},
|
|
1261
1272
|
host: null,
|
|
1262
|
-
|
|
1263
|
-
|
|
1273
|
+
pointerX: 0,
|
|
1274
|
+
pointerY: 0,
|
|
1264
1275
|
scale: 1,
|
|
1265
1276
|
scaleMax: 1,
|
|
1266
1277
|
scaleMin: 1,
|
|
@@ -1295,7 +1306,7 @@ class KritzelStore {
|
|
|
1295
1306
|
return this._state.objectsOctree.allObjects();
|
|
1296
1307
|
}
|
|
1297
1308
|
get selectedObjects() {
|
|
1298
|
-
return this.allObjects.filter(o => !(o instanceof index$1.KritzelSelectionGroup)).filter(o => o.
|
|
1309
|
+
return this.allObjects.filter(o => !(o instanceof index$1.KritzelSelectionGroup)).filter(o => o.isSelected);
|
|
1299
1310
|
}
|
|
1300
1311
|
get offsetX() {
|
|
1301
1312
|
return this._state.host.getBoundingClientRect().left;
|
|
@@ -1386,7 +1397,7 @@ class KritzelStore {
|
|
|
1386
1397
|
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
1387
1398
|
}
|
|
1388
1399
|
paste(x, y) {
|
|
1389
|
-
this.state.copiedObjects.
|
|
1400
|
+
this.state.copiedObjects.isSelected = true;
|
|
1390
1401
|
const adjustedX = x !== undefined ? x : this.state.copiedObjects.translateX + 25;
|
|
1391
1402
|
const adjustedY = y !== undefined ? y : this.state.copiedObjects.translateY + 25;
|
|
1392
1403
|
this.state.copiedObjects.updatePosition(adjustedX, adjustedY);
|
|
@@ -1446,10 +1457,10 @@ class KritzelStore {
|
|
|
1446
1457
|
}
|
|
1447
1458
|
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
1448
1459
|
objects.forEach(obj => {
|
|
1449
|
-
obj.
|
|
1460
|
+
obj.isSelected = false;
|
|
1450
1461
|
selectionGroup.addOrRemove(obj);
|
|
1451
1462
|
});
|
|
1452
|
-
selectionGroup.
|
|
1463
|
+
selectionGroup.isSelected = true;
|
|
1453
1464
|
this.state.selectionGroup = selectionGroup;
|
|
1454
1465
|
if (objects.length === 1) {
|
|
1455
1466
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
@@ -1470,10 +1481,10 @@ class KritzelStore {
|
|
|
1470
1481
|
if (objectsInViewport.length > 0) {
|
|
1471
1482
|
const selectionGroup = index$1.KritzelSelectionGroup.create(this);
|
|
1472
1483
|
objectsInViewport.forEach(obj => {
|
|
1473
|
-
obj.
|
|
1484
|
+
obj.isSelected = false;
|
|
1474
1485
|
selectionGroup.addOrRemove(obj);
|
|
1475
1486
|
});
|
|
1476
|
-
selectionGroup.
|
|
1487
|
+
selectionGroup.isSelected = true;
|
|
1477
1488
|
this.state.isSelecting = false;
|
|
1478
1489
|
if (objectsInViewport.length === 1) {
|
|
1479
1490
|
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
@@ -1514,6 +1525,45 @@ class KritzelStore {
|
|
|
1514
1525
|
}
|
|
1515
1526
|
return null;
|
|
1516
1527
|
}
|
|
1528
|
+
getObjectsFromPointerEvent(event, selector = '.object') {
|
|
1529
|
+
var _a;
|
|
1530
|
+
const shadowRoot = (_a = this.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
|
|
1531
|
+
if (!shadowRoot)
|
|
1532
|
+
return [];
|
|
1533
|
+
const clientX = event.clientX;
|
|
1534
|
+
const clientY = event.clientY;
|
|
1535
|
+
const elementsAtPoint = shadowRoot.elementsFromPoint(clientX, clientY);
|
|
1536
|
+
if (!elementsAtPoint || elementsAtPoint.length === 0)
|
|
1537
|
+
return [];
|
|
1538
|
+
const objectIds = new Set();
|
|
1539
|
+
elementsAtPoint.forEach(element => {
|
|
1540
|
+
const selectedObject = element.closest(selector);
|
|
1541
|
+
if (selectedObject && selectedObject.id) {
|
|
1542
|
+
objectIds.add(selectedObject.id);
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
if (objectIds.size > 0) {
|
|
1546
|
+
return this.allObjects.filter(object => objectIds.has(object.id)).sort((a, b) => b.zIndex - a.zIndex);
|
|
1547
|
+
}
|
|
1548
|
+
return [];
|
|
1549
|
+
}
|
|
1550
|
+
getCanvasPoint(event) {
|
|
1551
|
+
if (!this.state.host) {
|
|
1552
|
+
return { x: 0, y: 0 };
|
|
1553
|
+
}
|
|
1554
|
+
// Get the position of the kritzel-engine host element relative to the viewport
|
|
1555
|
+
const hostRect = this.state.host.getBoundingClientRect();
|
|
1556
|
+
// 1. Make the pointer coordinates relative to the host element
|
|
1557
|
+
const xRelativeToHost = event.clientX - hostRect.left;
|
|
1558
|
+
const yRelativeToHost = event.clientY - hostRect.top;
|
|
1559
|
+
// 2. Reverse the translation applied to the #origin div
|
|
1560
|
+
const xWithoutTranslate = xRelativeToHost - this.state.translateX;
|
|
1561
|
+
const yWithoutTranslate = yRelativeToHost - this.state.translateY;
|
|
1562
|
+
// 3. Reverse the scaling to get the final world coordinates
|
|
1563
|
+
const worldX = xWithoutTranslate / this.state.scale;
|
|
1564
|
+
const worldY = yWithoutTranslate / this.state.scale;
|
|
1565
|
+
return { x: worldX, y: worldY };
|
|
1566
|
+
}
|
|
1517
1567
|
}
|
|
1518
1568
|
|
|
1519
1569
|
class KritzelKeyHandler extends index$1.KritzelBaseHandler {
|
|
@@ -1612,7 +1662,7 @@ class KritzelContextMenuHandler extends index$1.KritzelBaseHandler {
|
|
|
1612
1662
|
if (selectedObject && !(selectedObject instanceof index$1.KritzelSelectionGroup)) {
|
|
1613
1663
|
this._store.state.selectionGroup = index$1.KritzelSelectionGroup.create(this._store);
|
|
1614
1664
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
1615
|
-
this._store.state.selectionGroup.
|
|
1665
|
+
this._store.state.selectionGroup.isSelected = true;
|
|
1616
1666
|
this._store.state.selectionGroup.rotation = selectedObject.rotation;
|
|
1617
1667
|
this._store.state.isSelecting = false;
|
|
1618
1668
|
this._store.history.executeCommand(new index$1.AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
@@ -1927,15 +1977,15 @@ const KritzelEngine = class {
|
|
|
1927
1977
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
1928
1978
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
1929
1979
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
1930
|
-
return (index.h(index.Host, { key: '
|
|
1931
|
-
_a.translateX), index.h("div", { key: '
|
|
1932
|
-
_b.translateY), index.h("div", { key: '
|
|
1933
|
-
_c.viewportWidth), index.h("div", { key: '
|
|
1934
|
-
_d.viewportHeight), index.h("div", { key: '
|
|
1935
|
-
_e.scale), index.h("div", { key: '
|
|
1936
|
-
_g.name), index.h("div", { key: '
|
|
1937
|
-
_m.
|
|
1938
|
-
_o.
|
|
1980
|
+
return (index.h(index.Host, { key: 'a8e6c284c98509ddd158686887d656d3907d40a2' }, index.h("div", { key: '3935b658e8859f746a5faef0bb91a527b68fcd3e', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '12c190c7ea99ac69310b27e719e7df8392b2b46e' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
1981
|
+
_a.translateX), index.h("div", { key: '4c98deccc2a029dab06ed76e5af426f4a05c7b66' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
1982
|
+
_b.translateY), index.h("div", { key: '1330191a39c7795f17a6adcc4fbd05e2d6a24d43' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
1983
|
+
_c.viewportWidth), index.h("div", { key: '1ee59427037357ee6bf746a094285426eb0e6a58' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
1984
|
+
_d.viewportHeight), index.h("div", { key: '1e68312e8516f25dcff34e9f9f70b90f426b8711' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '1d7cea9e21d9b744d8eaac29286528829143b4fa' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
1985
|
+
_e.scale), index.h("div", { key: '0b60168fbd55aefa3714067bace80f167b8bcac0' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
1986
|
+
_g.name), index.h("div", { key: '109752df6a77633d89929f325d296f96d27d7aa9' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'b35466caf465b490c5d448d694353186ff902f09' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '5df20e47f3bf234f04eea001b0a0abaf57946498' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '9d1ec8b8268488821a968e109fa279393977fdf8' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: '92fa98b7fa3bf877c4fffaca70683d2d908f5177' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '708d02459c1e3907dd88a2f2fd8916c1ee684cf1' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '27f45c1b6ee0b6bd0b3301a9c09b9198de722ac4' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '50d4476aecfc00d12bae7d8a3880ccb8de82fe68' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '0c582e97ee1535b4a14b75b7ef15373c43f21c4b' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: '7a8378ac991d17d0eaaba5fbd519875197903a39' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '00b56f11ffd16f7b9049d2857f5f7effceba1294' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '3b7773194bd6bc8b8b2d024afc768f4e9fbb54c6' }, "PointerX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
1987
|
+
_m.pointerX), index.h("div", { key: 'a2b2c96f6180591082a5aee20cc3e82236dac520' }, "PointerY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
1988
|
+
_o.pointerY)), index.h("div", { key: '309eb61fff5182b5076cb3886bbd79006efc30b1', id: "origin", class: "origin", style: {
|
|
1939
1989
|
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})`,
|
|
1940
1990
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
1941
1991
|
_t.map(object => {
|
|
@@ -1959,17 +2009,17 @@ const KritzelEngine = class {
|
|
|
1959
2009
|
borderStyle: 'solid',
|
|
1960
2010
|
padding: object.padding + 'px',
|
|
1961
2011
|
overflow: 'visible',
|
|
1962
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2012
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el => el ? object.mount(el) : object.unmount(), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
1963
2013
|
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
1964
2014
|
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
1965
2015
|
position: 'absolute',
|
|
1966
2016
|
overflow: 'visible',
|
|
1967
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, index.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') && (index.h("img", { ref: el => object.mount(el), src: object.src, style: {
|
|
2017
|
+
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, index.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') && (index.h("img", { ref: el => el ? object.mount(el) : object.unmount(), src: object.src, style: {
|
|
1968
2018
|
width: '100%',
|
|
1969
2019
|
height: '100%',
|
|
1970
2020
|
userSelect: 'none',
|
|
1971
2021
|
pointerEvents: 'none',
|
|
1972
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.h("textarea", { ref: el => object.mount(el), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
2022
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.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: {
|
|
1973
2023
|
width: '100%',
|
|
1974
2024
|
height: '100%',
|
|
1975
2025
|
color: object.fontColor,
|
|
@@ -1985,54 +2035,60 @@ const KritzelEngine = class {
|
|
|
1985
2035
|
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
1986
2036
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
1987
2037
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
1988
|
-
} })), KritzelClassHelper.isInstanceOf(object, '
|
|
2038
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelCustomElement') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
2039
|
+
width: '100%',
|
|
2040
|
+
height: '100%',
|
|
2041
|
+
pointerEvents: 'auto',
|
|
2042
|
+
overflow: 'hidden',
|
|
2043
|
+
display: 'block',
|
|
2044
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
1989
2045
|
width: '100%',
|
|
1990
2046
|
height: '100%',
|
|
1991
|
-
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
2047
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el => el ? object.mount(el) : object.unmount(), style: {
|
|
1992
2048
|
width: '100%',
|
|
1993
2049
|
height: '100%',
|
|
1994
2050
|
} }))), index.h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
1995
2051
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
1996
2052
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_b = this.store.state) === null || _b === void 0 ? void 0 : _b.scale})`,
|
|
1997
2053
|
strokeLinecap: 'square',
|
|
1998
|
-
}, visibility: object.
|
|
2054
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: "0", y1: "0", x2: "0", y2: object.totalHeight, style: {
|
|
1999
2055
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2000
2056
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_c = this.store.state) === null || _c === void 0 ? void 0 : _c.scale})`,
|
|
2001
2057
|
strokeLinecap: 'square',
|
|
2002
|
-
}, visibility: object.
|
|
2058
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: "0", y1: object.totalHeight, x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2003
2059
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2004
2060
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_d = this.store.state) === null || _d === void 0 ? void 0 : _d.scale})`,
|
|
2005
2061
|
strokeLinecap: 'square',
|
|
2006
|
-
}, visibility: object.
|
|
2062
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.h("line", { x1: object.totalWidth, y1: "0", x2: object.totalWidth, y2: object.totalHeight, style: {
|
|
2007
2063
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2008
2064
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_e = this.store.state) === null || _e === void 0 ? void 0 : _e.scale})`,
|
|
2009
2065
|
strokeLinecap: 'square',
|
|
2010
|
-
}, visibility: object.
|
|
2066
|
+
}, visibility: object.isSelected ? 'visible' : 'hidden' }), index.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: {
|
|
2011
2067
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2012
|
-
}, visibility: object.
|
|
2068
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2013
2069
|
fill: 'transparent',
|
|
2014
|
-
}, visibility: object.
|
|
2070
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2015
2071
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2016
|
-
}, visibility: object.
|
|
2072
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2017
2073
|
fill: 'transparent',
|
|
2018
|
-
}, visibility: object.
|
|
2074
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2019
2075
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2020
|
-
}, visibility: object.
|
|
2076
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2021
2077
|
fill: 'transparent',
|
|
2022
|
-
}, visibility: object.
|
|
2078
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2023
2079
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2024
|
-
}, visibility: object.
|
|
2080
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2025
2081
|
fill: 'transparent',
|
|
2026
|
-
}, visibility: object.
|
|
2082
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2027
2083
|
stroke: 'var(--kritzel-selection-border-color, #0e1111)',
|
|
2028
2084
|
strokeWidth: `calc(var(--kritzel-selection-border-width, 2px) * ${object.scale} / ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale})`,
|
|
2029
|
-
}, visibility: object.
|
|
2085
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2030
2086
|
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
2031
|
-
}, visibility: object.
|
|
2087
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.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: {
|
|
2032
2088
|
fill: 'transparent',
|
|
2033
2089
|
cursor: 'grab',
|
|
2034
|
-
}, visibility: object.
|
|
2035
|
-
}), index.h("svg", { key: '
|
|
2090
|
+
}, visibility: object.isSelected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.isDebugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), index.h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), index.h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), index.h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), index.h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
|
|
2091
|
+
}), index.h("svg", { key: '2bd19129a4d4d8334273c221aaa039c562240883', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2036
2092
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
2037
2093
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
2038
2094
|
left: '0',
|
|
@@ -2042,18 +2098,19 @@ const KritzelEngine = class {
|
|
|
2042
2098
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
2043
2099
|
transformOrigin: 'top left',
|
|
2044
2100
|
overflow: 'visible',
|
|
2045
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '
|
|
2101
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.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 && (index.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: {
|
|
2046
2102
|
position: 'fixed',
|
|
2047
2103
|
left: `${this.store.state.contextMenuX}px`,
|
|
2048
2104
|
top: `${this.store.state.contextMenuY}px`,
|
|
2049
2105
|
zIndex: '10000',
|
|
2050
2106
|
}, onActionSelected: event => {
|
|
2107
|
+
var _a;
|
|
2051
2108
|
event.detail.action({
|
|
2052
2109
|
x: (-this.store.state.translateX + this.store.state.contextMenuX) / this.store.state.scale,
|
|
2053
2110
|
y: (-this.store.state.translateY + this.store.state.contextMenuY) / this.store.state.scale,
|
|
2054
|
-
}, this.store.state.selectionGroup.objects);
|
|
2111
|
+
}, (_a = this.store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects);
|
|
2055
2112
|
this.hideContextMenu();
|
|
2056
|
-
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof index$1.KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '
|
|
2113
|
+
} })), ((_3 = this.store.state) === null || _3 === void 0 ? void 0 : _3.activeTool) instanceof index$1.KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '0fa1c51dd63156d26b21b9b443c471cf2014351c', store: this.store })));
|
|
2057
2114
|
}
|
|
2058
2115
|
get host() { return index.getElement(this); }
|
|
2059
2116
|
static get watchers() { return {
|