js-draw 0.25.0 → 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 +44 -45
  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 +43 -45
  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 -167
  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,805 +0,0 @@
1
- import Color4 from '../Color4';
2
- import { ComponentBuilderFactory } from '../components/builders/types';
3
- import { Vec2 } from '../math/Vec2';
4
- import SVGRenderer from '../rendering/renderers/SVGRenderer';
5
- import TextRenderingStyle from '../rendering/TextRenderingStyle';
6
- import Pen from '../tools/Pen';
7
- import { StrokeDataPoint } from '../types';
8
- import Viewport from '../Viewport';
9
-
10
- export type IconType = HTMLImageElement|SVGElement;
11
-
12
- const svgNamespace = 'http://www.w3.org/2000/svg';
13
- const iconColorFill = `
14
- style='fill: var(--icon-color);'
15
- `;
16
- const iconColorStrokeFill = `
17
- style='fill: var(--icon-color); stroke: var(--icon-color);'
18
- `;
19
-
20
- let checkerboardIdCounter = 0;
21
- const makeCheckerboardPattern = () => {
22
- const id = `checkerboard-${checkerboardIdCounter++}`;
23
- const patternDef = `
24
- <pattern
25
- id='${id}'
26
- viewBox='0,0,10,10'
27
- width='20%'
28
- height='20%'
29
- patternUnits='userSpaceOnUse'
30
- >
31
- <rect x=0 y=0 width=10 height=10 fill='white'/>
32
- <rect x=0 y=0 width=5 height=5 fill='gray'/>
33
- <rect x=5 y=5 width=5 height=5 fill='gray'/>
34
- </pattern>
35
- `;
36
- const patternRef = `url(#${id})`;
37
-
38
- return { patternDef, patternRef };
39
- };
40
-
41
-
42
- /**
43
- * Provides icons that can be used in the toolbar, etc.
44
- * Extend this class and override methods to customize icons.
45
- *
46
- * @example
47
- * ```ts
48
- * class CustomIconProvider extends jsdraw.IconProvider {
49
- * // Use '☺' instead of the default dropdown symbol.
50
- * public makeDropdownIcon() {
51
- * const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
52
- * icon.innerHTML = `
53
- * <text x='5' y='55' style='fill: var(--icon-color); font-size: 50pt;'>☺</text>
54
- * `;
55
- * icon.setAttribute('viewBox', '0 0 100 100');
56
- * return icon;
57
- * }
58
- * }
59
- *
60
- * const icons = new CustomIconProvider();
61
- * const editor = new jsdraw.Editor(document.body, {
62
- * iconProvider: icons,
63
- * });
64
- *
65
- * // Add a toolbar that uses these icons
66
- * editor.addToolbar();
67
- * ```
68
- */
69
- export default class IconProvider {
70
-
71
- public makeUndoIcon(): IconType {
72
- return this.makeRedoIcon(true);
73
- }
74
-
75
- // @param mirror - reflect across the x-axis. This parameter is internal.
76
- // @returns a redo icon.
77
- public makeRedoIcon(mirror: boolean = false): IconType {
78
- const icon = document.createElementNS(svgNamespace, 'svg');
79
- icon.innerHTML = `
80
- <style>
81
- .toolbar-svg-undo-redo-icon {
82
- stroke: var(--icon-color);
83
- stroke-width: 12;
84
- stroke-linejoin: round;
85
- stroke-linecap: round;
86
- fill: none;
87
-
88
- transform-origin: center;
89
- }
90
- </style>
91
- <path
92
- d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
93
- class='toolbar-svg-undo-redo-icon'
94
- style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
95
- `;
96
- icon.setAttribute('viewBox', '0 0 100 100');
97
- return icon;
98
- }
99
-
100
- public makeDropdownIcon(): IconType {
101
- const icon = document.createElementNS(svgNamespace, 'svg');
102
- icon.innerHTML = `
103
- <g>
104
- <path
105
- d='M5,10 L50,90 L95,10 Z'
106
- ${iconColorFill}
107
- />
108
- </g>
109
- `;
110
- icon.setAttribute('viewBox', '0 0 100 100');
111
- return icon;
112
- }
113
-
114
- public makeEraserIcon(eraserSize?: number): IconType {
115
- const icon = document.createElementNS(svgNamespace, 'svg');
116
- eraserSize ??= 10;
117
-
118
- const scaledSize = eraserSize / 4;
119
- const eraserColor = '#ff70af';
120
-
121
- // Draw an eraser-like shape. Created with Inkscape
122
- icon.innerHTML = `
123
- <g>
124
- <path
125
- style="fill:${eraserColor}"
126
- stroke="black"
127
- transform="rotate(41.35)"
128
- d="M 52.5 27
129
- C 50 28.9 48.9 31.7 48.9 34.8
130
- L 48.9 39.8
131
- C 48.9 45.3 53.4 49.8 58.9 49.8
132
- L 103.9 49.8
133
- C 105.8 49.8 107.6 49.2 109.1 48.3
134
- L 110.2 ${scaledSize + 49.5} L 159.7 ${scaledSize + 5}
135
- L 157.7 ${-scaledSize + 5.2} L 112.4 ${49.5 - scaledSize}
136
- C 113.4 43.5 113.9 41.7 113.9 39.8
137
- L 113.9 34.8
138
- C 113.9 29.3 109.4 24.8 103.9 24.8
139
- L 58.9 24.8
140
- C 56.5 24.8 54.3 25.7 52.5 27
141
- z "
142
- id="path438" />
143
-
144
- <rect
145
- stroke="#cc8077"
146
- ${iconColorFill}
147
- id="rect218"
148
- width="65"
149
- height="75"
150
- x="48.9"
151
- y="-38.7"
152
- transform="rotate(41.35)" />
153
- </g>
154
- `;
155
- icon.setAttribute('viewBox', '0 0 120 120');
156
- return icon;
157
- }
158
-
159
- public makeSelectionIcon(): IconType {
160
- const icon = document.createElementNS(svgNamespace, 'svg');
161
-
162
- // Draw a cursor-like shape
163
- icon.innerHTML = `
164
- <g>
165
- <rect x=10 y=10 width=70 height=70 fill='pink' stroke='black'/>
166
- <rect x=75 y=75 width=10 height=10 fill='white' stroke='black'/>
167
- </g>
168
- `;
169
- icon.setAttribute('viewBox', '0 0 100 100');
170
-
171
- return icon;
172
- }
173
-
174
- /**
175
- * @param pathData - SVG path data (e.g. `m10,10l30,30z`)
176
- * @param fill - A valid CSS color (e.g. `var(--icon-color)` or `#f0f`). This can be `none`.
177
- */
178
- protected makeIconFromPath(
179
- pathData: string,
180
- fill: string = 'var(--icon-color)',
181
- strokeColor: string = 'none',
182
- strokeWidth: string = '0px',
183
- ): IconType {
184
- const icon = document.createElementNS(svgNamespace, 'svg');
185
- const path = document.createElementNS(svgNamespace, 'path');
186
- path.setAttribute('d', pathData);
187
- path.style.fill = fill;
188
- path.style.stroke = strokeColor;
189
- path.style.strokeWidth = strokeWidth;
190
- icon.appendChild(path);
191
- icon.setAttribute('viewBox', '0 0 100 100');
192
-
193
- return icon;
194
- }
195
-
196
- public makeHandToolIcon(): IconType {
197
- const fill = 'none';
198
- const strokeColor = 'var(--icon-color)';
199
- const strokeWidth = '3';
200
-
201
- // Draw a cursor-like shape
202
- return this.makeIconFromPath(`
203
- m 10,60
204
- 5,30
205
- H 90
206
- V 30
207
- C 90,20 75,20 75,30
208
- V 60
209
- 20
210
- C 75,10 60,10 60,20
211
- V 60
212
- 15
213
- C 60,5 45,5 45,15
214
- V 60
215
- 25
216
- C 45,15 30,15 30,25
217
- V 60
218
- 75
219
- L 25,60
220
- C 20,45 10,50 10,60
221
- Z
222
- `, fill, strokeColor, strokeWidth);
223
- }
224
-
225
- public makeTouchPanningIcon(): IconType {
226
- const fill = 'none';
227
- const strokeColor = 'var(--icon-color)';
228
- const strokeWidth = '3';
229
-
230
- return this.makeIconFromPath(`
231
- M 5,5.5
232
- V 17.2
233
- L 16.25,5.46
234
- Z
235
-
236
- m 33.75,0
237
- L 50,17
238
- V 5.5
239
- Z
240
-
241
- M 5,40.7
242
- v 11.7
243
- h 11.25
244
- z
245
-
246
- M 26,19
247
- C 19.8,19.4 17.65,30.4 21.9,34.8
248
- L 50,70
249
- H 27.5
250
- c -11.25,0 -11.25,17.6 0,17.6
251
- H 61.25
252
- C 94.9,87.8 95,87.6 95,40.7 78.125,23 67,29 55.6,46.5
253
- L 33.1,23
254
- C 30.3125,20.128192 27.9,19 25.830078,19.119756
255
- Z
256
- `, fill, strokeColor, strokeWidth);
257
- }
258
-
259
- public makeAllDevicePanningIcon(): IconType {
260
- const fill = 'none';
261
- const strokeColor = 'var(--icon-color)';
262
- const strokeWidth = '3';
263
- return this.makeIconFromPath(`
264
- M 5 5
265
- L 5 17.5
266
- 17.5 5
267
- 5 5
268
- z
269
-
270
- M 42.5 5
271
- L 55 17.5
272
- 55 5
273
- 42.5 5
274
- z
275
-
276
- M 70 10
277
- L 70 21
278
- 61 15
279
- 55.5 23
280
- 66 30
281
- 56 37
282
- 61 45
283
- 70 39
284
- 70 50
285
- 80 50
286
- 80 39
287
- 89 45
288
- 95 36
289
- 84 30
290
- 95 23
291
- 89 15
292
- 80 21
293
- 80 10
294
- 70 10
295
- z
296
-
297
- M 27.5 26.25
298
- L 27.5 91.25
299
- L 43.75 83.125
300
- L 52 99
301
- L 68 91
302
- L 60 75
303
- L 76.25 66.875
304
- L 27.5 26.25
305
- z
306
-
307
- M 5 42.5
308
- L 5 55
309
- L 17.5 55
310
- L 5 42.5
311
- z
312
- `, fill, strokeColor, strokeWidth);
313
- }
314
-
315
- public makeZoomIcon(): IconType {
316
- const icon = document.createElementNS(svgNamespace, 'svg');
317
- icon.setAttribute('viewBox', '0 0 100 100');
318
-
319
- const addTextNode = (text: string, x: number, y: number) => {
320
- const textNode = document.createElementNS(svgNamespace, 'text');
321
- textNode.appendChild(document.createTextNode(text));
322
- textNode.setAttribute('x', x.toString());
323
- textNode.setAttribute('y', y.toString());
324
- textNode.style.textAlign = 'center';
325
- textNode.style.textAnchor = 'middle';
326
- textNode.style.fontSize = '55px';
327
- textNode.style.fill = 'var(--icon-color)';
328
- textNode.style.fontFamily = 'monospace';
329
-
330
- icon.appendChild(textNode);
331
- };
332
-
333
- addTextNode('+', 40, 45);
334
- addTextNode('-', 70, 75);
335
-
336
- return icon;
337
- }
338
-
339
- public makeRotationLockIcon(): IconType {
340
- const icon = this.makeIconFromPath(`
341
- M 40.1 25.1
342
- C 32.5 25 27.9 34.1 27.9 34.1
343
- L 25.7 30
344
- L 28 44.7
345
- L 36.6 40.3
346
- L 32.3 38.3
347
- C 33.6 28 38.1 25.2 45.1 31.8
348
- L 49.4 29.6
349
- C 45.9 26.3 42.8 25.1 40.1 25.1
350
- z
351
-
352
- M 51.7 34.2
353
- L 43.5 39.1
354
- L 48 40.8
355
- C 47.4 51.1 43.1 54.3 35.7 48.2
356
- L 31.6 50.7
357
- C 45.5 62.1 52.6 44.6 52.6 44.6
358
- L 55.1 48.6
359
- L 51.7 34.2
360
- z
361
-
362
- M 56.9 49.9
363
- C 49.8 49.9 49.2 57.3 49.3 60.9
364
- L 47.6 60.9
365
- L 47.6 73.7
366
- L 66.1 73.7
367
- L 66.1 60.9
368
- L 64.4 60.9
369
- C 64.5 57.3 63.9 49.9 56.9 49.9
370
- z
371
-
372
- M 56.9 53.5
373
- C 60.8 53.5 61 58.2 60.8 60.9
374
- L 52.9 60.9
375
- C 52.7 58.2 52.9 53.5 56.9 53.5
376
- z
377
- `);
378
-
379
- icon.setAttribute('viewBox', '10 10 70 70');
380
-
381
- return icon;
382
- }
383
-
384
- public makeInsertImageIcon(): IconType {
385
- return this.makeIconFromPath(`
386
- M 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z
387
- M 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z
388
- M 22.5 25 A 7.5 7.5 0 0 0 15 32.5 A 7.5 7.5 0 0 0 22.5 40 A 7.5 7.5 0 0 0 30 32.5 A 7.5 7.5 0 0 0 22.5 25 z
389
- `);
390
- }
391
-
392
- public makeTextIcon(textStyle: TextRenderingStyle): IconType {
393
- const icon = document.createElementNS(svgNamespace, 'svg');
394
- icon.setAttribute('viewBox', '0 0 100 100');
395
-
396
- const textNode = document.createElementNS(svgNamespace, 'text');
397
- textNode.appendChild(document.createTextNode('T'));
398
-
399
- textNode.style.fontFamily = textStyle.fontFamily;
400
- textNode.style.fontWeight = textStyle.fontWeight ?? '';
401
- textNode.style.fontVariant = textStyle.fontVariant ?? '';
402
- textNode.style.fill = textStyle.renderingStyle.fill.toHexString();
403
-
404
- textNode.style.textAnchor = 'middle';
405
- textNode.setAttribute('x', '50');
406
- textNode.setAttribute('y', '75');
407
- textNode.style.fontSize = '65px';
408
- textNode.style.filter = 'drop-shadow(0px 0px 10px var(--primary-shadow-color))';
409
-
410
- icon.appendChild(textNode);
411
-
412
- return icon;
413
- }
414
-
415
- public makePenIcon(strokeSize: number, color: string|Color4, rounded?: boolean): IconType {
416
- if (color instanceof Color4) {
417
- color = color.toHexString();
418
- }
419
-
420
- const icon = document.createElementNS(svgNamespace, 'svg');
421
- icon.setAttribute('viewBox', '0 0 100 100');
422
- const tipThickness = strokeSize / 2;
423
-
424
- const inkTipPath = `
425
- M ${15 - tipThickness},${80 - tipThickness}
426
- ${15 - tipThickness},${80 + tipThickness}
427
- 30,83
428
- 15,65
429
- Z
430
- `;
431
- const trailStartEndY = 80 + tipThickness;
432
- const inkTrailPath = `
433
- m ${15 - tipThickness * 1.1},${trailStartEndY}
434
- c 35,10 55,15 60,30
435
- l ${35 + tipThickness * 1.2},${-10 - tipThickness}
436
- C 80.47,98.32 50.5,${90 + tipThickness} 20,${trailStartEndY} Z
437
- `;
438
-
439
- const colorBubblePath = `
440
- M 72.45,35.67
441
- A 10,15 41.8 0 1 55,40.2 10,15 41.8 0 1 57.55,22.3 10,15 41.8 0 1 75,17.8 10,15 41.8 0 1 72.5,35.67
442
- Z
443
- `;
444
-
445
- let gripMainPath = 'M 85,-25 25,35 h 10 v 10 h 10 v 10 h 10 v 10 h 10 l -5,10 60,-60 z';
446
- let gripShadow1Path = 'M 25,35 H 35 L 90,-15 85,-25 Z';
447
- let gripShadow2Path = 'M 60,75 65,65 H 55 l 55,-55 10,5 z';
448
-
449
- if (rounded) {
450
- gripMainPath = 'M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z';
451
- gripShadow1Path = 'm 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z';
452
- gripShadow2Path = 'M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z';
453
- }
454
-
455
- const penTipPath = `M 25,35 ${10 - tipThickness / 4},${70 - tipThickness / 2} 20,75 25,85 60,75 70,55 45,25 Z`;
456
-
457
- const pencilTipColor = Color4.fromHex('#f4d7d7');
458
- const tipColor = pencilTipColor.mix(
459
- Color4.fromString(color), tipThickness / 40 - 0.1
460
- ).toHexString();
461
-
462
- const checkerboardPattern = makeCheckerboardPattern();
463
-
464
- const ink = `
465
- <path
466
- fill="${checkerboardPattern.patternRef}"
467
- d="${inkTipPath}"
468
- />
469
- <path
470
- fill="${checkerboardPattern.patternRef}"
471
- d="${inkTrailPath}"
472
- />
473
- <path
474
- fill="${color}"
475
- d="${inkTipPath}"
476
- />
477
- <path
478
- fill="${color}"
479
- d="${inkTrailPath}"
480
- />
481
- `;
482
-
483
- const penTip = `
484
- <path
485
- fill="${checkerboardPattern.patternRef}"
486
- d="${penTipPath}"
487
- />
488
- <path
489
- fill="${tipColor}"
490
- stroke="${color}"
491
- d="${penTipPath}"
492
- />
493
- `;
494
-
495
- const grip = `
496
- <path
497
- ${iconColorStrokeFill}
498
- d="${gripMainPath}"
499
- />
500
-
501
- <!-- shadows -->
502
- <path
503
- fill="rgba(150, 150, 150, 0.3)"
504
- d="${gripShadow1Path}"
505
- />
506
- <path
507
- fill="rgba(100, 100, 100, 0.2)"
508
- d="${gripShadow2Path}"
509
- />
510
-
511
- <!-- color bubble -->
512
- <path
513
- fill="${checkerboardPattern.patternRef}"
514
- d="${colorBubblePath}"
515
- />
516
- <path
517
- fill="${color}"
518
- d="${colorBubblePath}"
519
- />
520
- `;
521
-
522
- icon.innerHTML = `
523
- <defs>
524
- ${checkerboardPattern.patternDef}
525
- </defs>
526
- <g>
527
- ${ink}
528
- ${penTip}
529
- ${grip}
530
- </g>
531
- `;
532
- return icon;
533
- }
534
-
535
- public makeIconFromFactory(
536
- pen: Pen,
537
- factory: ComponentBuilderFactory,
538
-
539
- // If true, attempts to guess the location of a transparency grid
540
- includeTransparencyGrid: boolean = false
541
- ): IconType {
542
- // Increase the thickness we use to generate the icon less with larger actual thicknesses.
543
- // We want the icon to be recognisable with a large range of thicknesses.
544
- const thickness = Math.sqrt(pen.getThickness()) * 3;
545
-
546
- const nowTime = (new Date()).getTime();
547
- const startPoint: StrokeDataPoint = {
548
- pos: Vec2.of(10, 10),
549
- width: thickness,
550
- color: pen.getColor(),
551
- time: nowTime - 100,
552
- };
553
- const endPoint: StrokeDataPoint = {
554
- pos: Vec2.of(90, 90),
555
- width: thickness,
556
- color: pen.getColor(),
557
- time: nowTime,
558
- };
559
-
560
- const viewport = new Viewport(() => {});
561
- const builder = factory(startPoint, viewport);
562
- builder.addPoint(endPoint);
563
-
564
- const icon = document.createElementNS(svgNamespace, 'svg');
565
- icon.setAttribute('viewBox', '0 0 100 100');
566
- viewport.updateScreenSize(Vec2.of(100, 100));
567
-
568
- let renderer;
569
-
570
- if (includeTransparencyGrid) {
571
- const checkerboardPattern = makeCheckerboardPattern();
572
-
573
- const defs = document.createElementNS(svgNamespace, 'defs');
574
- defs.innerHTML = checkerboardPattern.patternDef;
575
- icon.appendChild(defs);
576
-
577
- const background = document.createElementNS(svgNamespace, 'g');
578
- icon.appendChild(background);
579
-
580
- renderer = new class extends SVGRenderer {
581
- public constructor() {
582
- super(icon, viewport);
583
- }
584
-
585
- protected override addPathToSVG() {
586
- const addedPath = super.addPathToSVG();
587
-
588
- if (addedPath) {
589
- // Add a copy of the path on the background
590
- const copy = addedPath.cloneNode(true) as SVGPathElement;
591
- copy.style.zIndex = '-1';
592
-
593
- // Make the
594
- if (copy.hasAttribute('fill')
595
- && copy.getAttribute('fill') !== 'transparent'
596
- && copy.getAttribute('fill') !== 'none') {
597
- copy.setAttribute('fill', checkerboardPattern.patternRef);
598
- }
599
-
600
- if (copy.hasAttribute('stroke')) {
601
- copy.setAttribute('stroke', checkerboardPattern.patternRef);
602
- }
603
-
604
- background.appendChild(copy);
605
- }
606
-
607
- return addedPath;
608
- }
609
- }();
610
- } else {
611
- renderer = new SVGRenderer(icon, viewport);
612
- }
613
- builder.preview(renderer);
614
-
615
- // If only a single path was rendered, try to give it a checkerboard background to
616
- // emphasize transparency. TODO: This is very fragile
617
-
618
-
619
- const bbox = builder.getBBox();
620
- icon.setAttribute('viewBox', `${bbox.x} ${bbox.y} ${bbox.w} ${bbox.h}`);
621
-
622
- return icon;
623
- }
624
-
625
- public makePipetteIcon(color?: Color4): IconType {
626
- const icon = document.createElementNS(svgNamespace, 'svg');
627
- const pipette = document.createElementNS(svgNamespace, 'path');
628
-
629
- pipette.setAttribute('d', `
630
- M 47,6
631
- C 35,5 25,15 35,30
632
- c -9.2,1.3 -15,0 -15,3
633
- 0,2 5,5 15,7
634
- V 81
635
- L 40,90
636
- h 6
637
- L 40,80
638
- V 40
639
- h 15
640
- v 40
641
- l -6,10
642
- h 6
643
- l 5,-9.2
644
- V 40
645
- C 70,38 75,35 75,33
646
- 75,30 69.2,31.2 60,30
647
- 65,15 65,5 47,6
648
- Z
649
- `);
650
- pipette.style.fill = 'var(--icon-color)';
651
-
652
- if (color) {
653
- const checkerboardPattern = makeCheckerboardPattern();
654
-
655
- const defs = document.createElementNS(svgNamespace, 'defs');
656
- defs.innerHTML = checkerboardPattern.patternDef;
657
- icon.appendChild(defs);
658
-
659
- const fluidBackground = document.createElementNS(svgNamespace, 'path');
660
- const fluid = document.createElementNS(svgNamespace, 'path');
661
-
662
- const fluidPathData = `
663
- m 40,50 c 5,5 10,0 15,-5 V 80 L 50,90 H 45 L 40,80 Z
664
- `;
665
-
666
- fluid.setAttribute('d', fluidPathData);
667
- fluidBackground.setAttribute('d', fluidPathData);
668
-
669
- fluid.style.fill = color.toHexString();
670
- fluidBackground.style.fill = checkerboardPattern.patternRef;
671
-
672
- icon.appendChild(fluidBackground);
673
- icon.appendChild(fluid);
674
- }
675
- icon.appendChild(pipette);
676
-
677
- icon.setAttribute('viewBox', '0 0 100 100');
678
- return icon;
679
- }
680
-
681
- public makeFormatSelectionIcon(): IconType {
682
- return this.makeIconFromPath(`
683
- M 5 10
684
- L 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z
685
- M 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z
686
- M 60 25 L 55 25 L 50 30 L 60 25 z
687
- M 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z
688
- M 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z
689
- `);
690
- }
691
-
692
- public makeResizeViewportIcon(): IconType {
693
- return this.makeIconFromPath(`
694
- M 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z
695
- M 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z
696
- M 84 15 82 17 81 16 81 20 85 20 84 19 86 17 84 15 z
697
- M 26 24 24 26 26 28 25 29 29 29 29 25 28 26 26 24 z
698
- M 25 71 26 72 24 74 26 76 28 74 29 75 29 71 25 71 z
699
- M 15 75 15 85 25 85 25 80 20 80 20 75 15 75 z
700
- M 90 75 90 90 75 90 75 95 95 95 95 75 90 75 z
701
- M 81 81 81 85 82 84 84 86 86 84 84 82 85 81 81 81 z
702
- `);
703
- }
704
-
705
- public makeDuplicateSelectionIcon(): IconType {
706
- return this.makeIconFromPath(`
707
- M 45,10 45,55 90,55 90,10 45,10 z
708
- M 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z
709
- `);
710
- }
711
-
712
- public makePasteIcon(): IconType {
713
- const icon = this.makeIconFromPath(`
714
- M 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z
715
- M 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z
716
- M 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z
717
- M 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z
718
- M 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z
719
- M 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z
720
- `);
721
- icon.setAttribute('viewBox', '0 0 120 120');
722
- return icon;
723
- }
724
-
725
- public makeDeleteSelectionIcon(): IconType {
726
- const strokeWidth = '5px';
727
- const strokeColor = 'var(--icon-color)';
728
- const fillColor = 'none';
729
-
730
- return this.makeIconFromPath(`
731
- M 10,10 90,90
732
- M 10,90 90,10
733
- `, fillColor, strokeColor, strokeWidth);
734
- }
735
-
736
- public makeSaveIcon(): IconType {
737
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
738
- svg.innerHTML = `
739
- <style>
740
- .toolbar-save-icon {
741
- stroke: var(--icon-color);
742
- stroke-width: 10;
743
- stroke-linejoin: round;
744
- stroke-linecap: round;
745
- fill: none;
746
- }
747
- </style>
748
- <path
749
- d='
750
- M 15,55 30,70 85,20
751
- '
752
- class='toolbar-save-icon'
753
- />
754
- `;
755
- svg.setAttribute('viewBox', '0 0 100 100');
756
- return svg;
757
- }
758
-
759
- public makeConfigureDocumentIcon(): IconType {
760
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
761
- svg.innerHTML = `
762
- <path
763
- d='
764
- M 5,5 V 95 H 95 V 5 Z m 5,5 H 90 V 90 H 10 Z
765
- m 5,10 V 30 H 50 V 25 H 20 v -5 z
766
- m 40,0 V 50 H 85 V 20 Z
767
- m 2,2 H 83 V 39 L 77,28 70,42 64,35 57,45 Z
768
- m 8.5,5 C 64.67,27 64,27.67 64,28.5 64,29.33 64.67,30 65.5,30 66.33,30 67,29.33 67,28.5 67,27.67 66.33,27 65.5,27 Z
769
- M 15,40 v 5 h 35 v -5 z
770
- m 0,15 v 5 h 70 v -5 z
771
- m 0,15 v 5 h 70 v -5 z
772
- '
773
- style='fill: var(--icon-color);'
774
- />
775
- `;
776
- svg.setAttribute('viewBox', '0 0 100 100');
777
- return svg;
778
- }
779
-
780
- public makeOverflowIcon(): IconType {
781
- return this.makeIconFromPath(`
782
- M 15 40
783
- A 12.5 12.5 0 0 0 2.5 52.5
784
- A 12.5 12.5 0 0 0 15 65
785
- A 12.5 12.5 0 0 0 27.5 52.5
786
- A 12.5 12.5 0 0 0 15 40
787
- z
788
-
789
- M 50 40
790
- A 12.5 12.5 0 0 0 37.5 52.5
791
- A 12.5 12.5 0 0 0 50 65
792
- A 12.5 12.5 0 0 0 62.5 52.5
793
- A 12.5 12.5 0 0 0 50 40
794
- z
795
-
796
- M 85 40
797
- A 12.5 12.5 0 0 0 72.5 52.5
798
- A 12.5 12.5 0 0 0 85 65
799
- A 12.5 12.5 0 0 0 97.5 52.5
800
- A 12.5 12.5 0 0 0 85 40
801
- z
802
- `);
803
- }
804
-
805
- }