js-draw 0.17.4 → 0.18.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 (413) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bundle.js +9 -1
  3. package/package.json +35 -33
  4. package/tsconfig.json +3 -2
  5. package/tsconfig.mjs.json +9 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -34
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  8. package/.github/ISSUE_TEMPLATE/translation.yml +0 -902
  9. package/.github/pull_request_template.md +0 -15
  10. package/.github/workflows/firebase-hosting-merge.yml +0 -32
  11. package/.github/workflows/firebase-hosting-pull-request.yml +0 -32
  12. package/.github/workflows/github-pages.yml +0 -56
  13. package/.husky/pre-commit +0 -4
  14. package/build_tools/BundledFile.ts +0 -167
  15. package/build_tools/buildTranslationTemplate.ts +0 -121
  16. package/build_tools/bundle.ts +0 -11
  17. package/dist/build_tools/BundledFile.d.ts +0 -13
  18. package/dist/build_tools/BundledFile.js +0 -157
  19. package/dist/build_tools/buildTranslationTemplate.d.ts +0 -1
  20. package/dist/build_tools/buildTranslationTemplate.js +0 -94
  21. package/dist/build_tools/bundle.d.ts +0 -1
  22. package/dist/build_tools/bundle.js +0 -5
  23. package/dist/src/Color4.d.ts +0 -60
  24. package/dist/src/Color4.js +0 -192
  25. package/dist/src/Editor.d.ts +0 -308
  26. package/dist/src/Editor.js +0 -874
  27. package/dist/src/EditorImage.d.ts +0 -97
  28. package/dist/src/EditorImage.js +0 -477
  29. package/dist/src/EventDispatcher.d.ts +0 -30
  30. package/dist/src/EventDispatcher.js +0 -54
  31. package/dist/src/Pointer.d.ts +0 -24
  32. package/dist/src/Pointer.js +0 -80
  33. package/dist/src/SVGLoader.d.ts +0 -48
  34. package/dist/src/SVGLoader.js +0 -442
  35. package/dist/src/UndoRedoHistory.d.ts +0 -19
  36. package/dist/src/UndoRedoHistory.js +0 -91
  37. package/dist/src/Viewport.d.ts +0 -71
  38. package/dist/src/Viewport.js +0 -256
  39. package/dist/src/bundle/bundled.d.ts +0 -4
  40. package/dist/src/bundle/bundled.js +0 -5
  41. package/dist/src/commands/Command.d.ts +0 -16
  42. package/dist/src/commands/Command.js +0 -30
  43. package/dist/src/commands/Duplicate.d.ts +0 -14
  44. package/dist/src/commands/Duplicate.js +0 -33
  45. package/dist/src/commands/Erase.d.ts +0 -14
  46. package/dist/src/commands/Erase.js +0 -57
  47. package/dist/src/commands/SerializableCommand.d.ts +0 -12
  48. package/dist/src/commands/SerializableCommand.js +0 -36
  49. package/dist/src/commands/UnresolvedCommand.d.ts +0 -14
  50. package/dist/src/commands/UnresolvedCommand.js +0 -22
  51. package/dist/src/commands/invertCommand.d.ts +0 -4
  52. package/dist/src/commands/invertCommand.js +0 -44
  53. package/dist/src/commands/lib.d.ts +0 -7
  54. package/dist/src/commands/lib.js +0 -7
  55. package/dist/src/commands/localization.d.ts +0 -23
  56. package/dist/src/commands/localization.js +0 -21
  57. package/dist/src/commands/uniteCommands.d.ts +0 -4
  58. package/dist/src/commands/uniteCommands.js +0 -116
  59. package/dist/src/components/AbstractComponent.d.ts +0 -73
  60. package/dist/src/components/AbstractComponent.js +0 -252
  61. package/dist/src/components/ImageBackground.d.ts +0 -42
  62. package/dist/src/components/ImageBackground.js +0 -139
  63. package/dist/src/components/ImageComponent.d.ts +0 -31
  64. package/dist/src/components/ImageComponent.js +0 -146
  65. package/dist/src/components/RestylableComponent.d.ts +0 -24
  66. package/dist/src/components/RestylableComponent.js +0 -80
  67. package/dist/src/components/SVGGlobalAttributesObject.d.ts +0 -21
  68. package/dist/src/components/SVGGlobalAttributesObject.js +0 -59
  69. package/dist/src/components/Stroke.d.ts +0 -40
  70. package/dist/src/components/Stroke.js +0 -185
  71. package/dist/src/components/TextComponent.d.ts +0 -53
  72. package/dist/src/components/TextComponent.js +0 -252
  73. package/dist/src/components/UnknownSVGObject.d.ts +0 -18
  74. package/dist/src/components/UnknownSVGObject.js +0 -44
  75. package/dist/src/components/builders/ArrowBuilder.d.ts +0 -19
  76. package/dist/src/components/builders/ArrowBuilder.js +0 -86
  77. package/dist/src/components/builders/FreehandLineBuilder.d.ts +0 -33
  78. package/dist/src/components/builders/FreehandLineBuilder.js +0 -165
  79. package/dist/src/components/builders/LineBuilder.d.ts +0 -18
  80. package/dist/src/components/builders/LineBuilder.js +0 -58
  81. package/dist/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -36
  82. package/dist/src/components/builders/PressureSensitiveFreehandLineBuilder.js +0 -339
  83. package/dist/src/components/builders/RectangleBuilder.d.ts +0 -20
  84. package/dist/src/components/builders/RectangleBuilder.js +0 -50
  85. package/dist/src/components/builders/types.d.ts +0 -12
  86. package/dist/src/components/builders/types.js +0 -1
  87. package/dist/src/components/lib.d.ts +0 -12
  88. package/dist/src/components/lib.js +0 -12
  89. package/dist/src/components/localization.d.ts +0 -11
  90. package/dist/src/components/localization.js +0 -10
  91. package/dist/src/components/util/StrokeSmoother.d.ts +0 -35
  92. package/dist/src/components/util/StrokeSmoother.js +0 -210
  93. package/dist/src/components/util/describeComponentList.d.ts +0 -4
  94. package/dist/src/components/util/describeComponentList.js +0 -14
  95. package/dist/src/lib.d.ts +0 -34
  96. package/dist/src/lib.js +0 -34
  97. package/dist/src/localization.d.ts +0 -14
  98. package/dist/src/localization.js +0 -10
  99. package/dist/src/localizations/de.d.ts +0 -3
  100. package/dist/src/localizations/de.js +0 -4
  101. package/dist/src/localizations/en.d.ts +0 -3
  102. package/dist/src/localizations/en.js +0 -4
  103. package/dist/src/localizations/es.d.ts +0 -3
  104. package/dist/src/localizations/es.js +0 -18
  105. package/dist/src/localizations/getLocalizationTable.d.ts +0 -3
  106. package/dist/src/localizations/getLocalizationTable.js +0 -45
  107. package/dist/src/math/LineSegment2.d.ts +0 -24
  108. package/dist/src/math/LineSegment2.js +0 -125
  109. package/dist/src/math/Mat33.d.ts +0 -118
  110. package/dist/src/math/Mat33.js +0 -326
  111. package/dist/src/math/Path.d.ts +0 -71
  112. package/dist/src/math/Path.js +0 -648
  113. package/dist/src/math/Rect2.d.ts +0 -52
  114. package/dist/src/math/Rect2.js +0 -228
  115. package/dist/src/math/Triangle.d.ts +0 -11
  116. package/dist/src/math/Triangle.js +0 -19
  117. package/dist/src/math/Vec2.d.ts +0 -13
  118. package/dist/src/math/Vec2.js +0 -13
  119. package/dist/src/math/Vec3.d.ts +0 -106
  120. package/dist/src/math/Vec3.js +0 -174
  121. package/dist/src/math/lib.d.ts +0 -7
  122. package/dist/src/math/lib.js +0 -7
  123. package/dist/src/math/rounding.d.ts +0 -4
  124. package/dist/src/math/rounding.js +0 -128
  125. package/dist/src/rendering/Display.d.ts +0 -75
  126. package/dist/src/rendering/Display.js +0 -207
  127. package/dist/src/rendering/RenderingStyle.d.ts +0 -31
  128. package/dist/src/rendering/RenderingStyle.js +0 -38
  129. package/dist/src/rendering/TextRenderingStyle.d.ts +0 -36
  130. package/dist/src/rendering/TextRenderingStyle.js +0 -23
  131. package/dist/src/rendering/caching/CacheRecord.d.ts +0 -20
  132. package/dist/src/rendering/caching/CacheRecord.js +0 -55
  133. package/dist/src/rendering/caching/CacheRecordManager.d.ts +0 -12
  134. package/dist/src/rendering/caching/CacheRecordManager.js +0 -43
  135. package/dist/src/rendering/caching/RenderingCache.d.ts +0 -11
  136. package/dist/src/rendering/caching/RenderingCache.js +0 -45
  137. package/dist/src/rendering/caching/RenderingCacheNode.d.ts +0 -29
  138. package/dist/src/rendering/caching/RenderingCacheNode.js +0 -320
  139. package/dist/src/rendering/caching/testUtils.d.ts +0 -9
  140. package/dist/src/rendering/caching/testUtils.js +0 -20
  141. package/dist/src/rendering/caching/types.d.ts +0 -19
  142. package/dist/src/rendering/caching/types.js +0 -1
  143. package/dist/src/rendering/lib.d.ts +0 -5
  144. package/dist/src/rendering/lib.js +0 -5
  145. package/dist/src/rendering/localization.d.ts +0 -10
  146. package/dist/src/rendering/localization.js +0 -9
  147. package/dist/src/rendering/renderers/AbstractRenderer.d.ts +0 -68
  148. package/dist/src/rendering/renderers/AbstractRenderer.js +0 -144
  149. package/dist/src/rendering/renderers/CanvasRenderer.d.ts +0 -63
  150. package/dist/src/rendering/renderers/CanvasRenderer.js +0 -230
  151. package/dist/src/rendering/renderers/DummyRenderer.d.ts +0 -35
  152. package/dist/src/rendering/renderers/DummyRenderer.js +0 -106
  153. package/dist/src/rendering/renderers/SVGRenderer.d.ts +0 -57
  154. package/dist/src/rendering/renderers/SVGRenderer.js +0 -304
  155. package/dist/src/rendering/renderers/TextOnlyRenderer.d.ts +0 -29
  156. package/dist/src/rendering/renderers/TextOnlyRenderer.js +0 -57
  157. package/dist/src/testing/beforeEachFile.d.ts +0 -1
  158. package/dist/src/testing/beforeEachFile.js +0 -7
  159. package/dist/src/testing/createEditor.d.ts +0 -4
  160. package/dist/src/testing/createEditor.js +0 -9
  161. package/dist/src/testing/lib.d.ts +0 -2
  162. package/dist/src/testing/lib.js +0 -2
  163. package/dist/src/testing/loadExpectExtensions.d.ts +0 -2
  164. package/dist/src/testing/loadExpectExtensions.js +0 -24
  165. package/dist/src/testing/sendPenEvent.d.ts +0 -12
  166. package/dist/src/testing/sendPenEvent.js +0 -19
  167. package/dist/src/testing/sendTouchEvent.d.ts +0 -42
  168. package/dist/src/testing/sendTouchEvent.js +0 -62
  169. package/dist/src/toolbar/HTMLToolbar.d.ts +0 -103
  170. package/dist/src/toolbar/HTMLToolbar.js +0 -376
  171. package/dist/src/toolbar/IconProvider.d.ts +0 -62
  172. package/dist/src/toolbar/IconProvider.js +0 -654
  173. package/dist/src/toolbar/lib.d.ts +0 -3
  174. package/dist/src/toolbar/lib.js +0 -3
  175. package/dist/src/toolbar/localization.d.ts +0 -49
  176. package/dist/src/toolbar/localization.js +0 -48
  177. package/dist/src/toolbar/makeColorInput.d.ts +0 -6
  178. package/dist/src/toolbar/makeColorInput.js +0 -113
  179. package/dist/src/toolbar/types.d.ts +0 -4
  180. package/dist/src/toolbar/types.js +0 -1
  181. package/dist/src/toolbar/widgets/ActionButtonWidget.d.ts +0 -15
  182. package/dist/src/toolbar/widgets/ActionButtonWidget.js +0 -25
  183. package/dist/src/toolbar/widgets/BaseToolWidget.d.ts +0 -11
  184. package/dist/src/toolbar/widgets/BaseToolWidget.js +0 -44
  185. package/dist/src/toolbar/widgets/BaseWidget.d.ts +0 -72
  186. package/dist/src/toolbar/widgets/BaseWidget.js +0 -307
  187. package/dist/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +0 -18
  188. package/dist/src/toolbar/widgets/DocumentPropertiesWidget.js +0 -120
  189. package/dist/src/toolbar/widgets/EraserToolWidget.d.ts +0 -17
  190. package/dist/src/toolbar/widgets/EraserToolWidget.js +0 -57
  191. package/dist/src/toolbar/widgets/HandToolWidget.d.ts +0 -17
  192. package/dist/src/toolbar/widgets/HandToolWidget.js +0 -172
  193. package/dist/src/toolbar/widgets/InsertImageWidget.d.ts +0 -19
  194. package/dist/src/toolbar/widgets/InsertImageWidget.js +0 -170
  195. package/dist/src/toolbar/widgets/OverflowWidget.d.ts +0 -25
  196. package/dist/src/toolbar/widgets/OverflowWidget.js +0 -71
  197. package/dist/src/toolbar/widgets/PenToolWidget.d.ts +0 -27
  198. package/dist/src/toolbar/widgets/PenToolWidget.js +0 -220
  199. package/dist/src/toolbar/widgets/SelectionToolWidget.d.ts +0 -13
  200. package/dist/src/toolbar/widgets/SelectionToolWidget.js +0 -147
  201. package/dist/src/toolbar/widgets/TextToolWidget.d.ts +0 -16
  202. package/dist/src/toolbar/widgets/TextToolWidget.js +0 -109
  203. package/dist/src/toolbar/widgets/lib.d.ts +0 -10
  204. package/dist/src/toolbar/widgets/lib.js +0 -10
  205. package/dist/src/tools/BaseTool.d.ts +0 -22
  206. package/dist/src/tools/BaseTool.js +0 -63
  207. package/dist/src/tools/Eraser.d.ts +0 -23
  208. package/dist/src/tools/Eraser.js +0 -106
  209. package/dist/src/tools/FindTool.d.ts +0 -21
  210. package/dist/src/tools/FindTool.js +0 -114
  211. package/dist/src/tools/PanZoom.d.ts +0 -52
  212. package/dist/src/tools/PanZoom.js +0 -414
  213. package/dist/src/tools/PasteHandler.d.ts +0 -23
  214. package/dist/src/tools/PasteHandler.js +0 -93
  215. package/dist/src/tools/Pen.d.ts +0 -39
  216. package/dist/src/tools/Pen.js +0 -173
  217. package/dist/src/tools/PipetteTool.d.ts +0 -18
  218. package/dist/src/tools/PipetteTool.js +0 -39
  219. package/dist/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -8
  220. package/dist/src/tools/SelectionTool/SelectAllShortcutHandler.js +0 -22
  221. package/dist/src/tools/SelectionTool/Selection.d.ts +0 -64
  222. package/dist/src/tools/SelectionTool/Selection.js +0 -459
  223. package/dist/src/tools/SelectionTool/SelectionHandle.d.ts +0 -38
  224. package/dist/src/tools/SelectionTool/SelectionHandle.js +0 -81
  225. package/dist/src/tools/SelectionTool/SelectionTool.d.ts +0 -36
  226. package/dist/src/tools/SelectionTool/SelectionTool.js +0 -398
  227. package/dist/src/tools/SelectionTool/TransformMode.d.ts +0 -34
  228. package/dist/src/tools/SelectionTool/TransformMode.js +0 -98
  229. package/dist/src/tools/SelectionTool/types.d.ts +0 -9
  230. package/dist/src/tools/SelectionTool/types.js +0 -11
  231. package/dist/src/tools/TextTool.d.ts +0 -33
  232. package/dist/src/tools/TextTool.js +0 -256
  233. package/dist/src/tools/ToolController.d.ts +0 -18
  234. package/dist/src/tools/ToolController.js +0 -158
  235. package/dist/src/tools/ToolEnabledGroup.d.ts +0 -6
  236. package/dist/src/tools/ToolEnabledGroup.js +0 -11
  237. package/dist/src/tools/ToolSwitcherShortcut.d.ts +0 -16
  238. package/dist/src/tools/ToolSwitcherShortcut.js +0 -32
  239. package/dist/src/tools/ToolbarShortcutHandler.d.ts +0 -12
  240. package/dist/src/tools/ToolbarShortcutHandler.js +0 -23
  241. package/dist/src/tools/UndoRedoShortcut.d.ts +0 -8
  242. package/dist/src/tools/UndoRedoShortcut.js +0 -22
  243. package/dist/src/tools/lib.d.ts +0 -16
  244. package/dist/src/tools/lib.js +0 -16
  245. package/dist/src/tools/localization.d.ts +0 -28
  246. package/dist/src/tools/localization.js +0 -27
  247. package/dist/src/types.d.ts +0 -151
  248. package/dist/src/types.js +0 -35
  249. package/dist/src/util/assertions.d.ts +0 -23
  250. package/dist/src/util/assertions.js +0 -45
  251. package/dist/src/util/fileToBase64.d.ts +0 -3
  252. package/dist/src/util/fileToBase64.js +0 -13
  253. package/dist/src/util/untilNextAnimationFrame.d.ts +0 -3
  254. package/dist/src/util/untilNextAnimationFrame.js +0 -7
  255. package/dist/src/util/waitForTimeout.d.ts +0 -2
  256. package/dist/src/util/waitForTimeout.js +0 -7
  257. package/src/Color4.test.ts +0 -40
  258. package/src/Color4.ts +0 -234
  259. package/src/Editor.css +0 -86
  260. package/src/Editor.loadFrom.test.ts +0 -24
  261. package/src/Editor.toSVG.test.ts +0 -111
  262. package/src/Editor.ts +0 -1122
  263. package/src/EditorImage.test.ts +0 -120
  264. package/src/EditorImage.ts +0 -603
  265. package/src/EventDispatcher.test.ts +0 -123
  266. package/src/EventDispatcher.ts +0 -71
  267. package/src/Pointer.ts +0 -127
  268. package/src/SVGLoader.test.ts +0 -114
  269. package/src/SVGLoader.ts +0 -511
  270. package/src/UndoRedoHistory.test.ts +0 -33
  271. package/src/UndoRedoHistory.ts +0 -102
  272. package/src/Viewport.ts +0 -319
  273. package/src/bundle/bundled.ts +0 -7
  274. package/src/commands/Command.ts +0 -45
  275. package/src/commands/Duplicate.ts +0 -48
  276. package/src/commands/Erase.ts +0 -74
  277. package/src/commands/SerializableCommand.ts +0 -49
  278. package/src/commands/UnresolvedCommand.ts +0 -37
  279. package/src/commands/invertCommand.ts +0 -51
  280. package/src/commands/lib.ts +0 -16
  281. package/src/commands/localization.ts +0 -47
  282. package/src/commands/uniteCommands.test.ts +0 -23
  283. package/src/commands/uniteCommands.ts +0 -135
  284. package/src/components/AbstractComponent.transformBy.test.ts +0 -22
  285. package/src/components/AbstractComponent.ts +0 -364
  286. package/src/components/ImageBackground.test.ts +0 -35
  287. package/src/components/ImageBackground.ts +0 -176
  288. package/src/components/ImageComponent.ts +0 -171
  289. package/src/components/RestylableComponent.ts +0 -142
  290. package/src/components/SVGGlobalAttributesObject.ts +0 -81
  291. package/src/components/Stroke.test.ts +0 -139
  292. package/src/components/Stroke.ts +0 -245
  293. package/src/components/TextComponent.test.ts +0 -99
  294. package/src/components/TextComponent.ts +0 -315
  295. package/src/components/UnknownSVGObject.test.ts +0 -10
  296. package/src/components/UnknownSVGObject.ts +0 -60
  297. package/src/components/builders/ArrowBuilder.ts +0 -107
  298. package/src/components/builders/FreehandLineBuilder.ts +0 -212
  299. package/src/components/builders/LineBuilder.ts +0 -77
  300. package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
  301. package/src/components/builders/RectangleBuilder.ts +0 -74
  302. package/src/components/builders/types.ts +0 -15
  303. package/src/components/lib.ts +0 -25
  304. package/src/components/localization.ts +0 -22
  305. package/src/components/util/StrokeSmoother.ts +0 -293
  306. package/src/components/util/describeComponentList.ts +0 -18
  307. package/src/lib.ts +0 -37
  308. package/src/localization.ts +0 -34
  309. package/src/localizations/de.ts +0 -98
  310. package/src/localizations/en.ts +0 -8
  311. package/src/localizations/es.ts +0 -74
  312. package/src/localizations/getLocalizationTable.test.ts +0 -27
  313. package/src/localizations/getLocalizationTable.ts +0 -55
  314. package/src/math/LineSegment2.test.ts +0 -99
  315. package/src/math/LineSegment2.ts +0 -160
  316. package/src/math/Mat33.test.ts +0 -244
  317. package/src/math/Mat33.ts +0 -437
  318. package/src/math/Path.fromString.test.ts +0 -223
  319. package/src/math/Path.test.ts +0 -198
  320. package/src/math/Path.toString.test.ts +0 -77
  321. package/src/math/Path.ts +0 -790
  322. package/src/math/Rect2.test.ts +0 -204
  323. package/src/math/Rect2.ts +0 -315
  324. package/src/math/Triangle.ts +0 -29
  325. package/src/math/Vec2.test.ts +0 -30
  326. package/src/math/Vec2.ts +0 -18
  327. package/src/math/Vec3.test.ts +0 -44
  328. package/src/math/Vec3.ts +0 -218
  329. package/src/math/lib.ts +0 -15
  330. package/src/math/rounding.test.ts +0 -65
  331. package/src/math/rounding.ts +0 -156
  332. package/src/rendering/Display.ts +0 -249
  333. package/src/rendering/RenderingStyle.test.ts +0 -68
  334. package/src/rendering/RenderingStyle.ts +0 -55
  335. package/src/rendering/TextRenderingStyle.ts +0 -45
  336. package/src/rendering/caching/CacheRecord.test.ts +0 -49
  337. package/src/rendering/caching/CacheRecord.ts +0 -77
  338. package/src/rendering/caching/CacheRecordManager.ts +0 -71
  339. package/src/rendering/caching/RenderingCache.test.ts +0 -44
  340. package/src/rendering/caching/RenderingCache.ts +0 -66
  341. package/src/rendering/caching/RenderingCacheNode.ts +0 -405
  342. package/src/rendering/caching/testUtils.ts +0 -35
  343. package/src/rendering/caching/types.ts +0 -34
  344. package/src/rendering/lib.ts +0 -6
  345. package/src/rendering/localization.ts +0 -20
  346. package/src/rendering/renderers/AbstractRenderer.ts +0 -222
  347. package/src/rendering/renderers/CanvasRenderer.ts +0 -296
  348. package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
  349. package/src/rendering/renderers/DummyRenderer.ts +0 -136
  350. package/src/rendering/renderers/SVGRenderer.ts +0 -354
  351. package/src/rendering/renderers/TextOnlyRenderer.ts +0 -70
  352. package/src/styles.js +0 -7
  353. package/src/testing/beforeEachFile.ts +0 -8
  354. package/src/testing/createEditor.ts +0 -11
  355. package/src/testing/global.d.ts +0 -17
  356. package/src/testing/lib.ts +0 -3
  357. package/src/testing/loadExpectExtensions.ts +0 -25
  358. package/src/testing/sendPenEvent.ts +0 -31
  359. package/src/testing/sendTouchEvent.ts +0 -78
  360. package/src/toolbar/HTMLToolbar.ts +0 -492
  361. package/src/toolbar/IconProvider.ts +0 -736
  362. package/src/toolbar/lib.ts +0 -4
  363. package/src/toolbar/localization.ts +0 -106
  364. package/src/toolbar/makeColorInput.ts +0 -145
  365. package/src/toolbar/toolbar.css +0 -213
  366. package/src/toolbar/types.ts +0 -5
  367. package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
  368. package/src/toolbar/widgets/BaseToolWidget.ts +0 -56
  369. package/src/toolbar/widgets/BaseWidget.ts +0 -377
  370. package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -167
  371. package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
  372. package/src/toolbar/widgets/HandToolWidget.ts +0 -250
  373. package/src/toolbar/widgets/InsertImageWidget.css +0 -44
  374. package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
  375. package/src/toolbar/widgets/OverflowWidget.css +0 -27
  376. package/src/toolbar/widgets/OverflowWidget.ts +0 -92
  377. package/src/toolbar/widgets/PenToolWidget.ts +0 -288
  378. package/src/toolbar/widgets/SelectionToolWidget.ts +0 -190
  379. package/src/toolbar/widgets/TextToolWidget.ts +0 -145
  380. package/src/toolbar/widgets/lib.ts +0 -13
  381. package/src/tools/BaseTool.ts +0 -76
  382. package/src/tools/Eraser.test.ts +0 -103
  383. package/src/tools/Eraser.ts +0 -139
  384. package/src/tools/FindTool.css +0 -7
  385. package/src/tools/FindTool.ts +0 -152
  386. package/src/tools/PanZoom.test.ts +0 -310
  387. package/src/tools/PanZoom.ts +0 -520
  388. package/src/tools/PasteHandler.ts +0 -95
  389. package/src/tools/Pen.test.ts +0 -194
  390. package/src/tools/Pen.ts +0 -226
  391. package/src/tools/PipetteTool.ts +0 -55
  392. package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -28
  393. package/src/tools/SelectionTool/Selection.ts +0 -607
  394. package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
  395. package/src/tools/SelectionTool/SelectionTool.css +0 -23
  396. package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
  397. package/src/tools/SelectionTool/SelectionTool.ts +0 -480
  398. package/src/tools/SelectionTool/TransformMode.ts +0 -114
  399. package/src/tools/SelectionTool/types.ts +0 -11
  400. package/src/tools/TextTool.ts +0 -326
  401. package/src/tools/ToolController.ts +0 -178
  402. package/src/tools/ToolEnabledGroup.ts +0 -14
  403. package/src/tools/ToolSwitcherShortcut.ts +0 -39
  404. package/src/tools/ToolbarShortcutHandler.ts +0 -34
  405. package/src/tools/UndoRedoShortcut.test.ts +0 -56
  406. package/src/tools/UndoRedoShortcut.ts +0 -25
  407. package/src/tools/lib.ts +0 -21
  408. package/src/tools/localization.ts +0 -66
  409. package/src/types.ts +0 -234
  410. package/src/util/assertions.ts +0 -55
  411. package/src/util/fileToBase64.ts +0 -18
  412. package/src/util/untilNextAnimationFrame.ts +0 -9
  413. package/src/util/waitForTimeout.ts +0 -9
