kritzel-stencil 0.0.51 → 0.0.53

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.
Files changed (75) hide show
  1. package/dist/cjs/kritzel-brush-style_17.cjs.entry.js +117 -45
  2. package/dist/cjs/kritzel-brush-style_17.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/handlers/context-menu.handler.js +6 -2
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/move.handler.js +2 -2
  8. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/resize.handler.js +2 -2
  10. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/rotation.handler.js +2 -2
  12. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/selection.handler.js +3 -3
  14. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  15. package/dist/collection/classes/objects/text.class.js +6 -0
  16. package/dist/collection/classes/objects/text.class.js.map +1 -1
  17. package/dist/collection/classes/tools/base-tool.class.js +3 -0
  18. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  19. package/dist/collection/classes/tools/brush-tool.class.js +2 -2
  20. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  21. package/dist/collection/classes/tools/eraser-tool.class.js +2 -2
  22. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  23. package/dist/collection/classes/tools/selection-tool.class.js +19 -5
  24. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  25. package/dist/collection/classes/tools/text-tool.class.js +2 -3
  26. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  27. package/dist/collection/classes/viewport.class.js +3 -3
  28. package/dist/collection/classes/viewport.class.js.map +1 -1
  29. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +4 -2
  30. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  31. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +42 -17
  32. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  33. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +6 -4
  34. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  35. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +6 -4
  36. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -1
  37. package/dist/collection/helpers/event.helper.js +35 -0
  38. package/dist/collection/helpers/event.helper.js.map +1 -0
  39. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  40. package/dist/components/kritzel-controls.js +1 -1
  41. package/dist/components/kritzel-editor.js +7 -5
  42. package/dist/components/kritzel-editor.js.map +1 -1
  43. package/dist/components/kritzel-engine.js +1 -1
  44. package/dist/components/kritzel-utility-panel.js +1 -1
  45. package/dist/components/{p-BEMp5kP-.js → p-BO_dOgoX.js} +10 -8
  46. package/dist/components/p-BO_dOgoX.js.map +1 -0
  47. package/dist/components/{p-D1ycNrZ_.js → p-Ck6uu17l.js} +47 -25
  48. package/dist/components/p-Ck6uu17l.js.map +1 -0
  49. package/dist/components/{p-s77CSeNI.js → p-DPTUFMP6.js} +61 -17
  50. package/dist/components/p-DPTUFMP6.js.map +1 -0
  51. package/dist/components/{p-BSRSevAl.js → p-HG6IciIx.js} +8 -6
  52. package/dist/components/p-HG6IciIx.js.map +1 -0
  53. package/dist/esm/kritzel-brush-style_17.entry.js +117 -45
  54. package/dist/esm/kritzel-brush-style_17.entry.js.map +1 -1
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/stencil.js +1 -1
  57. package/dist/stencil/p-79114109.entry.js +2 -0
  58. package/dist/stencil/p-79114109.entry.js.map +1 -0
  59. package/dist/stencil/stencil.esm.js +1 -1
  60. package/dist/types/classes/objects/text.class.d.ts +1 -0
  61. package/dist/types/classes/tools/base-tool.class.d.ts +1 -0
  62. package/dist/types/classes/tools/selection-tool.class.d.ts +1 -0
  63. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +1 -0
  64. package/dist/types/helpers/event.helper.d.ts +9 -0
  65. package/dist/types/interfaces/tool.interface.d.ts +1 -0
  66. package/package.json +1 -1
  67. package/dist/collection/helpers/click.helper.js +0 -13
  68. package/dist/collection/helpers/click.helper.js.map +0 -1
  69. package/dist/components/p-BEMp5kP-.js.map +0 -1
  70. package/dist/components/p-BSRSevAl.js.map +0 -1
  71. package/dist/components/p-D1ycNrZ_.js.map +0 -1
  72. package/dist/components/p-s77CSeNI.js.map +0 -1
  73. package/dist/stencil/p-86fabca2.entry.js +0 -2
  74. package/dist/stencil/p-86fabca2.entry.js.map +0 -1
  75. package/dist/types/helpers/click.helper.d.ts +0 -5
