js-draw 0.23.1 → 0.24.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.
- package/README.md +2 -2
- package/build-config.json +23 -0
- package/dist/bundle.js +3 -3
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Color4.js +263 -0
- package/dist/cjs/Editor.d.ts +328 -0
- package/dist/cjs/Editor.js +1058 -0
- package/dist/cjs/EditorImage.d.ts +97 -0
- package/dist/cjs/EditorImage.js +531 -0
- package/dist/cjs/EventDispatcher.d.ts +29 -0
- package/dist/cjs/EventDispatcher.js +58 -0
- package/dist/cjs/Pointer.d.ts +37 -0
- package/dist/cjs/Pointer.js +123 -0
- package/dist/cjs/SVGLoader.d.ts +48 -0
- package/dist/cjs/SVGLoader.js +667 -0
- package/dist/cjs/SVGLoader.test.d.ts +1 -0
- package/dist/cjs/UndoRedoHistory.js +105 -0
- package/dist/cjs/UndoRedoHistory.test.d.ts +1 -0
- package/dist/cjs/Viewport.d.ts +73 -0
- package/dist/cjs/Viewport.js +307 -0
- package/dist/cjs/bundle/bundled.js +21 -0
- package/dist/cjs/commands/Command.js +61 -0
- package/dist/cjs/commands/Duplicate.js +80 -0
- package/dist/cjs/commands/Erase.js +101 -0
- package/dist/cjs/commands/SerializableCommand.js +57 -0
- package/dist/cjs/commands/UnresolvedCommand.js +43 -0
- package/dist/cjs/commands/invertCommand.js +77 -0
- package/dist/cjs/commands/lib.js +15 -0
- package/dist/cjs/commands/localization.d.ts +23 -0
- package/dist/cjs/commands/localization.js +24 -0
- package/dist/cjs/commands/uniteCommands.js +152 -0
- package/dist/cjs/commands/uniteCommands.test.d.ts +1 -0
- package/dist/cjs/components/AbstractComponent.d.ts +85 -0
- package/dist/cjs/components/AbstractComponent.js +300 -0
- package/dist/cjs/components/AbstractComponent.transformBy.test.d.ts +1 -0
- package/dist/cjs/components/BackgroundComponent.d.ts +62 -0
- package/dist/cjs/components/BackgroundComponent.js +311 -0
- package/dist/cjs/components/BackgroundComponent.test.d.ts +1 -0
- package/dist/cjs/components/ImageComponent.d.ts +31 -0
- package/dist/cjs/components/ImageComponent.js +228 -0
- package/dist/cjs/components/RestylableComponent.js +103 -0
- package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/cjs/components/SVGGlobalAttributesObject.js +82 -0
- package/dist/cjs/components/Stroke.d.ts +76 -0
- package/dist/cjs/components/Stroke.js +271 -0
- package/dist/cjs/components/Stroke.test.d.ts +1 -0
- package/dist/cjs/components/TextComponent.d.ts +79 -0
- package/dist/cjs/components/TextComponent.js +411 -0
- package/dist/cjs/components/TextComponent.test.d.ts +1 -0
- package/dist/cjs/components/UnknownSVGObject.d.ts +18 -0
- package/dist/cjs/components/UnknownSVGObject.js +65 -0
- package/dist/cjs/components/UnknownSVGObject.test.d.ts +1 -0
- package/dist/cjs/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/cjs/components/builders/ArrowBuilder.js +93 -0
- package/dist/cjs/components/builders/CircleBuilder.d.ts +2 -0
- package/dist/cjs/components/builders/CircleBuilder.js +74 -0
- package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/cjs/components/builders/FreehandLineBuilder.js +183 -0
- package/dist/cjs/components/builders/FreehandLineBuilder.test.d.ts +1 -0
- package/dist/cjs/components/builders/LineBuilder.d.ts +18 -0
- package/dist/cjs/components/builders/LineBuilder.js +65 -0
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +351 -0
- package/dist/cjs/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/cjs/components/builders/RectangleBuilder.js +58 -0
- package/dist/cjs/components/builders/types.d.ts +12 -0
- package/dist/cjs/components/lib.d.ts +14 -0
- package/dist/cjs/components/lib.js +42 -0
- package/dist/cjs/components/localization.js +14 -0
- package/dist/cjs/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/cjs/components/util/StrokeSmoother.js +225 -0
- package/dist/cjs/components/util/describeComponentList.d.ts +4 -0
- package/dist/cjs/components/util/describeComponentList.js +17 -0
- package/dist/cjs/lib.d.ts +66 -0
- package/dist/cjs/lib.js +94 -0
- package/dist/cjs/localization.js +24 -0
- package/dist/cjs/localizations/de.js +17 -0
- package/dist/cjs/localizations/en.js +17 -0
- package/dist/cjs/localizations/es.js +31 -0
- package/dist/cjs/localizations/getLocalizationTable.d.ts +17 -0
- package/dist/cjs/localizations/getLocalizationTable.js +65 -0
- package/dist/cjs/localizations/getLocalizationTable.test.d.ts +1 -0
- package/dist/cjs/math/Mat33.d.ts +123 -0
- package/dist/cjs/math/Mat33.js +340 -0
- package/dist/cjs/math/Mat33.test.d.ts +1 -0
- package/dist/cjs/math/Vec2.js +37 -0
- package/dist/cjs/math/Vec2.test.d.ts +1 -0
- package/dist/cjs/math/Vec3.js +183 -0
- package/dist/cjs/math/Vec3.test.d.ts +1 -0
- package/dist/cjs/math/lib.d.ts +7 -0
- package/dist/cjs/math/lib.js +15 -0
- package/dist/cjs/math/polynomial/solveQuadratic.d.ts +9 -0
- package/dist/cjs/math/polynomial/solveQuadratic.js +39 -0
- package/dist/cjs/math/polynomial/solveQuadratic.test.d.ts +1 -0
- package/dist/cjs/math/rounding.js +140 -0
- package/dist/cjs/math/rounding.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Abstract2DShape.d.ts +49 -0
- package/dist/cjs/math/shapes/Abstract2DShape.js +42 -0
- package/dist/cjs/math/shapes/BezierJSWrapper.d.ts +36 -0
- package/dist/cjs/math/shapes/BezierJSWrapper.js +109 -0
- package/dist/cjs/math/shapes/CubicBezier.d.ts +17 -0
- package/dist/cjs/math/shapes/CubicBezier.js +50 -0
- package/dist/cjs/math/shapes/LineSegment2.d.ts +70 -0
- package/dist/cjs/math/shapes/LineSegment2.js +204 -0
- package/dist/cjs/math/shapes/LineSegment2.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Path.d.ts +93 -0
- package/dist/cjs/math/shapes/Path.fromString.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Path.js +865 -0
- package/dist/cjs/math/shapes/Path.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Path.toString.test.d.ts +1 -0
- package/dist/cjs/math/shapes/PointShape2D.d.ts +18 -0
- package/dist/cjs/math/shapes/PointShape2D.js +46 -0
- package/dist/cjs/math/shapes/QuadraticBezier.d.ts +34 -0
- package/dist/cjs/math/shapes/QuadraticBezier.js +133 -0
- package/dist/cjs/math/shapes/QuadraticBezier.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Rect2.d.ts +57 -0
- package/dist/cjs/math/shapes/Rect2.js +311 -0
- package/dist/cjs/math/shapes/Rect2.test.d.ts +1 -0
- package/dist/cjs/math/shapes/Triangle.d.ts +46 -0
- package/dist/cjs/math/shapes/Triangle.js +148 -0
- package/dist/cjs/math/shapes/Triangle.test.d.ts +1 -0
- package/dist/cjs/rendering/Display.js +222 -0
- package/dist/cjs/rendering/RenderingStyle.d.ts +31 -0
- package/dist/cjs/rendering/RenderingStyle.js +56 -0
- package/dist/cjs/rendering/RenderingStyle.test.d.ts +1 -0
- package/dist/cjs/rendering/TextRenderingStyle.d.ts +43 -0
- package/dist/cjs/rendering/TextRenderingStyle.js +40 -0
- package/dist/cjs/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/cjs/rendering/caching/CacheRecord.js +59 -0
- package/dist/cjs/rendering/caching/CacheRecord.test.d.ts +1 -0
- package/dist/cjs/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/cjs/rendering/caching/CacheRecordManager.js +48 -0
- package/dist/cjs/rendering/caching/RenderingCache.js +50 -0
- package/dist/cjs/rendering/caching/RenderingCache.test.d.ts +1 -0
- package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +340 -0
- package/dist/cjs/rendering/caching/testUtils.js +34 -0
- package/dist/cjs/rendering/lib.js +14 -0
- package/dist/cjs/rendering/localization.js +12 -0
- package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +85 -0
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +168 -0
- package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +263 -0
- package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/cjs/rendering/renderers/DummyRenderer.js +132 -0
- package/dist/cjs/rendering/renderers/DummyRenderer.test.d.ts +1 -0
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/cjs/rendering/renderers/SVGRenderer.js +355 -0
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +89 -0
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.test.d.ts +1 -0
- package/dist/cjs/shortcuts/KeyBinding.d.ts +46 -0
- package/dist/cjs/shortcuts/KeyBinding.js +157 -0
- package/dist/cjs/shortcuts/KeyBinding.test.d.ts +1 -0
- package/dist/cjs/shortcuts/KeyboardShortcutManager.d.ts +77 -0
- package/dist/cjs/shortcuts/KeyboardShortcutManager.js +148 -0
- package/dist/cjs/shortcuts/KeyboardShortcutManager.test.d.ts +1 -0
- package/dist/cjs/shortcuts/lib.d.ts +2 -0
- package/dist/cjs/shortcuts/lib.js +7 -0
- package/dist/cjs/testing/createEditor.js +11 -0
- package/dist/cjs/testing/lib.js +7 -0
- package/dist/cjs/testing/sendPenEvent.js +21 -0
- package/dist/cjs/testing/sendTouchEvent.js +73 -0
- package/dist/cjs/toolbar/HTMLToolbar.js +465 -0
- package/dist/cjs/toolbar/IconProvider.js +274 -0
- package/dist/cjs/toolbar/lib.js +21 -0
- package/dist/cjs/toolbar/localization.d.ts +52 -0
- package/dist/cjs/toolbar/localization.js +54 -0
- package/dist/cjs/toolbar/makeColorInput.js +125 -0
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +47 -0
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +64 -0
- package/dist/cjs/toolbar/widgets/BaseWidget.js +359 -0
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +196 -0
- package/dist/cjs/toolbar/widgets/EraserToolWidget.js +90 -0
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +211 -0
- package/dist/cjs/toolbar/widgets/InsertImageWidget.js +246 -0
- package/dist/cjs/toolbar/widgets/OverflowWidget.js +103 -0
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +264 -0
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +213 -0
- package/dist/cjs/toolbar/widgets/TextToolWidget.js +142 -0
- package/dist/cjs/toolbar/widgets/keybindings.d.ts +2 -0
- package/dist/cjs/toolbar/widgets/keybindings.js +13 -0
- package/dist/cjs/toolbar/widgets/lib.js +23 -0
- package/dist/cjs/tools/BaseTool.js +67 -0
- package/dist/cjs/tools/Eraser.d.ts +24 -0
- package/dist/cjs/tools/Eraser.js +148 -0
- package/dist/cjs/tools/Eraser.test.d.ts +1 -0
- package/dist/cjs/tools/FindTool.d.ts +20 -0
- package/dist/cjs/tools/FindTool.js +137 -0
- package/dist/cjs/tools/PanZoom.d.ts +52 -0
- package/dist/cjs/tools/PanZoom.js +471 -0
- package/dist/cjs/tools/PanZoom.test.d.ts +1 -0
- package/dist/cjs/tools/PasteHandler.js +179 -0
- package/dist/cjs/tools/Pen.d.ts +41 -0
- package/dist/cjs/tools/Pen.js +238 -0
- package/dist/cjs/tools/Pen.test.d.ts +1 -0
- package/dist/cjs/tools/PipetteTool.js +63 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +44 -0
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/cjs/tools/SelectionTool/Selection.js +602 -0
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +86 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +37 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +441 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +1 -0
- package/dist/cjs/tools/SelectionTool/TransformMode.js +107 -0
- package/dist/cjs/tools/SelectionTool/types.js +14 -0
- package/dist/cjs/tools/SoundUITool.js +182 -0
- package/dist/cjs/tools/TextTool.d.ts +34 -0
- package/dist/cjs/tools/TextTool.js +284 -0
- package/dist/cjs/tools/ToolController.js +179 -0
- package/dist/cjs/tools/ToolEnabledGroup.js +16 -0
- package/dist/cjs/tools/ToolSwitcherShortcut.js +54 -0
- package/dist/cjs/tools/ToolbarShortcutHandler.js +50 -0
- package/dist/cjs/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/cjs/tools/UndoRedoShortcut.js +42 -0
- package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +1 -0
- package/dist/cjs/tools/keybindings.d.ts +17 -0
- package/dist/cjs/tools/keybindings.js +44 -0
- package/dist/cjs/tools/lib.js +35 -0
- package/dist/cjs/tools/localization.js +33 -0
- package/dist/cjs/types.d.ts +154 -0
- package/dist/cjs/types.js +38 -0
- package/dist/cjs/util/assertions.js +54 -0
- package/dist/cjs/util/fileToBase64.js +15 -0
- package/dist/cjs/util/untilNextAnimationFrame.js +9 -0
- package/dist/cjs/util/waitForAll.js +17 -0
- package/dist/cjs/util/waitForTimeout.js +9 -0
- package/dist/mjs/Color4.mjs +260 -0
- package/dist/mjs/Color4.test.d.ts +1 -0
- package/dist/mjs/Editor.d.ts +328 -0
- package/dist/mjs/Editor.loadFrom.test.d.ts +1 -0
- package/dist/mjs/Editor.mjs +1055 -0
- package/dist/mjs/Editor.toSVG.test.d.ts +1 -0
- package/dist/mjs/EditorImage.d.ts +97 -0
- package/dist/mjs/EditorImage.mjs +527 -0
- package/dist/mjs/EditorImage.test.d.ts +1 -0
- package/dist/mjs/EventDispatcher.d.ts +29 -0
- package/dist/mjs/EventDispatcher.mjs +56 -0
- package/dist/mjs/EventDispatcher.test.d.ts +1 -0
- package/dist/mjs/Pointer.d.ts +37 -0
- package/dist/mjs/Pointer.mjs +120 -0
- package/dist/mjs/SVGLoader.d.ts +48 -0
- package/dist/mjs/SVGLoader.mjs +664 -0
- package/dist/mjs/SVGLoader.test.d.ts +1 -0
- package/dist/mjs/UndoRedoHistory.mjs +103 -0
- package/dist/mjs/UndoRedoHistory.test.d.ts +1 -0
- package/dist/mjs/Viewport.d.ts +73 -0
- package/dist/mjs/Viewport.mjs +304 -0
- package/dist/mjs/commands/Command.mjs +58 -0
- package/dist/mjs/commands/Duplicate.mjs +78 -0
- package/dist/mjs/commands/Erase.mjs +99 -0
- package/dist/mjs/commands/SerializableCommand.mjs +55 -0
- package/dist/mjs/commands/UnresolvedCommand.mjs +41 -0
- package/dist/mjs/commands/invertCommand.mjs +75 -0
- package/dist/mjs/commands/localization.d.ts +23 -0
- package/dist/mjs/commands/localization.mjs +21 -0
- package/dist/mjs/commands/uniteCommands.mjs +150 -0
- package/dist/mjs/commands/uniteCommands.test.d.ts +1 -0
- package/dist/mjs/components/AbstractComponent.d.ts +85 -0
- package/dist/mjs/components/AbstractComponent.mjs +298 -0
- package/dist/mjs/components/AbstractComponent.transformBy.test.d.ts +1 -0
- package/dist/mjs/components/BackgroundComponent.d.ts +62 -0
- package/dist/mjs/components/BackgroundComponent.mjs +308 -0
- package/dist/mjs/components/BackgroundComponent.test.d.ts +1 -0
- package/dist/mjs/components/ImageComponent.d.ts +31 -0
- package/dist/mjs/components/ImageComponent.mjs +226 -0
- package/dist/mjs/components/RestylableComponent.mjs +98 -0
- package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +80 -0
- package/dist/mjs/components/Stroke.d.ts +76 -0
- package/dist/mjs/components/Stroke.mjs +269 -0
- package/dist/mjs/components/Stroke.test.d.ts +1 -0
- package/dist/mjs/components/TextComponent.d.ts +79 -0
- package/dist/mjs/components/TextComponent.mjs +408 -0
- package/dist/mjs/components/TextComponent.test.d.ts +1 -0
- package/dist/mjs/components/UnknownSVGObject.d.ts +18 -0
- package/dist/mjs/components/UnknownSVGObject.mjs +63 -0
- package/dist/mjs/components/UnknownSVGObject.test.d.ts +1 -0
- package/dist/mjs/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/mjs/components/builders/ArrowBuilder.mjs +89 -0
- package/dist/mjs/components/builders/CircleBuilder.d.ts +2 -0
- package/dist/mjs/components/builders/CircleBuilder.mjs +70 -0
- package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/mjs/components/builders/FreehandLineBuilder.mjs +179 -0
- package/dist/mjs/components/builders/FreehandLineBuilder.test.d.ts +1 -0
- package/dist/mjs/components/builders/LineBuilder.d.ts +18 -0
- package/dist/mjs/components/builders/LineBuilder.mjs +61 -0
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +347 -0
- package/dist/mjs/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/mjs/components/builders/RectangleBuilder.mjs +53 -0
- package/dist/mjs/components/builders/types.d.ts +12 -0
- package/dist/mjs/components/builders/types.mjs +1 -0
- package/dist/mjs/components/lib.d.ts +14 -0
- package/dist/mjs/components/lib.mjs +15 -0
- package/dist/mjs/components/localization.mjs +11 -0
- package/dist/mjs/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/mjs/components/util/StrokeSmoother.mjs +222 -0
- package/dist/mjs/components/util/describeComponentList.d.ts +4 -0
- package/dist/mjs/components/util/describeComponentList.mjs +15 -0
- package/dist/mjs/lib.d.ts +66 -0
- package/dist/mjs/lib.mjs +66 -0
- package/dist/mjs/localization.mjs +21 -0
- package/dist/mjs/localizations/de.mjs +15 -0
- package/dist/mjs/localizations/en.mjs +15 -0
- package/dist/mjs/localizations/es.mjs +29 -0
- package/dist/mjs/localizations/getLocalizationTable.d.ts +17 -0
- package/dist/mjs/localizations/getLocalizationTable.mjs +61 -0
- package/dist/mjs/localizations/getLocalizationTable.test.d.ts +1 -0
- package/dist/mjs/math/Mat33.d.ts +123 -0
- package/dist/mjs/math/Mat33.mjs +338 -0
- package/dist/mjs/math/Mat33.test.d.ts +1 -0
- package/dist/mjs/math/Vec2.mjs +34 -0
- package/dist/mjs/math/Vec2.test.d.ts +1 -0
- package/dist/mjs/math/Vec3.mjs +181 -0
- package/dist/mjs/math/Vec3.test.d.ts +1 -0
- package/dist/mjs/math/lib.d.ts +7 -0
- package/dist/mjs/math/lib.mjs +7 -0
- package/dist/mjs/math/polynomial/solveQuadratic.d.ts +9 -0
- package/dist/mjs/math/polynomial/solveQuadratic.mjs +37 -0
- package/dist/mjs/math/polynomial/solveQuadratic.test.d.ts +1 -0
- package/dist/mjs/math/rounding.mjs +133 -0
- package/dist/mjs/math/rounding.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Abstract2DShape.d.ts +49 -0
- package/dist/mjs/math/shapes/Abstract2DShape.mjs +40 -0
- package/dist/mjs/math/shapes/BezierJSWrapper.d.ts +36 -0
- package/dist/mjs/math/shapes/BezierJSWrapper.mjs +107 -0
- package/dist/mjs/math/shapes/CubicBezier.d.ts +17 -0
- package/dist/mjs/math/shapes/CubicBezier.mjs +48 -0
- package/dist/mjs/math/shapes/LineSegment2.d.ts +70 -0
- package/dist/mjs/math/shapes/LineSegment2.mjs +202 -0
- package/dist/mjs/math/shapes/LineSegment2.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Path.d.ts +93 -0
- package/dist/mjs/math/shapes/Path.fromString.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Path.mjs +862 -0
- package/dist/mjs/math/shapes/Path.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Path.toString.test.d.ts +1 -0
- package/dist/mjs/math/shapes/PointShape2D.d.ts +18 -0
- package/dist/mjs/math/shapes/PointShape2D.mjs +44 -0
- package/dist/mjs/math/shapes/QuadraticBezier.d.ts +34 -0
- package/dist/mjs/math/shapes/QuadraticBezier.mjs +131 -0
- package/dist/mjs/math/shapes/QuadraticBezier.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Rect2.d.ts +57 -0
- package/dist/mjs/math/shapes/Rect2.mjs +309 -0
- package/dist/mjs/math/shapes/Rect2.test.d.ts +1 -0
- package/dist/mjs/math/shapes/Triangle.d.ts +46 -0
- package/dist/mjs/math/shapes/Triangle.mjs +146 -0
- package/dist/mjs/math/shapes/Triangle.test.d.ts +1 -0
- package/dist/mjs/rendering/Display.mjs +219 -0
- package/dist/mjs/rendering/RenderingStyle.d.ts +31 -0
- package/dist/mjs/rendering/RenderingStyle.mjs +49 -0
- package/dist/mjs/rendering/RenderingStyle.test.d.ts +1 -0
- package/dist/mjs/rendering/TextRenderingStyle.d.ts +43 -0
- package/dist/mjs/rendering/TextRenderingStyle.mjs +34 -0
- package/dist/mjs/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/mjs/rendering/caching/CacheRecord.mjs +57 -0
- package/dist/mjs/rendering/caching/CacheRecord.test.d.ts +1 -0
- package/dist/mjs/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/mjs/rendering/caching/CacheRecordManager.mjs +45 -0
- package/dist/mjs/rendering/caching/RenderingCache.mjs +48 -0
- package/dist/mjs/rendering/caching/RenderingCache.test.d.ts +1 -0
- package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +338 -0
- package/dist/mjs/rendering/caching/testUtils.mjs +30 -0
- package/dist/mjs/rendering/caching/types.mjs +1 -0
- package/dist/mjs/rendering/localization.mjs +9 -0
- package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +85 -0
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +166 -0
- package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +261 -0
- package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +130 -0
- package/dist/mjs/rendering/renderers/DummyRenderer.test.d.ts +1 -0
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +352 -0
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +87 -0
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.test.d.ts +1 -0
- package/dist/mjs/shortcuts/KeyBinding.d.ts +46 -0
- package/dist/mjs/shortcuts/KeyBinding.mjs +155 -0
- package/dist/mjs/shortcuts/KeyBinding.test.d.ts +1 -0
- package/dist/mjs/shortcuts/KeyboardShortcutManager.d.ts +77 -0
- package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +146 -0
- package/dist/mjs/shortcuts/KeyboardShortcutManager.test.d.ts +1 -0
- package/dist/mjs/shortcuts/lib.d.ts +2 -0
- package/dist/mjs/shortcuts/lib.mjs +2 -0
- package/dist/mjs/testing/createEditor.mjs +9 -0
- package/dist/mjs/testing/sendPenEvent.mjs +19 -0
- package/dist/mjs/testing/sendTouchEvent.mjs +71 -0
- package/dist/mjs/toolbar/HTMLToolbar.mjs +462 -0
- package/dist/mjs/toolbar/IconProvider.mjs +272 -0
- package/dist/mjs/toolbar/localization.d.ts +52 -0
- package/dist/mjs/toolbar/localization.mjs +51 -0
- package/dist/mjs/toolbar/makeColorInput.mjs +121 -0
- package/dist/mjs/toolbar/types.mjs +1 -0
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +45 -0
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +62 -0
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +357 -0
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +194 -0
- package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +88 -0
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +209 -0
- package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +244 -0
- package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +101 -0
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +262 -0
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +211 -0
- package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +140 -0
- package/dist/mjs/toolbar/widgets/keybindings.d.ts +2 -0
- package/dist/mjs/toolbar/widgets/keybindings.mjs +10 -0
- package/dist/mjs/tools/BaseTool.mjs +65 -0
- package/dist/mjs/tools/Eraser.d.ts +24 -0
- package/dist/mjs/tools/Eraser.mjs +146 -0
- package/dist/mjs/tools/Eraser.test.d.ts +1 -0
- package/dist/mjs/tools/FindTool.d.ts +20 -0
- package/dist/mjs/tools/FindTool.mjs +135 -0
- package/dist/mjs/tools/PanZoom.d.ts +52 -0
- package/dist/mjs/tools/PanZoom.mjs +468 -0
- package/dist/mjs/tools/PanZoom.test.d.ts +1 -0
- package/dist/mjs/tools/PasteHandler.mjs +177 -0
- package/dist/mjs/tools/Pen.d.ts +41 -0
- package/dist/mjs/tools/Pen.mjs +236 -0
- package/dist/mjs/tools/Pen.test.d.ts +1 -0
- package/dist/mjs/tools/PipetteTool.mjs +61 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +42 -0
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/mjs/tools/SelectionTool/Selection.mjs +600 -0
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +83 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +37 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +438 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +1 -0
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +104 -0
- package/dist/mjs/tools/SoundUITool.mjs +180 -0
- package/dist/mjs/tools/TextTool.d.ts +34 -0
- package/dist/mjs/tools/TextTool.mjs +282 -0
- package/dist/mjs/tools/ToolController.mjs +177 -0
- package/dist/mjs/tools/ToolEnabledGroup.mjs +14 -0
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +52 -0
- package/dist/mjs/tools/ToolbarShortcutHandler.mjs +48 -0
- package/dist/mjs/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/mjs/tools/UndoRedoShortcut.mjs +40 -0
- package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +1 -0
- package/dist/mjs/tools/keybindings.d.ts +17 -0
- package/dist/mjs/tools/keybindings.mjs +41 -0
- package/dist/mjs/tools/localization.mjs +30 -0
- package/dist/mjs/types.d.ts +154 -0
- package/dist/mjs/util/assertions.mjs +48 -0
- package/dist/mjs/util/fileToBase64.mjs +13 -0
- package/dist/mjs/util/untilNextAnimationFrame.mjs +7 -0
- package/dist/mjs/util/waitForAll.mjs +15 -0
- package/dist/mjs/util/waitForTimeout.mjs +7 -0
- package/dist-test/test_imports/package-lock.json +13 -0
- package/dist-test/test_imports/package.json +12 -0
- package/dist-test/test_imports/test-imports.js +17 -0
- package/dist-test/test_imports/test-require.cjs +19 -0
- package/package.json +99 -124
- package/src/Color4.test.ts +47 -0
- package/src/Color4.ts +304 -0
- package/src/Editor.loadFrom.test.ts +24 -0
- package/src/Editor.toSVG.test.ts +111 -0
- package/src/Editor.ts +1171 -0
- package/src/EditorImage.test.ts +120 -0
- package/src/EditorImage.ts +603 -0
- package/src/EventDispatcher.test.ts +123 -0
- package/src/EventDispatcher.ts +72 -0
- package/src/Pointer.ts +167 -0
- package/src/SVGLoader.test.ts +114 -0
- package/src/SVGLoader.ts +610 -0
- package/src/UndoRedoHistory.test.ts +33 -0
- package/src/UndoRedoHistory.ts +102 -0
- package/src/Viewport.ts +325 -0
- package/src/bundle/bundled.ts +7 -0
- package/src/commands/Command.ts +45 -0
- package/src/commands/Duplicate.ts +75 -0
- package/src/commands/Erase.ts +94 -0
- package/src/commands/SerializableCommand.ts +49 -0
- package/src/commands/UnresolvedCommand.ts +37 -0
- package/src/commands/invertCommand.ts +58 -0
- package/src/commands/lib.ts +16 -0
- package/src/commands/localization.ts +47 -0
- package/src/commands/uniteCommands.test.ts +23 -0
- package/src/commands/uniteCommands.ts +140 -0
- package/src/components/AbstractComponent.transformBy.test.ts +22 -0
- package/src/components/AbstractComponent.ts +374 -0
- package/src/components/BackgroundComponent.test.ts +45 -0
- package/src/components/BackgroundComponent.ts +353 -0
- package/src/components/ImageComponent.ts +178 -0
- package/src/components/RestylableComponent.ts +161 -0
- package/src/components/SVGGlobalAttributesObject.ts +81 -0
- package/src/components/Stroke.test.ts +139 -0
- package/src/components/Stroke.ts +296 -0
- package/src/components/TextComponent.test.ts +204 -0
- package/src/components/TextComponent.ts +432 -0
- package/src/components/UnknownSVGObject.test.ts +10 -0
- package/src/components/UnknownSVGObject.ts +60 -0
- package/src/components/builders/ArrowBuilder.ts +107 -0
- package/src/components/builders/CircleBuilder.ts +102 -0
- package/src/components/builders/FreehandLineBuilder.test.ts +25 -0
- package/src/components/builders/FreehandLineBuilder.ts +212 -0
- package/src/components/builders/LineBuilder.ts +77 -0
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +454 -0
- package/src/components/builders/RectangleBuilder.ts +74 -0
- package/src/components/builders/types.ts +15 -0
- package/src/components/lib.ts +31 -0
- package/src/components/localization.ts +24 -0
- package/src/components/util/StrokeSmoother.ts +302 -0
- package/src/components/util/describeComponentList.ts +18 -0
- package/src/lib.ts +69 -0
- package/src/localization.ts +34 -0
- package/src/localizations/de.ts +146 -0
- package/src/localizations/en.ts +8 -0
- package/src/localizations/es.ts +74 -0
- package/src/localizations/getLocalizationTable.test.ts +27 -0
- package/src/localizations/getLocalizationTable.ts +74 -0
- package/src/math/Mat33.test.ts +244 -0
- package/src/math/Mat33.ts +442 -0
- package/src/math/Vec2.test.ts +30 -0
- package/src/math/Vec2.ts +40 -0
- package/src/math/Vec3.test.ts +44 -0
- package/src/math/Vec3.ts +218 -0
- package/src/math/lib.ts +15 -0
- package/src/math/polynomial/solveQuadratic.test.ts +39 -0
- package/src/math/polynomial/solveQuadratic.ts +43 -0
- package/src/math/rounding.test.ts +65 -0
- package/src/math/rounding.ts +156 -0
- package/src/math/shapes/Abstract2DShape.ts +63 -0
- package/src/math/shapes/BezierJSWrapper.ts +93 -0
- package/src/math/shapes/CubicBezier.ts +35 -0
- package/src/math/shapes/LineSegment2.test.ts +99 -0
- package/src/math/shapes/LineSegment2.ts +231 -0
- package/src/math/shapes/Path.fromString.test.ts +223 -0
- package/src/math/shapes/Path.test.ts +309 -0
- package/src/math/shapes/Path.toString.test.ts +77 -0
- package/src/math/shapes/Path.ts +1027 -0
- package/src/math/shapes/PointShape2D.ts +33 -0
- package/src/math/shapes/QuadraticBezier.test.ts +31 -0
- package/src/math/shapes/QuadraticBezier.ts +141 -0
- package/src/math/shapes/Rect2.test.ts +209 -0
- package/src/math/shapes/Rect2.ts +344 -0
- package/src/math/shapes/Triangle.test.ts +61 -0
- package/src/math/shapes/Triangle.ts +139 -0
- package/src/rendering/Display.ts +248 -0
- package/src/rendering/RenderingStyle.test.ts +68 -0
- package/src/rendering/RenderingStyle.ts +55 -0
- package/src/rendering/TextRenderingStyle.ts +55 -0
- package/src/rendering/caching/CacheRecord.test.ts +49 -0
- package/src/rendering/caching/CacheRecord.ts +77 -0
- package/src/rendering/caching/CacheRecordManager.ts +71 -0
- package/src/rendering/caching/RenderingCache.test.ts +44 -0
- package/src/rendering/caching/RenderingCache.ts +66 -0
- package/src/rendering/caching/RenderingCacheNode.ts +405 -0
- package/src/rendering/caching/testUtils.ts +35 -0
- package/src/rendering/caching/types.ts +34 -0
- package/src/rendering/lib.ts +8 -0
- package/src/rendering/localization.ts +20 -0
- package/src/rendering/renderers/AbstractRenderer.ts +242 -0
- package/src/rendering/renderers/CanvasRenderer.ts +305 -0
- package/src/rendering/renderers/DummyRenderer.test.ts +42 -0
- package/src/rendering/renderers/DummyRenderer.ts +145 -0
- package/src/rendering/renderers/SVGRenderer.ts +374 -0
- package/src/rendering/renderers/TextOnlyRenderer.test.ts +34 -0
- package/src/rendering/renderers/TextOnlyRenderer.ts +71 -0
- package/src/shortcuts/KeyBinding.test.ts +51 -0
- package/src/shortcuts/KeyBinding.ts +218 -0
- package/src/shortcuts/KeyboardShortcutManager.test.ts +95 -0
- package/src/shortcuts/KeyboardShortcutManager.ts +163 -0
- package/src/shortcuts/lib.ts +3 -0
- package/src/testing/createEditor.ts +11 -0
- package/src/testing/lib.ts +3 -0
- package/src/testing/sendPenEvent.ts +31 -0
- package/src/testing/sendTouchEvent.ts +78 -0
- package/src/toolbar/HTMLToolbar.ts +567 -0
- package/src/toolbar/IconProvider.ts +736 -0
- package/src/toolbar/lib.ts +4 -0
- package/src/toolbar/localization.ts +114 -0
- package/src/toolbar/makeColorInput.ts +159 -0
- package/src/toolbar/types.ts +5 -0
- package/src/toolbar/widgets/ActionButtonWidget.ts +39 -0
- package/src/toolbar/widgets/BaseToolWidget.ts +56 -0
- package/src/toolbar/widgets/BaseWidget.ts +428 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +234 -0
- package/src/toolbar/widgets/EraserToolWidget.ts +85 -0
- package/src/toolbar/widgets/HandToolWidget.ts +250 -0
- package/src/toolbar/widgets/InsertImageWidget.ts +223 -0
- package/src/toolbar/widgets/OverflowWidget.ts +92 -0
- package/src/toolbar/widgets/PenToolWidget.ts +297 -0
- package/src/toolbar/widgets/SelectionToolWidget.ts +193 -0
- package/src/toolbar/widgets/TextToolWidget.ts +145 -0
- package/src/toolbar/widgets/keybindings.ts +21 -0
- package/src/toolbar/widgets/lib.ts +13 -0
- package/src/tools/BaseTool.ts +76 -0
- package/src/tools/Eraser.test.ts +103 -0
- package/src/tools/Eraser.ts +160 -0
- package/src/tools/FindTool.ts +153 -0
- package/src/tools/PanZoom.test.ts +349 -0
- package/src/tools/PanZoom.ts +502 -0
- package/src/tools/PasteHandler.ts +95 -0
- package/src/tools/Pen.test.ts +194 -0
- package/src/tools/Pen.ts +262 -0
- package/src/tools/PipetteTool.ts +55 -0
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +29 -0
- package/src/tools/SelectionTool/Selection.ts +611 -0
- package/src/tools/SelectionTool/SelectionHandle.ts +108 -0
- package/src/tools/SelectionTool/SelectionTool.test.ts +261 -0
- package/src/tools/SelectionTool/SelectionTool.ts +496 -0
- package/src/tools/SelectionTool/TransformMode.ts +114 -0
- package/src/tools/SelectionTool/types.ts +11 -0
- package/src/tools/SoundUITool.ts +212 -0
- package/src/tools/TextTool.ts +340 -0
- package/src/tools/ToolController.ts +185 -0
- package/src/tools/ToolEnabledGroup.ts +14 -0
- package/src/tools/ToolSwitcherShortcut.ts +39 -0
- package/src/tools/ToolbarShortcutHandler.ts +39 -0
- package/src/tools/UndoRedoShortcut.test.ts +56 -0
- package/src/tools/UndoRedoShortcut.ts +24 -0
- package/src/tools/keybindings.ts +85 -0
- package/src/tools/lib.ts +22 -0
- package/src/tools/localization.ts +74 -0
- package/src/types.ts +239 -0
- package/src/util/assertions.ts +55 -0
- package/src/util/fileToBase64.ts +18 -0
- package/src/util/untilNextAnimationFrame.ts +9 -0
- package/src/util/waitForAll.ts +18 -0
- package/src/util/waitForTimeout.ts +9 -0
- package/tools/allLocales.js +4 -0
- package/tools/copyREADME.ts +62 -0
- package/tsconfig.json +2 -32
- package/.eslintrc.js +0 -60
- package/.firebaserc +0 -5
- package/CHANGELOG.md +0 -390
- package/CONTRIBUTING.md +0 -75
- package/LICENSE +0 -21
- package/__mocks__/coloris.ts +0 -8
- package/__mocks__/styleMock.js +0 -1
- package/dist/cjs/src/Color4.js +0 -264
- package/dist/cjs/src/Editor.d.ts +0 -309
- package/dist/cjs/src/Editor.js +0 -922
- package/dist/cjs/src/EditorImage.d.ts +0 -97
- package/dist/cjs/src/EditorImage.js +0 -492
- package/dist/cjs/src/EventDispatcher.d.ts +0 -30
- package/dist/cjs/src/EventDispatcher.js +0 -57
- package/dist/cjs/src/Pointer.d.ts +0 -26
- package/dist/cjs/src/Pointer.js +0 -109
- package/dist/cjs/src/SVGLoader.d.ts +0 -48
- package/dist/cjs/src/SVGLoader.js +0 -537
- package/dist/cjs/src/UndoRedoHistory.js +0 -93
- package/dist/cjs/src/Viewport.d.ts +0 -73
- package/dist/cjs/src/Viewport.js +0 -268
- package/dist/cjs/src/bundle/bundled.js +0 -24
- package/dist/cjs/src/commands/Command.js +0 -34
- package/dist/cjs/src/commands/Duplicate.js +0 -65
- package/dist/cjs/src/commands/Erase.js +0 -83
- package/dist/cjs/src/commands/SerializableCommand.js +0 -42
- package/dist/cjs/src/commands/UnresolvedCommand.js +0 -28
- package/dist/cjs/src/commands/invertCommand.js +0 -55
- package/dist/cjs/src/commands/lib.js +0 -18
- package/dist/cjs/src/commands/localization.d.ts +0 -23
- package/dist/cjs/src/commands/localization.js +0 -24
- package/dist/cjs/src/commands/uniteCommands.js +0 -122
- package/dist/cjs/src/components/AbstractComponent.d.ts +0 -85
- package/dist/cjs/src/components/AbstractComponent.js +0 -273
- package/dist/cjs/src/components/BackgroundComponent.d.ts +0 -62
- package/dist/cjs/src/components/BackgroundComponent.js +0 -316
- package/dist/cjs/src/components/ImageComponent.d.ts +0 -31
- package/dist/cjs/src/components/ImageComponent.js +0 -157
- package/dist/cjs/src/components/RestylableComponent.js +0 -88
- package/dist/cjs/src/components/SVGGlobalAttributesObject.d.ts +0 -21
- package/dist/cjs/src/components/SVGGlobalAttributesObject.js +0 -65
- package/dist/cjs/src/components/Stroke.d.ts +0 -76
- package/dist/cjs/src/components/Stroke.js +0 -238
- package/dist/cjs/src/components/TextComponent.d.ts +0 -63
- package/dist/cjs/src/components/TextComponent.js +0 -280
- package/dist/cjs/src/components/UnknownSVGObject.d.ts +0 -18
- package/dist/cjs/src/components/UnknownSVGObject.js +0 -50
- package/dist/cjs/src/components/builders/ArrowBuilder.d.ts +0 -19
- package/dist/cjs/src/components/builders/ArrowBuilder.js +0 -117
- package/dist/cjs/src/components/builders/FreehandLineBuilder.d.ts +0 -33
- package/dist/cjs/src/components/builders/FreehandLineBuilder.js +0 -173
- package/dist/cjs/src/components/builders/LineBuilder.d.ts +0 -18
- package/dist/cjs/src/components/builders/LineBuilder.js +0 -89
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -36
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.js +0 -347
- package/dist/cjs/src/components/builders/RectangleBuilder.d.ts +0 -20
- package/dist/cjs/src/components/builders/RectangleBuilder.js +0 -59
- package/dist/cjs/src/components/builders/types.d.ts +0 -12
- package/dist/cjs/src/components/lib.d.ts +0 -13
- package/dist/cjs/src/components/lib.js +0 -43
- package/dist/cjs/src/components/localization.js +0 -14
- package/dist/cjs/src/components/util/StrokeSmoother.d.ts +0 -35
- package/dist/cjs/src/components/util/StrokeSmoother.js +0 -225
- package/dist/cjs/src/components/util/describeComponentList.d.ts +0 -4
- package/dist/cjs/src/components/util/describeComponentList.js +0 -16
- package/dist/cjs/src/lib.d.ts +0 -64
- package/dist/cjs/src/lib.js +0 -93
- package/dist/cjs/src/localization.js +0 -13
- package/dist/cjs/src/localizations/de.js +0 -6
- package/dist/cjs/src/localizations/en.js +0 -6
- package/dist/cjs/src/localizations/es.js +0 -20
- package/dist/cjs/src/localizations/getLocalizationTable.d.ts +0 -3
- package/dist/cjs/src/localizations/getLocalizationTable.js +0 -50
- package/dist/cjs/src/math/LineSegment2.d.ts +0 -26
- package/dist/cjs/src/math/LineSegment2.js +0 -135
- package/dist/cjs/src/math/Mat33.d.ts +0 -118
- package/dist/cjs/src/math/Mat33.js +0 -332
- package/dist/cjs/src/math/Path.d.ts +0 -92
- package/dist/cjs/src/math/Path.js +0 -876
- package/dist/cjs/src/math/Rect2.d.ts +0 -52
- package/dist/cjs/src/math/Rect2.js +0 -235
- package/dist/cjs/src/math/Triangle.d.ts +0 -11
- package/dist/cjs/src/math/Triangle.js +0 -22
- package/dist/cjs/src/math/Vec2.js +0 -39
- package/dist/cjs/src/math/Vec3.js +0 -177
- package/dist/cjs/src/math/lib.d.ts +0 -7
- package/dist/cjs/src/math/lib.js +0 -18
- package/dist/cjs/src/math/polynomial/QuadraticBezier.d.ts +0 -28
- package/dist/cjs/src/math/polynomial/QuadraticBezier.js +0 -114
- package/dist/cjs/src/math/polynomial/solveQuadratic.d.ts +0 -6
- package/dist/cjs/src/math/polynomial/solveQuadratic.js +0 -36
- package/dist/cjs/src/math/rounding.js +0 -135
- package/dist/cjs/src/rendering/Display.js +0 -213
- package/dist/cjs/src/rendering/RenderingStyle.d.ts +0 -31
- package/dist/cjs/src/rendering/RenderingStyle.js +0 -48
- package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +0 -36
- package/dist/cjs/src/rendering/TextRenderingStyle.js +0 -29
- package/dist/cjs/src/rendering/caching/CacheRecord.d.ts +0 -20
- package/dist/cjs/src/rendering/caching/CacheRecord.js +0 -61
- package/dist/cjs/src/rendering/caching/CacheRecordManager.d.ts +0 -12
- package/dist/cjs/src/rendering/caching/CacheRecordManager.js +0 -50
- package/dist/cjs/src/rendering/caching/RenderingCache.js +0 -51
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.d.ts +0 -29
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.js +0 -326
- package/dist/cjs/src/rendering/caching/testUtils.js +0 -27
- package/dist/cjs/src/rendering/lib.js +0 -17
- package/dist/cjs/src/rendering/localization.js +0 -12
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +0 -85
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.js +0 -188
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +0 -63
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +0 -243
- package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +0 -35
- package/dist/cjs/src/rendering/renderers/DummyRenderer.js +0 -112
- package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +0 -57
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +0 -320
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +0 -29
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.js +0 -63
- package/dist/cjs/src/testing/beforeEachFile.js +0 -12
- package/dist/cjs/src/testing/createEditor.js +0 -14
- package/dist/cjs/src/testing/lib.js +0 -10
- package/dist/cjs/src/testing/loadExpectExtensions.d.ts +0 -2
- package/dist/cjs/src/testing/loadExpectExtensions.js +0 -28
- package/dist/cjs/src/testing/sendPenEvent.js +0 -24
- package/dist/cjs/src/testing/sendTouchEvent.js +0 -87
- package/dist/cjs/src/toolbar/HTMLToolbar.js +0 -449
- package/dist/cjs/src/toolbar/IconProvider.js +0 -660
- package/dist/cjs/src/toolbar/lib.js +0 -24
- package/dist/cjs/src/toolbar/localization.d.ts +0 -51
- package/dist/cjs/src/toolbar/localization.js +0 -53
- package/dist/cjs/src/toolbar/makeColorInput.js +0 -128
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.js +0 -31
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +0 -49
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +0 -351
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +0 -201
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +0 -63
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.js +0 -201
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +0 -176
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.js +0 -77
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +0 -226
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.js +0 -153
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +0 -115
- package/dist/cjs/src/toolbar/widgets/lib.js +0 -26
- package/dist/cjs/src/tools/BaseTool.js +0 -66
- package/dist/cjs/src/tools/Eraser.d.ts +0 -23
- package/dist/cjs/src/tools/Eraser.js +0 -112
- package/dist/cjs/src/tools/FindTool.d.ts +0 -21
- package/dist/cjs/src/tools/FindTool.js +0 -121
- package/dist/cjs/src/tools/PanZoom.d.ts +0 -52
- package/dist/cjs/src/tools/PanZoom.js +0 -421
- package/dist/cjs/src/tools/PasteHandler.js +0 -99
- package/dist/cjs/src/tools/Pen.d.ts +0 -43
- package/dist/cjs/src/tools/Pen.js +0 -202
- package/dist/cjs/src/tools/PipetteTool.js +0 -45
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -8
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.js +0 -28
- package/dist/cjs/src/tools/SelectionTool/Selection.d.ts +0 -64
- package/dist/cjs/src/tools/SelectionTool/Selection.js +0 -491
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.js +0 -85
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.d.ts +0 -37
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +0 -413
- package/dist/cjs/src/tools/SelectionTool/TransformMode.js +0 -107
- package/dist/cjs/src/tools/SelectionTool/types.js +0 -14
- package/dist/cjs/src/tools/SoundUITool.js +0 -164
- package/dist/cjs/src/tools/TextTool.d.ts +0 -33
- package/dist/cjs/src/tools/TextTool.js +0 -262
- package/dist/cjs/src/tools/ToolController.js +0 -192
- package/dist/cjs/src/tools/ToolEnabledGroup.js +0 -14
- package/dist/cjs/src/tools/ToolSwitcherShortcut.js +0 -38
- package/dist/cjs/src/tools/ToolbarShortcutHandler.js +0 -29
- package/dist/cjs/src/tools/UndoRedoShortcut.d.ts +0 -8
- package/dist/cjs/src/tools/UndoRedoShortcut.js +0 -28
- package/dist/cjs/src/tools/lib.js +0 -38
- package/dist/cjs/src/tools/localization.js +0 -33
- package/dist/cjs/src/types.d.ts +0 -153
- package/dist/cjs/src/types.js +0 -38
- package/dist/cjs/src/util/assertions.js +0 -51
- package/dist/cjs/src/util/fileToBase64.js +0 -15
- package/dist/cjs/src/util/untilNextAnimationFrame.js +0 -9
- package/dist/cjs/src/util/waitForAll.js +0 -17
- package/dist/cjs/src/util/waitForTimeout.js +0 -9
- package/dist/mjs/src/Color4.mjs +0 -258
- package/dist/mjs/src/Editor.d.ts +0 -309
- package/dist/mjs/src/Editor.mjs +0 -892
- package/dist/mjs/src/EditorImage.d.ts +0 -97
- package/dist/mjs/src/EditorImage.mjs +0 -485
- package/dist/mjs/src/EventDispatcher.d.ts +0 -30
- package/dist/mjs/src/EventDispatcher.mjs +0 -54
- package/dist/mjs/src/Pointer.d.ts +0 -26
- package/dist/mjs/src/Pointer.mjs +0 -105
- package/dist/mjs/src/SVGLoader.d.ts +0 -48
- package/dist/mjs/src/SVGLoader.mjs +0 -507
- package/dist/mjs/src/UndoRedoHistory.mjs +0 -91
- package/dist/mjs/src/Viewport.d.ts +0 -73
- package/dist/mjs/src/Viewport.mjs +0 -261
- package/dist/mjs/src/commands/Command.mjs +0 -31
- package/dist/mjs/src/commands/Duplicate.mjs +0 -59
- package/dist/mjs/src/commands/Erase.mjs +0 -77
- package/dist/mjs/src/commands/SerializableCommand.mjs +0 -37
- package/dist/mjs/src/commands/UnresolvedCommand.mjs +0 -22
- package/dist/mjs/src/commands/invertCommand.mjs +0 -50
- package/dist/mjs/src/commands/localization.d.ts +0 -23
- package/dist/mjs/src/commands/localization.mjs +0 -21
- package/dist/mjs/src/commands/uniteCommands.mjs +0 -117
- package/dist/mjs/src/components/AbstractComponent.d.ts +0 -85
- package/dist/mjs/src/components/AbstractComponent.mjs +0 -268
- package/dist/mjs/src/components/BackgroundComponent.d.ts +0 -62
- package/dist/mjs/src/components/BackgroundComponent.mjs +0 -286
- package/dist/mjs/src/components/ImageComponent.d.ts +0 -31
- package/dist/mjs/src/components/ImageComponent.mjs +0 -151
- package/dist/mjs/src/components/RestylableComponent.mjs +0 -80
- package/dist/mjs/src/components/SVGGlobalAttributesObject.d.ts +0 -21
- package/dist/mjs/src/components/SVGGlobalAttributesObject.mjs +0 -59
- package/dist/mjs/src/components/Stroke.d.ts +0 -76
- package/dist/mjs/src/components/Stroke.mjs +0 -232
- package/dist/mjs/src/components/TextComponent.d.ts +0 -63
- package/dist/mjs/src/components/TextComponent.mjs +0 -275
- package/dist/mjs/src/components/UnknownSVGObject.d.ts +0 -18
- package/dist/mjs/src/components/UnknownSVGObject.mjs +0 -44
- package/dist/mjs/src/components/builders/ArrowBuilder.d.ts +0 -19
- package/dist/mjs/src/components/builders/ArrowBuilder.mjs +0 -86
- package/dist/mjs/src/components/builders/FreehandLineBuilder.d.ts +0 -33
- package/dist/mjs/src/components/builders/FreehandLineBuilder.mjs +0 -165
- package/dist/mjs/src/components/builders/LineBuilder.d.ts +0 -18
- package/dist/mjs/src/components/builders/LineBuilder.mjs +0 -58
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -36
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.mjs +0 -339
- package/dist/mjs/src/components/builders/RectangleBuilder.d.ts +0 -20
- package/dist/mjs/src/components/builders/RectangleBuilder.mjs +0 -50
- package/dist/mjs/src/components/builders/types.d.ts +0 -12
- package/dist/mjs/src/components/lib.d.ts +0 -13
- package/dist/mjs/src/components/lib.mjs +0 -14
- package/dist/mjs/src/components/localization.mjs +0 -11
- package/dist/mjs/src/components/util/StrokeSmoother.d.ts +0 -35
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +0 -218
- package/dist/mjs/src/components/util/describeComponentList.d.ts +0 -4
- package/dist/mjs/src/components/util/describeComponentList.mjs +0 -14
- package/dist/mjs/src/lib.d.ts +0 -64
- package/dist/mjs/src/lib.mjs +0 -64
- package/dist/mjs/src/localization.mjs +0 -10
- package/dist/mjs/src/localizations/de.mjs +0 -4
- package/dist/mjs/src/localizations/en.mjs +0 -4
- package/dist/mjs/src/localizations/es.mjs +0 -18
- package/dist/mjs/src/localizations/getLocalizationTable.d.ts +0 -3
- package/dist/mjs/src/localizations/getLocalizationTable.mjs +0 -45
- package/dist/mjs/src/math/LineSegment2.d.ts +0 -26
- package/dist/mjs/src/math/LineSegment2.mjs +0 -129
- package/dist/mjs/src/math/Mat33.d.ts +0 -118
- package/dist/mjs/src/math/Mat33.mjs +0 -327
- package/dist/mjs/src/math/Path.d.ts +0 -92
- package/dist/mjs/src/math/Path.mjs +0 -870
- package/dist/mjs/src/math/Rect2.d.ts +0 -52
- package/dist/mjs/src/math/Rect2.mjs +0 -230
- package/dist/mjs/src/math/Triangle.d.ts +0 -11
- package/dist/mjs/src/math/Triangle.mjs +0 -19
- package/dist/mjs/src/math/Vec2.mjs +0 -33
- package/dist/mjs/src/math/Vec3.mjs +0 -175
- package/dist/mjs/src/math/lib.d.ts +0 -7
- package/dist/mjs/src/math/lib.mjs +0 -7
- package/dist/mjs/src/math/polynomial/QuadraticBezier.d.ts +0 -28
- package/dist/mjs/src/math/polynomial/QuadraticBezier.mjs +0 -108
- package/dist/mjs/src/math/polynomial/solveQuadratic.d.ts +0 -6
- package/dist/mjs/src/math/polynomial/solveQuadratic.mjs +0 -34
- package/dist/mjs/src/math/rounding.mjs +0 -128
- package/dist/mjs/src/rendering/Display.mjs +0 -206
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +0 -31
- package/dist/mjs/src/rendering/RenderingStyle.mjs +0 -38
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +0 -36
- package/dist/mjs/src/rendering/TextRenderingStyle.mjs +0 -23
- package/dist/mjs/src/rendering/caching/CacheRecord.d.ts +0 -20
- package/dist/mjs/src/rendering/caching/CacheRecord.mjs +0 -55
- package/dist/mjs/src/rendering/caching/CacheRecordManager.d.ts +0 -12
- package/dist/mjs/src/rendering/caching/CacheRecordManager.mjs +0 -43
- package/dist/mjs/src/rendering/caching/RenderingCache.mjs +0 -45
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.d.ts +0 -29
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.mjs +0 -320
- package/dist/mjs/src/rendering/caching/testUtils.mjs +0 -20
- package/dist/mjs/src/rendering/localization.mjs +0 -9
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +0 -85
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.mjs +0 -162
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +0 -63
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +0 -237
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +0 -35
- package/dist/mjs/src/rendering/renderers/DummyRenderer.mjs +0 -106
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +0 -57
- package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +0 -313
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +0 -29
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.mjs +0 -57
- package/dist/mjs/src/testing/beforeEachFile.mjs +0 -7
- package/dist/mjs/src/testing/createEditor.mjs +0 -9
- package/dist/mjs/src/testing/loadExpectExtensions.d.ts +0 -2
- package/dist/mjs/src/testing/loadExpectExtensions.mjs +0 -24
- package/dist/mjs/src/testing/sendPenEvent.mjs +0 -19
- package/dist/mjs/src/testing/sendTouchEvent.mjs +0 -62
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +0 -443
- package/dist/mjs/src/toolbar/IconProvider.mjs +0 -654
- package/dist/mjs/src/toolbar/localization.d.ts +0 -51
- package/dist/mjs/src/toolbar/localization.mjs +0 -50
- package/dist/mjs/src/toolbar/makeColorInput.mjs +0 -121
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.mjs +0 -25
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +0 -43
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +0 -345
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +0 -173
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +0 -58
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.mjs +0 -172
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +0 -171
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.mjs +0 -71
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +0 -221
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.mjs +0 -147
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +0 -110
- package/dist/mjs/src/tools/BaseTool.mjs +0 -63
- package/dist/mjs/src/tools/Eraser.d.ts +0 -23
- package/dist/mjs/src/tools/Eraser.mjs +0 -106
- package/dist/mjs/src/tools/FindTool.d.ts +0 -21
- package/dist/mjs/src/tools/FindTool.mjs +0 -114
- package/dist/mjs/src/tools/PanZoom.d.ts +0 -52
- package/dist/mjs/src/tools/PanZoom.mjs +0 -414
- package/dist/mjs/src/tools/PasteHandler.mjs +0 -93
- package/dist/mjs/src/tools/Pen.d.ts +0 -43
- package/dist/mjs/src/tools/Pen.mjs +0 -196
- package/dist/mjs/src/tools/PipetteTool.mjs +0 -39
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -8
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.mjs +0 -22
- package/dist/mjs/src/tools/SelectionTool/Selection.d.ts +0 -64
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +0 -463
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.mjs +0 -81
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.d.ts +0 -37
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +0 -407
- package/dist/mjs/src/tools/SelectionTool/TransformMode.mjs +0 -98
- package/dist/mjs/src/tools/SoundUITool.mjs +0 -158
- package/dist/mjs/src/tools/TextTool.d.ts +0 -33
- package/dist/mjs/src/tools/TextTool.mjs +0 -256
- package/dist/mjs/src/tools/ToolController.mjs +0 -163
- package/dist/mjs/src/tools/ToolEnabledGroup.mjs +0 -11
- package/dist/mjs/src/tools/ToolSwitcherShortcut.mjs +0 -32
- package/dist/mjs/src/tools/ToolbarShortcutHandler.mjs +0 -23
- package/dist/mjs/src/tools/UndoRedoShortcut.d.ts +0 -8
- package/dist/mjs/src/tools/UndoRedoShortcut.mjs +0 -22
- package/dist/mjs/src/tools/localization.mjs +0 -30
- package/dist/mjs/src/types.d.ts +0 -153
- package/dist/mjs/src/util/assertions.mjs +0 -45
- package/dist/mjs/src/util/fileToBase64.mjs +0 -13
- package/dist/mjs/src/util/untilNextAnimationFrame.mjs +0 -7
- package/dist/mjs/src/util/waitForAll.mjs +0 -15
- package/dist/mjs/src/util/waitForTimeout.mjs +0 -7
- package/firebase.json +0 -16
- package/jest.config.js +0 -29
- package/lint-staged.config.js +0 -6
- package/tsconfig-typedoc.json +0 -7
- package/tsconfig.mjs.json +0 -9
- package/typedoc.json +0 -25
- /package/dist/cjs/{src/Color4.d.ts → Color4.d.ts} +0 -0
- /package/dist/cjs/{src/testing/beforeEachFile.d.ts → Color4.test.d.ts} +0 -0
- /package/dist/{mjs/src/components/builders/types.mjs → cjs/Editor.loadFrom.test.d.ts} +0 -0
- /package/dist/{mjs/src/rendering/caching/types.mjs → cjs/Editor.toSVG.test.d.ts} +0 -0
- /package/dist/{mjs/src/testing/beforeEachFile.d.ts → cjs/EditorImage.test.d.ts} +0 -0
- /package/dist/{mjs/src/toolbar/types.mjs → cjs/EventDispatcher.test.d.ts} +0 -0
- /package/dist/cjs/{src/UndoRedoHistory.d.ts → UndoRedoHistory.d.ts} +0 -0
- /package/dist/cjs/{src/bundle → bundle}/bundled.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/Command.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/Duplicate.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/Erase.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/SerializableCommand.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/UnresolvedCommand.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/invertCommand.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/lib.d.ts +0 -0
- /package/dist/cjs/{src/commands → commands}/uniteCommands.d.ts +0 -0
- /package/dist/cjs/{src/components → components}/RestylableComponent.d.ts +0 -0
- /package/dist/cjs/{src/components → components}/builders/types.js +0 -0
- /package/dist/cjs/{src/components → components}/localization.d.ts +0 -0
- /package/dist/cjs/{src/localization.d.ts → localization.d.ts} +0 -0
- /package/dist/cjs/{src/localizations → localizations}/de.d.ts +0 -0
- /package/dist/cjs/{src/localizations → localizations}/en.d.ts +0 -0
- /package/dist/cjs/{src/localizations → localizations}/es.d.ts +0 -0
- /package/dist/cjs/{src/math → math}/Vec2.d.ts +0 -0
- /package/dist/cjs/{src/math → math}/Vec3.d.ts +0 -0
- /package/dist/cjs/{src/math → math}/rounding.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/Display.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/caching/RenderingCache.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/caching/testUtils.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/caching/types.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/caching/types.js +0 -0
- /package/dist/cjs/{src/rendering → rendering}/lib.d.ts +0 -0
- /package/dist/cjs/{src/rendering → rendering}/localization.d.ts +0 -0
- /package/dist/cjs/{src/testing → testing}/createEditor.d.ts +0 -0
- /package/dist/cjs/{src/testing → testing}/lib.d.ts +0 -0
- /package/dist/cjs/{src/testing → testing}/sendPenEvent.d.ts +0 -0
- /package/dist/cjs/{src/testing → testing}/sendTouchEvent.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/HTMLToolbar.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/IconProvider.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/lib.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/makeColorInput.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/types.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/types.js +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/ActionButtonWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/BaseToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/BaseWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/DocumentPropertiesWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/EraserToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/HandToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/InsertImageWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/OverflowWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/PenToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/SelectionToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/TextToolWidget.d.ts +0 -0
- /package/dist/cjs/{src/toolbar → toolbar}/widgets/lib.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/BaseTool.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/PasteHandler.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/PipetteTool.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/SelectionTool/SelectionHandle.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/SelectionTool/TransformMode.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/SelectionTool/types.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/SoundUITool.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ToolController.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ToolEnabledGroup.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ToolSwitcherShortcut.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ToolbarShortcutHandler.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/lib.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/localization.d.ts +0 -0
- /package/dist/cjs/{src/util → util}/assertions.d.ts +0 -0
- /package/dist/cjs/{src/util → util}/fileToBase64.d.ts +0 -0
- /package/dist/cjs/{src/util → util}/untilNextAnimationFrame.d.ts +0 -0
- /package/dist/cjs/{src/util → util}/waitForAll.d.ts +0 -0
- /package/dist/cjs/{src/util → util}/waitForTimeout.d.ts +0 -0
- /package/dist/mjs/{src/Color4.d.ts → Color4.d.ts} +0 -0
- /package/dist/mjs/{src/UndoRedoHistory.d.ts → UndoRedoHistory.d.ts} +0 -0
- /package/dist/mjs/{src/bundle → bundle}/bundled.d.ts +0 -0
- /package/dist/mjs/{src/bundle → bundle}/bundled.mjs +0 -0
- /package/dist/mjs/{src/commands → commands}/Command.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/Duplicate.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/Erase.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/SerializableCommand.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/UnresolvedCommand.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/invertCommand.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/lib.d.ts +0 -0
- /package/dist/mjs/{src/commands → commands}/lib.mjs +0 -0
- /package/dist/mjs/{src/commands → commands}/uniteCommands.d.ts +0 -0
- /package/dist/mjs/{src/components → components}/RestylableComponent.d.ts +0 -0
- /package/dist/mjs/{src/components → components}/localization.d.ts +0 -0
- /package/dist/mjs/{src/localization.d.ts → localization.d.ts} +0 -0
- /package/dist/mjs/{src/localizations → localizations}/de.d.ts +0 -0
- /package/dist/mjs/{src/localizations → localizations}/en.d.ts +0 -0
- /package/dist/mjs/{src/localizations → localizations}/es.d.ts +0 -0
- /package/dist/mjs/{src/math → math}/Vec2.d.ts +0 -0
- /package/dist/mjs/{src/math → math}/Vec3.d.ts +0 -0
- /package/dist/mjs/{src/math → math}/rounding.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/Display.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/caching/RenderingCache.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/caching/testUtils.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/caching/types.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/lib.d.ts +0 -0
- /package/dist/mjs/{src/rendering → rendering}/lib.mjs +0 -0
- /package/dist/mjs/{src/rendering → rendering}/localization.d.ts +0 -0
- /package/dist/mjs/{src/testing → testing}/createEditor.d.ts +0 -0
- /package/dist/mjs/{src/testing → testing}/lib.d.ts +0 -0
- /package/dist/mjs/{src/testing → testing}/lib.mjs +0 -0
- /package/dist/mjs/{src/testing → testing}/sendPenEvent.d.ts +0 -0
- /package/dist/mjs/{src/testing → testing}/sendTouchEvent.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/HTMLToolbar.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/IconProvider.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/lib.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/lib.mjs +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/makeColorInput.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/types.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/ActionButtonWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/BaseToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/BaseWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/DocumentPropertiesWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/EraserToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/HandToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/InsertImageWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/OverflowWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/PenToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/SelectionToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/TextToolWidget.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/lib.d.ts +0 -0
- /package/dist/mjs/{src/toolbar → toolbar}/widgets/lib.mjs +0 -0
- /package/dist/mjs/{src/tools → tools}/BaseTool.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/PasteHandler.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/PipetteTool.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/SelectionTool/SelectionHandle.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/SelectionTool/TransformMode.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/SelectionTool/types.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/SelectionTool/types.mjs +0 -0
- /package/dist/mjs/{src/tools → tools}/SoundUITool.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/ToolController.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/ToolEnabledGroup.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/ToolSwitcherShortcut.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/ToolbarShortcutHandler.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/lib.d.ts +0 -0
- /package/dist/mjs/{src/tools → tools}/lib.mjs +0 -0
- /package/dist/mjs/{src/tools → tools}/localization.d.ts +0 -0
- /package/dist/mjs/{src/types.mjs → types.mjs} +0 -0
- /package/dist/mjs/{src/util → util}/assertions.d.ts +0 -0
- /package/dist/mjs/{src/util → util}/fileToBase64.d.ts +0 -0
- /package/dist/mjs/{src/util → util}/untilNextAnimationFrame.d.ts +0 -0
- /package/dist/mjs/{src/util → util}/waitForAll.d.ts +0 -0
- /package/dist/mjs/{src/util → util}/waitForTimeout.d.ts +0 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
import Color4 from '../Color4';
|
2
|
+
import EditorImage from '../EditorImage';
|
3
|
+
import Mat33 from '../math/Mat33';
|
4
|
+
import { Vec2 } from '../math/Vec2';
|
5
|
+
import TextRenderingStyle from '../rendering/TextRenderingStyle';
|
6
|
+
import createEditor from '../testing/createEditor';
|
7
|
+
import AbstractComponent from './AbstractComponent';
|
8
|
+
import TextComponent, { TextTransformMode } from './TextComponent';
|
9
|
+
|
10
|
+
|
11
|
+
describe('TextComponent', () => {
|
12
|
+
it('should be serializable', () => {
|
13
|
+
const style: TextRenderingStyle = {
|
14
|
+
size: 12,
|
15
|
+
fontFamily: 'serif',
|
16
|
+
renderingStyle: { fill: Color4.black },
|
17
|
+
};
|
18
|
+
const text = new TextComponent([ 'Foo' ], Mat33.identity, style);
|
19
|
+
const serialized = text.serialize();
|
20
|
+
const deserialized = AbstractComponent.deserialize(serialized) as TextComponent;
|
21
|
+
expect(deserialized.getBBox()).objEq(text.getBBox());
|
22
|
+
expect(deserialized['getText']()).toContain('Foo');
|
23
|
+
});
|
24
|
+
|
25
|
+
it('should be deserializable', () => {
|
26
|
+
const textComponent = TextComponent.deserializeFromString(`{
|
27
|
+
"textObjects": [ { "text": "Foo" } ],
|
28
|
+
"transform": [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ],
|
29
|
+
"style": {
|
30
|
+
"fontFamily": "sans",
|
31
|
+
"size": 10,
|
32
|
+
"renderingStyle": { "fill": "#000" }
|
33
|
+
}
|
34
|
+
}`);
|
35
|
+
|
36
|
+
expect(textComponent.getText()).toBe('Foo');
|
37
|
+
expect(textComponent.getTransform()).objEq(Mat33.identity);
|
38
|
+
expect(textComponent.getStyle().color!).objEq(Color4.black);
|
39
|
+
expect(textComponent.getTextStyle().fontFamily!).toBe('sans');
|
40
|
+
});
|
41
|
+
|
42
|
+
it('should be restylable', () => {
|
43
|
+
const style: TextRenderingStyle = {
|
44
|
+
size: 10,
|
45
|
+
fontFamily: 'sans',
|
46
|
+
renderingStyle: { fill: Color4.red },
|
47
|
+
};
|
48
|
+
const text = new TextComponent([ 'Foo' ], Mat33.identity, style);
|
49
|
+
|
50
|
+
expect(text.getStyle().color).objEq(Color4.red);
|
51
|
+
text.forceStyle({
|
52
|
+
color: Color4.green,
|
53
|
+
}, null);
|
54
|
+
expect(text.getStyle().color).objEq(Color4.green);
|
55
|
+
expect(text.getTextStyle().renderingStyle.fill).objEq(Color4.green);
|
56
|
+
|
57
|
+
const restyleCommand = text.updateStyle({
|
58
|
+
color: Color4.purple,
|
59
|
+
});
|
60
|
+
|
61
|
+
// Should queue a re-render after restyling.
|
62
|
+
const editor = createEditor();
|
63
|
+
EditorImage.addElement(text).apply(editor);
|
64
|
+
|
65
|
+
editor.rerender();
|
66
|
+
expect(editor.isRerenderQueued()).toBe(false);
|
67
|
+
editor.dispatch(restyleCommand);
|
68
|
+
expect(editor.isRerenderQueued()).toBe(true);
|
69
|
+
|
70
|
+
// Undoing should reset to the correct color.
|
71
|
+
expect(text.getStyle().color).objEq(Color4.purple);
|
72
|
+
editor.history.undo();
|
73
|
+
expect(text.getStyle().color).objEq(Color4.green);
|
74
|
+
});
|
75
|
+
|
76
|
+
it('calling forceStyle on the duplicate of a TextComponent should preserve the original\'s style', () => {
|
77
|
+
const originalStyle: TextRenderingStyle = {
|
78
|
+
size: 11,
|
79
|
+
fontFamily: 'sans-serif',
|
80
|
+
renderingStyle: { fill: Color4.purple, },
|
81
|
+
};
|
82
|
+
|
83
|
+
const text1 = new TextComponent([ 'Test' ], Mat33.identity, originalStyle);
|
84
|
+
const text2 = text1.clone() as TextComponent;
|
85
|
+
|
86
|
+
text1.forceStyle({
|
87
|
+
color: Color4.red,
|
88
|
+
}, null);
|
89
|
+
|
90
|
+
expect(text2.getStyle().color).objEq(Color4.purple);
|
91
|
+
expect(text1.getStyle().color).objEq(Color4.red);
|
92
|
+
|
93
|
+
text2.forceStyle({
|
94
|
+
textStyle: originalStyle,
|
95
|
+
}, null);
|
96
|
+
|
97
|
+
expect(text1.getStyle().color).objEq(Color4.red);
|
98
|
+
expect(text2.getTextStyle()).toMatchObject(originalStyle);
|
99
|
+
});
|
100
|
+
|
101
|
+
describe('should position text components relatively or absolutely (bounding box tests)', () => {
|
102
|
+
const baseStyle: TextRenderingStyle = {
|
103
|
+
size: 12,
|
104
|
+
fontFamily: 'sans-serif',
|
105
|
+
renderingStyle: { fill: Color4.red },
|
106
|
+
};
|
107
|
+
|
108
|
+
it('strings should be placed relative to one another', () => {
|
109
|
+
const str1 = 'test';
|
110
|
+
const str2 = 'test2';
|
111
|
+
|
112
|
+
const container = new TextComponent([ str1, str2 ], Mat33.identity, baseStyle);
|
113
|
+
|
114
|
+
// Create separate components for str1 and str2 so we can check their individual bounding boxes
|
115
|
+
const str1Component = new TextComponent([ str1 ], Mat33.identity, baseStyle);
|
116
|
+
const str2Component = new TextComponent([ str2 ], Mat33.identity, baseStyle);
|
117
|
+
|
118
|
+
const widthSum = str1Component.getBBox().width + str2Component.getBBox().width;
|
119
|
+
const maxHeight = Math.max(str1Component.getBBox().height, str2Component.getBBox().height);
|
120
|
+
expect(container.getBBox().size).objEq(Vec2.of(widthSum, maxHeight));
|
121
|
+
});
|
122
|
+
|
123
|
+
it('RELATIVE_X_ABSOLUTE_Y should work (relatively positioned along x, absolutely along y)', () => {
|
124
|
+
const component1 = new TextComponent([ 'test' ], Mat33.identity, baseStyle);
|
125
|
+
|
126
|
+
const componentTranslation = Vec2.of(10, 10);
|
127
|
+
const component2 = new TextComponent(
|
128
|
+
[ 'relatively' ],
|
129
|
+
Mat33.translation(componentTranslation),
|
130
|
+
baseStyle,
|
131
|
+
TextTransformMode.RELATIVE_X_ABSOLUTE_Y
|
132
|
+
);
|
133
|
+
|
134
|
+
const component3 = new TextComponent(
|
135
|
+
[ 'more of a test...' ],
|
136
|
+
Mat33.translation(componentTranslation),
|
137
|
+
baseStyle,
|
138
|
+
TextTransformMode.RELATIVE_X_ABSOLUTE_Y
|
139
|
+
);
|
140
|
+
|
141
|
+
|
142
|
+
const container = new TextComponent([ component1, component2, component3 ], Mat33.identity, baseStyle);
|
143
|
+
const expectedWidth =
|
144
|
+
component1.getBBox().width
|
145
|
+
// x should take the translation from each component into account.
|
146
|
+
+ componentTranslation.x + component2.getBBox().width
|
147
|
+
+ componentTranslation.x + component3.getBBox().width;
|
148
|
+
const expectedHeight = Math.max(
|
149
|
+
component1.getBBox().height,
|
150
|
+
|
151
|
+
// Absolute y: Should *not* take into account both components' y translations
|
152
|
+
componentTranslation.y + component3.getBBox().height
|
153
|
+
);
|
154
|
+
expect(container.getBBox().size).objEq(Vec2.of(expectedWidth, expectedHeight));
|
155
|
+
});
|
156
|
+
|
157
|
+
it('RELATIVE_Y_ABSOLUTE_X should work (relatively positioned along y, absolutely along x)', () => {
|
158
|
+
const firstComponentTranslation = Vec2.of(1000, 1000);
|
159
|
+
const component1 = new TextComponent(
|
160
|
+
[ '...' ],
|
161
|
+
|
162
|
+
// The translation of the first component shouldn't affect the Y size of the bounding box.
|
163
|
+
Mat33.translation(firstComponentTranslation),
|
164
|
+
|
165
|
+
baseStyle);
|
166
|
+
|
167
|
+
const componentTranslation = Vec2.of(10, 20);
|
168
|
+
const component2 = new TextComponent(
|
169
|
+
[ 'Test!' ],
|
170
|
+
Mat33.translation(componentTranslation),
|
171
|
+
baseStyle,
|
172
|
+
TextTransformMode.RELATIVE_Y_ABSOLUTE_X
|
173
|
+
);
|
174
|
+
|
175
|
+
const component3 = new TextComponent(
|
176
|
+
[ 'Even more of a test.' ],
|
177
|
+
Mat33.translation(componentTranslation),
|
178
|
+
baseStyle,
|
179
|
+
TextTransformMode.RELATIVE_Y_ABSOLUTE_X
|
180
|
+
);
|
181
|
+
|
182
|
+
|
183
|
+
const container = new TextComponent([ component1, component2, component3 ], Mat33.identity, baseStyle);
|
184
|
+
const expectedWidth =
|
185
|
+
component1.getBBox().width
|
186
|
+
|
187
|
+
// Space between the start of components 2 and 3 and the start of component 1
|
188
|
+
+ firstComponentTranslation.x - componentTranslation.x;
|
189
|
+
|
190
|
+
const expectedHeight =
|
191
|
+
// Don't include component1.bbox.height: component1 overlaps with component 2 completely in y
|
192
|
+
// similarly, component 2 overlaps completely with component3 in y.
|
193
|
+
//
|
194
|
+
// Note that while relative positioning is relative to the right edge of the baseline of the previous
|
195
|
+
// item (when in left-to-right mode). Thus, x is adjusted automatically by the text width, while
|
196
|
+
// y remains the same (if there is no additional translation).
|
197
|
+
+ componentTranslation.y
|
198
|
+
+ componentTranslation.y
|
199
|
+
+ component3.getBBox().height;
|
200
|
+
|
201
|
+
expect(container.getBBox().size).objEq(Vec2.of(expectedWidth, expectedHeight));
|
202
|
+
});
|
203
|
+
});
|
204
|
+
});
|
@@ -0,0 +1,432 @@
|
|
1
|
+
import SerializableCommand from '../commands/SerializableCommand';
|
2
|
+
import LineSegment2 from '../math/shapes/LineSegment2';
|
3
|
+
import Mat33, { Mat33Array } from '../math/Mat33';
|
4
|
+
import Rect2 from '../math/shapes/Rect2';
|
5
|
+
import Editor from '../Editor';
|
6
|
+
import { Vec2 } from '../math/Vec2';
|
7
|
+
import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
|
8
|
+
import { cloneTextStyle, TextRenderingStyle, textStyleFromJSON, textStyleToJSON } from '../rendering/TextRenderingStyle';
|
9
|
+
import AbstractComponent from './AbstractComponent';
|
10
|
+
import { ImageComponentLocalization } from './localization';
|
11
|
+
import RestyleableComponent, { ComponentStyle, createRestyleComponentCommand } from './RestylableComponent';
|
12
|
+
|
13
|
+
const componentTypeId = 'text';
|
14
|
+
|
15
|
+
export enum TextTransformMode {
|
16
|
+
/** Absolutely positioned in both the X and Y dimensions. */
|
17
|
+
ABSOLUTE_XY,
|
18
|
+
|
19
|
+
/** Relatively positioned in both the X and Y dimensions. */
|
20
|
+
RELATIVE_XY,
|
21
|
+
|
22
|
+
/**Relatively positioned in the X direction, absolutely positioned in the Y direction. */
|
23
|
+
RELATIVE_X_ABSOLUTE_Y,
|
24
|
+
|
25
|
+
/**Relatively positioned in the Y direction, absolutely positioned in the X direction. */
|
26
|
+
RELATIVE_Y_ABSOLUTE_X,
|
27
|
+
}
|
28
|
+
|
29
|
+
type TextElement = TextComponent|string;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Displays text.
|
33
|
+
*/
|
34
|
+
export default class TextComponent extends AbstractComponent implements RestyleableComponent {
|
35
|
+
protected contentBBox: Rect2;
|
36
|
+
|
37
|
+
// eslint-disable-next-line @typescript-eslint/prefer-as-const
|
38
|
+
readonly isRestylableComponent: true = true;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Creates a new text object from a list of component text or child TextComponents.
|
42
|
+
*
|
43
|
+
* @see {@link fromLines}
|
44
|
+
*/
|
45
|
+
public constructor(
|
46
|
+
protected readonly textObjects: Array<TextElement>,
|
47
|
+
|
48
|
+
// Transformation relative to this component's parent element.
|
49
|
+
private transform: Mat33,
|
50
|
+
private style: TextRenderingStyle,
|
51
|
+
|
52
|
+
// @internal
|
53
|
+
private transformMode: TextTransformMode = TextTransformMode.ABSOLUTE_XY,
|
54
|
+
) {
|
55
|
+
super(componentTypeId);
|
56
|
+
this.recomputeBBox();
|
57
|
+
|
58
|
+
// If this has no direct children, choose a style representative of this' content
|
59
|
+
// (useful for estimating the style of the TextComponent).
|
60
|
+
const hasDirectContent = textObjects.some(obj => typeof obj === 'string');
|
61
|
+
if (!hasDirectContent && textObjects.length > 0) {
|
62
|
+
this.style = (textObjects[0] as TextComponent).getTextStyle();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
public static applyTextStyles(ctx: CanvasRenderingContext2D, style: TextRenderingStyle) {
|
67
|
+
// Quote the font family if necessary.
|
68
|
+
const fontFamily = style.fontFamily.match(/\s/) ? style.fontFamily.replace(/["]/g, '\\"') : style.fontFamily;
|
69
|
+
|
70
|
+
ctx.font = [
|
71
|
+
style.fontStyle ?? '',
|
72
|
+
style.fontWeight ?? '',
|
73
|
+
(style.size ?? 12) + 'px',
|
74
|
+
`${fontFamily}`
|
75
|
+
].join(' ');
|
76
|
+
|
77
|
+
// TODO: Support RTL
|
78
|
+
ctx.textAlign = 'left';
|
79
|
+
}
|
80
|
+
|
81
|
+
private static textMeasuringCtx: CanvasRenderingContext2D|null = null;
|
82
|
+
|
83
|
+
// Roughly estimate the bounding box of `text`. Use if no CanvasRenderingContext2D is available.
|
84
|
+
private static estimateTextDimens(text: string, style: TextRenderingStyle): Rect2 {
|
85
|
+
const widthEst = text.length * style.size;
|
86
|
+
const heightEst = style.size;
|
87
|
+
|
88
|
+
// Text is drawn with (0, 0) as its baseline. As such, the majority of the text's height should
|
89
|
+
// be above (0, 0).
|
90
|
+
return new Rect2(0, -heightEst * 2/3, widthEst, heightEst);
|
91
|
+
}
|
92
|
+
|
93
|
+
// Returns a set of TextMetrics for the given text, if a canvas is available.
|
94
|
+
private static getTextMetrics(text: string, style: TextRenderingStyle): TextMetrics|null {
|
95
|
+
TextComponent.textMeasuringCtx ??= document.createElement('canvas').getContext('2d') ?? null;
|
96
|
+
if (!TextComponent.textMeasuringCtx) {
|
97
|
+
return null;
|
98
|
+
}
|
99
|
+
|
100
|
+
const ctx = TextComponent.textMeasuringCtx;
|
101
|
+
TextComponent.applyTextStyles(ctx, style);
|
102
|
+
|
103
|
+
return ctx.measureText(text);
|
104
|
+
}
|
105
|
+
|
106
|
+
// Returns the bounding box of `text`. This is approximate if no Canvas is available.
|
107
|
+
private static getTextDimens(text: string, style: TextRenderingStyle): Rect2 {
|
108
|
+
const metrics = this.getTextMetrics(text, style);
|
109
|
+
|
110
|
+
if (!metrics) {
|
111
|
+
return this.estimateTextDimens(text, style);
|
112
|
+
}
|
113
|
+
|
114
|
+
// Text is drawn with (0,0) at the bottom left of the baseline.
|
115
|
+
const textY = -metrics.actualBoundingBoxAscent;
|
116
|
+
const textHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
|
117
|
+
return new Rect2(0, textY, metrics.width, textHeight);
|
118
|
+
}
|
119
|
+
|
120
|
+
private static getFontHeight(style: TextRenderingStyle): number {
|
121
|
+
return style.size;
|
122
|
+
}
|
123
|
+
|
124
|
+
private computeUntransformedBBoxOfPart(part: TextElement) {
|
125
|
+
if (typeof part === 'string') {
|
126
|
+
return TextComponent.getTextDimens(part, this.style);
|
127
|
+
} else {
|
128
|
+
return part.contentBBox;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
private recomputeBBox() {
|
133
|
+
let bbox: Rect2|null = null;
|
134
|
+
const cursor = new TextComponent.TextCursor(this.transform, this.style);
|
135
|
+
|
136
|
+
for (const textObject of this.textObjects) {
|
137
|
+
const transform = cursor.update(textObject);
|
138
|
+
const currentBBox = this.computeUntransformedBBoxOfPart(textObject).transformedBoundingBox(transform);
|
139
|
+
|
140
|
+
bbox ??= currentBBox;
|
141
|
+
bbox = bbox.union(currentBBox);
|
142
|
+
}
|
143
|
+
|
144
|
+
this.contentBBox = bbox ?? Rect2.empty;
|
145
|
+
}
|
146
|
+
|
147
|
+
private renderInternal(canvas: AbstractRenderer) {
|
148
|
+
const cursor = new TextComponent.TextCursor(this.transform, this.style);
|
149
|
+
|
150
|
+
for (const textObject of this.textObjects) {
|
151
|
+
const transform = cursor.update(textObject);
|
152
|
+
|
153
|
+
if (typeof textObject === 'string') {
|
154
|
+
canvas.drawText(textObject, transform, this.style);
|
155
|
+
} else {
|
156
|
+
canvas.pushTransform(transform);
|
157
|
+
textObject.renderInternal(canvas);
|
158
|
+
canvas.popTransform();
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
public override render(canvas: AbstractRenderer, _visibleRect?: Rect2): void {
|
164
|
+
canvas.startObject(this.contentBBox);
|
165
|
+
this.renderInternal(canvas);
|
166
|
+
canvas.endObject(this.getLoadSaveData());
|
167
|
+
}
|
168
|
+
|
169
|
+
public override getProportionalRenderingTime(): number {
|
170
|
+
return this.textObjects.length;
|
171
|
+
}
|
172
|
+
|
173
|
+
public override intersects(lineSegment: LineSegment2): boolean {
|
174
|
+
const cursor = new TextComponent.TextCursor(this.transform, this.style);
|
175
|
+
|
176
|
+
for (const subObject of this.textObjects) {
|
177
|
+
// Convert canvas space to internal space relative to the current object.
|
178
|
+
const invTransform = cursor.update(subObject).inverse();
|
179
|
+
const transformedLine = lineSegment.transformedBy(invTransform);
|
180
|
+
|
181
|
+
if (typeof subObject === 'string') {
|
182
|
+
const textBBox = TextComponent.getTextDimens(subObject, this.style);
|
183
|
+
|
184
|
+
// TODO: Use a better intersection check. Perhaps draw the text onto a CanvasElement and
|
185
|
+
// use pixel-testing to check for intersection with its contour.
|
186
|
+
if (textBBox.getEdges().some(edge => transformedLine.intersection(edge) !== null)) {
|
187
|
+
return true;
|
188
|
+
}
|
189
|
+
} else {
|
190
|
+
if (subObject.intersects(transformedLine)) {
|
191
|
+
return true;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
return false;
|
197
|
+
}
|
198
|
+
|
199
|
+
public getStyle(): ComponentStyle {
|
200
|
+
return {
|
201
|
+
color: this.style.renderingStyle.fill,
|
202
|
+
|
203
|
+
// Make a copy
|
204
|
+
textStyle: {
|
205
|
+
...this.style,
|
206
|
+
renderingStyle: {
|
207
|
+
...this.style.renderingStyle,
|
208
|
+
},
|
209
|
+
},
|
210
|
+
};
|
211
|
+
}
|
212
|
+
|
213
|
+
public updateStyle(style: ComponentStyle): SerializableCommand {
|
214
|
+
return createRestyleComponentCommand(this.getStyle(), style, this);
|
215
|
+
}
|
216
|
+
|
217
|
+
public forceStyle(style: ComponentStyle, editor: Editor|null): void {
|
218
|
+
if (style.textStyle) {
|
219
|
+
this.style = cloneTextStyle(style.textStyle);
|
220
|
+
} else if (style.color) {
|
221
|
+
this.style = {
|
222
|
+
...this.style,
|
223
|
+
renderingStyle: {
|
224
|
+
...this.style.renderingStyle,
|
225
|
+
fill: style.color,
|
226
|
+
},
|
227
|
+
};
|
228
|
+
} else {
|
229
|
+
return;
|
230
|
+
}
|
231
|
+
|
232
|
+
for (const child of this.textObjects) {
|
233
|
+
if (child instanceof TextComponent) {
|
234
|
+
child.forceStyle(style, editor);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
if (editor) {
|
239
|
+
editor.image.queueRerenderOf(this);
|
240
|
+
editor.queueRerender();
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
// See {@link getStyle}
|
245
|
+
public getTextStyle(): TextRenderingStyle {
|
246
|
+
return cloneTextStyle(this.style);
|
247
|
+
}
|
248
|
+
|
249
|
+
public getBaselinePos() {
|
250
|
+
return this.transform.transformVec2(Vec2.zero);
|
251
|
+
}
|
252
|
+
|
253
|
+
public getTransform(): Mat33 {
|
254
|
+
return this.transform;
|
255
|
+
}
|
256
|
+
|
257
|
+
protected applyTransformation(affineTransfm: Mat33): void {
|
258
|
+
this.transform = affineTransfm.rightMul(this.transform);
|
259
|
+
this.recomputeBBox();
|
260
|
+
}
|
261
|
+
|
262
|
+
protected createClone(): AbstractComponent {
|
263
|
+
const clonedTextObjects = this.textObjects.map(obj => {
|
264
|
+
if (typeof obj === 'string') {
|
265
|
+
return obj;
|
266
|
+
} else {
|
267
|
+
return obj.createClone() as TextComponent;
|
268
|
+
}
|
269
|
+
});
|
270
|
+
return new TextComponent(clonedTextObjects, this.transform, this.style);
|
271
|
+
}
|
272
|
+
|
273
|
+
public getText() {
|
274
|
+
const result: string[] = [];
|
275
|
+
|
276
|
+
for (const textObject of this.textObjects) {
|
277
|
+
if (typeof textObject === 'string') {
|
278
|
+
result.push(textObject);
|
279
|
+
} else {
|
280
|
+
result.push(textObject.getText());
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
return result.join('\n');
|
285
|
+
}
|
286
|
+
|
287
|
+
public description(localizationTable: ImageComponentLocalization): string {
|
288
|
+
return localizationTable.text(this.getText());
|
289
|
+
}
|
290
|
+
|
291
|
+
// Do not rely on the output of `serializeToJSON` taking any particular format.
|
292
|
+
protected serializeToJSON(): Record<string, any> {
|
293
|
+
const serializableStyle = textStyleToJSON(this.style);
|
294
|
+
|
295
|
+
const serializedTextObjects = this.textObjects.map(text => {
|
296
|
+
if (typeof text === 'string') {
|
297
|
+
return {
|
298
|
+
text,
|
299
|
+
};
|
300
|
+
} else {
|
301
|
+
return {
|
302
|
+
json: text.serializeToJSON(),
|
303
|
+
};
|
304
|
+
}
|
305
|
+
});
|
306
|
+
|
307
|
+
return {
|
308
|
+
textObjects: serializedTextObjects,
|
309
|
+
transform: this.transform.toArray(),
|
310
|
+
style: serializableStyle,
|
311
|
+
};
|
312
|
+
}
|
313
|
+
|
314
|
+
// @internal
|
315
|
+
public static deserializeFromString(json: any): TextComponent {
|
316
|
+
if (typeof json === 'string') {
|
317
|
+
json = JSON.parse(json);
|
318
|
+
}
|
319
|
+
|
320
|
+
const style = textStyleFromJSON(json.style);
|
321
|
+
|
322
|
+
const textObjects: Array<TextElement> = json.textObjects.map((data: any) => {
|
323
|
+
if ((data.text ?? null) !== null) {
|
324
|
+
return data.text;
|
325
|
+
}
|
326
|
+
|
327
|
+
return TextComponent.deserializeFromString(data.json);
|
328
|
+
});
|
329
|
+
|
330
|
+
json.transform = json.transform.filter((elem: any) => typeof elem === 'number');
|
331
|
+
if (json.transform.length !== 9) {
|
332
|
+
throw new Error(`Unable to deserialize transform, ${json.transform}.`);
|
333
|
+
}
|
334
|
+
|
335
|
+
const transformData = json.transform as Mat33Array;
|
336
|
+
const transform = new Mat33(...transformData);
|
337
|
+
|
338
|
+
return new TextComponent(textObjects, transform, style);
|
339
|
+
}
|
340
|
+
|
341
|
+
/**
|
342
|
+
* Creates a `TextComponent` from `lines`.
|
343
|
+
*
|
344
|
+
* @example
|
345
|
+
* ```ts
|
346
|
+
* const textStyle = {
|
347
|
+
* size: 12,
|
348
|
+
* fontFamily: 'serif',
|
349
|
+
* renderingStyle: { fill: Color4.black },
|
350
|
+
* };
|
351
|
+
*
|
352
|
+
* const text = TextComponent.fromLines('foo\nbar'.split('\n'), Mat33.identity, textStyle);
|
353
|
+
* ```
|
354
|
+
*/
|
355
|
+
public static fromLines(lines: string[], transform: Mat33, style: TextRenderingStyle): AbstractComponent {
|
356
|
+
let lastComponent: TextComponent|null = null;
|
357
|
+
const components: TextComponent[] = [];
|
358
|
+
|
359
|
+
const lineMargin = Math.round(this.getFontHeight(style));
|
360
|
+
|
361
|
+
let position = Vec2.zero;
|
362
|
+
for (const line of lines) {
|
363
|
+
if (lastComponent) {
|
364
|
+
position = position.plus(Vec2.unitY.times(lineMargin));
|
365
|
+
}
|
366
|
+
|
367
|
+
const component = new TextComponent([ line ], Mat33.translation(position), style);
|
368
|
+
components.push(component);
|
369
|
+
lastComponent = component;
|
370
|
+
}
|
371
|
+
|
372
|
+
return new TextComponent(components, transform, style);
|
373
|
+
}
|
374
|
+
|
375
|
+
private static TextCursor = class {
|
376
|
+
public transform: Mat33 = Mat33.identity;
|
377
|
+
public constructor(
|
378
|
+
private parentTransform: Mat33 = Mat33.identity, private parentStyle: TextRenderingStyle
|
379
|
+
) { }
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Based on previous calls to `update`, returns the transformation of
|
383
|
+
* the given `element` (including the parentTransform given to this cursor's
|
384
|
+
* constructor).
|
385
|
+
*
|
386
|
+
* The result does not take into account
|
387
|
+
*/
|
388
|
+
public update(elem: TextElement) {
|
389
|
+
let elementTransform = Mat33.identity;
|
390
|
+
let elemInternalTransform = Mat33.identity;
|
391
|
+
let textSize;
|
392
|
+
if (typeof(elem) === 'string') {
|
393
|
+
textSize = TextComponent.getTextDimens(elem, this.parentStyle);
|
394
|
+
} else {
|
395
|
+
// TODO: Double-check whether we need to take elem.transform into account here.
|
396
|
+
// elementTransform = elem.transform;
|
397
|
+
elemInternalTransform = elem.transform;
|
398
|
+
textSize = elem.getBBox();
|
399
|
+
}
|
400
|
+
const positioning = typeof(elem) === 'string' ? TextTransformMode.RELATIVE_XY : elem.transformMode;
|
401
|
+
|
402
|
+
if (positioning === TextTransformMode.RELATIVE_XY) {
|
403
|
+
// Position relative to the previous element's transform.
|
404
|
+
elementTransform = this.transform.rightMul(elementTransform);
|
405
|
+
} else if (positioning === TextTransformMode.RELATIVE_X_ABSOLUTE_Y || positioning === TextTransformMode.RELATIVE_Y_ABSOLUTE_X) {
|
406
|
+
// Zero the absolute component of this.transform's translation
|
407
|
+
const transform = this.transform.mapEntries((component, [row, col]) => {
|
408
|
+
if (positioning === TextTransformMode.RELATIVE_X_ABSOLUTE_Y) {
|
409
|
+
// Zero the y component of this.transform's translation
|
410
|
+
return row === 1 && col === 2 ? 0 : component;
|
411
|
+
} else if (positioning === TextTransformMode.RELATIVE_Y_ABSOLUTE_X) {
|
412
|
+
// Zero the x component of this.transform's translation
|
413
|
+
return row === 0 && col === 2 ? 0 : component;
|
414
|
+
}
|
415
|
+
|
416
|
+
throw new Error('Unreachable');
|
417
|
+
return 0;
|
418
|
+
});
|
419
|
+
|
420
|
+
elementTransform = transform.rightMul(elementTransform);
|
421
|
+
}
|
422
|
+
|
423
|
+
// Update this.transform so that future calls to update return correct values.
|
424
|
+
const endShiftTransform = Mat33.translation(Vec2.of(textSize.width, 0));
|
425
|
+
this.transform = elementTransform.rightMul(elemInternalTransform).rightMul(endShiftTransform);
|
426
|
+
|
427
|
+
return this.parentTransform.rightMul(elementTransform);
|
428
|
+
}
|
429
|
+
};
|
430
|
+
}
|
431
|
+
|
432
|
+
AbstractComponent.registerComponent(componentTypeId, (data: string) => TextComponent.deserializeFromString(data));
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import AbstractComponent from './AbstractComponent';
|
2
|
+
import UnknownSVGObject from './UnknownSVGObject';
|
3
|
+
|
4
|
+
describe('UnknownSVGObject', () => {
|
5
|
+
it('should not be deserializable', () => {
|
6
|
+
const obj = new UnknownSVGObject(document.createElementNS('http://www.w3.org/2000/svg', 'circle'));
|
7
|
+
const serialized = obj.serialize();
|
8
|
+
expect(() => AbstractComponent.deserialize(serialized)).toThrow(/.*cannot be deserialized.*/);
|
9
|
+
});
|
10
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
//
|
2
|
+
// Stores objects loaded from an SVG that aren't recognised by the editor.
|
3
|
+
// @internal
|
4
|
+
// @packageDocumentation
|
5
|
+
//
|
6
|
+
|
7
|
+
import LineSegment2 from '../math/shapes/LineSegment2';
|
8
|
+
import Mat33 from '../math/Mat33';
|
9
|
+
import Rect2 from '../math/shapes/Rect2';
|
10
|
+
import AbstractRenderer from '../rendering/renderers/AbstractRenderer';
|
11
|
+
import SVGRenderer from '../rendering/renderers/SVGRenderer';
|
12
|
+
import AbstractComponent from './AbstractComponent';
|
13
|
+
import { ImageComponentLocalization } from './localization';
|
14
|
+
|
15
|
+
const componentId = 'unknown-svg-object';
|
16
|
+
export default class UnknownSVGObject extends AbstractComponent {
|
17
|
+
protected contentBBox: Rect2;
|
18
|
+
|
19
|
+
public constructor(private svgObject: SVGElement) {
|
20
|
+
super(componentId);
|
21
|
+
this.contentBBox = Rect2.of(svgObject.getBoundingClientRect());
|
22
|
+
}
|
23
|
+
|
24
|
+
public override render(canvas: AbstractRenderer, _visibleRect?: Rect2): void {
|
25
|
+
if (!(canvas instanceof SVGRenderer)) {
|
26
|
+
// Don't draw unrenderable objects if we can't
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
canvas.drawSVGElem(this.svgObject);
|
31
|
+
}
|
32
|
+
|
33
|
+
public override intersects(lineSegment: LineSegment2): boolean {
|
34
|
+
return this.contentBBox.getEdges().some(edge => edge.intersection(lineSegment) !== null);
|
35
|
+
}
|
36
|
+
|
37
|
+
protected applyTransformation(_affineTransfm: Mat33): void {
|
38
|
+
}
|
39
|
+
|
40
|
+
public override isSelectable() {
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
|
44
|
+
protected createClone(): AbstractComponent {
|
45
|
+
return new UnknownSVGObject(this.svgObject.cloneNode(true) as SVGElement);
|
46
|
+
}
|
47
|
+
|
48
|
+
public description(localization: ImageComponentLocalization): string {
|
49
|
+
return localization.svgObject;
|
50
|
+
}
|
51
|
+
|
52
|
+
protected serializeToJSON(): string | null {
|
53
|
+
return JSON.stringify({
|
54
|
+
html: this.svgObject.outerHTML,
|
55
|
+
});
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// null: Do not deserialize UnknownSVGObjects.
|
60
|
+
AbstractComponent.registerComponent(componentId, null);
|