js-draw 0.18.1 → 0.18.2
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/CHANGELOG.md +3 -0
- package/dist/cjs/src/Color4.d.ts +61 -0
- package/dist/cjs/src/Color4.js +197 -0
- package/dist/cjs/src/Editor.d.ts +308 -0
- package/dist/cjs/src/Editor.js +904 -0
- package/dist/cjs/src/EditorImage.d.ts +97 -0
- package/dist/cjs/src/EditorImage.js +486 -0
- package/dist/cjs/src/EventDispatcher.d.ts +30 -0
- package/dist/cjs/src/EventDispatcher.js +57 -0
- package/dist/cjs/src/Pointer.d.ts +24 -0
- package/dist/cjs/src/Pointer.js +84 -0
- package/dist/cjs/src/SVGLoader.d.ts +48 -0
- package/dist/cjs/src/SVGLoader.js +472 -0
- package/dist/cjs/src/UndoRedoHistory.d.ts +19 -0
- package/dist/cjs/src/UndoRedoHistory.js +93 -0
- package/dist/cjs/src/Viewport.d.ts +71 -0
- package/dist/cjs/src/Viewport.js +264 -0
- package/dist/cjs/src/bundle/bundled.d.ts +4 -0
- package/dist/cjs/src/bundle/bundled.js +24 -0
- package/dist/cjs/src/commands/Command.d.ts +16 -0
- package/dist/cjs/src/commands/Command.js +34 -0
- package/dist/cjs/src/commands/Duplicate.d.ts +14 -0
- package/dist/cjs/src/commands/Duplicate.js +39 -0
- package/dist/cjs/src/commands/Erase.d.ts +14 -0
- package/dist/cjs/src/commands/Erase.js +63 -0
- package/dist/cjs/src/commands/SerializableCommand.d.ts +12 -0
- package/dist/cjs/src/commands/SerializableCommand.js +42 -0
- package/dist/cjs/src/commands/UnresolvedCommand.d.ts +14 -0
- package/dist/cjs/src/commands/UnresolvedCommand.js +28 -0
- package/dist/cjs/src/commands/invertCommand.d.ts +4 -0
- package/dist/cjs/src/commands/invertCommand.js +49 -0
- package/dist/cjs/src/commands/lib.d.ts +7 -0
- package/dist/cjs/src/commands/lib.js +18 -0
- package/dist/cjs/src/commands/localization.d.ts +23 -0
- package/dist/cjs/src/commands/localization.js +24 -0
- package/dist/cjs/src/commands/uniteCommands.d.ts +4 -0
- package/dist/cjs/src/commands/uniteCommands.js +121 -0
- package/dist/cjs/src/components/AbstractComponent.d.ts +73 -0
- package/dist/cjs/src/components/AbstractComponent.js +258 -0
- package/dist/cjs/src/components/ImageBackground.d.ts +42 -0
- package/dist/cjs/src/components/ImageBackground.js +146 -0
- package/dist/cjs/src/components/ImageComponent.d.ts +31 -0
- package/dist/cjs/src/components/ImageComponent.js +152 -0
- package/dist/cjs/src/components/RestylableComponent.d.ts +24 -0
- package/dist/cjs/src/components/RestylableComponent.js +88 -0
- package/dist/cjs/src/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/cjs/src/components/SVGGlobalAttributesObject.js +65 -0
- package/dist/cjs/src/components/Stroke.d.ts +40 -0
- package/dist/cjs/src/components/Stroke.js +191 -0
- package/dist/cjs/src/components/TextComponent.d.ts +53 -0
- package/dist/cjs/src/components/TextComponent.js +258 -0
- package/dist/cjs/src/components/UnknownSVGObject.d.ts +18 -0
- package/dist/cjs/src/components/UnknownSVGObject.js +50 -0
- package/dist/cjs/src/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/cjs/src/components/builders/ArrowBuilder.js +117 -0
- package/dist/cjs/src/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/cjs/src/components/builders/FreehandLineBuilder.js +173 -0
- package/dist/cjs/src/components/builders/LineBuilder.d.ts +18 -0
- package/dist/cjs/src/components/builders/LineBuilder.js +89 -0
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.js +347 -0
- package/dist/cjs/src/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/cjs/src/components/builders/RectangleBuilder.js +59 -0
- package/dist/cjs/src/components/builders/types.d.ts +12 -0
- package/dist/cjs/src/components/builders/types.js +2 -0
- package/dist/cjs/src/components/lib.d.ts +12 -0
- package/dist/cjs/src/components/lib.js +43 -0
- package/dist/cjs/src/components/localization.d.ts +11 -0
- package/dist/cjs/src/components/localization.js +13 -0
- package/dist/cjs/src/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/cjs/src/components/util/StrokeSmoother.js +217 -0
- package/dist/cjs/src/components/util/describeComponentList.d.ts +4 -0
- package/dist/cjs/src/components/util/describeComponentList.js +16 -0
- package/dist/cjs/src/lib.d.ts +34 -0
- package/dist/cjs/src/lib.js +63 -0
- package/dist/cjs/src/localization.d.ts +14 -0
- package/dist/cjs/src/localization.js +13 -0
- package/dist/cjs/src/localizations/de.d.ts +3 -0
- package/dist/cjs/src/localizations/de.js +6 -0
- package/dist/cjs/src/localizations/en.d.ts +3 -0
- package/dist/cjs/src/localizations/en.js +6 -0
- package/dist/cjs/src/localizations/es.d.ts +3 -0
- package/dist/cjs/src/localizations/es.js +20 -0
- package/dist/cjs/src/localizations/getLocalizationTable.d.ts +3 -0
- package/dist/cjs/src/localizations/getLocalizationTable.js +50 -0
- package/dist/cjs/src/math/LineSegment2.d.ts +24 -0
- package/dist/cjs/src/math/LineSegment2.js +131 -0
- package/dist/cjs/src/math/Mat33.d.ts +118 -0
- package/dist/cjs/src/math/Mat33.js +332 -0
- package/dist/cjs/src/math/Path.d.ts +71 -0
- package/dist/cjs/src/math/Path.js +655 -0
- package/dist/cjs/src/math/Rect2.d.ts +52 -0
- package/dist/cjs/src/math/Rect2.js +234 -0
- package/dist/cjs/src/math/Triangle.d.ts +11 -0
- package/dist/cjs/src/math/Triangle.js +22 -0
- package/dist/cjs/src/math/Vec2.d.ts +13 -0
- package/dist/cjs/src/math/Vec2.js +19 -0
- package/dist/cjs/src/math/Vec3.d.ts +106 -0
- package/dist/cjs/src/math/Vec3.js +177 -0
- package/dist/cjs/src/math/lib.d.ts +7 -0
- package/dist/cjs/src/math/lib.js +18 -0
- package/dist/cjs/src/math/rounding.d.ts +4 -0
- package/dist/cjs/src/math/rounding.js +135 -0
- package/dist/cjs/src/rendering/Display.d.ts +75 -0
- package/dist/cjs/src/rendering/Display.js +214 -0
- package/dist/cjs/src/rendering/RenderingStyle.d.ts +31 -0
- package/dist/cjs/src/rendering/RenderingStyle.js +48 -0
- package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +36 -0
- package/dist/cjs/src/rendering/TextRenderingStyle.js +29 -0
- package/dist/cjs/src/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/cjs/src/rendering/caching/CacheRecord.js +61 -0
- package/dist/cjs/src/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/cjs/src/rendering/caching/CacheRecordManager.js +50 -0
- package/dist/cjs/src/rendering/caching/RenderingCache.d.ts +11 -0
- package/dist/cjs/src/rendering/caching/RenderingCache.js +51 -0
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.js +326 -0
- package/dist/cjs/src/rendering/caching/testUtils.d.ts +9 -0
- package/dist/cjs/src/rendering/caching/testUtils.js +27 -0
- package/dist/cjs/src/rendering/caching/types.d.ts +19 -0
- package/dist/cjs/src/rendering/caching/types.js +2 -0
- package/dist/cjs/src/rendering/lib.d.ts +5 -0
- package/dist/cjs/src/rendering/lib.js +17 -0
- package/dist/cjs/src/rendering/localization.d.ts +10 -0
- package/dist/cjs/src/rendering/localization.js +12 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +68 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.js +170 -0
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +236 -0
- package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/cjs/src/rendering/renderers/DummyRenderer.js +112 -0
- package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +311 -0
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.js +63 -0
- package/dist/cjs/src/testing/beforeEachFile.d.ts +1 -0
- package/dist/cjs/src/testing/beforeEachFile.js +12 -0
- package/dist/cjs/src/testing/createEditor.d.ts +4 -0
- package/dist/cjs/src/testing/createEditor.js +14 -0
- package/dist/cjs/src/testing/lib.d.ts +2 -0
- package/dist/cjs/src/testing/lib.js +10 -0
- package/dist/cjs/src/testing/loadExpectExtensions.d.ts +2 -0
- package/dist/cjs/src/testing/loadExpectExtensions.js +28 -0
- package/dist/cjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/cjs/src/testing/sendPenEvent.js +24 -0
- package/dist/cjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/cjs/src/testing/sendTouchEvent.js +87 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.d.ts +103 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.js +383 -0
- package/dist/cjs/src/toolbar/IconProvider.d.ts +62 -0
- package/dist/cjs/src/toolbar/IconProvider.js +660 -0
- package/dist/cjs/src/toolbar/lib.d.ts +3 -0
- package/dist/cjs/src/toolbar/lib.js +24 -0
- package/dist/cjs/src/toolbar/localization.d.ts +49 -0
- package/dist/cjs/src/toolbar/localization.js +51 -0
- package/dist/cjs/src/toolbar/makeColorInput.d.ts +6 -0
- package/dist/cjs/src/toolbar/makeColorInput.js +120 -0
- package/dist/cjs/src/toolbar/types.d.ts +4 -0
- package/dist/cjs/src/toolbar/types.js +2 -0
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.d.ts +15 -0
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.js +31 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.d.ts +11 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +50 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.d.ts +72 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +313 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +18 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +126 -0
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.d.ts +17 -0
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +63 -0
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.d.ts +17 -0
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.js +201 -0
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.d.ts +19 -0
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +176 -0
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.d.ts +25 -0
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.js +77 -0
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.d.ts +27 -0
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +226 -0
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.d.ts +13 -0
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.js +153 -0
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.d.ts +16 -0
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +115 -0
- package/dist/cjs/src/toolbar/widgets/lib.d.ts +10 -0
- package/dist/cjs/src/toolbar/widgets/lib.js +26 -0
- package/dist/cjs/src/tools/BaseTool.d.ts +22 -0
- package/dist/cjs/src/tools/BaseTool.js +66 -0
- package/dist/cjs/src/tools/Eraser.d.ts +23 -0
- package/dist/cjs/src/tools/Eraser.js +112 -0
- package/dist/cjs/src/tools/FindTool.d.ts +21 -0
- package/dist/cjs/src/tools/FindTool.js +121 -0
- package/dist/cjs/src/tools/PanZoom.d.ts +52 -0
- package/dist/cjs/src/tools/PanZoom.js +421 -0
- package/dist/cjs/src/tools/PasteHandler.d.ts +23 -0
- package/dist/cjs/src/tools/PasteHandler.js +99 -0
- package/dist/cjs/src/tools/Pen.d.ts +39 -0
- package/dist/cjs/src/tools/Pen.js +179 -0
- package/dist/cjs/src/tools/PipetteTool.d.ts +18 -0
- package/dist/cjs/src/tools/PipetteTool.js +45 -0
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.js +28 -0
- package/dist/cjs/src/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/cjs/src/tools/SelectionTool/Selection.js +488 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.d.ts +38 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.js +85 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.d.ts +36 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +405 -0
- package/dist/cjs/src/tools/SelectionTool/TransformMode.d.ts +34 -0
- package/dist/cjs/src/tools/SelectionTool/TransformMode.js +107 -0
- package/dist/cjs/src/tools/SelectionTool/types.d.ts +9 -0
- package/dist/cjs/src/tools/SelectionTool/types.js +14 -0
- package/dist/cjs/src/tools/TextTool.d.ts +33 -0
- package/dist/cjs/src/tools/TextTool.js +262 -0
- package/dist/cjs/src/tools/ToolController.d.ts +18 -0
- package/dist/cjs/src/tools/ToolController.js +187 -0
- package/dist/cjs/src/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/cjs/src/tools/ToolEnabledGroup.js +14 -0
- package/dist/cjs/src/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/cjs/src/tools/ToolSwitcherShortcut.js +38 -0
- package/dist/cjs/src/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/cjs/src/tools/ToolbarShortcutHandler.js +29 -0
- package/dist/cjs/src/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/cjs/src/tools/UndoRedoShortcut.js +28 -0
- package/dist/cjs/src/tools/lib.d.ts +16 -0
- package/dist/cjs/src/tools/lib.js +36 -0
- package/dist/cjs/src/tools/localization.d.ts +28 -0
- package/dist/cjs/src/tools/localization.js +30 -0
- package/dist/cjs/src/types.d.ts +151 -0
- package/dist/cjs/src/types.js +38 -0
- package/dist/cjs/src/util/assertions.d.ts +23 -0
- package/dist/cjs/src/util/assertions.js +51 -0
- package/dist/cjs/src/util/fileToBase64.d.ts +3 -0
- package/dist/cjs/src/util/fileToBase64.js +15 -0
- package/dist/cjs/src/util/untilNextAnimationFrame.d.ts +3 -0
- package/dist/cjs/src/util/untilNextAnimationFrame.js +9 -0
- package/dist/cjs/src/util/waitForTimeout.d.ts +2 -0
- package/dist/cjs/src/util/waitForTimeout.js +9 -0
- package/dist/mjs/src/Color4.d.ts +61 -0
- package/dist/mjs/src/Color4.mjs +193 -0
- package/dist/mjs/src/Editor.d.ts +308 -0
- package/dist/mjs/src/Editor.mjs +874 -0
- package/dist/mjs/src/EditorImage.d.ts +97 -0
- package/dist/mjs/src/EditorImage.mjs +477 -0
- package/dist/mjs/src/EventDispatcher.d.ts +30 -0
- package/dist/mjs/src/EventDispatcher.mjs +54 -0
- package/dist/mjs/src/Pointer.d.ts +24 -0
- package/dist/mjs/src/Pointer.mjs +80 -0
- package/dist/mjs/src/SVGLoader.d.ts +48 -0
- package/dist/mjs/src/SVGLoader.mjs +442 -0
- package/dist/mjs/src/UndoRedoHistory.d.ts +19 -0
- package/dist/mjs/src/UndoRedoHistory.mjs +91 -0
- package/dist/mjs/src/Viewport.d.ts +71 -0
- package/dist/mjs/src/Viewport.mjs +256 -0
- package/dist/mjs/src/bundle/bundled.d.ts +4 -0
- package/dist/mjs/src/bundle/bundled.mjs +5 -0
- package/dist/mjs/src/commands/Command.d.ts +16 -0
- package/dist/mjs/src/commands/Command.mjs +30 -0
- package/dist/mjs/src/commands/Duplicate.d.ts +14 -0
- package/dist/mjs/src/commands/Duplicate.mjs +33 -0
- package/dist/mjs/src/commands/Erase.d.ts +14 -0
- package/dist/mjs/src/commands/Erase.mjs +57 -0
- package/dist/mjs/src/commands/SerializableCommand.d.ts +12 -0
- package/dist/mjs/src/commands/SerializableCommand.mjs +36 -0
- package/dist/mjs/src/commands/UnresolvedCommand.d.ts +14 -0
- package/dist/mjs/src/commands/UnresolvedCommand.mjs +22 -0
- package/dist/mjs/src/commands/invertCommand.d.ts +4 -0
- package/dist/mjs/src/commands/invertCommand.mjs +44 -0
- package/dist/mjs/src/commands/lib.d.ts +7 -0
- package/dist/mjs/src/commands/lib.mjs +7 -0
- package/dist/mjs/src/commands/localization.d.ts +23 -0
- package/dist/mjs/src/commands/localization.mjs +21 -0
- package/dist/mjs/src/commands/uniteCommands.d.ts +4 -0
- package/dist/mjs/src/commands/uniteCommands.mjs +116 -0
- package/dist/mjs/src/components/AbstractComponent.d.ts +73 -0
- package/dist/mjs/src/components/AbstractComponent.mjs +252 -0
- package/dist/mjs/src/components/ImageBackground.d.ts +42 -0
- package/dist/mjs/src/components/ImageBackground.mjs +139 -0
- package/dist/mjs/src/components/ImageComponent.d.ts +31 -0
- package/dist/mjs/src/components/ImageComponent.mjs +146 -0
- package/dist/mjs/src/components/RestylableComponent.d.ts +24 -0
- package/dist/mjs/src/components/RestylableComponent.mjs +80 -0
- package/dist/mjs/src/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/mjs/src/components/SVGGlobalAttributesObject.mjs +59 -0
- package/dist/mjs/src/components/Stroke.d.ts +40 -0
- package/dist/mjs/src/components/Stroke.mjs +185 -0
- package/dist/mjs/src/components/TextComponent.d.ts +53 -0
- package/dist/mjs/src/components/TextComponent.mjs +252 -0
- package/dist/mjs/src/components/UnknownSVGObject.d.ts +18 -0
- package/dist/mjs/src/components/UnknownSVGObject.mjs +44 -0
- package/dist/mjs/src/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/mjs/src/components/builders/ArrowBuilder.mjs +86 -0
- package/dist/mjs/src/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/mjs/src/components/builders/FreehandLineBuilder.mjs +165 -0
- package/dist/mjs/src/components/builders/LineBuilder.d.ts +18 -0
- package/dist/mjs/src/components/builders/LineBuilder.mjs +58 -0
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.mjs +339 -0
- package/dist/mjs/src/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/mjs/src/components/builders/RectangleBuilder.mjs +50 -0
- package/dist/mjs/src/components/builders/types.d.ts +12 -0
- package/dist/mjs/src/components/builders/types.mjs +1 -0
- package/dist/mjs/src/components/lib.d.ts +12 -0
- package/dist/mjs/src/components/lib.mjs +12 -0
- package/dist/mjs/src/components/localization.d.ts +11 -0
- package/dist/mjs/src/components/localization.mjs +10 -0
- package/dist/mjs/src/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +210 -0
- package/dist/mjs/src/components/util/describeComponentList.d.ts +4 -0
- package/dist/mjs/src/components/util/describeComponentList.mjs +14 -0
- package/dist/mjs/src/lib.d.ts +34 -0
- package/dist/mjs/src/lib.mjs +34 -0
- package/dist/mjs/src/localization.d.ts +14 -0
- package/dist/mjs/src/localization.mjs +10 -0
- package/dist/mjs/src/localizations/de.d.ts +3 -0
- package/dist/mjs/src/localizations/de.mjs +4 -0
- package/dist/mjs/src/localizations/en.d.ts +3 -0
- package/dist/mjs/src/localizations/en.mjs +4 -0
- package/dist/mjs/src/localizations/es.d.ts +3 -0
- package/dist/mjs/src/localizations/es.mjs +18 -0
- package/dist/mjs/src/localizations/getLocalizationTable.d.ts +3 -0
- package/dist/mjs/src/localizations/getLocalizationTable.mjs +45 -0
- package/dist/mjs/src/math/LineSegment2.d.ts +24 -0
- package/dist/mjs/src/math/LineSegment2.mjs +125 -0
- package/dist/mjs/src/math/Mat33.d.ts +118 -0
- package/dist/mjs/src/math/Mat33.mjs +326 -0
- package/dist/mjs/src/math/Path.d.ts +71 -0
- package/dist/mjs/src/math/Path.mjs +648 -0
- package/dist/mjs/src/math/Rect2.d.ts +52 -0
- package/dist/mjs/src/math/Rect2.mjs +228 -0
- package/dist/mjs/src/math/Triangle.d.ts +11 -0
- package/dist/mjs/src/math/Triangle.mjs +19 -0
- package/dist/mjs/src/math/Vec2.d.ts +13 -0
- package/dist/mjs/src/math/Vec2.mjs +13 -0
- package/dist/mjs/src/math/Vec3.d.ts +106 -0
- package/dist/mjs/src/math/Vec3.mjs +174 -0
- package/dist/mjs/src/math/lib.d.ts +7 -0
- package/dist/mjs/src/math/lib.mjs +7 -0
- package/dist/mjs/src/math/rounding.d.ts +4 -0
- package/dist/mjs/src/math/rounding.mjs +128 -0
- package/dist/mjs/src/rendering/Display.d.ts +75 -0
- package/dist/mjs/src/rendering/Display.mjs +207 -0
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +31 -0
- package/dist/mjs/src/rendering/RenderingStyle.mjs +38 -0
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +36 -0
- package/dist/mjs/src/rendering/TextRenderingStyle.mjs +23 -0
- package/dist/mjs/src/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/mjs/src/rendering/caching/CacheRecord.mjs +55 -0
- package/dist/mjs/src/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/mjs/src/rendering/caching/CacheRecordManager.mjs +43 -0
- package/dist/mjs/src/rendering/caching/RenderingCache.d.ts +11 -0
- package/dist/mjs/src/rendering/caching/RenderingCache.mjs +45 -0
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.mjs +320 -0
- package/dist/mjs/src/rendering/caching/testUtils.d.ts +9 -0
- package/dist/mjs/src/rendering/caching/testUtils.mjs +20 -0
- package/dist/mjs/src/rendering/caching/types.d.ts +19 -0
- package/dist/mjs/src/rendering/caching/types.mjs +1 -0
- package/dist/mjs/src/rendering/lib.d.ts +5 -0
- package/dist/mjs/src/rendering/lib.mjs +5 -0
- package/dist/mjs/src/rendering/localization.d.ts +10 -0
- package/dist/mjs/src/rendering/localization.mjs +9 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +68 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.mjs +144 -0
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +230 -0
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/mjs/src/rendering/renderers/DummyRenderer.mjs +106 -0
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +304 -0
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.mjs +57 -0
- package/dist/mjs/src/testing/beforeEachFile.d.ts +1 -0
- package/dist/mjs/src/testing/beforeEachFile.mjs +7 -0
- package/dist/mjs/src/testing/createEditor.d.ts +4 -0
- package/dist/mjs/src/testing/createEditor.mjs +9 -0
- package/dist/mjs/src/testing/lib.d.ts +2 -0
- package/dist/mjs/src/testing/lib.mjs +2 -0
- package/dist/mjs/src/testing/loadExpectExtensions.d.ts +2 -0
- package/dist/mjs/src/testing/loadExpectExtensions.mjs +24 -0
- package/dist/mjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/mjs/src/testing/sendPenEvent.mjs +19 -0
- package/dist/mjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/mjs/src/testing/sendTouchEvent.mjs +62 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +103 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +376 -0
- package/dist/mjs/src/toolbar/IconProvider.d.ts +62 -0
- package/dist/mjs/src/toolbar/IconProvider.mjs +654 -0
- package/dist/mjs/src/toolbar/lib.d.ts +3 -0
- package/dist/mjs/src/toolbar/lib.mjs +3 -0
- package/dist/mjs/src/toolbar/localization.d.ts +49 -0
- package/dist/mjs/src/toolbar/localization.mjs +48 -0
- package/dist/mjs/src/toolbar/makeColorInput.d.ts +6 -0
- package/dist/mjs/src/toolbar/makeColorInput.mjs +113 -0
- package/dist/mjs/src/toolbar/types.d.ts +4 -0
- package/dist/mjs/src/toolbar/types.mjs +1 -0
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.d.ts +15 -0
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.mjs +25 -0
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +11 -0
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +44 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +72 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +307 -0
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +18 -0
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +120 -0
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.d.ts +17 -0
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +57 -0
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.d.ts +17 -0
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.mjs +172 -0
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.d.ts +19 -0
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +170 -0
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.d.ts +25 -0
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.mjs +71 -0
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.d.ts +27 -0
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +220 -0
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.d.ts +13 -0
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.mjs +147 -0
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.d.ts +16 -0
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +109 -0
- package/dist/mjs/src/toolbar/widgets/lib.d.ts +10 -0
- package/dist/mjs/src/toolbar/widgets/lib.mjs +10 -0
- package/dist/mjs/src/tools/BaseTool.d.ts +22 -0
- package/dist/mjs/src/tools/BaseTool.mjs +63 -0
- package/dist/mjs/src/tools/Eraser.d.ts +23 -0
- package/dist/mjs/src/tools/Eraser.mjs +106 -0
- package/dist/mjs/src/tools/FindTool.d.ts +21 -0
- package/dist/mjs/src/tools/FindTool.mjs +114 -0
- package/dist/mjs/src/tools/PanZoom.d.ts +52 -0
- package/dist/mjs/src/tools/PanZoom.mjs +414 -0
- package/dist/mjs/src/tools/PasteHandler.d.ts +23 -0
- package/dist/mjs/src/tools/PasteHandler.mjs +93 -0
- package/dist/mjs/src/tools/Pen.d.ts +39 -0
- package/dist/mjs/src/tools/Pen.mjs +173 -0
- package/dist/mjs/src/tools/PipetteTool.d.ts +18 -0
- package/dist/mjs/src/tools/PipetteTool.mjs +39 -0
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.mjs +22 -0
- package/dist/mjs/src/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +459 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.d.ts +38 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.mjs +81 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.d.ts +36 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +398 -0
- package/dist/mjs/src/tools/SelectionTool/TransformMode.d.ts +34 -0
- package/dist/mjs/src/tools/SelectionTool/TransformMode.mjs +98 -0
- package/dist/mjs/src/tools/SelectionTool/types.d.ts +9 -0
- package/dist/mjs/src/tools/SelectionTool/types.mjs +11 -0
- package/dist/mjs/src/tools/TextTool.d.ts +33 -0
- package/dist/mjs/src/tools/TextTool.mjs +256 -0
- package/dist/mjs/src/tools/ToolController.d.ts +18 -0
- package/dist/mjs/src/tools/ToolController.mjs +158 -0
- package/dist/mjs/src/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/mjs/src/tools/ToolEnabledGroup.mjs +11 -0
- package/dist/mjs/src/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/mjs/src/tools/ToolSwitcherShortcut.mjs +32 -0
- package/dist/mjs/src/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/mjs/src/tools/ToolbarShortcutHandler.mjs +23 -0
- package/dist/mjs/src/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/mjs/src/tools/UndoRedoShortcut.mjs +22 -0
- package/dist/mjs/src/tools/lib.d.ts +16 -0
- package/dist/mjs/src/tools/lib.mjs +16 -0
- package/dist/mjs/src/tools/localization.d.ts +28 -0
- package/dist/mjs/src/tools/localization.mjs +27 -0
- package/dist/mjs/src/types.d.ts +151 -0
- package/dist/mjs/src/types.mjs +35 -0
- package/dist/mjs/src/util/assertions.d.ts +23 -0
- package/dist/mjs/src/util/assertions.mjs +45 -0
- package/dist/mjs/src/util/fileToBase64.d.ts +3 -0
- package/dist/mjs/src/util/fileToBase64.mjs +13 -0
- package/dist/mjs/src/util/untilNextAnimationFrame.d.ts +3 -0
- package/dist/mjs/src/util/untilNextAnimationFrame.mjs +7 -0
- package/dist/mjs/src/util/waitForTimeout.d.ts +2 -0
- package/dist/mjs/src/util/waitForTimeout.mjs +7 -0
- package/package.json +1 -1
- package/src/Color4.test.ts +40 -0
- package/src/Color4.ts +236 -0
- package/src/Editor.css +86 -0
- package/src/Editor.loadFrom.test.ts +24 -0
- package/src/Editor.toSVG.test.ts +111 -0
- package/src/Editor.ts +1122 -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 +71 -0
- package/src/Pointer.ts +127 -0
- package/src/SVGLoader.test.ts +114 -0
- package/src/SVGLoader.ts +511 -0
- package/src/UndoRedoHistory.test.ts +33 -0
- package/src/UndoRedoHistory.ts +102 -0
- package/src/Viewport.ts +319 -0
- package/src/bundle/bundled.ts +7 -0
- package/src/commands/Command.ts +45 -0
- package/src/commands/Duplicate.ts +48 -0
- package/src/commands/Erase.ts +74 -0
- package/src/commands/SerializableCommand.ts +49 -0
- package/src/commands/UnresolvedCommand.ts +37 -0
- package/src/commands/invertCommand.ts +51 -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 +135 -0
- package/src/components/AbstractComponent.transformBy.test.ts +22 -0
- package/src/components/AbstractComponent.ts +364 -0
- package/src/components/ImageBackground.test.ts +35 -0
- package/src/components/ImageBackground.ts +176 -0
- package/src/components/ImageComponent.ts +171 -0
- package/src/components/RestylableComponent.ts +142 -0
- package/src/components/SVGGlobalAttributesObject.ts +81 -0
- package/src/components/Stroke.test.ts +139 -0
- package/src/components/Stroke.ts +245 -0
- package/src/components/TextComponent.test.ts +99 -0
- package/src/components/TextComponent.ts +315 -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/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 +25 -0
- package/src/components/localization.ts +22 -0
- package/src/components/util/StrokeSmoother.ts +293 -0
- package/src/components/util/describeComponentList.ts +18 -0
- package/src/lib.ts +37 -0
- package/src/localization.ts +34 -0
- package/src/localizations/de.ts +98 -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 +55 -0
- package/src/math/LineSegment2.test.ts +99 -0
- package/src/math/LineSegment2.ts +160 -0
- package/src/math/Mat33.test.ts +244 -0
- package/src/math/Mat33.ts +437 -0
- package/src/math/Path.fromString.test.ts +223 -0
- package/src/math/Path.test.ts +198 -0
- package/src/math/Path.toString.test.ts +77 -0
- package/src/math/Path.ts +790 -0
- package/src/math/Rect2.test.ts +204 -0
- package/src/math/Rect2.ts +315 -0
- package/src/math/Triangle.ts +29 -0
- package/src/math/Vec2.test.ts +30 -0
- package/src/math/Vec2.ts +18 -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/rounding.test.ts +65 -0
- package/src/math/rounding.ts +156 -0
- package/src/rendering/Display.ts +249 -0
- package/src/rendering/RenderingStyle.test.ts +68 -0
- package/src/rendering/RenderingStyle.ts +55 -0
- package/src/rendering/TextRenderingStyle.ts +45 -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 +6 -0
- package/src/rendering/localization.ts +20 -0
- package/src/rendering/renderers/AbstractRenderer.ts +222 -0
- package/src/rendering/renderers/CanvasRenderer.ts +296 -0
- package/src/rendering/renderers/DummyRenderer.test.ts +42 -0
- package/src/rendering/renderers/DummyRenderer.ts +136 -0
- package/src/rendering/renderers/SVGRenderer.ts +354 -0
- package/src/rendering/renderers/TextOnlyRenderer.ts +70 -0
- package/src/styles.js +7 -0
- package/src/testing/beforeEachFile.ts +8 -0
- package/src/testing/createEditor.ts +11 -0
- package/src/testing/global.d.ts +17 -0
- package/src/testing/lib.ts +3 -0
- package/src/testing/loadExpectExtensions.ts +25 -0
- package/src/testing/sendPenEvent.ts +31 -0
- package/src/testing/sendTouchEvent.ts +78 -0
- package/src/toolbar/HTMLToolbar.ts +492 -0
- package/src/toolbar/IconProvider.ts +736 -0
- package/src/toolbar/lib.ts +4 -0
- package/src/toolbar/localization.ts +106 -0
- package/src/toolbar/makeColorInput.ts +145 -0
- package/src/toolbar/toolbar.css +213 -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 +377 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +167 -0
- package/src/toolbar/widgets/EraserToolWidget.ts +85 -0
- package/src/toolbar/widgets/HandToolWidget.ts +250 -0
- package/src/toolbar/widgets/InsertImageWidget.css +44 -0
- package/src/toolbar/widgets/InsertImageWidget.ts +223 -0
- package/src/toolbar/widgets/OverflowWidget.css +27 -0
- package/src/toolbar/widgets/OverflowWidget.ts +92 -0
- package/src/toolbar/widgets/PenToolWidget.ts +288 -0
- package/src/toolbar/widgets/SelectionToolWidget.ts +190 -0
- package/src/toolbar/widgets/TextToolWidget.ts +145 -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 +139 -0
- package/src/tools/FindTool.css +7 -0
- package/src/tools/FindTool.ts +152 -0
- package/src/tools/PanZoom.test.ts +310 -0
- package/src/tools/PanZoom.ts +520 -0
- package/src/tools/PasteHandler.ts +95 -0
- package/src/tools/Pen.test.ts +194 -0
- package/src/tools/Pen.ts +226 -0
- package/src/tools/PipetteTool.ts +55 -0
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +28 -0
- package/src/tools/SelectionTool/Selection.ts +607 -0
- package/src/tools/SelectionTool/SelectionHandle.ts +108 -0
- package/src/tools/SelectionTool/SelectionTool.css +23 -0
- package/src/tools/SelectionTool/SelectionTool.test.ts +261 -0
- package/src/tools/SelectionTool/SelectionTool.ts +480 -0
- package/src/tools/SelectionTool/TransformMode.ts +114 -0
- package/src/tools/SelectionTool/types.ts +11 -0
- package/src/tools/TextTool.ts +326 -0
- package/src/tools/ToolController.ts +178 -0
- package/src/tools/ToolEnabledGroup.ts +14 -0
- package/src/tools/ToolSwitcherShortcut.ts +39 -0
- package/src/tools/ToolbarShortcutHandler.ts +34 -0
- package/src/tools/UndoRedoShortcut.test.ts +56 -0
- package/src/tools/UndoRedoShortcut.ts +25 -0
- package/src/tools/lib.ts +21 -0
- package/src/tools/localization.ts +66 -0
- package/src/types.ts +234 -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/waitForTimeout.ts +9 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const ArrowBuilder_1 = require("../../components/builders/ArrowBuilder");
|
7
|
+
const FreehandLineBuilder_1 = require("../../components/builders/FreehandLineBuilder");
|
8
|
+
const PressureSensitiveFreehandLineBuilder_1 = require("../../components/builders/PressureSensitiveFreehandLineBuilder");
|
9
|
+
const LineBuilder_1 = require("../../components/builders/LineBuilder");
|
10
|
+
const RectangleBuilder_1 = require("../../components/builders/RectangleBuilder");
|
11
|
+
const types_1 = require("../../types");
|
12
|
+
const HTMLToolbar_1 = require("../HTMLToolbar");
|
13
|
+
const makeColorInput_1 = __importDefault(require("../makeColorInput"));
|
14
|
+
const BaseToolWidget_1 = __importDefault(require("./BaseToolWidget"));
|
15
|
+
const Color4_1 = __importDefault(require("../../Color4"));
|
16
|
+
class PenToolWidget extends BaseToolWidget_1.default {
|
17
|
+
constructor(editor, tool, localization) {
|
18
|
+
super(editor, tool, 'pen', localization);
|
19
|
+
this.tool = tool;
|
20
|
+
this.updateInputs = () => { };
|
21
|
+
// Default pen types
|
22
|
+
this.penTypes = [
|
23
|
+
{
|
24
|
+
name: this.localizationTable.pressureSensitiveFreehandPen,
|
25
|
+
id: 'pressure-sensitive-pen',
|
26
|
+
factory: PressureSensitiveFreehandLineBuilder_1.makePressureSensitiveFreehandLineBuilder,
|
27
|
+
},
|
28
|
+
{
|
29
|
+
name: this.localizationTable.freehandPen,
|
30
|
+
id: 'freehand-pen',
|
31
|
+
factory: FreehandLineBuilder_1.makeFreehandLineBuilder,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
name: this.localizationTable.arrowPen,
|
35
|
+
id: 'arrow',
|
36
|
+
factory: ArrowBuilder_1.makeArrowBuilder,
|
37
|
+
},
|
38
|
+
{
|
39
|
+
name: this.localizationTable.linePen,
|
40
|
+
id: 'line',
|
41
|
+
factory: LineBuilder_1.makeLineBuilder,
|
42
|
+
},
|
43
|
+
{
|
44
|
+
name: this.localizationTable.filledRectanglePen,
|
45
|
+
id: 'filled-rectangle',
|
46
|
+
factory: RectangleBuilder_1.makeFilledRectangleBuilder,
|
47
|
+
},
|
48
|
+
{
|
49
|
+
name: this.localizationTable.outlinedRectanglePen,
|
50
|
+
id: 'outlined-rectangle',
|
51
|
+
factory: RectangleBuilder_1.makeOutlinedRectangleBuilder,
|
52
|
+
},
|
53
|
+
];
|
54
|
+
this.editor.notifier.on(types_1.EditorEventType.ToolUpdated, toolEvt => {
|
55
|
+
if (toolEvt.kind !== types_1.EditorEventType.ToolUpdated) {
|
56
|
+
throw new Error('Invalid event type!');
|
57
|
+
}
|
58
|
+
// The button icon may depend on tool properties.
|
59
|
+
if (toolEvt.tool === this.tool) {
|
60
|
+
this.updateIcon();
|
61
|
+
this.updateInputs();
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
getTitle() {
|
66
|
+
return this.targetTool.description;
|
67
|
+
}
|
68
|
+
// Return the index of this tool's stroke factory in the list of
|
69
|
+
// all stroke factories.
|
70
|
+
//
|
71
|
+
// Returns -1 if the stroke factory is not in the list of all stroke factories.
|
72
|
+
getCurrentPenTypeIdx() {
|
73
|
+
const currentFactory = this.tool.getStrokeFactory();
|
74
|
+
for (let i = 0; i < this.penTypes.length; i++) {
|
75
|
+
if (this.penTypes[i].factory === currentFactory) {
|
76
|
+
return i;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return -1;
|
80
|
+
}
|
81
|
+
getCurrentPenType() {
|
82
|
+
for (const penType of this.penTypes) {
|
83
|
+
if (penType.factory === this.tool.getStrokeFactory()) {
|
84
|
+
return penType;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
createIcon() {
|
90
|
+
const strokeFactory = this.tool.getStrokeFactory();
|
91
|
+
if (strokeFactory === FreehandLineBuilder_1.makeFreehandLineBuilder || strokeFactory === PressureSensitiveFreehandLineBuilder_1.makePressureSensitiveFreehandLineBuilder) {
|
92
|
+
// Use a square-root scale to prevent the pen's tip from overflowing.
|
93
|
+
const scale = Math.round(Math.sqrt(this.tool.getThickness()) * 4);
|
94
|
+
const color = this.tool.getColor();
|
95
|
+
const roundedTip = strokeFactory === FreehandLineBuilder_1.makeFreehandLineBuilder;
|
96
|
+
return this.editor.icons.makePenIcon(scale, color.toHexString(), roundedTip);
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
const strokeFactory = this.tool.getStrokeFactory();
|
100
|
+
return this.editor.icons.makeIconFromFactory(this.tool, strokeFactory);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
fillDropdown(dropdown) {
|
104
|
+
const container = document.createElement('div');
|
105
|
+
container.classList.add(`${HTMLToolbar_1.toolbarCSSPrefix}spacedList`);
|
106
|
+
const thicknessRow = document.createElement('div');
|
107
|
+
const objectTypeRow = document.createElement('div');
|
108
|
+
// Thickness: Value of the input is squared to allow for finer control/larger values.
|
109
|
+
const thicknessLabel = document.createElement('label');
|
110
|
+
const thicknessInput = document.createElement('input');
|
111
|
+
const objectSelectLabel = document.createElement('label');
|
112
|
+
const objectTypeSelect = document.createElement('select');
|
113
|
+
// Give inputs IDs so we can label them with a <label for=...>Label text</label>
|
114
|
+
thicknessInput.id = `${HTMLToolbar_1.toolbarCSSPrefix}penThicknessInput${PenToolWidget.idCounter++}`;
|
115
|
+
objectTypeSelect.id = `${HTMLToolbar_1.toolbarCSSPrefix}penBuilderSelect${PenToolWidget.idCounter++}`;
|
116
|
+
thicknessLabel.innerText = this.localizationTable.thicknessLabel;
|
117
|
+
thicknessLabel.setAttribute('for', thicknessInput.id);
|
118
|
+
objectSelectLabel.innerText = this.localizationTable.selectObjectType;
|
119
|
+
objectSelectLabel.setAttribute('for', objectTypeSelect.id);
|
120
|
+
// Use a logarithmic scale for thicknessInput (finer control over thinner strokewidths.)
|
121
|
+
const inverseThicknessInputFn = (t) => Math.log10(t);
|
122
|
+
const thicknessInputFn = (t) => Math.pow(10, t);
|
123
|
+
thicknessInput.type = 'range';
|
124
|
+
thicknessInput.min = `${inverseThicknessInputFn(2)}`;
|
125
|
+
thicknessInput.max = `${inverseThicknessInputFn(400)}`;
|
126
|
+
thicknessInput.step = '0.1';
|
127
|
+
thicknessInput.oninput = () => {
|
128
|
+
this.tool.setThickness(thicknessInputFn(parseFloat(thicknessInput.value)));
|
129
|
+
};
|
130
|
+
thicknessRow.appendChild(thicknessLabel);
|
131
|
+
thicknessRow.appendChild(thicknessInput);
|
132
|
+
objectTypeSelect.oninput = () => {
|
133
|
+
const penTypeIdx = parseInt(objectTypeSelect.value);
|
134
|
+
if (penTypeIdx < 0 || penTypeIdx >= this.penTypes.length) {
|
135
|
+
console.error('Invalid pen type index', penTypeIdx);
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
this.tool.setStrokeFactory(this.penTypes[penTypeIdx].factory);
|
139
|
+
};
|
140
|
+
objectTypeRow.appendChild(objectSelectLabel);
|
141
|
+
objectTypeRow.appendChild(objectTypeSelect);
|
142
|
+
const colorRow = document.createElement('div');
|
143
|
+
const colorLabel = document.createElement('label');
|
144
|
+
const [colorInput, colorInputContainer, setColorInputValue] = (0, makeColorInput_1.default)(this.editor, color => {
|
145
|
+
this.tool.setColor(color);
|
146
|
+
});
|
147
|
+
colorInput.id = `${HTMLToolbar_1.toolbarCSSPrefix}colorInput${PenToolWidget.idCounter++}`;
|
148
|
+
colorLabel.innerText = this.localizationTable.colorLabel;
|
149
|
+
colorLabel.setAttribute('for', colorInput.id);
|
150
|
+
colorRow.appendChild(colorLabel);
|
151
|
+
colorRow.appendChild(colorInputContainer);
|
152
|
+
this.updateInputs = () => {
|
153
|
+
setColorInputValue(this.tool.getColor());
|
154
|
+
thicknessInput.value = inverseThicknessInputFn(this.tool.getThickness()).toString();
|
155
|
+
// Update the list of stroke factories
|
156
|
+
objectTypeSelect.replaceChildren();
|
157
|
+
for (let i = 0; i < this.penTypes.length; i++) {
|
158
|
+
const penType = this.penTypes[i];
|
159
|
+
const option = document.createElement('option');
|
160
|
+
option.value = i.toString();
|
161
|
+
option.innerText = penType.name;
|
162
|
+
objectTypeSelect.appendChild(option);
|
163
|
+
}
|
164
|
+
// Update the selected stroke factory.
|
165
|
+
const strokeFactoryIdx = this.getCurrentPenTypeIdx();
|
166
|
+
if (strokeFactoryIdx === -1) {
|
167
|
+
objectTypeSelect.value = '';
|
168
|
+
}
|
169
|
+
else {
|
170
|
+
objectTypeSelect.value = strokeFactoryIdx.toString();
|
171
|
+
}
|
172
|
+
};
|
173
|
+
this.updateInputs();
|
174
|
+
container.replaceChildren(colorRow, thicknessRow, objectTypeRow);
|
175
|
+
dropdown.replaceChildren(container);
|
176
|
+
return true;
|
177
|
+
}
|
178
|
+
onKeyPress(event) {
|
179
|
+
if (!this.isSelected()) {
|
180
|
+
return false;
|
181
|
+
}
|
182
|
+
// Map alt+0-9 to different pen types.
|
183
|
+
if (/^[0-9]$/.exec(event.key) && event.ctrlKey) {
|
184
|
+
const penTypeIdx = parseInt(event.key) - 1;
|
185
|
+
if (penTypeIdx >= 0 && penTypeIdx < this.penTypes.length) {
|
186
|
+
this.tool.setStrokeFactory(this.penTypes[penTypeIdx].factory);
|
187
|
+
return true;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
return false;
|
191
|
+
}
|
192
|
+
serializeState() {
|
193
|
+
var _a;
|
194
|
+
return Object.assign(Object.assign({}, super.serializeState()), { color: this.tool.getColor().toHexString(), thickness: this.tool.getThickness(), strokeFactoryId: (_a = this.getCurrentPenType()) === null || _a === void 0 ? void 0 : _a.id });
|
195
|
+
}
|
196
|
+
deserializeFrom(state) {
|
197
|
+
super.deserializeFrom(state);
|
198
|
+
const verifyPropertyType = (propertyName, expectedType) => {
|
199
|
+
const actualType = typeof (state[propertyName]);
|
200
|
+
if (actualType !== expectedType) {
|
201
|
+
throw new Error(`Deserializing property ${propertyName}: Invalid type. Expected ${expectedType},` +
|
202
|
+
` was ${actualType}.`);
|
203
|
+
}
|
204
|
+
};
|
205
|
+
if (state.color) {
|
206
|
+
verifyPropertyType('color', 'string');
|
207
|
+
this.tool.setColor(Color4_1.default.fromHex(state.color));
|
208
|
+
}
|
209
|
+
if (state.thickness) {
|
210
|
+
verifyPropertyType('thickness', 'number');
|
211
|
+
this.tool.setThickness(state.thickness);
|
212
|
+
}
|
213
|
+
if (state.strokeFactoryId) {
|
214
|
+
verifyPropertyType('strokeFactoryId', 'string');
|
215
|
+
const factoryId = state.strokeFactoryId;
|
216
|
+
for (const penType of this.penTypes) {
|
217
|
+
if (factoryId === penType.id) {
|
218
|
+
this.tool.setStrokeFactory(penType.factory);
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
exports.default = PenToolWidget;
|
226
|
+
PenToolWidget.idCounter = 0;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import Editor from '../../Editor';
|
2
|
+
import SelectionTool from '../../tools/SelectionTool/SelectionTool';
|
3
|
+
import { KeyPressEvent } from '../../types';
|
4
|
+
import { ToolbarLocalization } from '../localization';
|
5
|
+
import BaseToolWidget from './BaseToolWidget';
|
6
|
+
export default class SelectionToolWidget extends BaseToolWidget {
|
7
|
+
private tool;
|
8
|
+
constructor(editor: Editor, tool: SelectionTool, localization?: ToolbarLocalization);
|
9
|
+
private resizeImageToSelection;
|
10
|
+
protected onKeyPress(event: KeyPressEvent): boolean;
|
11
|
+
protected getTitle(): string;
|
12
|
+
protected createIcon(): Element;
|
13
|
+
}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const Color4_1 = __importDefault(require("../../Color4"));
|
16
|
+
const RestylableComponent_1 = require("../../components/RestylableComponent");
|
17
|
+
const uniteCommands_1 = __importDefault(require("../../commands/uniteCommands"));
|
18
|
+
const types_1 = require("../../types");
|
19
|
+
const makeColorInput_1 = __importDefault(require("../makeColorInput"));
|
20
|
+
const ActionButtonWidget_1 = __importDefault(require("./ActionButtonWidget"));
|
21
|
+
const BaseToolWidget_1 = __importDefault(require("./BaseToolWidget"));
|
22
|
+
const BaseWidget_1 = __importDefault(require("./BaseWidget"));
|
23
|
+
class RestyleSelectionWidget extends BaseWidget_1.default {
|
24
|
+
constructor(editor, selectionTool, localizationTable) {
|
25
|
+
super(editor, 'restyle-selection', localizationTable);
|
26
|
+
this.selectionTool = selectionTool;
|
27
|
+
this.updateFormatData = () => { };
|
28
|
+
// Allow showing the dropdown even if this widget isn't selected yet
|
29
|
+
this.container.classList.add('dropdownShowable');
|
30
|
+
this.editor.notifier.on(types_1.EditorEventType.ToolUpdated, toolEvt => {
|
31
|
+
if (toolEvt.kind !== types_1.EditorEventType.ToolUpdated) {
|
32
|
+
throw new Error('Invalid event type!');
|
33
|
+
}
|
34
|
+
if (toolEvt.tool === this.selectionTool) {
|
35
|
+
this.updateFormatData();
|
36
|
+
}
|
37
|
+
});
|
38
|
+
}
|
39
|
+
getTitle() {
|
40
|
+
return this.localizationTable.reformatSelection;
|
41
|
+
}
|
42
|
+
createIcon() {
|
43
|
+
return this.editor.icons.makeFormatSelectionIcon();
|
44
|
+
}
|
45
|
+
handleClick() {
|
46
|
+
this.setDropdownVisible(!this.isDropdownVisible());
|
47
|
+
}
|
48
|
+
fillDropdown(dropdown) {
|
49
|
+
const container = document.createElement('div');
|
50
|
+
const colorRow = document.createElement('div');
|
51
|
+
const colorLabel = document.createElement('label');
|
52
|
+
const [colorInput, colorInputContainer, setColorInputValue] = (0, makeColorInput_1.default)(this.editor, color => {
|
53
|
+
const selection = this.selectionTool.getSelection();
|
54
|
+
if (selection) {
|
55
|
+
const updateStyleCommands = [];
|
56
|
+
for (const elem of selection.getSelectedObjects()) {
|
57
|
+
if ((0, RestylableComponent_1.isRestylableComponent)(elem)) {
|
58
|
+
updateStyleCommands.push(elem.updateStyle({ color }));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
const unitedCommand = (0, uniteCommands_1.default)(updateStyleCommands);
|
62
|
+
this.editor.dispatch(unitedCommand);
|
63
|
+
}
|
64
|
+
});
|
65
|
+
colorLabel.innerText = this.localizationTable.colorLabel;
|
66
|
+
this.updateFormatData = () => {
|
67
|
+
const selection = this.selectionTool.getSelection();
|
68
|
+
if (selection) {
|
69
|
+
colorInput.disabled = false;
|
70
|
+
const colors = [];
|
71
|
+
for (const elem of selection.getSelectedObjects()) {
|
72
|
+
if ((0, RestylableComponent_1.isRestylableComponent)(elem)) {
|
73
|
+
const color = elem.getStyle().color;
|
74
|
+
if (color) {
|
75
|
+
colors.push(color);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
setColorInputValue(Color4_1.default.average(colors));
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
colorInput.disabled = true;
|
83
|
+
}
|
84
|
+
};
|
85
|
+
colorRow.replaceChildren(colorLabel, colorInputContainer);
|
86
|
+
container.replaceChildren(colorRow);
|
87
|
+
dropdown.replaceChildren(container);
|
88
|
+
return true;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
class SelectionToolWidget extends BaseToolWidget_1.default {
|
92
|
+
constructor(editor, tool, localization) {
|
93
|
+
super(editor, tool, 'selection-tool-widget', localization);
|
94
|
+
this.tool = tool;
|
95
|
+
const resizeButton = new ActionButtonWidget_1.default(editor, 'resize-btn', () => editor.icons.makeResizeViewportIcon(), this.localizationTable.resizeImageToSelection, () => {
|
96
|
+
this.resizeImageToSelection();
|
97
|
+
}, localization);
|
98
|
+
const deleteButton = new ActionButtonWidget_1.default(editor, 'delete-btn', () => editor.icons.makeDeleteSelectionIcon(), this.localizationTable.deleteSelection, () => {
|
99
|
+
const selection = this.tool.getSelection();
|
100
|
+
this.editor.dispatch(selection.deleteSelectedObjects());
|
101
|
+
this.tool.clearSelection();
|
102
|
+
}, localization);
|
103
|
+
const duplicateButton = new ActionButtonWidget_1.default(editor, 'duplicate-btn', () => editor.icons.makeDuplicateSelectionIcon(), this.localizationTable.duplicateSelection, () => __awaiter(this, void 0, void 0, function* () {
|
104
|
+
const selection = this.tool.getSelection();
|
105
|
+
this.editor.dispatch(yield selection.duplicateSelectedObjects());
|
106
|
+
}), localization);
|
107
|
+
const restyleButton = new RestyleSelectionWidget(editor, this.tool, localization);
|
108
|
+
this.addSubWidget(resizeButton);
|
109
|
+
this.addSubWidget(deleteButton);
|
110
|
+
this.addSubWidget(duplicateButton);
|
111
|
+
this.addSubWidget(restyleButton);
|
112
|
+
const updateDisabled = (disabled) => {
|
113
|
+
resizeButton.setDisabled(disabled);
|
114
|
+
deleteButton.setDisabled(disabled);
|
115
|
+
duplicateButton.setDisabled(disabled);
|
116
|
+
restyleButton.setDisabled(disabled);
|
117
|
+
};
|
118
|
+
updateDisabled(true);
|
119
|
+
// Enable/disable actions based on whether items are selected
|
120
|
+
this.editor.notifier.on(types_1.EditorEventType.ToolUpdated, toolEvt => {
|
121
|
+
if (toolEvt.kind !== types_1.EditorEventType.ToolUpdated) {
|
122
|
+
throw new Error('Invalid event type!');
|
123
|
+
}
|
124
|
+
if (toolEvt.tool === this.tool) {
|
125
|
+
const selection = this.tool.getSelection();
|
126
|
+
const hasSelection = selection && selection.getSelectedItemCount() > 0;
|
127
|
+
updateDisabled(!hasSelection);
|
128
|
+
}
|
129
|
+
});
|
130
|
+
}
|
131
|
+
resizeImageToSelection() {
|
132
|
+
const selection = this.tool.getSelection();
|
133
|
+
if (selection) {
|
134
|
+
this.editor.dispatch(this.editor.setImportExportRect(selection.region));
|
135
|
+
}
|
136
|
+
}
|
137
|
+
onKeyPress(event) {
|
138
|
+
// Resize image to selection:
|
139
|
+
// Other keys are handled directly by the selection tool.
|
140
|
+
if (event.ctrlKey && event.key === 'r') {
|
141
|
+
this.resizeImageToSelection();
|
142
|
+
return true;
|
143
|
+
}
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
getTitle() {
|
147
|
+
return this.localizationTable.select;
|
148
|
+
}
|
149
|
+
createIcon() {
|
150
|
+
return this.editor.icons.makeSelectionIcon();
|
151
|
+
}
|
152
|
+
}
|
153
|
+
exports.default = SelectionToolWidget;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import Editor from '../../Editor';
|
2
|
+
import TextTool from '../../tools/TextTool';
|
3
|
+
import { ToolbarLocalization } from '../localization';
|
4
|
+
import BaseToolWidget from './BaseToolWidget';
|
5
|
+
import { SavedToolbuttonState } from './BaseWidget';
|
6
|
+
export default class TextToolWidget extends BaseToolWidget {
|
7
|
+
private tool;
|
8
|
+
private updateDropdownInputs;
|
9
|
+
constructor(editor: Editor, tool: TextTool, localization?: ToolbarLocalization);
|
10
|
+
protected getTitle(): string;
|
11
|
+
protected createIcon(): Element;
|
12
|
+
private static idCounter;
|
13
|
+
protected fillDropdown(dropdown: HTMLElement): boolean;
|
14
|
+
serializeState(): SavedToolbuttonState;
|
15
|
+
deserializeFrom(state: SavedToolbuttonState): void;
|
16
|
+
}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const Color4_1 = __importDefault(require("../../Color4"));
|
7
|
+
const types_1 = require("../../types");
|
8
|
+
const HTMLToolbar_1 = require("../HTMLToolbar");
|
9
|
+
const makeColorInput_1 = __importDefault(require("../makeColorInput"));
|
10
|
+
const BaseToolWidget_1 = __importDefault(require("./BaseToolWidget"));
|
11
|
+
class TextToolWidget extends BaseToolWidget_1.default {
|
12
|
+
constructor(editor, tool, localization) {
|
13
|
+
super(editor, tool, 'text-tool-widget', localization);
|
14
|
+
this.tool = tool;
|
15
|
+
this.updateDropdownInputs = null;
|
16
|
+
editor.notifier.on(types_1.EditorEventType.ToolUpdated, evt => {
|
17
|
+
var _a;
|
18
|
+
if (evt.kind === types_1.EditorEventType.ToolUpdated && evt.tool === tool) {
|
19
|
+
this.updateIcon();
|
20
|
+
(_a = this.updateDropdownInputs) === null || _a === void 0 ? void 0 : _a.call(this);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
}
|
24
|
+
getTitle() {
|
25
|
+
return this.targetTool.description;
|
26
|
+
}
|
27
|
+
createIcon() {
|
28
|
+
const textStyle = this.tool.getTextStyle();
|
29
|
+
return this.editor.icons.makeTextIcon(textStyle);
|
30
|
+
}
|
31
|
+
fillDropdown(dropdown) {
|
32
|
+
const container = document.createElement('div');
|
33
|
+
container.classList.add(`${HTMLToolbar_1.toolbarCSSPrefix}spacedList`);
|
34
|
+
const fontRow = document.createElement('div');
|
35
|
+
const colorRow = document.createElement('div');
|
36
|
+
const sizeRow = document.createElement('div');
|
37
|
+
const fontInput = document.createElement('select');
|
38
|
+
const fontLabel = document.createElement('label');
|
39
|
+
const sizeInput = document.createElement('input');
|
40
|
+
const sizeLabel = document.createElement('label');
|
41
|
+
const [colorInput, colorInputContainer, setColorInputValue] = (0, makeColorInput_1.default)(this.editor, color => {
|
42
|
+
this.tool.setColor(color);
|
43
|
+
});
|
44
|
+
const colorLabel = document.createElement('label');
|
45
|
+
const fontsInInput = new Set();
|
46
|
+
const addFontToInput = (fontName) => {
|
47
|
+
const option = document.createElement('option');
|
48
|
+
option.value = fontName;
|
49
|
+
option.textContent = fontName;
|
50
|
+
fontInput.appendChild(option);
|
51
|
+
fontsInInput.add(fontName);
|
52
|
+
};
|
53
|
+
sizeInput.setAttribute('type', 'number');
|
54
|
+
sizeInput.min = '1';
|
55
|
+
sizeInput.max = '128';
|
56
|
+
fontLabel.innerText = this.localizationTable.fontLabel;
|
57
|
+
colorLabel.innerText = this.localizationTable.colorLabel;
|
58
|
+
sizeLabel.innerText = this.localizationTable.textSize;
|
59
|
+
colorInput.id = `${HTMLToolbar_1.toolbarCSSPrefix}-text-color-input-${TextToolWidget.idCounter++}`;
|
60
|
+
colorLabel.setAttribute('for', colorInput.id);
|
61
|
+
sizeInput.id = `${HTMLToolbar_1.toolbarCSSPrefix}-text-size-input-${TextToolWidget.idCounter++}`;
|
62
|
+
sizeLabel.setAttribute('for', sizeInput.id);
|
63
|
+
addFontToInput('monospace');
|
64
|
+
addFontToInput('serif');
|
65
|
+
addFontToInput('sans-serif');
|
66
|
+
fontInput.id = `${HTMLToolbar_1.toolbarCSSPrefix}-text-font-input-${TextToolWidget.idCounter++}`;
|
67
|
+
fontLabel.setAttribute('for', fontInput.id);
|
68
|
+
fontInput.onchange = () => {
|
69
|
+
this.tool.setFontFamily(fontInput.value);
|
70
|
+
};
|
71
|
+
sizeInput.onchange = () => {
|
72
|
+
const size = parseInt(sizeInput.value);
|
73
|
+
if (!isNaN(size) && size > 0) {
|
74
|
+
this.tool.setFontSize(size);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
colorRow.appendChild(colorLabel);
|
78
|
+
colorRow.appendChild(colorInputContainer);
|
79
|
+
fontRow.appendChild(fontLabel);
|
80
|
+
fontRow.appendChild(fontInput);
|
81
|
+
sizeRow.appendChild(sizeLabel);
|
82
|
+
sizeRow.appendChild(sizeInput);
|
83
|
+
this.updateDropdownInputs = () => {
|
84
|
+
const style = this.tool.getTextStyle();
|
85
|
+
setColorInputValue(style.renderingStyle.fill);
|
86
|
+
if (!fontsInInput.has(style.fontFamily)) {
|
87
|
+
addFontToInput(style.fontFamily);
|
88
|
+
}
|
89
|
+
fontInput.value = style.fontFamily;
|
90
|
+
sizeInput.value = `${style.size}`;
|
91
|
+
};
|
92
|
+
this.updateDropdownInputs();
|
93
|
+
container.replaceChildren(colorRow, sizeRow, fontRow);
|
94
|
+
dropdown.appendChild(container);
|
95
|
+
return true;
|
96
|
+
}
|
97
|
+
serializeState() {
|
98
|
+
const textStyle = this.tool.getTextStyle();
|
99
|
+
return Object.assign(Object.assign({}, super.serializeState()), { fontFamily: textStyle.fontFamily, textSize: textStyle.size, color: textStyle.renderingStyle.fill.toHexString() });
|
100
|
+
}
|
101
|
+
deserializeFrom(state) {
|
102
|
+
if (state.fontFamily && typeof (state.fontFamily) === 'string') {
|
103
|
+
this.tool.setFontFamily(state.fontFamily);
|
104
|
+
}
|
105
|
+
if (state.color && typeof (state.color) === 'string') {
|
106
|
+
this.tool.setColor(Color4_1.default.fromHex(state.color));
|
107
|
+
}
|
108
|
+
if (state.textSize && typeof (state.textSize) === 'number') {
|
109
|
+
this.tool.setFontSize(state.textSize);
|
110
|
+
}
|
111
|
+
super.deserializeFrom(state);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
exports.default = TextToolWidget;
|
115
|
+
TextToolWidget.idCounter = 0;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export { default as ActionButtonWidget } from './ActionButtonWidget';
|
2
|
+
export { default as BaseToolWidget } from './BaseToolWidget';
|
3
|
+
export { default as BaseWidget } from './BaseWidget';
|
4
|
+
export { default as PenToolWidget } from './PenToolWidget';
|
5
|
+
export { default as TextToolWidget } from './TextToolWidget';
|
6
|
+
export { default as HandToolWidget } from './HandToolWidget';
|
7
|
+
export { default as SelectionToolWidget } from './SelectionToolWidget';
|
8
|
+
export { default as EraserToolWidget } from './EraserToolWidget';
|
9
|
+
export { default as InsertImageWidget } from './InsertImageWidget';
|
10
|
+
export { default as DocumentPropertiesWidget } from './DocumentPropertiesWidget';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.DocumentPropertiesWidget = exports.InsertImageWidget = exports.EraserToolWidget = exports.SelectionToolWidget = exports.HandToolWidget = exports.TextToolWidget = exports.PenToolWidget = exports.BaseWidget = exports.BaseToolWidget = exports.ActionButtonWidget = void 0;
|
7
|
+
var ActionButtonWidget_1 = require("./ActionButtonWidget");
|
8
|
+
Object.defineProperty(exports, "ActionButtonWidget", { enumerable: true, get: function () { return __importDefault(ActionButtonWidget_1).default; } });
|
9
|
+
var BaseToolWidget_1 = require("./BaseToolWidget");
|
10
|
+
Object.defineProperty(exports, "BaseToolWidget", { enumerable: true, get: function () { return __importDefault(BaseToolWidget_1).default; } });
|
11
|
+
var BaseWidget_1 = require("./BaseWidget");
|
12
|
+
Object.defineProperty(exports, "BaseWidget", { enumerable: true, get: function () { return __importDefault(BaseWidget_1).default; } });
|
13
|
+
var PenToolWidget_1 = require("./PenToolWidget");
|
14
|
+
Object.defineProperty(exports, "PenToolWidget", { enumerable: true, get: function () { return __importDefault(PenToolWidget_1).default; } });
|
15
|
+
var TextToolWidget_1 = require("./TextToolWidget");
|
16
|
+
Object.defineProperty(exports, "TextToolWidget", { enumerable: true, get: function () { return __importDefault(TextToolWidget_1).default; } });
|
17
|
+
var HandToolWidget_1 = require("./HandToolWidget");
|
18
|
+
Object.defineProperty(exports, "HandToolWidget", { enumerable: true, get: function () { return __importDefault(HandToolWidget_1).default; } });
|
19
|
+
var SelectionToolWidget_1 = require("./SelectionToolWidget");
|
20
|
+
Object.defineProperty(exports, "SelectionToolWidget", { enumerable: true, get: function () { return __importDefault(SelectionToolWidget_1).default; } });
|
21
|
+
var EraserToolWidget_1 = require("./EraserToolWidget");
|
22
|
+
Object.defineProperty(exports, "EraserToolWidget", { enumerable: true, get: function () { return __importDefault(EraserToolWidget_1).default; } });
|
23
|
+
var InsertImageWidget_1 = require("./InsertImageWidget");
|
24
|
+
Object.defineProperty(exports, "InsertImageWidget", { enumerable: true, get: function () { return __importDefault(InsertImageWidget_1).default; } });
|
25
|
+
var DocumentPropertiesWidget_1 = require("./DocumentPropertiesWidget");
|
26
|
+
Object.defineProperty(exports, "DocumentPropertiesWidget", { enumerable: true, get: function () { return __importDefault(DocumentPropertiesWidget_1).default; } });
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { PointerEvtListener, WheelEvt, PointerEvt, EditorNotifier, KeyPressEvent, KeyUpEvent, PasteEvent, CopyEvent } from '../types';
|
2
|
+
import ToolEnabledGroup from './ToolEnabledGroup';
|
3
|
+
export default abstract class BaseTool implements PointerEvtListener {
|
4
|
+
private notifier;
|
5
|
+
readonly description: string;
|
6
|
+
private enabled;
|
7
|
+
private group;
|
8
|
+
onPointerDown(_event: PointerEvt): boolean;
|
9
|
+
onPointerMove(_event: PointerEvt): void;
|
10
|
+
onPointerUp(_event: PointerEvt): void;
|
11
|
+
onGestureCancel(): void;
|
12
|
+
protected constructor(notifier: EditorNotifier, description: string);
|
13
|
+
onWheel(_event: WheelEvt): boolean;
|
14
|
+
onCopy(_event: CopyEvent): boolean;
|
15
|
+
onPaste(_event: PasteEvent): boolean;
|
16
|
+
onKeyPress(_event: KeyPressEvent): boolean;
|
17
|
+
onKeyUp(_event: KeyUpEvent): boolean;
|
18
|
+
setEnabled(enabled: boolean): void;
|
19
|
+
isEnabled(): boolean;
|
20
|
+
setToolGroup(group: ToolEnabledGroup): void;
|
21
|
+
getToolGroup(): ToolEnabledGroup | null;
|
22
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const types_1 = require("../types");
|
4
|
+
class BaseTool {
|
5
|
+
onPointerDown(_event) { return false; }
|
6
|
+
onPointerMove(_event) { }
|
7
|
+
onPointerUp(_event) { }
|
8
|
+
onGestureCancel() { }
|
9
|
+
constructor(notifier, description) {
|
10
|
+
this.notifier = notifier;
|
11
|
+
this.description = description;
|
12
|
+
this.enabled = true;
|
13
|
+
this.group = null;
|
14
|
+
}
|
15
|
+
onWheel(_event) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
onCopy(_event) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
onPaste(_event) {
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
onKeyPress(_event) {
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
onKeyUp(_event) {
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
setEnabled(enabled) {
|
31
|
+
var _a;
|
32
|
+
this.enabled = enabled;
|
33
|
+
// Ensure that at most one tool in the group is enabled.
|
34
|
+
if (enabled) {
|
35
|
+
(_a = this.group) === null || _a === void 0 ? void 0 : _a.notifyEnabled(this);
|
36
|
+
this.notifier.dispatch(types_1.EditorEventType.ToolEnabled, {
|
37
|
+
kind: types_1.EditorEventType.ToolEnabled,
|
38
|
+
tool: this,
|
39
|
+
});
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
this.notifier.dispatch(types_1.EditorEventType.ToolDisabled, {
|
43
|
+
kind: types_1.EditorEventType.ToolDisabled,
|
44
|
+
tool: this,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
isEnabled() {
|
49
|
+
return this.enabled;
|
50
|
+
}
|
51
|
+
// Connect this tool to a set of other tools, ensuring that at most one
|
52
|
+
// of the tools in the group is enabled.
|
53
|
+
setToolGroup(group) {
|
54
|
+
if (this.isEnabled()) {
|
55
|
+
group.notifyEnabled(this);
|
56
|
+
}
|
57
|
+
this.group = group;
|
58
|
+
}
|
59
|
+
getToolGroup() {
|
60
|
+
if (this.group) {
|
61
|
+
return this.group;
|
62
|
+
}
|
63
|
+
return null;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
exports.default = BaseTool;
|