@@ -233,7 +233,7 @@ var KritzelMouseButton;
233
233
  KritzelMouseButton[KritzelMouseButton["Right"] = 2] = "Right";
234
234
  })(KritzelMouseButton || (KritzelMouseButton = {}));
235
235
 
236
- class KritzelMouseHelper {
236
+ class KritzelEventHelper {
237
237
  static isRightClick(ev) {
238
238
  return ev.button === KritzelMouseButton.Right;
239
239
  }
@@ -243,7 +243,29 @@ class KritzelMouseHelper {
243
243
  static isMainMouseWheel(event) {
244
244
  return Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0 && Number.isInteger(event.deltaY);
245
245
  }
246
+ static detectDoubleTap() {
247
+ const currentTime = Date.now();
248
+ const tapLength = currentTime - KritzelEventHelper.lastTapTimestamp;
249
+ if (KritzelEventHelper.tapTimeoutId) {
250
+ clearTimeout(KritzelEventHelper.tapTimeoutId);
251
+ KritzelEventHelper.tapTimeoutId = null;
252
+ }
253
+ if (tapLength < KritzelEventHelper.doubleTapTimeout && tapLength > 0) {
254
+ KritzelEventHelper.lastTapTimestamp = 0;
255
+ return true;
256
+ }
257
+ else {
258
+ KritzelEventHelper.lastTapTimestamp = currentTime;
259
+ KritzelEventHelper.tapTimeoutId = setTimeout(() => {
260
+ KritzelEventHelper.tapTimeoutId = null;
261
+ }, KritzelEventHelper.doubleTapTimeout);
262
+ return false;
263
+ }
264
+ }
246
265
  }
266
+ KritzelEventHelper.lastTapTimestamp = 0;
267
+ KritzelEventHelper.tapTimeoutId = null;
268
+ KritzelEventHelper.doubleTapTimeout = 300;
247
269
 
248
270
  class KritzelBaseCommand {
249
271
  constructor(store, initiator) {
@@ -313,7 +335,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
313
335
  }
314
336
  handleMouseDown(event) {
315
337
  var _a;
316
- if (KritzelMouseHelper.isLeftClick(event)) {
338
+ if (KritzelEventHelper.isLeftClick(event)) {
317
339
  if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
318
340
  const clientX = event.clientX - this._store.offsetX;
319
341
  const clientY = event.clientY - this._store.offsetY;
@@ -415,7 +437,7 @@ class KritzelResizeHandler extends KritzelBaseHandler {
415
437
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
416
438
  }
417
439
  handleMouseDown(event) {
418
- if (KritzelMouseHelper.isLeftClick(event)) {
440
+ if (KritzelEventHelper.isLeftClick(event)) {
419
441
  if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
420
442
  const clientX = event.clientX - this._store.offsetX;
421
443
  const clientY = event.clientY - this._store.offsetY;
@@ -573,7 +595,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
573
595
  this.rotation = 0;
574
596
  }
575
597
  handleMouseDown(event) {
576
- if (KritzelMouseHelper.isLeftClick(event)) {
598
+ if (KritzelEventHelper.isLeftClick(event)) {
577
599
  if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
578
600
  const clientX = event.clientX - this._store.offsetX;
579
601
  const clientY = event.clientY - this._store.offsetY;
@@ -3163,6 +3185,9 @@ class KritzelBaseTool {
3163
3185
  handleDoubleClick(_event) {
3164
3186
  // default implementation
3165
3187
  }
3188
+ handleDoubleTap(_event) {
3189
+ // default implementation
3190
+ }
3166
3191
  handleTouchStart(_event) {
3167
3192
  // default implementation
3168
3193
  }
@@ -3254,7 +3279,7 @@ class KritzelTextTool extends KritzelBaseTool {
3254
3279
  this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
3255
3280
  return;
3256
3281
  }
3257
- if (KritzelMouseHelper.isLeftClick(event) === false) {
3282
+ if (KritzelEventHelper.isLeftClick(event) === false) {
3258
3283
  return;
3259
3284
  }
3260
3285
  const clientX = event.clientX - this._store.offsetX;
@@ -3296,7 +3321,6 @@ class KritzelTextTool extends KritzelBaseTool {
3296
3321
  text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
3297
3322
  text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
3298
3323
  text.zIndex = this._store.currentZIndex;
3299
- text.adjustTextareaSize();
3300
3324
  this._store.state.activeText = text;
3301
3325
  this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
3302
3326
  }
@@ -3352,6 +3376,12 @@ class KritzelText extends KritzelBaseObject {
3352
3376
  this.translateX = x;
3353
3377
  this.translateY = y;
3354
3378
  }
3379
+ handleKeyDown(event) {
3380
+ if (this.isReadonly) {
3381
+ event.preventDefault();
3382
+ event.stopPropagation();
3383
+ }
3384
+ }
3355
3385
  handleInput(event) {
3356
3386
  const target = event.target;
3357
3387
  if (target.value === '') {
@@ -3425,7 +3455,7 @@ class KritzelBrushTool extends KritzelBaseTool {
3425
3455
  };
3426
3456
  }
3427
3457
  handleMouseDown(event) {
3428
- if (KritzelMouseHelper.isLeftClick(event)) {
3458
+ if (KritzelEventHelper.isLeftClick(event)) {
3429
3459
  this._store.state.isDrawing = true;
3430
3460
  const x = event.clientX - this._store.offsetX;
3431
3461
  const y = event.clientY - this._store.offsetY;
@@ -3540,7 +3570,7 @@ class KritzelEraserTool extends KritzelBaseTool {
3540
3570
  this.touchStartTimeout = null;
3541
3571
  }
3542
3572
  handleMouseDown(event) {
3543
- if (KritzelMouseHelper.isLeftClick(event)) {
3573
+ if (KritzelEventHelper.isLeftClick(event)) {
3544
3574
  this._store.state.isErasing = true;
3545
3575
  }
3546
3576
  }
@@ -3930,7 +3960,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
3930
3960
  this.touchStartTimeout = null;
3931
3961
  }
3932
3962
  handleMouseDown(event) {
3933
- if (KritzelMouseHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
3963
+ if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
3934
3964
  this.startMouseSelection(event);
3935
3965
  }
3936
3966
  }
@@ -3940,7 +3970,7 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
3940
3970
  }
3941
3971
  }
3942
3972
  handleMouseUp(event) {
3943
- if (KritzelMouseHelper.isLeftClick(event) && this._store.state.isSelecting) {
3973
+ if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
3944
3974
  if (this.isSelectionClick) {
3945
3975
  this.updateMouseSelection(event);
3946
3976
  this.addSelectedObjectAtIndexToSelectionGroup(0);
@@ -4114,7 +4144,7 @@ class KritzelSelectionTool extends KritzelBaseTool {
4114
4144
  this.rotationHandler = new KritzelRotationHandler(this._store);
4115
4145
  }
4116
4146
  handleMouseDown(event) {
4117
- if (KritzelMouseHelper.isLeftClick(event)) {
4147
+ if (KritzelEventHelper.isLeftClick(event)) {
4118
4148
  this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
4119
4149
  this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
4120
4150
  this._store.state.resizeHandleType = this.getHandleType(event);
@@ -4149,13 +4179,13 @@ class KritzelSelectionTool extends KritzelBaseTool {
4149
4179
  }
4150
4180
  handleDoubleClick(event) {
4151
4181
  var _a;
4152
- if (KritzelMouseHelper.isLeftClick(event)) {
4182
+ if (KritzelEventHelper.isLeftClick(event)) {
4153
4183
  if (this._store.state.selectionGroup && ((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.objects.length) === 1) {
4154
4184
  const selectedObject = this._store.state.selectionGroup.objects[0];
4155
4185
  if (selectedObject instanceof KritzelText) {
4156
- this._store.state.activeText = selectedObject;
4157
- this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
4158
4186
  this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
4187
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
4188
+ this._store.state.activeText = selectedObject;
4159
4189
  setTimeout(() => {
4160
4190
  selectedObject.focus();
4161
4191
  }, 300);
@@ -4163,6 +4193,20 @@ class KritzelSelectionTool extends KritzelBaseTool {
4163
4193
  }
4164
4194
  }
4165
4195
  }
4196
+ handleDoubleTap(event) {
4197
+ const selectionGroup = this.getSelectedObject(event);
4198
+ if (!selectionGroup || selectionGroup.objects.length !== 1) {
4199
+ return;
4200
+ }
4201
+ const selectedObject = selectionGroup.objects[0];
4202
+ if (selectedObject instanceof KritzelText) {
4203
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
4204
+ this._store.state.activeText = selectedObject;
4205
+ setTimeout(() => {
4206
+ selectedObject.focus();
4207
+ }, 300);
4208
+ }
4209
+ }
4166
4210
  handleTouchStart(event) {
4167
4211
  if (this._store.state.isScaling === true) {
4168
4212
  return;
@@ -4443,8 +4487,10 @@ const KritzelControls = class {
4443
4487
  this.kritzelEngine.enable();
4444
4488
  }
4445
4489
  preventDefault(event) {
4446
- event.preventDefault();
4447
- event.stopPropagation();
4490
+ if (event.cancelable) {
4491
+ event.preventDefault();
4492
+ event.stopPropagation();
4493
+ }
4448
4494
  }
4449
4495
  async handleControlClick(control) {
4450
4496
  this.activeControl = control;
@@ -4464,11 +4510,11 @@ const KritzelControls = class {
4464
4510
  render() {
4465
4511
  var _a, _b;
4466
4512
  const hasNoConfig = ((_a = this.activeControl) === null || _a === void 0 ? void 0 : _a.config) === undefined || ((_b = this.activeControl) === null || _b === void 0 ? void 0 : _b.config) === null;
4467
- return (index.h(index.Host, { key: '536bc38ca09833acffad3377bc2828922fb0a9ab' }, index.h("kritzel-utility-panel", { key: 'ce1dabdadada896a6352a60f075b4c2b0ecec7f7', style: {
4513
+ return (index.h(index.Host, { key: '8a2dd731112b08ba40071c27cd382e42aede4ed1' }, index.h("kritzel-utility-panel", { key: '16b7a429969a005f2f660d0ede211d23de5b259c', style: {
4468
4514
  position: 'absolute',
4469
4515
  bottom: '56px',
4470
4516
  left: '12px',
4471
- }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), index.h("div", { key: '8b5d568342495a3b3f75fbda591efe3c58485a4b', class: "kritzel-controls" }, this.controls.map(control => {
4517
+ }, onUndo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.undo(); }, onRedo: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.redo(); }, onDelete: () => { var _a; return (_a = this.kritzelEngine) === null || _a === void 0 ? void 0 : _a.delete(); } }), index.h("div", { key: '97a410c6aae8ef20e55703f19bfd222521e42b1c', class: "kritzel-controls" }, this.controls.map(control => {
4472
4518
  var _a, _b, _c, _d, _e, _f, _g;
4473
4519
  if (control.type === 'tool') {
4474
4520
  return (index.h("button", { class: {
@@ -4741,7 +4787,9 @@ const KritzelEditor = class {
4741
4787
  this.customSvgIcons = {};
4742
4788
  }
4743
4789
  handleTouchStart(event) {
4744
- event.preventDefault();
4790
+ if (event.cancelable) {
4791
+ event.preventDefault();
4792
+ }
4745
4793
  }
4746
4794
  componentWillLoad() {
4747
4795
  for (const [name, svg] of Object.entries(this.customSvgIcons)) {
@@ -4749,7 +4797,7 @@ const KritzelEditor = class {
4749
4797
  }
4750
4798
  }
4751
4799
  render() {
4752
- return (index.h(index.Host, { key: '970334035de62ba56f1f810da20187463bea44d5' }, index.h("kritzel-engine", { key: '42d3d69248b861fe51b3e87661bcf51bfdf76163' }), index.h("kritzel-controls", { key: '931d48d4e0cf02f945f2bb90328018e7df5661db', controls: this.controls })));
4800
+ return (index.h(index.Host, { key: 'abd8f2477e1596034ec953781f7d7145117fc0ef' }, index.h("kritzel-engine", { key: 'ea4bc0f6c876ceeea558c2dbc315f6a6448ab34e' }), index.h("kritzel-controls", { key: '566473bb09a72d34e37bc52d6037f6776b345d96', controls: this.controls })));
4753
4801
  }
4754
4802
  };
4755
4803
  KritzelEditor.style = kritzelEditorCss;
@@ -4777,7 +4825,7 @@ class KritzelViewport {
4777
4825
  handleMouseDown(event) {
4778
4826
  const adjustedClientX = event.clientX - this._store.offsetX;
4779
4827
  const adjustedClientY = event.clientY - this._store.offsetY;
4780
- if (KritzelMouseHelper.isRightClick(event)) {
4828
+ if (KritzelEventHelper.isRightClick(event)) {
4781
4829
  this._store.state.isPanning = true;
4782
4830
  this._store.state.startX = adjustedClientX;
4783
4831
  this._store.state.startY = adjustedClientY;
@@ -4855,7 +4903,7 @@ class KritzelViewport {
4855
4903
  }
4856
4904
  handleWheel(event) {
4857
4905
  event.preventDefault();
4858
- if (event.ctrlKey === true && KritzelMouseHelper.isMainMouseWheel(event)) {
4906
+ if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {
4859
4907
  this.handleZoom(event);
4860
4908
  }
4861
4909
  if (!event.ctrlKey) {
@@ -5532,7 +5580,9 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
5532
5580
  this.objectContextMenuItems = objectContextMenuItems;
5533
5581
  }
5534
5582
  handleContextMenu(event) {
5535
- event.preventDefault();
5583
+ if (event.cancelable) {
5584
+ event.preventDefault();
5585
+ }
5536
5586
  if (!(this._store.state.activeTool instanceof KritzelSelectionTool)) {
5537
5587
  return;
5538
5588
  }
@@ -5561,7 +5611,9 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
5561
5611
  this._store.rerender();
5562
5612
  }
5563
5613
  handleContextMenuTouch(event) {
5564
- event.preventDefault();
5614
+ if (event.cancelable) {
5615
+ event.preventDefault();
5616
+ }
5565
5617
  if (this._store.state.touchCount > 1 || !(this._store.state.activeTool instanceof KritzelSelectionTool)) {
5566
5618
  return;
5567
5619
  }
@@ -5708,16 +5760,30 @@ const KritzelEngine = class {
5708
5760
  }
5709
5761
  (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleClick(ev);
5710
5762
  }
5763
+ handleDoubleTap(ev) {
5764
+ var _a, _b;
5765
+ if (this.store.state.isEnabled === false) {
5766
+ return;
5767
+ }
5768
+ const touchEvent = ev instanceof CustomEvent && ev.detail ? ev.detail : ev;
5769
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleTap(touchEvent);
5770
+ }
5711
5771
  handleTouchStart(ev) {
5712
5772
  var _a, _b;
5713
5773
  if (this.store.state.isEnabled === false) {
5714
5774
  return;
5715
5775
  }
5776
+ if (KritzelEventHelper.detectDoubleTap()) {
5777
+ const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
5778
+ this.host.dispatchEvent(doubleTapEvent);
5779
+ }
5716
5780
  if (ev.touches.length > 1) {
5717
5781
  clearTimeout(this.store.state.longTouchTimeout);
5718
5782
  }
5783
+ if (ev.cancelable) {
5784
+ ev.preventDefault();
5785
+ }
5719
5786
  this.store.state.longTouchTimeout = setTimeout(() => this.contextMenuHandler.handleContextMenuTouch(ev), this.store.state.longTouchDelay);
5720
- ev.preventDefault();
5721
5787
  this.viewport.handleTouchStart(ev);
5722
5788
  (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchStart(ev);
5723
5789
  }
@@ -5726,7 +5792,9 @@ const KritzelEngine = class {
5726
5792
  if (this.store.state.isEnabled === false) {
5727
5793
  return;
5728
5794
  }
5729
- ev.preventDefault();
5795
+ if (ev.cancelable) {
5796
+ ev.preventDefault();
5797
+ }
5730
5798
  this.viewport.handleTouchMove(ev);
5731
5799
  (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchMove(ev);
5732
5800
  }
@@ -5735,8 +5803,10 @@ const KritzelEngine = class {
5735
5803
  if (this.store.state.isEnabled === false) {
5736
5804
  return;
5737
5805
  }
5806
+ if (ev.cancelable) {
5807
+ ev.preventDefault();
5808
+ }
5738
5809
  clearTimeout(this.store.state.longTouchTimeout);
5739
- ev.preventDefault();
5740
5810
  this.viewport.handleTouchEnd(ev);
5741
5811
  (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchEnd(ev);
5742
5812
  }
@@ -5835,15 +5905,15 @@ const KritzelEngine = class {
5835
5905
  const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
5836
5906
  const baseHandleSize = parseFloat(baseHandleSizePx);
5837
5907
  const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
5838
- return (index.h(index.Host, { key: '692a4958608cfc1edc10cf6897bddc3a06f0dfa5' }, index.h("div", { key: '1c41c844a8240643564ac595675811b6efd879da', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '17693c97f32eb226b9119b2fb47f013b21a6cf44' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
5839
- _a.translateX), index.h("div", { key: '8e41a759b49e9e62a03405431091b1fd3a52ae40' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
5840
- _b.translateY), index.h("div", { key: 'dbed688264e9ff3af37304da6cdef8c7e535e696' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
5841
- _c.viewportWidth), index.h("div", { key: 'a29098fc7b352d5a30d89934b969d1d81a1ec631' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
5842
- _d.viewportHeight), index.h("div", { key: '27fd4b120b97d61aa31b6599faf4829aadd4a218' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '7c2bcf18ffcf8d032b9d8c0adaf9621164dd22c6' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
5843
- _e.scale), index.h("div", { key: 'a85bd690ab7b3e9753d7dbf040764154709ea45a' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
5844
- _g.name), index.h("div", { key: '42101914fda26a0fe0f27880d1176d11886636c2' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'dde2e4e23bc2a8264df9732a4c2a6c3ef5bb562a' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: 'cd8ba57b12c014d3d6befe1485b74b82f022b0fd' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '08bacac63f98f28e02042fe86ce80868a612e715' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: '989ef4daa1a387adf3ac1edccfa93f61fd74563c' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: 'd5cae174cef526441b3f607e4dc0f815a917f126' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '262936c83a71c1f27d2347b0c936453097bd93e0' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '3463771ecfe52e790be1c765302167608e9de9f9' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '2883fc0fbe9fc3c6c17a05f70fbcf43a71804e9c' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'a142a2f46189a79a9a440f9fd746a665e02b320b' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: 'f1c87057e018ec140499dbc109258cf37c1b26ea' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '7501005ddad1d3f3d8c0eec50cc28ceaf013b57c' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
5845
- _m.cursorX), index.h("div", { key: 'a06347469efff1a721c50c6810e62cd5c1dc5e3d' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
5846
- _o.cursorY)), index.h("div", { key: '02bc591edd964cf211e625f6f81b849500796e79', class: "origin", style: {
5908
+ return (index.h(index.Host, { key: '0642d2ac0140afd334cabae1b39b9db020286620' }, index.h("div", { key: '66669b6fc5fca51cfe7e673b00e87fa5748d5fe5', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: 'a56d8b51ed73c4de16ef24d6735a39e4661b409b' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
5909
+ _a.translateX), index.h("div", { key: 'b27570df7cd39911eb5d01195f32ed3192cafa7c' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
5910
+ _b.translateY), index.h("div", { key: '57483850fbb6a91917cf803f1a71e5282a066510' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
5911
+ _c.viewportWidth), index.h("div", { key: 'd54b545f70fe8557cc0b3d5eae6791cd7825d231' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
5912
+ _d.viewportHeight), index.h("div", { key: '9c645cac860bec7c8bd16ee8840fe16088c48879' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '1df32022232631bfdc3242a4f7327d462b0a1e38' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
5913
+ _e.scale), index.h("div", { key: '2fdcbfef0441c8ebbb1ee84e7ad83f3355f7a350' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
5914
+ _g.name), index.h("div", { key: '2fa6b406f5dbe2fb6e131a62d46f794e4ff9e2cc' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: '2d5ca8b9359677d9cc83b496975cc5414e521fdc' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '0ed663cd8205374353bac02f1553a405a5ed3109' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: 'a7180e7ce19752dd4bc7c5c59c00ef91a0b93588' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: 'b7cc871cf2ef034f19a38995b66486aceb11d824' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '3407c6bbdc33746210d1ab409d80c675450b2a44' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: '36cbc462ee49ef8adb22cd633da0963dc88e94e9' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '1502f6b8cc85f02f1ec7738838ade0e6ba5d19a7' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '0d8f8c9c23483645a7f2d5443974f89027b19439' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: 'e0ad0d92ef028196af7a84a005d6c4849d9fade8' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: '2ce04740c32890c39a8d49cf0776bca493db3b8b' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: '0d0732f612b9699ae3ada6ae9a06252c5d63d49c' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
5915
+ _m.cursorX), index.h("div", { key: 'ea122cc8a84ec7d92bf863fa30a9769693ba72f5' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
5916
+ _o.cursorY)), index.h("div", { key: '5f5fb180ea6186451db973f109182ba94dfd3cd9', class: "origin", style: {
5847
5917
  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})`,
5848
5918
  } }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
5849
5919
  _t.map(object => {
@@ -5869,7 +5939,6 @@ const KritzelEngine = class {
5869
5939
  borderStyle: 'solid',
5870
5940
  padding: object.padding + 'px',
5871
5941
  overflow: 'visible',
5872
- willChange: 'transform'
5873
5942
  } }, object instanceof KritzelPath && (index.h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
5874
5943
  height: object === null || object === void 0 ? void 0 : object.height.toString(),
5875
5944
  width: object === null || object === void 0 ? void 0 : object.width.toString(),
@@ -5880,7 +5949,7 @@ const KritzelEngine = class {
5880
5949
  height: '100%',
5881
5950
  userSelect: 'none',
5882
5951
  pointerEvents: 'none',
5883
- }, draggable: false, onDragStart: e => e.preventDefault() })), object instanceof KritzelText && (index.h("textarea", { ref: el => object.mount(el), value: object.value, onInput: event => object.handleInput(event), rows: object.rows, style: {
5952
+ }, draggable: false, onDragStart: e => e.preventDefault() })), object instanceof KritzelText && (index.h("textarea", { ref: el => object.mount(el), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
5884
5953
  width: '100%',
5885
5954
  height: '100%',
5886
5955
  color: object.fontColor,
@@ -5891,6 +5960,7 @@ const KritzelEngine = class {
5891
5960
  resize: 'none',
5892
5961
  overflow: 'hidden',
5893
5962
  display: 'block',
5963
+ padding: '1px',
5894
5964
  whiteSpace: 'nowrap',
5895
5965
  cursor: object.isReadonly ? 'default' : 'text',
5896
5966
  caretColor: object.isReadonly ? 'transparent' : 'auto',
@@ -5941,7 +6011,7 @@ const KritzelEngine = class {
5941
6011
  fill: 'transparent',
5942
6012
  cursor: 'grab',
5943
6013
  }, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' })), index.h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : '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))))));
5944
- }), index.h("svg", { key: '5b9e5b55898fdf00bdb22ac955b24f527a55ebe6', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
6014
+ }), index.h("svg", { key: '0357e82c07e37e21fdc4cc47845336e3eb9531e5', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
5945
6015
  height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
5946
6016
  width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
5947
6017
  left: '0',
@@ -5950,12 +6020,12 @@ const KritzelEngine = class {
5950
6020
  position: 'absolute',
5951
6021
  transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
5952
6022
  overflow: 'visible',
5953
- }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '4d7fcff9c1776ccc6b36653b8f3be578f8e6df66', 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: '2692801179aad0f7f01d253880dcb6de81465f04', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
6023
+ }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: 'b8360e3d7650bf003cd346520480f581e8ab3a0e', 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: '85a8b8401fe9370d55fbf0a50a695fc426728685', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
5954
6024
  position: 'fixed',
5955
6025
  left: `${this.store.state.contextMenuX}px`,
5956
6026
  top: `${this.store.state.contextMenuY}px`,
5957
6027
  zIndex: '10000',
5958
- }, 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: '04fb60d0fffbf7cdbe7dbc5d4254fe20fff32348' })));
6028
+ }, 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: '29022106319055db651a526338d4dd0ed5f98761' })));
5959
6029
  }
5960
6030
  get host() { return index.getElement(this); }
5961
6031
  };
@@ -6098,9 +6168,11 @@ const KritzelUtilityPanel = class {
6098
6168
  this.delete = index.createEvent(this, "delete");
6099
6169
  }
6100
6170
  handleUndo(event) {
6101
- event.preventDefault();
6102
- event.stopPropagation();
6103
- this.undo.emit();
6171
+ if (event.cancelable) {
6172
+ event.preventDefault();
6173
+ event.stopPropagation();
6174
+ this.undo.emit();
6175
+ }
6104
6176
  }
6105
6177
  handleRedo(event) {
6106
6178
  event.preventDefault();
@@ -6108,7 +6180,7 @@ const KritzelUtilityPanel = class {
6108
6180
  this.redo.emit();
6109
6181
  }
6110
6182
  render() {
6111
- return (index.h(index.Host, { key: '81a0f77f58817dbf500dffe7724b01f5fb73e113' }, index.h("button", { key: '735fff4238ff5ae03c8422929375af1441e14f30', class: "utility-button", onClick: (event) => this.handleUndo(event) }, index.h("kritzel-icon", { key: '52e9649fd2b51968241826380243662c1dd4fe68', name: "undo" })), index.h("button", { key: '61759379c99204a0dd8286eb29e76a137cc47de8', class: "utility-button", onClick: (event) => this.handleRedo(event) }, index.h("kritzel-icon", { key: 'b62c1e8820bae090c218deaaf9d89eb2c7152cd3', name: "redo" })), index.h("div", { key: 'c9693263b71ffa31b4f08c23daf3fd52bbbe5700', class: "utility-separator" }), index.h("button", { key: 'fa2193db98b334a7aa23c6372a2e60284e926ee6', class: "utility-button" }, index.h("kritzel-icon", { key: 'b0599e4d11c1fefa48b2026ee5d1f74efcd76cd3', name: "delete", onClick: () => this.delete.emit() }))));
6183
+ return (index.h(index.Host, { key: 'c3ab0aa976a4ce2a4b412ebcb808681510658ab7' }, index.h("button", { key: '7a6c9ee6b74bd38bfa085508e0820ed121ab547a', class: "utility-button", onClick: event => this.handleUndo(event) }, index.h("kritzel-icon", { key: 'dd12ae17f1b64e8c98c7abe3b0f31db69793b1fb', name: "undo" })), index.h("button", { key: '0fbe8ac953da6cb6cf07527f0813fcc101dc5108', class: "utility-button", onClick: event => this.handleRedo(event) }, index.h("kritzel-icon", { key: '4abe227b018d051132c22ce009f4518120d83d5b', name: "redo" })), index.h("div", { key: '952083fd2b3339cddfaf7d0c6193d1e41e8d845d', class: "utility-separator" }), index.h("button", { key: 'd2da5474bebaceb968bdc81b436b997b14125e4f', class: "utility-button" }, index.h("kritzel-icon", { key: '4eee54431ff8af555018aa9c1e575f0fbc2cb215', name: "delete", onClick: () => this.delete.emit() }))));
6112
6184
  }
6113
6185
  };
6114
6186
  KritzelUtilityPanel.style = kritzelUtilityPanelCss;