js-draw 1.20.3 → 1.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. package/LICENSE +1 -1
  2. package/dist/Editor.css +134 -26
  3. package/dist/bundle.js +2 -2
  4. package/dist/bundledStyles.js +1 -1
  5. package/dist/cjs/Editor.d.ts +27 -6
  6. package/dist/cjs/Editor.js +30 -8
  7. package/dist/cjs/SVGLoader/SVGLoader.js +2 -2
  8. package/dist/cjs/Viewport.d.ts +2 -2
  9. package/dist/cjs/commands/Command.d.ts +5 -0
  10. package/dist/cjs/commands/Command.js +5 -0
  11. package/dist/cjs/commands/SerializableCommand.d.ts +7 -0
  12. package/dist/cjs/commands/SerializableCommand.js +9 -0
  13. package/dist/cjs/dialogs/makeAboutDialog.d.ts +1 -1
  14. package/dist/cjs/dialogs/makeAboutDialog.js +10 -25
  15. package/dist/cjs/dialogs/makeMessageDialog.d.ts +11 -0
  16. package/dist/cjs/dialogs/makeMessageDialog.js +56 -0
  17. package/dist/cjs/image/EditorImage.d.ts +15 -1
  18. package/dist/cjs/image/EditorImage.js +15 -5
  19. package/dist/cjs/inputEvents.d.ts +10 -2
  20. package/dist/cjs/inputEvents.js +1 -0
  21. package/dist/cjs/localizations/es.js +3 -0
  22. package/dist/cjs/rendering/Display.d.ts +1 -0
  23. package/dist/cjs/rendering/Display.js +1 -0
  24. package/dist/cjs/rendering/TextRenderingStyle.d.ts +7 -6
  25. package/dist/cjs/rendering/TextRenderingStyle.js +1 -0
  26. package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +12 -3
  27. package/dist/cjs/rendering/renderers/CanvasRenderer.js +15 -2
  28. package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +1 -1
  29. package/dist/cjs/testing/firstElementAncestorOfNode.d.ts +1 -1
  30. package/dist/cjs/testing/firstElementAncestorOfNode.js +1 -1
  31. package/dist/cjs/testing/sendPenEvent.d.ts +2 -2
  32. package/dist/cjs/testing/sendTouchEvent.d.ts +2 -2
  33. package/dist/cjs/toolbar/AbstractToolbar.d.ts +6 -1
  34. package/dist/cjs/toolbar/AbstractToolbar.js +6 -1
  35. package/dist/cjs/toolbar/IconProvider.d.ts +1 -1
  36. package/dist/cjs/toolbar/IconProvider.js +6 -1
  37. package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +8 -0
  38. package/dist/cjs/toolbar/widgets/BaseWidget.js +8 -0
  39. package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
  40. package/dist/cjs/toolbar/widgets/HandToolWidget.js +1 -0
  41. package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +6 -0
  42. package/dist/cjs/toolbar/widgets/PenToolWidget.js +5 -0
  43. package/dist/cjs/types.d.ts +5 -0
  44. package/dist/cjs/types.js +1 -0
  45. package/dist/cjs/util/ClipboardHandler.d.ts +9 -1
  46. package/dist/cjs/util/ClipboardHandler.js +82 -24
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/mjs/Editor.d.ts +27 -6
  49. package/dist/mjs/Editor.mjs +31 -9
  50. package/dist/mjs/SVGLoader/SVGLoader.mjs +2 -2
  51. package/dist/mjs/Viewport.d.ts +2 -2
  52. package/dist/mjs/commands/Command.d.ts +5 -0
  53. package/dist/mjs/commands/Command.mjs +5 -0
  54. package/dist/mjs/commands/SerializableCommand.d.ts +7 -0
  55. package/dist/mjs/commands/SerializableCommand.mjs +9 -0
  56. package/dist/mjs/dialogs/makeAboutDialog.d.ts +1 -1
  57. package/dist/mjs/dialogs/makeAboutDialog.mjs +7 -25
  58. package/dist/mjs/dialogs/makeMessageDialog.d.ts +11 -0
  59. package/dist/mjs/dialogs/makeMessageDialog.mjs +51 -0
  60. package/dist/mjs/image/EditorImage.d.ts +15 -1
  61. package/dist/mjs/image/EditorImage.mjs +15 -5
  62. package/dist/mjs/inputEvents.d.ts +10 -2
  63. package/dist/mjs/inputEvents.mjs +1 -0
  64. package/dist/mjs/localizations/es.mjs +3 -0
  65. package/dist/mjs/rendering/Display.d.ts +1 -0
  66. package/dist/mjs/rendering/Display.mjs +1 -0
  67. package/dist/mjs/rendering/TextRenderingStyle.d.ts +7 -6
  68. package/dist/mjs/rendering/TextRenderingStyle.mjs +1 -0
  69. package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +12 -3
  70. package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +15 -2
  71. package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +1 -1
  72. package/dist/mjs/testing/firstElementAncestorOfNode.d.ts +1 -1
  73. package/dist/mjs/testing/firstElementAncestorOfNode.mjs +1 -1
  74. package/dist/mjs/testing/sendPenEvent.d.ts +2 -2
  75. package/dist/mjs/testing/sendTouchEvent.d.ts +2 -2
  76. package/dist/mjs/toolbar/AbstractToolbar.d.ts +6 -1
  77. package/dist/mjs/toolbar/AbstractToolbar.mjs +6 -1
  78. package/dist/mjs/toolbar/IconProvider.d.ts +1 -1
  79. package/dist/mjs/toolbar/IconProvider.mjs +6 -1
  80. package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +8 -0
  81. package/dist/mjs/toolbar/widgets/BaseWidget.mjs +8 -0
  82. package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
  83. package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +1 -0
  84. package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +6 -0
  85. package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +5 -0
  86. package/dist/mjs/types.d.ts +5 -0
  87. package/dist/mjs/types.mjs +1 -0
  88. package/dist/mjs/util/ClipboardHandler.d.ts +9 -1
  89. package/dist/mjs/util/ClipboardHandler.mjs +82 -24
  90. package/dist/mjs/version.mjs +1 -1
  91. package/package.json +8 -9
  92. package/src/dialogs/dialogs.scss +9 -21
  93. package/src/dialogs/makeAboutDialog.scss +13 -33
  94. package/src/dialogs/makeMessageDialog.scss +46 -0
  95. package/dist/cjs/tools/BaseTool.d.ts +0 -60
  96. package/dist/cjs/tools/BaseTool.js +0 -174
  97. package/dist/cjs/tools/Eraser.d.ts +0 -56
  98. package/dist/cjs/tools/Eraser.js +0 -295
  99. package/dist/cjs/tools/Eraser.test.d.ts +0 -1
  100. package/dist/cjs/tools/FindTool.d.ts +0 -21
  101. package/dist/cjs/tools/FindTool.js +0 -137
  102. package/dist/cjs/tools/FindTool.test.d.ts +0 -1
  103. package/dist/cjs/tools/InputFilter/FunctionMapper.d.ts +0 -12
  104. package/dist/cjs/tools/InputFilter/FunctionMapper.js +0 -21
  105. package/dist/cjs/tools/InputFilter/InputMapper.d.ts +0 -23
  106. package/dist/cjs/tools/InputFilter/InputMapper.js +0 -38
  107. package/dist/cjs/tools/InputFilter/InputPipeline.d.ts +0 -15
  108. package/dist/cjs/tools/InputFilter/InputPipeline.js +0 -54
  109. package/dist/cjs/tools/InputFilter/InputPipeline.test.d.ts +0 -1
  110. package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +0 -29
  111. package/dist/cjs/tools/InputFilter/InputStabilizer.js +0 -181
  112. package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +0 -21
  113. package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +0 -84
  114. package/dist/cjs/tools/PanZoom.d.ts +0 -119
  115. package/dist/cjs/tools/PanZoom.js +0 -508
  116. package/dist/cjs/tools/PanZoom.test.d.ts +0 -1
  117. package/dist/cjs/tools/PasteHandler.d.ts +0 -23
  118. package/dist/cjs/tools/PasteHandler.js +0 -109
  119. package/dist/cjs/tools/Pen.d.ts +0 -53
  120. package/dist/cjs/tools/Pen.js +0 -318
  121. package/dist/cjs/tools/Pen.test.d.ts +0 -1
  122. package/dist/cjs/tools/PipetteTool.d.ts +0 -28
  123. package/dist/cjs/tools/PipetteTool.js +0 -69
  124. package/dist/cjs/tools/ScrollbarTool.d.ts +0 -18
  125. package/dist/cjs/tools/ScrollbarTool.js +0 -85
  126. package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -9
  127. package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +0 -32
  128. package/dist/cjs/tools/SelectionTool/Selection.d.ts +0 -71
  129. package/dist/cjs/tools/SelectionTool/Selection.js +0 -620
  130. package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +0 -62
  131. package/dist/cjs/tools/SelectionTool/SelectionHandle.js +0 -141
  132. package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +0 -40
  133. package/dist/cjs/tools/SelectionTool/SelectionTool.js +0 -494
  134. package/dist/cjs/tools/SelectionTool/SelectionTool.selecting.test.d.ts +0 -1
  135. package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
  136. package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.d.ts +0 -23
  137. package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.js +0 -83
  138. package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +0 -42
  139. package/dist/cjs/tools/SelectionTool/TransformMode.js +0 -155
  140. package/dist/cjs/tools/SelectionTool/types.d.ts +0 -28
  141. package/dist/cjs/tools/SelectionTool/types.js +0 -14
  142. package/dist/cjs/tools/SoundUITool.d.ts +0 -26
  143. package/dist/cjs/tools/SoundUITool.js +0 -171
  144. package/dist/cjs/tools/TextTool.d.ts +0 -36
  145. package/dist/cjs/tools/TextTool.js +0 -285
  146. package/dist/cjs/tools/TextTool.test.d.ts +0 -1
  147. package/dist/cjs/tools/ToolController.d.ts +0 -73
  148. package/dist/cjs/tools/ToolController.js +0 -304
  149. package/dist/cjs/tools/ToolController.test.d.ts +0 -1
  150. package/dist/cjs/tools/ToolEnabledGroup.d.ts +0 -6
  151. package/dist/cjs/tools/ToolEnabledGroup.js +0 -13
  152. package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +0 -16
  153. package/dist/cjs/tools/ToolSwitcherShortcut.js +0 -40
  154. package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +0 -12
  155. package/dist/cjs/tools/ToolbarShortcutHandler.js +0 -34
  156. package/dist/cjs/tools/UndoRedoShortcut.d.ts +0 -8
  157. package/dist/cjs/tools/UndoRedoShortcut.js +0 -27
  158. package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +0 -1
  159. package/dist/cjs/tools/keybindings.d.ts +0 -18
  160. package/dist/cjs/tools/keybindings.js +0 -49
  161. package/dist/cjs/tools/lib.d.ts +0 -14
  162. package/dist/cjs/tools/lib.js +0 -36
  163. package/dist/cjs/tools/localization.d.ts +0 -34
  164. package/dist/cjs/tools/localization.js +0 -36
  165. package/dist/cjs/tools/util/StationaryPenDetector.d.ts +0 -22
  166. package/dist/cjs/tools/util/StationaryPenDetector.js +0 -95
  167. package/dist/mjs/tools/BaseTool.d.ts +0 -60
  168. package/dist/mjs/tools/BaseTool.mjs +0 -172
  169. package/dist/mjs/tools/Eraser.d.ts +0 -56
  170. package/dist/mjs/tools/Eraser.mjs +0 -288
  171. package/dist/mjs/tools/Eraser.test.d.ts +0 -1
  172. package/dist/mjs/tools/FindTool.d.ts +0 -21
  173. package/dist/mjs/tools/FindTool.mjs +0 -131
  174. package/dist/mjs/tools/FindTool.test.d.ts +0 -1
  175. package/dist/mjs/tools/InputFilter/FunctionMapper.d.ts +0 -12
  176. package/dist/mjs/tools/InputFilter/FunctionMapper.mjs +0 -15
  177. package/dist/mjs/tools/InputFilter/InputMapper.d.ts +0 -23
  178. package/dist/mjs/tools/InputFilter/InputMapper.mjs +0 -36
  179. package/dist/mjs/tools/InputFilter/InputPipeline.d.ts +0 -15
  180. package/dist/mjs/tools/InputFilter/InputPipeline.mjs +0 -49
  181. package/dist/mjs/tools/InputFilter/InputPipeline.test.d.ts +0 -1
  182. package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +0 -29
  183. package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +0 -175
  184. package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +0 -21
  185. package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +0 -78
  186. package/dist/mjs/tools/PanZoom.d.ts +0 -119
  187. package/dist/mjs/tools/PanZoom.mjs +0 -501
  188. package/dist/mjs/tools/PanZoom.test.d.ts +0 -1
  189. package/dist/mjs/tools/PasteHandler.d.ts +0 -23
  190. package/dist/mjs/tools/PasteHandler.mjs +0 -103
  191. package/dist/mjs/tools/Pen.d.ts +0 -53
  192. package/dist/mjs/tools/Pen.mjs +0 -312
  193. package/dist/mjs/tools/Pen.test.d.ts +0 -1
  194. package/dist/mjs/tools/PipetteTool.d.ts +0 -28
  195. package/dist/mjs/tools/PipetteTool.mjs +0 -63
  196. package/dist/mjs/tools/ScrollbarTool.d.ts +0 -18
  197. package/dist/mjs/tools/ScrollbarTool.mjs +0 -79
  198. package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -9
  199. package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +0 -26
  200. package/dist/mjs/tools/SelectionTool/Selection.d.ts +0 -71
  201. package/dist/mjs/tools/SelectionTool/Selection.mjs +0 -592
  202. package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +0 -62
  203. package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +0 -137
  204. package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +0 -40
  205. package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +0 -488
  206. package/dist/mjs/tools/SelectionTool/SelectionTool.selecting.test.d.ts +0 -1
  207. package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
  208. package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.d.ts +0 -23
  209. package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.mjs +0 -77
  210. package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +0 -42
  211. package/dist/mjs/tools/SelectionTool/TransformMode.mjs +0 -146
  212. package/dist/mjs/tools/SelectionTool/types.d.ts +0 -28
  213. package/dist/mjs/tools/SelectionTool/types.mjs +0 -11
  214. package/dist/mjs/tools/SoundUITool.d.ts +0 -26
  215. package/dist/mjs/tools/SoundUITool.mjs +0 -165
  216. package/dist/mjs/tools/TextTool.d.ts +0 -36
  217. package/dist/mjs/tools/TextTool.mjs +0 -279
  218. package/dist/mjs/tools/TextTool.test.d.ts +0 -1
  219. package/dist/mjs/tools/ToolController.d.ts +0 -73
  220. package/dist/mjs/tools/ToolController.mjs +0 -275
  221. package/dist/mjs/tools/ToolController.test.d.ts +0 -1
  222. package/dist/mjs/tools/ToolEnabledGroup.d.ts +0 -6
  223. package/dist/mjs/tools/ToolEnabledGroup.mjs +0 -10
  224. package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +0 -16
  225. package/dist/mjs/tools/ToolSwitcherShortcut.mjs +0 -34
  226. package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +0 -12
  227. package/dist/mjs/tools/ToolbarShortcutHandler.mjs +0 -28
  228. package/dist/mjs/tools/UndoRedoShortcut.d.ts +0 -8
  229. package/dist/mjs/tools/UndoRedoShortcut.mjs +0 -21
  230. package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +0 -1
  231. package/dist/mjs/tools/keybindings.d.ts +0 -18
  232. package/dist/mjs/tools/keybindings.mjs +0 -43
  233. package/dist/mjs/tools/lib.d.ts +0 -14
  234. package/dist/mjs/tools/lib.mjs +0 -14
  235. package/dist/mjs/tools/localization.d.ts +0 -34
  236. package/dist/mjs/tools/localization.mjs +0 -33
  237. package/dist/mjs/tools/util/StationaryPenDetector.d.ts +0 -22
  238. package/dist/mjs/tools/util/StationaryPenDetector.mjs +0 -92
  239. package/src/tools/FindTool.css +0 -7
  240. package/src/tools/ScrollbarTool.scss +0 -57
  241. package/src/tools/SelectionTool/SelectionTool.scss +0 -137
  242. package/src/tools/SoundUITool.scss +0 -22
  243. package/src/tools/tools.scss +0 -5