@@ -1,94 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { defaultEditorLocalization } from '../src/localization';
4
- // Adds markdown formatting to format text like code.
5
- const codeFormat = (text) => {
6
- let maxConsecutiveBackticks = 0;
7
- // Find the longest number of consecutive backticks — we need to have more
8
- // than that for the delimiters.
9
- const backtickRuns = text.matchAll(/[`]+/g);
10
- for (const backticks of backtickRuns) {
11
- if (backticks.length > maxConsecutiveBackticks) {
12
- maxConsecutiveBackticks = backticks.length;
13
- }
14
- }
15
- let codeStartEnd = '';
16
- for (let i = 0; i < maxConsecutiveBackticks + 1; i++) {
17
- codeStartEnd += '`';
18
- }
19
- // If the text already starts with a `, add a space to prevent the
20
- // markdown parser from treating it as part of the delimiter.
21
- if (text.startsWith('`')) {
22
- text = ' ' + text;
23
- }
24
- if (text.endsWith('`')) {
25
- text = text + ' ';
26
- }
27
- return `${codeStartEnd}${text}${codeStartEnd}`;
28
- };
29
- const collapseSpaces = (text) => text.replace(/\s+/g, ' ');
30
- const generateTranslationTemplate = () => {
31
- const bodyContentLines = [];
32
- const addInput = (type, id, attrs, required = false) => {
33
- const lines = [];
34
- lines.push(` - type: ${type}`);
35
- lines.push(` id: ${id}`);
36
- lines.push(' attributes:');
37
- for (const key in attrs) {
38
- const value = `${attrs[key]}`;
39
- const escapedValue = value.replace(/[\\]/g, '\\\\').replace(/"/g, '\\"');
40
- lines.push(` ${key}: "${escapedValue}"`);
41
- }
42
- lines.push(' validations:');
43
- lines.push(` required: ${required}`);
44
- bodyContentLines.push(...lines);
45
- };
46
- const addLabel = (text) => {
47
- bodyContentLines.push(' - type: markdown');
48
- bodyContentLines.push(' attributes:');
49
- bodyContentLines.push(' value: |');
50
- bodyContentLines.push(' ' + text);
51
- };
52
- addLabel(collapseSpaces(`
53
- Thank you for taking the time to translate \`js-draw\`! If you don't have time to translate
54
- all of the strings below, feel free to submit an incomplete translation and edit it later.
55
- Use this template to update an existing translation or to create a new translation.
56
- `));
57
- addLabel(collapseSpaces(`
58
- (Optional) If you would like to submit a pull request that applies this translation,
59
- note that existing translations are present in
60
- [src/localizations/](https://github.com/personalizedrefrigerator/js-draw/tree/main/src/localizations).
61
- `));
62
- addInput('input', 'language-name', {
63
- label: 'Language',
64
- description: 'The name of the language to translate to in English (e.g. Spanish)',
65
- }, true);
66
- for (const key in defaultEditorLocalization) {
67
- const englishTranslation = `${defaultEditorLocalization[key]}`;
68
- addInput('input', `translation-${key}`, {
69
- label: `${key}`,
70
- description: `Translate ${codeFormat(englishTranslation)}.`,
71
- placeholder: englishTranslation,
72
- });
73
- }
74
- addInput('textarea', 'additional-comments', {
75
- label: 'Additional information',
76
- placeholder: 'Any additional information/comments on the translation can go here.',
77
- });
78
- return `name: Translation
79
- # This template is auto-generated by build_tools/buildTranslationTemplate.ts
80
- # Do not modify it directly.
81
- description: Translate the editor to a new language!
82
- title: "[Translation]: <language>"
83
- labels: [localization]
84
- assignees: []
85
- body:
86
- ${bodyContentLines.join('\n')}`;
87
- };
88
- const template = generateTranslationTemplate();
89
- // According to https://stackoverflow.com/a/13650454, fs should
90
- // be able to handle forward and back slashes (both) on Windows (so extra
91
- // path logic shouldn't be needed here.)
92
- const rootDir = path.dirname(__dirname);
93
- const translationTempaltePath = path.join(rootDir, '.github/ISSUE_TEMPLATE/translation.yml');
94
- fs.writeFileSync(translationTempaltePath, template);
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { dirname } from 'path';
2
- import BundledFile from './BundledFile';
3
- const rootDir = dirname(__dirname);
4
- const mainBundle = new BundledFile('jsdraw', `${rootDir}/src/bundle/bundled.ts`, `${rootDir}/dist/bundle.js`);
5
- void mainBundle.build();
@@ -1,60 +0,0 @@
1
- export default class Color4 {
2
- /** Red component. Should be in the range [0, 1]. */
3
- readonly r: number;
4
- /** Green component. `g` ∈ [0, 1] */
5
- readonly g: number;
6
- /** Blue component. `b` ∈ [0, 1] */
7
- readonly b: number;
8
- /** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
9
- readonly a: number;
10
- private constructor();
11
- /**
12
- * Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
13
- *
14
- * Each component should be in the range [0, 1].
15
- */
16
- static ofRGB(red: number, green: number, blue: number): Color4;
17
- static ofRGBA(red: number, green: number, blue: number, alpha: number): Color4;
18
- static fromHex(hexString: string): Color4;
19
- /** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
20
- static fromString(text: string): Color4;
21
- /** @returns true if `this` and `other` are approximately equal. */
22
- eq(other: Color4 | null | undefined): boolean;
23
- /**
24
- * If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
25
- * in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
26
- *
27
- * @returns a color `fractionTo` of the way from this color to `other`.
28
- *
29
- * @example
30
- * ```ts
31
- * Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
32
- * ```
33
- */
34
- mix(other: Color4, fractionTo: number): Color4;
35
- /**
36
- * @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
37
- */
38
- static average(colors: Color4[]): Color4;
39
- private hexString;
40
- /**
41
- * @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
42
- *
43
- * @example
44
- * ```
45
- * Color4.red.toHexString(); // -> #ff0000ff
46
- * ```
47
- */
48
- toHexString(): string;
49
- toString(): string;
50
- static transparent: Color4;
51
- static red: Color4;
52
- static green: Color4;
53
- static blue: Color4;
54
- static purple: Color4;
55
- static yellow: Color4;
56
- static clay: Color4;
57
- static black: Color4;
58
- static gray: Color4;
59
- static white: Color4;
60
- }
@@ -1,192 +0,0 @@
1
- export default class Color4 {
2
- constructor(
3
- /** Red component. Should be in the range [0, 1]. */
4
- r,
5
- /** Green component. `g` ∈ [0, 1] */
6
- g,
7
- /** Blue component. `b` ∈ [0, 1] */
8
- b,
9
- /** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
10
- a) {
11
- this.r = r;
12
- this.g = g;
13
- this.b = b;
14
- this.a = a;
15
- this.hexString = null;
16
- }
17
- /**
18
- * Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
19
- *
20
- * Each component should be in the range [0, 1].
21
- */
22
- static ofRGB(red, green, blue) {
23
- return Color4.ofRGBA(red, green, blue, 1.0);
24
- }
25
- static ofRGBA(red, green, blue, alpha) {
26
- red = Math.max(0, Math.min(red, 1));
27
- green = Math.max(0, Math.min(green, 1));
28
- blue = Math.max(0, Math.min(blue, 1));
29
- alpha = Math.max(0, Math.min(alpha, 1));
30
- return new Color4(red, green, blue, alpha);
31
- }
32
- static fromHex(hexString) {
33
- var _a;
34
- // Remove starting '#' (if present)
35
- hexString = ((_a = hexString.match(/^[#]?(.*)$/)) !== null && _a !== void 0 ? _a : [])[1];
36
- hexString = hexString.toUpperCase();
37
- if (!hexString.match(/^[0-9A-F]+$/)) {
38
- throw new Error(`${hexString} is not in a valid format.`);
39
- }
40
- // RGBA or RGB
41
- if (hexString.length === 3 || hexString.length === 4) {
42
- // Each character is a component
43
- const components = hexString.split('');
44
- // Convert to RRGGBBAA or RRGGBB format
45
- hexString = components.map(component => `${component}0`).join('');
46
- }
47
- if (hexString.length === 6) {
48
- // Alpha component
49
- hexString += 'FF';
50
- }
51
- const components = [];
52
- for (let i = 2; i <= hexString.length; i += 2) {
53
- const chunk = hexString.substring(i - 2, i);
54
- components.push(parseInt(chunk, 16) / 255);
55
- }
56
- if (components.length !== 4) {
57
- throw new Error(`Unable to parse ${hexString}: Wrong number of components.`);
58
- }
59
- return Color4.ofRGBA(components[0], components[1], components[2], components[3]);
60
- }
61
- /** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
62
- static fromString(text) {
63
- if (text.startsWith('#')) {
64
- return Color4.fromHex(text);
65
- }
66
- if (text === 'none' || text === 'transparent') {
67
- return Color4.transparent;
68
- }
69
- // rgba?: Match both rgb and rgba strings.
70
- // ([,0-9.]+): Match any string of only numeric, '.' and ',' characters.
71
- const rgbRegex = /^rgba?\(([,0-9.]+)\)$/i;
72
- const rgbMatch = text.replace(/\s*/g, '').match(rgbRegex);
73
- if (rgbMatch) {
74
- const componentsListStr = rgbMatch[1];
75
- const componentsList = JSON.parse(`[ ${componentsListStr} ]`);
76
- if (componentsList.length === 3) {
77
- return Color4.ofRGB(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255);
78
- }
79
- else if (componentsList.length === 4) {
80
- return Color4.ofRGBA(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255, componentsList[3]);
81
- }
82
- else {
83
- throw new Error(`RGB string, ${text}, has wrong number of components: ${componentsList.length}`);
84
- }
85
- }
86
- // Otherwise, try to use an HTMLCanvasElement to determine the color.
87
- // Note: We may be unable to create an HTMLCanvasElement if running as a unit test.
88
- const canvas = document.createElement('canvas');
89
- canvas.width = 1;
90
- canvas.height = 1;
91
- const ctx = canvas.getContext('2d');
92
- ctx.fillStyle = text;
93
- ctx.fillRect(0, 0, 1, 1);
94
- const data = ctx.getImageData(0, 0, 1, 1);
95
- const red = data.data[0] / 255;
96
- const green = data.data[1] / 255;
97
- const blue = data.data[2] / 255;
98
- const alpha = data.data[3] / 255;
99
- return Color4.ofRGBA(red, green, blue, alpha);
100
- }
101
- /** @returns true if `this` and `other` are approximately equal. */
102
- eq(other) {
103
- if (other == null) {
104
- return false;
105
- }
106
- // If both completely transparent,
107
- if (this.a === 0 && other.a === 0) {
108
- return true;
109
- }
110
- return this.toHexString() === other.toHexString();
111
- }
112
- /**
113
- * If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
114
- * in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
115
- *
116
- * @returns a color `fractionTo` of the way from this color to `other`.
117
- *
118
- * @example
119
- * ```ts
120
- * Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
121
- * ```
122
- */
123
- mix(other, fractionTo) {
124
- fractionTo = Math.min(Math.max(fractionTo, 0), 1);
125
- const fractionOfThis = 1 - fractionTo;
126
- return new Color4(this.r * fractionOfThis + other.r * fractionTo, this.g * fractionOfThis + other.g * fractionTo, this.b * fractionOfThis + other.b * fractionTo, this.a * fractionOfThis + other.a * fractionTo);
127
- }
128
- /**
129
- * @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
130
- */
131
- static average(colors) {
132
- let averageA = 0;
133
- let averageR = 0;
134
- let averageG = 0;
135
- let averageB = 0;
136
- for (const color of colors) {
137
- averageA += color.a;
138
- averageR += color.r;
139
- averageG += color.g;
140
- averageB += color.b;
141
- }
142
- if (colors.length > 0) {
143
- averageA /= colors.length;
144
- averageR /= colors.length;
145
- averageG /= colors.length;
146
- averageB /= colors.length;
147
- }
148
- return new Color4(averageR, averageG, averageB, averageA);
149
- }
150
- /**
151
- * @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
152
- *
153
- * @example
154
- * ```
155
- * Color4.red.toHexString(); // -> #ff0000ff
156
- * ```
157
- */
158
- toHexString() {
159
- if (this.hexString) {
160
- return this.hexString;
161
- }
162
- const componentToHex = (component) => {
163
- const res = Math.round(255 * component).toString(16);
164
- if (res.length === 1) {
165
- return `0${res}`;
166
- }
167
- return res;
168
- };
169
- const alpha = componentToHex(this.a);
170
- const red = componentToHex(this.r);
171
- const green = componentToHex(this.g);
172
- const blue = componentToHex(this.b);
173
- if (alpha === 'ff') {
174
- return `#${red}${green}${blue}`;
175
- }
176
- this.hexString = `#${red}${green}${blue}${alpha}`;
177
- return this.hexString;
178
- }
179
- toString() {
180
- return this.toHexString();
181
- }
182
- }
183
- Color4.transparent = Color4.ofRGBA(0, 0, 0, 0);
184
- Color4.red = Color4.ofRGB(1.0, 0.0, 0.0);
185
- Color4.green = Color4.ofRGB(0.0, 1.0, 0.0);
186
- Color4.blue = Color4.ofRGB(0.0, 0.0, 1.0);
187
- Color4.purple = Color4.ofRGB(0.5, 0.2, 0.5);
188
- Color4.yellow = Color4.ofRGB(1, 1, 0.1);
189
- Color4.clay = Color4.ofRGB(0.8, 0.4, 0.2);
190
- Color4.black = Color4.ofRGB(0, 0, 0);
191
- Color4.gray = Color4.ofRGB(0.5, 0.5, 0.5);
192
- Color4.white = Color4.ofRGB(1, 1, 1);
@@ -1,308 +0,0 @@
1
- import EditorImage from './EditorImage';
2
- import ToolController from './tools/ToolController';
3
- import { InputEvtType, EditorNotifier, ImageLoader } from './types';
4
- import Command from './commands/Command';
5
- import UndoRedoHistory from './UndoRedoHistory';
6
- import Viewport from './Viewport';
7
- import { Point2 } from './math/Vec2';
8
- import HTMLToolbar from './toolbar/HTMLToolbar';
9
- import { RenderablePathSpec } from './rendering/renderers/AbstractRenderer';
10
- import Display, { RenderingMode } from './rendering/Display';
11
- import Color4 from './Color4';
12
- import Pointer from './Pointer';
13
- import Rect2 from './math/Rect2';
14
- import { EditorLocalization } from './localization';
15
- import IconProvider from './toolbar/IconProvider';
16
- import AbstractComponent from './components/AbstractComponent';
17
- type HTMLPointerEventType = 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel';
18
- type HTMLPointerEventFilter = (eventName: HTMLPointerEventType, event: PointerEvent) => boolean;
19
- export interface EditorSettings {
20
- /** Defaults to `RenderingMode.CanvasRenderer` */
21
- renderingMode: RenderingMode;
22
- /** Uses a default English localization if a translation is not given. */
23
- localization: Partial<EditorLocalization>;
24
- /**
25
- * `true` if touchpad/mousewheel scrolling should scroll the editor instead of the document.
26
- * This does not include pinch-zoom events.
27
- * Defaults to true.
28
- */
29
- wheelEventsEnabled: boolean | 'only-if-focused';
30
- /** Minimum zoom fraction (e.g. 0.5 → 50% zoom). */
31
- minZoom: number;
32
- maxZoom: number;
33
- iconProvider: IconProvider;
34
- }
35
- /**
36
- * The main entrypoint for the full editor.
37
- *
38
- * @example
39
- * To create an editor with a toolbar,
40
- * ```
41
- * const editor = new Editor(document.body);
42
- *
43
- * const toolbar = editor.addToolbar();
44
- * toolbar.addActionButton('Save', () => {
45
- * const saveData = editor.toSVG().outerHTML;
46
- * // Do something with saveData...
47
- * });
48
- * ```
49
- *
50
- * See also
51
- * [`docs/example/example.ts`](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/example/example.ts#L15).
52
- */
53
- export declare class Editor {
54
- private container;
55
- private renderingRegion;
56
- /** Manages drawing surfaces/{@link lib!AbstractRenderer}s. */
57
- display: Display;
58
- /**
59
- * Handles undo/redo.
60
- *
61
- * @example
62
- * ```
63
- * const editor = new Editor(document.body);
64
- *
65
- * // Do something undoable.
66
- * // ...
67
- *
68
- * // Undo the last action
69
- * editor.history.undo();
70
- * ```
71
- */
72
- history: UndoRedoHistory;
73
- /**
74
- * Data structure for adding/removing/querying objects in the image.
75
- *
76
- * @example
77
- * ```
78
- * const editor = new Editor(document.body);
79
- *
80
- * // Create a path.
81
- * const stroke = new Stroke([
82
- * Path.fromString('M0,0 L30,30 z').toRenderable({ fill: Color4.black }),
83
- * ]);
84
- * const addElementCommand = editor.image.addElement(stroke);
85
- *
86
- * // Add the stroke to the editor
87
- * editor.dispatch(addElementCommand);
88
- * ```
89
- */
90
- readonly image: EditorImage;
91
- /**
92
- * Allows transforming the view and querying information about
93
- * what is currently visible.
94
- */
95
- readonly viewport: Viewport;
96
- /** @internal */
97
- readonly localization: EditorLocalization;
98
- /** {@link lib!EditorSettings.iconProvider} */
99
- readonly icons: IconProvider;
100
- /**
101
- * Controls the list of tools. See
102
- * [the custom tool example](https://github.com/personalizedrefrigerator/js-draw/tree/main/docs/example-custom-tools)
103
- * for more.
104
- */
105
- readonly toolController: ToolController;
106
- /**
107
- * Global event dispatcher/subscriber.
108
- */
109
- readonly notifier: EditorNotifier;
110
- private loadingWarning;
111
- private accessibilityAnnounceArea;
112
- private accessibilityControlArea;
113
- private eventListenerTargets;
114
- private settings;
115
- /**
116
- * @example
117
- * ```
118
- * const container = document.body;
119
- *
120
- * // Create an editor
121
- * const editor = new Editor(container, {
122
- * // 2e-10 and 1e12 are the default values for minimum/maximum zoom.
123
- * minZoom: 2e-10,
124
- * maxZoom: 1e12,
125
- * });
126
- *
127
- * // Add the default toolbar
128
- * const toolbar = editor.addToolbar();
129
- *
130
- * // Add a save button
131
- * toolbar.addActionButton({
132
- * label: 'Save'
133
- * icon: createSaveIcon(),
134
- * }, () => {
135
- * const saveData = editor.toSVG().outerHTML;
136
- * // Do something with saveData
137
- * });
138
- * ```
139
- */
140
- constructor(parent: HTMLElement, settings?: Partial<EditorSettings>);
141
- /**
142
- * @returns a reference to the editor's container.
143
- *
144
- * @example
145
- * ```
146
- * // Set the editor's height to 500px
147
- * editor.getRootElement().style.height = '500px';
148
- * ```
149
- */
150
- getRootElement(): HTMLElement;
151
- /** @param fractionLoaded - should be a number from 0 to 1, where 1 represents completely loaded. */
152
- showLoadingWarning(fractionLoaded: number): void;
153
- hideLoadingWarning(): void;
154
- private previousAccessibilityAnnouncement;
155
- /**
156
- * Announce `message` for screen readers. If `message` is the same as the previous
157
- * message, it is re-announced.
158
- */
159
- announceForAccessibility(message: string): void;
160
- /**
161
- * Creates a toolbar. If `defaultLayout` is true, default buttons are used.
162
- * @returns a reference to the toolbar.
163
- */
164
- addToolbar(defaultLayout?: boolean): HTMLToolbar;
165
- private registerListeners;
166
- private pointers;
167
- private getPointerList;
168
- /**
169
- * Dispatches a `PointerEvent` to the editor. The target element for `evt` must have the same top left
170
- * as the content of the editor.
171
- */
172
- handleHTMLPointerEvent(eventType: 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel', evt: PointerEvent): boolean;
173
- private isEventSink;
174
- private handlePaste;
175
- /**
176
- * Forward pointer events from `elem` to this editor. Such that right-click/right-click drag
177
- * events are also forwarded, `elem`'s contextmenu is disabled.
178
- *
179
- * @example
180
- * ```ts
181
- * const overlay = document.createElement('div');
182
- * editor.createHTMLOverlay(overlay);
183
- *
184
- * // Send all pointer events that don't have the control key pressed
185
- * // to the editor.
186
- * editor.handlePointerEventsFrom(overlay, (event) => {
187
- * if (event.ctrlKey) {
188
- * return false;
189
- * }
190
- * return true;
191
- * });
192
- * ```
193
- */
194
- handlePointerEventsFrom(elem: HTMLElement, filter?: HTMLPointerEventFilter): void;
195
- /** Adds event listners for keypresses to `elem` and forwards those events to the editor. */
196
- handleKeyEventsFrom(elem: HTMLElement): void;
197
- /** `apply` a command. `command` will be announced for accessibility. */
198
- dispatch(command: Command, addToHistory?: boolean): void | Promise<void>;
199
- /**
200
- * Dispatches a command without announcing it. By default, does not add to history.
201
- * Use this to show finalized commands that don't need to have `announceForAccessibility`
202
- * called.
203
- *
204
- * Prefer `command.apply(editor)` for incomplete commands. `dispatchNoAnnounce` may allow
205
- * clients to listen for the application of commands (e.g. `SerializableCommand`s so they can
206
- * be sent across the network), while `apply` does not.
207
- *
208
- * @example
209
- * ```
210
- * const addToHistory = false;
211
- * editor.dispatchNoAnnounce(editor.viewport.zoomTo(someRectangle), addToHistory);
212
- * ```
213
- */
214
- dispatchNoAnnounce(command: Command, addToHistory?: boolean): void | Promise<void>;
215
- /**
216
- * Apply a large transformation in chunks.
217
- * If `apply` is `false`, the commands are unapplied.
218
- * Triggers a re-render after each `updateChunkSize`-sized group of commands
219
- * has been applied.
220
- */
221
- asyncApplyOrUnapplyCommands(commands: Command[], apply: boolean, updateChunkSize: number): Promise<void>;
222
- asyncApplyCommands(commands: Command[], chunkSize: number): Promise<void>;
223
- asyncUnapplyCommands(commands: Command[], chunkSize: number, unapplyInReverseOrder?: boolean): Promise<void>;
224
- private announceUndoCallback;
225
- private announceRedoCallback;
226
- private nextRerenderListeners;
227
- private rerenderQueued;
228
- /**
229
- * Schedule a re-render for some time in the near future. Does not schedule an additional
230
- * re-render if a re-render is already queued.
231
- *
232
- * @returns a promise that resolves when re-rendering has completed.
233
- */
234
- queueRerender(): Promise<void>;
235
- isRerenderQueued(): boolean;
236
- /**
237
- * Re-renders the entire image.
238
- *
239
- * @see {@link Editor.queueRerender}
240
- */
241
- rerender(showImageBounds?: boolean): void;
242
- /**
243
- * Draws the given path onto the wet ink renderer. The given path will
244
- * be displayed on top of the main image.
245
- *
246
- * @see {@link Display.getWetInkRenderer} {@link Display.flatten}
247
- */
248
- drawWetInk(...path: RenderablePathSpec[]): void;
249
- /**
250
- * Clears the wet ink display.
251
- *
252
- * @see {@link Display.getWetInkRenderer}
253
- */
254
- clearWetInk(): void;
255
- /**
256
- * Focuses the region used for text input/key commands.
257
- */
258
- focus(): void;
259
- /**
260
- * Creates an element that will be positioned on top of the dry/wet ink
261
- * renderers.
262
- *
263
- * This is useful for displaying content on top of the rendered content
264
- * (e.g. a selection box).
265
- */
266
- createHTMLOverlay(overlay: HTMLElement): {
267
- remove: () => void;
268
- };
269
- addStyleSheet(content: string): HTMLStyleElement;
270
- sendKeyboardEvent(eventType: InputEvtType.KeyPressEvent | InputEvtType.KeyUpEvent, key: string, ctrlKey?: boolean, altKey?: boolean): void;
271
- /**
272
- * Dispatch a pen event to the currently selected tool.
273
- * Intended primarially for unit tests.
274
- *
275
- * @deprecated
276
- * @see {@link sendPenEvent} {@link sendTouchEvent}
277
- */
278
- sendPenEvent(eventType: InputEvtType.PointerDownEvt | InputEvtType.PointerMoveEvt | InputEvtType.PointerUpEvt, point: Point2, allPointers?: Pointer[]): void;
279
- addAndCenterComponents(components: AbstractComponent[], selectComponents?: boolean): Promise<void>;
280
- toDataURL(format?: 'image/png' | 'image/jpeg' | 'image/webp'): string;
281
- toSVG(): SVGElement;
282
- /**
283
- * Load editor data from an `ImageLoader` (e.g. an {@link SVGLoader}).
284
- *
285
- * @see loadFromSVG
286
- */
287
- loadFrom(loader: ImageLoader): Promise<void>;
288
- private getTopmostBackgroundComponent;
289
- /**
290
- * Set the background color of the image.
291
- */
292
- setBackgroundColor(color: Color4): Command;
293
- /**
294
- * @returns the average of the colors of all background components. Use this to get the current background
295
- * color.
296
- */
297
- estimateBackgroundColor(): Color4;
298
- getImportExportRect(): Rect2;
299
- setImportExportRect(imageRect: Rect2): Command;
300
- /**
301
- * Alias for loadFrom(SVGLoader.fromString).
302
- *
303
- * This is particularly useful when accessing a bundled version of the editor,
304
- * where `SVGLoader.fromString` is unavailable.
305
- */
306
- loadFromSVG(svgData: string, sanitize?: boolean): Promise<void>;
307
- }
308
- export default Editor;