js-draw 0.18.2 → 0.20.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 (269) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +10 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/bundledStyles.js +1 -0
  5. package/dist/cjs/src/Color4.d.ts +8 -0
  6. package/dist/cjs/src/Color4.js +67 -0
  7. package/dist/cjs/src/Editor.d.ts +2 -2
  8. package/dist/cjs/src/Editor.js +7 -7
  9. package/dist/cjs/src/SVGLoader.js +77 -12
  10. package/dist/cjs/src/Viewport.d.ts +2 -0
  11. package/dist/cjs/src/Viewport.js +6 -2
  12. package/dist/cjs/src/components/AbstractComponent.d.ts +2 -2
  13. package/dist/cjs/src/components/AbstractComponent.js +3 -3
  14. package/dist/cjs/src/components/{ImageBackground.d.ts → BackgroundComponent.d.ts} +23 -3
  15. package/dist/cjs/src/components/BackgroundComponent.js +309 -0
  16. package/dist/cjs/src/components/RestylableComponent.d.ts +21 -2
  17. package/dist/cjs/src/components/Stroke.d.ts +35 -0
  18. package/dist/cjs/src/components/Stroke.js +37 -3
  19. package/dist/cjs/src/components/TextComponent.d.ts +27 -17
  20. package/dist/cjs/src/components/TextComponent.js +23 -1
  21. package/dist/cjs/src/components/lib.d.ts +4 -3
  22. package/dist/cjs/src/components/lib.js +2 -2
  23. package/dist/cjs/src/components/util/StrokeSmoother.js +25 -15
  24. package/dist/cjs/src/lib.d.ts +30 -0
  25. package/dist/cjs/src/lib.js +30 -0
  26. package/dist/cjs/src/localizations/de.js +1 -1
  27. package/dist/cjs/src/localizations/es.js +1 -1
  28. package/dist/cjs/src/math/Path.js +1 -1
  29. package/dist/cjs/src/math/polynomial/QuadraticBezier.d.ts +28 -0
  30. package/dist/cjs/src/math/polynomial/QuadraticBezier.js +115 -0
  31. package/dist/cjs/src/math/polynomial/solveQuadratic.d.ts +6 -0
  32. package/dist/cjs/src/math/polynomial/solveQuadratic.js +36 -0
  33. package/dist/cjs/src/rendering/RenderingStyle.d.ts +4 -4
  34. package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +10 -10
  35. package/dist/cjs/src/rendering/lib.d.ts +2 -0
  36. package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +2 -2
  37. package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +2 -2
  38. package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +5 -3
  39. package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +2 -2
  40. package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +2 -2
  41. package/dist/cjs/src/rendering/renderers/SVGRenderer.js +15 -6
  42. package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +2 -2
  43. package/dist/cjs/src/toolbar/IconProvider.d.ts +2 -2
  44. package/dist/cjs/src/toolbar/localization.d.ts +2 -1
  45. package/dist/cjs/src/toolbar/localization.js +3 -2
  46. package/dist/cjs/src/toolbar/widgets/BaseWidget.js +1 -1
  47. package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +5 -0
  48. package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +77 -2
  49. package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +1 -1
  50. package/dist/cjs/src/tools/FindTool.js +1 -1
  51. package/dist/cjs/src/tools/SoundUITool.d.ts +24 -0
  52. package/dist/cjs/src/tools/SoundUITool.js +164 -0
  53. package/dist/cjs/src/tools/TextTool.d.ts +2 -2
  54. package/dist/cjs/src/tools/ToolController.js +6 -1
  55. package/dist/cjs/src/tools/lib.d.ts +1 -0
  56. package/dist/cjs/src/tools/lib.js +3 -1
  57. package/dist/cjs/src/tools/localization.d.ts +3 -0
  58. package/dist/cjs/src/tools/localization.js +3 -0
  59. package/dist/mjs/src/Color4.d.ts +8 -0
  60. package/dist/mjs/src/Color4.mjs +64 -0
  61. package/dist/mjs/src/Editor.d.ts +2 -2
  62. package/dist/mjs/src/Editor.mjs +6 -6
  63. package/dist/mjs/src/SVGLoader.mjs +76 -11
  64. package/dist/mjs/src/Viewport.d.ts +2 -0
  65. package/dist/mjs/src/Viewport.mjs +6 -2
  66. package/dist/mjs/src/components/AbstractComponent.d.ts +2 -2
  67. package/dist/mjs/src/components/AbstractComponent.mjs +3 -3
  68. package/dist/mjs/src/components/{ImageBackground.d.ts → BackgroundComponent.d.ts} +23 -3
  69. package/dist/mjs/src/components/BackgroundComponent.mjs +279 -0
  70. package/dist/mjs/src/components/RestylableComponent.d.ts +21 -2
  71. package/dist/mjs/src/components/Stroke.d.ts +35 -0
  72. package/dist/mjs/src/components/Stroke.mjs +37 -3
  73. package/dist/mjs/src/components/TextComponent.d.ts +27 -17
  74. package/dist/mjs/src/components/TextComponent.mjs +23 -1
  75. package/dist/mjs/src/components/lib.d.ts +4 -3
  76. package/dist/mjs/src/components/lib.mjs +2 -2
  77. package/dist/mjs/src/components/util/StrokeSmoother.mjs +25 -15
  78. package/dist/mjs/src/lib.d.ts +30 -0
  79. package/dist/mjs/src/lib.mjs +30 -0
  80. package/dist/mjs/src/localizations/de.mjs +1 -1
  81. package/dist/mjs/src/localizations/es.mjs +1 -1
  82. package/dist/mjs/src/math/Path.mjs +1 -1
  83. package/dist/mjs/src/math/polynomial/QuadraticBezier.d.ts +28 -0
  84. package/dist/mjs/src/math/polynomial/QuadraticBezier.mjs +109 -0
  85. package/dist/mjs/src/math/polynomial/solveQuadratic.d.ts +6 -0
  86. package/dist/mjs/src/math/polynomial/solveQuadratic.mjs +34 -0
  87. package/dist/mjs/src/rendering/RenderingStyle.d.ts +4 -4
  88. package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +10 -10
  89. package/dist/mjs/src/rendering/lib.d.ts +2 -0
  90. package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +2 -2
  91. package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +2 -2
  92. package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +5 -3
  93. package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +2 -2
  94. package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +2 -2
  95. package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +15 -6
  96. package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +2 -2
  97. package/dist/mjs/src/toolbar/IconProvider.d.ts +2 -2
  98. package/dist/mjs/src/toolbar/localization.d.ts +2 -1
  99. package/dist/mjs/src/toolbar/localization.mjs +3 -2
  100. package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +1 -1
  101. package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +5 -0
  102. package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +54 -2
  103. package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +1 -1
  104. package/dist/mjs/src/tools/FindTool.mjs +1 -1
  105. package/dist/mjs/src/tools/SoundUITool.d.ts +24 -0
  106. package/dist/mjs/src/tools/SoundUITool.mjs +158 -0
  107. package/dist/mjs/src/tools/TextTool.d.ts +2 -2
  108. package/dist/mjs/src/tools/ToolController.mjs +6 -1
  109. package/dist/mjs/src/tools/lib.d.ts +1 -0
  110. package/dist/mjs/src/tools/lib.mjs +1 -0
  111. package/dist/mjs/src/tools/localization.d.ts +3 -0
  112. package/dist/mjs/src/tools/localization.mjs +3 -0
  113. package/jest.config.js +1 -1
  114. package/package.json +19 -17
  115. package/src/Editor.css +2 -2
  116. package/src/tools/SoundUITool.css +15 -0
  117. package/src/tools/tools.css +4 -0
  118. package/dist/cjs/src/components/ImageBackground.js +0 -146
  119. package/dist/mjs/src/components/ImageBackground.mjs +0 -139
  120. package/src/Color4.test.ts +0 -40
  121. package/src/Color4.ts +0 -236
  122. package/src/Editor.loadFrom.test.ts +0 -24
  123. package/src/Editor.toSVG.test.ts +0 -111
  124. package/src/Editor.ts +0 -1122
  125. package/src/EditorImage.test.ts +0 -120
  126. package/src/EditorImage.ts +0 -603
  127. package/src/EventDispatcher.test.ts +0 -123
  128. package/src/EventDispatcher.ts +0 -71
  129. package/src/Pointer.ts +0 -127
  130. package/src/SVGLoader.test.ts +0 -114
  131. package/src/SVGLoader.ts +0 -511
  132. package/src/UndoRedoHistory.test.ts +0 -33
  133. package/src/UndoRedoHistory.ts +0 -102
  134. package/src/Viewport.ts +0 -319
  135. package/src/bundle/bundled.ts +0 -7
  136. package/src/commands/Command.ts +0 -45
  137. package/src/commands/Duplicate.ts +0 -48
  138. package/src/commands/Erase.ts +0 -74
  139. package/src/commands/SerializableCommand.ts +0 -49
  140. package/src/commands/UnresolvedCommand.ts +0 -37
  141. package/src/commands/invertCommand.ts +0 -51
  142. package/src/commands/lib.ts +0 -16
  143. package/src/commands/localization.ts +0 -47
  144. package/src/commands/uniteCommands.test.ts +0 -23
  145. package/src/commands/uniteCommands.ts +0 -135
  146. package/src/components/AbstractComponent.transformBy.test.ts +0 -22
  147. package/src/components/AbstractComponent.ts +0 -364
  148. package/src/components/ImageBackground.test.ts +0 -35
  149. package/src/components/ImageBackground.ts +0 -176
  150. package/src/components/ImageComponent.ts +0 -171
  151. package/src/components/RestylableComponent.ts +0 -142
  152. package/src/components/SVGGlobalAttributesObject.ts +0 -81
  153. package/src/components/Stroke.test.ts +0 -139
  154. package/src/components/Stroke.ts +0 -245
  155. package/src/components/TextComponent.test.ts +0 -99
  156. package/src/components/TextComponent.ts +0 -315
  157. package/src/components/UnknownSVGObject.test.ts +0 -10
  158. package/src/components/UnknownSVGObject.ts +0 -60
  159. package/src/components/builders/ArrowBuilder.ts +0 -107
  160. package/src/components/builders/FreehandLineBuilder.ts +0 -212
  161. package/src/components/builders/LineBuilder.ts +0 -77
  162. package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
  163. package/src/components/builders/RectangleBuilder.ts +0 -74
  164. package/src/components/builders/types.ts +0 -15
  165. package/src/components/lib.ts +0 -25
  166. package/src/components/localization.ts +0 -22
  167. package/src/components/util/StrokeSmoother.ts +0 -293
  168. package/src/components/util/describeComponentList.ts +0 -18
  169. package/src/lib.ts +0 -37
  170. package/src/localization.ts +0 -34
  171. package/src/localizations/de.ts +0 -98
  172. package/src/localizations/en.ts +0 -8
  173. package/src/localizations/es.ts +0 -74
  174. package/src/localizations/getLocalizationTable.test.ts +0 -27
  175. package/src/localizations/getLocalizationTable.ts +0 -55
  176. package/src/math/LineSegment2.test.ts +0 -99
  177. package/src/math/LineSegment2.ts +0 -160
  178. package/src/math/Mat33.test.ts +0 -244
  179. package/src/math/Mat33.ts +0 -437
  180. package/src/math/Path.fromString.test.ts +0 -223
  181. package/src/math/Path.test.ts +0 -198
  182. package/src/math/Path.toString.test.ts +0 -77
  183. package/src/math/Path.ts +0 -790
  184. package/src/math/Rect2.test.ts +0 -204
  185. package/src/math/Rect2.ts +0 -315
  186. package/src/math/Triangle.ts +0 -29
  187. package/src/math/Vec2.test.ts +0 -30
  188. package/src/math/Vec2.ts +0 -18
  189. package/src/math/Vec3.test.ts +0 -44
  190. package/src/math/Vec3.ts +0 -218
  191. package/src/math/lib.ts +0 -15
  192. package/src/math/rounding.test.ts +0 -65
  193. package/src/math/rounding.ts +0 -156
  194. package/src/rendering/Display.ts +0 -249
  195. package/src/rendering/RenderingStyle.test.ts +0 -68
  196. package/src/rendering/RenderingStyle.ts +0 -55
  197. package/src/rendering/TextRenderingStyle.ts +0 -45
  198. package/src/rendering/caching/CacheRecord.test.ts +0 -49
  199. package/src/rendering/caching/CacheRecord.ts +0 -77
  200. package/src/rendering/caching/CacheRecordManager.ts +0 -71
  201. package/src/rendering/caching/RenderingCache.test.ts +0 -44
  202. package/src/rendering/caching/RenderingCache.ts +0 -66
  203. package/src/rendering/caching/RenderingCacheNode.ts +0 -405
  204. package/src/rendering/caching/testUtils.ts +0 -35
  205. package/src/rendering/caching/types.ts +0 -34
  206. package/src/rendering/lib.ts +0 -6
  207. package/src/rendering/localization.ts +0 -20
  208. package/src/rendering/renderers/AbstractRenderer.ts +0 -222
  209. package/src/rendering/renderers/CanvasRenderer.ts +0 -296
  210. package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
  211. package/src/rendering/renderers/DummyRenderer.ts +0 -136
  212. package/src/rendering/renderers/SVGRenderer.ts +0 -354
  213. package/src/rendering/renderers/TextOnlyRenderer.ts +0 -70
  214. package/src/testing/beforeEachFile.ts +0 -8
  215. package/src/testing/createEditor.ts +0 -11
  216. package/src/testing/global.d.ts +0 -17
  217. package/src/testing/lib.ts +0 -3
  218. package/src/testing/loadExpectExtensions.ts +0 -25
  219. package/src/testing/sendPenEvent.ts +0 -31
  220. package/src/testing/sendTouchEvent.ts +0 -78
  221. package/src/toolbar/HTMLToolbar.ts +0 -492
  222. package/src/toolbar/IconProvider.ts +0 -736
  223. package/src/toolbar/lib.ts +0 -4
  224. package/src/toolbar/localization.ts +0 -106
  225. package/src/toolbar/makeColorInput.ts +0 -145
  226. package/src/toolbar/types.ts +0 -5
  227. package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
  228. package/src/toolbar/widgets/BaseToolWidget.ts +0 -56
  229. package/src/toolbar/widgets/BaseWidget.ts +0 -377
  230. package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -167
  231. package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
  232. package/src/toolbar/widgets/HandToolWidget.ts +0 -250
  233. package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
  234. package/src/toolbar/widgets/OverflowWidget.ts +0 -92
  235. package/src/toolbar/widgets/PenToolWidget.ts +0 -288
  236. package/src/toolbar/widgets/SelectionToolWidget.ts +0 -190
  237. package/src/toolbar/widgets/TextToolWidget.ts +0 -145
  238. package/src/toolbar/widgets/lib.ts +0 -13
  239. package/src/tools/BaseTool.ts +0 -76
  240. package/src/tools/Eraser.test.ts +0 -103
  241. package/src/tools/Eraser.ts +0 -139
  242. package/src/tools/FindTool.ts +0 -152
  243. package/src/tools/PanZoom.test.ts +0 -310
  244. package/src/tools/PanZoom.ts +0 -520
  245. package/src/tools/PasteHandler.ts +0 -95
  246. package/src/tools/Pen.test.ts +0 -194
  247. package/src/tools/Pen.ts +0 -226
  248. package/src/tools/PipetteTool.ts +0 -55
  249. package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -28
  250. package/src/tools/SelectionTool/Selection.ts +0 -607
  251. package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
  252. package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
  253. package/src/tools/SelectionTool/SelectionTool.ts +0 -480
  254. package/src/tools/SelectionTool/TransformMode.ts +0 -114
  255. package/src/tools/SelectionTool/types.ts +0 -11
  256. package/src/tools/TextTool.ts +0 -326
  257. package/src/tools/ToolController.ts +0 -178
  258. package/src/tools/ToolEnabledGroup.ts +0 -14
  259. package/src/tools/ToolSwitcherShortcut.ts +0 -39
  260. package/src/tools/ToolbarShortcutHandler.ts +0 -34
  261. package/src/tools/UndoRedoShortcut.test.ts +0 -56
  262. package/src/tools/UndoRedoShortcut.ts +0 -25
  263. package/src/tools/lib.ts +0 -21
  264. package/src/tools/localization.ts +0 -66
  265. package/src/types.ts +0 -234
  266. package/src/util/assertions.ts +0 -55
  267. package/src/util/fileToBase64.ts +0 -18
  268. package/src/util/untilNextAnimationFrame.ts +0 -9
  269. package/src/util/waitForTimeout.ts +0 -9