@@ -1,285 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const TextComponent_1 = __importDefault(require("../components/TextComponent"));
7
- const EditorImage_1 = __importDefault(require("../image/EditorImage"));
8
- const math_1 = require("@js-draw/math");
9
- const Pointer_1 = require("../Pointer");
10
- const types_1 = require("../types");
11
- const BaseTool_1 = __importDefault(require("./BaseTool"));
12
- const Erase_1 = __importDefault(require("../commands/Erase"));
13
- const uniteCommands_1 = __importDefault(require("../commands/uniteCommands"));
14
- const ReactiveValue_1 = require("../util/ReactiveValue");
15
- const overlayCSSClass = 'textEditorOverlay';
16
- class TextTool extends BaseTool_1.default {
17
- constructor(editor, description, localizationTable) {
18
- super(editor.notifier, description);
19
- this.editor = editor;
20
- this.localizationTable = localizationTable;
21
- this.textInputElem = null;
22
- this.textTargetPosition = null;
23
- this.textMeasuringCtx = null;
24
- this.textScale = math_1.Vec2.of(1, 1);
25
- this.removeExistingCommand = null;
26
- const editorFonts = editor.getCurrentSettings().text?.fonts ?? [];
27
- this.textStyleValue = ReactiveValue_1.ReactiveValue.fromInitialValue({
28
- size: 32,
29
- fontFamily: editorFonts.length > 0 ? editorFonts[0] : 'sans-serif',
30
- renderingStyle: {
31
- fill: math_1.Color4.purple,
32
- },
33
- });
34
- this.textStyleValue.onUpdateAndNow(() => {
35
- this.textStyle = this.textStyleValue.get();
36
- this.updateTextInput();
37
- this.editor.notifier.dispatch(types_1.EditorEventType.ToolUpdated, {
38
- kind: types_1.EditorEventType.ToolUpdated,
39
- tool: this,
40
- });
41
- });
42
- this.textEditOverlay = document.createElement('div');
43
- this.textEditOverlay.classList.add(overlayCSSClass);
44
- this.editor.addStyleSheet(`
45
- .${overlayCSSClass} {
46
- height: 0;
47
- overflow: visible;
48
-
49
- /* Allows absolutely-positioned textareas to scroll with
50
- the containing overlay. */
51
- position: relative;
52
- }
53
-
54
- .${overlayCSSClass} textarea {
55
- background-color: rgba(0, 0, 0, 0);
56
-
57
- white-space: pre;
58
- overflow: hidden;
59
-
60
- padding: 0;
61
- margin: 0;
62
- border: none;
63
- padding: 0;
64
-
65
- min-width: 100px;
66
- min-height: 1.1em;
67
- }
68
- `);
69
- this.editor.createHTMLOverlay(this.textEditOverlay);
70
- this.editor.notifier.on(types_1.EditorEventType.ViewportChanged, () => this.updateTextInput());
71
- }
72
- initTextMeasuringCanvas() {
73
- this.textMeasuringCtx ??= document.createElement('canvas').getContext('2d');
74
- }
75
- getTextAscent(text, style) {
76
- this.initTextMeasuringCanvas();
77
- if (this.textMeasuringCtx) {
78
- this.textMeasuringCtx.textBaseline = 'alphabetic';
79
- TextComponent_1.default.applyTextStyles(this.textMeasuringCtx, style);
80
- const measurement = this.textMeasuringCtx.measureText(text);
81
- return measurement.fontBoundingBoxAscent ?? measurement.actualBoundingBoxAscent;
82
- }
83
- // Estimate
84
- return style.size * 2 / 3;
85
- }
86
- // Take input from this' textInputElem and add it to the EditorImage.
87
- // If [removeInput], the HTML input element is removed. Otherwise, its value
88
- // is cleared.
89
- flushInput(removeInput = true) {
90
- if (this.textInputElem && this.textTargetPosition) {
91
- const content = this.textInputElem.value.trimEnd();
92
- this.textInputElem.value = '';
93
- if (removeInput) {
94
- // In some browsers, .remove() triggers a .blur event (synchronously).
95
- // Clear this.textInputElem before removal
96
- const input = this.textInputElem;
97
- this.textInputElem = null;
98
- input.remove();
99
- }
100
- if (content === '') {
101
- return;
102
- }
103
- const textTransform = math_1.Mat33.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(math_1.Mat33.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(math_1.Mat33.zRotation(this.textRotation));
104
- const textComponent = TextComponent_1.default.fromLines(content.split('\n'), textTransform, this.textStyle);
105
- const action = EditorImage_1.default.addElement(textComponent);
106
- if (this.removeExistingCommand) {
107
- // Unapply so that `removeExistingCommand` can be added to the undo stack.
108
- this.removeExistingCommand.unapply(this.editor);
109
- this.editor.dispatch((0, uniteCommands_1.default)([this.removeExistingCommand, action]));
110
- this.removeExistingCommand = null;
111
- }
112
- else {
113
- this.editor.dispatch(action);
114
- }
115
- }
116
- }
117
- getTextScaleMatrix() {
118
- return math_1.Mat33.scaling2D(this.textScale.times(1 / this.editor.viewport.getSizeOfPixelOnCanvas()));
119
- }
120
- updateTextInput() {
121
- if (!this.textInputElem || !this.textTargetPosition) {
122
- this.textInputElem?.remove();
123
- return;
124
- }
125
- const viewport = this.editor.viewport;
126
- const textScreenPos = viewport.canvasToScreen(this.textTargetPosition);
127
- this.textInputElem.placeholder = this.localizationTable.enterTextToInsert;
128
- this.textInputElem.style.fontFamily = this.textStyle.fontFamily;
129
- this.textInputElem.style.fontStyle = this.textStyle.fontStyle ?? '';
130
- this.textInputElem.style.fontVariant = this.textStyle.fontVariant ?? '';
131
- this.textInputElem.style.fontWeight = this.textStyle.fontWeight ?? '';
132
- this.textInputElem.style.fontSize = `${this.textStyle.size}px`;
133
- this.textInputElem.style.color = this.textStyle.renderingStyle.fill.toHexString();
134
- this.textInputElem.style.position = 'absolute';
135
- this.textInputElem.style.left = `${textScreenPos.x}px`;
136
- this.textInputElem.style.top = `${textScreenPos.y}px`;
137
- this.textInputElem.style.margin = '0';
138
- this.textInputElem.style.width = `${this.textInputElem.scrollWidth}px`;
139
- this.textInputElem.style.height = `${this.textInputElem.scrollHeight}px`;
140
- // Get the ascent based on the font, using a string of characters
141
- // that is tall in most fonts.
142
- const tallText = 'Testing!';
143
- const ascent = this.getTextAscent(tallText, this.textStyle);
144
- const vertAdjust = ascent;
145
- const rotation = this.textRotation + viewport.getRotationAngle();
146
- const scale = this.getTextScaleMatrix();
147
- this.textInputElem.style.transform =
148
- `${scale.toCSSMatrix()} rotate(${rotation * 180 / Math.PI}deg) translate(0, ${-vertAdjust}px)`;
149
- this.textInputElem.style.transformOrigin = 'top left';
150
- // Match the line height of default rendered text.
151
- const lineHeight = Math.floor(this.textStyle.size);
152
- this.textInputElem.style.lineHeight = `${lineHeight}px`;
153
- }
154
- startTextInput(textCanvasPos, initialText) {
155
- this.flushInput();
156
- this.textInputElem = document.createElement('textarea');
157
- this.textInputElem.value = initialText;
158
- this.textInputElem.style.display = 'inline-block';
159
- this.textTargetPosition = this.editor.viewport.roundPoint(textCanvasPos);
160
- this.textRotation = -this.editor.viewport.getRotationAngle();
161
- this.textScale = math_1.Vec2.of(1, 1).times(this.editor.viewport.getSizeOfPixelOnCanvas());
162
- this.updateTextInput();
163
- // Update the input size/position/etc. after the placeHolder has had time to appear.
164
- setTimeout(() => this.updateTextInput(), 0);
165
- this.textInputElem.oninput = () => {
166
- if (this.textInputElem) {
167
- this.textInputElem.style.width = `${this.textInputElem.scrollWidth}px`;
168
- this.textInputElem.style.height = `${this.textInputElem.scrollHeight}px`;
169
- }
170
- };
171
- this.textInputElem.onblur = () => {
172
- // Delay removing the input -- flushInput may be called within a blur()
173
- // event handler
174
- const removeInput = false;
175
- const input = this.textInputElem;
176
- this.flushInput(removeInput);
177
- this.textInputElem = null;
178
- setTimeout(() => {
179
- input?.remove();
180
- }, 0);
181
- };
182
- this.textInputElem.onkeyup = (evt) => {
183
- if (evt.key === 'Enter' && !evt.shiftKey) {
184
- this.flushInput();
185
- this.editor.focus();
186
- }
187
- else if (evt.key === 'Escape') {
188
- // Cancel input.
189
- this.textInputElem?.remove();
190
- this.textInputElem = null;
191
- this.editor.focus();
192
- this.removeExistingCommand?.unapply(this.editor);
193
- this.removeExistingCommand = null;
194
- }
195
- };
196
- this.textEditOverlay.replaceChildren(this.textInputElem);
197
- setTimeout(() => this.textInputElem?.focus(), 0);
198
- }
199
- setEnabled(enabled) {
200
- super.setEnabled(enabled);
201
- if (!this.isEnabled()) {
202
- this.flushInput();
203
- }
204
- this.textEditOverlay.style.display = enabled ? 'block' : 'none';
205
- }
206
- onPointerDown({ current, allPointers }) {
207
- if (current.device === Pointer_1.PointerDevice.Eraser) {
208
- return false;
209
- }
210
- if (allPointers.length === 1) {
211
- // Are we clicking on a text node?
212
- const canvasPos = current.canvasPos;
213
- const halfTestRegionSize = math_1.Vec2.of(2.5, 2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas());
214
- const testRegion = math_1.Rect2.fromCorners(canvasPos.minus(halfTestRegionSize), canvasPos.plus(halfTestRegionSize));
215
- const targetNodes = this.editor.image.getElementsIntersectingRegion(testRegion);
216
- let targetTextNodes = targetNodes.filter(node => node instanceof TextComponent_1.default);
217
- // Don't try to edit text nodes that contain the viewport (this allows us
218
- // to zoom in on text nodes and add text on top of them.)
219
- const visibleRect = this.editor.viewport.visibleRect;
220
- targetTextNodes = targetTextNodes.filter(node => !node.getBBox().containsRect(visibleRect));
221
- // End any TextNodes we're currently editing.
222
- this.flushInput();
223
- if (targetTextNodes.length > 0) {
224
- const targetNode = targetTextNodes[targetTextNodes.length - 1];
225
- this.setTextStyle(targetNode.getTextStyle());
226
- // Create and temporarily apply removeExistingCommand.
227
- this.removeExistingCommand = new Erase_1.default([targetNode]);
228
- this.removeExistingCommand.apply(this.editor);
229
- this.startTextInput(targetNode.getBaselinePos(), targetNode.getText());
230
- const transform = targetNode.getTransform();
231
- this.textRotation = transform.transformVec3(math_1.Vec2.unitX).angle();
232
- const scaleFactor = transform.transformVec3(math_1.Vec2.unitX).magnitude();
233
- this.textScale = math_1.Vec2.of(1, 1).times(scaleFactor);
234
- this.updateTextInput();
235
- }
236
- else {
237
- this.removeExistingCommand = null;
238
- this.startTextInput(current.canvasPos, '');
239
- }
240
- return true;
241
- }
242
- return false;
243
- }
244
- onGestureCancel() {
245
- this.flushInput();
246
- this.editor.focus();
247
- }
248
- setFontFamily(fontFamily) {
249
- if (fontFamily !== this.textStyle.fontFamily) {
250
- this.textStyleValue.set({
251
- ...this.textStyle,
252
- fontFamily: fontFamily,
253
- });
254
- }
255
- }
256
- setColor(color) {
257
- if (!color.eq(this.textStyle.renderingStyle.fill)) {
258
- this.textStyleValue.set({
259
- ...this.textStyle,
260
- renderingStyle: {
261
- ...this.textStyle.renderingStyle,
262
- fill: color,
263
- },
264
- });
265
- }
266
- }
267
- setFontSize(size) {
268
- if (size !== this.textStyle.size) {
269
- this.textStyleValue.set({
270
- ...this.textStyle,
271
- size,
272
- });
273
- }
274
- }
275
- getTextStyle() {
276
- return this.textStyle;
277
- }
278
- getStyleValue() {
279
- return this.textStyleValue;
280
- }
281
- setTextStyle(style) {
282
- this.textStyleValue.set(style);
283
- }
284
- }
285
- exports.default = TextTool;
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
1
- import Editor from '../Editor';
2
- import BaseTool from './BaseTool';
3
- import ToolEnabledGroup from './ToolEnabledGroup';
4
- import { ToolLocalization } from './localization';
5
- import InputMapper, { InputEventListener } from './InputFilter/InputMapper';
6
- import { InputEvt } from '../inputEvents';
7
- export default class ToolController implements InputEventListener {
8
- private tools;
9
- private activeTool;
10
- private primaryToolGroup;
11
- private inputPipeline;
12
- private isEditorReadOnly;
13
- /** @internal */
14
- constructor(editor: Editor, localization: ToolLocalization);
15
- /**
16
- * Replaces the current set of tools with `tools`. This should only be done before
17
- * the creation of the app's toolbar (if using `AbstractToolbar`).
18
- *
19
- * If no `primaryToolGroup` is given, an empty one will be created.
20
- */
21
- setTools(tools: BaseTool[], primaryToolGroup?: ToolEnabledGroup): void;
22
- /**
23
- * Add a tool that acts like one of the primary tools (only one primary tool can be enabled at a time).
24
- *
25
- * If the tool is already added to this, the tool is converted to a primary tool.
26
- *
27
- * This should be called before creating the app's toolbar.
28
- */
29
- addPrimaryTool(tool: BaseTool): void;
30
- getPrimaryTools(): BaseTool[];
31
- /**
32
- * Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
33
- * This should be called before creating the app's toolbar.
34
- *
35
- * If `options.addToFront`, the tool is added to the beginning of this' tool list.
36
- *
37
- * Does nothing if the tool is already present.
38
- */
39
- addTool(tool: BaseTool, options?: {
40
- addToFront: boolean;
41
- }): void;
42
- /**
43
- * Removes **and destroys** all tools in `tools` from this.
44
- */
45
- removeAndDestroyTools(tools: BaseTool[]): void;
46
- private insertTools;
47
- /**
48
- * Removes a tool from this' tool list and replaces it with `replaceWith`.
49
- *
50
- * If any of `toolsToInsert` have already been added to this, the tools are
51
- * moved.
52
- *
53
- * This should be called before creating the editor's toolbar.
54
- */
55
- insertToolsAfter(insertAfter: BaseTool, toolsToInsert: BaseTool[]): void;
56
- /** @see {@link insertToolsAfter} */
57
- insertToolsBefore(insertBefore: BaseTool, toolsToInsert: BaseTool[]): void;
58
- private onEventInternal;
59
- /** Alias for {@link dispatchInputEvent}. */
60
- onEvent(event: InputEvt): boolean;
61
- dispatchInputEvent(event: InputEvt): boolean;
62
- /**
63
- * Adds a new `InputMapper` to this' input pipeline.
64
- *
65
- * A `mapper` is really a relation that maps each event to no, one,
66
- * or many other events.
67
- *
68
- * @see {@link InputMapper}.
69
- */
70
- addInputMapper(mapper: InputMapper): void;
71
- getMatchingTools<Type extends BaseTool>(type: new (...args: any[]) => Type): Type[];
72
- onEditorDestroyed(): void;
73
- }
@@ -1,304 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const types_1 = require("../types");
30
- const math_1 = require("@js-draw/math");
31
- const PanZoom_1 = __importStar(require("./PanZoom"));
32
- const Pen_1 = __importDefault(require("./Pen"));
33
- const ToolEnabledGroup_1 = __importDefault(require("./ToolEnabledGroup"));
34
- const Eraser_1 = __importDefault(require("./Eraser"));
35
- const SelectionTool_1 = __importDefault(require("./SelectionTool/SelectionTool"));
36
- const UndoRedoShortcut_1 = __importDefault(require("./UndoRedoShortcut"));
37
- const TextTool_1 = __importDefault(require("./TextTool"));
38
- const PipetteTool_1 = __importDefault(require("./PipetteTool"));
39
- const ToolSwitcherShortcut_1 = __importDefault(require("./ToolSwitcherShortcut"));
40
- const PasteHandler_1 = __importDefault(require("./PasteHandler"));
41
- const ToolbarShortcutHandler_1 = __importDefault(require("./ToolbarShortcutHandler"));
42
- const PressureSensitiveFreehandLineBuilder_1 = require("../components/builders/PressureSensitiveFreehandLineBuilder");
43
- const FindTool_1 = __importDefault(require("./FindTool"));
44
- const SelectAllShortcutHandler_1 = __importDefault(require("./SelectionTool/SelectAllShortcutHandler"));
45
- const SoundUITool_1 = __importDefault(require("./SoundUITool"));
46
- const inputEvents_1 = require("../inputEvents");
47
- const InputPipeline_1 = __importDefault(require("./InputFilter/InputPipeline"));
48
- const InputStabilizer_1 = __importDefault(require("./InputFilter/InputStabilizer"));
49
- const ScrollbarTool_1 = __importDefault(require("./ScrollbarTool"));
50
- class ToolController {
51
- /** @internal */
52
- constructor(editor, localization) {
53
- this.activeTool = null;
54
- this.isEditorReadOnly = editor.isReadOnlyReactiveValue();
55
- this.inputPipeline = new InputPipeline_1.default();
56
- this.inputPipeline.setEmitListener(event => this.onEventInternal(event));
57
- const primaryToolGroup = new ToolEnabledGroup_1.default();
58
- this.primaryToolGroup = primaryToolGroup;
59
- const panZoomTool = new PanZoom_1.default(editor, PanZoom_1.PanZoomMode.TwoFingerTouchGestures | PanZoom_1.PanZoomMode.RightClickDrags, localization.touchPanTool);
60
- const keyboardPanZoomTool = new PanZoom_1.default(editor, PanZoom_1.PanZoomMode.Keyboard, localization.keyboardPanZoom);
61
- const primaryPenTool = new Pen_1.default(editor, localization.penTool(1), { color: math_1.Color4.purple, thickness: 8 });
62
- const secondaryPenTool = new Pen_1.default(editor, localization.penTool(2), { color: math_1.Color4.clay, thickness: 4 });
63
- // Stabilize the secondary pen tool.
64
- secondaryPenTool.setInputMapper(new InputStabilizer_1.default(editor.viewport));
65
- const eraser = new Eraser_1.default(editor, localization.eraserTool);
66
- const primaryTools = [
67
- // Three pens
68
- primaryPenTool,
69
- secondaryPenTool,
70
- // Highlighter-like pen with width=40
71
- new Pen_1.default(editor, localization.penTool(3), {
72
- color: math_1.Color4.ofRGBA(1, 1, 0, 0.5),
73
- thickness: 40,
74
- factory: PressureSensitiveFreehandLineBuilder_1.makePressureSensitiveFreehandLineBuilder
75
- }),
76
- eraser,
77
- new SelectionTool_1.default(editor, localization.selectionTool),
78
- new TextTool_1.default(editor, localization.textTool, localization),
79
- new PanZoom_1.default(editor, PanZoom_1.PanZoomMode.SinglePointerGestures, localization.anyDevicePanning),
80
- ];
81
- // Accessibility tools
82
- const soundExplorer = new SoundUITool_1.default(editor, localization.soundExplorer);
83
- soundExplorer.setEnabled(false);
84
- this.tools = [
85
- new ScrollbarTool_1.default(editor),
86
- new PipetteTool_1.default(editor, localization.pipetteTool),
87
- soundExplorer,
88
- panZoomTool,
89
- ...primaryTools,
90
- keyboardPanZoomTool,
91
- new UndoRedoShortcut_1.default(editor),
92
- new ToolbarShortcutHandler_1.default(editor),
93
- new ToolSwitcherShortcut_1.default(editor),
94
- eraser.makeEraserSwitcherTool(),
95
- new FindTool_1.default(editor),
96
- new PasteHandler_1.default(editor),
97
- new SelectAllShortcutHandler_1.default(editor),
98
- ];
99
- primaryTools.forEach(tool => tool.setToolGroup(primaryToolGroup));
100
- panZoomTool.setEnabled(true);
101
- primaryPenTool.setEnabled(true);
102
- editor.notifier.on(types_1.EditorEventType.ToolEnabled, event => {
103
- if (event.kind === types_1.EditorEventType.ToolEnabled) {
104
- editor.announceForAccessibility(localization.toolEnabledAnnouncement(event.tool.description));
105
- }
106
- });
107
- editor.notifier.on(types_1.EditorEventType.ToolDisabled, event => {
108
- if (event.kind === types_1.EditorEventType.ToolDisabled) {
109
- editor.announceForAccessibility(localization.toolDisabledAnnouncement(event.tool.description));
110
- }
111
- });
112
- this.activeTool = null;
113
- }
114
- /**
115
- * Replaces the current set of tools with `tools`. This should only be done before
116
- * the creation of the app's toolbar (if using `AbstractToolbar`).
117
- *
118
- * If no `primaryToolGroup` is given, an empty one will be created.
119
- */
120
- setTools(tools, primaryToolGroup) {
121
- this.tools = tools;
122
- this.primaryToolGroup = primaryToolGroup ?? new ToolEnabledGroup_1.default();
123
- }
124
- /**
125
- * Add a tool that acts like one of the primary tools (only one primary tool can be enabled at a time).
126
- *
127
- * If the tool is already added to this, the tool is converted to a primary tool.
128
- *
129
- * This should be called before creating the app's toolbar.
130
- */
131
- addPrimaryTool(tool) {
132
- tool.setToolGroup(this.primaryToolGroup);
133
- if (tool.isEnabled()) {
134
- this.primaryToolGroup.notifyEnabled(tool);
135
- }
136
- if (!this.tools.includes(tool)) {
137
- this.addTool(tool);
138
- }
139
- }
140
- getPrimaryTools() {
141
- return this.tools.filter(tool => {
142
- return tool.getToolGroup() === this.primaryToolGroup;
143
- });
144
- }
145
- /**
146
- * Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
147
- * This should be called before creating the app's toolbar.
148
- *
149
- * If `options.addToFront`, the tool is added to the beginning of this' tool list.
150
- *
151
- * Does nothing if the tool is already present.
152
- */
153
- addTool(tool, options) {
154
- // Only add if not already present.
155
- if (!this.tools.includes(tool)) {
156
- if (options?.addToFront) {
157
- this.tools.splice(0, 0, tool);
158
- }
159
- else {
160
- this.tools.push(tool);
161
- }
162
- }
163
- }
164
- /**
165
- * Removes **and destroys** all tools in `tools` from this.
166
- */
167
- removeAndDestroyTools(tools) {
168
- const newTools = [];
169
- for (const tool of this.tools) {
170
- if (tools.includes(tool)) {
171
- if (this.activeTool === tool) {
172
- this.activeTool = null;
173
- }
174
- tool.onDestroy();
175
- }
176
- else {
177
- newTools.push(tool);
178
- }
179
- }
180
- this.tools = newTools;
181
- }
182
- insertTools(insertNear, toolsToInsert, mode) {
183
- this.tools = this.tools.filter(tool => !toolsToInsert.includes(tool));
184
- const newTools = [];
185
- for (const tool of this.tools) {
186
- if (mode === 'after') {
187
- newTools.push(tool);
188
- }
189
- if (tool === insertNear) {
190
- newTools.push(...toolsToInsert);
191
- }
192
- if (mode === 'before') {
193
- newTools.push(tool);
194
- }
195
- }
196
- this.tools = newTools;
197
- }
198
- /**
199
- * Removes a tool from this' tool list and replaces it with `replaceWith`.
200
- *
201
- * If any of `toolsToInsert` have already been added to this, the tools are
202
- * moved.
203
- *
204
- * This should be called before creating the editor's toolbar.
205
- */
206
- insertToolsAfter(insertAfter, toolsToInsert) {
207
- this.insertTools(insertAfter, toolsToInsert, 'after');
208
- }
209
- /** @see {@link insertToolsAfter} */
210
- insertToolsBefore(insertBefore, toolsToInsert) {
211
- this.insertTools(insertBefore, toolsToInsert, 'before');
212
- }
213
- // @internal use `dispatchEvent` rather than calling `onEvent` directly.
214
- onEventInternal(event) {
215
- const isEditorReadOnly = this.isEditorReadOnly.get();
216
- const canToolReceiveInput = (tool) => {
217
- return tool.isEnabled() && (!isEditorReadOnly || tool.canReceiveInputInReadOnlyEditor());
218
- };
219
- let handled = false;
220
- if (event.kind === inputEvents_1.InputEvtType.PointerDownEvt) {
221
- let canOnlySendToActiveTool = false;
222
- if (this.activeTool && !this.activeTool.eventCanBeDeliveredToNonActiveTool(event)) {
223
- canOnlySendToActiveTool = true;
224
- }
225
- for (const tool of this.tools) {
226
- if (canOnlySendToActiveTool && tool !== this.activeTool) {
227
- continue;
228
- }
229
- if (canToolReceiveInput(tool) && tool.onEvent(event)) {
230
- if (this.activeTool !== tool) {
231
- this.activeTool?.onEvent({ kind: inputEvents_1.InputEvtType.GestureCancelEvt });
232
- }
233
- this.activeTool = tool;
234
- handled = true;
235
- break;
236
- }
237
- }
238
- }
239
- else if (event.kind === inputEvents_1.InputEvtType.PointerUpEvt) {
240
- const upResult = this.activeTool?.onEvent(event);
241
- const continueHandlingEvents = upResult && event.allPointers.length > 1;
242
- // Should the active tool continue handling events (without an additional pointer down?)
243
- if (!continueHandlingEvents) {
244
- // No -- Remove the current tool
245
- this.activeTool = null;
246
- }
247
- handled = true;
248
- }
249
- else if (event.kind === inputEvents_1.InputEvtType.PointerMoveEvt) {
250
- if (this.activeTool !== null) {
251
- this.activeTool.onEvent(event);
252
- handled = true;
253
- }
254
- }
255
- else if (event.kind === inputEvents_1.InputEvtType.GestureCancelEvt) {
256
- if (this.activeTool !== null) {
257
- this.activeTool.onEvent(event);
258
- this.activeTool = null;
259
- }
260
- }
261
- else {
262
- for (const tool of this.tools) {
263
- if (!canToolReceiveInput(tool)) {
264
- continue;
265
- }
266
- handled = tool.onEvent(event);
267
- if (handled) {
268
- break;
269
- }
270
- }
271
- }
272
- return handled;
273
- }
274
- /** Alias for {@link dispatchInputEvent}. */
275
- onEvent(event) {
276
- return this.dispatchInputEvent(event);
277
- }
278
- // Returns true if the event was handled.
279
- dispatchInputEvent(event) {
280
- // Feed the event through the input pipeline
281
- return this.inputPipeline.onEvent(event);
282
- }
283
- /**
284
- * Adds a new `InputMapper` to this' input pipeline.
285
- *
286
- * A `mapper` is really a relation that maps each event to no, one,
287
- * or many other events.
288
- *
289
- * @see {@link InputMapper}.
290
- */
291
- addInputMapper(mapper) {
292
- this.inputPipeline.addToTail(mapper);
293
- }
294
- getMatchingTools(type) {
295
- return this.tools.filter(tool => tool instanceof type);
296
- }
297
- // @internal
298
- onEditorDestroyed() {
299
- for (const tool of this.tools) {
300
- tool.onDestroy();
301
- }
302
- }
303
- }
304
- exports.default = ToolController;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import BaseTool from './BaseTool';
2
- export default class ToolEnabledGroup {
3
- private activeTool;
4
- constructor();
5
- notifyEnabled(tool: BaseTool): void;
6
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // Connects a group of tools -- at most one tool in the group can be enabled.
4
- class ToolEnabledGroup {
5
- constructor() { }
6
- notifyEnabled(tool) {
7
- if (tool !== this.activeTool) {
8
- this.activeTool?.setEnabled(false);
9
- this.activeTool = tool;
10
- }
11
- }
12
- }
13
- exports.default = ToolEnabledGroup;