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
package/src/toolbar/lib.ts
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export interface ToolbarLocalization {
|
4
|
-
fontLabel: string;
|
5
|
-
textSize: string;
|
6
|
-
touchPanning: string;
|
7
|
-
lockRotation: string;
|
8
|
-
outlinedRectanglePen: string;
|
9
|
-
filledRectanglePen: string;
|
10
|
-
linePen: string;
|
11
|
-
arrowPen: string;
|
12
|
-
image: string;
|
13
|
-
inputAltText: string;
|
14
|
-
chooseFile: string;
|
15
|
-
cancel: string;
|
16
|
-
submit: string;
|
17
|
-
freehandPen: string;
|
18
|
-
pressureSensitiveFreehandPen: string;
|
19
|
-
selectObjectType: string;
|
20
|
-
colorLabel: string;
|
21
|
-
pen: string;
|
22
|
-
eraser: string;
|
23
|
-
select: string;
|
24
|
-
handTool: string;
|
25
|
-
thicknessLabel: string;
|
26
|
-
resizeImageToSelection: string;
|
27
|
-
deleteSelection: string;
|
28
|
-
duplicateSelection: string;
|
29
|
-
pickColorFromScreen: string;
|
30
|
-
clickToPickColorAnnouncement: string;
|
31
|
-
reformatSelection: string;
|
32
|
-
undo: string;
|
33
|
-
redo: string;
|
34
|
-
zoom: string;
|
35
|
-
resetView: string;
|
36
|
-
selectionToolKeyboardShortcuts: string;
|
37
|
-
paste: string;
|
38
|
-
documentProperties: string;
|
39
|
-
backgroundColor: string;
|
40
|
-
imageWidthOption: string;
|
41
|
-
imageHeightOption: string;
|
42
|
-
toggleOverflow: string,
|
43
|
-
|
44
|
-
errorImageHasZeroSize: string;
|
45
|
-
|
46
|
-
dropdownShown: (toolName: string)=> string;
|
47
|
-
dropdownHidden: (toolName: string)=> string;
|
48
|
-
zoomLevel: (zoomPercentage: number)=> string;
|
49
|
-
colorChangedAnnouncement: (color: string)=> string;
|
50
|
-
imageSize: (size: number, units: string)=> string;
|
51
|
-
imageLoadError: (message: string)=> string;
|
52
|
-
}
|
53
|
-
|
54
|
-
export const defaultToolbarLocalization: ToolbarLocalization = {
|
55
|
-
pen: 'Pen',
|
56
|
-
eraser: 'Eraser',
|
57
|
-
select: 'Select',
|
58
|
-
handTool: 'Pan',
|
59
|
-
zoom: 'Zoom',
|
60
|
-
image: 'Image',
|
61
|
-
reformatSelection: 'Format selection',
|
62
|
-
inputAltText: 'Alt text: ',
|
63
|
-
chooseFile: 'Choose file: ',
|
64
|
-
submit: 'Submit',
|
65
|
-
cancel: 'Cancel',
|
66
|
-
resetView: 'Reset view',
|
67
|
-
thicknessLabel: 'Thickness: ',
|
68
|
-
colorLabel: 'Color: ',
|
69
|
-
fontLabel: 'Font: ',
|
70
|
-
textSize: 'Size: ',
|
71
|
-
resizeImageToSelection: 'Resize image to selection',
|
72
|
-
deleteSelection: 'Delete selection',
|
73
|
-
duplicateSelection: 'Duplicate selection',
|
74
|
-
undo: 'Undo',
|
75
|
-
redo: 'Redo',
|
76
|
-
selectObjectType: 'Object type: ',
|
77
|
-
pickColorFromScreen: 'Pick color from screen',
|
78
|
-
clickToPickColorAnnouncement: 'Click on the screen to pick a color',
|
79
|
-
selectionToolKeyboardShortcuts: 'Selection tool: Use arrow keys to move selected items, lowercase/uppercase ‘i’ and ‘o’ to resize.',
|
80
|
-
documentProperties: 'Document',
|
81
|
-
backgroundColor: 'Background Color: ',
|
82
|
-
imageWidthOption: 'Width: ',
|
83
|
-
imageHeightOption: 'Height: ',
|
84
|
-
toggleOverflow: 'More',
|
85
|
-
|
86
|
-
touchPanning: 'Touchscreen panning',
|
87
|
-
|
88
|
-
freehandPen: 'Freehand',
|
89
|
-
pressureSensitiveFreehandPen: 'Freehand (pressure sensitive)',
|
90
|
-
arrowPen: 'Arrow',
|
91
|
-
linePen: 'Line',
|
92
|
-
outlinedRectanglePen: 'Outlined rectangle',
|
93
|
-
filledRectanglePen: 'Filled rectangle',
|
94
|
-
lockRotation: 'Lock rotation',
|
95
|
-
|
96
|
-
paste: 'Paste',
|
97
|
-
|
98
|
-
dropdownShown: (toolName) => `Dropdown for ${toolName} shown`,
|
99
|
-
dropdownHidden: (toolName) => `Dropdown for ${toolName} hidden`,
|
100
|
-
zoomLevel: (zoomPercent: number) => `Zoom: ${zoomPercent}%`,
|
101
|
-
colorChangedAnnouncement: (color: string) => `Color changed to ${color}`,
|
102
|
-
imageSize: (size: number, units: string) => `Image size: ${size} ${units}`,
|
103
|
-
|
104
|
-
errorImageHasZeroSize: 'Error: Image has zero size',
|
105
|
-
imageLoadError: (message: string)=> `Error loading image: ${message}`,
|
106
|
-
};
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import Color4 from '../Color4';
|
2
|
-
import Editor from '../Editor';
|
3
|
-
import PipetteTool from '../tools/PipetteTool';
|
4
|
-
import { EditorEventType } from '../types';
|
5
|
-
|
6
|
-
type OnColorChangeListener = (color: Color4)=>void;
|
7
|
-
type SetColorCallback = (color: Color4|string) => void;
|
8
|
-
|
9
|
-
// Returns [ color input, input container, callback to change the color value ].
|
10
|
-
export const makeColorInput = (
|
11
|
-
editor: Editor, onColorChange: OnColorChangeListener
|
12
|
-
): [ HTMLInputElement, HTMLElement, SetColorCallback ] => {
|
13
|
-
|
14
|
-
const colorInputContainer = document.createElement('span');
|
15
|
-
const colorInput = document.createElement('input');
|
16
|
-
|
17
|
-
colorInput.type = 'button';
|
18
|
-
colorInput.classList.add('coloris_input');
|
19
|
-
colorInputContainer.classList.add('color-input-container');
|
20
|
-
|
21
|
-
colorInputContainer.appendChild(colorInput);
|
22
|
-
const pipetteController = addPipetteTool(editor, colorInputContainer, (color: Color4) => {
|
23
|
-
colorInput.value = color.toHexString();
|
24
|
-
onInputEnd();
|
25
|
-
|
26
|
-
// Update the color preview, if it exists (may be managed by Coloris).
|
27
|
-
const parentElem = colorInput.parentElement;
|
28
|
-
if (parentElem && parentElem.classList.contains('clr-field')) {
|
29
|
-
parentElem.style.color = colorInput.value;
|
30
|
-
}
|
31
|
-
});
|
32
|
-
|
33
|
-
let currentColor: Color4|undefined;
|
34
|
-
const handleColorInput = () => {
|
35
|
-
currentColor = Color4.fromHex(colorInput.value);
|
36
|
-
};
|
37
|
-
|
38
|
-
// Only change the pen color when we finish sending input (this limits the number of
|
39
|
-
// editor events triggered and accessibility announcements).
|
40
|
-
const onInputEnd = () => {
|
41
|
-
handleColorInput();
|
42
|
-
|
43
|
-
if (currentColor) {
|
44
|
-
editor.announceForAccessibility(
|
45
|
-
editor.localization.colorChangedAnnouncement(currentColor.toHexString())
|
46
|
-
);
|
47
|
-
onColorChange(currentColor);
|
48
|
-
editor.notifier.dispatch(EditorEventType.ColorPickerColorSelected, {
|
49
|
-
kind: EditorEventType.ColorPickerColorSelected,
|
50
|
-
color: currentColor,
|
51
|
-
});
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
colorInput.oninput = handleColorInput;
|
56
|
-
colorInput.addEventListener('open', () => {
|
57
|
-
editor.notifier.dispatch(EditorEventType.ColorPickerToggled, {
|
58
|
-
kind: EditorEventType.ColorPickerToggled,
|
59
|
-
open: true,
|
60
|
-
});
|
61
|
-
pipetteController.cancel();
|
62
|
-
});
|
63
|
-
colorInput.addEventListener('close', () => {
|
64
|
-
editor.notifier.dispatch(EditorEventType.ColorPickerToggled, {
|
65
|
-
kind: EditorEventType.ColorPickerToggled,
|
66
|
-
open: false,
|
67
|
-
});
|
68
|
-
onInputEnd();
|
69
|
-
});
|
70
|
-
|
71
|
-
const setColorInputValue = (color: Color4|string) => {
|
72
|
-
if (typeof color === 'object') {
|
73
|
-
color = color.toHexString();
|
74
|
-
}
|
75
|
-
|
76
|
-
colorInput.value = color;
|
77
|
-
|
78
|
-
// Fire all color event listeners. See
|
79
|
-
// https://github.com/mdbassit/Coloris#manually-updating-the-thumbnail
|
80
|
-
colorInput.dispatchEvent(new Event('input', { bubbles: true }));
|
81
|
-
};
|
82
|
-
|
83
|
-
return [ colorInput, colorInputContainer, setColorInputValue ];
|
84
|
-
};
|
85
|
-
|
86
|
-
const addPipetteTool = (editor: Editor, container: HTMLElement, onColorChange: OnColorChangeListener) => {
|
87
|
-
const pipetteButton = document.createElement('button');
|
88
|
-
pipetteButton.classList.add('pipetteButton');
|
89
|
-
pipetteButton.title = editor.localization.pickColorFromScreen;
|
90
|
-
pipetteButton.setAttribute('alt', pipetteButton.title);
|
91
|
-
|
92
|
-
const updatePipetteIcon = (color?: Color4) => {
|
93
|
-
pipetteButton.replaceChildren(editor.icons.makePipetteIcon(color));
|
94
|
-
};
|
95
|
-
updatePipetteIcon();
|
96
|
-
|
97
|
-
const pipetteTool: PipetteTool|undefined = editor.toolController.getMatchingTools(PipetteTool)[0];
|
98
|
-
const endColorSelectMode = () => {
|
99
|
-
pipetteTool?.clearColorListener();
|
100
|
-
updatePipetteIcon();
|
101
|
-
pipetteButton.classList.remove('active');
|
102
|
-
};
|
103
|
-
const pipetteColorSelect = (color: Color4|null) => {
|
104
|
-
endColorSelectMode();
|
105
|
-
|
106
|
-
if (color) {
|
107
|
-
onColorChange(color);
|
108
|
-
}
|
109
|
-
};
|
110
|
-
const pipetteColorPreview = (color: Color4|null) => {
|
111
|
-
if (color) {
|
112
|
-
updatePipetteIcon(color);
|
113
|
-
} else {
|
114
|
-
updatePipetteIcon();
|
115
|
-
}
|
116
|
-
};
|
117
|
-
|
118
|
-
pipetteButton.onclick = () => {
|
119
|
-
// If already picking, cancel it.
|
120
|
-
if (pipetteButton.classList.contains('active')) {
|
121
|
-
endColorSelectMode();
|
122
|
-
return;
|
123
|
-
}
|
124
|
-
|
125
|
-
pipetteTool?.setColorListener(
|
126
|
-
pipetteColorPreview,
|
127
|
-
pipetteColorSelect,
|
128
|
-
);
|
129
|
-
if (pipetteTool) {
|
130
|
-
pipetteButton.classList.add('active');
|
131
|
-
editor.announceForAccessibility(editor.localization.clickToPickColorAnnouncement);
|
132
|
-
}
|
133
|
-
};
|
134
|
-
|
135
|
-
container.appendChild(pipetteButton);
|
136
|
-
|
137
|
-
return {
|
138
|
-
// Cancel a pipette color selection if one is in progress.
|
139
|
-
cancel: () => {
|
140
|
-
endColorSelectMode();
|
141
|
-
},
|
142
|
-
};
|
143
|
-
};
|
144
|
-
|
145
|
-
export default makeColorInput;
|
package/src/toolbar/toolbar.css
DELETED
@@ -1,213 +0,0 @@
|
|
1
|
-
@import url(./widgets/InsertImageWidget.css);
|
2
|
-
@import url(./widgets/OverflowWidget.css);
|
3
|
-
|
4
|
-
|
5
|
-
.toolbar-root {
|
6
|
-
background-color: var(--primary-background-color);
|
7
|
-
--icon-color: var(--primary-foreground-color);
|
8
|
-
|
9
|
-
|
10
|
-
border: 1px solid var(--secondary-background-color);
|
11
|
-
border-radius: 2px;
|
12
|
-
flex-wrap: wrap;
|
13
|
-
|
14
|
-
box-sizing: border-box;
|
15
|
-
width: 100%;
|
16
|
-
|
17
|
-
display: flex;
|
18
|
-
flex-direction: row;
|
19
|
-
justify-content: center;
|
20
|
-
|
21
|
-
--toolbar-button-height: min(20vh, 60px);
|
22
|
-
|
23
|
-
/* Display above selection dialogs, etc. */
|
24
|
-
z-index: 2;
|
25
|
-
|
26
|
-
font-family: system-ui, -apple-system, sans-serif;
|
27
|
-
}
|
28
|
-
|
29
|
-
.toolbar-root > .toolbar-toolContainer > .toolbar-button,
|
30
|
-
.toolbar-root > .toolbar-toolContainer > * > button,
|
31
|
-
.toolbar-root > .toolbar-buttonGroup > button,
|
32
|
-
.toolbar-root > .toolbar-button {
|
33
|
-
width: min-content;
|
34
|
-
white-space: pre;
|
35
|
-
height: var(--toolbar-button-height);
|
36
|
-
}
|
37
|
-
|
38
|
-
.toolbar-dropdown .toolbar-button > .toolbar-icon {
|
39
|
-
max-width: 50px;
|
40
|
-
width: 100%;
|
41
|
-
}
|
42
|
-
|
43
|
-
.toolbar-button.disabled {
|
44
|
-
filter: opacity(0.5) sepia(0.2);
|
45
|
-
cursor: unset;
|
46
|
-
}
|
47
|
-
|
48
|
-
.toolbar-button, .toolbar-root button {
|
49
|
-
cursor: pointer;
|
50
|
-
text-align: center;
|
51
|
-
border-radius: 6px;
|
52
|
-
|
53
|
-
--icon-color: var(--primary-foreground-color);
|
54
|
-
background-color: var(--primary-background-color);
|
55
|
-
color: var(--primary-foreground-color);
|
56
|
-
border: none;
|
57
|
-
box-shadow: 0px 0px 2px var(--primary-shadow-color);
|
58
|
-
|
59
|
-
transition: background-color 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;
|
60
|
-
}
|
61
|
-
|
62
|
-
.toolbar-button,
|
63
|
-
.toolbar-buttonGroup > button,
|
64
|
-
.toolbar-toolContainer > * > button,
|
65
|
-
.toolbar-root > button {
|
66
|
-
display: flex;
|
67
|
-
flex-direction: column;
|
68
|
-
align-items: center;
|
69
|
-
justify-content: center;
|
70
|
-
|
71
|
-
padding-left: 3px;
|
72
|
-
padding-right: 3px;
|
73
|
-
margin-left: 3px;
|
74
|
-
margin-right: 3px;
|
75
|
-
|
76
|
-
min-width: 40px;
|
77
|
-
width: min-content;
|
78
|
-
font-size: 1em;
|
79
|
-
}
|
80
|
-
|
81
|
-
.toolbar-button > label {
|
82
|
-
cursor: inherit;
|
83
|
-
}
|
84
|
-
|
85
|
-
.toolbar-dropdown > .toolbar-toolContainer > button,
|
86
|
-
.toolbar-dropdown > .toolbar-toolContainer > .toolbar-button {
|
87
|
-
width: 6em;
|
88
|
-
}
|
89
|
-
|
90
|
-
.toolbar-button:not(.disabled):hover, .toolbar-root button:not(:disabled):hover {
|
91
|
-
box-shadow: 0px 2px 4px var(--primary-shadow-color);
|
92
|
-
}
|
93
|
-
|
94
|
-
.toolbar-root button:disabled {
|
95
|
-
cursor: inherit;
|
96
|
-
filter: opacity(0.5);
|
97
|
-
}
|
98
|
-
|
99
|
-
.toolbar-root .toolbar-icon {
|
100
|
-
flex-shrink: 1;
|
101
|
-
|
102
|
-
width: 100%;
|
103
|
-
min-width: 30px;
|
104
|
-
min-height: 30px;
|
105
|
-
}
|
106
|
-
|
107
|
-
.toolbar-toolContainer.selected > .toolbar-button {
|
108
|
-
background-color: var(--secondary-background-color);
|
109
|
-
color: var(--secondary-foreground-color);
|
110
|
-
--icon-color: var(--secondary-foreground-color);
|
111
|
-
}
|
112
|
-
|
113
|
-
.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-button > .toolbar-showHideDropdownIcon {
|
114
|
-
display: none;
|
115
|
-
}
|
116
|
-
|
117
|
-
.toolbar-toolContainer > .toolbar-button > .toolbar-showHideDropdownIcon {
|
118
|
-
height: 10px;
|
119
|
-
transition: transform 0.5s ease;
|
120
|
-
}
|
121
|
-
|
122
|
-
.toolbar-toolContainer.dropdownVisible > .toolbar-button > .toolbar-showHideDropdownIcon {
|
123
|
-
transform: rotate(180deg);
|
124
|
-
}
|
125
|
-
|
126
|
-
.toolbar-dropdown.hidden,
|
127
|
-
.toolbar-toolContainer:not(.selected):not(.dropdownShowable) > .toolbar-dropdown {
|
128
|
-
display: none;
|
129
|
-
}
|
130
|
-
|
131
|
-
.toolbar-dropdown {
|
132
|
-
position: absolute;
|
133
|
-
padding: 15px;
|
134
|
-
padding-top: 5px;
|
135
|
-
|
136
|
-
display: flex;
|
137
|
-
flex-wrap: wrap;
|
138
|
-
flex-direction: column;
|
139
|
-
max-height: 80vh;
|
140
|
-
|
141
|
-
max-width: fit-content;
|
142
|
-
|
143
|
-
/* Prevent overlap/being displayed under the undo/redo buttons */
|
144
|
-
z-index: 2;
|
145
|
-
background-color: var(--primary-background-color);
|
146
|
-
box-shadow: 0px 3px 3px var(--primary-shadow-color);
|
147
|
-
}
|
148
|
-
|
149
|
-
.toolbar-buttonGroup {
|
150
|
-
display: flex;
|
151
|
-
flex-direction: row;
|
152
|
-
justify-content: center;
|
153
|
-
}
|
154
|
-
|
155
|
-
.toolbar-closeColorPickerOverlay {
|
156
|
-
display: none;
|
157
|
-
position: fixed;
|
158
|
-
top: 0;
|
159
|
-
left: 0;
|
160
|
-
bottom: 0;
|
161
|
-
right: 0;
|
162
|
-
|
163
|
-
background-color: var(--primary-background-color);
|
164
|
-
opacity: 0.3;
|
165
|
-
}
|
166
|
-
|
167
|
-
/* Make color selection buttons fill their containing label */
|
168
|
-
.toolbar-dropdown .clr-field button {
|
169
|
-
width: 100%;
|
170
|
-
height: 100%;
|
171
|
-
border-radius: 2px;
|
172
|
-
margin-left: 0;
|
173
|
-
margin-right: 0;
|
174
|
-
}
|
175
|
-
|
176
|
-
.toolbar-root .toolbar-zoomLevelEditor {
|
177
|
-
display: flex;
|
178
|
-
flex-direction: row;
|
179
|
-
}
|
180
|
-
|
181
|
-
.toolbar-root .toolbar-zoomLevelEditor .zoomDisplay {
|
182
|
-
flex-grow: 1;
|
183
|
-
}
|
184
|
-
|
185
|
-
.toolbar-root .toolbar-zoomLevelEditor button {
|
186
|
-
min-width: 48px;
|
187
|
-
}
|
188
|
-
|
189
|
-
.color-input-container {
|
190
|
-
display: inline-flex;
|
191
|
-
flex-direction: row;
|
192
|
-
}
|
193
|
-
|
194
|
-
.color-input-container .pipetteButton {
|
195
|
-
width: 30px;
|
196
|
-
height: 30px;
|
197
|
-
padding: 0;
|
198
|
-
display: inline-flex;
|
199
|
-
}
|
200
|
-
|
201
|
-
.color-input-container .pipetteButton > svg {
|
202
|
-
width: 100%;
|
203
|
-
}
|
204
|
-
|
205
|
-
.color-input-container .pipetteButton.active {
|
206
|
-
background-color: var(--secondary-background-color);
|
207
|
-
--icon-color: var(--secondary-foreground-color);
|
208
|
-
}
|
209
|
-
|
210
|
-
.toolbar-spacedList > * {
|
211
|
-
padding-bottom: 5px;
|
212
|
-
padding-top: 5px;
|
213
|
-
}
|
package/src/toolbar/types.ts
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import Editor from '../../Editor';
|
2
|
-
import { ToolbarLocalization } from '../localization';
|
3
|
-
import BaseWidget from './BaseWidget';
|
4
|
-
|
5
|
-
export default class ActionButtonWidget extends BaseWidget {
|
6
|
-
public constructor(
|
7
|
-
editor: Editor,
|
8
|
-
id: string,
|
9
|
-
|
10
|
-
protected makeIcon: ()=> Element|null,
|
11
|
-
protected title: string,
|
12
|
-
protected clickAction: ()=>void,
|
13
|
-
|
14
|
-
localizationTable?: ToolbarLocalization,
|
15
|
-
protected mustBeToplevel: boolean = false,
|
16
|
-
) {
|
17
|
-
super(editor, id, localizationTable);
|
18
|
-
}
|
19
|
-
|
20
|
-
protected handleClick() {
|
21
|
-
this.clickAction();
|
22
|
-
}
|
23
|
-
|
24
|
-
protected getTitle(): string {
|
25
|
-
return this.title;
|
26
|
-
}
|
27
|
-
|
28
|
-
protected createIcon(): Element|null {
|
29
|
-
return this.makeIcon();
|
30
|
-
}
|
31
|
-
|
32
|
-
protected fillDropdown(_dropdown: HTMLElement): boolean {
|
33
|
-
return false;
|
34
|
-
}
|
35
|
-
|
36
|
-
public canBeInOverflowMenu(): boolean {
|
37
|
-
return !this.mustBeToplevel;
|
38
|
-
}
|
39
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import Editor from '../../Editor';
|
2
|
-
import BaseTool from '../../tools/BaseTool';
|
3
|
-
import { EditorEventType } from '../../types';
|
4
|
-
import { ToolbarLocalization } from '../localization';
|
5
|
-
import BaseWidget from './BaseWidget';
|
6
|
-
|
7
|
-
export default abstract class BaseToolWidget extends BaseWidget {
|
8
|
-
public constructor(
|
9
|
-
protected editor: Editor,
|
10
|
-
protected targetTool: BaseTool,
|
11
|
-
id: string,
|
12
|
-
localizationTable?: ToolbarLocalization,
|
13
|
-
) {
|
14
|
-
super(editor, id, localizationTable);
|
15
|
-
|
16
|
-
editor.notifier.on(EditorEventType.ToolEnabled, toolEvt => {
|
17
|
-
if (toolEvt.kind !== EditorEventType.ToolEnabled) {
|
18
|
-
throw new Error('Incorrect event type! (Expected ToolEnabled)');
|
19
|
-
}
|
20
|
-
|
21
|
-
if (toolEvt.tool === targetTool) {
|
22
|
-
this.setSelected(true);
|
23
|
-
}
|
24
|
-
});
|
25
|
-
|
26
|
-
editor.notifier.on(EditorEventType.ToolDisabled, toolEvt => {
|
27
|
-
if (toolEvt.kind !== EditorEventType.ToolDisabled) {
|
28
|
-
throw new Error('Incorrect event type! (Expected ToolDisabled)');
|
29
|
-
}
|
30
|
-
|
31
|
-
if (toolEvt.tool === targetTool) {
|
32
|
-
this.setSelected(false);
|
33
|
-
this.setDropdownVisible(false);
|
34
|
-
}
|
35
|
-
});
|
36
|
-
}
|
37
|
-
|
38
|
-
protected handleClick() {
|
39
|
-
if (this.hasDropdown) {
|
40
|
-
if (!this.targetTool.isEnabled()) {
|
41
|
-
this.targetTool.setEnabled(true);
|
42
|
-
} else {
|
43
|
-
this.setDropdownVisible(!this.isDropdownVisible());
|
44
|
-
}
|
45
|
-
} else {
|
46
|
-
this.targetTool.setEnabled(!this.targetTool.isEnabled());
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
public addTo(parent: HTMLElement) {
|
51
|
-
const result = super.addTo(parent);
|
52
|
-
this.setSelected(this.targetTool.isEnabled());
|
53
|
-
|
54
|
-
return result;
|
55
|
-
}
|
56
|
-
}
|