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.
Files changed (117) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +858 -820
  2. package/dist/cjs/kritzel-brush-style_18.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 +2 -47
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/key.handler.js +1 -1
  8. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/move.handler.js +62 -55
  10. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  12. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  14. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  15. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  16. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  17. package/dist/collection/classes/objects/base-object.class.js +3 -0
  18. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  19. package/dist/collection/classes/objects/text.class.js +11 -1
  20. package/dist/collection/classes/objects/text.class.js.map +1 -1
  21. package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
  22. package/dist/collection/classes/registries/tool.registry.js.map +1 -0
  23. package/dist/collection/classes/store.class.js +3 -54
  24. package/dist/collection/classes/store.class.js.map +1 -1
  25. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  26. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  28. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  29. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  30. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  33. package/dist/collection/classes/tools/selection-tool.class.js +94 -74
  34. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  35. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  36. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  37. package/dist/collection/classes/viewport.class.js +76 -69
  38. package/dist/collection/classes/viewport.class.js.map +1 -1
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  40. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -2
  41. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  42. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  43. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +69 -121
  44. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  45. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +1 -1
  46. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
  47. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  48. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  49. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  50. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  51. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  52. package/dist/collection/configs/default-engine-state.js +53 -0
  53. package/dist/collection/configs/default-engine-state.js.map +1 -0
  54. package/dist/collection/helpers/devices.helper.js +6 -0
  55. package/dist/collection/helpers/devices.helper.js.map +1 -0
  56. package/dist/collection/helpers/event.helper.js +43 -20
  57. package/dist/collection/helpers/event.helper.js.map +1 -1
  58. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  59. package/dist/collection/interfaces/object.interface.js.map +1 -1
  60. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  61. package/dist/components/kritzel-context-menu.js +1 -1
  62. package/dist/components/kritzel-controls.js +1 -1
  63. package/dist/components/kritzel-editor.js +6 -6
  64. package/dist/components/kritzel-editor.js.map +1 -1
  65. package/dist/components/kritzel-engine.js +1 -1
  66. package/dist/components/{p-CesjDLvT.js → p-7Ns73-wN.js} +237 -206
  67. package/dist/components/p-7Ns73-wN.js.map +1 -0
  68. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  69. package/dist/components/p-BmAloSfd.js.map +1 -0
  70. package/dist/components/{p-_3gCPfqz.js → p-BmrZipyu.js} +621 -622
  71. package/dist/components/p-BmrZipyu.js.map +1 -0
  72. package/dist/components/p-CZkSABuJ.js.map +1 -1
  73. package/dist/components/{p-DTcfnx4-.js → p-Ch6TgHX3.js} +18 -8
  74. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  75. package/dist/esm/kritzel-brush-style_18.entry.js +858 -820
  76. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/esm/stencil.js +1 -1
  79. package/dist/stencil/p-c976660c.entry.js +2 -0
  80. package/dist/stencil/p-c976660c.entry.js.map +1 -0
  81. package/dist/stencil/stencil.esm.js +1 -1
  82. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  83. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  84. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  85. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  86. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  87. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  88. package/dist/types/classes/objects/text.class.d.ts +1 -0
  89. package/dist/types/classes/{tool.registry.d.ts → registries/tool.registry.d.ts} +2 -2
  90. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  91. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  92. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  93. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  94. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  95. package/dist/types/classes/viewport.class.d.ts +3 -6
  96. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  97. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  98. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  99. package/dist/types/components.d.ts +0 -2
  100. package/dist/types/configs/default-engine-state.d.ts +2 -0
  101. package/dist/types/helpers/devices.helper.d.ts +3 -0
  102. package/dist/types/helpers/event.helper.d.ts +2 -4
  103. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  104. package/dist/types/interfaces/object.interface.d.ts +1 -0
  105. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  106. package/package.json +1 -1
  107. package/dist/collection/classes/icon-registry.class.js.map +0 -1
  108. package/dist/collection/classes/tool.registry.js.map +0 -1
  109. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  110. package/dist/components/p-CesjDLvT.js.map +0 -1
  111. package/dist/components/p-DTcfnx4-.js.map +0 -1
  112. package/dist/components/p-_3gCPfqz.js.map +0 -1
  113. package/dist/stencil/p-e596d004.entry.js +0 -2
  114. package/dist/stencil/p-e596d004.entry.js.map +0 -1
  115. /package/dist/collection/classes/{icon-registry.class.js → registries/icon-registry.class.js} +0 -0
  116. /package/dist/collection/classes/{tool.registry.js → registries/tool.registry.js} +0 -0
  117. /package/dist/types/classes/{icon-registry.class.d.ts → registries/icon-registry.class.d.ts} +0 -0
@@ -7,7 +7,7 @@ import { KritzelSelectionHandler } from "../handlers/selection.handler";
7
7
  import { KritzelSelectionGroup } from "../objects/selection-group.class";
