kritzel-stencil 0.0.107 → 0.0.108
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 +52 -35
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +1 -1
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
- package/dist/collection/classes/registries/tool.registry.js.map +1 -0
- package/dist/collection/classes/store.class.js +3 -54
- package/dist/collection/classes/store.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 +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +1 -1
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +18 -16
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +53 -0
- package/dist/collection/configs/default-engine-state.js.map +1 -0
- package/dist/collection/helpers/event.helper.js +14 -0
- package/dist/collection/helpers/event.helper.js.map +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +4 -4
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-CesjDLvT.js → p-BNfHRlWL.js} +34 -20
- package/dist/components/p-BNfHRlWL.js.map +1 -0
- package/dist/components/{p-DTcfnx4-.js → p-Box62paJ.js} +3 -3
- package/dist/components/{p-DTcfnx4-.js.map → p-Box62paJ.js.map} +1 -1
- package/dist/components/p-CZkSABuJ.js.map +1 -1
- package/dist/components/{p-_3gCPfqz.js → p-CqJr3YCp.js} +22 -19
- package/dist/components/{p-_3gCPfqz.js.map → p-CqJr3YCp.js.map} +1 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +52 -35
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/stencil/p-3a7d7b58.entry.js +2 -0
- package/dist/stencil/p-3a7d7b58.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/{tool.registry.d.ts → registries/tool.registry.d.ts} +2 -2
- package/dist/types/configs/default-engine-state.d.ts +2 -0
- package/dist/types/helpers/event.helper.d.ts +5 -3
- package/package.json +1 -1
- package/dist/collection/classes/icon-registry.class.js.map +0 -1
- package/dist/collection/classes/tool.registry.js.map +0 -1
- package/dist/components/p-CesjDLvT.js.map +0 -1
- package/dist/stencil/p-e596d004.entry.js +0 -2
- package/dist/stencil/p-e596d004.entry.js.map +0 -1
- /package/dist/collection/classes/{icon-registry.class.js → registries/icon-registry.class.js} +0 -0
- /package/dist/collection/classes/{tool.registry.js → registries/tool.registry.js} +0 -0
- /package/dist/types/classes/{icon-registry.class.d.ts → registries/icon-registry.class.d.ts} +0 -0
|
@@ -244,6 +244,15 @@ class KritzelEventHelper {
|
|
|
244
244
|
static detectDoubleTap() {
|
|
245
245
|
const currentTime = Date.now();
|
|
246
246
|
const tapLength = currentTime - KritzelEventHelper.lastTapTimestamp;
|
|
247
|
+
if (KritzelEventHelper.twoFingerTouchDetected) {
|
|
248
|
+
KritzelEventHelper.lastTapTimestamp = 0;
|
|
249
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
250
|
+
if (KritzelEventHelper.tapTimeoutId) {
|
|
251
|
+
clearTimeout(KritzelEventHelper.tapTimeoutId);
|
|
252
|
+
KritzelEventHelper.tapTimeoutId = null;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
247
256
|
if (KritzelEventHelper.tapTimeoutId) {
|
|
248
257
|
clearTimeout(KritzelEventHelper.tapTimeoutId);
|
|
249
258
|
KritzelEventHelper.tapTimeoutId = null;
|
|
@@ -256,14 +265,19 @@ class KritzelEventHelper {
|
|
|
256
265
|
KritzelEventHelper.lastTapTimestamp = currentTime;
|
|
257
266
|
KritzelEventHelper.tapTimeoutId = setTimeout(() => {
|
|
258
267
|
KritzelEventHelper.tapTimeoutId = null;
|
|
268
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
259
269
|
}, KritzelEventHelper.doubleTapTimeout);
|
|
260
270
|
return false;
|
|
261
271
|
}
|
|
262
272
|
}
|
|
273
|
+
static notifyTwoFingerTouch() {
|
|
274
|
+
KritzelEventHelper.twoFingerTouchDetected = true;
|
|
275
|
+
}
|
|
263
276
|
}
|
|
264
277
|
KritzelEventHelper.lastTapTimestamp = 0;
|
|
265
278
|
KritzelEventHelper.tapTimeoutId = null;
|
|
266
279
|
KritzelEventHelper.doubleTapTimeout = 300;
|
|
280
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
267
281
|
|
|
268
282
|
class KritzelBaseCommand {
|
|
269
283
|
constructor(store, initiator) {
|
|
@@ -916,24 +930,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
916
930
|
}
|
|
917
931
|
}
|
|
918
932
|
|
|
919
|
-
class KritzelToolRegistry {
|
|
920
|
-
static registerTool(toolName, constructor, store) {
|
|
921
|
-
const toolInstance = new constructor(store);
|
|
922
|
-
toolInstance.name = toolName;
|
|
923
|
-
this.registry[toolName] = toolInstance;
|
|
924
|
-
return toolInstance;
|
|
925
|
-
}
|
|
926
|
-
static getTool(toolName) {
|
|
927
|
-
const toolInstance = this.registry[toolName];
|
|
928
|
-
if (!toolInstance) {
|
|
929
|
-
console.warn(`Unknown tool: ${toolName}`);
|
|
930
|
-
return null;
|
|
931
|
-
}
|
|
932
|
-
return toolInstance;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
KritzelToolRegistry.registry = {};
|
|
936
|
-
|
|
937
933
|
class KritzelKeyboardHelper {
|
|
938
934
|
static forceHideKeyboard() {
|
|
939
935
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -965,6 +961,24 @@ class KritzelKeyboardHelper {
|
|
|
965
961
|
}
|
|
966
962
|
}
|
|
967
963
|
|
|
964
|
+
class KritzelToolRegistry {
|
|
965
|
+
static registerTool(toolName, constructor, store) {
|
|
966
|
+
const toolInstance = new constructor(store);
|
|
967
|
+
toolInstance.name = toolName;
|
|
968
|
+
this.registry[toolName] = toolInstance;
|
|
969
|
+
return toolInstance;
|
|
970
|
+
}
|
|
971
|
+
static getTool(toolName) {
|
|
972
|
+
const toolInstance = this.registry[toolName];
|
|
973
|
+
if (!toolInstance) {
|
|
974
|
+
console.warn(`Unknown tool: ${toolName}`);
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
return toolInstance;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
KritzelToolRegistry.registry = {};
|
|
981
|
+
|
|
968
982
|
class KritzelTextTool extends KritzelBaseTool {
|
|
969
983
|
constructor(store) {
|
|
970
984
|
super(store);
|
|
@@ -2858,7 +2872,7 @@ const KritzelEditor = class {
|
|
|
2858
2872
|
}
|
|
2859
2873
|
}
|
|
2860
2874
|
render() {
|
|
2861
|
-
return (h(Host, { key: '
|
|
2875
|
+
return (h(Host, { key: '74206218105a7675872539955729e9329573b83b' }, h("kritzel-engine", { key: '596be73738bdfcbd04472a3ffef2e7ace393c94e', ref: el => (this.engineRef = el) }), h("kritzel-controls", { key: '95701130a74395c27c07c56eb74294074261a8be', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2862
2876
|
}
|
|
2863
2877
|
get host() { return getElement(this); }
|
|
2864
2878
|
};
|
|
@@ -3269,7 +3283,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
3269
3283
|
}
|
|
3270
3284
|
}
|
|
3271
3285
|
|
|
3272
|
-
const
|
|
3286
|
+
const DEFAULT_ENGINE_STATE = {
|
|
3273
3287
|
activeTool: null,
|
|
3274
3288
|
activeText: null,
|
|
3275
3289
|
currentPath: null,
|
|
@@ -3321,6 +3335,7 @@ const initialState = {
|
|
|
3321
3335
|
longTouchTimeout: null,
|
|
3322
3336
|
longTouchDelay: 300,
|
|
3323
3337
|
};
|
|
3338
|
+
|
|
3324
3339
|
class KritzelStore {
|
|
3325
3340
|
get history() {
|
|
3326
3341
|
return this._history;
|
|
@@ -3346,7 +3361,7 @@ class KritzelStore {
|
|
|
3346
3361
|
constructor(kritzelEngine) {
|
|
3347
3362
|
this._listeners = new Map();
|
|
3348
3363
|
this.objects = [];
|
|
3349
|
-
this._state =
|
|
3364
|
+
this._state = DEFAULT_ENGINE_STATE;
|
|
3350
3365
|
this._kritzelEngine = kritzelEngine;
|
|
3351
3366
|
this._history = new KritzelHistory(this);
|
|
3352
3367
|
this._state.objectsOctree = new KritzelOctree({
|
|
@@ -3844,6 +3859,9 @@ const KritzelEngine = class {
|
|
|
3844
3859
|
if (this.store.state.isEnabled === false) {
|
|
3845
3860
|
return;
|
|
3846
3861
|
}
|
|
3862
|
+
if (ev.touches.length === 2) {
|
|
3863
|
+
KritzelEventHelper.notifyTwoFingerTouch();
|
|
3864
|
+
}
|
|
3847
3865
|
if (KritzelEventHelper.detectDoubleTap()) {
|
|
3848
3866
|
const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
|
|
3849
3867
|
this.host.dispatchEvent(doubleTapEvent);
|
|
@@ -4019,20 +4037,20 @@ const KritzelEngine = class {
|
|
|
4019
4037
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
4020
4038
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
4021
4039
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
4022
|
-
return (h(Host, { key: '
|
|
4023
|
-
_a.translateX), h("div", { key: '
|
|
4024
|
-
_b.translateY), h("div", { key: '
|
|
4025
|
-
_c.viewportWidth), h("div", { key: '
|
|
4026
|
-
_d.viewportHeight), h("div", { key: '
|
|
4027
|
-
_e.scale), h("div", { key: '
|
|
4028
|
-
_g.name), h("div", { key: '
|
|
4029
|
-
_m.cursorX), h("div", { key: '
|
|
4030
|
-
_o.cursorY)), h("div", { key: '
|
|
4040
|
+
return (h(Host, { key: '7592f0cc9b3c4f5c2c68b8a69151e57e254e1bcd' }, h("div", { key: '83d550a8b257c6c30915b4125633410b935df1c7', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: 'aaebf84d2344cf117d7e2b221f4675abfa3e2423' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
4041
|
+
_a.translateX), h("div", { key: '0dff156e5b57abe1919af5a14da374ee86f62821' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
4042
|
+
_b.translateY), h("div", { key: 'bb7fe1f8442c70e1bd7655ea222f37ed55c0cf8f' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
4043
|
+
_c.viewportWidth), h("div", { key: 'c0399a368afa2186ba45e7be6fa69495f77912b2' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
4044
|
+
_d.viewportHeight), h("div", { key: '2506ae215413710417a9b494dfeaa06a95381e1e' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '858e6cff62c24d97f36560ca57c59eb90d7fe253' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
4045
|
+
_e.scale), h("div", { key: 'b7dd1926a2a374b34ccb0f1af2f5100bb256a323' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
4046
|
+
_g.name), h("div", { key: 'e75a98de366a36b9e4a478119db1754df85ce149' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: 'c78c09fbb6efc97be8cde8bc55d2c9ca724d913e' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '7864d38c808ff8fa01fc24d150ac03ec56eb2111' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '8ce8b3522065ad221d0cac69366199fa78e6c985' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'f2dc96d374c66798ab0ec6f4759a851448375def' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '7a8642ee44c2c6d6419da80c2a27b0370c51c67d' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '9f819435c8ad8c2f836edca397918bd98e2ed34d' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '252201d35275563594bfe13ae19ded7289d4860a' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '45056c11f0733c433f9a91008d021702df660063' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'a6fedfe47aac88ffa4df90da060a28d83f8bf1cf' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '30b311e5dee2174ba0baea6e5bc9f1fca1a01fac' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'e2d1936e16dd5a268dd1efab8b7e67b567170e9b' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
4047
|
+
_m.cursorX), h("div", { key: 'bb1e751d01b31ca727c01537927808daec4425e9' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
4048
|
+
_o.cursorY)), h("div", { key: 'a5ccd3e025b425660a1dd9ef523db203fcbde610', class: "origin", style: {
|
|
4031
4049
|
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})`,
|
|
4032
4050
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
4033
4051
|
_t.map(object => {
|
|
4034
4052
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
4035
|
-
return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
|
|
4053
|
+
return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
|
|
4036
4054
|
height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
|
|
4037
4055
|
width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
|
|
4038
4056
|
left: '0',
|
|
@@ -4042,7 +4060,6 @@ const KritzelEngine = class {
|
|
|
4042
4060
|
transformOrigin: 'center',
|
|
4043
4061
|
opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
|
|
4044
4062
|
pointerEvents: object.markedForRemoval ? 'none' : 'auto',
|
|
4045
|
-
zIndex: object.zIndex.toString(),
|
|
4046
4063
|
} }, h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
|
|
4047
4064
|
minHeight: '0',
|
|
4048
4065
|
minWidth: '0',
|
|
@@ -4124,7 +4141,7 @@ const KritzelEngine = class {
|
|
|
4124
4141
|
fill: 'transparent',
|
|
4125
4142
|
cursor: 'grab',
|
|
4126
4143
|
}, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
|
|
4127
|
-
}), h("svg", { key: '
|
|
4144
|
+
}), h("svg", { key: 'c2b10893d4bea0e25c98058e640ad8eef6135a80', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
4128
4145
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
4129
4146
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
4130
4147
|
left: '0',
|
|
@@ -4134,12 +4151,12 @@ const KritzelEngine = class {
|
|
|
4134
4151
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
4135
4152
|
transformOrigin: 'top left',
|
|
4136
4153
|
overflow: 'visible',
|
|
4137
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '
|
|
4154
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '84b018b26b93e0f382062ac2e24efbce8bc07e3f', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: 'c372bd8595656b35d7eed2e38400490e7d71808b', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
4138
4155
|
position: 'fixed',
|
|
4139
4156
|
left: `${this.store.state.contextMenuX}px`,
|
|
4140
4157
|
top: `${this.store.state.contextMenuY}px`,
|
|
4141
4158
|
zIndex: '10000',
|
|
4142
|
-
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
4159
|
+
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: 'ce67e9df4714a9585bb1a8db3780baff6faeb66d' })));
|
|
4143
4160
|
}
|
|
4144
4161
|
get host() { return getElement(this); }
|
|
4145
4162
|
};
|