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,71 +0,0 @@
1
- /**
2
- * @internal
3
- * @packageDocumentation
4
- */
5
- import SerializableCommand from '../../commands/SerializableCommand';
6
- import Editor from '../../Editor';
7
- import { Mat33, Rect2, Point2 } from '@js-draw/math';
8
- import Pointer from '../../Pointer';
9
- import AbstractComponent from '../../components/AbstractComponent';
10
- import Command from '../../commands/Command';
11
- export default class Selection {
12
- private editor;
13
- private childwidgets;
14
- private originalRegion;
15
- private selectionTightBoundingBox;
16
- private transformers;
17
- private transform;
18
- private selectedElems;
19
- private outerContainer;
20
- private innerContainer;
21
- private backgroundElem;
22
- private hasParent;
23
- constructor(startPoint: Point2, editor: Editor);
24
- getBackgroundElem(): HTMLElement;
25
- getTransform(): Mat33;
26
- get preTransformRegion(): Rect2;
27
- get region(): Rect2;
28
- /**
29
- * Computes and returns the bounding box of the selection without
30
- * any additional padding. Computes directly from the elements that are selected.
31
- * @internal
32
- */
33
- computeTightBoundingBox(): Rect2;
34
- get regionRotation(): number;
35
- get preTransformedScreenRegion(): Rect2;
36
- get preTransformedScreenRegionRotation(): number;
37
- getScreenRegion(): Rect2;
38
- get screenRegionRotation(): number;
39
- setTransform(transform: Mat33, preview?: boolean): void;
40
- private getDeltaZIndexToMoveSelectionToTop;
41
- finalizeTransform(): void | Promise<void>;
42
- /** Sends all selected elements to the bottom of the visible image. */
43
- sendToBack(): SerializableCommand | null;
44
- private static ApplyTransformationCommand;
45
- private previewTransformCmds;
46
- resolveToObjects(): boolean;
47
- recomputeRegion(): boolean;
48
- padRegion(): void;
49
- getMinCanvasSize(): number;
50
- getSelectedItemCount(): number;
51
- updateUI(): void;
52
- private removedFromImage;
53
- private addRemoveSelectionFromImage;
54
- private removeDeletedElemsFromSelection;
55
- private activeHandle;
56
- private backgroundDragging;
57
- onDragStart(pointer: Pointer): boolean;
58
- onDragUpdate(pointer: Pointer): void;
59
- onDragEnd(): void;
60
- onDragCancel(): void;
61
- scrollTo(): boolean;
62
- deleteSelectedObjects(): Command;
63
- private selectionDuplicatedAnimationTimeout;
64
- private runSelectionDuplicatedAnimation;
65
- duplicateSelectedObjects(): Promise<Command>;
66
- addTo(elem: HTMLElement): void;
67
- setToPoint(point: Point2): void;
68
- cancelSelection(): void;
69
- setSelectedObjects(objects: AbstractComponent[], bbox: Rect2): void;
70
- getSelectedObjects(): AbstractComponent[];
71
- }
@@ -1,620 +0,0 @@
1
- "use strict";
2
- /**
3
- * @internal
4
- * @packageDocumentation
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
29
- var __importDefault = (this && this.__importDefault) || function (mod) {
30
- return (mod && mod.__esModule) ? mod : { "default": mod };
31
- };
32
- var _a;
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- const SerializableCommand_1 = __importDefault(require("../../commands/SerializableCommand"));
35
- const math_1 = require("@js-draw/math");
36
- const SelectionHandle_1 = __importStar(require("./SelectionHandle"));
37
- const SelectionTool_1 = require("./SelectionTool");
38
- const Viewport_1 = __importDefault(require("../../Viewport"));
39
- const Erase_1 = __importDefault(require("../../commands/Erase"));
40
- const Duplicate_1 = __importDefault(require("../../commands/Duplicate"));
41
- const TransformMode_1 = require("./TransformMode");
42
- const types_1 = require("./types");
43
- const EditorImage_1 = __importDefault(require("../../image/EditorImage"));
44
- const uniteCommands_1 = __importDefault(require("../../commands/uniteCommands"));
45
- const updateChunkSize = 100;
46
- const maxPreviewElemCount = 500;
47
- // @internal
48
- class Selection {
49
- constructor(startPoint, editor) {
50
- this.editor = editor;
51
- // The last-computed bounding box of selected content
52
- // @see getTightBoundingBox
53
- this.selectionTightBoundingBox = null;
54
- this.transform = math_1.Mat33.identity;
55
- // invariant: sorted by increasing z-index
56
- this.selectedElems = [];
57
- this.hasParent = true;
58
- // Maps IDs to whether we removed the component from the image
59
- this.removedFromImage = {};
60
- this.activeHandle = null;
61
- this.backgroundDragging = false;
62
- this.selectionDuplicatedAnimationTimeout = null;
63
- this.originalRegion = new math_1.Rect2(startPoint.x, startPoint.y, 0, 0);
64
- this.transformers = {
65
- drag: new TransformMode_1.DragTransformer(editor, this),
66
- resize: new TransformMode_1.ResizeTransformer(editor, this),
67
- rotate: new TransformMode_1.RotateTransformer(editor, this),
68
- };
69
- // We need two containers for some CSS to apply (the outer container
70
- // needs zero height, the inner needs to prevent the selection background
71
- // from being visible outside of the editor).
72
- this.outerContainer = document.createElement('div');
73
- this.outerContainer.classList.add(`${SelectionTool_1.cssPrefix}selection-outer-container`);
74
- this.innerContainer = document.createElement('div');
75
- this.innerContainer.classList.add(`${SelectionTool_1.cssPrefix}selection-inner-container`);
76
- this.backgroundElem = document.createElement('div');
77
- this.backgroundElem.classList.add(`${SelectionTool_1.cssPrefix}selection-background`);
78
- this.innerContainer.appendChild(this.backgroundElem);
79
- this.outerContainer.appendChild(this.innerContainer);
80
- const makeResizeHandle = (mode, side) => {
81
- const modeToAction = {
82
- [types_1.ResizeMode.Both]: SelectionHandle_1.HandleAction.ResizeXY,
83
- [types_1.ResizeMode.HorizontalOnly]: SelectionHandle_1.HandleAction.ResizeX,
84
- [types_1.ResizeMode.VerticalOnly]: SelectionHandle_1.HandleAction.ResizeY,
85
- };
86
- return new SelectionHandle_1.default({
87
- action: modeToAction[mode],
88
- side,
89
- }, this, this.editor.viewport, (startPoint) => this.transformers.resize.onDragStart(startPoint, mode), (currentPoint) => this.transformers.resize.onDragUpdate(currentPoint), () => this.transformers.resize.onDragEnd());
90
- };
91
- const resizeHorizontalHandles = [
92
- makeResizeHandle(types_1.ResizeMode.HorizontalOnly, math_1.Vec2.of(0, 0.5)),
93
- makeResizeHandle(types_1.ResizeMode.HorizontalOnly, math_1.Vec2.of(1, 0.5)),
94
- ];
95
- const resizeVerticalHandle = makeResizeHandle(types_1.ResizeMode.VerticalOnly, math_1.Vec2.of(0.5, 1));
96
- const resizeBothHandle = makeResizeHandle(types_1.ResizeMode.Both, math_1.Vec2.of(1, 1));
97
- const rotationHandle = new SelectionHandle_1.default({
98
- action: SelectionHandle_1.HandleAction.Rotate,
99
- side: math_1.Vec2.of(0.5, 0),
100
- icon: this.editor.icons.makeRotateIcon(),
101
- }, this, this.editor.viewport, (startPoint) => this.transformers.rotate.onDragStart(startPoint), (currentPoint) => this.transformers.rotate.onDragUpdate(currentPoint), () => this.transformers.rotate.onDragEnd());
102
- this.childwidgets = [
103
- resizeBothHandle,
104
- ...resizeHorizontalHandles,
105
- resizeVerticalHandle,
106
- rotationHandle,
107
- ];
108
- for (const widget of this.childwidgets) {
109
- widget.addTo(this.backgroundElem);
110
- }
111
- this.updateUI();
112
- }
113
- // @internal Intended for unit tests
114
- getBackgroundElem() {
115
- return this.backgroundElem;
116
- }
117
- getTransform() {
118
- return this.transform;
119
- }
120
- get preTransformRegion() {
121
- return this.originalRegion;
122
- }
123
- get region() {
124
- // TODO: This currently assumes that the region rotates about its center.
125
- // This may not be true.
126
- const rotationMatrix = math_1.Mat33.zRotation(this.regionRotation, this.originalRegion.center);
127
- const scaleAndTranslateMat = this.transform.rightMul(rotationMatrix.inverse());
128
- return this.originalRegion.transformedBoundingBox(scaleAndTranslateMat);
129
- }
130
- /**
131
- * Computes and returns the bounding box of the selection without
132
- * any additional padding. Computes directly from the elements that are selected.
133
- * @internal
134
- */
135
- computeTightBoundingBox() {
136
- const bbox = this.selectedElems.reduce((accumulator, elem) => {
137
- return (accumulator ?? elem.getBBox()).union(elem.getBBox());
138
- }, null);
139
- return bbox ?? math_1.Rect2.empty;
140
- }
141
- get regionRotation() {
142
- return this.transform.transformVec3(math_1.Vec2.unitX).angle();
143
- }
144
- get preTransformedScreenRegion() {
145
- const toScreen = (vec) => this.editor.viewport.canvasToScreen(vec);
146
- return math_1.Rect2.fromCorners(toScreen(this.preTransformRegion.topLeft), toScreen(this.preTransformRegion.bottomRight));
147
- }
148
- get preTransformedScreenRegionRotation() {
149
- return this.editor.viewport.getRotationAngle();
150
- }
151
- getScreenRegion() {
152
- const toScreen = this.editor.viewport.canvasToScreenTransform;
153
- const scaleFactor = this.editor.viewport.getScaleFactor();
154
- const screenCenter = toScreen.transformVec2(this.region.center);
155
- return new math_1.Rect2(screenCenter.x, screenCenter.y, scaleFactor * this.region.width, scaleFactor * this.region.height).translatedBy(this.region.size.times(-scaleFactor / 2));
156
- }
157
- get screenRegionRotation() {
158
- return this.regionRotation + this.editor.viewport.getRotationAngle();
159
- }
160
- // Applies, previews, but doesn't finalize the given transformation.
161
- setTransform(transform, preview = true) {
162
- this.transform = transform;
163
- if (preview && this.hasParent) {
164
- this.previewTransformCmds();
165
- }
166
- }
167
- getDeltaZIndexToMoveSelectionToTop() {
168
- if (this.selectedElems.length === 0) {
169
- return 0;
170
- }
171
- const selectedBottommostZIndex = this.selectedElems[0].getZIndex();
172
- const visibleObjects = this.editor.image.getElementsIntersectingRegion(this.region);
173
- const topMostVisibleZIndex = visibleObjects[visibleObjects.length - 1]?.getZIndex() ?? selectedBottommostZIndex;
174
- const deltaZIndex = (topMostVisibleZIndex + 1) - selectedBottommostZIndex;
175
- return deltaZIndex;
176
- }
177
- // Applies the current transformation to the selection
178
- finalizeTransform() {
179
- const fullTransform = this.transform;
180
- const selectedElems = this.selectedElems;
181
- // Reset for the next drag
182
- this.originalRegion = this.originalRegion.transformedBoundingBox(this.transform);
183
- this.transform = math_1.Mat33.identity;
184
- this.scrollTo();
185
- let transformPromise = undefined;
186
- // Make the commands undo-able.
187
- // Don't check for non-empty transforms because this breaks changing the
188
- // z-index of the just-transformed commands.
189
- if (this.selectedElems.length > 0) {
190
- const deltaZIndex = this.getDeltaZIndexToMoveSelectionToTop();
191
- transformPromise = this.editor.dispatch(new _a.ApplyTransformationCommand(this, selectedElems, fullTransform, deltaZIndex));
192
- }
193
- // Clear renderings of any in-progress transformations
194
- const wetInkRenderer = this.editor.display.getWetInkRenderer();
195
- wetInkRenderer.clear();
196
- return transformPromise;
197
- }
198
- /** Sends all selected elements to the bottom of the visible image. */
199
- sendToBack() {
200
- const visibleObjects = this.editor.image.getElementsIntersectingRegion(this.editor.viewport.visibleRect);
201
- // VisibleObjects and selectedElems should both be sorted by z-index
202
- const lowestVisibleZIndex = visibleObjects[0]?.getZIndex() ?? 0;
203
- const highestSelectedZIndex = this.selectedElems[this.selectedElems.length - 1]?.getZIndex() ?? 0;
204
- const targetHighestZIndex = lowestVisibleZIndex - 1;
205
- const deltaZIndex = targetHighestZIndex - highestSelectedZIndex;
206
- if (deltaZIndex !== 0) {
207
- const commands = this.selectedElems.map(elem => {
208
- return elem.setZIndex(elem.getZIndex() + deltaZIndex);
209
- });
210
- return (0, uniteCommands_1.default)(commands, updateChunkSize);
211
- }
212
- return null;
213
- }
214
- // Preview the effects of the current transformation on the selection
215
- previewTransformCmds() {
216
- if (this.selectedElems.length === 0) {
217
- return;
218
- }
219
- // Don't render what we're moving if it's likely to be slow.
220
- if (this.selectedElems.length > maxPreviewElemCount) {
221
- this.updateUI();
222
- return;
223
- }
224
- const wetInkRenderer = this.editor.display.getWetInkRenderer();
225
- wetInkRenderer.clear();
226
- wetInkRenderer.pushTransform(this.transform);
227
- const viewportVisibleRect = this.editor.viewport.visibleRect.union(this.region);
228
- const visibleRect = viewportVisibleRect.transformedBoundingBox(this.transform.inverse());
229
- for (const elem of this.selectedElems) {
230
- elem.render(wetInkRenderer, visibleRect);
231
- }
232
- wetInkRenderer.popTransform();
233
- this.updateUI();
234
- }
235
- // Find the objects corresponding to this in the document,
236
- // select them.
237
- // Returns false iff nothing was selected.
238
- resolveToObjects() {
239
- let singleItemSelectionMode = false;
240
- this.transform = math_1.Mat33.identity;
241
- // Grow the rectangle, if necessary
242
- if (this.region.w === 0 || this.region.h === 0) {
243
- const padding = this.editor.viewport.visibleRect.maxDimension / 200;
244
- this.originalRegion = math_1.Rect2.bboxOf(this.region.corners, padding);
245
- // Only select one item if the rectangle was very small.
246
- singleItemSelectionMode = true;
247
- }
248
- this.selectedElems = this.editor.image.getElementsIntersectingRegion(this.region).filter(elem => {
249
- return elem.intersectsRect(this.region) && elem.isSelectable();
250
- });
251
- if (singleItemSelectionMode && this.selectedElems.length > 0) {
252
- this.selectedElems = [this.selectedElems[this.selectedElems.length - 1]];
253
- }
254
- // Find the bounding box of all selected elements.
255
- if (!this.recomputeRegion()) {
256
- return false;
257
- }
258
- this.updateUI();
259
- return true;
260
- }
261
- // Recompute this' region from the selected elements.
262
- // Returns false if the selection is empty.
263
- recomputeRegion() {
264
- const newRegion = this.computeTightBoundingBox();
265
- this.selectionTightBoundingBox = newRegion;
266
- if (!newRegion) {
267
- this.cancelSelection();
268
- return false;
269
- }
270
- this.originalRegion = newRegion;
271
- this.padRegion();
272
- return true;
273
- }
274
- // Applies padding to the current region if it is too small.
275
- // @internal
276
- padRegion() {
277
- const sourceRegion = this.selectionTightBoundingBox ?? this.originalRegion;
278
- const minSize = this.getMinCanvasSize();
279
- if (sourceRegion.w < minSize || sourceRegion.h < minSize) {
280
- // Add padding
281
- const padding = minSize / 2;
282
- this.originalRegion = math_1.Rect2.bboxOf(sourceRegion.corners, padding);
283
- this.updateUI();
284
- }
285
- }
286
- getMinCanvasSize() {
287
- const canvasHandleSize = SelectionHandle_1.handleSize / this.editor.viewport.getScaleFactor();
288
- return canvasHandleSize * 2;
289
- }
290
- getSelectedItemCount() {
291
- return this.selectedElems.length;
292
- }
293
- // @internal
294
- updateUI() {
295
- // Don't update old selections.
296
- if (!this.hasParent) {
297
- return;
298
- }
299
- const screenRegion = this.getScreenRegion();
300
- // marginLeft, marginTop: Display relative to the top left of the selection overlay.
301
- // left, top don't work for this.
302
- this.backgroundElem.style.marginLeft = `${screenRegion.topLeft.x}px`;
303
- this.backgroundElem.style.marginTop = `${screenRegion.topLeft.y}px`;
304
- this.backgroundElem.style.width = `${screenRegion.width}px`;
305
- this.backgroundElem.style.height = `${screenRegion.height}px`;
306
- const rotationDeg = this.screenRegionRotation * 180 / Math.PI;
307
- this.backgroundElem.style.transform = `rotate(${rotationDeg}deg)`;
308
- this.backgroundElem.style.transformOrigin = 'center';
309
- // If closer to perpendicular, apply different CSS
310
- const perpendicularClassName = `${SelectionTool_1.cssPrefix}rotated-near-perpendicular`;
311
- if (Math.abs(Math.sin(this.screenRegionRotation)) > 0.5) {
312
- this.innerContainer.classList.add(perpendicularClassName);
313
- }
314
- else {
315
- this.innerContainer.classList.remove(perpendicularClassName);
316
- }
317
- // Hide handles when empty
318
- if (screenRegion.width === 0 && screenRegion.height === 0) {
319
- this.innerContainer.classList.add('-empty');
320
- }
321
- else {
322
- this.innerContainer.classList.remove('-empty');
323
- }
324
- for (const widget of this.childwidgets) {
325
- widget.updatePosition(this.getScreenRegion());
326
- }
327
- }
328
- // Add/remove the contents of this seleciton from the editor.
329
- // Used to prevent previewed content from looking like duplicate content
330
- // while dragging.
331
- //
332
- // Does nothing if a large number of elements are selected (and so modifying
333
- // the editor image is likely to be slow.)
334
- //
335
- // If removed from the image, selected elements are drawn as wet ink.
336
- //
337
- // [inImage] should be `true` if the selected elements should be added to the
338
- // main image, `false` if they should be removed.
339
- addRemoveSelectionFromImage(inImage) {
340
- // Don't hide elements if doing so will be slow.
341
- if (!inImage && this.selectedElems.length > maxPreviewElemCount) {
342
- return;
343
- }
344
- for (const elem of this.selectedElems) {
345
- const parent = this.editor.image.findParent(elem);
346
- if (!inImage && parent) {
347
- this.removedFromImage[elem.getId()] = true;
348
- parent.remove();
349
- }
350
- // If we're making things visible and the selected object wasn't previously
351
- // visible,
352
- else if (!parent && this.removedFromImage[elem.getId()]) {
353
- EditorImage_1.default.addElement(elem).apply(this.editor);
354
- this.removedFromImage[elem.getId()] = false;
355
- delete this.removedFromImage[elem.getId()];
356
- }
357
- }
358
- // Don't await queueRerender. If we're running in a test, the re-render might never
359
- // happen.
360
- this.editor.queueRerender().then(() => {
361
- if (!inImage) {
362
- this.previewTransformCmds();
363
- }
364
- });
365
- }
366
- removeDeletedElemsFromSelection() {
367
- // Remove any deleted elements from the selection.
368
- this.selectedElems = this.selectedElems.filter(elem => {
369
- const hasParent = !!this.editor.image.findParent(elem);
370
- // If we removed the element and haven't added it back yet, don't remove it
371
- // from the selection.
372
- const weRemoved = this.removedFromImage[elem.getId()];
373
- return hasParent || weRemoved;
374
- });
375
- }
376
- onDragStart(pointer) {
377
- // Clear the HTML selection (prevent HTML drag and drop being triggered by this drag)
378
- document.getSelection()?.removeAllRanges();
379
- this.activeHandle = null;
380
- let result = false;
381
- this.backgroundDragging = false;
382
- if (this.region.containsPoint(pointer.canvasPos)) {
383
- this.backgroundDragging = true;
384
- result = true;
385
- }
386
- for (const widget of this.childwidgets) {
387
- if (widget.containsPoint(pointer.canvasPos)) {
388
- this.activeHandle = widget;
389
- this.backgroundDragging = false;
390
- result = true;
391
- }
392
- }
393
- if (result) {
394
- this.removeDeletedElemsFromSelection();
395
- this.addRemoveSelectionFromImage(false);
396
- }
397
- if (this.activeHandle) {
398
- this.activeHandle.handleDragStart(pointer);
399
- }
400
- if (this.backgroundDragging) {
401
- this.transformers.drag.onDragStart(pointer.canvasPos);
402
- }
403
- return result;
404
- }
405
- onDragUpdate(pointer) {
406
- if (this.backgroundDragging) {
407
- this.transformers.drag.onDragUpdate(pointer.canvasPos);
408
- }
409
- if (this.activeHandle) {
410
- this.activeHandle.handleDragUpdate(pointer);
411
- }
412
- }
413
- onDragEnd() {
414
- if (this.backgroundDragging) {
415
- this.transformers.drag.onDragEnd();
416
- }
417
- else if (this.activeHandle) {
418
- this.activeHandle.handleDragEnd();
419
- }
420
- this.addRemoveSelectionFromImage(true);
421
- this.backgroundDragging = false;
422
- this.activeHandle = null;
423
- this.updateUI();
424
- }
425
- onDragCancel() {
426
- this.backgroundDragging = false;
427
- this.activeHandle = null;
428
- this.setTransform(math_1.Mat33.identity);
429
- this.addRemoveSelectionFromImage(true);
430
- this.updateUI();
431
- }
432
- // Scroll the viewport to this. Does not zoom
433
- scrollTo() {
434
- if (this.selectedElems.length === 0) {
435
- return false;
436
- }
437
- const screenSize = this.editor.viewport.getScreenRectSize();
438
- const screenRect = new math_1.Rect2(0, 0, screenSize.x, screenSize.y);
439
- const selectionScreenRegion = this.getScreenRegion();
440
- if (!screenRect.containsPoint(selectionScreenRegion.center)) {
441
- const targetPointScreen = selectionScreenRegion.center;
442
- const closestPointScreen = screenRect.getClosestPointOnBoundaryTo(targetPointScreen);
443
- const closestPointCanvas = this.editor.viewport.screenToCanvas(closestPointScreen);
444
- const targetPointCanvas = this.region.center;
445
- const delta = closestPointCanvas.minus(targetPointCanvas);
446
- this.editor.dispatchNoAnnounce(Viewport_1.default.transformBy(math_1.Mat33.translation(delta.times(0.5))), false);
447
- this.editor.queueRerender().then(() => {
448
- this.previewTransformCmds();
449
- });
450
- return true;
451
- }
452
- return false;
453
- }
454
- deleteSelectedObjects() {
455
- if (this.backgroundDragging || this.activeHandle) {
456
- this.onDragEnd();
457
- }
458
- return new Erase_1.default(this.selectedElems);
459
- }
460
- runSelectionDuplicatedAnimation() {
461
- if (this.selectionDuplicatedAnimationTimeout) {
462
- clearTimeout(this.selectionDuplicatedAnimationTimeout);
463
- }
464
- const animationDuration = 400; // ms
465
- this.backgroundElem.style.animation = `${animationDuration}ms ease selection-duplicated-animation`;
466
- this.selectionDuplicatedAnimationTimeout = setTimeout(() => {
467
- this.backgroundElem.style.animation = '';
468
- this.selectionDuplicatedAnimationTimeout = null;
469
- }, animationDuration);
470
- }
471
- async duplicateSelectedObjects() {
472
- const wasTransforming = this.backgroundDragging || this.activeHandle;
473
- let tmpApplyCommand = null;
474
- if (!wasTransforming) {
475
- this.runSelectionDuplicatedAnimation();
476
- }
477
- if (wasTransforming) {
478
- // Don't update the selection's focus when redoing/undoing
479
- const selectionToUpdate = null;
480
- const deltaZIndex = this.getDeltaZIndexToMoveSelectionToTop();
481
- tmpApplyCommand = new _a.ApplyTransformationCommand(selectionToUpdate, this.selectedElems, this.transform, deltaZIndex);
482
- // Transform to ensure that the duplicates are in the correct location
483
- await tmpApplyCommand.apply(this.editor);
484
- // Show items again
485
- this.addRemoveSelectionFromImage(true);
486
- }
487
- const duplicateCommand = new Duplicate_1.default(this.selectedElems);
488
- if (wasTransforming) {
489
- // Move the selected objects back to the correct location.
490
- await tmpApplyCommand?.unapply(this.editor);
491
- this.addRemoveSelectionFromImage(false);
492
- this.previewTransformCmds();
493
- this.updateUI();
494
- }
495
- return duplicateCommand;
496
- }
497
- addTo(elem) {
498
- if (this.outerContainer.parentElement) {
499
- this.outerContainer.remove();
500
- }
501
- elem.appendChild(this.outerContainer);
502
- this.hasParent = true;
503
- }
504
- setToPoint(point) {
505
- this.originalRegion = this.originalRegion.grownToPoint(point);
506
- this.selectionTightBoundingBox = null;
507
- this.updateUI();
508
- }
509
- cancelSelection() {
510
- if (this.outerContainer.parentElement) {
511
- this.outerContainer.remove();
512
- }
513
- this.originalRegion = math_1.Rect2.empty;
514
- this.selectionTightBoundingBox = null;
515
- this.hasParent = false;
516
- }
517
- setSelectedObjects(objects, bbox) {
518
- this.addRemoveSelectionFromImage(true);
519
- this.originalRegion = bbox;
520
- this.selectionTightBoundingBox = bbox;
521
- this.selectedElems = objects.filter(object => object.isSelectable());
522
- // Enforce increasing z-index invariant
523
- this.selectedElems.sort((a, b) => a.getZIndex() - b.getZIndex());
524
- this.padRegion();
525
- this.updateUI();
526
- }
527
- getSelectedObjects() {
528
- return [...this.selectedElems];
529
- }
530
- }
531
- _a = Selection;
532
- (() => {
533
- SerializableCommand_1.default.register('selection-tool-transform', (json, _editor) => {
534
- // The selection box is lost when serializing/deserializing. No need to store box rotation
535
- const fullTransform = new math_1.Mat33(...json.transform);
536
- const elemIds = (json.elems ?? []);
537
- const deltaZIndex = parseInt(json.deltaZIndex ?? 0);
538
- return new _a.ApplyTransformationCommand(null, elemIds, fullTransform, deltaZIndex);
539
- });
540
- })();
541
- Selection.ApplyTransformationCommand = class extends SerializableCommand_1.default {
542
- constructor(selection,
543
- // If a `string[]`, selectedElems is a list of element IDs.
544
- selectedElems,
545
- // Full transformation used to transform elements.
546
- fullTransform, deltaZIndex) {
547
- super('selection-tool-transform');
548
- this.selection = selection;
549
- this.fullTransform = fullTransform;
550
- this.deltaZIndex = deltaZIndex;
551
- const isIDList = (arr) => {
552
- return typeof arr[0] === 'string';
553
- };
554
- // If a list of element IDs,
555
- if (isIDList(selectedElems)) {
556
- this.selectedElemIds = selectedElems;
557
- }
558
- else {
559
- this.selectedElemIds = selectedElems.map(elem => elem.getId());
560
- this.transformCommands = selectedElems.map(elem => {
561
- return elem.setZIndexAndTransformBy(this.fullTransform, elem.getZIndex() + deltaZIndex);
562
- });
563
- }
564
- }
565
- resolveToElems(editor, isUndoing) {
566
- if (this.transformCommands) {
567
- return;
568
- }
569
- this.transformCommands = this.selectedElemIds.map(id => {
570
- const elem = editor.image.lookupElement(id);
571
- if (!elem) {
572
- // There may be valid reasons for an element lookup to fail:
573
- // For example, if the element was deleted remotely and the remote deletion
574
- // hasn't been undone.
575
- console.warn(`Unable to find element with ID, ${id}.`);
576
- return null;
577
- }
578
- let originalZIndex = elem.getZIndex();
579
- let targetZIndex = elem.getZIndex() + this.deltaZIndex;
580
- // If the command has already been applied, the element should currently
581
- // have the target z-index.
582
- if (isUndoing) {
583
- targetZIndex = elem.getZIndex();
584
- originalZIndex = elem.getZIndex() - this.deltaZIndex;
585
- }
586
- return elem.setZIndexAndTransformBy(this.fullTransform, targetZIndex, originalZIndex);
587
- }).filter(// Remove all null commands
588
- // Remove all null commands
589
- command => command !== null);
590
- }
591
- async apply(editor) {
592
- this.resolveToElems(editor, false);
593
- this.selection?.setTransform(this.fullTransform, false);
594
- this.selection?.updateUI();
595
- await editor.asyncApplyCommands(this.transformCommands, updateChunkSize);
596
- this.selection?.setTransform(math_1.Mat33.identity, false);
597
- this.selection?.recomputeRegion();
598
- this.selection?.updateUI();
599
- }
600
- async unapply(editor) {
601
- this.resolveToElems(editor, true);
602
- this.selection?.setTransform(this.fullTransform.inverse(), false);
603
- this.selection?.updateUI();
604
- await editor.asyncUnapplyCommands(this.transformCommands, updateChunkSize, true);
605
- this.selection?.setTransform(math_1.Mat33.identity, false);
606
- this.selection?.recomputeRegion();
607
- this.selection?.updateUI();
608
- }
609
- serializeToJSON() {
610
- return {
611
- elems: this.selectedElemIds,
612
- transform: this.fullTransform.toArray(),
613
- deltaZIndex: this.deltaZIndex,
614
- };
615
- }
616
- description(_editor, localizationTable) {
617
- return localizationTable.transformedElements(this.selectedElemIds.length);
618
- }
619
- };
620
- exports.default = Selection;