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
|
@@ -246,6 +246,15 @@ class KritzelEventHelper {
|
|
|
246
246
|
static detectDoubleTap() {
|
|
247
247
|
const currentTime = Date.now();
|
|
248
248
|
const tapLength = currentTime - KritzelEventHelper.lastTapTimestamp;
|
|
249
|
+
if (KritzelEventHelper.twoFingerTouchDetected) {
|
|
250
|
+
KritzelEventHelper.lastTapTimestamp = 0;
|
|
251
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
252
|
+
if (KritzelEventHelper.tapTimeoutId) {
|
|
253
|
+
clearTimeout(KritzelEventHelper.tapTimeoutId);
|
|
254
|
+
KritzelEventHelper.tapTimeoutId = null;
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
249
258
|
if (KritzelEventHelper.tapTimeoutId) {
|
|
250
259
|
clearTimeout(KritzelEventHelper.tapTimeoutId);
|
|
251
260
|
KritzelEventHelper.tapTimeoutId = null;
|
|
@@ -258,14 +267,19 @@ class KritzelEventHelper {
|
|
|
258
267
|
KritzelEventHelper.lastTapTimestamp = currentTime;
|
|
259
268
|
KritzelEventHelper.tapTimeoutId = setTimeout(() => {
|
|
260
269
|
KritzelEventHelper.tapTimeoutId = null;
|
|
270
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
261
271
|
}, KritzelEventHelper.doubleTapTimeout);
|
|
262
272
|
return false;
|
|
263
273
|
}
|
|
264
274
|
}
|
|
275
|
+
static notifyTwoFingerTouch() {
|
|
276
|
+
KritzelEventHelper.twoFingerTouchDetected = true;
|
|
277
|
+
}
|
|
265
278
|
}
|
|
266
279
|
KritzelEventHelper.lastTapTimestamp = 0;
|
|
267
280
|
KritzelEventHelper.tapTimeoutId = null;
|
|
268
281
|
KritzelEventHelper.doubleTapTimeout = 300;
|
|
282
|
+
KritzelEventHelper.twoFingerTouchDetected = false;
|
|
269
283
|
|
|
270
284
|
class KritzelBaseCommand {
|
|
271
285
|
constructor(store, initiator) {
|
|
@@ -918,24 +932,6 @@ class KritzelText extends KritzelBaseObject {
|
|
|
918
932
|
}
|
|
919
933
|
}
|
|
920
934
|
|
|
921
|
-
class KritzelToolRegistry {
|
|
922
|
-
static registerTool(toolName, constructor, store) {
|
|
923
|
-
const toolInstance = new constructor(store);
|
|
924
|
-
toolInstance.name = toolName;
|
|
925
|
-
this.registry[toolName] = toolInstance;
|
|
926
|
-
return toolInstance;
|
|
927
|
-
}
|
|
928
|
-
static getTool(toolName) {
|
|
929
|
-
const toolInstance = this.registry[toolName];
|
|
930
|
-
if (!toolInstance) {
|
|
931
|
-
console.warn(`Unknown tool: ${toolName}`);
|
|
932
|
-
return null;
|
|
933
|
-
}
|
|
934
|
-
return toolInstance;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
KritzelToolRegistry.registry = {};
|
|
938
|
-
|
|
939
935
|
class KritzelKeyboardHelper {
|
|
940
936
|
static forceHideKeyboard() {
|
|
941
937
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -967,6 +963,24 @@ class KritzelKeyboardHelper {
|
|
|
967
963
|
}
|
|
968
964
|
}
|
|
969
965
|
|
|
966
|
+
class KritzelToolRegistry {
|
|
967
|
+
static registerTool(toolName, constructor, store) {
|
|
968
|
+
const toolInstance = new constructor(store);
|
|
969
|
+
toolInstance.name = toolName;
|
|
970
|
+
this.registry[toolName] = toolInstance;
|
|
971
|
+
return toolInstance;
|
|
972
|
+
}
|
|
973
|
+
static getTool(toolName) {
|
|
974
|
+
const toolInstance = this.registry[toolName];
|
|
975
|
+
if (!toolInstance) {
|
|
976
|
+
console.warn(`Unknown tool: ${toolName}`);
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
return toolInstance;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
KritzelToolRegistry.registry = {};
|
|
983
|
+
|
|
970
984
|
class KritzelTextTool extends KritzelBaseTool {
|
|
971
985
|
constructor(store) {
|
|
972
986
|
super(store);
|
|
@@ -2860,7 +2874,7 @@ const KritzelEditor = class {
|
|
|
2860
2874
|
}
|
|
2861
2875
|
}
|
|
2862
2876
|
render() {
|
|
2863
|
-
return (index.h(index.Host, { key: '
|
|
2877
|
+
return (index.h(index.Host, { key: '74206218105a7675872539955729e9329573b83b' }, index.h("kritzel-engine", { key: '596be73738bdfcbd04472a3ffef2e7ace393c94e', ref: el => (this.engineRef = el) }), index.h("kritzel-controls", { key: '95701130a74395c27c07c56eb74294074261a8be', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2864
2878
|
}
|
|
2865
2879
|
get host() { return index.getElement(this); }
|
|
2866
2880
|
};
|
|
@@ -3271,7 +3285,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
3271
3285
|
}
|
|
3272
3286
|
}
|
|
3273
3287
|
|
|
3274
|
-
const
|
|
3288
|
+
const DEFAULT_ENGINE_STATE = {
|
|
3275
3289
|
activeTool: null,
|
|
3276
3290
|
activeText: null,
|
|
3277
3291
|
currentPath: null,
|
|
@@ -3323,6 +3337,7 @@ const initialState = {
|
|
|
3323
3337
|
longTouchTimeout: null,
|
|
3324
3338
|
longTouchDelay: 300,
|
|
3325
3339
|
};
|
|
3340
|
+
|
|
3326
3341
|
class KritzelStore {
|
|
3327
3342
|
get history() {
|
|
3328
3343
|
return this._history;
|
|
@@ -3348,7 +3363,7 @@ class KritzelStore {
|
|
|
3348
3363
|
constructor(kritzelEngine) {
|
|
3349
3364
|
this._listeners = new Map();
|
|
3350
3365
|
this.objects = [];
|
|
3351
|
-
this._state =
|
|
3366
|
+
this._state = DEFAULT_ENGINE_STATE;
|
|
3352
3367
|
this._kritzelEngine = kritzelEngine;
|
|
3353
3368
|
this._history = new KritzelHistory(this);
|
|
3354
3369
|
this._state.objectsOctree = new KritzelOctree({
|
|
@@ -3846,6 +3861,9 @@ const KritzelEngine = class {
|
|
|
3846
3861
|
if (this.store.state.isEnabled === false) {
|
|
3847
3862
|
return;
|
|
3848
3863
|
}
|
|
3864
|
+
if (ev.touches.length === 2) {
|
|
3865
|
+
KritzelEventHelper.notifyTwoFingerTouch();
|
|
3866
|
+
}
|
|
3849
3867
|
if (KritzelEventHelper.detectDoubleTap()) {
|
|
3850
3868
|
const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
|
|
3851
3869
|
this.host.dispatchEvent(doubleTapEvent);
|
|
@@ -4021,20 +4039,20 @@ const KritzelEngine = class {
|
|
|
4021
4039
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
4022
4040
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
4023
4041
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
4024
|
-
return (index.h(index.Host, { key: '
|
|
4025
|
-
_a.translateX), index.h("div", { key: '
|
|
4026
|
-
_b.translateY), index.h("div", { key: '
|
|
4027
|
-
_c.viewportWidth), index.h("div", { key: '
|
|
4028
|
-
_d.viewportHeight), index.h("div", { key: '
|
|
4029
|
-
_e.scale), index.h("div", { key: '
|
|
4030
|
-
_g.name), index.h("div", { key: '
|
|
4031
|
-
_m.cursorX), index.h("div", { key: '
|
|
4032
|
-
_o.cursorY)), index.h("div", { key: '
|
|
4042
|
+
return (index.h(index.Host, { key: '7592f0cc9b3c4f5c2c68b8a69151e57e254e1bcd' }, index.h("div", { key: '83d550a8b257c6c30915b4125633410b935df1c7', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: 'aaebf84d2344cf117d7e2b221f4675abfa3e2423' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
4043
|
+
_a.translateX), index.h("div", { key: '0dff156e5b57abe1919af5a14da374ee86f62821' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
4044
|
+
_b.translateY), index.h("div", { key: 'bb7fe1f8442c70e1bd7655ea222f37ed55c0cf8f' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
4045
|
+
_c.viewportWidth), index.h("div", { key: 'c0399a368afa2186ba45e7be6fa69495f77912b2' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
4046
|
+
_d.viewportHeight), index.h("div", { key: '2506ae215413710417a9b494dfeaa06a95381e1e' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '858e6cff62c24d97f36560ca57c59eb90d7fe253' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
4047
|
+
_e.scale), index.h("div", { key: 'b7dd1926a2a374b34ccb0f1af2f5100bb256a323' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
4048
|
+
_g.name), index.h("div", { key: 'e75a98de366a36b9e4a478119db1754df85ce149' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'c78c09fbb6efc97be8cde8bc55d2c9ca724d913e' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '7864d38c808ff8fa01fc24d150ac03ec56eb2111' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '8ce8b3522065ad221d0cac69366199fa78e6c985' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: 'f2dc96d374c66798ab0ec6f4759a851448375def' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '7a8642ee44c2c6d6419da80c2a27b0370c51c67d' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '9f819435c8ad8c2f836edca397918bd98e2ed34d' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '252201d35275563594bfe13ae19ded7289d4860a' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '45056c11f0733c433f9a91008d021702df660063' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'a6fedfe47aac88ffa4df90da060a28d83f8bf1cf' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '30b311e5dee2174ba0baea6e5bc9f1fca1a01fac' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: 'e2d1936e16dd5a268dd1efab8b7e67b567170e9b' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
4049
|
+
_m.cursorX), index.h("div", { key: 'bb1e751d01b31ca727c01537927808daec4425e9' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
4050
|
+
_o.cursorY)), index.h("div", { key: 'a5ccd3e025b425660a1dd9ef523db203fcbde610', class: "origin", style: {
|
|
4033
4051
|
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})`,
|
|
4034
4052
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
4035
4053
|
_t.map(object => {
|
|
4036
4054
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
4037
|
-
return (index.h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left' } }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
|
|
4055
|
+
return (index.h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
|
|
4038
4056
|
height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
|
|
4039
4057
|
width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
|
|
4040
4058
|
left: '0',
|
|
@@ -4044,7 +4062,6 @@ const KritzelEngine = class {
|
|
|
4044
4062
|
transformOrigin: 'center',
|
|
4045
4063
|
opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
|
|
4046
4064
|
pointerEvents: object.markedForRemoval ? 'none' : 'auto',
|
|
4047
|
-
zIndex: object.zIndex.toString(),
|
|
4048
4065
|
} }, index.h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
|
|
4049
4066
|
minHeight: '0',
|
|
4050
4067
|
minWidth: '0',
|
|
@@ -4126,7 +4143,7 @@ const KritzelEngine = class {
|
|
|
4126
4143
|
fill: 'transparent',
|
|
4127
4144
|
cursor: 'grab',
|
|
4128
4145
|
}, 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)))))));
|
|
4129
|
-
}), index.h("svg", { key: '
|
|
4146
|
+
}), index.h("svg", { key: 'c2b10893d4bea0e25c98058e640ad8eef6135a80', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
4130
4147
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
4131
4148
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
4132
4149
|
left: '0',
|
|
@@ -4136,12 +4153,12 @@ const KritzelEngine = class {
|
|
|
4136
4153
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
4137
4154
|
transformOrigin: 'top left',
|
|
4138
4155
|
overflow: 'visible',
|
|
4139
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '
|
|
4156
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.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 && (index.h("kritzel-context-menu", { key: 'c372bd8595656b35d7eed2e38400490e7d71808b', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
4140
4157
|
position: 'fixed',
|
|
4141
4158
|
left: `${this.store.state.contextMenuX}px`,
|
|
4142
4159
|
top: `${this.store.state.contextMenuY}px`,
|
|
4143
4160
|
zIndex: '10000',
|
|
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: '
|
|
4161
|
+
}, 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: 'ce67e9df4714a9585bb1a8db3780baff6faeb66d' })));
|
|
4145
4162
|
}
|
|
4146
4163
|
get host() { return index.getElement(this); }
|
|
4147
4164
|
};
|