kritzel-stencil 0.0.105 → 0.0.107
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/kritzel-brush-style_18.cjs.entry.js +251 -124
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +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/selection.handler.js +4 -4
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +7 -2
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +14 -7
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +22 -16
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +15 -9
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +11 -5
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +29 -12
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/reviver.class.js +4 -4
- package/dist/collection/classes/reviver.class.js.map +1 -1
- package/dist/collection/classes/store.class.js +30 -14
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +4 -4
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +2 -2
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +5 -2
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -10
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- 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 +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +235 -22
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.css +43 -43
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +2 -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.css +20 -20
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +53 -53
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.css +10 -10
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +48 -48
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +2 -2
- 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.css +30 -30
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +17 -17
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +17 -17
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- 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 -1
- 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.css +18 -18
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
- package/dist/collection/helpers/keyboard.helper.js +23 -0
- package/dist/collection/helpers/keyboard.helper.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/components/kritzel-brush-style.js +1 -1
- 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 +17 -17
- package/dist/components/kritzel-editor.js.map +1 -1
- 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-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/{p-D06w3u84.js → p-B7P9QBiE.js} +4 -4
- package/dist/components/p-B7P9QBiE.js.map +1 -0
- package/dist/components/{p-BjqfG-5H.js → p-BXJ8s30N.js} +8 -8
- package/dist/components/{p-BjqfG-5H.js.map → p-BXJ8s30N.js.map} +1 -1
- package/dist/components/{p-BYH2jNAX.js → p-CPjl7Inl.js} +3 -3
- package/dist/components/{p-BYH2jNAX.js.map → p-CPjl7Inl.js.map} +1 -1
- package/dist/components/p-CZkSABuJ.js.map +1 -1
- package/dist/components/{p-BYt7-mGK.js → p-Cbu5RSmC.js} +3 -3
- package/dist/components/{p-BYt7-mGK.js.map → p-Cbu5RSmC.js.map} +1 -1
- package/dist/components/{p-DT8_Rz-o.js → p-CesjDLvT.js} +100 -39
- package/dist/components/p-CesjDLvT.js.map +1 -0
- package/dist/components/{p-DaeIjoQm.js → p-Ck2d5Wd1.js} +4 -4
- package/dist/components/p-Ck2d5Wd1.js.map +1 -0
- package/dist/components/{p-C8KDwUb7.js → p-CmckGlXt.js} +3 -3
- package/dist/components/p-CmckGlXt.js.map +1 -0
- package/dist/components/{p-_wFpvzNp.js → p-DFhbw-Fr.js} +4 -4
- package/dist/components/p-DFhbw-Fr.js.map +1 -0
- package/dist/components/{p-BJ5xxphF.js → p-DHT5gK0E.js} +3 -3
- package/dist/components/{p-BJ5xxphF.js.map → p-DHT5gK0E.js.map} +1 -1
- package/dist/components/{p-X3xYsp4r.js → p-DInF8Iby.js} +6 -6
- package/dist/components/p-DInF8Iby.js.map +1 -0
- package/dist/components/{p-D31-QJwi.js → p-DTcfnx4-.js} +14 -14
- package/dist/components/{p-D31-QJwi.js.map → p-DTcfnx4-.js.map} +1 -1
- package/dist/components/{p-BgUIonZF.js → p-DfMdBA8L.js} +4 -4
- package/dist/components/p-DfMdBA8L.js.map +1 -0
- package/dist/components/{p-CDhTT8u8.js → p-Ds3FhuuO.js} +3 -3
- package/dist/components/p-Ds3FhuuO.js.map +1 -0
- package/dist/components/{p-C3vo4rx8.js → p-_3gCPfqz.js} +151 -79
- package/dist/components/p-_3gCPfqz.js.map +1 -0
- package/dist/components/{p-DQHNxDS7.js → p-c6tIpE_t.js} +3 -3
- package/dist/components/p-c6tIpE_t.js.map +1 -0
- package/dist/components/{p-BqUM5gV3.js → p-maiDeBe9.js} +9 -9
- package/dist/components/p-maiDeBe9.js.map +1 -0
- package/dist/esm/kritzel-brush-style_18.entry.js +251 -124
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/p-e596d004.entry.js +2 -0
- package/dist/stencil/p-e596d004.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/base-object.class.d.ts +4 -3
- package/dist/types/classes/objects/image.class.d.ts +1 -1
- package/dist/types/classes/objects/path.class.d.ts +1 -1
- package/dist/types/classes/objects/selection-box.class.d.ts +1 -1
- package/dist/types/classes/objects/selection-group.class.d.ts +1 -1
- package/dist/types/classes/objects/text.class.d.ts +12 -1
- package/dist/types/classes/store.class.d.ts +3 -3
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +2 -0
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +8 -1
- package/dist/types/components.d.ts +11 -3
- package/dist/types/helpers/keyboard.helper.d.ts +2 -0
- package/dist/types/interfaces/object.interface.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-BgUIonZF.js.map +0 -1
- package/dist/components/p-BqUM5gV3.js.map +0 -1
- package/dist/components/p-C3vo4rx8.js.map +0 -1
- package/dist/components/p-C8KDwUb7.js.map +0 -1
- package/dist/components/p-CDhTT8u8.js.map +0 -1
- package/dist/components/p-D06w3u84.js.map +0 -1
- package/dist/components/p-DQHNxDS7.js.map +0 -1
- package/dist/components/p-DT8_Rz-o.js.map +0 -1
- package/dist/components/p-DaeIjoQm.js.map +0 -1
- package/dist/components/p-X3xYsp4r.js.map +0 -1
- package/dist/components/p-_wFpvzNp.js.map +0 -1
- package/dist/stencil/p-d0394bb5.entry.js +0 -2
- package/dist/stencil/p-d0394bb5.entry.js.map +0 -1
|
@@ -22,7 +22,7 @@ const KritzelBrushStyle = class {
|
|
|
22
22
|
value: option.value,
|
|
23
23
|
label: option.label,
|
|
24
24
|
}));
|
|
25
|
-
return (index.h(index.Host, { key: '
|
|
25
|
+
return (index.h(index.Host, { key: 'd7af382fe6f613aa16a5146785990ad2faa17f60' }, index.h("kritzel-dropdown", { key: '6d6d330d415c210058834b2968774b3db2ab7fc4', options: dropdownOptions, value: this.type, onValueChanged: event => this.handleDropdownValueChange(event) }, index.h("button", { key: 'c9fb33795b8e25f68c1d2ae248dc82a6de29e199', class: "brush-style-button", slot: "prefix" }, index.h("kritzel-icon", { key: '975c95b545a1c27ae2984405ac298592eec9743d', name: this.type, size: 16 })))));
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
KritzelBrushStyle.style = kritzelBrushStyleCss;
|
|
@@ -60,13 +60,13 @@ const KritzelColor = class {
|
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
62
|
const isColorVeryLight = this.isLightColor(this.value);
|
|
63
|
-
return (index.h(index.Host, { key: '
|
|
63
|
+
return (index.h(index.Host, { key: '19ad3872a132c885c612dc3b96698a0c8dc7214d' }, index.h("div", { key: 'f67108e82396cbaa3d070c8dfc83da2b080ddf47', class: "checkerboard-bg", style: {
|
|
64
64
|
width: `${this.size}px`,
|
|
65
65
|
height: `${this.size}px`,
|
|
66
66
|
borderRadius: '50%',
|
|
67
67
|
display: 'inline-block',
|
|
68
68
|
position: 'relative',
|
|
69
|
-
} }, index.h("div", { key: '
|
|
69
|
+
} }, index.h("div", { key: '1af0cc3e9f6eebc04cae2367510ef3b98420a818', class: {
|
|
70
70
|
'color-circle': true,
|
|
71
71
|
'white': isColorVeryLight,
|
|
72
72
|
}, style: {
|
|
@@ -136,7 +136,7 @@ const KritzelContextMenu = class {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
render() {
|
|
139
|
-
return (index.h(index.Host, { key: '
|
|
139
|
+
return (index.h(index.Host, { key: 'db318a0936f89f202ef5101447b723c0ba7aa139' }, index.h("div", { key: '53da01021464f605e08c5f910997bb8f21d481a1', class: "menu-container" }, this.items.map(item => (index.h("button", { key: `${item.label}-${this.items.indexOf(item)}`, class: { 'menu-item': true, 'disabled': typeof item.disabled === 'function' ? item.disabled() : item.disabled }, onClick: () => this.handleItemClick(item), onTouchStart: () => this.handleItemClick(item), disabled: typeof item.disabled === 'function' ? item.disabled() : item.disabled }, item.icon && index.h("kritzel-icon", { name: item.icon, size: 16 }), index.h("span", { class: "label" }, item.label)))))));
|
|
140
140
|
}
|
|
141
141
|
get hostElement() { return index.getElement(this); }
|
|
142
142
|
};
|
|
@@ -175,14 +175,14 @@ const KritzelControlBrushConfig = class {
|
|
|
175
175
|
this.toolChange.emit(this.tool);
|
|
176
176
|
}
|
|
177
177
|
render() {
|
|
178
|
-
return (index.h(index.Host, { key: '
|
|
178
|
+
return (index.h(index.Host, { key: '8e7930fcc093f7277ed088d8ec5e54e4cd051b86' }, index.h("div", { key: '08bd37b90decc9054c05d646aabbba0a4985d04c', style: {
|
|
179
179
|
display: 'flex',
|
|
180
180
|
flexDirection: 'row',
|
|
181
181
|
alignItems: 'center',
|
|
182
182
|
justifyContent: 'flex-start',
|
|
183
183
|
width: '100%',
|
|
184
184
|
gap: '8px',
|
|
185
|
-
} }, index.h("kritzel-brush-style", { key: '
|
|
185
|
+
} }, index.h("kritzel-brush-style", { key: 'f79744fb6523d0b4fa67c324cbf8ff3eb8a0308d', type: this.tool.type, onTypeChange: event => this.handleTypeChange(event) }), index.h("button", { key: 'dc3bdd90cebb29f2357e13dbc8d2dcaf02ae056e', class: "expand-toggle", onClick: () => this.handleToggleExpand(), title: this.isExpanded ? 'Collapse' : 'Expand', style: this.palette.length > 6 ? { visibillity: 'visible' } : { visibility: 'hidden' } }, index.h("kritzel-icon", { key: '6e9e6de7fc7c708aad700498e030d2ad7364a9f3', name: this.isExpanded ? 'chevron-up' : 'chevron-down' }))), index.h("kritzel-color-palette", { key: 'c1ffd48a475754bb1447e9d866b494fd3476f050', colors: this.palette, selectedColor: this.tool.color, isExpanded: this.isExpanded, isOpaque: true, onColorChange: color => this.handleColorChange(color) }), index.h("kritzel-stroke-size", { key: '38e265b42fe09d0105e0385d7ec8e7d8d318abb0', selectedSize: this.tool.size, onSizeChange: event => this.handleSizeChange(event) })));
|
|
186
186
|
}
|
|
187
187
|
static get watchers() { return {
|
|
188
188
|
"tool": ["handleToolChange"]
|
|
@@ -454,7 +454,7 @@ class KritzelBaseObject {
|
|
|
454
454
|
get centerY() {
|
|
455
455
|
return this.translateY + this.totalHeight / 2;
|
|
456
456
|
}
|
|
457
|
-
constructor(
|
|
457
|
+
constructor() {
|
|
458
458
|
this.__class__ = 'KritzelBaseObject';
|
|
459
459
|
this.visible = true;
|
|
460
460
|
this.borderWidth = 0;
|
|
@@ -467,9 +467,14 @@ class KritzelBaseObject {
|
|
|
467
467
|
this.isMounted = false;
|
|
468
468
|
this.zIndex = 0;
|
|
469
469
|
this.debugInfoVisible = false;
|
|
470
|
-
this._store = store;
|
|
471
470
|
this.id = this.generateId();
|
|
472
471
|
}
|
|
472
|
+
static create(store) {
|
|
473
|
+
const object = new KritzelBaseObject();
|
|
474
|
+
object._store = store;
|
|
475
|
+
object.zIndex = store.currentZIndex;
|
|
476
|
+
return object;
|
|
477
|
+
}
|
|
473
478
|
mount(element) {
|
|
474
479
|
if (this.isMounted) {
|
|
475
480
|
return;
|
|
@@ -528,12 +533,8 @@ class KritzelBaseObject {
|
|
|
528
533
|
}
|
|
529
534
|
|
|
530
535
|
class KritzelPath extends KritzelBaseObject {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
constructor(store, options) {
|
|
535
|
-
var _a, _b, _c, _d, _e, _f;
|
|
536
|
-
super(store);
|
|
536
|
+
constructor() {
|
|
537
|
+
super(...arguments);
|
|
537
538
|
this.__class__ = 'KritzelPath';
|
|
538
539
|
this.stroke = 'none';
|
|
539
540
|
this.lineSlack = 0.5;
|
|
@@ -544,16 +545,26 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
544
545
|
this.scale = 1;
|
|
545
546
|
this.visible = true;
|
|
546
547
|
this.debugInfoVisible = true;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
this.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
548
|
+
}
|
|
549
|
+
get viewBox() {
|
|
550
|
+
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
551
|
+
}
|
|
552
|
+
static create(store, options) {
|
|
553
|
+
var _a, _b, _c, _d, _e, _f;
|
|
554
|
+
const object = new KritzelPath();
|
|
555
|
+
object._store = store;
|
|
556
|
+
object.id = object.generateId();
|
|
557
|
+
object.options = options;
|
|
558
|
+
object.points = (_a = options === null || options === void 0 ? void 0 : options.points) !== null && _a !== void 0 ? _a : [];
|
|
559
|
+
object.translateX = (_b = options === null || options === void 0 ? void 0 : options.translateX) !== null && _b !== void 0 ? _b : 0;
|
|
560
|
+
object.translateY = (_c = options === null || options === void 0 ? void 0 : options.translateY) !== null && _c !== void 0 ? _c : 0;
|
|
561
|
+
object.scale = (_d = options === null || options === void 0 ? void 0 : options.scale) !== null && _d !== void 0 ? _d : 1;
|
|
562
|
+
object.strokeWidth = (_e = options === null || options === void 0 ? void 0 : options.strokeWidth) !== null && _e !== void 0 ? _e : 8;
|
|
563
|
+
object.fill = (_f = options === null || options === void 0 ? void 0 : options.fill) !== null && _f !== void 0 ? _f : '#000000';
|
|
564
|
+
object.zIndex = store.currentZIndex;
|
|
565
|
+
object.d = object.generateSvgPath();
|
|
566
|
+
object.updateDimensions();
|
|
567
|
+
return object;
|
|
557
568
|
}
|
|
558
569
|
resize(x, y, width, height) {
|
|
559
570
|
if (width <= 1 || height <= 1) {
|
|
@@ -700,7 +711,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
700
711
|
this._store.state.isDrawing = true;
|
|
701
712
|
const x = event.clientX - this._store.offsetX;
|
|
702
713
|
const y = event.clientY - this._store.offsetY;
|
|
703
|
-
this._store.state.currentPath =
|
|
714
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
704
715
|
points: [[x, y]],
|
|
705
716
|
translateX: -this._store.state.translateX,
|
|
706
717
|
translateY: -this._store.state.translateY,
|
|
@@ -714,7 +725,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
714
725
|
if (this._store.state.isDrawing) {
|
|
715
726
|
const x = event.clientX - this._store.offsetX;
|
|
716
727
|
const y = event.clientY - this._store.offsetY;
|
|
717
|
-
this._store.state.currentPath =
|
|
728
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
718
729
|
points: [...this._store.state.currentPath.points, [x, y]],
|
|
719
730
|
translateX: -this._store.state.translateX,
|
|
720
731
|
translateY: -this._store.state.translateY,
|
|
@@ -740,7 +751,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
740
751
|
const x = Math.round(event.touches[0].clientX - this._store.offsetX);
|
|
741
752
|
const y = Math.round(event.touches[0].clientY - this._store.offsetY);
|
|
742
753
|
this._store.state.isDrawing = true;
|
|
743
|
-
this._store.state.currentPath =
|
|
754
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
744
755
|
points: [[x, y]],
|
|
745
756
|
translateX: -this._store.state.translateX,
|
|
746
757
|
translateY: -this._store.state.translateY,
|
|
@@ -755,7 +766,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
755
766
|
if (this._store.state.touchCount === 1) {
|
|
756
767
|
const x = Math.round(event.touches[0].clientX - this._store.offsetX);
|
|
757
768
|
const y = Math.round(event.touches[0].clientY - this._store.offsetY);
|
|
758
|
-
this._store.state.currentPath =
|
|
769
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
759
770
|
points: [...this._store.state.currentPath.points, [x, y]],
|
|
760
771
|
translateX: -this._store.state.translateX,
|
|
761
772
|
translateY: -this._store.state.translateY,
|
|
@@ -783,8 +794,8 @@ class KritzelText extends KritzelBaseObject {
|
|
|
783
794
|
get isReadonly() {
|
|
784
795
|
return !(this._store.state.activeTool instanceof KritzelTextTool);
|
|
785
796
|
}
|
|
786
|
-
constructor(
|
|
787
|
-
super(
|
|
797
|
+
constructor(config) {
|
|
798
|
+
super();
|
|
788
799
|
this.__class__ = 'KritzelText';
|
|
789
800
|
this.value = '';
|
|
790
801
|
this.fontFamily = 'Arial';
|
|
@@ -794,16 +805,33 @@ class KritzelText extends KritzelBaseObject {
|
|
|
794
805
|
this.isNew = true;
|
|
795
806
|
this.debugInfoVisible = true;
|
|
796
807
|
this.rows = 1;
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
808
|
+
if (config) {
|
|
809
|
+
this.value = config.value || ' ';
|
|
810
|
+
this.translateX = config.translateX || 0;
|
|
811
|
+
this.translateY = config.translateY || 0;
|
|
812
|
+
this.fontSize = config.fontSize || 8;
|
|
813
|
+
this.fontFamily = config.fontFamily || 'Arial';
|
|
814
|
+
this.fontColor = config.fontColor || '#000000';
|
|
815
|
+
this.height = config.height || (this.fontSize * 1.2);
|
|
816
|
+
this.width = config.width || 0;
|
|
817
|
+
this.scale = config.scale || 1;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
static create(store, fontSize, fontFamily) {
|
|
821
|
+
const object = new KritzelText();
|
|
822
|
+
object._store = store;
|
|
823
|
+
object.fontSize = fontSize;
|
|
824
|
+
object.fontFamily = fontFamily;
|
|
825
|
+
object.translateX = 0;
|
|
826
|
+
object.translateY = 0;
|
|
827
|
+
object.width = object.initialWidth / (object._store.state.scale < 0 ? object._store.state.scale : 1);
|
|
828
|
+
object.height = (object.fontSize * 1.2) / (object._store.state.scale < 0 ? object._store.state.scale : 1);
|
|
829
|
+
object.padding = 5;
|
|
830
|
+
object.backgroundColor = 'transparent';
|
|
831
|
+
object.scale = object._store.state.scale;
|
|
832
|
+
object.value = ' ';
|
|
833
|
+
object.zIndex = store.currentZIndex;
|
|
834
|
+
return object;
|
|
807
835
|
}
|
|
808
836
|
mount(element) {
|
|
809
837
|
if ((this.isMounted && this.elementRef === element) || this.isInViewport() === false) {
|
|
@@ -908,6 +936,37 @@ class KritzelToolRegistry {
|
|
|
908
936
|
}
|
|
909
937
|
KritzelToolRegistry.registry = {};
|
|
910
938
|
|
|
939
|
+
class KritzelKeyboardHelper {
|
|
940
|
+
static forceHideKeyboard() {
|
|
941
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
942
|
+
document.activeElement.blur();
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
static enableInteractiveWidget() {
|
|
946
|
+
const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
|
|
947
|
+
if (meta) {
|
|
948
|
+
let currentContent = meta.getAttribute('content');
|
|
949
|
+
if (!currentContent.includes('interactive-widget=resizes-content')) {
|
|
950
|
+
currentContent += ', interactive-widget=resizes-content';
|
|
951
|
+
}
|
|
952
|
+
meta.setAttribute('content', currentContent);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
static disableInteractiveWidget() {
|
|
956
|
+
const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
|
|
957
|
+
if (meta) {
|
|
958
|
+
let currentContent = meta.getAttribute('content');
|
|
959
|
+
let newContent = currentContent.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g, '');
|
|
960
|
+
newContent = newContent
|
|
961
|
+
.replace(/,(\s*,)+/g, ',')
|
|
962
|
+
.replace(/^,/, '')
|
|
963
|
+
.replace(/,$/, '')
|
|
964
|
+
.trim();
|
|
965
|
+
meta.setAttribute('content', newContent);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
911
970
|
class KritzelTextTool extends KritzelBaseTool {
|
|
912
971
|
constructor(store) {
|
|
913
972
|
super(store);
|
|
@@ -955,7 +1014,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
955
1014
|
}
|
|
956
1015
|
const clientX = event.clientX - this._store.offsetX;
|
|
957
1016
|
const clientY = event.clientY - this._store.offsetY;
|
|
958
|
-
const text =
|
|
1017
|
+
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
959
1018
|
text.fontColor = this.fontColor;
|
|
960
1019
|
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
961
1020
|
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
@@ -990,9 +1049,10 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
990
1049
|
if (this._store.state.touchCount > 1) {
|
|
991
1050
|
return;
|
|
992
1051
|
}
|
|
1052
|
+
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
993
1053
|
const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);
|
|
994
1054
|
const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);
|
|
995
|
-
const text =
|
|
1055
|
+
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
996
1056
|
text.fontColor = this.fontColor;
|
|
997
1057
|
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
998
1058
|
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
@@ -1004,6 +1064,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
1004
1064
|
var _a, _b;
|
|
1005
1065
|
(_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1006
1066
|
(_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
|
|
1067
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
1007
1068
|
}
|
|
1008
1069
|
}
|
|
1009
1070
|
|
|
@@ -1204,7 +1265,7 @@ const KritzelCursorTrail = class {
|
|
|
1204
1265
|
}
|
|
1205
1266
|
}
|
|
1206
1267
|
render() {
|
|
1207
|
-
return (index.h(index.Host, { key: '
|
|
1268
|
+
return (index.h(index.Host, { key: 'c0a9b9ebe1634ba020024efed6446791d6a65a2f' }, this.cursorTrailPoints.length > 1 && (index.h("svg", { key: '50c73784eaffe743823bc6a75524fa4dc98566a8', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
1208
1269
|
position: 'absolute',
|
|
1209
1270
|
left: '0',
|
|
1210
1271
|
top: '0',
|
|
@@ -1308,7 +1369,7 @@ const KritzelDropdown = class {
|
|
|
1308
1369
|
'has-suffix-border': this.hasSuffixContent,
|
|
1309
1370
|
'has-prefix-border': this.hasPrefixContent,
|
|
1310
1371
|
};
|
|
1311
|
-
return (index.h(index.Host, { key: '
|
|
1372
|
+
return (index.h(index.Host, { key: '32c5f5a4f807c1e316c91b795c005b8d30ce6189' }, index.h("div", { key: 'b1cbeff18e688da4a2f7472be290b9527a619f07', class: "dropdown-wrapper" }, index.h("slot", { key: 'b3bbb7e21c6f5620cab41aa4b1c7206b6c75fd86', name: "prefix", ref: el => this.prefixSlotElement = el, onSlotchange: this.evaluatePrefixContent }), index.h("select", { key: '8b2dcdc125bee59cf29fce7c980b755e78d5816e', class: selectClasses, style: Object.assign(Object.assign({}, this.selectStyles), { width: this.width }), onInput: this.handleSelectChange }, this.options.map(option => (index.h("option", { value: option.value, style: option.style, selected: option.value === this.internalValue }, option.label)))), index.h("slot", { key: '8d83f0dea41ac959bf2392948efef33bb70d0154', name: "suffix", ref: el => this.suffixSlotElement = el, onSlotchange: this.evaluateSuffixContent }))));
|
|
1312
1373
|
}
|
|
1313
1374
|
static get watchers() { return {
|
|
1314
1375
|
"value": ["externalValueChanged"],
|
|
@@ -1461,16 +1522,23 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
1461
1522
|
}
|
|
1462
1523
|
|
|
1463
1524
|
class KritzelImage extends KritzelBaseObject {
|
|
1464
|
-
constructor(
|
|
1465
|
-
super(
|
|
1525
|
+
constructor() {
|
|
1526
|
+
super(...arguments);
|
|
1466
1527
|
this.__class__ = 'KritzelImage';
|
|
1467
1528
|
this.src = '';
|
|
1468
1529
|
this.debugInfoVisible = true;
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1530
|
+
}
|
|
1531
|
+
static create(store) {
|
|
1532
|
+
const object = new KritzelImage();
|
|
1533
|
+
object._store = store;
|
|
1534
|
+
object.id = object.generateId();
|
|
1535
|
+
object.x = 0;
|
|
1536
|
+
object.y = 0;
|
|
1537
|
+
object.translateX = 0;
|
|
1538
|
+
object.translateY = 0;
|
|
1539
|
+
object.scale = object._store.state.scale;
|
|
1540
|
+
object.zIndex = store.currentZIndex;
|
|
1541
|
+
return object;
|
|
1474
1542
|
}
|
|
1475
1543
|
resize(x, y, width, height) {
|
|
1476
1544
|
if (width <= 1 || height <= 1) {
|
|
@@ -1935,17 +2003,23 @@ class KritzelGeometryHelper {
|
|
|
1935
2003
|
}
|
|
1936
2004
|
|
|
1937
2005
|
class KrtizelSelectionBox extends KritzelBaseObject {
|
|
1938
|
-
constructor(
|
|
1939
|
-
super(
|
|
2006
|
+
constructor() {
|
|
2007
|
+
super(...arguments);
|
|
1940
2008
|
this.__class__ = 'KrtizelSelectionBox';
|
|
1941
2009
|
this.objects = [];
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2010
|
+
}
|
|
2011
|
+
static create(store) {
|
|
2012
|
+
const object = new KrtizelSelectionBox();
|
|
2013
|
+
object._store = store;
|
|
2014
|
+
object.id = object.generateId();
|
|
2015
|
+
object.scale = store.state.scale;
|
|
2016
|
+
object.zIndex = 99999;
|
|
2017
|
+
object.backgroundColor = 'var(--kritzel-selection-box-background-color, rgba(14, 17, 17, 0.2))';
|
|
2018
|
+
object.borderColor = 'var(--kritzel-selection-box-border-color, rgba(14, 17, 17, 0.5))';
|
|
2019
|
+
object.borderWidth = 2;
|
|
2020
|
+
object.height = 0;
|
|
2021
|
+
object.width = 0;
|
|
2022
|
+
return object;
|
|
1949
2023
|
}
|
|
1950
2024
|
}
|
|
1951
2025
|
|
|
@@ -2047,7 +2121,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2047
2121
|
let clientX, clientY;
|
|
2048
2122
|
clientX = event.clientX - this._store.offsetX;
|
|
2049
2123
|
clientY = event.clientY - this._store.offsetY;
|
|
2050
|
-
const selectionBox =
|
|
2124
|
+
const selectionBox = KrtizelSelectionBox.create(this._store);
|
|
2051
2125
|
this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
2052
2126
|
this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
2053
2127
|
selectionBox.translateX = this.startX;
|
|
@@ -2068,7 +2142,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2068
2142
|
clientY = Math.round(firstTouch.clientY - this._store.offsetY);
|
|
2069
2143
|
this.touchStartX = clientX;
|
|
2070
2144
|
this.touchStartY = clientY;
|
|
2071
|
-
const selectionBox =
|
|
2145
|
+
const selectionBox = KrtizelSelectionBox.create(this._store);
|
|
2072
2146
|
this.startX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
2073
2147
|
this.startY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
2074
2148
|
selectionBox.translateX = this.startX;
|
|
@@ -2130,7 +2204,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2130
2204
|
return;
|
|
2131
2205
|
}
|
|
2132
2206
|
selectedObjects.forEach(o => (o.selected = false));
|
|
2133
|
-
this._store.state.selectionGroup =
|
|
2207
|
+
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
2134
2208
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
2135
2209
|
this._store.state.selectionGroup.selected = true;
|
|
2136
2210
|
this._store.state.selectionGroup.rotation = this._store.state.selectionGroup.objects[0].rotation;
|
|
@@ -2141,7 +2215,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
|
|
|
2141
2215
|
if (selectedObjects.length === 0) {
|
|
2142
2216
|
return;
|
|
2143
2217
|
}
|
|
2144
|
-
this._store.state.selectionGroup =
|
|
2218
|
+
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
2145
2219
|
selectedObjects.forEach(o => {
|
|
2146
2220
|
o.selected = false;
|
|
2147
2221
|
this._store.state.selectionGroup.addOrRemove(o);
|
|
@@ -2281,7 +2355,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2281
2355
|
return object;
|
|
2282
2356
|
}
|
|
2283
2357
|
else {
|
|
2284
|
-
const group =
|
|
2358
|
+
const group = KritzelSelectionGroup.create(this._store);
|
|
2285
2359
|
group.translateX = 0;
|
|
2286
2360
|
group.translateY = 0;
|
|
2287
2361
|
group.addOrRemove(object);
|
|
@@ -2323,16 +2397,16 @@ class KritzelReviver {
|
|
|
2323
2397
|
let revivedObj;
|
|
2324
2398
|
switch (obj.__class__) {
|
|
2325
2399
|
case 'KritzelPath':
|
|
2326
|
-
revivedObj =
|
|
2400
|
+
revivedObj = KritzelPath.create(this._store).revive(obj);
|
|
2327
2401
|
break;
|
|
2328
2402
|
case 'KritzelText':
|
|
2329
|
-
revivedObj =
|
|
2403
|
+
revivedObj = KritzelText.create(this._store, obj.fontSize, obj.fontFamily).revive(obj);
|
|
2330
2404
|
break;
|
|
2331
2405
|
case 'KritzelImage':
|
|
2332
|
-
revivedObj =
|
|
2406
|
+
revivedObj = KritzelImage.create(this._store).revive(obj);
|
|
2333
2407
|
break;
|
|
2334
2408
|
case 'KritzelSelectionGroup':
|
|
2335
|
-
revivedObj =
|
|
2409
|
+
revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
|
|
2336
2410
|
break;
|
|
2337
2411
|
case 'KritzelBrushTool':
|
|
2338
2412
|
revivedObj = new KritzelBrushTool(this._store);
|
|
@@ -2367,17 +2441,23 @@ class KritzelReviver {
|
|
|
2367
2441
|
}
|
|
2368
2442
|
|
|
2369
2443
|
class KritzelSelectionGroup extends KritzelBaseObject {
|
|
2370
|
-
constructor(
|
|
2371
|
-
super(
|
|
2444
|
+
constructor() {
|
|
2445
|
+
super(...arguments);
|
|
2372
2446
|
this.__class__ = 'KritzelSelectionGroup';
|
|
2373
2447
|
this.objects = [];
|
|
2374
2448
|
this.unchangedObjects = [];
|
|
2375
|
-
this.scale = this._store.state.scale;
|
|
2376
|
-
this.zIndex = 99999;
|
|
2377
2449
|
}
|
|
2378
2450
|
get length() {
|
|
2379
2451
|
return this.objects.length;
|
|
2380
2452
|
}
|
|
2453
|
+
static create(store) {
|
|
2454
|
+
const object = new KritzelSelectionGroup();
|
|
2455
|
+
object._store = store;
|
|
2456
|
+
object.id = object.generateId();
|
|
2457
|
+
object.scale = store.state.scale;
|
|
2458
|
+
object.zIndex = 99999;
|
|
2459
|
+
return object;
|
|
2460
|
+
}
|
|
2381
2461
|
addOrRemove(object) {
|
|
2382
2462
|
const index = this.objects.findIndex(obj => obj.id === object.id);
|
|
2383
2463
|
if (index === -1) {
|
|
@@ -2462,7 +2542,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2462
2542
|
});
|
|
2463
2543
|
}
|
|
2464
2544
|
copy() {
|
|
2465
|
-
const selectionGroup =
|
|
2545
|
+
const selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
2466
2546
|
let currentZIndex = this._store.currentZIndex;
|
|
2467
2547
|
this.objects.forEach(obj => {
|
|
2468
2548
|
const copiedObject = obj.copy();
|
|
@@ -2601,7 +2681,7 @@ class KritzelImageTool extends KritzelBaseTool {
|
|
|
2601
2681
|
return { scaledWidth, scaledHeight };
|
|
2602
2682
|
}
|
|
2603
2683
|
createKritzelImage(img, width, height) {
|
|
2604
|
-
const image =
|
|
2684
|
+
const image = KritzelImage.create(this._store);
|
|
2605
2685
|
image.src = img.src;
|
|
2606
2686
|
image.width = width;
|
|
2607
2687
|
image.height = height;
|
|
@@ -2610,7 +2690,7 @@ class KritzelImageTool extends KritzelBaseTool {
|
|
|
2610
2690
|
return image;
|
|
2611
2691
|
}
|
|
2612
2692
|
addImageToStore(image) {
|
|
2613
|
-
const selectionGroup =
|
|
2693
|
+
const selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
2614
2694
|
selectionGroup.addOrRemove(image);
|
|
2615
2695
|
selectionGroup.selected = true;
|
|
2616
2696
|
const addImageCommand = new AddObjectCommand(this._store, this, image);
|
|
@@ -2780,7 +2860,7 @@ const KritzelEditor = class {
|
|
|
2780
2860
|
}
|
|
2781
2861
|
}
|
|
2782
2862
|
render() {
|
|
2783
|
-
return (index.h(index.Host, { key: '
|
|
2863
|
+
return (index.h(index.Host, { key: 'f86e43f5b908d682ba2e20e55466dcdf9f128140' }, index.h("kritzel-engine", { key: '11d72009fd277ea4379b596d57aa2a1b19b9d6bd', ref: el => (this.engineRef = el) }), index.h("kritzel-controls", { key: '4a575354c9bf117b12db7deaafaffcdcb9461bc6', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2784
2864
|
}
|
|
2785
2865
|
get host() { return index.getElement(this); }
|
|
2786
2866
|
};
|
|
@@ -3322,9 +3402,6 @@ class KritzelStore {
|
|
|
3322
3402
|
}
|
|
3323
3403
|
}
|
|
3324
3404
|
}
|
|
3325
|
-
clearSelection() {
|
|
3326
|
-
this.history.executeCommand(new RemoveSelectionGroupCommand(this, this.state.selectionGroup));
|
|
3327
|
-
}
|
|
3328
3405
|
delete() {
|
|
3329
3406
|
if (!this.state.selectionGroup) {
|
|
3330
3407
|
return;
|
|
@@ -3401,7 +3478,23 @@ class KritzelStore {
|
|
|
3401
3478
|
});
|
|
3402
3479
|
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
3403
3480
|
}
|
|
3404
|
-
|
|
3481
|
+
selectObjects(objects) {
|
|
3482
|
+
if (objects.length === 0) {
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
3486
|
+
objects.forEach(obj => {
|
|
3487
|
+
obj.selected = false;
|
|
3488
|
+
selectionGroup.addOrRemove(obj);
|
|
3489
|
+
});
|
|
3490
|
+
selectionGroup.selected = true;
|
|
3491
|
+
this.state.selectionGroup = selectionGroup;
|
|
3492
|
+
if (objects.length === 1) {
|
|
3493
|
+
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
3494
|
+
}
|
|
3495
|
+
this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
|
|
3496
|
+
}
|
|
3497
|
+
selectAllObjectsInViewport() {
|
|
3405
3498
|
const objectsInViewport = this._state.objectsOctree
|
|
3406
3499
|
.query({
|
|
3407
3500
|
x: -this._state.translateX / this._state.scale,
|
|
@@ -3413,17 +3506,29 @@ class KritzelStore {
|
|
|
3413
3506
|
})
|
|
3414
3507
|
.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KrtizelSelectionBox) && !(o instanceof KritzelContextMenu));
|
|
3415
3508
|
if (objectsInViewport.length > 0) {
|
|
3416
|
-
const selectionGroup =
|
|
3509
|
+
const selectionGroup = KritzelSelectionGroup.create(this);
|
|
3417
3510
|
objectsInViewport.forEach(obj => {
|
|
3418
3511
|
obj.selected = false;
|
|
3419
3512
|
selectionGroup.addOrRemove(obj);
|
|
3420
3513
|
});
|
|
3421
3514
|
selectionGroup.selected = true;
|
|
3422
3515
|
this.state.isSelecting = false;
|
|
3516
|
+
if (objectsInViewport.length === 1) {
|
|
3517
|
+
selectionGroup.rotation = selectionGroup.objects[0].rotation;
|
|
3518
|
+
}
|
|
3423
3519
|
this.history.executeCommand(new AddSelectionGroupCommand(this, this, selectionGroup));
|
|
3424
3520
|
this.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
3425
3521
|
}
|
|
3426
3522
|
}
|
|
3523
|
+
clearSelection() {
|
|
3524
|
+
const command = new RemoveSelectionGroupCommand(this, this.state.selectionGroup);
|
|
3525
|
+
this.history.executeCommand(command);
|
|
3526
|
+
this.state.selectionGroup = null;
|
|
3527
|
+
this.state.selectionBox = null;
|
|
3528
|
+
this.state.isSelecting = false;
|
|
3529
|
+
this.state.isResizeHandleSelected = false;
|
|
3530
|
+
this.state.isRotationHandleSelected = false;
|
|
3531
|
+
}
|
|
3427
3532
|
resetActiveText() {
|
|
3428
3533
|
if (this.state.activeText && this.state.activeText.value === ' ') {
|
|
3429
3534
|
this.deleteObject(this.state.activeText.id, false);
|
|
@@ -3458,15 +3563,6 @@ class KritzelStore {
|
|
|
3458
3563
|
}
|
|
3459
3564
|
return null;
|
|
3460
3565
|
}
|
|
3461
|
-
resetSelection() {
|
|
3462
|
-
this.state.selectionGroup = null;
|
|
3463
|
-
this.state.selectionBox = null;
|
|
3464
|
-
this.state.isSelecting = false;
|
|
3465
|
-
this.state.isResizeHandleSelected = false;
|
|
3466
|
-
this.state.isRotationHandleSelected = false;
|
|
3467
|
-
this._state.objectsOctree.remove(obj => obj instanceof KritzelSelectionGroup);
|
|
3468
|
-
this.rerender();
|
|
3469
|
-
}
|
|
3470
3566
|
}
|
|
3471
3567
|
|
|
3472
3568
|
class KritzelKeyHandler extends KritzelBaseHandler {
|
|
@@ -3547,14 +3643,6 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
3547
3643
|
}
|
|
3548
3644
|
}
|
|
3549
3645
|
|
|
3550
|
-
class KritzelKeyboardHelper {
|
|
3551
|
-
static forceHideKeyboard() {
|
|
3552
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
3553
|
-
document.activeElement.blur();
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
|
|
3558
3646
|
class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
3559
3647
|
constructor(store, globalContextMenuItems, objectContextMenuItems) {
|
|
3560
3648
|
super(store);
|
|
@@ -3606,7 +3694,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
3606
3694
|
}
|
|
3607
3695
|
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
3608
3696
|
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
3609
|
-
this._store.state.selectionGroup =
|
|
3697
|
+
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
3610
3698
|
this._store.state.selectionGroup.addOrRemove(selectedObject);
|
|
3611
3699
|
this._store.state.selectionGroup.selected = true;
|
|
3612
3700
|
this._store.state.selectionGroup.rotation = selectedObject.rotation;
|
|
@@ -3663,7 +3751,7 @@ const KritzelEngine = class {
|
|
|
3663
3751
|
this.paste(x, y);
|
|
3664
3752
|
},
|
|
3665
3753
|
},
|
|
3666
|
-
{ label: 'Select All', icon: 'select-all', action: () => this.
|
|
3754
|
+
{ label: 'Select All', icon: 'select-all', action: () => this.selectAllObjectsInViewport() },
|
|
3667
3755
|
];
|
|
3668
3756
|
this.objectContextMenuItems = [
|
|
3669
3757
|
{ label: 'Copy', icon: 'copy', action: () => this.copy() },
|
|
@@ -3688,7 +3776,7 @@ const KritzelEngine = class {
|
|
|
3688
3776
|
this.keyHandler = new KritzelKeyHandler(this.store);
|
|
3689
3777
|
this.store.onStateChange('activeTool', (activeTool) => {
|
|
3690
3778
|
if (!(activeTool instanceof KritzelSelectionTool)) {
|
|
3691
|
-
this.store.
|
|
3779
|
+
this.store.clearSelection();
|
|
3692
3780
|
}
|
|
3693
3781
|
this.store.state.skipContextMenu = false;
|
|
3694
3782
|
this.activeToolChange.emit(activeTool);
|
|
@@ -3874,9 +3962,6 @@ const KritzelEngine = class {
|
|
|
3874
3962
|
async moveToBottom() {
|
|
3875
3963
|
this.store.moveToBottom();
|
|
3876
3964
|
}
|
|
3877
|
-
async selectAllInViewport() {
|
|
3878
|
-
this.store.selectAllInViewport();
|
|
3879
|
-
}
|
|
3880
3965
|
async undo() {
|
|
3881
3966
|
this.store.history.undo();
|
|
3882
3967
|
}
|
|
@@ -3888,21 +3973,63 @@ const KritzelEngine = class {
|
|
|
3888
3973
|
this.store.state.selectionBox = null;
|
|
3889
3974
|
this.store.state.isSelecting = false;
|
|
3890
3975
|
}
|
|
3976
|
+
async getObjectById(id) {
|
|
3977
|
+
const object = this.store.objects.find(obj => obj.id === id);
|
|
3978
|
+
return object || null;
|
|
3979
|
+
}
|
|
3980
|
+
async addObject(object) {
|
|
3981
|
+
this.store.deselectAllObjects();
|
|
3982
|
+
object.id = object.generateId();
|
|
3983
|
+
object._store = this.store;
|
|
3984
|
+
object.zIndex = this.store.currentZIndex;
|
|
3985
|
+
const command = new AddObjectCommand(this.store, this, object);
|
|
3986
|
+
this.store.history.executeCommand(command);
|
|
3987
|
+
return object;
|
|
3988
|
+
}
|
|
3989
|
+
async updateObject(object, updatedProperties) {
|
|
3990
|
+
this.store.deselectAllObjects();
|
|
3991
|
+
const command = new UpdateObjectCommand(this.store, this, object, updatedProperties);
|
|
3992
|
+
this.store.history.executeCommand(command);
|
|
3993
|
+
return object;
|
|
3994
|
+
}
|
|
3995
|
+
async removeObject(object) {
|
|
3996
|
+
this.store.deselectAllObjects();
|
|
3997
|
+
const command = new RemoveObjectCommand(this.store, this, object);
|
|
3998
|
+
this.store.history.executeCommand(command);
|
|
3999
|
+
return object;
|
|
4000
|
+
}
|
|
4001
|
+
async selectObjects(objects) {
|
|
4002
|
+
var _a;
|
|
4003
|
+
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
4004
|
+
this.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
4005
|
+
this.store.deselectAllObjects();
|
|
4006
|
+
this.store.selectObjects(objects);
|
|
4007
|
+
}
|
|
4008
|
+
async selectAllObjectsInViewport() {
|
|
4009
|
+
var _a;
|
|
4010
|
+
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
4011
|
+
this.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
4012
|
+
this.store.deselectAllObjects();
|
|
4013
|
+
this.store.selectAllObjectsInViewport();
|
|
4014
|
+
}
|
|
4015
|
+
async clearSelection() {
|
|
4016
|
+
this.store.clearSelection();
|
|
4017
|
+
}
|
|
3891
4018
|
render() {
|
|
3892
4019
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
3893
4020
|
const computedStyle = window.getComputedStyle(this.host);
|
|
3894
4021
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
3895
4022
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
3896
4023
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
3897
|
-
return (index.h(index.Host, { key: '
|
|
3898
|
-
_a.translateX), index.h("div", { key: '
|
|
3899
|
-
_b.translateY), index.h("div", { key: '
|
|
3900
|
-
_c.viewportWidth), index.h("div", { key: '
|
|
3901
|
-
_d.viewportHeight), index.h("div", { key: '
|
|
3902
|
-
_e.scale), index.h("div", { key: '
|
|
3903
|
-
_g.name), index.h("div", { key: '
|
|
3904
|
-
_m.cursorX), index.h("div", { key: '
|
|
3905
|
-
_o.cursorY)), index.h("div", { key: '
|
|
4024
|
+
return (index.h(index.Host, { key: '0c20c50e3ad8ac088902881c35c406ad2f0787d5' }, index.h("div", { key: 'a89d76b5f6a10cbc54c40d034a08b3ceb99be063', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '94345439d02de7d005bb92abb377b7ebeb91fcdb' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
4025
|
+
_a.translateX), index.h("div", { key: '1e2e3ffc6ad760f089f4d02d94dfeb09bb5725cb' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
4026
|
+
_b.translateY), index.h("div", { key: '36d6170934959e19b95326d84b32c9abe2385edc' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
4027
|
+
_c.viewportWidth), index.h("div", { key: '57e5d37af3fd1f6ad24ea89ca525a6f0bc8e014b' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
4028
|
+
_d.viewportHeight), index.h("div", { key: '8281e788e350db75bbf1fe12dd8c17b91b429135' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '9f42aad27d0a266cbc720d1e13292bea5be84770' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
4029
|
+
_e.scale), index.h("div", { key: '76848c1a0eb2379ee0d0314523a540dbeb3d0697' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
4030
|
+
_g.name), index.h("div", { key: '77f8ff0b660227f7b25c12b74d70946bc1f66e78' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: '229e94fee90a847a853419ae61bc131221313fc6' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: 'f31784916ab54f9a5eda02cffebe55a1f9aaa51f' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '4611a6dd48f1033d42fc3b7813634cbc16bf9b3b' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: '14388f4b5cca60d8a2d8d474f941b53a78ad327d' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '2f3dcd488855413e392f56718af640e369d99fae' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '2cd0e44a1d13eaf5d3a942f75a727a074bf37622' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '99d51cf25e02c9d06865bf1f847c704ad8a32110' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '87ab9908a318b238ad1fb00e91dba9c485038443' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: '20f291bf45ba06b4107002e288b93f8f61ef9520' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '52244f4f0d368e7bc183eed4c65abe536d134f44' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '641edd47e7bccc7514ed6aeac3ecbead95568dde' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
4031
|
+
_m.cursorX), index.h("div", { key: 'bf0826a9cbc800ca0f13d4de4da7dbb21241498f' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
4032
|
+
_o.cursorY)), index.h("div", { key: '5659cb254f57b79ca8e33ab11a8087d5ca5088dc', class: "origin", style: {
|
|
3906
4033
|
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})`,
|
|
3907
4034
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
3908
4035
|
_t.map(object => {
|
|
@@ -3999,7 +4126,7 @@ const KritzelEngine = class {
|
|
|
3999
4126
|
fill: 'transparent',
|
|
4000
4127
|
cursor: 'grab',
|
|
4001
4128
|
}, visibility: object.selected && !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.debugInfoVisible ? '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)))))));
|
|
4002
|
-
}), index.h("svg", { key: '
|
|
4129
|
+
}), index.h("svg", { key: '05a35ebb17312d00a4065dc6dc76f3a93a72eff4', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
4003
4130
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
4004
4131
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
4005
4132
|
left: '0',
|
|
@@ -4009,12 +4136,12 @@ const KritzelEngine = class {
|
|
|
4009
4136
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
4010
4137
|
transformOrigin: 'top left',
|
|
4011
4138
|
overflow: 'visible',
|
|
4012
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '
|
|
4139
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: 'cb232e2697ce6ede2e4d9ed2e1b433ccde3961b5', 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: 'e41b88a78bbd25f692fbdba88fda80993055a078', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
4013
4140
|
position: 'fixed',
|
|
4014
4141
|
left: `${this.store.state.contextMenuX}px`,
|
|
4015
4142
|
top: `${this.store.state.contextMenuY}px`,
|
|
4016
4143
|
zIndex: '10000',
|
|
4017
|
-
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '
|
|
4144
|
+
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '1d96c0d7fa94ddcf5820fd76fbaf69c54b1face2' })));
|
|
4018
4145
|
}
|
|
4019
4146
|
get host() { return index.getElement(this); }
|
|
4020
4147
|
};
|
|
@@ -4030,7 +4157,7 @@ const KritzelFont = class {
|
|
|
4030
4157
|
this.color = '#000000';
|
|
4031
4158
|
}
|
|
4032
4159
|
render() {
|
|
4033
|
-
return (index.h(index.Host, { key: '
|
|
4160
|
+
return (index.h(index.Host, { key: 'd0378237899c5641ae4354f3bffb14e3f8bafb59' }, index.h("div", { key: '1475a6ae39ffc97eb780b30c85015c22cecafa6e', class: "font-preview", style: {
|
|
4034
4161
|
fontFamily: this.fontFamily,
|
|
4035
4162
|
fontSize: `${this.size}px`,
|
|
4036
4163
|
color: this.color
|
|
@@ -4075,7 +4202,7 @@ const KritzelFontFamily = class {
|
|
|
4075
4202
|
label: option.label,
|
|
4076
4203
|
style: { fontFamily: option.value },
|
|
4077
4204
|
}));
|
|
4078
|
-
return (index.h(index.Host, { key: '
|
|
4205
|
+
return (index.h(index.Host, { key: 'f420ff18156d54bfc475148a7d9aae0f1441408c' }, index.h("kritzel-dropdown", { key: '6b54fb8265a0eb59a6a681c6a2b7a95fb222671c', options: dropdownOptions, value: this.selectedFontFamily, onValueChanged: this.handleDropdownValueChange, selectStyles: { fontFamily: this.selectedFontFamily } }, index.h("button", { key: 'b853c75a425c7baafa7a8e749c90c0b08884375c', class: "font-style-button", slot: "suffix" }, "B"), index.h("button", { key: '68dea850dd1d1f38db727d8be0eec3481890c571', class: "font-style-button italic-text", slot: "suffix" }, "I"))));
|
|
4079
4206
|
}
|
|
4080
4207
|
};
|
|
4081
4208
|
KritzelFontFamily.style = kritzelFontFamilyCss;
|
|
@@ -4095,7 +4222,7 @@ const KritzelFontSize = class {
|
|
|
4095
4222
|
this.sizeChange.emit(size);
|
|
4096
4223
|
}
|
|
4097
4224
|
render() {
|
|
4098
|
-
return (index.h(index.Host, { key: '
|
|
4225
|
+
return (index.h(index.Host, { key: '1c09a403f1e8278d30b2675c3a6e17e12ec79afa' }, this.sizes.map(size => (index.h("div", { class: {
|
|
4099
4226
|
'size-container': true,
|
|
4100
4227
|
'selected': this.selectedSize === size,
|
|
4101
4228
|
}, onClick: () => this.handleSizeClick(size) }, index.h("kritzel-font", { fontFamily: this.fontFamily, size: size }))))));
|
|
@@ -4188,23 +4315,23 @@ const KritzelTooltip = class {
|
|
|
4188
4315
|
}
|
|
4189
4316
|
}
|
|
4190
4317
|
render() {
|
|
4191
|
-
return (index.h(index.Host, { key: '
|
|
4318
|
+
return (index.h(index.Host, { key: '3161826337f6957d2e568f52cfe3f57d705af0ed', style: {
|
|
4192
4319
|
position: 'fixed',
|
|
4193
4320
|
zIndex: '9999',
|
|
4194
4321
|
transition: 'opacity 0.3s ease-in-out, transform 0.3s ease-in-out',
|
|
4195
4322
|
visibility: this.isVisible ? 'visible' : 'hidden',
|
|
4196
4323
|
left: !this.isMobileView ? `${this.positionX}px` : '50%',
|
|
4197
4324
|
marginBottom: `${this.offsetY + this.arrowSize}px`,
|
|
4198
|
-
} }, index.h("div", { key: '
|
|
4325
|
+
} }, index.h("div", { key: '12fc4bc05b7be756102ce3779c9be1d51f3fe13b', class: "tooltip-content", onClick: event => event.stopPropagation() }, index.h("slot", { key: '90f645f8f7cec371aaeda7207a9fb420b02b2ae4' }), index.h("div", { key: '73380e2c6df22bc4a97479a52315e7b34d069fa1', class: "tooltip-arrow-wrapper", style: {
|
|
4199
4326
|
position: 'fixed',
|
|
4200
4327
|
left: this.arrowOffset,
|
|
4201
4328
|
bottom: `-${this.arrowSize * 2}px`,
|
|
4202
|
-
} }, index.h("div", { key: '
|
|
4329
|
+
} }, index.h("div", { key: '2e13cb01a3282e161d3212f4970a93b20ca1a0fe', class: "tooltip-arrow", style: {
|
|
4203
4330
|
borderLeft: `${this.arrowSize}px solid transparent`,
|
|
4204
4331
|
borderRight: `${this.arrowSize}px solid transparent`,
|
|
4205
4332
|
borderTop: `${this.arrowSize}px solid var(--kritzel-controls-tooltip-background-color, #ffffff)`,
|
|
4206
4333
|
filter: 'drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2))',
|
|
4207
|
-
} }), index.h("div", { key: '
|
|
4334
|
+
} }), index.h("div", { key: '30ddbd00b928c0c734656d6309eaefbae5baf264', class: "tooltip-arrow-rect", style: {
|
|
4208
4335
|
position: 'relative',
|
|
4209
4336
|
width: `${this.arrowSize * 2}px`,
|
|
4210
4337
|
height: `${this.arrowSize}px`,
|