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