kritzel-stencil 0.0.107 → 0.0.109
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 +858 -820
- 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 +2 -47
- package/dist/collection/classes/handlers/context-menu.handler.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/handlers/move.handler.js +62 -55
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +122 -113
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +74 -66
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +59 -50
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +3 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +11 -1
- package/dist/collection/classes/objects/text.class.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/base-tool.class.js +3 -18
- package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +79 -71
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +1 -1
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +94 -74
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +73 -70
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/classes/viewport.class.js +76 -69
- package/dist/collection/classes/viewport.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
- 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.css +6 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +69 -121
- 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/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.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/devices.helper.js +6 -0
- package/dist/collection/helpers/devices.helper.js.map +1 -0
- package/dist/collection/helpers/event.helper.js +43 -20
- package/dist/collection/helpers/event.helper.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/collection/interfaces/tool.interface.js.map +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +6 -6
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-CesjDLvT.js → p-7Ns73-wN.js} +237 -206
- package/dist/components/p-7Ns73-wN.js.map +1 -0
- package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
- package/dist/components/p-BmAloSfd.js.map +1 -0
- package/dist/components/{p-_3gCPfqz.js → p-BmrZipyu.js} +621 -622
- package/dist/components/p-BmrZipyu.js.map +1 -0
- package/dist/components/p-CZkSABuJ.js.map +1 -1
- package/dist/components/{p-DTcfnx4-.js → p-Ch6TgHX3.js} +18 -8
- package/dist/components/p-Ch6TgHX3.js.map +1 -0
- package/dist/esm/kritzel-brush-style_18.entry.js +858 -820
- 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-c976660c.entry.js +2 -0
- package/dist/stencil/p-c976660c.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
- package/dist/types/classes/handlers/move.handler.d.ts +3 -6
- package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
- package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
- package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
- package/dist/types/classes/objects/base-object.class.d.ts +1 -0
- package/dist/types/classes/objects/text.class.d.ts +1 -0
- package/dist/types/classes/{tool.registry.d.ts → registries/tool.registry.d.ts} +2 -2
- package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
- package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
- package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
- package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
- package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
- package/dist/types/classes/viewport.class.d.ts +3 -6
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
- package/dist/types/components.d.ts +0 -2
- package/dist/types/configs/default-engine-state.d.ts +2 -0
- package/dist/types/helpers/devices.helper.d.ts +3 -0
- package/dist/types/helpers/event.helper.d.ts +2 -4
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
- package/dist/types/interfaces/object.interface.d.ts +1 -0
- package/dist/types/interfaces/tool.interface.d.ts +3 -8
- 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-Cbu5RSmC.js.map +0 -1
- package/dist/components/p-CesjDLvT.js.map +0 -1
- package/dist/components/p-DTcfnx4-.js.map +0 -1
- package/dist/components/p-_3gCPfqz.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
|
@@ -15,29 +15,52 @@ class KritzelEventHelper {
|
|
|
15
15
|
static isMainMouseWheel(event) {
|
|
16
16
|
return Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0 && Number.isInteger(event.deltaY);
|
|
17
17
|
}
|
|
18
|
-
static
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
static isPointerEventOnContextMenu(event) {
|
|
19
|
+
const path = event.composedPath();
|
|
20
|
+
const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
|
|
21
|
+
return !!contextMenu;
|
|
22
|
+
}
|
|
23
|
+
static onLongTouchPress(event, onSuccess, onCancel) {
|
|
24
|
+
if (event.pointerType !== 'touch') {
|
|
25
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
26
|
+
return () => { };
|
|
27
|
+
}
|
|
28
|
+
const longPressTimeout = 400;
|
|
29
|
+
const moveThreshold = 10;
|
|
30
|
+
const startX = event.clientX;
|
|
31
|
+
const startY = event.clientY;
|
|
32
|
+
const target = event.target;
|
|
33
|
+
const timer = setTimeout(() => {
|
|
34
|
+
removeListeners();
|
|
35
|
+
onSuccess(event);
|
|
36
|
+
}, longPressTimeout);
|
|
37
|
+
const cancel = () => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
removeListeners();
|
|
40
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
41
|
+
};
|
|
42
|
+
const onPointerMove = (e) => {
|
|
43
|
+
if (Math.abs(e.clientX - startX) > moveThreshold || Math.abs(e.clientY - startY) > moveThreshold) {
|
|
44
|
+
cancel();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const onPointerUp = () => {
|
|
48
|
+
cancel();
|
|
49
|
+
};
|
|
50
|
+
const onPointerCancel = () => {
|
|
51
|
+
cancel();
|
|
52
|
+
};
|
|
53
|
+
const removeListeners = () => {
|
|
54
|
+
target.removeEventListener('pointermove', onPointerMove);
|
|
55
|
+
target.removeEventListener('pointerup', onPointerUp);
|
|
56
|
+
target.removeEventListener('pointercancel', onPointerCancel);
|
|
57
|
+
};
|
|
58
|
+
target.addEventListener('pointermove', onPointerMove, { passive: true });
|
|
59
|
+
target.addEventListener('pointerup', onPointerUp, { once: true });
|
|
60
|
+
target.addEventListener('pointercancel', onPointerCancel, { once: true });
|
|
61
|
+
return cancel;
|
|
36
62
|
}
|
|
37
63
|
}
|
|
38
|
-
KritzelEventHelper.lastTapTimestamp = 0;
|
|
39
|
-
KritzelEventHelper.tapTimeoutId = null;
|
|
40
|
-
KritzelEventHelper.doubleTapTimeout = 300;
|
|
41
64
|
|
|
42
65
|
class KritzelBaseCommand {
|
|
43
66
|
constructor(store, initiator) {
|
|
@@ -298,6 +321,9 @@ class KritzelBaseObject {
|
|
|
298
321
|
copiedObject.isMounted = false;
|
|
299
322
|
return copiedObject;
|
|
300
323
|
}
|
|
324
|
+
onSelectedClick() {
|
|
325
|
+
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
326
|
+
}
|
|
301
327
|
revive(object) {
|
|
302
328
|
Object.assign(this, object);
|
|
303
329
|
return this;
|
|
@@ -434,28 +460,13 @@ class KritzelBaseTool {
|
|
|
434
460
|
onDeactivate() {
|
|
435
461
|
// default implementation
|
|
436
462
|
}
|
|
437
|
-
|
|
463
|
+
handlePointerDown(_event) {
|
|
438
464
|
// default implementation
|
|
439
465
|
}
|
|
440
|
-
|
|
466
|
+
handlePointerMove(_event) {
|
|
441
467
|
// default implementation
|
|
442
468
|
}
|
|
443
|
-
|
|
444
|
-
// default implementation
|
|
445
|
-
}
|
|
446
|
-
handleDoubleClick(_event) {
|
|
447
|
-
// default implementation
|
|
448
|
-
}
|
|
449
|
-
handleDoubleTap(_event) {
|
|
450
|
-
// default implementation
|
|
451
|
-
}
|
|
452
|
-
handleTouchStart(_event) {
|
|
453
|
-
// default implementation
|
|
454
|
-
}
|
|
455
|
-
handleTouchMove(_event) {
|
|
456
|
-
// default implementation
|
|
457
|
-
}
|
|
458
|
-
handleTouchEnd(_event) {
|
|
469
|
+
handlePointerUp(_event) {
|
|
459
470
|
// default implementation
|
|
460
471
|
}
|
|
461
472
|
handleWheel(_event) {
|
|
@@ -478,90 +489,116 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
478
489
|
highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
|
|
479
490
|
};
|
|
480
491
|
}
|
|
481
|
-
|
|
482
|
-
if (
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
handleMouseMove(event) {
|
|
497
|
-
if (this._store.state.isDrawing) {
|
|
498
|
-
const x = event.clientX - this._store.offsetX;
|
|
499
|
-
const y = event.clientY - this._store.offsetY;
|
|
500
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
501
|
-
points: [...this._store.state.currentPath.points, [x, y]],
|
|
502
|
-
translateX: -this._store.state.translateX,
|
|
503
|
-
translateY: -this._store.state.translateY,
|
|
504
|
-
scale: this._store.state.scale,
|
|
505
|
-
fill: this.color,
|
|
506
|
-
strokeWidth: this.size,
|
|
507
|
-
});
|
|
508
|
-
this._store.rerender();
|
|
492
|
+
handlePointerDown(event) {
|
|
493
|
+
if (event.pointerType === 'mouse') {
|
|
494
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
495
|
+
this._store.state.isDrawing = true;
|
|
496
|
+
const x = event.clientX - this._store.offsetX;
|
|
497
|
+
const y = event.clientY - this._store.offsetY;
|
|
498
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
499
|
+
points: [[x, y]],
|
|
500
|
+
translateX: -this._store.state.translateX,
|
|
501
|
+
translateY: -this._store.state.translateY,
|
|
502
|
+
scale: this._store.state.scale,
|
|
503
|
+
fill: this.color,
|
|
504
|
+
strokeWidth: this.size,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
509
507
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
this._store.state.
|
|
516
|
-
this._store.
|
|
508
|
+
if (event.pointerType === 'touch') {
|
|
509
|
+
const activePointers = Array.from(this._store.state.pointers.values());
|
|
510
|
+
if (activePointers.length === 1) {
|
|
511
|
+
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
512
|
+
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
513
|
+
this._store.state.isDrawing = true;
|
|
514
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
515
|
+
points: [[x, y]],
|
|
516
|
+
translateX: -this._store.state.translateX,
|
|
517
|
+
translateY: -this._store.state.translateY,
|
|
518
|
+
scale: this._store.state.scale,
|
|
519
|
+
fill: this.color,
|
|
520
|
+
strokeWidth: this.size,
|
|
521
|
+
});
|
|
522
|
+
this._store.rerender();
|
|
517
523
|
}
|
|
518
|
-
this._store.state.currentPath = undefined;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
handleTouchStart(event) {
|
|
522
|
-
if (this._store.state.touchCount === 1) {
|
|
523
|
-
const x = Math.round(event.touches[0].clientX - this._store.offsetX);
|
|
524
|
-
const y = Math.round(event.touches[0].clientY - this._store.offsetY);
|
|
525
|
-
this._store.state.isDrawing = true;
|
|
526
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
527
|
-
points: [[x, y]],
|
|
528
|
-
translateX: -this._store.state.translateX,
|
|
529
|
-
translateY: -this._store.state.translateY,
|
|
530
|
-
scale: this._store.state.scale,
|
|
531
|
-
fill: this.color,
|
|
532
|
-
strokeWidth: this.size,
|
|
533
|
-
});
|
|
534
|
-
this._store.rerender();
|
|
535
524
|
}
|
|
536
525
|
}
|
|
537
|
-
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
526
|
+
handlePointerMove(event) {
|
|
527
|
+
if (event.pointerType === 'mouse') {
|
|
528
|
+
if (this._store.state.isDrawing) {
|
|
529
|
+
const x = event.clientX - this._store.offsetX;
|
|
530
|
+
const y = event.clientY - this._store.offsetY;
|
|
531
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
532
|
+
points: [...this._store.state.currentPath.points, [x, y]],
|
|
533
|
+
translateX: -this._store.state.translateX,
|
|
534
|
+
translateY: -this._store.state.translateY,
|
|
535
|
+
scale: this._store.state.scale,
|
|
536
|
+
fill: this.color,
|
|
537
|
+
strokeWidth: this.size,
|
|
538
|
+
});
|
|
539
|
+
this._store.rerender();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (event.pointerType === 'touch') {
|
|
543
|
+
const activePointers = Array.from(this._store.state.pointers.values());
|
|
544
|
+
if (activePointers.length === 1) {
|
|
545
|
+
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
546
|
+
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
547
|
+
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
548
|
+
points: [...this._store.state.currentPath.points, [x, y]],
|
|
549
|
+
translateX: -this._store.state.translateX,
|
|
550
|
+
translateY: -this._store.state.translateY,
|
|
551
|
+
scale: this._store.state.scale,
|
|
552
|
+
fill: this.color,
|
|
553
|
+
strokeWidth: this.size,
|
|
554
|
+
});
|
|
555
|
+
this._store.rerender();
|
|
556
|
+
}
|
|
550
557
|
}
|
|
551
558
|
}
|
|
552
|
-
|
|
553
|
-
if (
|
|
554
|
-
this._store.state.isDrawing
|
|
555
|
-
|
|
556
|
-
this._store.state.currentPath
|
|
557
|
-
|
|
559
|
+
handlePointerUp(event) {
|
|
560
|
+
if (event.pointerType === 'mouse') {
|
|
561
|
+
if (this._store.state.isDrawing) {
|
|
562
|
+
this._store.state.isDrawing = false;
|
|
563
|
+
if (this._store.state.currentPath) {
|
|
564
|
+
this._store.state.currentPath.zIndex = this._store.currentZIndex;
|
|
565
|
+
this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
|
|
566
|
+
}
|
|
567
|
+
this._store.state.currentPath = undefined;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (event.pointerType === 'touch') {
|
|
571
|
+
if (this._store.state.isDrawing) {
|
|
572
|
+
this._store.state.isDrawing = false;
|
|
573
|
+
if (this._store.state.currentPath) {
|
|
574
|
+
this._store.state.currentPath.zIndex = this._store.currentZIndex;
|
|
575
|
+
this._store.history.executeCommand(new AddObjectCommand(this._store, this, this._store.state.currentPath));
|
|
576
|
+
}
|
|
577
|
+
this._store.state.currentPath = undefined;
|
|
578
|
+
this._store.rerender();
|
|
558
579
|
}
|
|
559
|
-
this._store.state.currentPath = undefined;
|
|
560
|
-
this._store.rerender();
|
|
561
580
|
}
|
|
562
581
|
}
|
|
563
582
|
}
|
|
564
583
|
|
|
584
|
+
class KritzelToolRegistry {
|
|
585
|
+
static registerTool(toolName, constructor, store) {
|
|
586
|
+
const toolInstance = new constructor(store);
|
|
587
|
+
toolInstance.name = toolName;
|
|
588
|
+
this.registry[toolName] = toolInstance;
|
|
589
|
+
return toolInstance;
|
|
590
|
+
}
|
|
591
|
+
static getTool(toolName) {
|
|
592
|
+
const toolInstance = this.registry[toolName];
|
|
593
|
+
if (!toolInstance) {
|
|
594
|
+
console.warn(`Unknown tool: ${toolName}`);
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
return toolInstance;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
KritzelToolRegistry.registry = {};
|
|
601
|
+
|
|
565
602
|
class KritzelText extends KritzelBaseObject {
|
|
566
603
|
get isReadonly() {
|
|
567
604
|
return !(this._store.state.activeTool instanceof KritzelTextTool);
|
|
@@ -584,7 +621,7 @@ class KritzelText extends KritzelBaseObject {
|
|
|
584
621
|
this.fontSize = config.fontSize || 8;
|
|
585
622
|
this.fontFamily = config.fontFamily || 'Arial';
|
|
586
623
|
this.fontColor = config.fontColor || '#000000';
|
|
587
|
-
this.height = config.height ||
|
|
624
|
+
this.height = config.height || this.fontSize * 1.2;
|
|
588
625
|
this.width = config.width || 0;
|
|
589
626
|
this.scale = config.scale || 1;
|
|
590
627
|
}
|
|
@@ -688,25 +725,16 @@ class KritzelText extends KritzelBaseObject {
|
|
|
688
725
|
}
|
|
689
726
|
}
|
|
690
727
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
static getTool(toolName) {
|
|
701
|
-
const toolInstance = this.registry[toolName];
|
|
702
|
-
if (!toolInstance) {
|
|
703
|
-
console.warn(`Unknown tool: ${toolName}`);
|
|
704
|
-
return null;
|
|
705
|
-
}
|
|
706
|
-
return toolInstance;
|
|
728
|
+
onSelectedClick() {
|
|
729
|
+
this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
730
|
+
this._store.state.selectionGroup = null;
|
|
731
|
+
this._store.state.selectionBox = null;
|
|
732
|
+
this._store.state.activeText = this;
|
|
733
|
+
setTimeout(() => {
|
|
734
|
+
this.focus();
|
|
735
|
+
}, 300);
|
|
707
736
|
}
|
|
708
737
|
}
|
|
709
|
-
KritzelToolRegistry.registry = {};
|
|
710
738
|
|
|
711
739
|
class KritzelKeyboardHelper {
|
|
712
740
|
static forceHideKeyboard() {
|
|
@@ -763,84 +791,87 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
763
791
|
'#800080',
|
|
764
792
|
];
|
|
765
793
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
this._store.state.activeText
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
object
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
this._store.
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
this._store.state.activeText
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
794
|
+
handlePointerDown(event) {
|
|
795
|
+
if (event.pointerType === 'mouse') {
|
|
796
|
+
const path = event.composedPath().slice(1);
|
|
797
|
+
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
798
|
+
const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
|
|
799
|
+
if (this._store.state.activeText === null && object && object instanceof KritzelText) {
|
|
800
|
+
this._store.state.activeText = object;
|
|
801
|
+
object.focus();
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
if (this._store.state.activeText !== null && object instanceof KritzelText) {
|
|
805
|
+
object.focus();
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (this._store.state.activeText !== null) {
|
|
809
|
+
this._store.resetActiveText();
|
|
810
|
+
this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (KritzelEventHelper.isLeftClick(event) === false) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
const clientX = event.clientX - this._store.offsetX;
|
|
817
|
+
const clientY = event.clientY - this._store.offsetY;
|
|
818
|
+
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
819
|
+
text.fontColor = this.fontColor;
|
|
820
|
+
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
821
|
+
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
822
|
+
text.zIndex = this._store.currentZIndex;
|
|
823
|
+
this._store.state.activeText = text;
|
|
824
|
+
this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
|
|
825
|
+
}
|
|
826
|
+
if (event.pointerType === 'touch') {
|
|
827
|
+
const activePointers = Array.from(this._store.state.pointers.values());
|
|
828
|
+
const path = event.composedPath().slice(1);
|
|
829
|
+
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
830
|
+
const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
|
|
831
|
+
if (this._store.state.activeText === null && object && object instanceof KritzelText) {
|
|
832
|
+
this._store.state.activeText = object;
|
|
833
|
+
object.focus();
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
if (this._store.state.activeText !== null && object instanceof KritzelText) {
|
|
837
|
+
object.focus();
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (this._store.state.activeText !== null) {
|
|
841
|
+
this._store.resetActiveText();
|
|
842
|
+
this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
if (activePointers.length > 1) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
849
|
+
const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
850
|
+
const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
851
|
+
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
852
|
+
text.fontColor = this.fontColor;
|
|
853
|
+
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
854
|
+
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
855
|
+
text.zIndex = this._store.currentZIndex;
|
|
856
|
+
this._store.state.activeText = text;
|
|
857
|
+
this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
handlePointerUp(event) {
|
|
861
|
+
var _a, _b, _c, _d;
|
|
862
|
+
if (event.pointerType === 'mouse') {
|
|
863
|
+
(_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
|
|
864
|
+
(_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
|
|
865
|
+
}
|
|
866
|
+
if (event.pointerType === 'touch') {
|
|
867
|
+
(_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
|
|
868
|
+
(_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
|
|
869
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
823
870
|
}
|
|
824
|
-
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
825
|
-
const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);
|
|
826
|
-
const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);
|
|
827
|
-
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
828
|
-
text.fontColor = this.fontColor;
|
|
829
|
-
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
830
|
-
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
831
|
-
text.zIndex = this._store.currentZIndex;
|
|
832
|
-
this._store.state.activeText = text;
|
|
833
|
-
this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
|
|
834
|
-
}
|
|
835
|
-
handleTouchEnd(_event) {
|
|
836
|
-
var _a, _b;
|
|
837
|
-
(_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
|
|
838
|
-
(_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
|
|
839
|
-
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
840
871
|
}
|
|
841
872
|
}
|
|
842
873
|
|
|
843
|
-
export { AddObjectCommand as A, KritzelBrushTool as K, ObjectHelper as O, KritzelTextTool as a, KritzelBaseCommand as b, KritzelBaseTool as c, KritzelEventHelper as d, KritzelBaseObject as e, KritzelText as f, KritzelToolRegistry as g, KritzelPath as h,
|
|
844
|
-
//# sourceMappingURL=p-
|
|
874
|
+
export { AddObjectCommand as A, KritzelBrushTool as K, ObjectHelper as O, KritzelTextTool as a, KritzelBaseCommand as b, KritzelBaseTool as c, KritzelEventHelper as d, KritzelBaseObject as e, KritzelText as f, KritzelToolRegistry as g, KritzelPath as h, KritzelMouseButton as i, KritzelKeyboardHelper as j };
|
|
875
|
+
//# sourceMappingURL=p-7Ns73-wN.js.map
|
|
845
876
|
|
|
846
|
-
//# sourceMappingURL=p-
|
|
877
|
+
//# sourceMappingURL=p-7Ns73-wN.js.map
|