js-draw 0.25.1 → 1.0.1

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 (750) hide show
  1. package/README.md +80 -26
  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/dist-test/test_imports/package.json +1 -1
  462. package/dist-test/test_imports/test-imports.js +5 -11
  463. package/dist-test/test_imports/test-require.cjs +6 -11
  464. package/package.json +11 -22
  465. package/src/Coloris.css +8 -8
  466. package/src/Editor.loadFrom.test.ts +1 -1
  467. package/src/Editor.scss +148 -0
  468. package/src/Editor.test.ts +107 -0
  469. package/src/Editor.toSVG.test.ts +184 -1
  470. package/src/Editor.ts +325 -53
  471. package/src/EditorImage.test.ts +4 -7
  472. package/src/EditorImage.ts +10 -4
  473. package/src/Pointer.ts +18 -5
  474. package/src/SVGLoader.ts +77 -15
  475. package/src/UndoRedoHistory.test.ts +2 -1
  476. package/src/Viewport.ts +1 -4
  477. package/src/commands/Erase.ts +1 -0
  478. package/src/commands/localization.ts +1 -1
  479. package/src/commands/uniteCommands.test.ts +3 -3
  480. package/src/components/AbstractComponent.transformBy.test.ts +2 -1
  481. package/src/components/AbstractComponent.ts +12 -3
  482. package/src/components/BackgroundComponent.test.ts +1 -2
  483. package/src/components/BackgroundComponent.ts +3 -8
  484. package/src/components/ImageComponent.ts +1 -3
  485. package/src/components/RestylableComponent.ts +1 -1
  486. package/src/components/SVGGlobalAttributesObject.ts +1 -3
  487. package/src/components/Stroke.test.ts +4 -6
  488. package/src/components/Stroke.ts +5 -7
  489. package/src/components/TextComponent.test.ts +1 -3
  490. package/src/components/TextComponent.ts +1 -4
  491. package/src/components/UnknownSVGObject.ts +3 -3
  492. package/src/components/builders/ArrowBuilder.ts +1 -2
  493. package/src/components/builders/CircleBuilder.ts +3 -5
  494. package/src/components/builders/FreehandLineBuilder.test.ts +2 -3
  495. package/src/components/builders/FreehandLineBuilder.ts +3 -5
  496. package/src/components/builders/LineBuilder.ts +3 -3
  497. package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +3 -4
  498. package/src/components/builders/RectangleBuilder.ts +3 -4
  499. package/src/components/builders/types.ts +1 -1
  500. package/src/components/lib.ts +1 -1
  501. package/src/components/util/StrokeSmoother.ts +7 -7
  502. package/src/dialogs/dialogs.scss +36 -0
  503. package/src/dialogs/makeAboutDialog.scss +41 -0
  504. package/src/dialogs/makeAboutDialog.ts +82 -0
  505. package/src/inputEvents.ts +143 -0
  506. package/src/lib.ts +35 -13
  507. package/src/localizations/de.ts +2 -2
  508. package/src/localizations/es.ts +5 -5
  509. package/src/rendering/Display.ts +1 -2
  510. package/src/rendering/RenderablePathSpec.ts +88 -0
  511. package/src/rendering/RenderingStyle.test.ts +1 -1
  512. package/src/rendering/RenderingStyle.ts +1 -1
  513. package/src/rendering/caching/CacheRecord.test.ts +1 -2
  514. package/src/rendering/caching/CacheRecord.ts +1 -2
  515. package/src/rendering/caching/CacheRecordManager.ts +1 -1
  516. package/src/rendering/caching/RenderingCache.test.ts +3 -4
  517. package/src/rendering/caching/RenderingCache.ts +1 -1
  518. package/src/rendering/caching/RenderingCacheNode.ts +1 -2
  519. package/src/rendering/caching/testUtils.ts +1 -1
  520. package/src/rendering/caching/types.ts +3 -3
  521. package/src/rendering/renderers/AbstractRenderer.ts +4 -14
  522. package/src/rendering/renderers/CanvasRenderer.ts +17 -12
  523. package/src/rendering/renderers/DummyRenderer.test.ts +1 -2
  524. package/src/rendering/renderers/DummyRenderer.ts +1 -4
  525. package/src/rendering/renderers/SVGRenderer.ts +68 -11
  526. package/src/rendering/renderers/TextOnlyRenderer.ts +1 -4
  527. package/src/shortcuts/KeyBinding.test.ts +10 -0
  528. package/src/shortcuts/KeyBinding.ts +74 -35
  529. package/src/shortcuts/KeyboardShortcutManager.test.ts +1 -1
  530. package/src/styles.js +1 -1
  531. package/src/testing/sendPenEvent.ts +2 -2
  532. package/src/testing/sendTouchEvent.ts +2 -2
  533. package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
  534. package/src/toolbar/AbstractToolbar.ts +542 -0
  535. package/src/toolbar/DropdownToolbar.scss +46 -0
  536. package/src/toolbar/DropdownToolbar.ts +220 -0
  537. package/src/toolbar/EdgeToolbar.scss +511 -0
  538. package/src/toolbar/EdgeToolbar.test.ts +54 -0
  539. package/src/toolbar/EdgeToolbar.ts +543 -0
  540. package/src/toolbar/IconProvider.ts +189 -133
  541. package/src/toolbar/constants.ts +1 -0
  542. package/src/toolbar/lib.ts +4 -2
  543. package/src/toolbar/localization.ts +39 -17
  544. package/src/toolbar/toolbar.scss +11 -0
  545. package/src/toolbar/types.ts +8 -0
  546. package/src/toolbar/widgets/ActionButtonWidget.ts +2 -2
  547. package/src/toolbar/widgets/BaseToolWidget.ts +17 -1
  548. package/src/toolbar/widgets/BaseWidget.ts +179 -112
  549. package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
  550. package/src/toolbar/widgets/DocumentPropertiesWidget.ts +26 -10
  551. package/src/toolbar/widgets/EraserToolWidget.ts +21 -22
  552. package/src/toolbar/widgets/HandToolWidget.scss +14 -0
  553. package/src/toolbar/widgets/HandToolWidget.ts +21 -32
  554. package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
  555. package/src/toolbar/widgets/InsertImageWidget.ts +90 -65
  556. package/src/toolbar/widgets/PenToolWidget.css +0 -51
  557. package/src/toolbar/widgets/PenToolWidget.ts +106 -146
  558. package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
  559. package/src/toolbar/widgets/SelectionToolWidget.ts +83 -85
  560. package/src/toolbar/widgets/TextToolWidget.ts +9 -5
  561. package/src/toolbar/widgets/components/components.scss +5 -0
  562. package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
  563. package/src/toolbar/{makeColorInput.ts → widgets/components/makeColorInput.ts} +39 -14
  564. package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
  565. package/src/toolbar/widgets/components/makeFileInput.ts +128 -0
  566. package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
  567. package/src/toolbar/widgets/components/makeGridSelector.ts +179 -0
  568. package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
  569. package/src/toolbar/widgets/components/makeSeparator.ts +17 -0
  570. package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
  571. package/src/toolbar/widgets/components/makeThicknessSlider.ts +62 -0
  572. package/src/toolbar/widgets/keybindings.ts +1 -3
  573. package/src/toolbar/widgets/layout/DropdownLayoutManager.ts +262 -0
  574. package/src/toolbar/widgets/layout/EdgeToolbarLayoutManager.ts +71 -0
  575. package/src/toolbar/widgets/layout/types.ts +74 -0
  576. package/src/toolbar/widgets/lib.ts +2 -2
  577. package/src/tools/BaseTool.ts +102 -30
  578. package/src/tools/Eraser.test.ts +2 -2
  579. package/src/tools/Eraser.ts +24 -11
  580. package/src/tools/FindTool.css +3 -3
  581. package/src/tools/FindTool.test.ts +67 -0
  582. package/src/tools/FindTool.ts +3 -3
  583. package/src/tools/InputFilter/FunctionMapper.ts +17 -0
  584. package/src/tools/InputFilter/InputMapper.ts +41 -0
  585. package/src/tools/InputFilter/InputPipeline.test.ts +41 -0
  586. package/src/tools/InputFilter/InputPipeline.ts +34 -0
  587. package/src/tools/InputFilter/InputStabilizer.ts +254 -0
  588. package/src/tools/InputFilter/StrokeKeyboardControl.ts +104 -0
  589. package/src/tools/PanZoom.test.ts +3 -13
  590. package/src/tools/PanZoom.ts +33 -10
  591. package/src/tools/PasteHandler.ts +2 -3
  592. package/src/tools/Pen.test.ts +2 -4
  593. package/src/tools/Pen.ts +54 -70
  594. package/src/tools/PipetteTool.ts +31 -2
  595. package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +1 -1
  596. package/src/tools/SelectionTool/Selection.ts +52 -16
  597. package/src/tools/SelectionTool/SelectionHandle.ts +46 -12
  598. package/src/tools/SelectionTool/SelectionTool.css +23 -11
  599. package/src/tools/SelectionTool/SelectionTool.test.ts +130 -21
  600. package/src/tools/SelectionTool/SelectionTool.ts +62 -48
  601. package/src/tools/SelectionTool/TransformMode.ts +1 -3
  602. package/src/tools/SoundUITool.ts +13 -4
  603. package/src/tools/TextTool.ts +29 -30
  604. package/src/tools/ToolController.ts +60 -36
  605. package/src/tools/ToolSwitcherShortcut.ts +1 -1
  606. package/src/tools/ToolbarShortcutHandler.ts +1 -1
  607. package/src/tools/UndoRedoShortcut.test.ts +10 -4
  608. package/src/tools/UndoRedoShortcut.ts +1 -1
  609. package/src/tools/keybindings.ts +17 -17
  610. package/src/tools/localization.ts +4 -2
  611. package/src/tools/tools.scss +4 -0
  612. package/src/types.ts +25 -113
  613. package/src/util/ReactiveValue.test.ts +168 -0
  614. package/src/util/ReactiveValue.ts +241 -0
  615. package/src/util/guessKeyCodeFromKey.ts +36 -0
  616. package/src/util/listPrefixMatch.ts +19 -0
  617. package/src/util/stopPropagationOfScrollingWheelEvents.ts +20 -0
  618. package/src/version.test.ts +12 -0
  619. package/src/version.ts +3 -0
  620. package/tsconfig.json +1 -1
  621. package/typedoc.json +4 -0
  622. package/dist/cjs/Color4.d.ts +0 -69
  623. package/dist/cjs/Color4.js +0 -263
  624. package/dist/cjs/math/Mat33.d.ts +0 -123
  625. package/dist/cjs/math/Mat33.js +0 -340
  626. package/dist/cjs/math/Vec2.d.ts +0 -33
  627. package/dist/cjs/math/Vec2.js +0 -37
  628. package/dist/cjs/math/Vec3.d.ts +0 -106
  629. package/dist/cjs/math/Vec3.js +0 -183
  630. package/dist/cjs/math/lib.d.ts +0 -7
  631. package/dist/cjs/math/lib.js +0 -15
  632. package/dist/cjs/math/polynomial/solveQuadratic.d.ts +0 -9
  633. package/dist/cjs/math/polynomial/solveQuadratic.js +0 -39
  634. package/dist/cjs/math/rounding.d.ts +0 -4
  635. package/dist/cjs/math/rounding.js +0 -140
  636. package/dist/cjs/math/shapes/Abstract2DShape.d.ts +0 -49
  637. package/dist/cjs/math/shapes/Abstract2DShape.js +0 -42
  638. package/dist/cjs/math/shapes/BezierJSWrapper.d.ts +0 -36
  639. package/dist/cjs/math/shapes/BezierJSWrapper.js +0 -109
  640. package/dist/cjs/math/shapes/CubicBezier.d.ts +0 -17
  641. package/dist/cjs/math/shapes/CubicBezier.js +0 -50
  642. package/dist/cjs/math/shapes/LineSegment2.d.ts +0 -70
  643. package/dist/cjs/math/shapes/LineSegment2.js +0 -204
  644. package/dist/cjs/math/shapes/Path.d.ts +0 -93
  645. package/dist/cjs/math/shapes/Path.js +0 -865
  646. package/dist/cjs/math/shapes/PointShape2D.d.ts +0 -18
  647. package/dist/cjs/math/shapes/PointShape2D.js +0 -46
  648. package/dist/cjs/math/shapes/QuadraticBezier.d.ts +0 -34
  649. package/dist/cjs/math/shapes/QuadraticBezier.js +0 -133
  650. package/dist/cjs/math/shapes/Rect2.d.ts +0 -57
  651. package/dist/cjs/math/shapes/Rect2.js +0 -311
  652. package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
  653. package/dist/cjs/math/shapes/Triangle.js +0 -148
  654. package/dist/cjs/toolbar/HTMLToolbar.d.ts +0 -105
  655. package/dist/cjs/toolbar/HTMLToolbar.js +0 -465
  656. package/dist/cjs/toolbar/makeColorInput.d.ts +0 -6
  657. package/dist/mjs/Color4.d.ts +0 -69
  658. package/dist/mjs/Color4.mjs +0 -260
  659. package/dist/mjs/Color4.test.d.ts +0 -1
  660. package/dist/mjs/math/Mat33.d.ts +0 -123
  661. package/dist/mjs/math/Mat33.mjs +0 -338
  662. package/dist/mjs/math/Mat33.test.d.ts +0 -1
  663. package/dist/mjs/math/Vec2.d.ts +0 -33
  664. package/dist/mjs/math/Vec2.mjs +0 -34
  665. package/dist/mjs/math/Vec2.test.d.ts +0 -1
  666. package/dist/mjs/math/Vec3.d.ts +0 -106
  667. package/dist/mjs/math/Vec3.mjs +0 -181
  668. package/dist/mjs/math/Vec3.test.d.ts +0 -1
  669. package/dist/mjs/math/lib.d.ts +0 -7
  670. package/dist/mjs/math/lib.mjs +0 -7
  671. package/dist/mjs/math/polynomial/solveQuadratic.d.ts +0 -9
  672. package/dist/mjs/math/polynomial/solveQuadratic.mjs +0 -37
  673. package/dist/mjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
  674. package/dist/mjs/math/rounding.d.ts +0 -4
  675. package/dist/mjs/math/rounding.mjs +0 -133
  676. package/dist/mjs/math/rounding.test.d.ts +0 -1
  677. package/dist/mjs/math/shapes/Abstract2DShape.d.ts +0 -49
  678. package/dist/mjs/math/shapes/Abstract2DShape.mjs +0 -40
  679. package/dist/mjs/math/shapes/BezierJSWrapper.d.ts +0 -36
  680. package/dist/mjs/math/shapes/BezierJSWrapper.mjs +0 -107
  681. package/dist/mjs/math/shapes/CubicBezier.d.ts +0 -17
  682. package/dist/mjs/math/shapes/CubicBezier.mjs +0 -48
  683. package/dist/mjs/math/shapes/LineSegment2.d.ts +0 -70
  684. package/dist/mjs/math/shapes/LineSegment2.mjs +0 -202
  685. package/dist/mjs/math/shapes/LineSegment2.test.d.ts +0 -1
  686. package/dist/mjs/math/shapes/Path.d.ts +0 -93
  687. package/dist/mjs/math/shapes/Path.fromString.test.d.ts +0 -1
  688. package/dist/mjs/math/shapes/Path.mjs +0 -862
  689. package/dist/mjs/math/shapes/Path.test.d.ts +0 -1
  690. package/dist/mjs/math/shapes/Path.toString.test.d.ts +0 -1
  691. package/dist/mjs/math/shapes/PointShape2D.d.ts +0 -18
  692. package/dist/mjs/math/shapes/PointShape2D.mjs +0 -44
  693. package/dist/mjs/math/shapes/QuadraticBezier.d.ts +0 -34
  694. package/dist/mjs/math/shapes/QuadraticBezier.mjs +0 -131
  695. package/dist/mjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
  696. package/dist/mjs/math/shapes/Rect2.d.ts +0 -57
  697. package/dist/mjs/math/shapes/Rect2.mjs +0 -309
  698. package/dist/mjs/math/shapes/Rect2.test.d.ts +0 -1
  699. package/dist/mjs/math/shapes/Triangle.d.ts +0 -46
  700. package/dist/mjs/math/shapes/Triangle.mjs +0 -146
  701. package/dist/mjs/math/shapes/Triangle.test.d.ts +0 -1
  702. package/dist/mjs/toolbar/HTMLToolbar.d.ts +0 -105
  703. package/dist/mjs/toolbar/HTMLToolbar.mjs +0 -462
  704. package/dist/mjs/toolbar/makeColorInput.d.ts +0 -6
  705. package/src/Color4.test.ts +0 -47
  706. package/src/Color4.ts +0 -304
  707. package/src/Editor.css +0 -98
  708. package/src/math/Mat33.test.ts +0 -244
  709. package/src/math/Mat33.ts +0 -442
  710. package/src/math/Vec2.test.ts +0 -30
  711. package/src/math/Vec2.ts +0 -40
  712. package/src/math/Vec3.test.ts +0 -44
  713. package/src/math/Vec3.ts +0 -218
  714. package/src/math/lib.ts +0 -15
  715. package/src/math/polynomial/solveQuadratic.test.ts +0 -39
  716. package/src/math/polynomial/solveQuadratic.ts +0 -43
  717. package/src/math/rounding.test.ts +0 -65
  718. package/src/math/rounding.ts +0 -156
  719. package/src/math/shapes/Abstract2DShape.ts +0 -63
  720. package/src/math/shapes/BezierJSWrapper.ts +0 -93
  721. package/src/math/shapes/CubicBezier.ts +0 -35
  722. package/src/math/shapes/LineSegment2.test.ts +0 -99
  723. package/src/math/shapes/LineSegment2.ts +0 -231
  724. package/src/math/shapes/Path.fromString.test.ts +0 -223
  725. package/src/math/shapes/Path.test.ts +0 -309
  726. package/src/math/shapes/Path.toString.test.ts +0 -77
  727. package/src/math/shapes/Path.ts +0 -1027
  728. package/src/math/shapes/PointShape2D.ts +0 -33
  729. package/src/math/shapes/QuadraticBezier.test.ts +0 -31
  730. package/src/math/shapes/QuadraticBezier.ts +0 -141
  731. package/src/math/shapes/Rect2.test.ts +0 -209
  732. package/src/math/shapes/Rect2.ts +0 -344
  733. package/src/math/shapes/Triangle.test.ts +0 -61
  734. package/src/math/shapes/Triangle.ts +0 -139
  735. package/src/toolbar/HTMLToolbar.ts +0 -567
  736. package/src/toolbar/widgets/InsertImageWidget.css +0 -44
  737. package/src/tools/tools.css +0 -4
  738. /package/dist/cjs/{Color4.test.d.ts → Editor.test.d.ts} +0 -0
  739. /package/dist/cjs/{math/Mat33.test.d.ts → toolbar/EdgeToolbar.test.d.ts} +0 -0
  740. /package/dist/cjs/{math/Vec2.test.d.ts → tools/FindTool.test.d.ts} +0 -0
  741. /package/dist/cjs/{math/Vec3.test.d.ts → tools/InputFilter/InputPipeline.test.d.ts} +0 -0
  742. /package/dist/cjs/{math/polynomial/solveQuadratic.test.d.ts → util/ReactiveValue.test.d.ts} +0 -0
  743. /package/dist/cjs/{math/rounding.test.d.ts → version.test.d.ts} +0 -0
  744. /package/dist/{cjs/math/shapes/LineSegment2.test.d.ts → mjs/Editor.test.d.ts} +0 -0
  745. /package/dist/{cjs/math/shapes/Path.fromString.test.d.ts → mjs/toolbar/EdgeToolbar.test.d.ts} +0 -0
  746. /package/dist/{cjs/math/shapes/Path.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
  747. /package/dist/{cjs/math/shapes/Path.toString.test.d.ts → mjs/tools/FindTool.test.d.ts} +0 -0
  748. /package/dist/{cjs/math/shapes/QuadraticBezier.test.d.ts → mjs/tools/InputFilter/InputPipeline.test.d.ts} +0 -0
  749. /package/dist/{cjs/math/shapes/Rect2.test.d.ts → mjs/util/ReactiveValue.test.d.ts} +0 -0
  750. /package/dist/{cjs/math/shapes/Triangle.test.d.ts → mjs/version.test.d.ts} +0 -0
package/src/SVGLoader.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Color4 from './Color4';
1
+ import { Color4, Mat33, Path, Rect2, Vec2 } from '@js-draw/math';
2
2
  import AbstractComponent from './components/AbstractComponent';
3
3
  import BackgroundComponent, { BackgroundType, backgroundTypeToClassNameMap, imageBackgroundCSSClassName, imageBackgroundGridSizeCSSPrefix, imageBackgroundNonAutomaticSecondaryColorCSSClassName } from './components/BackgroundComponent';
4
4
  import ImageComponent from './components/ImageComponent';
@@ -6,14 +6,10 @@ import Stroke from './components/Stroke';
6
6
  import SVGGlobalAttributesObject from './components/SVGGlobalAttributesObject';
7
7
  import TextComponent, { TextTransformMode } from './components/TextComponent';
8
8
  import UnknownSVGObject from './components/UnknownSVGObject';
9
- import Mat33 from './math/Mat33';
10
- import Path from './math/shapes/Path';
11
- import Rect2 from './math/shapes/Rect2';
12
- import { Vec2 } from './math/Vec2';
13
- import { RenderablePathSpec } from './rendering/renderers/AbstractRenderer';
14
9
  import RenderingStyle from './rendering/RenderingStyle';
15
10
  import TextRenderingStyle from './rendering/TextRenderingStyle';
16
11
  import { ComponentAddedListener, ImageLoader, OnDetermineExportRectListener, OnProgressListener } from './types';
12
+ import RenderablePathSpec, { pathToRenderable } from './rendering/RenderablePathSpec';
17
13
 
18
14
  type OnFinishListener = ()=> void;
19
15
 
@@ -22,8 +18,14 @@ export const defaultSVGViewRect = new Rect2(0, 0, 500, 500);
22
18
 
23
19
  // Key to retrieve unrecognised attributes from an AbstractComponent
24
20
  export const svgAttributesDataKey = 'svgAttrs';
21
+
22
+ // Like {@link svgAttributesDataKey}, but for styles
25
23
  export const svgStyleAttributesDataKey = 'svgStyleAttrs';
26
24
 
25
+ // Key that specifies the ID of an SVG element that contained a given node when the image
26
+ // was first loaded.
27
+ export const svgLoaderAttributeContainerID = 'svgContainerID';
28
+
27
29
  // [key, value]
28
30
  export type SVGLoaderUnknownAttribute = [ string, string ];
29
31
 
@@ -109,7 +111,7 @@ export default class SVGLoader implements ImageLoader {
109
111
  const current = !isFirst ? `M${part}` : part;
110
112
 
111
113
  const path = Path.fromString(current);
112
- const spec = path.toRenderable(style);
114
+ const spec = pathToRenderable(path, style);
113
115
  result.push(spec);
114
116
  }
115
117
 
@@ -140,7 +142,11 @@ export default class SVGLoader implements ImageLoader {
140
142
  }
141
143
 
142
144
  if (supportedStyleAttrs && node.style) {
143
- for (const attr of node.style) {
145
+ // Use a for loop instead of an iterator: js-dom seems to not
146
+ // support using node.style as an iterator.
147
+ for (let i = 0; i < node.style.length; i ++) {
148
+ const attr = node.style[i];
149
+
144
150
  if (attr === '' || !attr) {
145
151
  continue;
146
152
  }
@@ -187,7 +193,7 @@ export default class SVGLoader implements ImageLoader {
187
193
  return;
188
194
  }
189
195
  }
190
- await this.onAddComponent?.(elem);
196
+ await this.addComponent(elem);
191
197
  }
192
198
 
193
199
  private async addBackground(node: SVGElement) {
@@ -252,13 +258,13 @@ export default class SVGLoader implements ImageLoader {
252
258
  const elem = BackgroundComponent.ofGrid(
253
259
  backgroundColor, gridSize, foregroundColor, gridStrokeWidth
254
260
  );
255
- await this.onAddComponent?.(elem);
261
+ await this.addComponent(elem);
256
262
  }
257
263
  // Otherwise, if just a <path/>, it's a solid color background.
258
264
  else if (node.tagName.toLowerCase() === 'path') {
259
265
  const fill = Color4.fromString(node.getAttribute('fill') ?? node.style.fill ?? 'black');
260
266
  const elem = new BackgroundComponent(BackgroundType.SolidColor, fill);
261
- await this.onAddComponent?.(elem);
267
+ await this.addComponent(elem);
262
268
  }
263
269
  else {
264
270
  await this.addUnknownNode(node);
@@ -395,7 +401,7 @@ export default class SVGLoader implements ImageLoader {
395
401
  private async addText(elem: SVGTextElement|SVGTSpanElement) {
396
402
  try {
397
403
  const textElem = this.makeText(elem);
398
- await this.onAddComponent?.(textElem);
404
+ await this.addComponent(textElem);
399
405
  } catch (e) {
400
406
  console.error('Invalid text object in node', elem, '. Continuing.... Error:', e);
401
407
  this.addUnknownNode(elem);
@@ -418,7 +424,7 @@ export default class SVGLoader implements ImageLoader {
418
424
  new Set([ 'transform' ])
419
425
  );
420
426
 
421
- await this.onAddComponent?.(imageElem);
427
+ await this.addComponent(imageElem);
422
428
  } catch (e) {
423
429
  console.error('Error loading image:', e, '. Element: ', elem, '. Continuing...');
424
430
  await this.addUnknownNode(elem);
@@ -428,10 +434,60 @@ export default class SVGLoader implements ImageLoader {
428
434
  private async addUnknownNode(node: SVGElement) {
429
435
  if (this.storeUnknown) {
430
436
  const component = new UnknownSVGObject(node);
431
- await this.onAddComponent?.(component);
437
+ await this.addComponent(component);
432
438
  }
433
439
  }
434
440
 
441
+ private containerGroupIDs: string[] = [];
442
+ private encounteredIDs: string[] = [];
443
+ private async startGroup(node: SVGGElement) {
444
+ node = node.cloneNode(false) as SVGGElement;
445
+
446
+ // Select a unique ID based on the node's ID property (if it exists).
447
+ // Use `||` and not `??` so that empty string IDs are also replaced.
448
+ let id = node.id || `id-${this.encounteredIDs.length}`;
449
+
450
+ // Make id unique.
451
+ let idSuffixCounter = 0;
452
+ let suffix = '';
453
+ while (this.encounteredIDs.includes(id + suffix)) {
454
+ idSuffixCounter ++;
455
+ suffix = '--' + idSuffixCounter;
456
+ }
457
+ id += suffix;
458
+
459
+ // Remove all children from the node -- children will be handled separately
460
+ // (not removing children here could cause duplicates in the result, when rendered).
461
+ node.replaceChildren();
462
+
463
+ node.id = id;
464
+
465
+ const component = new UnknownSVGObject(node);
466
+ this.addComponent(component);
467
+
468
+ // Add to IDs after -- we don't want the <g> element to be marked
469
+ // as its own container.
470
+ this.containerGroupIDs.push(node.id);
471
+ this.encounteredIDs.push(node.id);
472
+ }
473
+
474
+ // Ends the most recent group started by .startGroup
475
+ private async endGroup() {
476
+ this.containerGroupIDs.pop();
477
+ }
478
+
479
+ private async addComponent(component: AbstractComponent) {
480
+ // Attach the stack of container IDs
481
+ if (this.containerGroupIDs.length > 0) {
482
+ component.attachLoadSaveData(
483
+ svgLoaderAttributeContainerID,
484
+ [ ...this.containerGroupIDs ]
485
+ );
486
+ }
487
+
488
+ await this.onAddComponent?.(component);
489
+ }
490
+
435
491
  private updateViewBox(node: SVGSVGElement) {
436
492
  const viewBoxAttr = node.getAttribute('viewBox');
437
493
  if (this.rootViewBox || !viewBoxAttr) {
@@ -468,6 +524,8 @@ export default class SVGLoader implements ImageLoader {
468
524
  if (node.classList.contains(imageBackgroundCSSClassName)) {
469
525
  await this.addBackground(node as SVGElement);
470
526
  visitChildren = false;
527
+ } else {
528
+ await this.startGroup(node as SVGGElement);
471
529
  }
472
530
  // Otherwise, continue -- visit the node's children.
473
531
  break;
@@ -496,7 +554,7 @@ export default class SVGLoader implements ImageLoader {
496
554
  await this.addUnknownNode(node as SVGStyleElement);
497
555
  break;
498
556
  default:
499
- console.warn('Unknown SVG element,', node);
557
+ console.warn('Unknown SVG element,', node, node.tagName);
500
558
  if (!(node instanceof SVGElement)) {
501
559
  console.warn(
502
560
  'Element', node, 'is not an SVGElement!', this.storeUnknown ? 'Continuing anyway.' : 'Skipping.'
@@ -511,6 +569,10 @@ export default class SVGLoader implements ImageLoader {
511
569
  for (const child of node.children) {
512
570
  await this.visit(child);
513
571
  }
572
+
573
+ if (node.tagName.toLowerCase() === 'g') {
574
+ await this.endGroup();
575
+ }
514
576
  }
515
577
 
516
578
  this.processedCount ++;
@@ -1,11 +1,12 @@
1
1
 
2
2
  import { Color4, EditorImage, Path, Stroke, Mat33, Vec2 } from './lib';
3
+ import { pathToRenderable } from './rendering/RenderablePathSpec';
3
4
  import createEditor from './testing/createEditor';
4
5
 
5
6
  describe('UndoRedoHistory', () => {
6
7
  it('should keep history size below maximum', () => {
7
8
  const editor = createEditor();
8
- const stroke = new Stroke([ Path.fromString('m0,0 10,10').toRenderable({ fill: Color4.red }) ]);
9
+ const stroke = new Stroke([ pathToRenderable(Path.fromString('m0,0 10,10'), { fill: Color4.red }) ]);
9
10
  editor.dispatch(EditorImage.addElement(stroke));
10
11
 
11
12
  for (let i = 0; i < editor.history['maxUndoRedoStackSize'] + 10; i++) {
package/src/Viewport.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  import Command from './commands/Command';
2
2
  import { CommandLocalization } from './commands/localization';
3
3
  import Editor from './Editor';
4
- import Mat33 from './math/Mat33';
5
- import Rect2 from './math/shapes/Rect2';
6
- import { Point2, Vec2 } from './math/Vec2';
7
- import Vec3 from './math/Vec3';
4
+ import { Mat33, Rect2, Point2, Vec2, Vec3 } from '@js-draw/math';
8
5
  import { StrokeDataPoint } from './types';
9
6
 
10
7
  // Returns the base type of some type of point/number
@@ -42,6 +42,7 @@ export default class Erase extends SerializableCommand {
42
42
  const parent = editor.image.findParent(part);
43
43
 
44
44
  if (parent) {
45
+ editor.image.onDestroyElement(part);
45
46
  parent.remove();
46
47
  }
47
48
  }
@@ -1,4 +1,4 @@
1
- import Rect2 from '../math/shapes/Rect2';
1
+ import { Rect2 } from '@js-draw/math';
2
2
 
3
3
  export interface CommandLocalization {
4
4
  movedLeft: string;
@@ -1,12 +1,12 @@
1
-
2
1
  import { Color4, EditorImage, Mat33, Path, SerializableCommand, StrokeComponent, Vec2 } from '../lib';
3
2
  import uniteCommands from './uniteCommands';
4
3
  import createEditor from '../testing/createEditor';
4
+ import { pathToRenderable } from '../rendering/RenderablePathSpec';
5
5
 
6
6
  describe('uniteCommands', () => {
7
7
  it('should be serializable and deserializable', () => {
8
8
  const editor = createEditor();
9
- const stroke = new StrokeComponent([ Path.fromString('m0,0 l10,10 h-2 z').toRenderable({ fill: Color4.red }) ]);
9
+ const stroke = new StrokeComponent([ pathToRenderable(Path.fromString('m0,0 l10,10 h-2 z'), { fill: Color4.red }) ]);
10
10
  const union = uniteCommands([
11
11
  EditorImage.addElement(stroke),
12
12
  stroke.transformBy(Mat33.translation(Vec2.of(1, 10))),
@@ -20,4 +20,4 @@ describe('uniteCommands', () => {
20
20
  expect(lookupResult?.getBBox().topLeft).toMatchObject(Vec2.of(1, 10));
21
21
  expect(lookupResult?.getBBox().bottomRight).toMatchObject(Vec2.of(11, 20));
22
22
  });
23
- });
23
+ });
@@ -1,11 +1,12 @@
1
1
  import { Color4, EditorImage, Mat33, Path, Rect2, Vec2 } from '../lib';
2
+ import { pathToRenderable } from '../rendering/RenderablePathSpec';
2
3
  import createEditor from '../testing/createEditor';
3
4
  import Stroke from './Stroke';
4
5
 
5
6
  describe('AbstractComponent.transformBy', () => {
6
7
  it('should restore the component\'s z-index on undo', () => {
7
8
  const editor = createEditor();
8
- const component = new Stroke([ Path.fromRect(Rect2.unitSquare).toRenderable({ fill: Color4.red }) ]);
9
+ const component = new Stroke([ pathToRenderable(Path.fromRect(Rect2.unitSquare), { fill: Color4.red }) ]);
9
10
  EditorImage.addElement(component).apply(editor);
10
11
 
11
12
  const origZIndex = component.getZIndex();
@@ -1,9 +1,7 @@
1
1
  import SerializableCommand from '../commands/SerializableCommand';
2
2
  import Editor from '../Editor';
3
3
  import EditorImage from '../EditorImage';
4
- import LineSegment2 from '../math/shapes/LineSegment2';
5
- import Mat33, { Mat33Array } from '../math/Mat33';
6
- import Rect2 from '../math/shapes/Rect2';
4
+ import { LineSegment2, Mat33, Mat33Array, Rect2 } from '@js-draw/math';
7
5
  import { EditorLocalization } from '../localization';
8
6
  import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
9
7
  import { ImageComponentLocalization } from './localization';
@@ -116,6 +114,16 @@ export default abstract class AbstractComponent {
116
114
  public onAddToImage(_image: EditorImage): void { }
117
115
  public onRemoveFromImage(): void { }
118
116
 
117
+ /**
118
+ * Renders this component onto the given `canvas`.
119
+ *
120
+ * If `visibleRect` is given, it should be the region of `canvas` that is visible --
121
+ * rendering anything outside of `visibleRect` should have no visible effect on the
122
+ * resultant image.
123
+ *
124
+ * For optimal performance, implementers should call `canvas.startObject` and `canvas.endObject`
125
+ * before and after rendering.
126
+ */
119
127
  public abstract render(canvas: AbstractRenderer, visibleRect?: Rect2): void;
120
128
 
121
129
  /** @return true if `lineSegment` intersects this component. */
@@ -152,6 +160,7 @@ export default abstract class AbstractComponent {
152
160
 
153
161
  // Returns a command that, when applied, transforms this by [affineTransfm] and
154
162
  // updates the editor.
163
+ // This also increases the element's z-index so that it is on top.
155
164
  public transformBy(affineTransfm: Mat33): SerializableCommand {
156
165
  return new AbstractComponent.TransformElementCommand(affineTransfm, this.getId(), this);
157
166
  }
@@ -1,5 +1,4 @@
1
- import Color4 from '../Color4';
2
- import { Path, Rect2 } from '../math/lib';
1
+ import { Path, Rect2, Color4 } from '@js-draw/math';
3
2
  import createEditor from '../testing/createEditor';
4
3
  import AbstractComponent from './AbstractComponent';
5
4
  import BackgroundComponent, { BackgroundType, imageBackgroundCSSClassName } from './BackgroundComponent';
@@ -1,19 +1,14 @@
1
- import Color4 from '../Color4';
2
1
  import Editor from '../Editor';
3
2
  import EditorImage, { EditorImageEventType } from '../EditorImage';
4
3
  import { DispatcherEventListener } from '../EventDispatcher';
5
4
  import SerializableCommand from '../commands/SerializableCommand';
6
- import LineSegment2 from '../math/shapes/LineSegment2';
7
- import Mat33 from '../math/Mat33';
8
- import Rect2 from '../math/shapes/Rect2';
5
+ import { LineSegment2, Mat33, Rect2, Color4, toRoundedString, Path, PathCommandType, Vec2, PathCommand } from '@js-draw/math';
9
6
  import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
10
7
  import AbstractComponent from './AbstractComponent';
11
8
  import { ImageComponentLocalization } from './localization';
12
9
  import RestyleableComponent, { ComponentStyle, createRestyleComponentCommand } from './RestylableComponent';
13
- import Path, { PathCommand, PathCommandType } from '../math/shapes/Path';
14
- import { Vec2 } from '../math/Vec2';
15
10
  import Viewport from '../Viewport';
16
- import { toRoundedString } from '../math/rounding';
11
+ import { pathToRenderable } from '../rendering/RenderablePathSpec';
17
12
 
18
13
  export enum BackgroundType {
19
14
  SolidColor,
@@ -246,7 +241,7 @@ export default class BackgroundComponent extends AbstractComponent implements Re
246
241
  fill: Color4.transparent,
247
242
  stroke: { width: this.gridStrokeWidth, color: gridColor }
248
243
  };
249
- canvas.drawPath(this.generateGridPath(visibleRect).toRenderable(style));
244
+ canvas.drawPath(pathToRenderable(this.generateGridPath(visibleRect), style));
250
245
  }
251
246
 
252
247
  const backgroundTypeCSSClass = backgroundTypeToClassNameMap[this.backgroundType];
@@ -1,6 +1,4 @@
1
- import LineSegment2 from '../math/shapes/LineSegment2';
2
- import Mat33, { Mat33Array } from '../math/Mat33';
3
- import Rect2 from '../math/shapes/Rect2';
1
+ import { Mat33Array, Rect2, Mat33, LineSegment2 } from '@js-draw/math';
4
2
  import AbstractRenderer, { RenderableImage } from '../rendering/renderers/AbstractRenderer';
5
3
  import { assertIsNumber, assertIsNumberArray } from '../util/assertions';
6
4
  import AbstractComponent from './AbstractComponent';
@@ -1,4 +1,4 @@
1
- import Color4 from '../Color4';
1
+ import { Color4 } from '@js-draw/math';
2
2
  import SerializableCommand from '../commands/SerializableCommand';
3
3
  import UnresolvedSerializableCommand from '../commands/UnresolvedCommand';
4
4
  import Editor from '../Editor';
@@ -5,9 +5,7 @@
5
5
  // @packageDocumentation
6
6
  //
7
7
 
8
- import LineSegment2 from '../math/shapes/LineSegment2';
9
- import Mat33 from '../math/Mat33';
10
- import Rect2 from '../math/shapes/Rect2';
8
+ import { LineSegment2, Mat33, Rect2 } from '@js-draw/math';
11
9
  import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
12
10
  import SVGRenderer from '../rendering/renderers/SVGRenderer';
13
11
  import AbstractComponent from './AbstractComponent';
@@ -1,12 +1,10 @@
1
- import Color4 from '../Color4';
2
- import Path from '../math/shapes/Path';
3
- import { Vec2 } from '../math/Vec2';
1
+ import { Path, Vec2, Mat33, Color4 } from '@js-draw/math';
4
2
  import Stroke from './Stroke';
5
3
  import createEditor from '../testing/createEditor';
6
- import Mat33 from '../math/Mat33';
7
4
  import EditorImage from '../EditorImage';
8
5
  import AbstractComponent from './AbstractComponent';
9
6
  import { DummyRenderer, SerializableCommand } from '../lib';
7
+ import { pathToRenderable } from '../rendering/RenderablePathSpec';
10
8
 
11
9
  describe('Stroke', () => {
12
10
  it('empty stroke should have an empty bounding box', () => {
@@ -24,7 +22,7 @@ describe('Stroke', () => {
24
22
 
25
23
  it('cloned strokes should have the same points', () => {
26
24
  const stroke = new Stroke([
27
- Path.fromString('m1,1 2,2 3,3 z').toRenderable({ fill: Color4.red })
25
+ pathToRenderable(Path.fromString('m1,1 2,2 3,3 z'), { fill: Color4.red })
28
26
  ]);
29
27
  const clone = stroke.clone();
30
28
 
@@ -38,7 +36,7 @@ describe('Stroke', () => {
38
36
  it('transforming a cloned stroke should not affect the original', () => {
39
37
  const editor = createEditor();
40
38
  const stroke = new Stroke([
41
- Path.fromString('m1,1 2,2 3,3 z').toRenderable({ fill: Color4.red })
39
+ pathToRenderable(Path.fromString('m1,1 2,2 3,3 z'), { fill: Color4.red })
42
40
  ]);
43
41
  const origBBox = stroke.getBBox();
44
42
  expect(origBBox).toMatchObject({
@@ -1,14 +1,12 @@
1
1
  import SerializableCommand from '../commands/SerializableCommand';
2
- import LineSegment2 from '../math/shapes/LineSegment2';
3
- import Mat33 from '../math/Mat33';
4
- import Path from '../math/shapes/Path';
5
- import Rect2 from '../math/shapes/Rect2';
2
+ import { Mat33, Path, Rect2, LineSegment2 } from '@js-draw/math';
6
3
  import Editor from '../Editor';
7
- import AbstractRenderer, { RenderablePathSpec } from '../rendering/renderers/AbstractRenderer';
4
+ import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
8
5
  import RenderingStyle, { styleFromJSON, styleToJSON } from '../rendering/RenderingStyle';
9
6
  import AbstractComponent from './AbstractComponent';
10
7
  import { ImageComponentLocalization } from './localization';
11
8
  import RestyleableComponent, { ComponentStyle, createRestyleComponentCommand } from './RestylableComponent';
9
+ import RenderablePathSpec, { pathFromRenderable, pathToRenderable } from '../rendering/RenderablePathSpec';
12
10
 
13
11
  interface StrokePart extends RenderablePathSpec {
14
12
  path: Path;
@@ -64,7 +62,7 @@ export default class Stroke extends AbstractComponent implements RestyleableComp
64
62
  this.parts = [];
65
63
 
66
64
  for (const section of parts) {
67
- const path = Path.fromRenderable(section);
65
+ const path = pathFromRenderable(section);
68
66
  const pathBBox = this.bboxForPart(path.bbox, section.style);
69
67
 
70
68
  if (!this.contentBBox) {
@@ -287,7 +285,7 @@ export default class Stroke extends AbstractComponent implements RestyleableComp
287
285
 
288
286
  const pathSpec: RenderablePathSpec[] = json.map((part: any) => {
289
287
  const style = styleFromJSON(part.style);
290
- return Path.fromString(part.path).toRenderable(style);
288
+ return pathToRenderable(Path.fromString(part.path), style);
291
289
  });
292
290
  return new Stroke(pathSpec);
293
291
  }
@@ -1,7 +1,5 @@
1
- import Color4 from '../Color4';
2
1
  import EditorImage from '../EditorImage';
3
- import Mat33 from '../math/Mat33';
4
- import { Vec2 } from '../math/Vec2';
2
+ import { Vec2, Mat33, Color4 } from '@js-draw/math';
5
3
  import TextRenderingStyle from '../rendering/TextRenderingStyle';
6
4
  import createEditor from '../testing/createEditor';
7
5
  import AbstractComponent from './AbstractComponent';
@@ -1,9 +1,6 @@
1
1
  import SerializableCommand from '../commands/SerializableCommand';
2
- import LineSegment2 from '../math/shapes/LineSegment2';
3
- import Mat33, { Mat33Array } from '../math/Mat33';
4
- import Rect2 from '../math/shapes/Rect2';
5
2
  import Editor from '../Editor';
6
- import { Vec2 } from '../math/Vec2';
3
+ import { Vec2, LineSegment2, Rect2, Mat33, Mat33Array } from '@js-draw/math';
7
4
  import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
8
5
  import { cloneTextStyle, TextRenderingStyle, textStyleFromJSON, textStyleToJSON } from '../rendering/TextRenderingStyle';
9
6
  import AbstractComponent from './AbstractComponent';
@@ -4,9 +4,7 @@
4
4
  // @packageDocumentation
5
5
  //
6
6
 
7
- import LineSegment2 from '../math/shapes/LineSegment2';
8
- import Mat33 from '../math/Mat33';
9
- import Rect2 from '../math/shapes/Rect2';
7
+ import { LineSegment2, Mat33, Rect2 } from '@js-draw/math';
10
8
  import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
11
9
  import SVGRenderer from '../rendering/renderers/SVGRenderer';
12
10
  import AbstractComponent from './AbstractComponent';
@@ -27,7 +25,9 @@ export default class UnknownSVGObject extends AbstractComponent {
27
25
  return;
28
26
  }
29
27
 
28
+ canvas.startObject(this.contentBBox);
30
29
  canvas.drawSVGElem(this.svgObject);
30
+ canvas.endObject(this.getLoadSaveData());
31
31
  }
32
32
 
33
33
  public override intersects(lineSegment: LineSegment2): boolean {
@@ -1,5 +1,4 @@
1
- import Path, { PathCommandType } from '../../math/shapes/Path';
2
- import Rect2 from '../../math/shapes/Rect2';
1
+ import { Path, PathCommandType, Rect2 } from '@js-draw/math';
3
2
  import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
4
3
  import { StrokeDataPoint } from '../../types';
5
4
  import Viewport from '../../Viewport';
@@ -1,13 +1,11 @@
1
- import { Vec2 } from '../../math/Vec2';
2
- import Path, { PathCommand, PathCommandType } from '../../math/shapes/Path';
3
- import Rect2 from '../../math/shapes/Rect2';
1
+ import { Vec2, Path, PathCommand, PathCommandType, Rect2, Color4 } from '@js-draw/math';
4
2
  import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
3
+ import { pathToRenderable } from '../../rendering/RenderablePathSpec';
5
4
  import { StrokeDataPoint } from '../../types';
6
5
  import Viewport from '../../Viewport';
7
6
  import AbstractComponent from '../AbstractComponent';
8
7
  import Stroke from '../Stroke';
9
8
  import { ComponentBuilder, ComponentBuilderFactory } from './types';
10
- import Color4 from '../../Color4';
11
9
 
12
10
  export const makeOutlinedCircleBuilder: ComponentBuilderFactory = (initialPoint: StrokeDataPoint, viewport: Viewport) => {
13
11
  return new CircleBuilder(initialPoint, viewport);
@@ -76,7 +74,7 @@ class CircleBuilder implements ComponentBuilder {
76
74
  .mapPoints(point => this.viewport.roundPoint(point));
77
75
 
78
76
  const preview = new Stroke([
79
- path.toRenderable({
77
+ pathToRenderable(path, {
80
78
  fill: Color4.transparent,
81
79
  stroke: {
82
80
  width: strokeWidth,
@@ -1,6 +1,5 @@
1
- import Color4 from '../../Color4';
2
1
  import Viewport from '../../Viewport';
3
- import { Vec2 } from '../../math/Vec2';
2
+ import { Vec2, Color4 } from '@js-draw/math';
4
3
  import { StrokeDataPoint } from '../../types';
5
4
  import { makeFreehandLineBuilder } from './FreehandLineBuilder';
6
5
 
@@ -10,7 +9,7 @@ describe('FreehandLineBuilder', () => {
10
9
  const startPoint: StrokeDataPoint = {
11
10
  pos: Vec2.zero,
12
11
  width: 1,
13
- time: (new Date()).getTime(),
12
+ time: performance.now(),
14
13
  color: Color4.red,
15
14
  };
16
15
  const lineBuilder = makeFreehandLineBuilder(startPoint, viewport);
@@ -1,14 +1,12 @@
1
- import AbstractRenderer, { RenderablePathSpec } from '../../rendering/renderers/AbstractRenderer';
2
- import { Point2, Vec2 } from '../../math/Vec2';
3
- import Rect2 from '../../math/shapes/Rect2';
4
- import { PathCommand, PathCommandType } from '../../math/shapes/Path';
1
+ import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
2
+ import RenderablePathSpec from '../../rendering/RenderablePathSpec';
3
+ import { Point2, Vec2, Rect2, Color4, PathCommand, PathCommandType } from '@js-draw/math';
5
4
  import Stroke from '../Stroke';
6
5
  import Viewport from '../../Viewport';
7
6
  import { StrokeDataPoint } from '../../types';
8
7
  import { ComponentBuilder, ComponentBuilderFactory } from './types';
9
8
  import RenderingStyle from '../../rendering/RenderingStyle';
10
9
  import { StrokeSmoother, Curve } from '../util/StrokeSmoother';
11
- import Color4 from '../../Color4';
12
10
 
13
11
  export const makeFreehandLineBuilder: ComponentBuilderFactory = (initialPoint: StrokeDataPoint, viewport: Viewport) => {
14
12
  // Don't smooth if input is more than ± 3 pixels from the true curve, do smooth if
@@ -1,6 +1,6 @@
1
- import Path, { PathCommandType } from '../../math/shapes/Path';
2
- import Rect2 from '../../math/shapes/Rect2';
1
+ import { Path, PathCommandType, Rect2 } from '@js-draw/math';
3
2
  import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
3
+ import { pathToRenderable } from '../../rendering/RenderablePathSpec';
4
4
  import { StrokeDataPoint } from '../../types';
5
5
  import Viewport from '../../Viewport';
6
6
  import AbstractComponent from '../AbstractComponent';
@@ -57,7 +57,7 @@ export default class LineBuilder implements ComponentBuilder {
57
57
  ]).mapPoints(point => this.viewport.roundPoint(point));
58
58
 
59
59
  const preview = new Stroke([
60
- path.toRenderable({ fill: this.startPoint.color })
60
+ pathToRenderable(path, { fill: this.startPoint.color })
61
61
  ]);
62
62
 
63
63
  return preview;
@@ -1,8 +1,7 @@
1
1
  import { Bezier } from 'bezier-js';
2
- import AbstractRenderer, { RenderablePathSpec } from '../../rendering/renderers/AbstractRenderer';
3
- import { Point2, Vec2 } from '../../math/Vec2';
4
- import Rect2 from '../../math/shapes/Rect2';
5
- import { LinePathCommand, PathCommand, PathCommandType, QuadraticBezierPathCommand } from '../../math/shapes/Path';
2
+ import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
3
+ import RenderablePathSpec from '../../rendering/RenderablePathSpec';
4
+ import { Point2, Vec2, Rect2, PathCommand, PathCommandType, QuadraticBezierPathCommand, LinePathCommand } from '@js-draw/math';
6
5
  import Stroke from '../Stroke';
7
6
  import Viewport from '../../Viewport';
8
7
  import { StrokeDataPoint } from '../../types';
@@ -1,7 +1,6 @@
1
- import Mat33 from '../../math/Mat33';
2
- import Path from '../../math/shapes/Path';
3
- import Rect2 from '../../math/shapes/Rect2';
1
+ import { Mat33, Rect2, Path } from '@js-draw/math';
4
2
  import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
3
+ import { pathToRenderable } from '../../rendering/RenderablePathSpec';
5
4
  import { StrokeDataPoint } from '../../types';
6
5
  import Viewport from '../../Viewport';
7
6
  import AbstractComponent from '../AbstractComponent';
@@ -52,7 +51,7 @@ export default class RectangleBuilder implements ComponentBuilder {
52
51
  ).mapPoints(point => this.viewport.roundPoint(point));
53
52
 
54
53
  const preview = new Stroke([
55
- path.toRenderable({
54
+ pathToRenderable(path, {
56
55
  fill: this.endPoint.color
57
56
  }),
58
57
  ]);
@@ -1,4 +1,4 @@
1
- import Rect2 from '../../math/shapes/Rect2';
1
+ import { Rect2 } from '@js-draw/math';
2
2
  import AbstractRenderer from '../../rendering/renderers/AbstractRenderer';
3
3
  import { StrokeDataPoint } from '../../types';
4
4
  import Viewport from '../../Viewport';
@@ -22,7 +22,7 @@ export {
22
22
 
23
23
  TextComponent,
24
24
 
25
- // @deprecated
25
+ /** @deprecated use {@link TextComponent} */
26
26
  TextComponent as Text,
27
27
 
28
28
  Stroke as StrokeComponent,