8
8
  import { KritzelBaseTool } from "./base-tool.class";
9
9
  import { KritzelText } from "../objects/text.class";
10
- import { KritzelToolRegistry } from "../tool.registry";
10
+ import { KritzelToolRegistry } from "../registries/tool.registry";
11
11
  export class KritzelSelectionTool extends KritzelBaseTool {
12
12
  constructor(store) {
13
13
  super(store);
@@ -16,39 +16,103 @@ export class KritzelSelectionTool extends KritzelBaseTool {
16
16
  this.resizeHandler = new KritzelResizeHandler(this._store);
17
17
  this.rotationHandler = new KritzelRotationHandler(this._store);
18
18
  }
19
- handleMouseDown(event) {
20
- if (KritzelEventHelper.isLeftClick(event)) {
21
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
22
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
23
- this._store.state.resizeHandleType = this.getHandleType(event);
24
- const selectedObject = this.getSelectedObject(event);
25
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
26
- if ((selectedObject === null || isDifferentObject) &&
27
- this._store.state.selectionGroup &&
28
- !this._store.state.isResizeHandleSelected &&
29
- !this._store.state.isRotationHandleSelected) {
30
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
19
+ handlePointerDown(event) {
20
+ if (event.pointerType === 'mouse') {
21
+ if (KritzelEventHelper.isLeftClick(event)) {
22
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
23
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
24
+ this._store.state.resizeHandleType = this.getHandleType(event);
25
+ const selectedObject = this.getSelectedObject(event);
26
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
27
+ if ((selectedObject === null || isDifferentObject) &&
28
+ this._store.state.selectionGroup &&
29
+ !this._store.state.isResizeHandleSelected &&
30
+ !this._store.state.isRotationHandleSelected) {
31
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
32
+ }
33
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
34
+ setTimeout(() => {
35
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
36
+ selectedObject.objects[0].onSelectedClick();
37
+ }
38
+ }, 100);
39
+ }
40
+ }
41
+ this.moveHandler.handlePointerDown(event);
42
+ this.selectionHandler.handlePointerDown(event);
43
+ this.resizeHandler.handlePointerDown(event);
44
+ this.rotationHandler.handlePointerDown(event);
45
+ this._store.rerender();
46
+ }
47
+ if (event.pointerType === 'touch') {
48
+ if (this._store.state.isScaling === true) {
49
+ return;
50
+ }
51
+ if (this._store.state.pointers.size === 1) {
52
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
53
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
54
+ this._store.state.resizeHandleType = this.getHandleType(event);
55
+ const selectedObject = this.getSelectedObject(event);
56
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
57
+ if (!this._store.state.selectionGroup && selectedObject) {
58
+ this._store.state.skipContextMenu = true;
59
+ }
60
+ if ((selectedObject === null || isDifferentObject) &&
61
+ this._store.state.selectionGroup &&
62
+ !this._store.state.isResizeHandleSelected &&
63
+ !this._store.state.isRotationHandleSelected) {
64
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
65
+ }
66
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
67
+ setTimeout(() => {
68
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
69
+ selectedObject.objects[0].onSelectedClick();
70
+ }
71
+ }, 100);
72
+ }
31
73
  }
74
+ this.rotationHandler.handlePointerDown(event);
75
+ this.resizeHandler.handlePointerDown(event);
76
+ this.moveHandler.handlePointerDown(event);
77
+ this.selectionHandler.handlePointerDown(event);
32
78
  }
33
- this.moveHandler.handleMouseDown(event);
34
- this.selectionHandler.handleMouseDown(event);
35
- this.resizeHandler.handleMouseDown(event);
36
- this.rotationHandler.handleMouseDown(event);
37
- this._store.rerender();
38
79
  }
39
- handleMouseMove(event) {
40
- this.moveHandler.handleMouseMove(event);
41
- this.selectionHandler.handleMouseMove(event);
42
- this.resizeHandler.handleMouseMove(event);
43
- this.rotationHandler.handleMouseMove(event);
44
- this._store.rerender();
80
+ handlePointerMove(event) {
81
+ if (event.pointerType === 'mouse') {
82
+ this.moveHandler.handlePointerMove(event);
83
+ this.selectionHandler.handlePointerMove(event);
84
+ this.resizeHandler.handlePointerMove(event);
85
+ this.rotationHandler.handlePointerMove(event);
86
+ this._store.rerender();
87
+ }
88
+ if (event.pointerType === 'touch') {
89
+ if (this._store.state.isScaling === true) {
90
+ return;
91
+ }
92
+ this.rotationHandler.handlePointerMove(event);
93
+ this.resizeHandler.handlePointerMove(event);
94
+ this.moveHandler.handlePointerMove(event);
95
+ this.selectionHandler.handlePointerMove(event);
96
+ this._store.rerender();
97
+ }
45
98
  }
46
- handleMouseUp(event) {
47
- this.moveHandler.handleMouseUp(event);
48
- this.selectionHandler.handleMouseUp(event);
49
- this.resizeHandler.handleMouseUp(event);
50
- this.rotationHandler.handleMouseUp(event);
51
- this._store.rerender();
99
+ handlePointerUp(event) {
100
+ if (event.pointerType === 'mouse') {
101
+ this.moveHandler.handlePointerUp(event);
102
+ this.selectionHandler.handlePointerUp(event);
103
+ this.resizeHandler.handlePointerUp(event);
104
+ this.rotationHandler.handlePointerUp(event);
105
+ this._store.rerender();
106
+ }
107
+ if (event.pointerType === 'touch') {
108
+ if (this._store.state.isScaling === true) {
109
+ return;
110
+ }
111
+ this.rotationHandler.handlePointerUp(event);
112
+ this.resizeHandler.handlePointerUp(event);
113
+ this.moveHandler.handlePointerUp(event);
114
+ this.selectionHandler.handlePointerUp(event);
115
+ }
52
116
  }
53
117
  handleDoubleClick(event) {
54
118
  var _a;
@@ -80,50 +144,6 @@ export class KritzelSelectionTool extends KritzelBaseTool {
80
144
  }, 300);
81
145
  }
82
146
  }
83
- handleTouchStart(event) {
84
- if (this._store.state.isScaling === true) {
85
- return;
86
- }
87
- if (this._store.state.touchCount === 1) {
88
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
89
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
90
- this._store.state.resizeHandleType = this.getHandleType(event);
91
- const selectedObject = this.getSelectedObject(event);
92
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
93
- if (!this._store.state.selectionGroup && selectedObject) {
94
- this._store.state.skipContextMenu = true;
95
- }
96
- if ((selectedObject === null || isDifferentObject) &&
97
- this._store.state.selectionGroup &&
98
- !this._store.state.isResizeHandleSelected &&
99
- !this._store.state.isRotationHandleSelected) {
100
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
101
- }
102
- }
103
- this.rotationHandler.handleTouchStart(event);
104
- this.resizeHandler.handleTouchStart(event);
105
- this.moveHandler.handleTouchStart(event);
106
- this.selectionHandler.handleTouchStart(event);
107
- }
108
- handleTouchMove(event) {
109
- if (this._store.state.isScaling === true) {
110
- return;
111
- }
112
- this.rotationHandler.handleTouchMove(event);
113
- this.resizeHandler.handleTouchMove(event);
114
- this.moveHandler.handleTouchMove(event);
115
- this.selectionHandler.handleTouchMove(event);
116
- this._store.rerender();
117
- }
118
- handleTouchEnd(event) {
119
- if (this._store.state.isScaling === true) {
120
- return;
121
- }
122
- this.rotationHandler.handleTouchEnd(event);
123
- this.resizeHandler.handleTouchEnd(event);
124
- this.moveHandler.handleTouchEnd(event);
125
- this.selectionHandler.handleTouchEnd(event);
126
- }
127
147
  getSelectedObject(event) {
128
148
  const path = event.composedPath().slice(1);
129
149
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
@@ -1 +1 @@
1
- {"version":3,"file":"selection-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/selection-tool.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,E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AC;IAEO,wBAAwB,CAAC,KAA8B;QAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,EAAmB,CAAC;QAEnD,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { RemoveSelectionGroupCommand } from '../commands/remove-selection-group.command';\r\nimport { KritzelMoveHandler } from '../handlers/move.handler';\r\nimport { KritzelResizeHandler } from '../handlers/resize.handler';\r\nimport { KritzelRotationHandler } from '../handlers/rotation.handler';\r\nimport { KritzelSelectionHandler } from '../handlers/selection.handler';\r\nimport { KritzelSelectionGroup } from '../objects/selection-group.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { KritzelText } from '../objects/text.class';\r\nimport { KritzelToolRegistry } from '../tool.registry';\r\n\r\nexport class KritzelSelectionTool extends KritzelBaseTool {\r\n selectionHandler: KritzelSelectionHandler;\r\n moveHandler: KritzelMoveHandler;\r\n resizeHandler: KritzelResizeHandler;\r\n rotationHandler: KritzelRotationHandler;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n this.selectionHandler = new KritzelSelectionHandler(this._store);\r\n this.moveHandler = new KritzelMoveHandler(this._store);\r\n this.resizeHandler = new KritzelResizeHandler(this._store);\r\n this.rotationHandler = new KritzelRotationHandler(this._store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isResizeHandleSelected = this.isHandleSelected(event);\r\n this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);\r\n this._store.state.resizeHandleType = this.getHandleType(event);\r\n\r\n const selectedObject = this.getSelectedObject(event);\r\n const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;\r\n\r\n if (\r\n (selectedObject === null || isDifferentObject) &&\r\n this._store.state.selectionGroup &&\r\n !this._store.state.isResizeHandleSelected &&\r\n !this._store.state.isRotationHandleSelected\r\n ) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n }\r\n }\r\n\r\n this.moveHandler.handleMouseDown(event);\r\n this.selectionHandler.handleMouseDown(event);\r\n this.resizeHandler.handleMouseDown(event);\r\n this.rotationHandler.handleMouseDown(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n handleMouseMove(event: MouseEvent): void {\r\n this.moveHandler.handleMouseMove(event);\r\n this.selectionHandler.handleMouseMove(event);\r\n this.resizeHandler.handleMouseMove(event);\r\n this.rotationHandler.handleMouseMove(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n handleMouseUp(event: MouseEvent): void {\r\n this.moveHandler.handleMouseUp(event);\r\n this.selectionHandler.handleMouseUp(event);\r\n this.resizeHandler.handleMouseUp(event);\r\n this.rotationHandler.handleMouseUp(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n handleDoubleClick(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.selectionGroup?.objects.length === 1) {\r\n const selectedObject = this._store.state.selectionGroup.objects[0];\r\n\r\n if (selectedObject instanceof KritzelText) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));\r\n this._store.state.activeText = selectedObject;\r\n\r\n setTimeout(() => {\r\n selectedObject.focus();\r\n }, 300);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handleDoubleTap(event: TouchEvent): void {\r\n const selectionGroup = this.getSelectedObject(event);\r\n \r\n if (!selectionGroup || selectionGroup.objects.length !== 1) {\r\n return;\r\n }\r\n\r\n const selectedObject = selectionGroup.objects[0];\r\n\r\n if (selectedObject instanceof KritzelText) {\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));\r\n this._store.state.activeText = selectedObject;\r\n\r\n setTimeout(() => {\r\n selectedObject.focus();\r\n }, 300);\r\n }\r\n }\r\n\r\n handleTouchStart(event: TouchEvent): void {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n if (this._store.state.touchCount === 1) {\r\n this._store.state.isResizeHandleSelected = this.isHandleSelected(event);\r\n this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);\r\n this._store.state.resizeHandleType = this.getHandleType(event);\r\n\r\n const selectedObject = this.getSelectedObject(event);\r\n const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;\r\n\r\n if (!this._store.state.selectionGroup && selectedObject) {\r\n this._store.state.skipContextMenu = true;\r\n }\r\n\r\n if (\r\n (selectedObject === null || isDifferentObject) &&\r\n this._store.state.selectionGroup &&\r\n !this._store.state.isResizeHandleSelected &&\r\n !this._store.state.isRotationHandleSelected\r\n ) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n }\r\n }\r\n\r\n this.rotationHandler.handleTouchStart(event);\r\n this.resizeHandler.handleTouchStart(event);\r\n this.moveHandler.handleTouchStart(event);\r\n this.selectionHandler.handleTouchStart(event);\r\n }\r\n\r\n handleTouchMove(event: TouchEvent): void {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n this.rotationHandler.handleTouchMove(event);\r\n this.resizeHandler.handleTouchMove(event);\r\n this.moveHandler.handleTouchMove(event);\r\n this.selectionHandler.handleTouchMove(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n handleTouchEnd(event: TouchEvent): void {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n this.rotationHandler.handleTouchEnd(event);\r\n this.resizeHandler.handleTouchEnd(event);\r\n this.moveHandler.handleTouchEnd(event);\r\n this.selectionHandler.handleTouchEnd(event);\r\n }\r\n\r\n private getSelectedObject(event: MouseEvent | TouchEvent): KritzelSelectionGroup | null {\r\n \r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (!object) {\r\n return null;\r\n }\r\n\r\n if (object instanceof KritzelSelectionGroup) {\r\n return object;\r\n } else {\r\n const group = KritzelSelectionGroup.create(this._store);\r\n group.translateX = 0;\r\n group.translateY = 0;\r\n group.addOrRemove(object);\r\n return group;\r\n }\r\n }\r\n\r\n private getHandleType(event: MouseEvent | TouchEvent): KritzelHandleType {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const point = event instanceof TouchEvent ? event.touches[0] : event;\r\n const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);\r\n\r\n const handle = elementAtPoint.closest('.resize-handle-overlay') as HTMLElement | null;\r\n\r\n return handle?.classList[1] as KritzelHandleType;\r\n }\r\n\r\n private isHandleSelected(event: MouseEvent | TouchEvent): boolean {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return false;\r\n\r\n const point = event instanceof TouchEvent ? event.touches[0] : event;\r\n const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);\r\n\r\n return elementAtPoint?.classList.contains('resize-handle-overlay');\r\n }\r\n\r\n private isRotationHandleSelected(event: MouseEvent | TouchEvent): boolean {\r\n const path = event.composedPath() as HTMLElement[];\r\n\r\n return !!path.find(element => element.classList && element.classList.contains('rotation-handle-overlay'));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"selection-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/selection-tool.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,2B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QAEjF,OAAO,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IACrE,CAAC;IAEO,wBAAwB,CAAC,KAA8B;QAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,EAAmB,CAAC;QAEnD,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { RemoveSelectionGroupCommand } from '../commands/remove-selection-group.command';\r\nimport { KritzelMoveHandler } from '../handlers/move.handler';\r\nimport { KritzelResizeHandler } from '../handlers/resize.handler';\r\nimport { KritzelRotationHandler } from '../handlers/rotation.handler';\r\nimport { KritzelSelectionHandler } from '../handlers/selection.handler';\r\nimport { KritzelSelectionGroup } from '../objects/selection-group.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { KritzelText } from '../objects/text.class';\r\nimport { KritzelToolRegistry } from '../registries/tool.registry';\r\n\r\nexport class KritzelSelectionTool extends KritzelBaseTool {\r\n selectionHandler: KritzelSelectionHandler;\r\n moveHandler: KritzelMoveHandler;\r\n resizeHandler: KritzelResizeHandler;\r\n rotationHandler: KritzelRotationHandler;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n this.selectionHandler = new KritzelSelectionHandler(this._store);\r\n this.moveHandler = new KritzelMoveHandler(this._store);\r\n this.resizeHandler = new KritzelResizeHandler(this._store);\r\n this.rotationHandler = new KritzelRotationHandler(this._store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n this._store.state.isResizeHandleSelected = this.isHandleSelected(event);\r\n this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);\r\n this._store.state.resizeHandleType = this.getHandleType(event);\r\n\r\n const selectedObject = this.getSelectedObject(event);\r\n const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;\r\n\r\n if (\r\n (selectedObject === null || isDifferentObject) &&\r\n this._store.state.selectionGroup &&\r\n !this._store.state.isResizeHandleSelected &&\r\n !this._store.state.isRotationHandleSelected\r\n ) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n }\r\n\r\n if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {\r\n setTimeout(() => {\r\n if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {\r\n selectedObject.objects[0].onSelectedClick();\r\n }\r\n }, 100);\r\n }\r\n }\r\n\r\n this.moveHandler.handlePointerDown(event);\r\n this.selectionHandler.handlePointerDown(event);\r\n this.resizeHandler.handlePointerDown(event);\r\n this.rotationHandler.handlePointerDown(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n if (this._store.state.pointers.size === 1) {\r\n this._store.state.isResizeHandleSelected = this.isHandleSelected(event);\r\n this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);\r\n this._store.state.resizeHandleType = this.getHandleType(event);\r\n\r\n const selectedObject = this.getSelectedObject(event);\r\n const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;\r\n\r\n if (!this._store.state.selectionGroup && selectedObject) {\r\n this._store.state.skipContextMenu = true;\r\n }\r\n\r\n if (\r\n (selectedObject === null || isDifferentObject) &&\r\n this._store.state.selectionGroup &&\r\n !this._store.state.isResizeHandleSelected &&\r\n !this._store.state.isRotationHandleSelected\r\n ) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n }\r\n\r\n if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {\r\n setTimeout(() => {\r\n if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {\r\n selectedObject.objects[0].onSelectedClick();\r\n }\r\n }, 100);\r\n }\r\n }\r\n\r\n this.rotationHandler.handlePointerDown(event);\r\n this.resizeHandler.handlePointerDown(event);\r\n this.moveHandler.handlePointerDown(event);\r\n this.selectionHandler.handlePointerDown(event);\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n this.moveHandler.handlePointerMove(event);\r\n this.selectionHandler.handlePointerMove(event);\r\n this.resizeHandler.handlePointerMove(event);\r\n this.rotationHandler.handlePointerMove(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n this.rotationHandler.handlePointerMove(event);\r\n this.resizeHandler.handlePointerMove(event);\r\n this.moveHandler.handlePointerMove(event);\r\n this.selectionHandler.handlePointerMove(event);\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n this.moveHandler.handlePointerUp(event);\r\n this.selectionHandler.handlePointerUp(event);\r\n this.resizeHandler.handlePointerUp(event);\r\n this.rotationHandler.handlePointerUp(event);\r\n\r\n this._store.rerender();\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isScaling === true) {\r\n return;\r\n }\r\n\r\n this.rotationHandler.handlePointerUp(event);\r\n this.resizeHandler.handlePointerUp(event);\r\n this.moveHandler.handlePointerUp(event);\r\n this.selectionHandler.handlePointerUp(event);\r\n }\r\n }\r\n\r\n handleDoubleClick(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.selectionGroup?.objects.length === 1) {\r\n const selectedObject = this._store.state.selectionGroup.objects[0];\r\n\r\n if (selectedObject instanceof KritzelText) {\r\n this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));\r\n this._store.state.activeText = selectedObject;\r\n\r\n setTimeout(() => {\r\n selectedObject.focus();\r\n }, 300);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handleDoubleTap(event: PointerEvent): void {\r\n const selectionGroup = this.getSelectedObject(event);\r\n\r\n if (!selectionGroup || selectionGroup.objects.length !== 1) {\r\n return;\r\n }\r\n\r\n const selectedObject = selectionGroup.objects[0];\r\n\r\n if (selectedObject instanceof KritzelText) {\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));\r\n this._store.state.activeText = selectedObject;\r\n\r\n setTimeout(() => {\r\n selectedObject.focus();\r\n }, 300);\r\n }\r\n }\r\n\r\n private getSelectedObject(event: MouseEvent | TouchEvent): KritzelSelectionGroup | null {\r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (!object) {\r\n return null;\r\n }\r\n\r\n if (object instanceof KritzelSelectionGroup) {\r\n return object;\r\n } else {\r\n const group = KritzelSelectionGroup.create(this._store);\r\n group.translateX = 0;\r\n group.translateY = 0;\r\n group.addOrRemove(object);\r\n return group;\r\n }\r\n }\r\n\r\n private getHandleType(event: MouseEvent | TouchEvent): KritzelHandleType {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return;\r\n\r\n const point = event instanceof TouchEvent ? event.touches[0] : event;\r\n const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);\r\n\r\n const handle = elementAtPoint.closest('.resize-handle-overlay') as HTMLElement | null;\r\n\r\n return handle?.classList[1] as KritzelHandleType;\r\n }\r\n\r\n private isHandleSelected(event: MouseEvent | TouchEvent): boolean {\r\n const shadowRoot = this._store.state.host?.shadowRoot;\r\n if (!shadowRoot) return false;\r\n\r\n const point = event instanceof TouchEvent ? event.touches[0] : event;\r\n const elementAtPoint = shadowRoot.elementFromPoint(point.clientX, point.clientY);\r\n\r\n return elementAtPoint?.classList.contains('resize-handle-overlay');\r\n }\r\n\r\n private isRotationHandleSelected(event: MouseEvent | TouchEvent): boolean {\r\n const path = event.composedPath() as HTMLElement[];\r\n\r\n return !!path.find(element => element.classList && element.classList.contains('rotation-handle-overlay'));\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@ import { KritzelText } from "../objects/text.class";
2
2
  import { KritzelBaseTool } from "./base-tool.class";
3
3
  import { AddObjectCommand } from "../commands/add-object.command";
4
4
  import { KritzelEventHelper } from "../../helpers/event.helper";
5
- import { KritzelToolRegistry } from "../tool.registry";
5
+ import { KritzelToolRegistry } from "../registries/tool.registry";
6
6
  import { KritzelKeyboardHelper } from "../../helpers/keyboard.helper";
7
7
  export class KritzelTextTool extends KritzelBaseTool {
8
8
  constructor(store) {
@@ -28,80 +28,83 @@ export class KritzelTextTool extends KritzelBaseTool {
28
28
  '#800080',
29
29
  ];
30
30
  }
31
- handleMouseDown(event) {
32
- const path = event.composedPath().slice(1);
33
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
34
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
35
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
36
- this._store.state.activeText = object;
37
- object.focus();
38
- return;
31
+ handlePointerDown(event) {
32
+ if (event.pointerType === 'mouse') {
33
+ const path = event.composedPath().slice(1);
34
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
35
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
36
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
37
+ this._store.state.activeText = object;
38
+ object.focus();
39
+ return;
40
+ }
41
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
42
+ object.focus();
43
+ return;
44
+ }
45
+ if (this._store.state.activeText !== null) {
46
+ this._store.resetActiveText();
47
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
48
+ return;
49
+ }
50
+ if (KritzelEventHelper.isLeftClick(event) === false) {
51
+ return;
52
+ }
53
+ const clientX = event.clientX - this._store.offsetX;
54
+ const clientY = event.clientY - this._store.offsetY;
55
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
56
+ text.fontColor = this.fontColor;
57
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
58
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
59
+ text.zIndex = this._store.currentZIndex;
60
+ this._store.state.activeText = text;
61
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
39
62
  }
40
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
41
- object.focus();
42
- return;
63
+ if (event.pointerType === 'touch') {
64
+ const activePointers = Array.from(this._store.state.pointers.values());
65
+ const path = event.composedPath().slice(1);
66
+ const objectElement = path.find(element => element.classList && element.classList.contains('object'));
67
+ const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
68
+ if (this._store.state.activeText === null && object && object instanceof KritzelText) {
69
+ this._store.state.activeText = object;
70
+ object.focus();
71
+ return;
72
+ }
73
+ if (this._store.state.activeText !== null && object instanceof KritzelText) {
74
+ object.focus();
75
+ return;
76
+ }
77
+ if (this._store.state.activeText !== null) {
78
+ this._store.resetActiveText();
79
+ this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
80
+ return;
81
+ }
82
+ if (activePointers.length > 1) {
83
+ return;
84
+ }
85
+ KritzelKeyboardHelper.disableInteractiveWidget();
86
+ const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
87
+ const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
88
+ const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
89
+ text.fontColor = this.fontColor;
90
+ text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
91
+ text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
92
+ text.zIndex = this._store.currentZIndex;
93
+ this._store.state.activeText = text;
94
+ this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
43
95
  }
44
- if (this._store.state.activeText !== null) {
45
- this._store.resetActiveText();
46
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
47
- return;
48
- }
49
- if (KritzelEventHelper.isLeftClick(event) === false) {
50
- return;
51
- }
52
- const clientX = event.clientX - this._store.offsetX;
53
- const clientY = event.clientY - this._store.offsetY;
54
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
55
- text.fontColor = this.fontColor;
56
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
57
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
58
- text.zIndex = this._store.currentZIndex;
59
- text.adjustTextareaSize();
60
- this._store.state.activeText = text;
61
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
62
- }
63
- handleMouseUp(_event) {
64
- var _a, _b;
65
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
66
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
67
96
  }
68
- handleTouchStart(event) {
69
- const path = event.composedPath().slice(1);
70
- const objectElement = path.find(element => element.classList && element.classList.contains('object'));
71
- const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
72
- if (this._store.state.activeText === null && object && object instanceof KritzelText) {
73
- this._store.state.activeText = object;
74
- object.focus();
75
- return;
97
+ handlePointerUp(event) {
98
+ var _a, _b, _c, _d;
99
+ if (event.pointerType === 'mouse') {
100
+ (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
101
+ (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
76
102
  }
77
- if (this._store.state.activeText !== null && object instanceof KritzelText) {
78
- object.focus();
79
- return;
103
+ if (event.pointerType === 'touch') {
104
+ (_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
105
+ (_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
106
+ KritzelKeyboardHelper.enableInteractiveWidget();
80
107
  }
81
- if (this._store.state.activeText !== null) {
82
- this._store.resetActiveText();
83
- this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
84
- return;
85
- }
86
- if (this._store.state.touchCount > 1) {
87
- return;
88
- }
89
- KritzelKeyboardHelper.disableInteractiveWidget();
90
- const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);
91
- const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);
92
- const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
93
- text.fontColor = this.fontColor;
94
- text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
95
- text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
96
- text.zIndex = this._store.currentZIndex;
97
- this._store.state.activeText = text;
98
- this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
99
- }
100
- handleTouchEnd(_event) {
101
- var _a, _b;
102
- (_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.focus();
103
- (_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.adjustTextareaSize();
104
- KritzelKeyboardHelper.enableInteractiveWidget();
105
108
  }
106
109
  }
107
110
  //# sourceMappingURL=text-tool.class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/text-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,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,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACpF,CAAC;IAGD,cAAc,CAAC,MAAkB;;QAC/B,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,EAAE,CAAC;QACtC,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,0CAAE,kBAAkB,EAAE,CAAC;QAEnD,qBAAqB,CAAC,uBAAuB,EAAE,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { KritzelText } from '../objects/text.class';\r\nimport { KritzelStore } from '../store.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { AddObjectCommand } from '../commands/add-object.command';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelToolRegistry } from '../tool.registry';\r\nimport { KritzelKeyboardHelper } from '../../helpers/keyboard.helper';\r\n\r\nexport class KritzelTextTool extends KritzelBaseTool {\r\n fontFamily: string = 'Arial';\r\n fontSize: number = 16;\r\n fontColor: string = '#000000';\r\n\r\n palette: string[] = [\r\n '#000000',\r\n '#FFFFFF',\r\n '#FF0000',\r\n '#00FF00',\r\n '#0000FF',\r\n '#FFFF00',\r\n '#FF00FF',\r\n '#00FFFF',\r\n '#808080',\r\n '#C0C0C0',\r\n '#800000',\r\n '#008000',\r\n '#000080',\r\n '#808000',\r\n '#800080',\r\n ];\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent): void {\r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (this._store.state.activeText === null && object && object instanceof KritzelText) {\r\n this._store.state.activeText = object;\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null && object instanceof KritzelText) {\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null) {\r\n this._store.resetActiveText();\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n return;\r\n }\r\n\r\n if (KritzelEventHelper.isLeftClick(event) === false) {\r\n return;\r\n }\r\n\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);\r\n\r\n text.fontColor = this.fontColor;\r\n text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n text.zIndex = this._store.currentZIndex;\r\n\r\n text.adjustTextareaSize();\r\n\r\n this._store.state.activeText = text;\r\n\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n this._store.state.activeText?.focus();\r\n this._store.state.activeText?.adjustTextareaSize();\r\n }\r\n\r\n handleTouchStart(event: TouchEvent): void {\r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (this._store.state.activeText === null && object && object instanceof KritzelText) {\r\n this._store.state.activeText = object;\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null && object instanceof KritzelText) {\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null) {\r\n this._store.resetActiveText();\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n return;\r\n }\r\n\r\n if (this._store.state.touchCount > 1) {\r\n return;\r\n }\r\n\r\n KritzelKeyboardHelper.disableInteractiveWidget()\r\n\r\n const clientX = Math.round(event.touches[0].clientX - this._store.offsetX);\r\n const clientY = Math.round(event.touches[0].clientY - this._store.offsetY);\r\n const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);\r\n\r\n text.fontColor = this.fontColor;\r\n text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n text.zIndex = this._store.currentZIndex;\r\n\r\n this._store.state.activeText = text;\r\n\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));\r\n }\r\n\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n this._store.state.activeText?.focus();\r\n this._store.state.activeText?.adjustTextareaSize();\r\n\r\n KritzelKeyboardHelper.enableInteractiveWidget();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"text-tool.class.js","sourceRoot":"","sources":["../../../src/classes/tools/text-tool.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAuBlD,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAvBf,eAAU,GAAW,OAAO,CAAC;QAC7B,aAAQ,GAAW,EAAE,CAAC;QACtB,cAAS,GAAW,SAAS,CAAC;QAE9B,YAAO,GAAa;YAClB,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;SACV,CAAC;IAIF,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC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ects/text.class';\r\nimport { KritzelStore } from '../store.class';\r\nimport { KritzelBaseTool } from './base-tool.class';\r\nimport { AddObjectCommand } from '../commands/add-object.command';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelToolRegistry } from '../registries/tool.registry';\r\nimport { KritzelKeyboardHelper } from '../../helpers/keyboard.helper';\r\n\r\nexport class KritzelTextTool extends KritzelBaseTool {\r\n fontFamily: string = 'Arial';\r\n fontSize: number = 16;\r\n fontColor: string = '#000000';\r\n\r\n palette: string[] = [\r\n '#000000',\r\n '#FFFFFF',\r\n '#FF0000',\r\n '#00FF00',\r\n '#0000FF',\r\n '#FFFF00',\r\n '#FF00FF',\r\n '#00FFFF',\r\n '#808080',\r\n '#C0C0C0',\r\n '#800000',\r\n '#008000',\r\n '#000080',\r\n '#808000',\r\n '#800080',\r\n ];\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (this._store.state.activeText === null && object && object instanceof KritzelText) {\r\n this._store.state.activeText = object;\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null && object instanceof KritzelText) {\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null) {\r\n this._store.resetActiveText();\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n return;\r\n }\r\n\r\n if (KritzelEventHelper.isLeftClick(event) === false) {\r\n return;\r\n }\r\n\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);\r\n\r\n text.fontColor = this.fontColor;\r\n text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n text.zIndex = this._store.currentZIndex;\r\n\r\n this._store.state.activeText = text;\r\n\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n\r\n const path = event.composedPath().slice(1) as HTMLElement[];\r\n const objectElement = path.find(element => element.classList && element.classList.contains('object'));\r\n const object = this._store.findObjectById(objectElement?.id);\r\n\r\n if (this._store.state.activeText === null && object && object instanceof KritzelText) {\r\n this._store.state.activeText = object;\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null && object instanceof KritzelText) {\r\n object.focus();\r\n return;\r\n }\r\n\r\n if (this._store.state.activeText !== null) {\r\n this._store.resetActiveText();\r\n this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));\r\n return;\r\n }\r\n\r\n if (activePointers.length > 1) {\r\n return;\r\n }\r\n\r\n KritzelKeyboardHelper.disableInteractiveWidget();\r\n\r\n const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);\r\n const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);\r\n const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);\r\n\r\n text.fontColor = this.fontColor;\r\n text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n text.zIndex = this._store.currentZIndex;\r\n\r\n this._store.state.activeText = text;\r\n\r\n this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n this._store.state.activeText?.adjustTextareaSize();\r\n this._store.state.activeText?.focus();\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n this._store.state.activeText?.adjustTextareaSize();\r\n this._store.state.activeText?.focus();\r\n \r\n KritzelKeyboardHelper.enableInteractiveWidget();\r\n }\r\n }\r\n}\r\n"]}