js-draw 0.25.1 → 1.0.0

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 (810) hide show
  1. package/README.md +60 -20
  2. package/build-config.json +22 -21
  3. package/dist/Editor.css +1281 -0
  4. package/dist/bundle.js +3 -3
  5. package/dist/bundledStyles.js +1 -1
  6. package/dist/cjs/Editor.d.ts +91 -12
  7. package/dist/cjs/Editor.js +619 -590
  8. package/dist/cjs/EditorImage.d.ts +5 -2
  9. package/dist/cjs/EditorImage.js +258 -297
  10. package/dist/cjs/EventDispatcher.js +17 -19
  11. package/dist/cjs/Pointer.d.ts +3 -1
  12. package/dist/cjs/Pointer.js +41 -44
  13. package/dist/cjs/SVGLoader.d.ts +7 -1
  14. package/dist/cjs/SVGLoader.js +373 -474
  15. package/dist/cjs/UndoRedoHistory.js +28 -40
  16. package/dist/cjs/Viewport.d.ts +1 -4
  17. package/dist/cjs/Viewport.js +150 -193
  18. package/dist/cjs/bundle/bundled.js +4 -1
  19. package/dist/cjs/commands/Command.js +22 -49
  20. package/dist/cjs/commands/Duplicate.js +28 -44
  21. package/dist/cjs/commands/Erase.js +36 -54
  22. package/dist/cjs/commands/SerializableCommand.js +20 -35
  23. package/dist/cjs/commands/UnresolvedCommand.js +14 -29
  24. package/dist/cjs/commands/invertCommand.js +29 -51
  25. package/dist/cjs/commands/lib.js +9 -6
  26. package/dist/cjs/commands/localization.d.ts +1 -1
  27. package/dist/cjs/commands/localization.js +9 -9
  28. package/dist/cjs/commands/uniteCommands.js +57 -87
  29. package/dist/cjs/components/AbstractComponent.d.ts +11 -3
  30. package/dist/cjs/components/AbstractComponent.js +141 -169
  31. package/dist/cjs/components/BackgroundComponent.d.ts +3 -6
  32. package/dist/cjs/components/BackgroundComponent.js +124 -149
  33. package/dist/cjs/components/ImageComponent.d.ts +3 -5
  34. package/dist/cjs/components/ImageComponent.js +95 -175
  35. package/dist/cjs/components/RestylableComponent.d.ts +1 -1
  36. package/dist/cjs/components/RestylableComponent.js +41 -56
  37. package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +1 -3
  38. package/dist/cjs/components/SVGGlobalAttributesObject.js +34 -51
  39. package/dist/cjs/components/Stroke.d.ts +4 -6
  40. package/dist/cjs/components/Stroke.js +95 -121
  41. package/dist/cjs/components/TextComponent.d.ts +2 -4
  42. package/dist/cjs/components/TextComponent.js +189 -234
  43. package/dist/cjs/components/UnknownSVGObject.d.ts +1 -3
  44. package/dist/cjs/components/UnknownSVGObject.js +30 -43
  45. package/dist/cjs/components/builders/ArrowBuilder.d.ts +1 -1
  46. package/dist/cjs/components/builders/ArrowBuilder.js +43 -42
  47. package/dist/cjs/components/builders/CircleBuilder.js +43 -43
  48. package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +3 -2
  49. package/dist/cjs/components/builders/FreehandLineBuilder.js +73 -86
  50. package/dist/cjs/components/builders/LineBuilder.d.ts +1 -1
  51. package/dist/cjs/components/builders/LineBuilder.js +38 -36
  52. package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
  53. package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +131 -139
  54. package/dist/cjs/components/builders/RectangleBuilder.d.ts +1 -1
  55. package/dist/cjs/components/builders/RectangleBuilder.js +31 -31
  56. package/dist/cjs/components/builders/types.d.ts +1 -1
  57. package/dist/cjs/components/lib.d.ts +3 -1
  58. package/dist/cjs/components/lib.js +10 -7
  59. package/dist/cjs/components/localization.js +4 -4
  60. package/dist/cjs/components/util/StrokeSmoother.d.ts +1 -2
  61. package/dist/cjs/components/util/StrokeSmoother.js +67 -72
  62. package/dist/cjs/components/util/describeComponentList.d.ts +1 -1
  63. package/dist/cjs/components/util/describeComponentList.js +4 -5
  64. package/dist/cjs/dialogs/makeAboutDialog.d.ts +15 -0
  65. package/dist/cjs/dialogs/makeAboutDialog.js +54 -0
  66. package/dist/cjs/inputEvents.d.ts +84 -0
  67. package/dist/cjs/inputEvents.js +40 -0
  68. package/dist/cjs/lib.d.ts +29 -13
  69. package/dist/cjs/lib.js +38 -23
  70. package/dist/cjs/localization.js +19 -18
  71. package/dist/cjs/localizations/de.js +117 -13
  72. package/dist/cjs/localizations/en.js +4 -13
  73. package/dist/cjs/localizations/es.js +62 -23
  74. package/dist/cjs/localizations/getLocalizationTable.js +15 -13
  75. package/dist/cjs/rendering/Display.d.ts +1 -2
  76. package/dist/cjs/rendering/Display.js +70 -83
  77. package/dist/cjs/rendering/RenderablePathSpec.d.ts +15 -0
  78. package/dist/cjs/rendering/RenderablePathSpec.js +70 -0
  79. package/dist/cjs/rendering/RenderingStyle.d.ts +4 -4
  80. package/dist/cjs/rendering/RenderingStyle.js +18 -28
  81. package/dist/cjs/rendering/TextRenderingStyle.d.ts +10 -10
  82. package/dist/cjs/rendering/TextRenderingStyle.js +13 -18
  83. package/dist/cjs/rendering/caching/CacheRecord.d.ts +1 -2
  84. package/dist/cjs/rendering/caching/CacheRecord.js +20 -22
  85. package/dist/cjs/rendering/caching/CacheRecordManager.d.ts +1 -1
  86. package/dist/cjs/rendering/caching/CacheRecordManager.js +17 -15
  87. package/dist/cjs/rendering/caching/RenderingCache.js +19 -19
  88. package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
  89. package/dist/cjs/rendering/caching/RenderingCacheNode.js +98 -118
  90. package/dist/cjs/rendering/caching/testUtils.js +24 -23
  91. package/dist/cjs/rendering/caching/types.d.ts +3 -3
  92. package/dist/cjs/rendering/lib.js +8 -5
  93. package/dist/cjs/rendering/localization.js +5 -5
  94. package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
  95. package/dist/cjs/rendering/renderers/AbstractRenderer.js +53 -57
  96. package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
  97. package/dist/cjs/rendering/renderers/CanvasRenderer.js +91 -106
  98. package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +1 -4
  99. package/dist/cjs/rendering/renderers/DummyRenderer.js +56 -76
  100. package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +5 -5
  101. package/dist/cjs/rendering/renderers/SVGRenderer.js +194 -176
  102. package/dist/cjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
  103. package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +47 -72
  104. package/dist/cjs/shortcuts/KeyBinding.d.ts +5 -0
  105. package/dist/cjs/shortcuts/KeyBinding.js +94 -70
  106. package/dist/cjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
  107. package/dist/cjs/shortcuts/KeyboardShortcutManager.js +36 -45
  108. package/dist/cjs/shortcuts/lib.js +5 -2
  109. package/dist/cjs/testing/createEditor.js +7 -4
  110. package/dist/cjs/testing/getUniquePointerId.js +4 -5
  111. package/dist/cjs/testing/lib.js +5 -2
  112. package/dist/cjs/testing/sendPenEvent.d.ts +2 -2
  113. package/dist/cjs/testing/sendPenEvent.js +10 -7
  114. package/dist/cjs/testing/sendTouchEvent.d.ts +2 -2
  115. package/dist/cjs/testing/sendTouchEvent.js +34 -16
  116. package/dist/cjs/toolbar/AbstractToolbar.d.ts +166 -0
  117. package/dist/cjs/toolbar/AbstractToolbar.js +410 -0
  118. package/dist/cjs/toolbar/DropdownToolbar.d.ts +43 -0
  119. package/dist/cjs/toolbar/DropdownToolbar.js +176 -0
  120. package/dist/cjs/toolbar/EdgeToolbar.d.ts +47 -0
  121. package/dist/cjs/toolbar/EdgeToolbar.js +422 -0
  122. package/dist/cjs/toolbar/IconProvider.d.ts +54 -30
  123. package/dist/cjs/toolbar/IconProvider.js +652 -224
  124. package/dist/cjs/toolbar/constants.d.ts +1 -0
  125. package/dist/cjs/toolbar/constants.js +4 -0
  126. package/dist/cjs/toolbar/lib.d.ts +4 -2
  127. package/dist/cjs/toolbar/lib.js +10 -3
  128. package/dist/cjs/toolbar/localization.d.ts +9 -2
  129. package/dist/cjs/toolbar/localization.js +26 -19
  130. package/dist/cjs/toolbar/types.d.ts +7 -0
  131. package/dist/cjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
  132. package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +23 -39
  133. package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
  134. package/dist/cjs/toolbar/widgets/BaseToolWidget.js +35 -37
  135. package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +60 -5
  136. package/dist/cjs/toolbar/widgets/BaseWidget.js +232 -177
  137. package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +130 -117
  138. package/dist/cjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
  139. package/dist/cjs/toolbar/widgets/EraserToolWidget.js +45 -73
  140. package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
  141. package/dist/cjs/toolbar/widgets/HandToolWidget.js +126 -141
  142. package/dist/cjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
  143. package/dist/cjs/toolbar/widgets/InsertImageWidget.js +147 -212
  144. package/dist/cjs/toolbar/widgets/OverflowWidget.js +33 -61
  145. package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
  146. package/dist/cjs/toolbar/widgets/PenToolWidget.js +162 -234
  147. package/dist/cjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
  148. package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +105 -177
  149. package/dist/cjs/toolbar/widgets/TextToolWidget.js +64 -87
  150. package/dist/cjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
  151. package/dist/cjs/toolbar/{makeColorInput.js → widgets/components/makeColorInput.js} +57 -34
  152. package/dist/cjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
  153. package/dist/cjs/toolbar/widgets/components/makeFileInput.js +111 -0
  154. package/dist/cjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
  155. package/dist/cjs/toolbar/widgets/components/makeGridSelector.js +127 -0
  156. package/dist/cjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
  157. package/dist/cjs/toolbar/widgets/components/makeSeparator.js +16 -0
  158. package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
  159. package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.js +47 -0
  160. package/dist/cjs/toolbar/widgets/keybindings.js +8 -5
  161. package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
  162. package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.js +199 -0
  163. package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
  164. package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.js +60 -0
  165. package/dist/cjs/toolbar/widgets/layout/types.d.ts +63 -0
  166. package/dist/cjs/toolbar/widgets/layout/types.js +2 -0
  167. package/dist/cjs/toolbar/widgets/lib.d.ts +1 -1
  168. package/dist/cjs/toolbar/widgets/lib.js +15 -11
  169. package/dist/cjs/tools/BaseTool.d.ts +28 -9
  170. package/dist/cjs/tools/BaseTool.js +128 -51
  171. package/dist/cjs/tools/Eraser.d.ts +8 -1
  172. package/dist/cjs/tools/Eraser.js +82 -92
  173. package/dist/cjs/tools/FindTool.d.ts +1 -1
  174. package/dist/cjs/tools/FindTool.js +61 -77
  175. package/dist/cjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
  176. package/dist/cjs/tools/InputFilter/FunctionMapper.js +21 -0
  177. package/dist/cjs/tools/InputFilter/InputMapper.d.ts +23 -0
  178. package/dist/cjs/tools/InputFilter/InputMapper.js +38 -0
  179. package/dist/cjs/tools/InputFilter/InputPipeline.d.ts +15 -0
  180. package/dist/cjs/tools/InputFilter/InputPipeline.js +54 -0
  181. package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
  182. package/dist/cjs/tools/InputFilter/InputStabilizer.js +181 -0
  183. package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
  184. package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +84 -0
  185. package/dist/cjs/tools/PanZoom.d.ts +4 -2
  186. package/dist/cjs/tools/PanZoom.js +186 -248
  187. package/dist/cjs/tools/PasteHandler.d.ts +1 -1
  188. package/dist/cjs/tools/PasteHandler.js +49 -148
  189. package/dist/cjs/tools/Pen.d.ts +12 -11
  190. package/dist/cjs/tools/Pen.js +123 -158
  191. package/dist/cjs/tools/PipetteTool.d.ts +11 -2
  192. package/dist/cjs/tools/PipetteTool.js +51 -48
  193. package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
  194. package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +15 -30
  195. package/dist/cjs/tools/SelectionTool/Selection.d.ts +5 -5
  196. package/dist/cjs/tools/SelectionTool/Selection.js +308 -415
  197. package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
  198. package/dist/cjs/tools/SelectionTool/SelectionHandle.js +63 -37
  199. package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
  200. package/dist/cjs/tools/SelectionTool/SelectionTool.js +164 -187
  201. package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +1 -1
  202. package/dist/cjs/tools/SelectionTool/TransformMode.js +65 -66
  203. package/dist/cjs/tools/SoundUITool.d.ts +2 -1
  204. package/dist/cjs/tools/SoundUITool.js +70 -84
  205. package/dist/cjs/tools/TextTool.d.ts +5 -3
  206. package/dist/cjs/tools/TextTool.js +169 -173
  207. package/dist/cjs/tools/ToolController.d.ts +16 -2
  208. package/dist/cjs/tools/ToolController.js +124 -100
  209. package/dist/cjs/tools/ToolEnabledGroup.js +6 -9
  210. package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +1 -1
  211. package/dist/cjs/tools/ToolSwitcherShortcut.js +16 -32
  212. package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +1 -1
  213. package/dist/cjs/tools/ToolbarShortcutHandler.js +17 -33
  214. package/dist/cjs/tools/UndoRedoShortcut.d.ts +1 -1
  215. package/dist/cjs/tools/UndoRedoShortcut.js +12 -27
  216. package/dist/cjs/tools/keybindings.js +21 -18
  217. package/dist/cjs/tools/lib.js +17 -14
  218. package/dist/cjs/tools/localization.d.ts +2 -1
  219. package/dist/cjs/tools/localization.js +8 -7
  220. package/dist/cjs/types.d.ts +22 -80
  221. package/dist/cjs/types.js +8 -16
  222. package/dist/cjs/util/ReactiveValue.d.ts +65 -0
  223. package/dist/cjs/util/ReactiveValue.js +166 -0
  224. package/dist/cjs/util/assertions.js +5 -8
  225. package/dist/cjs/util/fileToBase64.js +6 -6
  226. package/dist/cjs/util/guessKeyCodeFromKey.d.ts +9 -0
  227. package/dist/cjs/util/guessKeyCodeFromKey.js +32 -0
  228. package/dist/cjs/util/listPrefixMatch.d.ts +6 -0
  229. package/dist/cjs/util/listPrefixMatch.js +17 -0
  230. package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
  231. package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.js +17 -0
  232. package/dist/cjs/util/untilNextAnimationFrame.js +3 -3
  233. package/dist/cjs/util/waitForAll.js +3 -3
  234. package/dist/cjs/util/waitForTimeout.js +3 -3
  235. package/dist/cjs/version.d.ts +4 -0
  236. package/dist/cjs/version.js +5 -0
  237. package/dist/mjs/Editor.d.ts +91 -12
  238. package/dist/mjs/Editor.mjs +565 -563
  239. package/dist/mjs/EditorImage.d.ts +5 -2
  240. package/dist/mjs/EditorImage.mjs +248 -291
  241. package/dist/mjs/EventDispatcher.mjs +17 -20
  242. package/dist/mjs/Pointer.d.ts +3 -1
  243. package/dist/mjs/Pointer.mjs +40 -44
  244. package/dist/mjs/SVGLoader.d.ts +7 -1
  245. package/dist/mjs/SVGLoader.mjs +338 -466
  246. package/dist/mjs/UndoRedoHistory.mjs +27 -39
  247. package/dist/mjs/Viewport.d.ts +1 -4
  248. package/dist/mjs/Viewport.mjs +139 -187
  249. package/dist/mjs/commands/Command.mjs +21 -49
  250. package/dist/mjs/commands/Duplicate.mjs +22 -41
  251. package/dist/mjs/commands/Erase.mjs +30 -51
  252. package/dist/mjs/commands/SerializableCommand.mjs +16 -34
  253. package/dist/mjs/commands/UnresolvedCommand.mjs +10 -29
  254. package/dist/mjs/commands/invertCommand.mjs +24 -49
  255. package/dist/mjs/commands/localization.d.ts +1 -1
  256. package/dist/mjs/commands/localization.mjs +10 -10
  257. package/dist/mjs/commands/uniteCommands.mjs +52 -85
  258. package/dist/mjs/components/AbstractComponent.d.ts +11 -3
  259. package/dist/mjs/components/AbstractComponent.mjs +135 -166
  260. package/dist/mjs/components/BackgroundComponent.d.ts +3 -6
  261. package/dist/mjs/components/BackgroundComponent.mjs +107 -136
  262. package/dist/mjs/components/ImageComponent.d.ts +3 -5
  263. package/dist/mjs/components/ImageComponent.mjs +90 -174
  264. package/dist/mjs/components/RestylableComponent.d.ts +1 -1
  265. package/dist/mjs/components/RestylableComponent.mjs +35 -53
  266. package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +1 -3
  267. package/dist/mjs/components/SVGGlobalAttributesObject.mjs +29 -50
  268. package/dist/mjs/components/Stroke.d.ts +4 -6
  269. package/dist/mjs/components/Stroke.mjs +89 -119
  270. package/dist/mjs/components/TextComponent.d.ts +2 -4
  271. package/dist/mjs/components/TextComponent.mjs +180 -228
  272. package/dist/mjs/components/UnknownSVGObject.d.ts +1 -3
  273. package/dist/mjs/components/UnknownSVGObject.mjs +26 -43
  274. package/dist/mjs/components/builders/ArrowBuilder.d.ts +1 -1
  275. package/dist/mjs/components/builders/ArrowBuilder.mjs +32 -35
  276. package/dist/mjs/components/builders/CircleBuilder.mjs +35 -38
  277. package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +3 -2
  278. package/dist/mjs/components/builders/FreehandLineBuilder.mjs +52 -69
  279. package/dist/mjs/components/builders/LineBuilder.d.ts +1 -1
  280. package/dist/mjs/components/builders/LineBuilder.mjs +30 -32
  281. package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
  282. package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +103 -115
  283. package/dist/mjs/components/builders/RectangleBuilder.d.ts +1 -1
  284. package/dist/mjs/components/builders/RectangleBuilder.mjs +27 -31
  285. package/dist/mjs/components/builders/types.d.ts +1 -1
  286. package/dist/mjs/components/lib.d.ts +3 -1
  287. package/dist/mjs/components/lib.mjs +1 -1
  288. package/dist/mjs/components/localization.mjs +5 -5
  289. package/dist/mjs/components/util/StrokeSmoother.d.ts +1 -2
  290. package/dist/mjs/components/util/StrokeSmoother.mjs +63 -69
  291. package/dist/mjs/components/util/describeComponentList.d.ts +1 -1
  292. package/dist/mjs/components/util/describeComponentList.mjs +4 -5
  293. package/dist/mjs/dialogs/makeAboutDialog.d.ts +15 -0
  294. package/dist/mjs/dialogs/makeAboutDialog.mjs +52 -0
  295. package/dist/mjs/inputEvents.d.ts +84 -0
  296. package/dist/mjs/inputEvents.mjs +34 -0
  297. package/dist/mjs/lib.d.ts +29 -13
  298. package/dist/mjs/lib.mjs +30 -13
  299. package/dist/mjs/localization.mjs +14 -13
  300. package/dist/mjs/localizations/de.mjs +116 -12
  301. package/dist/mjs/localizations/en.mjs +3 -12
  302. package/dist/mjs/localizations/es.mjs +61 -22
  303. package/dist/mjs/localizations/getLocalizationTable.mjs +12 -13
  304. package/dist/mjs/rendering/Display.d.ts +1 -2
  305. package/dist/mjs/rendering/Display.mjs +62 -79
  306. package/dist/mjs/rendering/RenderablePathSpec.d.ts +15 -0
  307. package/dist/mjs/rendering/RenderablePathSpec.mjs +64 -0
  308. package/dist/mjs/rendering/RenderingStyle.d.ts +4 -4
  309. package/dist/mjs/rendering/RenderingStyle.mjs +16 -26
  310. package/dist/mjs/rendering/TextRenderingStyle.d.ts +10 -10
  311. package/dist/mjs/rendering/TextRenderingStyle.mjs +12 -17
  312. package/dist/mjs/rendering/caching/CacheRecord.d.ts +1 -2
  313. package/dist/mjs/rendering/caching/CacheRecord.mjs +20 -23
  314. package/dist/mjs/rendering/caching/CacheRecordManager.d.ts +1 -1
  315. package/dist/mjs/rendering/caching/CacheRecordManager.mjs +13 -15
  316. package/dist/mjs/rendering/caching/RenderingCache.mjs +13 -17
  317. package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
  318. package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +94 -115
  319. package/dist/mjs/rendering/caching/testUtils.mjs +19 -21
  320. package/dist/mjs/rendering/caching/types.d.ts +3 -3
  321. package/dist/mjs/rendering/localization.mjs +6 -6
  322. package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
  323. package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +47 -52
  324. package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
  325. package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +84 -103
  326. package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +1 -4
  327. package/dist/mjs/rendering/renderers/DummyRenderer.mjs +51 -75
  328. package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +5 -5
  329. package/dist/mjs/rendering/renderers/SVGRenderer.mjs +185 -171
  330. package/dist/mjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
  331. package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +43 -72
  332. package/dist/mjs/shortcuts/KeyBinding.d.ts +5 -0
  333. package/dist/mjs/shortcuts/KeyBinding.mjs +94 -71
  334. package/dist/mjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
  335. package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +32 -44
  336. package/dist/mjs/testing/createEditor.mjs +2 -2
  337. package/dist/mjs/testing/getUniquePointerId.mjs +4 -5
  338. package/dist/mjs/testing/sendPenEvent.d.ts +2 -2
  339. package/dist/mjs/testing/sendPenEvent.mjs +5 -5
  340. package/dist/mjs/testing/sendTouchEvent.d.ts +2 -2
  341. package/dist/mjs/testing/sendTouchEvent.mjs +8 -16
  342. package/dist/mjs/toolbar/AbstractToolbar.d.ts +166 -0
  343. package/dist/mjs/toolbar/AbstractToolbar.mjs +405 -0
  344. package/dist/mjs/toolbar/DropdownToolbar.d.ts +43 -0
  345. package/dist/mjs/toolbar/DropdownToolbar.mjs +168 -0
  346. package/dist/mjs/toolbar/EdgeToolbar.d.ts +47 -0
  347. package/dist/mjs/toolbar/EdgeToolbar.mjs +414 -0
  348. package/dist/mjs/toolbar/IconProvider.d.ts +54 -30
  349. package/dist/mjs/toolbar/IconProvider.mjs +644 -219
  350. package/dist/mjs/toolbar/constants.d.ts +1 -0
  351. package/dist/mjs/toolbar/constants.mjs +1 -0
  352. package/dist/mjs/toolbar/lib.d.ts +4 -2
  353. package/dist/mjs/toolbar/lib.mjs +3 -1
  354. package/dist/mjs/toolbar/localization.d.ts +9 -2
  355. package/dist/mjs/toolbar/localization.mjs +27 -20
  356. package/dist/mjs/toolbar/types.d.ts +7 -0
  357. package/dist/mjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
  358. package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +19 -39
  359. package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
  360. package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +30 -36
  361. package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +60 -5
  362. package/dist/mjs/toolbar/widgets/BaseWidget.mjs +227 -176
  363. package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +98 -111
  364. package/dist/mjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
  365. package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +41 -73
  366. package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
  367. package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +94 -136
  368. package/dist/mjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
  369. package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +140 -208
  370. package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +30 -62
  371. package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
  372. package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +150 -225
  373. package/dist/mjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
  374. package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +97 -173
  375. package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +59 -85
  376. package/dist/mjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
  377. package/dist/mjs/toolbar/{makeColorInput.mjs → widgets/components/makeColorInput.mjs} +53 -33
  378. package/dist/mjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
  379. package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +106 -0
  380. package/dist/mjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
  381. package/dist/mjs/toolbar/widgets/components/makeGridSelector.mjs +122 -0
  382. package/dist/mjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
  383. package/dist/mjs/toolbar/widgets/components/makeSeparator.mjs +14 -0
  384. package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
  385. package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.mjs +45 -0
  386. package/dist/mjs/toolbar/widgets/keybindings.mjs +5 -5
  387. package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
  388. package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.mjs +193 -0
  389. package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
  390. package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.mjs +57 -0
  391. package/dist/mjs/toolbar/widgets/layout/types.d.ts +63 -0
  392. package/dist/mjs/toolbar/widgets/lib.d.ts +1 -1
  393. package/dist/mjs/toolbar/widgets/lib.mjs +1 -1
  394. package/dist/mjs/tools/BaseTool.d.ts +28 -9
  395. package/dist/mjs/tools/BaseTool.mjs +127 -50
  396. package/dist/mjs/tools/Eraser.d.ts +8 -1
  397. package/dist/mjs/tools/Eraser.mjs +72 -86
  398. package/dist/mjs/tools/FindTool.d.ts +1 -1
  399. package/dist/mjs/tools/FindTool.mjs +55 -75
  400. package/dist/mjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
  401. package/dist/mjs/tools/InputFilter/FunctionMapper.mjs +15 -0
  402. package/dist/mjs/tools/InputFilter/InputMapper.d.ts +23 -0
  403. package/dist/mjs/tools/InputFilter/InputMapper.mjs +36 -0
  404. package/dist/mjs/tools/InputFilter/InputPipeline.d.ts +15 -0
  405. package/dist/mjs/tools/InputFilter/InputPipeline.mjs +49 -0
  406. package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
  407. package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +175 -0
  408. package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
  409. package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +78 -0
  410. package/dist/mjs/tools/PanZoom.d.ts +4 -2
  411. package/dist/mjs/tools/PanZoom.mjs +169 -235
  412. package/dist/mjs/tools/PasteHandler.d.ts +1 -1
  413. package/dist/mjs/tools/PasteHandler.mjs +42 -145
  414. package/dist/mjs/tools/Pen.d.ts +12 -11
  415. package/dist/mjs/tools/Pen.mjs +115 -154
  416. package/dist/mjs/tools/PipetteTool.d.ts +11 -2
  417. package/dist/mjs/tools/PipetteTool.mjs +47 -48
  418. package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
  419. package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +9 -28
  420. package/dist/mjs/tools/SelectionTool/Selection.d.ts +5 -5
  421. package/dist/mjs/tools/SelectionTool/Selection.mjs +268 -401
  422. package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
  423. package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +62 -37
  424. package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
  425. package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +153 -179
  426. package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +1 -1
  427. package/dist/mjs/tools/SelectionTool/TransformMode.mjs +52 -59
  428. package/dist/mjs/tools/SoundUITool.d.ts +2 -1
  429. package/dist/mjs/tools/SoundUITool.mjs +66 -84
  430. package/dist/mjs/tools/TextTool.d.ts +5 -3
  431. package/dist/mjs/tools/TextTool.mjs +155 -163
  432. package/dist/mjs/tools/ToolController.d.ts +16 -2
  433. package/dist/mjs/tools/ToolController.mjs +81 -84
  434. package/dist/mjs/tools/ToolEnabledGroup.mjs +6 -10
  435. package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +1 -1
  436. package/dist/mjs/tools/ToolSwitcherShortcut.mjs +12 -32
  437. package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +1 -1
  438. package/dist/mjs/tools/ToolbarShortcutHandler.mjs +13 -33
  439. package/dist/mjs/tools/UndoRedoShortcut.d.ts +1 -1
  440. package/dist/mjs/tools/UndoRedoShortcut.mjs +7 -26
  441. package/dist/mjs/tools/keybindings.mjs +34 -34
  442. package/dist/mjs/tools/localization.d.ts +2 -1
  443. package/dist/mjs/tools/localization.mjs +9 -8
  444. package/dist/mjs/types.d.ts +22 -80
  445. package/dist/mjs/types.mjs +7 -15
  446. package/dist/mjs/util/ReactiveValue.d.ts +65 -0
  447. package/dist/mjs/util/ReactiveValue.mjs +161 -0
  448. package/dist/mjs/util/assertions.mjs +5 -8
  449. package/dist/mjs/util/fileToBase64.mjs +6 -6
  450. package/dist/mjs/util/guessKeyCodeFromKey.d.ts +9 -0
  451. package/dist/mjs/util/guessKeyCodeFromKey.mjs +30 -0
  452. package/dist/mjs/util/listPrefixMatch.d.ts +6 -0
  453. package/dist/mjs/util/listPrefixMatch.mjs +15 -0
  454. package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
  455. package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.mjs +15 -0
  456. package/dist/mjs/util/untilNextAnimationFrame.mjs +3 -3
  457. package/dist/mjs/util/waitForAll.mjs +3 -3
  458. package/dist/mjs/util/waitForTimeout.mjs +3 -3
  459. package/dist/mjs/version.d.ts +4 -0
  460. package/dist/mjs/version.mjs +3 -0
  461. package/package.json +11 -22
  462. package/src/Coloris.css +8 -8
  463. package/src/Editor.scss +148 -0
  464. package/src/dialogs/dialogs.scss +36 -0
  465. package/src/dialogs/makeAboutDialog.scss +41 -0
  466. package/src/styles.js +1 -1
  467. package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
  468. package/src/toolbar/DropdownToolbar.scss +46 -0
  469. package/src/toolbar/EdgeToolbar.scss +511 -0
  470. package/src/toolbar/toolbar.scss +11 -0
  471. package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
  472. package/src/toolbar/widgets/HandToolWidget.scss +14 -0
  473. package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
  474. package/src/toolbar/widgets/PenToolWidget.css +0 -51
  475. package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
  476. package/src/toolbar/widgets/components/components.scss +5 -0
  477. package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
  478. package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
  479. package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
  480. package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
  481. package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
  482. package/src/tools/FindTool.css +3 -3
  483. package/src/tools/SelectionTool/SelectionTool.css +23 -11
  484. package/src/tools/tools.scss +4 -0
  485. package/tsconfig.json +1 -1
  486. package/typedoc.json +4 -0
  487. package/dist/cjs/Color4.d.ts +0 -69
  488. package/dist/cjs/Color4.js +0 -263
  489. package/dist/cjs/Editor.loadFrom.test.d.ts +0 -1
  490. package/dist/cjs/Editor.toSVG.test.d.ts +0 -1
  491. package/dist/cjs/EditorImage.test.d.ts +0 -1
  492. package/dist/cjs/EventDispatcher.test.d.ts +0 -1
  493. package/dist/cjs/SVGLoader.test.d.ts +0 -1
  494. package/dist/cjs/UndoRedoHistory.test.d.ts +0 -1
  495. package/dist/cjs/commands/uniteCommands.test.d.ts +0 -1
  496. package/dist/cjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
  497. package/dist/cjs/components/BackgroundComponent.test.d.ts +0 -1
  498. package/dist/cjs/components/Stroke.test.d.ts +0 -1
  499. package/dist/cjs/components/TextComponent.test.d.ts +0 -1
  500. package/dist/cjs/components/UnknownSVGObject.test.d.ts +0 -1
  501. package/dist/cjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
  502. package/dist/cjs/localizations/getLocalizationTable.test.d.ts +0 -1
  503. package/dist/cjs/math/Mat33.d.ts +0 -123
  504. package/dist/cjs/math/Mat33.js +0 -340
  505. package/dist/cjs/math/Mat33.test.d.ts +0 -1
  506. package/dist/cjs/math/Vec2.d.ts +0 -33
  507. package/dist/cjs/math/Vec2.js +0 -37
  508. package/dist/cjs/math/Vec2.test.d.ts +0 -1
  509. package/dist/cjs/math/Vec3.d.ts +0 -106
  510. package/dist/cjs/math/Vec3.js +0 -183
  511. package/dist/cjs/math/Vec3.test.d.ts +0 -1
  512. package/dist/cjs/math/lib.d.ts +0 -7
  513. package/dist/cjs/math/lib.js +0 -15
  514. package/dist/cjs/math/polynomial/solveQuadratic.d.ts +0 -9
  515. package/dist/cjs/math/polynomial/solveQuadratic.js +0 -39
  516. package/dist/cjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
  517. package/dist/cjs/math/rounding.d.ts +0 -4
  518. package/dist/cjs/math/rounding.js +0 -140
  519. package/dist/cjs/math/rounding.test.d.ts +0 -1
  520. package/dist/cjs/math/shapes/Abstract2DShape.d.ts +0 -49
  521. package/dist/cjs/math/shapes/Abstract2DShape.js +0 -42
  522. package/dist/cjs/math/shapes/BezierJSWrapper.d.ts +0 -36
  523. package/dist/cjs/math/shapes/BezierJSWrapper.js +0 -109
  524. package/dist/cjs/math/shapes/CubicBezier.d.ts +0 -17
  525. package/dist/cjs/math/shapes/CubicBezier.js +0 -50
  526. package/dist/cjs/math/shapes/LineSegment2.d.ts +0 -70
  527. package/dist/cjs/math/shapes/LineSegment2.js +0 -204
  528. package/dist/cjs/math/shapes/LineSegment2.test.d.ts +0 -1
  529. package/dist/cjs/math/shapes/Path.d.ts +0 -93
  530. package/dist/cjs/math/shapes/Path.fromString.test.d.ts +0 -1
  531. package/dist/cjs/math/shapes/Path.js +0 -865
  532. package/dist/cjs/math/shapes/Path.test.d.ts +0 -1
  533. package/dist/cjs/math/shapes/Path.toString.test.d.ts +0 -1
  534. package/dist/cjs/math/shapes/PointShape2D.d.ts +0 -18
  535. package/dist/cjs/math/shapes/PointShape2D.js +0 -46
  536. package/dist/cjs/math/shapes/QuadraticBezier.d.ts +0 -34
  537. package/dist/cjs/math/shapes/QuadraticBezier.js +0 -133
  538. package/dist/cjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
  539. package/dist/cjs/math/shapes/Rect2.d.ts +0 -57
  540. package/dist/cjs/math/shapes/Rect2.js +0 -311
  541. package/dist/cjs/math/shapes/Rect2.test.d.ts +0 -1
  542. package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
  543. package/dist/cjs/math/shapes/Triangle.js +0 -148
  544. package/dist/cjs/math/shapes/Triangle.test.d.ts +0 -1
  545. package/dist/cjs/rendering/RenderingStyle.test.d.ts +0 -1
  546. package/dist/cjs/rendering/caching/CacheRecord.test.d.ts +0 -1
  547. package/dist/cjs/rendering/caching/RenderingCache.test.d.ts +0 -1
  548. package/dist/cjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
  549. package/dist/cjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
  550. package/dist/cjs/shortcuts/KeyBinding.test.d.ts +0 -1
  551. package/dist/cjs/shortcuts/KeyboardShortcutManager.test.d.ts +0 -1
  552. package/dist/cjs/toolbar/HTMLToolbar.d.ts +0 -105
  553. package/dist/cjs/toolbar/HTMLToolbar.js +0 -465
  554. package/dist/cjs/toolbar/makeColorInput.d.ts +0 -6
  555. package/dist/cjs/tools/Eraser.test.d.ts +0 -1
  556. package/dist/cjs/tools/PanZoom.test.d.ts +0 -1
  557. package/dist/cjs/tools/Pen.test.d.ts +0 -1
  558. package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
  559. package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +0 -1
  560. package/dist/mjs/Color4.d.ts +0 -69
  561. package/dist/mjs/Color4.mjs +0 -260
  562. package/dist/mjs/Color4.test.d.ts +0 -1
  563. package/dist/mjs/Editor.loadFrom.test.d.ts +0 -1
  564. package/dist/mjs/Editor.toSVG.test.d.ts +0 -1
  565. package/dist/mjs/EditorImage.test.d.ts +0 -1
  566. package/dist/mjs/EventDispatcher.test.d.ts +0 -1
  567. package/dist/mjs/SVGLoader.test.d.ts +0 -1
  568. package/dist/mjs/UndoRedoHistory.test.d.ts +0 -1
  569. package/dist/mjs/commands/uniteCommands.test.d.ts +0 -1
  570. package/dist/mjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
  571. package/dist/mjs/components/BackgroundComponent.test.d.ts +0 -1
  572. package/dist/mjs/components/Stroke.test.d.ts +0 -1
  573. package/dist/mjs/components/TextComponent.test.d.ts +0 -1
  574. package/dist/mjs/components/UnknownSVGObject.test.d.ts +0 -1
  575. package/dist/mjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
  576. package/dist/mjs/localizations/getLocalizationTable.test.d.ts +0 -1
  577. package/dist/mjs/math/Mat33.d.ts +0 -123
  578. package/dist/mjs/math/Mat33.mjs +0 -338
  579. package/dist/mjs/math/Mat33.test.d.ts +0 -1
  580. package/dist/mjs/math/Vec2.d.ts +0 -33
  581. package/dist/mjs/math/Vec2.mjs +0 -34
  582. package/dist/mjs/math/Vec2.test.d.ts +0 -1
  583. package/dist/mjs/math/Vec3.d.ts +0 -106
  584. package/dist/mjs/math/Vec3.mjs +0 -181
  585. package/dist/mjs/math/Vec3.test.d.ts +0 -1
  586. package/dist/mjs/math/lib.d.ts +0 -7
  587. package/dist/mjs/math/lib.mjs +0 -7
  588. package/dist/mjs/math/polynomial/solveQuadratic.d.ts +0 -9
  589. package/dist/mjs/math/polynomial/solveQuadratic.mjs +0 -37
  590. package/dist/mjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
  591. package/dist/mjs/math/rounding.d.ts +0 -4
  592. package/dist/mjs/math/rounding.mjs +0 -133
  593. package/dist/mjs/math/rounding.test.d.ts +0 -1
  594. package/dist/mjs/math/shapes/Abstract2DShape.d.ts +0 -49
  595. package/dist/mjs/math/shapes/Abstract2DShape.mjs +0 -40
  596. package/dist/mjs/math/shapes/BezierJSWrapper.d.ts +0 -36
  597. package/dist/mjs/math/shapes/BezierJSWrapper.mjs +0 -107
  598. package/dist/mjs/math/shapes/CubicBezier.d.ts +0 -17
  599. package/dist/mjs/math/shapes/CubicBezier.mjs +0 -48
  600. package/dist/mjs/math/shapes/LineSegment2.d.ts +0 -70
  601. package/dist/mjs/math/shapes/LineSegment2.mjs +0 -202
  602. package/dist/mjs/math/shapes/LineSegment2.test.d.ts +0 -1
  603. package/dist/mjs/math/shapes/Path.d.ts +0 -93
  604. package/dist/mjs/math/shapes/Path.fromString.test.d.ts +0 -1
  605. package/dist/mjs/math/shapes/Path.mjs +0 -862
  606. package/dist/mjs/math/shapes/Path.test.d.ts +0 -1
  607. package/dist/mjs/math/shapes/Path.toString.test.d.ts +0 -1
  608. package/dist/mjs/math/shapes/PointShape2D.d.ts +0 -18
  609. package/dist/mjs/math/shapes/PointShape2D.mjs +0 -44
  610. package/dist/mjs/math/shapes/QuadraticBezier.d.ts +0 -34
  611. package/dist/mjs/math/shapes/QuadraticBezier.mjs +0 -131
  612. package/dist/mjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
  613. package/dist/mjs/math/shapes/Rect2.d.ts +0 -57
  614. package/dist/mjs/math/shapes/Rect2.mjs +0 -309
  615. package/dist/mjs/math/shapes/Rect2.test.d.ts +0 -1
  616. package/dist/mjs/math/shapes/Triangle.d.ts +0 -46
  617. package/dist/mjs/math/shapes/Triangle.mjs +0 -146
  618. package/dist/mjs/math/shapes/Triangle.test.d.ts +0 -1
  619. package/dist/mjs/rendering/RenderingStyle.test.d.ts +0 -1
  620. package/dist/mjs/rendering/caching/CacheRecord.test.d.ts +0 -1
  621. package/dist/mjs/rendering/caching/RenderingCache.test.d.ts +0 -1
  622. package/dist/mjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
  623. package/dist/mjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
  624. package/dist/mjs/shortcuts/KeyBinding.test.d.ts +0 -1
  625. package/dist/mjs/shortcuts/KeyboardShortcutManager.test.d.ts +0 -1
  626. package/dist/mjs/toolbar/HTMLToolbar.d.ts +0 -105
  627. package/dist/mjs/toolbar/HTMLToolbar.mjs +0 -462
  628. package/dist/mjs/toolbar/makeColorInput.d.ts +0 -6
  629. package/dist/mjs/tools/Eraser.test.d.ts +0 -1
  630. package/dist/mjs/tools/PanZoom.test.d.ts +0 -1
  631. package/dist/mjs/tools/Pen.test.d.ts +0 -1
  632. package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
  633. package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +0 -1
  634. package/dist-test/test_imports/package-lock.json +0 -13
  635. package/dist-test/test_imports/package.json +0 -12
  636. package/dist-test/test_imports/test-imports.js +0 -17
  637. package/dist-test/test_imports/test-require.cjs +0 -19
  638. package/src/Color4.test.ts +0 -47
  639. package/src/Color4.ts +0 -304
  640. package/src/Editor.css +0 -98
  641. package/src/Editor.loadFrom.test.ts +0 -24
  642. package/src/Editor.toSVG.test.ts +0 -111
  643. package/src/Editor.ts +0 -1171
  644. package/src/EditorImage.test.ts +0 -120
  645. package/src/EditorImage.ts +0 -603
  646. package/src/EventDispatcher.test.ts +0 -123
  647. package/src/EventDispatcher.ts +0 -72
  648. package/src/Pointer.ts +0 -170
  649. package/src/SVGLoader.test.ts +0 -114
  650. package/src/SVGLoader.ts +0 -610
  651. package/src/UndoRedoHistory.test.ts +0 -33
  652. package/src/UndoRedoHistory.ts +0 -102
  653. package/src/Viewport.ts +0 -325
  654. package/src/bundle/bundled.ts +0 -7
  655. package/src/commands/Command.ts +0 -45
  656. package/src/commands/Duplicate.ts +0 -75
  657. package/src/commands/Erase.ts +0 -94
  658. package/src/commands/SerializableCommand.ts +0 -49
  659. package/src/commands/UnresolvedCommand.ts +0 -37
  660. package/src/commands/invertCommand.ts +0 -58
  661. package/src/commands/lib.ts +0 -16
  662. package/src/commands/localization.ts +0 -47
  663. package/src/commands/uniteCommands.test.ts +0 -23
  664. package/src/commands/uniteCommands.ts +0 -140
  665. package/src/components/AbstractComponent.transformBy.test.ts +0 -22
  666. package/src/components/AbstractComponent.ts +0 -374
  667. package/src/components/BackgroundComponent.test.ts +0 -45
  668. package/src/components/BackgroundComponent.ts +0 -353
  669. package/src/components/ImageComponent.ts +0 -178
  670. package/src/components/RestylableComponent.ts +0 -161
  671. package/src/components/SVGGlobalAttributesObject.ts +0 -81
  672. package/src/components/Stroke.test.ts +0 -139
  673. package/src/components/Stroke.ts +0 -296
  674. package/src/components/TextComponent.test.ts +0 -204
  675. package/src/components/TextComponent.ts +0 -432
  676. package/src/components/UnknownSVGObject.test.ts +0 -10
  677. package/src/components/UnknownSVGObject.ts +0 -60
  678. package/src/components/builders/ArrowBuilder.ts +0 -107
  679. package/src/components/builders/CircleBuilder.ts +0 -102
  680. package/src/components/builders/FreehandLineBuilder.test.ts +0 -25
  681. package/src/components/builders/FreehandLineBuilder.ts +0 -212
  682. package/src/components/builders/LineBuilder.ts +0 -77
  683. package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
  684. package/src/components/builders/RectangleBuilder.ts +0 -74
  685. package/src/components/builders/types.ts +0 -15
  686. package/src/components/lib.ts +0 -31
  687. package/src/components/localization.ts +0 -24
  688. package/src/components/util/StrokeSmoother.ts +0 -302
  689. package/src/components/util/describeComponentList.ts +0 -18
  690. package/src/lib.ts +0 -69
  691. package/src/localization.ts +0 -34
  692. package/src/localizations/de.ts +0 -146
  693. package/src/localizations/en.ts +0 -8
  694. package/src/localizations/es.ts +0 -74
  695. package/src/localizations/getLocalizationTable.test.ts +0 -27
  696. package/src/localizations/getLocalizationTable.ts +0 -74
  697. package/src/math/Mat33.test.ts +0 -244
  698. package/src/math/Mat33.ts +0 -442
  699. package/src/math/Vec2.test.ts +0 -30
  700. package/src/math/Vec2.ts +0 -40
  701. package/src/math/Vec3.test.ts +0 -44
  702. package/src/math/Vec3.ts +0 -218
  703. package/src/math/lib.ts +0 -15
  704. package/src/math/polynomial/solveQuadratic.test.ts +0 -39
  705. package/src/math/polynomial/solveQuadratic.ts +0 -43
  706. package/src/math/rounding.test.ts +0 -65
  707. package/src/math/rounding.ts +0 -156
  708. package/src/math/shapes/Abstract2DShape.ts +0 -63
  709. package/src/math/shapes/BezierJSWrapper.ts +0 -93
  710. package/src/math/shapes/CubicBezier.ts +0 -35
  711. package/src/math/shapes/LineSegment2.test.ts +0 -99
  712. package/src/math/shapes/LineSegment2.ts +0 -231
  713. package/src/math/shapes/Path.fromString.test.ts +0 -223
  714. package/src/math/shapes/Path.test.ts +0 -309
  715. package/src/math/shapes/Path.toString.test.ts +0 -77
  716. package/src/math/shapes/Path.ts +0 -1027
  717. package/src/math/shapes/PointShape2D.ts +0 -33
  718. package/src/math/shapes/QuadraticBezier.test.ts +0 -31
  719. package/src/math/shapes/QuadraticBezier.ts +0 -141
  720. package/src/math/shapes/Rect2.test.ts +0 -209
  721. package/src/math/shapes/Rect2.ts +0 -344
  722. package/src/math/shapes/Triangle.test.ts +0 -61
  723. package/src/math/shapes/Triangle.ts +0 -139
  724. package/src/rendering/Display.ts +0 -248
  725. package/src/rendering/RenderingStyle.test.ts +0 -68
  726. package/src/rendering/RenderingStyle.ts +0 -55
  727. package/src/rendering/TextRenderingStyle.ts +0 -55
  728. package/src/rendering/caching/CacheRecord.test.ts +0 -49
  729. package/src/rendering/caching/CacheRecord.ts +0 -77
  730. package/src/rendering/caching/CacheRecordManager.ts +0 -71
  731. package/src/rendering/caching/RenderingCache.test.ts +0 -44
  732. package/src/rendering/caching/RenderingCache.ts +0 -66
  733. package/src/rendering/caching/RenderingCacheNode.ts +0 -405
  734. package/src/rendering/caching/testUtils.ts +0 -35
  735. package/src/rendering/caching/types.ts +0 -34
  736. package/src/rendering/lib.ts +0 -8
  737. package/src/rendering/localization.ts +0 -20
  738. package/src/rendering/renderers/AbstractRenderer.ts +0 -242
  739. package/src/rendering/renderers/CanvasRenderer.ts +0 -307
  740. package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
  741. package/src/rendering/renderers/DummyRenderer.ts +0 -145
  742. package/src/rendering/renderers/SVGRenderer.ts +0 -377
  743. package/src/rendering/renderers/TextOnlyRenderer.test.ts +0 -34
  744. package/src/rendering/renderers/TextOnlyRenderer.ts +0 -71
  745. package/src/shortcuts/KeyBinding.test.ts +0 -51
  746. package/src/shortcuts/KeyBinding.ts +0 -218
  747. package/src/shortcuts/KeyboardShortcutManager.test.ts +0 -95
  748. package/src/shortcuts/KeyboardShortcutManager.ts +0 -163
  749. package/src/shortcuts/lib.ts +0 -3
  750. package/src/testing/createEditor.ts +0 -11
  751. package/src/testing/getUniquePointerId.ts +0 -18
  752. package/src/testing/lib.ts +0 -3
  753. package/src/testing/sendPenEvent.ts +0 -36
  754. package/src/testing/sendTouchEvent.ts +0 -71
  755. package/src/toolbar/HTMLToolbar.ts +0 -567
  756. package/src/toolbar/IconProvider.ts +0 -805
  757. package/src/toolbar/lib.ts +0 -4
  758. package/src/toolbar/localization.ts +0 -114
  759. package/src/toolbar/makeColorInput.ts +0 -159
  760. package/src/toolbar/types.ts +0 -5
  761. package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
  762. package/src/toolbar/widgets/BaseToolWidget.ts +0 -65
  763. package/src/toolbar/widgets/BaseWidget.ts +0 -428
  764. package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -234
  765. package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
  766. package/src/toolbar/widgets/HandToolWidget.ts +0 -250
  767. package/src/toolbar/widgets/InsertImageWidget.css +0 -44
  768. package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
  769. package/src/toolbar/widgets/OverflowWidget.ts +0 -92
  770. package/src/toolbar/widgets/PenToolWidget.ts +0 -409
  771. package/src/toolbar/widgets/SelectionToolWidget.ts +0 -197
  772. package/src/toolbar/widgets/TextToolWidget.ts +0 -145
  773. package/src/toolbar/widgets/keybindings.ts +0 -21
  774. package/src/toolbar/widgets/lib.ts +0 -13
  775. package/src/tools/BaseTool.ts +0 -97
  776. package/src/tools/Eraser.test.ts +0 -103
  777. package/src/tools/Eraser.ts +0 -160
  778. package/src/tools/FindTool.ts +0 -153
  779. package/src/tools/PanZoom.test.ts +0 -349
  780. package/src/tools/PanZoom.ts +0 -502
  781. package/src/tools/PasteHandler.ts +0 -95
  782. package/src/tools/Pen.test.ts +0 -262
  783. package/src/tools/Pen.ts +0 -300
  784. package/src/tools/PipetteTool.ts +0 -55
  785. package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -29
  786. package/src/tools/SelectionTool/Selection.ts +0 -611
  787. package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
  788. package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
  789. package/src/tools/SelectionTool/SelectionTool.ts +0 -496
  790. package/src/tools/SelectionTool/TransformMode.ts +0 -114
  791. package/src/tools/SelectionTool/types.ts +0 -11
  792. package/src/tools/SoundUITool.ts +0 -212
  793. package/src/tools/TextTool.ts +0 -340
  794. package/src/tools/ToolController.ts +0 -200
  795. package/src/tools/ToolEnabledGroup.ts +0 -14
  796. package/src/tools/ToolSwitcherShortcut.ts +0 -39
  797. package/src/tools/ToolbarShortcutHandler.ts +0 -39
  798. package/src/tools/UndoRedoShortcut.test.ts +0 -56
  799. package/src/tools/UndoRedoShortcut.ts +0 -24
  800. package/src/tools/keybindings.ts +0 -85
  801. package/src/tools/lib.ts +0 -22
  802. package/src/tools/localization.ts +0 -74
  803. package/src/tools/tools.css +0 -4
  804. package/src/types.ts +0 -239
  805. package/src/util/assertions.ts +0 -55
  806. package/src/util/fileToBase64.ts +0 -18
  807. package/src/util/untilNextAnimationFrame.ts +0 -9
  808. package/src/util/waitForAll.ts +0 -18
  809. package/src/util/waitForTimeout.ts +0 -9
  810. /package/dist/{cjs/Color4.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
@@ -1,59 +1,34 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
17
2
  if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
18
3
  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
19
4
  };