@@ -3,3 +3,5 @@ export { default as DummyRenderer } from './renderers/DummyRenderer';
3
3
  export { default as SVGRenderer } from './renderers/SVGRenderer';
4
4
  export { default as CanvasRenderer } from './renderers/CanvasRenderer';
5
5
  export { default as Display, RenderingMode } from './Display';
6
+ export { default as TextRenderingStyle } from './TextRenderingStyle';
7
+ export { default as RenderingStyle } from './RenderingStyle';
@@ -6,7 +6,7 @@ import Rect2 from '../../math/Rect2';
6
6
  import { Point2, Vec2 } from '../../math/Vec2';
7
7
  import Viewport from '../../Viewport';
8
8
  import RenderingStyle from '../RenderingStyle';
9
- import TextStyle from '../TextRenderingStyle';
9
+ import TextRenderingStyle from '../TextRenderingStyle';
10
10
  export interface RenderablePathSpec {
11
11
  startPoint: Point2;
12
12
  commands: PathCommand[];
@@ -33,7 +33,7 @@ export default abstract class AbstractRenderer {
33
33
  protected abstract moveTo(point: Point2): void;
34
34
  protected abstract traceCubicBezierCurve(p1: Point2, p2: Point2, p3: Point2): void;
35
35
  protected abstract traceQuadraticBezierCurve(controlPoint: Point2, endPoint: Point2): void;
36
- abstract drawText(text: string, transform: Mat33, style: TextStyle): void;
36
+ abstract drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
37
37
  abstract drawImage(image: RenderableImage): void;
38
38
  abstract isTooSmallToRender(rect: Rect2): boolean;
39
39
  setDraftMode(_draftMode: boolean): void;
@@ -4,7 +4,7 @@ import { Point2, Vec2 } from '../../math/Vec2';
4
4
  import Vec3 from '../../math/Vec3';
5
5
  import Viewport from '../../Viewport';
6
6
  import RenderingStyle from '../RenderingStyle';
7
- import TextStyle from '../TextRenderingStyle';
7
+ import TextRenderingStyle from '../TextRenderingStyle';
8
8
  import AbstractRenderer, { RenderableImage, RenderablePathSpec } from './AbstractRenderer';
9
9
  /**
10
10
  * Renders onto a `CanvasRenderingContext2D`.
@@ -53,7 +53,7 @@ export default class CanvasRenderer extends AbstractRenderer {
53
53
  protected traceCubicBezierCurve(p1: Point2, p2: Point2, p3: Point2): void;
54
54
  protected traceQuadraticBezierCurve(controlPoint: Vec3, endPoint: Vec3): void;
55
55
  drawPath(path: RenderablePathSpec): void;
56
- drawText(text: string, transform: Mat33, style: TextStyle): void;
56
+ drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
57
57
  drawImage(image: RenderableImage): void;
58
58
  private clipLevels;
59
59
  startObject(boundingBox: Rect2, clip?: boolean): void;
@@ -186,14 +186,16 @@ export default class CanvasRenderer extends AbstractRenderer {
186
186
  }
187
187
  }
188
188
  endObject() {
189
+ // Cache this.objectLevel — it may be decremented by super.endObject.
190
+ const objectLevel = this.objectLevel;
191
+ this.currentObjectBBox = null;
192
+ super.endObject();
189
193
  if (!this.ignoringObject && this.clipLevels.length > 0) {
190
- if (this.clipLevels[this.clipLevels.length - 1] === this.objectLevel) {
194
+ if (this.clipLevels[this.clipLevels.length - 1] === objectLevel) {
191
195
  this.ctx.restore();
192
196
  this.clipLevels.pop();
193
197
  }
194
198
  }
195
- this.currentObjectBBox = null;
196
- super.endObject();
197
199
  // If exiting an object with a too-small-to-draw bounding box,
198
200
  if (this.ignoreObjectsAboveLevel !== null && this.getNestingLevel() <= this.ignoreObjectsAboveLevel) {
199
201
  this.ignoreObjectsAboveLevel = null;
@@ -4,7 +4,7 @@ import { Point2, Vec2 } from '../../math/Vec2';
4
4
  import Vec3 from '../../math/Vec3';
5
5
  import Viewport from '../../Viewport';
6
6
  import RenderingStyle from '../RenderingStyle';
7
- import TextStyle from '../TextRenderingStyle';
7
+ import TextRenderingStyle from '../TextRenderingStyle';
8
8
  import AbstractRenderer, { RenderableImage } from './AbstractRenderer';
9
9
  export default class DummyRenderer extends AbstractRenderer {
10
10
  clearedCount: number;
@@ -25,7 +25,7 @@ export default class DummyRenderer extends AbstractRenderer {
25
25
  protected traceCubicBezierCurve(p1: Vec3, p2: Vec3, p3: Vec3): void;
26
26
  protected traceQuadraticBezierCurve(controlPoint: Vec3, endPoint: Vec3): void;
27
27
  drawPoints(..._points: Vec3[]): void;
28
- drawText(text: string, _transform: Mat33, _style: TextStyle): void;
28
+ drawText(text: string, _transform: Mat33, _style: TextRenderingStyle): void;
29
29
  drawImage(image: RenderableImage): void;
30
30
  startObject(boundingBox: Rect2, _clip: boolean): void;
31
31
  endObject(): void;
@@ -4,7 +4,7 @@ import Rect2 from '../../math/Rect2';
4
4
  import { Point2, Vec2 } from '../../math/Vec2';
5
5
  import Viewport from '../../Viewport';
6
6
  import RenderingStyle from '../RenderingStyle';
7
- import TextStyle from '../TextRenderingStyle';
7
+ import TextRenderingStyle from '../TextRenderingStyle';
8
8
  import AbstractRenderer, { RenderableImage, RenderablePathSpec } from './AbstractRenderer';
9
9
  export declare const renderedStylesheetId = "js-draw-style-sheet";
10
10
  /**
@@ -36,7 +36,7 @@ export default class SVGRenderer extends AbstractRenderer {
36
36
  private textContainer;
37
37
  private textContainerTransform;
38
38
  private textParentStyle;
39
- drawText(text: string, transform: Mat33, style: TextStyle): void;
39
+ drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
40
40
  drawImage(image: RenderableImage): void;
41
41
  startObject(boundingBox: Rect2): void;
42
42
  endObject(loaderData?: LoadSaveDataTable, elemClassNames?: string[]): void;
@@ -3,6 +3,7 @@ import Path from '../../math/Path.mjs';
3
3
  import { toRoundedString } from '../../math/rounding.mjs';
4
4
  import { Vec2 } from '../../math/Vec2.mjs';
5
5
  import { svgAttributesDataKey, svgStyleAttributesDataKey } from '../../SVGLoader.mjs';
6
+ import { stylesEqual } from '../RenderingStyle.mjs';
6
7
  import AbstractRenderer from './AbstractRenderer.mjs';
7
8
  export const renderedStylesheetId = 'js-draw-style-sheet';
8
9
  const svgNameSpace = 'http://www.w3.org/2000/svg';
@@ -108,11 +109,10 @@ export default class SVGRenderer extends AbstractRenderer {
108
109
  (_a = this.objectElems) === null || _a === void 0 ? void 0 : _a.push(pathElem);
109
110
  }
110
111
  drawPath(pathSpec) {
111
- var _a;
112
112
  const style = pathSpec.style;
113
113
  const path = Path.fromRenderable(pathSpec).transformedBy(this.getCanvasToScreenTransform());
114
114
  // Try to extend the previous path, if possible
115
- if (!style.fill.eq((_a = this.lastPathStyle) === null || _a === void 0 ? void 0 : _a.fill) || this.lastPathString.length === 0) {
115
+ if (this.lastPathString.length === 0 || !this.lastPathStyle || !stylesEqual(this.lastPathStyle, style)) {
116
116
  this.addPathToSVG();
117
117
  this.lastPathStyle = style;
118
118
  this.lastPathString = [];
@@ -226,7 +226,7 @@ export default class SVGRenderer extends AbstractRenderer {
226
226
  this.objectElems = [];
227
227
  }
228
228
  endObject(loaderData, elemClassNames) {
229
- var _a, _b;
229
+ var _a;
230
230
  super.endObject(loaderData);
231
231
  // Don't extend paths across objects
232
232
  this.addPathToSVG();
@@ -248,9 +248,18 @@ export default class SVGRenderer extends AbstractRenderer {
248
248
  }
249
249
  }
250
250
  // Add class names to the object, if given.
251
- if (elemClassNames) {
252
- for (const elem of (_b = this.objectElems) !== null && _b !== void 0 ? _b : []) {
253
- elem.classList.add(...elemClassNames);
251
+ if (elemClassNames && this.objectElems) {
252
+ if (this.objectElems.length === 1) {
253
+ this.objectElems[0].classList.add(...elemClassNames);
254
+ }
255
+ else {
256
+ const wrapper = document.createElementNS(svgNameSpace, 'g');
257
+ wrapper.classList.add(...elemClassNames);
258
+ for (const elem of this.objectElems) {
259
+ elem.remove();
260
+ wrapper.appendChild(elem);
261
+ }
262
+ this.elem.appendChild(wrapper);
254
263
  }
255
264
  }
256
265
  }
@@ -4,7 +4,7 @@ import Vec3 from '../../math/Vec3';
4
4
  import Viewport from '../../Viewport';
5
5
  import { TextRendererLocalization } from '../localization';
6
6
  import RenderingStyle from '../RenderingStyle';
7
- import TextStyle from '../TextRenderingStyle';
7
+ import TextRenderingStyle from '../TextRenderingStyle';
8
8
  import AbstractRenderer, { RenderableImage } from './AbstractRenderer';
9
9
  export default class TextOnlyRenderer extends AbstractRenderer {
10
10
  private localizationTable;
@@ -22,7 +22,7 @@ export default class TextOnlyRenderer extends AbstractRenderer {
22
22
  protected moveTo(_point: Vec3): void;
23
23
  protected traceCubicBezierCurve(_p1: Vec3, _p2: Vec3, _p3: Vec3): void;
24
24
  protected traceQuadraticBezierCurve(_controlPoint: Vec3, _endPoint: Vec3): void;
25
- drawText(text: string, _transform: Mat33, _style: TextStyle): void;
25
+ drawText(text: string, _transform: Mat33, _style: TextRenderingStyle): void;
26
26
  drawImage(image: RenderableImage): void;
27
27
  isTooSmallToRender(rect: Rect2): boolean;
28
28
  drawPoints(..._points: Vec3[]): void;
@@ -1,6 +1,6 @@
1
1
  import Color4 from '../Color4';
2
2
  import { ComponentBuilderFactory } from '../components/builders/types';
3
- import TextStyle from '../rendering/TextRenderingStyle';
3
+ import TextRenderingStyle from '../rendering/TextRenderingStyle';
4
4
  import Pen from '../tools/Pen';
5
5
  export type IconType = HTMLImageElement | SVGElement;
6
6
  /**
@@ -47,7 +47,7 @@ export default class IconProvider {
47
47
  makeZoomIcon(): IconType;
48
48
  makeRotationLockIcon(): IconType;
49
49
  makeInsertImageIcon(): IconType;
50
- makeTextIcon(textStyle: TextStyle): IconType;
50
+ makeTextIcon(textStyle: TextRenderingStyle): IconType;
51
51
  makePenIcon(strokeSize: number, color: string | Color4, rounded?: boolean): IconType;
52
52
  makeIconFromFactory(pen: Pen, factory: ComponentBuilderFactory): IconType;
53
53
  makePipetteIcon(color?: Color4): IconType;
@@ -14,7 +14,7 @@ export interface ToolbarLocalization {
14
14
  submit: string;
15
15
  freehandPen: string;
16
16
  pressureSensitiveFreehandPen: string;
17
- selectObjectType: string;
17
+ selectPenType: string;
18
18
  colorLabel: string;
19
19
  pen: string;
20
20
  eraser: string;
@@ -37,6 +37,7 @@ export interface ToolbarLocalization {
37
37
  backgroundColor: string;
38
38
  imageWidthOption: string;
39
39
  imageHeightOption: string;
40
+ useGridOption: string;
40
41
  toggleOverflow: string;
41
42
  errorImageHasZeroSize: string;
42
43
  dropdownShown: (toolName: string) => string;
@@ -20,14 +20,15 @@ export const defaultToolbarLocalization = {
20
20
  duplicateSelection: 'Duplicate selection',
21
21
  undo: 'Undo',
22
22
  redo: 'Redo',
23
- selectObjectType: 'Object type: ',
23
+ selectPenType: 'Pen type: ',
24
24
  pickColorFromScreen: 'Pick color from screen',
25
25
  clickToPickColorAnnouncement: 'Click on the screen to pick a color',
26
26
  selectionToolKeyboardShortcuts: 'Selection tool: Use arrow keys to move selected items, lowercase/uppercase ‘i’ and ‘o’ to resize.',
27
- documentProperties: 'Document',
27
+ documentProperties: 'Page',
28
28
  backgroundColor: 'Background Color: ',
29
29
  imageWidthOption: 'Width: ',
30
30
  imageHeightOption: 'Height: ',
31
+ useGridOption: 'Grid: ',
31
32
  toggleOverflow: 'More',
32
33
  touchPanning: 'Touchscreen panning',
33
34
  freehandPen: 'Freehand',
@@ -122,7 +122,7 @@ export default class BaseWidget {
122
122
  }
123
123
  // Add a listener that is triggered when a key is pressed.
124
124
  // Listeners will fire regardless of whether this widget is selected and require that
125
- // {@link lib!Editor.toolController} to have an enabled {@link lib!ToolbarShortcutHandler} tool.
125
+ // {@link Editor.toolController} to have an enabled {@link ToolbarShortcutHandler} tool.
126
126
  onKeyPress(_event) {
127
127
  return false;
128
128
  }
@@ -12,6 +12,11 @@ export default class DocumentPropertiesWidget extends BaseWidget {
12
12
  private updateDropdown;
13
13
  private setBackgroundColor;
14
14
  private getBackgroundColor;
15
+ private removeBackgroundComponents;
16
+ /** Replace existing background components with a background of the given type. */
17
+ private setBackgroundType;
18
+ /** Returns the type of the topmost background component */
19
+ private getBackgroundType;
15
20
  private updateImportExportRectSize;
16
21
  private static idCounter;
17
22
  protected fillDropdown(dropdown: HTMLElement): boolean;
@@ -1,3 +1,6 @@
1
+ import Erase from '../../commands/Erase.mjs';
2
+ import uniteCommands from '../../commands/uniteCommands.mjs';
3
+ import BackgroundComponent, { BackgroundType } from '../../components/BackgroundComponent.mjs';
1
4
  import { EditorImageEventType } from '../../EditorImage.mjs';
2
5
  import Rect2 from '../../math/Rect2.mjs';
3
6
  import { EditorEventType } from '../../types.mjs';
@@ -6,7 +9,7 @@ import makeColorInput from '../makeColorInput.mjs';
6
9
  import BaseWidget from './BaseWidget.mjs';
7
10
  export default class DocumentPropertiesWidget extends BaseWidget {
8
11
  constructor(editor, localizationTable) {
9
- super(editor, 'zoom-widget', localizationTable);
12
+ super(editor, 'document-properties-widget', localizationTable);
10
13
  this.updateDropdownContent = () => { };
11
14
  this.dropdownUpdateQueued = false;
12
15
  // Make it possible to open the dropdown, even if this widget isn't selected.
@@ -46,6 +49,33 @@ export default class DocumentPropertiesWidget extends BaseWidget {
46
49
  getBackgroundColor() {
47
50
  return this.editor.estimateBackgroundColor();
48
51
  }
52
+ removeBackgroundComponents() {
53
+ const previousBackgrounds = [];
54
+ for (const component of this.editor.image.getBackgroundComponents()) {
55
+ if (component instanceof BackgroundComponent) {
56
+ previousBackgrounds.push(component);
57
+ }
58
+ }
59
+ return new Erase(previousBackgrounds);
60
+ }
61
+ /** Replace existing background components with a background of the given type. */
62
+ setBackgroundType(backgroundType) {
63
+ const prevBackgroundColor = this.editor.estimateBackgroundColor();
64
+ const newBackground = new BackgroundComponent(backgroundType, prevBackgroundColor);
65
+ const addBackgroundCommand = this.editor.image.addElement(newBackground);
66
+ return uniteCommands([this.removeBackgroundComponents(), addBackgroundCommand]);
67
+ }
68
+ /** Returns the type of the topmost background component */
69
+ getBackgroundType() {
70
+ const backgroundComponents = this.editor.image.getBackgroundComponents();
71
+ for (let i = backgroundComponents.length - 1; i >= 0; i--) {
72
+ const component = backgroundComponents[i];
73
+ if (component instanceof BackgroundComponent) {
74
+ return component.getBackgroundType();
75
+ }
76
+ }
77
+ return BackgroundType.None;
78
+ }
49
79
  updateImportExportRectSize(size) {
50
80
  const filterDimension = (dim) => {
51
81
  if (dim !== undefined && (!isFinite(dim) || dim <= 0)) {
@@ -74,6 +104,27 @@ export default class DocumentPropertiesWidget extends BaseWidget {
74
104
  colorInput.id = `${toolbarCSSPrefix}docPropertiesColorInput-${DocumentPropertiesWidget.idCounter++}`;
75
105
  backgroundColorLabel.htmlFor = colorInput.id;
76
106
  backgroundColorRow.replaceChildren(backgroundColorLabel, backgroundColorInputContainer);
107
+ const useGridRow = document.createElement('div');
108
+ const useGridLabel = document.createElement('label');
109
+ const useGridCheckbox = document.createElement('input');
110
+ useGridCheckbox.id = `${toolbarCSSPrefix}docPropertiesUseGridCheckbox-${DocumentPropertiesWidget.idCounter++}`;
111
+ useGridLabel.htmlFor = useGridCheckbox.id;
112
+ useGridCheckbox.type = 'checkbox';
113
+ useGridLabel.innerText = this.localizationTable.useGridOption;
114
+ useGridCheckbox.oninput = () => {
115
+ const prevBackgroundType = this.getBackgroundType();
116
+ const wasGrid = prevBackgroundType === BackgroundType.Grid;
117
+ if (wasGrid === useGridCheckbox.checked) {
118
+ // Already the requested background type.
119
+ return;
120
+ }
121
+ let newBackgroundType = BackgroundType.SolidColor;
122
+ if (useGridCheckbox.checked) {
123
+ newBackgroundType = BackgroundType.Grid;
124
+ }
125
+ this.editor.dispatch(this.setBackgroundType(newBackgroundType));
126
+ };
127
+ useGridRow.replaceChildren(useGridLabel, useGridCheckbox);
77
128
  const addDimensionRow = (labelContent, onChange) => {
78
129
  const row = document.createElement('div');
79
130
  const label = document.createElement('label');
@@ -110,9 +161,10 @@ export default class DocumentPropertiesWidget extends BaseWidget {
110
161
  const importExportRect = this.editor.getImportExportRect();
111
162
  imageWidthRow.setValue(importExportRect.width);
112
163
  imageHeightRow.setValue(importExportRect.height);
164
+ useGridCheckbox.checked = this.getBackgroundType() === BackgroundType.Grid;
113
165
  };
114
166
  this.updateDropdownContent();
115
- container.replaceChildren(backgroundColorRow, imageWidthRow.element, imageHeightRow.element);
167
+ container.replaceChildren(backgroundColorRow, useGridRow, imageWidthRow.element, imageHeightRow.element);
116
168
  dropdown.replaceChildren(container);
117
169
  return true;
118
170
  }
@@ -110,7 +110,7 @@ export default class PenToolWidget extends BaseToolWidget {
110
110
  objectTypeSelect.id = `${toolbarCSSPrefix}penBuilderSelect${PenToolWidget.idCounter++}`;
111
111
  thicknessLabel.innerText = this.localizationTable.thicknessLabel;
112
112
  thicknessLabel.setAttribute('for', thicknessInput.id);
113
- objectSelectLabel.innerText = this.localizationTable.selectObjectType;
113
+ objectSelectLabel.innerText = this.localizationTable.selectPenType;
114
114
  objectSelectLabel.setAttribute('for', objectTypeSelect.id);
115
115
  // Use a logarithmic scale for thicknessInput (finer control over thinner strokewidths.)
116
116
  const inverseThicknessInputFn = (t) => Math.log10(t);
@@ -1,4 +1,4 @@
1
- // Displays a find dialog that allows the user to search for and focus text.
1
+ // Displays a find dialog that allows the user to search for and focus text.
2
2
  //
3
3
  // @packageDocumentation
4
4
  import TextComponent from '../components/TextComponent.mjs';
@@ -0,0 +1,24 @@
1
+ import Editor from '../Editor';
2
+ import { PointerEvt } from '../types';
3
+ import BaseTool from './BaseTool';
4
+ /**
5
+ * This tool, when enabled, plays a sound representing the color of the portion of the display
6
+ * currently under the cursor. This tool adds a button that can be navigated to with the tab key
7
+ * that enables/disables the tool.
8
+ *
9
+ * This allows the user to explore the content of the display without a working screen.
10
+ */
11
+ export default class SoundUITool extends BaseTool {
12
+ private editor;
13
+ private soundFeedback;
14
+ private toggleButton;
15
+ private toggleButtonContainer;
16
+ constructor(editor: Editor, description: string);
17
+ private updateToggleButtonText;
18
+ setEnabled(enabled: boolean): void;
19
+ private lastPointerPos;
20
+ onPointerDown({ current, allPointers }: PointerEvt): boolean;
21
+ onPointerMove({ current }: PointerEvt): void;
22
+ onPointerUp(_event: PointerEvt): void;
23
+ onGestureCancel(): void;
24
+ }
@@ -0,0 +1,158 @@
1
+ import Color4 from '../Color4.mjs';
2
+ import LineSegment2 from '../math/LineSegment2.mjs';
3
+ import BaseTool from './BaseTool.mjs';
4
+ class SoundFeedback {
5
+ constructor() {
6
+ this.closed = false;
7
+ // No AudioContext? Exit!
8
+ if (!window.AudioContext) {
9
+ console.warn('Accessibility sound UI: Unable to open AudioContext.');
10
+ this.closed = true;
11
+ return;
12
+ }
13
+ this.ctx = new AudioContext();
14
+ // Color oscillator and gain
15
+ this.colorOscHue = this.ctx.createOscillator();
16
+ this.colorOscValue = this.ctx.createOscillator();
17
+ this.colorOscSaturation = this.ctx.createOscillator();
18
+ this.colorOscHue.type = 'triangle';
19
+ this.colorOscSaturation.type = 'sine';
20
+ this.colorOscValue.type = 'sawtooth';
21
+ this.valueGain = this.ctx.createGain();
22
+ this.colorOscValue.connect(this.valueGain);
23
+ this.valueGain.gain.setValueAtTime(0.18, this.ctx.currentTime);
24
+ this.colorGain = this.ctx.createGain();
25
+ this.colorOscHue.connect(this.colorGain);
26
+ this.valueGain.connect(this.colorGain);
27
+ this.colorOscSaturation.connect(this.colorGain);
28
+ this.colorGain.connect(this.ctx.destination);
29
+ // Boundary oscillator and gain
30
+ this.boundaryGain = this.ctx.createGain();
31
+ this.boundaryOsc = this.ctx.createOscillator();
32
+ this.boundaryOsc.type = 'sawtooth';
33
+ this.boundaryGain.gain.setValueAtTime(0, this.ctx.currentTime);
34
+ this.boundaryOsc.connect(this.boundaryGain);
35
+ this.boundaryGain.connect(this.ctx.destination);
36
+ // Prepare for the first announcement/feedback.
37
+ this.colorOscHue.start();
38
+ this.colorOscSaturation.start();
39
+ this.colorOscValue.start();
40
+ this.boundaryOsc.start();
41
+ this.pause();
42
+ }
43
+ pause() {
44
+ if (this.closed)
45
+ return;
46
+ this.colorGain.gain.setValueAtTime(0, this.ctx.currentTime);
47
+ void this.ctx.suspend();
48
+ }
49
+ play() {
50
+ if (this.closed)
51
+ return;
52
+ void this.ctx.resume();
53
+ }
54
+ setColor(color) {
55
+ const hsv = color.asHSV();
56
+ // Choose frequencies that roughly correspond to hue, saturation, and value.
57
+ const hueFrequency = (-Math.cos(hsv.x / 2)) * 220 + 440;
58
+ const saturationFrequency = hsv.y * 440 + 220;
59
+ const valueFrequency = (hsv.z + 0.1) * 440;
60
+ // Sigmoid with maximum 0.25 * alpha.
61
+ // Louder for greater value.
62
+ const gain = 0.25 * Math.min(1, color.a) / (1 + Math.exp(-(hsv.z - 0.5) * 3));
63
+ this.colorOscHue.frequency.setValueAtTime(hueFrequency, this.ctx.currentTime);
64
+ this.colorOscSaturation.frequency.setValueAtTime(saturationFrequency, this.ctx.currentTime);
65
+ this.colorOscValue.frequency.setValueAtTime(valueFrequency, this.ctx.currentTime);
66
+ this.valueGain.gain.setValueAtTime((1 - hsv.z) * 0.4, this.ctx.currentTime);
67
+ this.colorGain.gain.setValueAtTime(gain, this.ctx.currentTime);
68
+ }
69
+ announceBoundaryCross(boundaryCrossCount) {
70
+ this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime);
71
+ this.boundaryGain.gain.setValueAtTime(0, this.ctx.currentTime);
72
+ this.boundaryGain.gain.linearRampToValueAtTime(0.018, this.ctx.currentTime + 0.1);
73
+ this.boundaryOsc.frequency.setValueAtTime(440 + Math.atan(boundaryCrossCount / 2) * 100, this.ctx.currentTime);
74
+ this.boundaryGain.gain.linearRampToValueAtTime(0, this.ctx.currentTime + 0.25);
75
+ }
76
+ close() {
77
+ this.ctx.close();
78
+ this.closed = true;
79
+ }
80
+ }
81
+ /**
82
+ * This tool, when enabled, plays a sound representing the color of the portion of the display
83
+ * currently under the cursor. This tool adds a button that can be navigated to with the tab key
84
+ * that enables/disables the tool.
85
+ *
86
+ * This allows the user to explore the content of the display without a working screen.
87
+ */
88
+ export default class SoundUITool extends BaseTool {
89
+ constructor(editor, description) {
90
+ super(editor.notifier, description);
91
+ this.editor = editor;
92
+ this.soundFeedback = null;
93
+ // Create a screen-reader-usable method of toggling the tool:
94
+ this.toggleButtonContainer = document.createElement('div');
95
+ this.toggleButtonContainer.classList.add('js-draw-sound-ui-toggle');
96
+ this.toggleButton = document.createElement('button');
97
+ this.toggleButton.onclick = () => {
98
+ this.setEnabled(!this.isEnabled());
99
+ };
100
+ this.toggleButtonContainer.appendChild(this.toggleButton);
101
+ this.updateToggleButtonText();
102
+ editor.createHTMLOverlay(this.toggleButtonContainer);
103
+ }
104
+ updateToggleButtonText() {
105
+ const containerEnabledClass = 'sound-ui-tool-enabled';
106
+ if (this.isEnabled()) {
107
+ this.toggleButton.innerText = this.editor.localization.disableAccessibilityExploreTool;
108
+ this.toggleButtonContainer.classList.add(containerEnabledClass);
109
+ }
110
+ else {
111
+ this.toggleButton.innerText = this.editor.localization.enableAccessibilityExploreTool;
112
+ this.toggleButtonContainer.classList.remove(containerEnabledClass);
113
+ }
114
+ }
115
+ setEnabled(enabled) {
116
+ var _a;
117
+ super.setEnabled(enabled);
118
+ if (!enabled) {
119
+ (_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.close();
120
+ this.soundFeedback = null;
121
+ }
122
+ this.updateToggleButtonText();
123
+ }
124
+ onPointerDown({ current, allPointers }) {
125
+ var _a, _b, _c;
126
+ if (!this.soundFeedback) {
127
+ this.soundFeedback = new SoundFeedback();
128
+ }
129
+ // Allow two-finger gestures to move the screen.
130
+ if (allPointers.length >= 2) {
131
+ return false;
132
+ }
133
+ // Accept multiple cursors -- some screen readers require multiple (touch) pointers to interact with
134
+ // an image instead of using the built-in navigation features.
135
+ (_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.play();
136
+ (_b = this.soundFeedback) === null || _b === void 0 ? void 0 : _b.setColor((_c = this.editor.display.getColorAt(current.screenPos)) !== null && _c !== void 0 ? _c : Color4.black);
137
+ this.lastPointerPos = current.canvasPos;
138
+ return true;
139
+ }
140
+ onPointerMove({ current }) {
141
+ var _a, _b, _c;
142
+ (_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.setColor((_b = this.editor.display.getColorAt(current.screenPos)) !== null && _b !== void 0 ? _b : Color4.black);
143
+ const pointerMotionLine = new LineSegment2(this.lastPointerPos, current.canvasPos);
144
+ const collisions = this.editor.image.getElementsIntersectingRegion(pointerMotionLine.bbox).filter(component => component.intersects(pointerMotionLine));
145
+ this.lastPointerPos = current.canvasPos;
146
+ if (collisions.length > 0) {
147
+ (_c = this.soundFeedback) === null || _c === void 0 ? void 0 : _c.announceBoundaryCross(collisions.length);
148
+ }
149
+ }
150
+ onPointerUp(_event) {
151
+ var _a;
152
+ (_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.pause();
153
+ }
154
+ onGestureCancel() {
155
+ var _a;
156
+ (_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.pause();
157
+ }
158
+ }
@@ -3,7 +3,7 @@ import Editor from '../Editor';
3
3
  import { PointerEvt } from '../types';
4
4
  import BaseTool from './BaseTool';
5
5
  import { ToolLocalization } from './localization';
6
- import TextStyle from '../rendering/TextRenderingStyle';
6
+ import TextRenderingStyle from '../rendering/TextRenderingStyle';
7
7
  export default class TextTool extends BaseTool {
8
8
  private editor;
9
9
  private localizationTable;
@@ -28,6 +28,6 @@ export default class TextTool extends BaseTool {
28
28
  setFontFamily(fontFamily: string): void;
29
29
  setColor(color: Color4): void;
30
30
  setFontSize(size: number): void;
31
- getTextStyle(): TextStyle;
31
+ getTextStyle(): TextRenderingStyle;
32
32
  private setTextStyle;
33
33
  }
@@ -14,6 +14,7 @@ import ToolbarShortcutHandler from './ToolbarShortcutHandler.mjs';
14
14
  import { makePressureSensitiveFreehandLineBuilder } from '../components/builders/PressureSensitiveFreehandLineBuilder.mjs';
15
15
  import FindTool from './FindTool.mjs';
16
16
  import SelectAllShortcutHandler from './SelectionTool/SelectAllShortcutHandler.mjs';
17
+ import SoundUITool from './SoundUITool.mjs';
17
18
  export default class ToolController {
18
19
  /** @internal */
19
20
  constructor(editor, localization) {
@@ -32,10 +33,14 @@ export default class ToolController {
32
33
  new Eraser(editor, localization.eraserTool),
33
34
  new SelectionTool(editor, localization.selectionTool),
34
35
  new TextTool(editor, localization.textTool, localization),
35
- new PanZoom(editor, PanZoomMode.SinglePointerGestures, localization.anyDevicePanning)
36
+ new PanZoom(editor, PanZoomMode.SinglePointerGestures, localization.anyDevicePanning),
36
37
  ];
38
+ // Accessibility tools
39
+ const soundExplorer = new SoundUITool(editor, localization.soundExplorer);
40
+ soundExplorer.setEnabled(false);
37
41
  this.tools = [
38
42
  new PipetteTool(editor, localization.pipetteTool),
43
+ soundExplorer,
39
44
  panZoomTool,
40
45
  ...primaryTools,
41
46
  keyboardPanZoomTool,
@@ -13,4 +13,5 @@ export { default as SelectionTool } from './SelectionTool/SelectionTool';
13
13
  export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler';
14
14
  export { default as EraserTool } from './Eraser';
15
15
  export { default as PasteHandler } from './PasteHandler';
16
+ export { default as SoundUITool } from './SoundUITool';
16
17
  export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler';
@@ -13,4 +13,5 @@ export { default as SelectionTool } from './SelectionTool/SelectionTool.mjs';
13
13
  export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler.mjs';
14
14
  export { default as EraserTool } from './Eraser.mjs';
15
15
  export { default as PasteHandler } from './PasteHandler.mjs';
16
+ export { default as SoundUITool } from './SoundUITool.mjs';
16
17
  export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler.mjs';
@@ -13,6 +13,9 @@ export interface ToolLocalization {
13
13
  enterTextToInsert: string;
14
14
  changeTool: string;
15
15
  pasteHandler: string;
16
+ soundExplorer: string;
17
+ disableAccessibilityExploreTool: string;
18
+ enableAccessibilityExploreTool: string;
16
19
  findLabel: string;
17
20
  toNextMatch: string;
18
21
  closeFindDialog: string;
@@ -13,6 +13,9 @@ export const defaultToolLocalization = {
13
13
  enterTextToInsert: 'Text to insert',
14
14
  changeTool: 'Change tool',
15
15
  pasteHandler: 'Copy paste handler',
16
+ soundExplorer: 'Sound-based image exploration',
17
+ disableAccessibilityExploreTool: 'Disable sound-based exploration',
18
+ enableAccessibilityExploreTool: 'Enable sound-based exploration',
16
19
  findLabel: 'Find',
17
20
  toNextMatch: 'Next',
18
21
  closeFindDialog: 'Close',
package/jest.config.js CHANGED
@@ -21,7 +21,7 @@ const config = {
21
21
  '\\.(css|lessc)': '<rootDir>/__mocks__/styleMock.js',
22
22
  '@melloware/coloris': '<rootDir>/__mocks__/coloris.ts',
23
23
  },
24
-
24
+
25
25
  testEnvironment: 'jsdom',
26
26
  setupFilesAfterEnv: [ '<rootDir>/src/testing/beforeEachFile.ts' ],
27
27
  };