20
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
21
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
22
- if (ar || !(i in from)) {
23
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
24
- ar[i] = from[i];
25
- }
26
- }
27
- return to.concat(ar || Array.prototype.slice.call(from));
28
- };
5
+ var _a, _b, _c;
29
6
  import Viewport from './Viewport.mjs';
30
7
  import AbstractComponent from './components/AbstractComponent.mjs';
31
- import Rect2 from './math/shapes/Rect2.mjs';
8
+ import { Rect2, Vec2, Mat33 } from '@js-draw/math';
32
9
  import SerializableCommand from './commands/SerializableCommand.mjs';
33
10
  import EventDispatcher from './EventDispatcher.mjs';
34
- import { Vec2 } from './math/Vec2.mjs';
35
- import Mat33 from './math/Mat33.mjs';
36
11
  import { assertIsNumber, assertIsNumberArray } from './util/assertions.mjs';
37
12
  // @internal Sort by z-index, low to high
38
- export var sortLeavesByZIndex = function (leaves) {
39
- leaves.sort(function (a, b) { return a.getContent().getZIndex() - b.getContent().getZIndex(); });
13
+ export const sortLeavesByZIndex = (leaves) => {
14
+ leaves.sort((a, b) => a.getContent().getZIndex() - b.getContent().getZIndex());
40
15
  };
41
16
  export var EditorImageEventType;
42
17
  (function (EditorImageEventType) {
43
18
  EditorImageEventType[EditorImageEventType["ExportViewportChanged"] = 0] = "ExportViewportChanged";
44
19
  })(EditorImageEventType || (EditorImageEventType = {}));
45
20
  // Handles lookup/storage of elements in the image
46
- var EditorImage = /** @class */ (function () {
21
+ class EditorImage {
47
22
  // @internal
48
- function EditorImage() {
49
- var _this = this;
23
+ constructor() {
24
+ this.componentCount = 0;
50
25
  this.root = new ImageNode();
51
26
  this.background = new ImageNode();
52
27
  this.componentsById = {};
53
28
  this.notifier = new EventDispatcher();
54
- this.importExportViewport = new Viewport(function () {
55
- _this.notifier.dispatch(EditorImageEventType.ExportViewportChanged, {
56
- image: _this,
29
+ this.importExportViewport = new Viewport(() => {
30
+ this.notifier.dispatch(EditorImageEventType.ExportViewportChanged, {
31
+ image: this,
57
32
  });
58
33
  });
59
34
  // Default to a 500x500 image
@@ -61,96 +36,99 @@ var EditorImage = /** @class */ (function () {
61
36
  }
62
37
  // Returns all components that make up the background of this image. These
63
38
  // components are rendered below all other components.
64
- EditorImage.prototype.getBackgroundComponents = function () {
65
- var result = [];
66
- var leaves = this.background.getLeaves();
39
+ getBackgroundComponents() {
40
+ const result = [];
41
+ const leaves = this.background.getLeaves();
67
42
  sortLeavesByZIndex(leaves);
68
- for (var _i = 0, leaves_1 = leaves; _i < leaves_1.length; _i++) {
69
- var leaf = leaves_1[_i];
70
- var content = leaf.getContent();
43
+ for (const leaf of leaves) {
44
+ const content = leaf.getContent();
71
45
  if (content) {
72
46
  result.push(content);
73
47
  }
74
48
  }
75
49
  return result;
76
- };
50
+ }
77
51
  // Returns the parent of the given element, if it exists.
78
- EditorImage.prototype.findParent = function (elem) {
79
- var _b;
80
- return (_b = this.background.getChildWithContent(elem)) !== null && _b !== void 0 ? _b : this.root.getChildWithContent(elem);
81
- };
52
+ findParent(elem) {
53
+ return this.background.getChildWithContent(elem) ?? this.root.getChildWithContent(elem);
54
+ }
82
55
  // Forces a re-render of `elem` when the image is next re-rendered as a whole.
83
56
  // Does nothing if `elem` is not in this.
84
- EditorImage.prototype.queueRerenderOf = function (elem) {
57
+ queueRerenderOf(elem) {
85
58
  // TODO: Make more efficient (e.g. increase IDs of all parents,
86
59
  // make cache take into account last modified time instead of IDs, etc.)
87
- var parent = this.findParent(elem);
60
+ const parent = this.findParent(elem);
88
61
  if (parent) {
89
62
  parent.remove();
90
63
  this.addElementDirectly(elem);
91
64
  }
92
- };
65
+ }
93
66
  /** @internal */
94
- EditorImage.prototype.renderWithCache = function (screenRenderer, cache, viewport) {
67
+ renderWithCache(screenRenderer, cache, viewport) {
95
68
  this.background.render(screenRenderer, viewport.visibleRect);
96
69
  cache.render(screenRenderer, this.root, viewport);
97
- };
70
+ }
98
71
  /**
99
72
  * Renders all nodes visible from `viewport` (or all nodes if `viewport = null`).
100
73
  *
101
74
  * `viewport` is used to improve rendering performance. If given, it must match
102
75
  * the viewport used by the `renderer` (if any).
103
76
  */
104
- EditorImage.prototype.render = function (renderer, viewport) {
105
- this.background.render(renderer, viewport === null || viewport === void 0 ? void 0 : viewport.visibleRect);
106
- this.root.render(renderer, viewport === null || viewport === void 0 ? void 0 : viewport.visibleRect);
107
- };
77
+ render(renderer, viewport) {
78
+ this.background.render(renderer, viewport?.visibleRect);
79
+ this.root.render(renderer, viewport?.visibleRect);
80
+ }
108
81
  /** Renders all nodes, even ones not within the viewport. @internal */
109
- EditorImage.prototype.renderAll = function (renderer) {
82
+ renderAll(renderer) {
110
83
  this.render(renderer, null);
111
- };
84
+ }
112
85
  /** @returns all elements in the image, sorted by z-index. This can be slow for large images. */
113
- EditorImage.prototype.getAllElements = function () {
114
- var leaves = this.root.getLeaves();
86
+ getAllElements() {
87
+ const leaves = this.root.getLeaves();
115
88
  sortLeavesByZIndex(leaves);
116
- return leaves.map(function (leaf) { return leaf.getContent(); });
117
- };
89
+ return leaves.map(leaf => leaf.getContent());
90
+ }
91
+ /** Returns the number of elements added to this image. @internal */
92
+ estimateNumElements() {
93
+ return this.componentCount;
94
+ }
118
95
  /** @returns a list of `AbstractComponent`s intersecting `region`, sorted by z-index. */
119
- EditorImage.prototype.getElementsIntersectingRegion = function (region) {
120
- var leaves = this.root.getLeavesIntersectingRegion(region);
96
+ getElementsIntersectingRegion(region) {
97
+ const leaves = this.root.getLeavesIntersectingRegion(region);
121
98
  sortLeavesByZIndex(leaves);
122
- return leaves.map(function (leaf) { return leaf.getContent(); });
123
- };
124
- /** @internal */
125
- EditorImage.prototype.onDestroyElement = function (elem) {
99
+ return leaves.map(leaf => leaf.getContent());
100
+ }
101
+ /** Called whenever an element is completely removed. @internal */
102
+ onDestroyElement(elem) {
103
+ this.componentCount--;
126
104
  delete this.componentsById[elem.getId()];
127
- };
105
+ }
128
106
  /**
129
107
  * @returns the AbstractComponent with `id`, if it exists.
130
108
  *
131
109
  * @see {@link AbstractComponent.getId}
132
110
  */
133
- EditorImage.prototype.lookupElement = function (id) {
134
- var _b;
135
- return (_b = this.componentsById[id]) !== null && _b !== void 0 ? _b : null;
136
- };
137
- EditorImage.prototype.addElementDirectly = function (elem) {
111
+ lookupElement(id) {
112
+ return this.componentsById[id] ?? null;
113
+ }
114
+ addElementDirectly(elem) {
138
115
  elem.onAddToImage(this);
116
+ this.componentCount++;
139
117
  this.componentsById[elem.getId()] = elem;
140
118
  // If a background component, add to the background. Else,
141
119
  // add to the normal component tree.
142
- var parentTree = elem.isBackground() ? this.background : this.root;
120
+ const parentTree = elem.isBackground() ? this.background : this.root;
143
121
  return parentTree.addLeaf(elem);
144
- };
145
- EditorImage.prototype.removeElementDirectly = function (element) {
146
- var container = this.findParent(element);
147
- container === null || container === void 0 ? void 0 : container.remove();
122
+ }
123
+ removeElementDirectly(element) {
124
+ const container = this.findParent(element);
125
+ container?.remove();
148
126
  if (container) {
149
127
  this.onDestroyElement(element);
150
128
  return true;
151
129
  }
152
130
  return false;
153
- };
131
+ }
154
132
  /**
155
133
  * Returns a command that adds the given element to the `EditorImage`.
156
134
  * If `applyByFlattening` is true, the content of the wet ink renderer is
@@ -158,155 +136,143 @@ var EditorImage = /** @class */ (function () {
158
136
  *
159
137
  * @see {@link Display.flatten}
160
138
  */
161
- EditorImage.addElement = function (elem, applyByFlattening) {
162
- if (applyByFlattening === void 0) { applyByFlattening = false; }
139
+ static addElement(elem, applyByFlattening = false) {
163
140
  return new EditorImage.AddElementCommand(elem, applyByFlattening);
164
- };
141
+ }
165
142
  /** @see EditorImage.addElement */
166
- EditorImage.prototype.addElement = function (elem, applyByFlattening) {
143
+ addElement(elem, applyByFlattening) {
167
144
  return EditorImage.addElement(elem, applyByFlattening);
168
- };
145
+ }
169
146
  /**
170
147
  * @returns a `Viewport` for rendering the image when importing/exporting.
171
148
  */
172
- EditorImage.prototype.getImportExportViewport = function () {
149
+ getImportExportViewport() {
173
150
  return this.importExportViewport;
174
- };
175
- EditorImage.prototype.setImportExportRect = function (imageRect) {
176
- var importExportViewport = this.getImportExportViewport();
177
- var origSize = importExportViewport.visibleRect.size;
178
- var origTransform = importExportViewport.canvasToScreenTransform;
151
+ }
152
+ setImportExportRect(imageRect) {
153
+ const importExportViewport = this.getImportExportViewport();
154
+ const origSize = importExportViewport.visibleRect.size;
155
+ const origTransform = importExportViewport.canvasToScreenTransform;
179
156
  return new EditorImage.SetImportExportRectCommand(origSize, origTransform, imageRect);
180
- };
181
- var _a, _b, _c;
182
- _a = EditorImage;
183
- // A Command that can access private [EditorImage] functionality
184
- EditorImage.AddElementCommand = (_b = /** @class */ (function (_super) {
185
- __extends(class_1, _super);
186
- // If [applyByFlattening], then the rendered content of this element
187
- // is present on the display's wet ink canvas. As such, no re-render is necessary
188
- // the first time this command is applied (the surfaces are joined instead).
189
- function class_1(element, applyByFlattening) {
190
- if (applyByFlattening === void 0) { applyByFlattening = false; }
191
- var _this = _super.call(this, 'add-element') || this;
192
- _this.element = element;
193
- _this.applyByFlattening = applyByFlattening;
194
- _this.serializedElem = null;
195
- // FIXME: The serialized version of this command may be inaccurate if this is
196
- // serialized when this command is not on the top of the undo stack.
197
- //
198
- // Caching the element's serialized data leads to additional memory usage *and*
199
- // sometimes incorrect behavior in collaborative editing.
200
- _this.serializedElem = null;
201
- if (isNaN(element.getBBox().area)) {
202
- throw new Error('Elements in the image cannot have NaN bounding boxes');
203
- }
204
- return _this;
157
+ }
158
+ }
159
+ _a = EditorImage;
160
+ // A Command that can access private [EditorImage] functionality
161
+ EditorImage.AddElementCommand = (_b = class extends SerializableCommand {
162
+ // If [applyByFlattening], then the rendered content of this element
163
+ // is present on the display's wet ink canvas. As such, no re-render is necessary
164
+ // the first time this command is applied (the surfaces are joined instead).
165
+ constructor(element, applyByFlattening = false) {
166
+ super('add-element');
167
+ this.element = element;
168
+ this.applyByFlattening = applyByFlattening;
169
+ this.serializedElem = null;
170
+ // FIXME: The serialized version of this command may be inaccurate if this is
171
+ // serialized when this command is not on the top of the undo stack.
172
+ //
173
+ // Caching the element's serialized data leads to additional memory usage *and*
174
+ // sometimes incorrect behavior in collaborative editing.
175
+ this.serializedElem = null;
176
+ if (isNaN(element.getBBox().area)) {
177
+ throw new Error('Elements in the image cannot have NaN bounding boxes');
205
178
  }
206
- class_1.prototype.apply = function (editor) {
207
- editor.image.addElementDirectly(this.element);
208
- if (!this.applyByFlattening) {
209
- editor.queueRerender();
210
- }
211
- else {
212
- this.applyByFlattening = false;
213
- editor.display.flatten();
214
- }
215
- };
216
- class_1.prototype.unapply = function (editor) {
217
- editor.image.removeElementDirectly(this.element);
179
+ }
180
+ apply(editor) {
181
+ editor.image.addElementDirectly(this.element);
182
+ if (!this.applyByFlattening) {
218
183
  editor.queueRerender();
219
- };
220
- class_1.prototype.description = function (_editor, localization) {
221
- return localization.addElementAction(this.element.description(localization));
222
- };
223
- class_1.prototype.serializeToJSON = function () {
224
- var _b;
225
- return {
226
- elemData: (_b = this.serializedElem) !== null && _b !== void 0 ? _b : this.element.serialize(),
227
- };
228
- };
229
- return class_1;
230
- }(SerializableCommand)),
231
- __setFunctionName(_b, "AddElementCommand"),
232
- (function () {
233
- SerializableCommand.register('add-element', function (json, editor) {
234
- var id = json.elemData.id;
235
- var foundElem = editor.image.lookupElement(id);
236
- var elem = foundElem !== null && foundElem !== void 0 ? foundElem : AbstractComponent.deserialize(json.elemData);
237
- var result = new EditorImage.AddElementCommand(elem);
238
- result.serializedElem = json.elemData;
239
- return result;
240
- });
241
- })(),
242
- _b);
243
- // Handles resizing the background import/export region of the image.
244
- EditorImage.SetImportExportRectCommand = (_c = /** @class */ (function (_super) {
245
- __extends(class_2, _super);
246
- function class_2(originalSize, originalTransform, finalRect) {
247
- var _this = _super.call(this, EditorImage.SetImportExportRectCommand.commandId) || this;
248
- _this.originalSize = originalSize;
249
- _this.originalTransform = originalTransform;
250
- _this.finalRect = finalRect;
251
- return _this;
252
184
  }
253
- class_2.prototype.apply = function (editor) {
254
- var viewport = editor.image.getImportExportViewport();
255
- viewport.updateScreenSize(this.finalRect.size);
256
- viewport.resetTransform(Mat33.translation(this.finalRect.topLeft.times(-1)));
257
- editor.queueRerender();
258
- };
259
- class_2.prototype.unapply = function (editor) {
260
- var viewport = editor.image.getImportExportViewport();
261
- viewport.updateScreenSize(this.originalSize);
262
- viewport.resetTransform(this.originalTransform);
263
- editor.queueRerender();
264
- };
265
- class_2.prototype.description = function (_editor, localization) {
266
- return localization.resizeOutputCommand(this.finalRect);
185
+ else {
186
+ this.applyByFlattening = false;
187
+ editor.display.flatten();
188
+ }
189
+ }
190
+ unapply(editor) {
191
+ editor.image.removeElementDirectly(this.element);
192
+ editor.queueRerender();
193
+ }
194
+ description(_editor, localization) {
195
+ return localization.addElementAction(this.element.description(localization));
196
+ }
197
+ serializeToJSON() {
198
+ return {
199
+ elemData: this.serializedElem ?? this.element.serialize(),
267
200
  };
268
- class_2.prototype.serializeToJSON = function () {
269
- return {
270
- originalSize: this.originalSize.xy,
271
- originalTransform: this.originalTransform.toArray(),
272
- newRegion: {
273
- x: this.finalRect.x,
274
- y: this.finalRect.y,
275
- w: this.finalRect.w,
276
- h: this.finalRect.h,
277
- },
278
- };
201
+ }
202
+ },
203
+ __setFunctionName(_b, "AddElementCommand"),
204
+ (() => {
205
+ SerializableCommand.register('add-element', (json, editor) => {
206
+ const id = json.elemData.id;
207
+ const foundElem = editor.image.lookupElement(id);
208
+ const elem = foundElem ?? AbstractComponent.deserialize(json.elemData);
209
+ const result = new EditorImage.AddElementCommand(elem);
210
+ result.serializedElem = json.elemData;
211
+ return result;
212
+ });
213
+ })(),
214
+ _b);
215
+ // Handles resizing the background import/export region of the image.
216
+ EditorImage.SetImportExportRectCommand = (_c = class extends SerializableCommand {
217
+ constructor(originalSize, originalTransform, finalRect) {
218
+ super(EditorImage.SetImportExportRectCommand.commandId);
219
+ this.originalSize = originalSize;
220
+ this.originalTransform = originalTransform;
221
+ this.finalRect = finalRect;
222
+ }
223
+ apply(editor) {
224
+ const viewport = editor.image.getImportExportViewport();
225
+ viewport.updateScreenSize(this.finalRect.size);
226
+ viewport.resetTransform(Mat33.translation(this.finalRect.topLeft.times(-1)));
227
+ editor.queueRerender();
228
+ }
229
+ unapply(editor) {
230
+ const viewport = editor.image.getImportExportViewport();
231
+ viewport.updateScreenSize(this.originalSize);
232
+ viewport.resetTransform(this.originalTransform);
233
+ editor.queueRerender();
234
+ }
235
+ description(_editor, localization) {
236
+ return localization.resizeOutputCommand(this.finalRect);
237
+ }
238
+ serializeToJSON() {
239
+ return {
240
+ originalSize: this.originalSize.xy,
241
+ originalTransform: this.originalTransform.toArray(),
242
+ newRegion: {
243
+ x: this.finalRect.x,
244
+ y: this.finalRect.y,
245
+ w: this.finalRect.w,
246
+ h: this.finalRect.h,
247
+ },
279
248
  };
280
- return class_2;
281
- }(SerializableCommand)),
282
- __setFunctionName(_c, "SetImportExportRectCommand"),
283
- _c.commandId = 'set-import-export-rect',
284
- (function () {
285
- var commandId = _c.commandId;
286
- SerializableCommand.register(commandId, function (json, _editor) {
287
- assertIsNumber(json.originalSize.x);
288
- assertIsNumber(json.originalSize.y);
289
- assertIsNumberArray(json.originalTransform);
290
- assertIsNumberArray([
291
- json.newRegion.x,
292
- json.newRegion.y,
293
- json.newRegion.w,
294
- json.newRegion.h,
295
- ]);
296
- var originalSize = Vec2.ofXY(json.originalSize);
297
- var originalTransform = new (Mat33.bind.apply(Mat33, __spreadArray([void 0], json.originalTransform, false)))();
298
- var finalRect = new Rect2(json.newRegion.x, json.newRegion.y, json.newRegion.w, json.newRegion.h);
299
- return new EditorImage.SetImportExportRectCommand(originalSize, originalTransform, finalRect);
300
- });
301
- })(),
302
- _c);
303
- return EditorImage;
304
- }());
249
+ }
250
+ },
251
+ __setFunctionName(_c, "SetImportExportRectCommand"),
252
+ _c.commandId = 'set-import-export-rect',
253
+ (() => {
254
+ const commandId = _c.commandId;
255
+ SerializableCommand.register(commandId, (json, _editor) => {
256
+ assertIsNumber(json.originalSize.x);
257
+ assertIsNumber(json.originalSize.y);
258
+ assertIsNumberArray(json.originalTransform);
259
+ assertIsNumberArray([
260
+ json.newRegion.x,
261
+ json.newRegion.y,
262
+ json.newRegion.w,
263
+ json.newRegion.h,
264
+ ]);
265
+ const originalSize = Vec2.ofXY(json.originalSize);
266
+ const originalTransform = new Mat33(...json.originalTransform);
267
+ const finalRect = new Rect2(json.newRegion.x, json.newRegion.y, json.newRegion.w, json.newRegion.h);
268
+ return new EditorImage.SetImportExportRectCommand(originalSize, originalTransform, finalRect);
269
+ });
270
+ })(),
271
+ _c);
305
272
  export default EditorImage;
306
273
  /** Part of the Editor's image. @internal */
307
- export var ImageNode = /** @class */ (function () {
308
- function ImageNode(parent) {
309
- if (parent === void 0) { parent = null; }
274
+ export class ImageNode {
275
+ constructor(parent = null) {
310
276
  this.parent = parent;
311
277
  this.targetChildCount = 30;
312
278
  this.children = [];
@@ -314,77 +280,75 @@ export var ImageNode = /** @class */ (function () {
314
280
  this.content = null;
315
281
  this.id = ImageNode.idCounter++;
316
282
  }
317
- ImageNode.prototype.getId = function () {
283
+ getId() {
318
284
  return this.id;
319
- };
320
- ImageNode.prototype.onContentChange = function () {
285
+ }
286
+ onContentChange() {
321
287
  this.id = ImageNode.idCounter++;
322
- };
323
- ImageNode.prototype.getContent = function () {
288
+ }
289
+ getContent() {
324
290
  return this.content;
325
- };
326
- ImageNode.prototype.getParent = function () {
291
+ }
292
+ getParent() {
327
293
  return this.parent;
328
- };
329
- ImageNode.prototype.getChildrenIntersectingRegion = function (region) {
330
- return this.children.filter(function (child) {
294
+ }
295
+ getChildrenIntersectingRegion(region) {
296
+ return this.children.filter(child => {
331
297
  return child.getBBox().intersects(region);
332
298
  });
333
- };
334
- ImageNode.prototype.getChildrenOrSelfIntersectingRegion = function (region) {
299
+ }
300
+ getChildrenOrSelfIntersectingRegion(region) {
335
301
  if (this.content) {
336
302
  return [this];
337
303
  }
338
304
  return this.getChildrenIntersectingRegion(region);
339
- };
305
+ }
340
306
  // Returns a list of `ImageNode`s with content (and thus no children).
341
- ImageNode.prototype.getLeavesIntersectingRegion = function (region, isTooSmall) {
342
- var result = [];
343
- var current;
344
- var workList = [];
307
+ getLeavesIntersectingRegion(region, isTooSmall) {
308
+ const result = [];
309
+ let current;
310
+ const workList = [];
345
311
  workList.push(this);
346
- var toNext = function () {
312
+ const toNext = () => {
347
313
  current = undefined;
348
- var next = workList.pop();
349
- if (next && !(isTooSmall === null || isTooSmall === void 0 ? void 0 : isTooSmall(next.bbox))) {
314
+ const next = workList.pop();
315
+ if (next && !isTooSmall?.(next.bbox)) {
350
316
  current = next;
351
317
  if (current.content !== null && current.getBBox().intersection(region)) {
352
318
  result.push(current);
353
319
  }
354
- workList.push.apply(workList, current.getChildrenIntersectingRegion(region));
320
+ workList.push(...current.getChildrenIntersectingRegion(region));
355
321
  }
356
322
  };
357
323
  while (workList.length > 0) {
358
324
  toNext();
359
325
  }
360
326
  return result;
361
- };
327
+ }
362
328
  // Returns the child of this with the target content or `null` if no
363
329
  // such child exists.
364
- ImageNode.prototype.getChildWithContent = function (target) {
365
- var candidates = this.getLeavesIntersectingRegion(target.getBBox());
366
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
367
- var candidate = candidates_1[_i];
330
+ getChildWithContent(target) {
331
+ const candidates = this.getLeavesIntersectingRegion(target.getBBox());
332
+ for (const candidate of candidates) {
368
333
  if (candidate.getContent() === target) {
369
334
  return candidate;
370
335
  }
371
336
  }
372
337
  return null;
373
- };
338
+ }
374
339
  // Returns a list of leaves with this as an ancestor.
375
340
  // Like getLeavesInRegion, but does not check whether ancestors are in a given rectangle
376
- ImageNode.prototype.getLeaves = function () {
341
+ getLeaves() {
377
342
  if (this.content) {
378
343
  return [this];
379
344
  }
380
- var result = [];
381
- for (var _i = 0, _b = this.children; _i < _b.length; _i++) {
382
- var child = _b[_i];
383
- result.push.apply(result, child.getLeaves());
345
+ const result = [];
346
+ for (const child of this.children) {
347
+ result.push(...child.getLeaves());
384
348
  }
385
349
  return result;
386
- };
387
- ImageNode.prototype.addLeaf = function (leaf) {
350
+ }
351
+ addLeaf(leaf) {
388
352
  this.onContentChange();
389
353
  if (this.content === null && this.children.length === 0) {
390
354
  this.content = leaf;
@@ -393,7 +357,7 @@ export var ImageNode = /** @class */ (function () {
393
357
  }
394
358
  if (this.content !== null) {
395
359
  console.assert(this.children.length === 0);
396
- var contentNode = new ImageNode(this);
360
+ const contentNode = new ImageNode(this);
397
361
  contentNode.content = this.content;
398
362
  this.content = null;
399
363
  this.children.push(contentNode);
@@ -401,14 +365,14 @@ export var ImageNode = /** @class */ (function () {
401
365
  }
402
366
  // If this node is contained within the leaf, make this and the leaf
403
367
  // share a parent.
404
- var leafBBox = leaf.getBBox();
368
+ const leafBBox = leaf.getBBox();
405
369
  if (leafBBox.containsRect(this.getBBox())) {
406
- var nodeForNewLeaf = new ImageNode(this);
370
+ const nodeForNewLeaf = new ImageNode(this);
407
371
  if (this.children.length < this.targetChildCount) {
408
372
  this.children.push(nodeForNewLeaf);
409
373
  }
410
374
  else {
411
- var nodeForChildren = new ImageNode(this);
375
+ const nodeForChildren = new ImageNode(this);
412
376
  nodeForChildren.children = this.children;
413
377
  this.children = [nodeForNewLeaf, nodeForChildren];
414
378
  nodeForChildren.recomputeBBox(true);
@@ -416,58 +380,55 @@ export var ImageNode = /** @class */ (function () {
416
380
  }
417
381
  return nodeForNewLeaf.addLeaf(leaf);
418
382
  }
419
- var containingNodes = this.children.filter(function (child) { return child.getBBox().containsRect(leafBBox); });
383
+ const containingNodes = this.children.filter(child => child.getBBox().containsRect(leafBBox));
420
384
  // Does the leaf already fit within one of the children?
421
385
  if (containingNodes.length > 0 && this.children.length >= this.targetChildCount) {
422
386
  // Sort the containers in ascending order by area
423
- containingNodes.sort(function (a, b) { return a.getBBox().area - b.getBBox().area; });
387
+ containingNodes.sort((a, b) => a.getBBox().area - b.getBBox().area);
424
388
  // Choose the smallest child that contains the new element.
425
- var result = containingNodes[0].addLeaf(leaf);
389
+ const result = containingNodes[0].addLeaf(leaf);
426
390
  result.rebalance();
427
391
  return result;
428
392
  }
429
- var newNode = new ImageNode(this);
393
+ const newNode = new ImageNode(this);
430
394
  this.children.push(newNode);
431
395
  newNode.content = leaf;
432
396
  newNode.recomputeBBox(true);
433
397
  return newNode;
434
- };
435
- ImageNode.prototype.getBBox = function () {
398
+ }
399
+ getBBox() {
436
400
  return this.bbox;
437
- };
401
+ }
438
402
  // Recomputes this' bounding box. If [bubbleUp], also recompute
439
403
  // this' ancestors bounding boxes. This also re-computes this' bounding box
440
404
  // in the z-direction (z-indicies).
441
- ImageNode.prototype.recomputeBBox = function (bubbleUp) {
442
- var _b;
443
- var oldBBox = this.bbox;
405
+ recomputeBBox(bubbleUp) {
406
+ const oldBBox = this.bbox;
444
407
  if (this.content !== null) {
445
408
  this.bbox = this.content.getBBox();
446
409
  }
447
410
  else {
448
- this.bbox = Rect2.union.apply(Rect2, this.children.map(function (child) { return child.getBBox(); }));
411
+ this.bbox = Rect2.union(...this.children.map(child => child.getBBox()));
449
412
  }
450
413
  if (bubbleUp && !oldBBox.eq(this.bbox)) {
451
- (_b = this.parent) === null || _b === void 0 ? void 0 : _b.recomputeBBox(true);
414
+ this.parent?.recomputeBBox(true);
452
415
  }
453
- };
454
- ImageNode.prototype.updateParents = function (recursive) {
455
- if (recursive === void 0) { recursive = false; }
456
- for (var _i = 0, _b = this.children; _i < _b.length; _i++) {
457
- var child = _b[_i];
416
+ }
417
+ updateParents(recursive = false) {
418
+ for (const child of this.children) {
458
419
  child.parent = this;
459
420
  if (recursive) {
460
421
  child.updateParents(recursive);
461
422
  }
462
423
  }
463
- };
464
- ImageNode.prototype.rebalance = function () {
424
+ }
425
+ rebalance() {
465
426
  // If the current node is its parent's only child,
466
427
  if (this.parent && this.parent.children.length === 1) {
467
428
  console.assert(this.parent.content === null);
468
429
  console.assert(this.parent.children[0] === this);
469
430
  // Remove this' parent, if this' parent isn't the root.
470
- var oldParent = this.parent;
431
+ const oldParent = this.parent;
471
432
  if (oldParent.parent !== null) {
472
433
  oldParent.children = [];
473
434
  this.parent = oldParent.parent;
@@ -482,23 +443,21 @@ export var ImageNode = /** @class */ (function () {
482
443
  this.parent = null;
483
444
  }
484
445
  }
485
- };
446
+ }
486
447
  // Remove this node and all of its children
487
- ImageNode.prototype.remove = function () {
488
- var _this = this;
489
- var _b;
490
- (_b = this.content) === null || _b === void 0 ? void 0 : _b.onRemoveFromImage();
448
+ remove() {
449
+ this.content?.onRemoveFromImage();
491
450
  if (!this.parent) {
492
451
  this.content = null;
493
452
  this.children = [];
494
453
  return;
495
454
  }
496
- var oldChildCount = this.parent.children.length;
497
- this.parent.children = this.parent.children.filter(function (node) {
498
- return node !== _this;
455
+ const oldChildCount = this.parent.children.length;
456
+ this.parent.children = this.parent.children.filter(node => {
457
+ return node !== this;
499
458
  });
500
- console.assert(this.parent.children.length === oldChildCount - 1, "".concat(oldChildCount - 1, " \u2260 ").concat(this.parent.children.length, " after removing all nodes equal to ").concat(this, ". Nodes should only be removed once."));
501
- this.parent.children.forEach(function (child) {
459
+ console.assert(this.parent.children.length === oldChildCount - 1, `${oldChildCount - 1} ${this.parent.children.length} after removing all nodes equal to ${this}. Nodes should only be removed once.`);
460
+ this.parent.children.forEach(child => {
502
461
  child.rebalance();
503
462
  });
504
463
  this.parent.recomputeBBox(true);
@@ -506,22 +465,20 @@ export var ImageNode = /** @class */ (function () {
506
465
  this.content = null;
507
466
  this.parent = null;
508
467
  this.children = [];
509
- };
510
- ImageNode.prototype.render = function (renderer, visibleRect) {
511
- var leaves;
468
+ }
469
+ render(renderer, visibleRect) {
470
+ let leaves;
512
471
  if (visibleRect) {
513
- leaves = this.getLeavesIntersectingRegion(visibleRect, function (rect) { return renderer.isTooSmallToRender(rect); });
472
+ leaves = this.getLeavesIntersectingRegion(visibleRect, rect => renderer.isTooSmallToRender(rect));
514
473
  }
515
474
  else {
516
475
  leaves = this.getLeaves();
517
476
  }
518
477
  sortLeavesByZIndex(leaves);
519
- for (var _i = 0, leaves_2 = leaves; _i < leaves_2.length; _i++) {
520
- var leaf = leaves_2[_i];
478
+ for (const leaf of leaves) {
521
479
  // Leaves by definition have content
522
480
  leaf.getContent().render(renderer, visibleRect);
523
481
  }
524
- };
525
- ImageNode.idCounter = 0;
526
- return ImageNode;
527
- }());
482
+ }
483
+ }
484
+ ImageNode.idCounter = 0;