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,256 +0,0 @@
|
|
1
|
-
import Color4 from '../Color4';
|
2
|
-
import TextComponent from '../components/TextComponent';
|
3
|
-
import EditorImage from '../EditorImage';
|
4
|
-
import Rect2 from '../math/Rect2';
|
5
|
-
import Mat33 from '../math/Mat33';
|
6
|
-
import { Vec2 } from '../math/Vec2';
|
7
|
-
import { PointerDevice } from '../Pointer';
|
8
|
-
import { EditorEventType } from '../types';
|
9
|
-
import BaseTool from './BaseTool';
|
10
|
-
import Erase from '../commands/Erase';
|
11
|
-
import uniteCommands from '../commands/uniteCommands';
|
12
|
-
const overlayCssClass = 'textEditorOverlay';
|
13
|
-
export default class TextTool extends BaseTool {
|
14
|
-
constructor(editor, description, localizationTable) {
|
15
|
-
super(editor.notifier, description);
|
16
|
-
this.editor = editor;
|
17
|
-
this.localizationTable = localizationTable;
|
18
|
-
this.textInputElem = null;
|
19
|
-
this.textTargetPosition = null;
|
20
|
-
this.textMeasuringCtx = null;
|
21
|
-
this.textScale = Vec2.of(1, 1);
|
22
|
-
this.removeExistingCommand = null;
|
23
|
-
this.textStyle = {
|
24
|
-
size: 32,
|
25
|
-
fontFamily: 'sans-serif',
|
26
|
-
renderingStyle: {
|
27
|
-
fill: Color4.purple,
|
28
|
-
},
|
29
|
-
};
|
30
|
-
this.textEditOverlay = document.createElement('div');
|
31
|
-
this.textEditOverlay.classList.add(overlayCssClass);
|
32
|
-
this.editor.addStyleSheet(`
|
33
|
-
.${overlayCssClass} {
|
34
|
-
height: 0;
|
35
|
-
overflow: visible;
|
36
|
-
}
|
37
|
-
|
38
|
-
.${overlayCssClass} textarea {
|
39
|
-
background-color: rgba(0, 0, 0, 0);
|
40
|
-
|
41
|
-
white-space: pre;
|
42
|
-
overflow: hidden;
|
43
|
-
|
44
|
-
padding: 0;
|
45
|
-
margin: 0;
|
46
|
-
border: none;
|
47
|
-
padding: 0;
|
48
|
-
|
49
|
-
min-width: 100px;
|
50
|
-
min-height: 1.1em;
|
51
|
-
}
|
52
|
-
`);
|
53
|
-
this.editor.createHTMLOverlay(this.textEditOverlay);
|
54
|
-
this.editor.notifier.on(EditorEventType.ViewportChanged, () => this.updateTextInput());
|
55
|
-
}
|
56
|
-
getTextAscent(text, style) {
|
57
|
-
var _a;
|
58
|
-
(_a = this.textMeasuringCtx) !== null && _a !== void 0 ? _a : (this.textMeasuringCtx = document.createElement('canvas').getContext('2d'));
|
59
|
-
if (this.textMeasuringCtx) {
|
60
|
-
TextComponent.applyTextStyles(this.textMeasuringCtx, style);
|
61
|
-
return this.textMeasuringCtx.measureText(text).actualBoundingBoxAscent;
|
62
|
-
}
|
63
|
-
// Estimate
|
64
|
-
return style.size * 2 / 3;
|
65
|
-
}
|
66
|
-
// Take input from this' textInputElem and add it to the EditorImage.
|
67
|
-
// If [removeInput], the HTML input element is removed. Otherwise, its value
|
68
|
-
// is cleared.
|
69
|
-
flushInput(removeInput = true) {
|
70
|
-
if (this.textInputElem && this.textTargetPosition) {
|
71
|
-
const content = this.textInputElem.value.trimEnd();
|
72
|
-
this.textInputElem.value = '';
|
73
|
-
if (removeInput) {
|
74
|
-
// In some browsers, .remove() triggers a .blur event (synchronously).
|
75
|
-
// Clear this.textInputElem before removal
|
76
|
-
const input = this.textInputElem;
|
77
|
-
this.textInputElem = null;
|
78
|
-
input.remove();
|
79
|
-
}
|
80
|
-
if (content === '') {
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
const textTransform = Mat33.translation(this.textTargetPosition).rightMul(this.getTextScaleMatrix()).rightMul(Mat33.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas())).rightMul(Mat33.zRotation(this.textRotation));
|
84
|
-
const textComponent = TextComponent.fromLines(content.split('\n'), textTransform, this.textStyle);
|
85
|
-
const action = EditorImage.addElement(textComponent);
|
86
|
-
if (this.removeExistingCommand) {
|
87
|
-
// Unapply so that `removeExistingCommand` can be added to the undo stack.
|
88
|
-
this.removeExistingCommand.unapply(this.editor);
|
89
|
-
this.editor.dispatch(uniteCommands([this.removeExistingCommand, action]));
|
90
|
-
this.removeExistingCommand = null;
|
91
|
-
}
|
92
|
-
else {
|
93
|
-
this.editor.dispatch(action);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
getTextScaleMatrix() {
|
98
|
-
return Mat33.scaling2D(this.textScale.times(1 / this.editor.viewport.getSizeOfPixelOnCanvas()));
|
99
|
-
}
|
100
|
-
updateTextInput() {
|
101
|
-
var _a, _b, _c;
|
102
|
-
if (!this.textInputElem || !this.textTargetPosition) {
|
103
|
-
(_a = this.textInputElem) === null || _a === void 0 ? void 0 : _a.remove();
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
const viewport = this.editor.viewport;
|
107
|
-
const textScreenPos = viewport.canvasToScreen(this.textTargetPosition);
|
108
|
-
this.textInputElem.placeholder = this.localizationTable.enterTextToInsert;
|
109
|
-
this.textInputElem.style.fontFamily = this.textStyle.fontFamily;
|
110
|
-
this.textInputElem.style.fontVariant = (_b = this.textStyle.fontVariant) !== null && _b !== void 0 ? _b : '';
|
111
|
-
this.textInputElem.style.fontWeight = (_c = this.textStyle.fontWeight) !== null && _c !== void 0 ? _c : '';
|
112
|
-
this.textInputElem.style.fontSize = `${this.textStyle.size}px`;
|
113
|
-
this.textInputElem.style.color = this.textStyle.renderingStyle.fill.toHexString();
|
114
|
-
this.textInputElem.style.position = 'relative';
|
115
|
-
this.textInputElem.style.left = `${textScreenPos.x}px`;
|
116
|
-
this.textInputElem.style.top = `${textScreenPos.y}px`;
|
117
|
-
this.textInputElem.style.margin = '0';
|
118
|
-
this.textInputElem.style.width = `${this.textInputElem.scrollWidth}px`;
|
119
|
-
this.textInputElem.style.height = `${this.textInputElem.scrollHeight}px`;
|
120
|
-
// Get the ascent based on the font, using a character that is tall in most fonts.
|
121
|
-
const tallCharacter = '⎢';
|
122
|
-
const ascent = this.getTextAscent(tallCharacter, this.textStyle);
|
123
|
-
const rotation = this.textRotation + viewport.getRotationAngle();
|
124
|
-
const scale = this.getTextScaleMatrix();
|
125
|
-
this.textInputElem.style.transform = `${scale.toCSSMatrix()} rotate(${rotation * 180 / Math.PI}deg) translate(0, ${-ascent}px)`;
|
126
|
-
this.textInputElem.style.transformOrigin = 'top left';
|
127
|
-
}
|
128
|
-
startTextInput(textCanvasPos, initialText) {
|
129
|
-
this.flushInput();
|
130
|
-
this.textInputElem = document.createElement('textarea');
|
131
|
-
this.textInputElem.value = initialText;
|
132
|
-
this.textInputElem.style.display = 'inline-block';
|
133
|
-
this.textTargetPosition = this.editor.viewport.roundPoint(textCanvasPos);
|
134
|
-
this.textRotation = -this.editor.viewport.getRotationAngle();
|
135
|
-
this.textScale = Vec2.of(1, 1).times(this.editor.viewport.getSizeOfPixelOnCanvas());
|
136
|
-
this.updateTextInput();
|
137
|
-
// Update the input size/position/etc. after the placeHolder has had time to appear.
|
138
|
-
setTimeout(() => this.updateTextInput(), 0);
|
139
|
-
this.textInputElem.oninput = () => {
|
140
|
-
if (this.textInputElem) {
|
141
|
-
this.textInputElem.style.width = `${this.textInputElem.scrollWidth}px`;
|
142
|
-
this.textInputElem.style.height = `${this.textInputElem.scrollHeight}px`;
|
143
|
-
}
|
144
|
-
};
|
145
|
-
this.textInputElem.onblur = () => {
|
146
|
-
// Delay removing the input -- flushInput may be called within a blur()
|
147
|
-
// event handler
|
148
|
-
const removeInput = false;
|
149
|
-
const input = this.textInputElem;
|
150
|
-
this.flushInput(removeInput);
|
151
|
-
this.textInputElem = null;
|
152
|
-
setTimeout(() => {
|
153
|
-
input === null || input === void 0 ? void 0 : input.remove();
|
154
|
-
}, 0);
|
155
|
-
};
|
156
|
-
this.textInputElem.onkeyup = (evt) => {
|
157
|
-
var _a, _b;
|
158
|
-
if (evt.key === 'Enter' && !evt.shiftKey) {
|
159
|
-
this.flushInput();
|
160
|
-
this.editor.focus();
|
161
|
-
}
|
162
|
-
else if (evt.key === 'Escape') {
|
163
|
-
// Cancel input.
|
164
|
-
(_a = this.textInputElem) === null || _a === void 0 ? void 0 : _a.remove();
|
165
|
-
this.textInputElem = null;
|
166
|
-
this.editor.focus();
|
167
|
-
(_b = this.removeExistingCommand) === null || _b === void 0 ? void 0 : _b.unapply(this.editor);
|
168
|
-
this.removeExistingCommand = null;
|
169
|
-
}
|
170
|
-
};
|
171
|
-
this.textEditOverlay.replaceChildren(this.textInputElem);
|
172
|
-
setTimeout(() => { var _a; return (_a = this.textInputElem) === null || _a === void 0 ? void 0 : _a.focus(); }, 0);
|
173
|
-
}
|
174
|
-
setEnabled(enabled) {
|
175
|
-
super.setEnabled(enabled);
|
176
|
-
if (!enabled) {
|
177
|
-
this.flushInput();
|
178
|
-
}
|
179
|
-
this.textEditOverlay.style.display = enabled ? 'block' : 'none';
|
180
|
-
}
|
181
|
-
onPointerDown({ current, allPointers }) {
|
182
|
-
if (current.device === PointerDevice.Eraser) {
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
if (allPointers.length === 1) {
|
186
|
-
// Are we clicking on a text node?
|
187
|
-
const canvasPos = current.canvasPos;
|
188
|
-
const halfTestRegionSize = Vec2.of(2.5, 2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas());
|
189
|
-
const testRegion = Rect2.fromCorners(canvasPos.minus(halfTestRegionSize), canvasPos.plus(halfTestRegionSize));
|
190
|
-
const targetNodes = this.editor.image.getElementsIntersectingRegion(testRegion);
|
191
|
-
let targetTextNodes = targetNodes.filter(node => node instanceof TextComponent);
|
192
|
-
// Don't try to edit text nodes that contain the viewport (this allows us
|
193
|
-
// to zoom in on text nodes and add text on top of them.)
|
194
|
-
const visibleRect = this.editor.viewport.visibleRect;
|
195
|
-
targetTextNodes = targetTextNodes.filter(node => !node.getBBox().containsRect(visibleRect));
|
196
|
-
// End any TextNodes we're currently editing.
|
197
|
-
this.flushInput();
|
198
|
-
if (targetTextNodes.length > 0) {
|
199
|
-
const targetNode = targetTextNodes[targetTextNodes.length - 1];
|
200
|
-
this.setTextStyle(targetNode.getTextStyle());
|
201
|
-
// Create and temporarily apply removeExistingCommand.
|
202
|
-
this.removeExistingCommand = new Erase([targetNode]);
|
203
|
-
this.removeExistingCommand.apply(this.editor);
|
204
|
-
this.startTextInput(targetNode.getBaselinePos(), targetNode.getText());
|
205
|
-
const transform = targetNode.getTransform();
|
206
|
-
this.textRotation = transform.transformVec3(Vec2.unitX).angle();
|
207
|
-
const scaleFactor = transform.transformVec3(Vec2.unitX).magnitude();
|
208
|
-
this.textScale = Vec2.of(1, 1).times(scaleFactor);
|
209
|
-
this.updateTextInput();
|
210
|
-
}
|
211
|
-
else {
|
212
|
-
this.removeExistingCommand = null;
|
213
|
-
this.startTextInput(current.canvasPos, '');
|
214
|
-
}
|
215
|
-
return true;
|
216
|
-
}
|
217
|
-
return false;
|
218
|
-
}
|
219
|
-
onGestureCancel() {
|
220
|
-
this.flushInput();
|
221
|
-
this.editor.focus();
|
222
|
-
}
|
223
|
-
dispatchUpdateEvent() {
|
224
|
-
this.updateTextInput();
|
225
|
-
this.editor.notifier.dispatch(EditorEventType.ToolUpdated, {
|
226
|
-
kind: EditorEventType.ToolUpdated,
|
227
|
-
tool: this,
|
228
|
-
});
|
229
|
-
}
|
230
|
-
setFontFamily(fontFamily) {
|
231
|
-
if (fontFamily !== this.textStyle.fontFamily) {
|
232
|
-
this.textStyle = Object.assign(Object.assign({}, this.textStyle), { fontFamily: fontFamily });
|
233
|
-
this.dispatchUpdateEvent();
|
234
|
-
}
|
235
|
-
}
|
236
|
-
setColor(color) {
|
237
|
-
if (!color.eq(this.textStyle.renderingStyle.fill)) {
|
238
|
-
this.textStyle = Object.assign(Object.assign({}, this.textStyle), { renderingStyle: Object.assign(Object.assign({}, this.textStyle.renderingStyle), { fill: color }) });
|
239
|
-
this.dispatchUpdateEvent();
|
240
|
-
}
|
241
|
-
}
|
242
|
-
setFontSize(size) {
|
243
|
-
if (size !== this.textStyle.size) {
|
244
|
-
this.textStyle = Object.assign(Object.assign({}, this.textStyle), { size });
|
245
|
-
this.dispatchUpdateEvent();
|
246
|
-
}
|
247
|
-
}
|
248
|
-
getTextStyle() {
|
249
|
-
return this.textStyle;
|
250
|
-
}
|
251
|
-
setTextStyle(style) {
|
252
|
-
// Copy the style — we may change parts of it.
|
253
|
-
this.textStyle = Object.assign(Object.assign({}, style), { renderingStyle: Object.assign({}, style.renderingStyle) });
|
254
|
-
this.dispatchUpdateEvent();
|
255
|
-
}
|
256
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { InputEvt } from '../types';
|
2
|
-
import Editor from '../Editor';
|
3
|
-
import BaseTool from './BaseTool';
|
4
|
-
import ToolEnabledGroup from './ToolEnabledGroup';
|
5
|
-
import { ToolLocalization } from './localization';
|
6
|
-
export default class ToolController {
|
7
|
-
private tools;
|
8
|
-
private activeTool;
|
9
|
-
private primaryToolGroup;
|
10
|
-
/** @internal */
|
11
|
-
constructor(editor: Editor, localization: ToolLocalization);
|
12
|
-
setTools(tools: BaseTool[], primaryToolGroup?: ToolEnabledGroup): void;
|
13
|
-
addPrimaryTool(tool: BaseTool): void;
|
14
|
-
getPrimaryTools(): BaseTool[];
|
15
|
-
addTool(tool: BaseTool): void;
|
16
|
-
dispatchInputEvent(event: InputEvt): boolean;
|
17
|
-
getMatchingTools<Type extends BaseTool>(type: new (...args: any[]) => Type): Type[];
|
18
|
-
}
|
@@ -1,158 +0,0 @@
|
|
1
|
-
import { InputEvtType, EditorEventType } from '../types';
|
2
|
-
import PanZoom, { PanZoomMode } from './PanZoom';
|
3
|
-
import Pen from './Pen';
|
4
|
-
import ToolEnabledGroup from './ToolEnabledGroup';
|
5
|
-
import Eraser from './Eraser';
|
6
|
-
import SelectionTool from './SelectionTool/SelectionTool';
|
7
|
-
import Color4 from '../Color4';
|
8
|
-
import UndoRedoShortcut from './UndoRedoShortcut';
|
9
|
-
import TextTool from './TextTool';
|
10
|
-
import PipetteTool from './PipetteTool';
|
11
|
-
import ToolSwitcherShortcut from './ToolSwitcherShortcut';
|
12
|
-
import PasteHandler from './PasteHandler';
|
13
|
-
import ToolbarShortcutHandler from './ToolbarShortcutHandler';
|
14
|
-
import { makePressureSensitiveFreehandLineBuilder } from '../components/builders/PressureSensitiveFreehandLineBuilder';
|
15
|
-
import FindTool from './FindTool';
|
16
|
-
import SelectAllShortcutHandler from './SelectionTool/SelectAllShortcutHandler';
|
17
|
-
export default class ToolController {
|
18
|
-
/** @internal */
|
19
|
-
constructor(editor, localization) {
|
20
|
-
this.activeTool = null;
|
21
|
-
const primaryToolGroup = new ToolEnabledGroup();
|
22
|
-
this.primaryToolGroup = primaryToolGroup;
|
23
|
-
const panZoomTool = new PanZoom(editor, PanZoomMode.TwoFingerTouchGestures | PanZoomMode.RightClickDrags, localization.touchPanTool);
|
24
|
-
const keyboardPanZoomTool = new PanZoom(editor, PanZoomMode.Keyboard, localization.keyboardPanZoom);
|
25
|
-
const primaryPenTool = new Pen(editor, localization.penTool(1), { color: Color4.purple, thickness: 8 });
|
26
|
-
const primaryTools = [
|
27
|
-
// Three pens
|
28
|
-
primaryPenTool,
|
29
|
-
new Pen(editor, localization.penTool(2), { color: Color4.clay, thickness: 4 }),
|
30
|
-
// Highlighter-like pen with width=40
|
31
|
-
new Pen(editor, localization.penTool(3), { color: Color4.ofRGBA(1, 1, 0, 0.5), thickness: 40 }, makePressureSensitiveFreehandLineBuilder),
|
32
|
-
new Eraser(editor, localization.eraserTool),
|
33
|
-
new SelectionTool(editor, localization.selectionTool),
|
34
|
-
new TextTool(editor, localization.textTool, localization),
|
35
|
-
new PanZoom(editor, PanZoomMode.SinglePointerGestures, localization.anyDevicePanning)
|
36
|
-
];
|
37
|
-
this.tools = [
|
38
|
-
new PipetteTool(editor, localization.pipetteTool),
|
39
|
-
panZoomTool,
|
40
|
-
...primaryTools,
|
41
|
-
keyboardPanZoomTool,
|
42
|
-
new UndoRedoShortcut(editor),
|
43
|
-
new ToolbarShortcutHandler(editor),
|
44
|
-
new ToolSwitcherShortcut(editor),
|
45
|
-
new FindTool(editor),
|
46
|
-
new PasteHandler(editor),
|
47
|
-
new SelectAllShortcutHandler(editor),
|
48
|
-
];
|
49
|
-
primaryTools.forEach(tool => tool.setToolGroup(primaryToolGroup));
|
50
|
-
panZoomTool.setEnabled(true);
|
51
|
-
primaryPenTool.setEnabled(true);
|
52
|
-
editor.notifier.on(EditorEventType.ToolEnabled, event => {
|
53
|
-
if (event.kind === EditorEventType.ToolEnabled) {
|
54
|
-
editor.announceForAccessibility(localization.toolEnabledAnnouncement(event.tool.description));
|
55
|
-
}
|
56
|
-
});
|
57
|
-
editor.notifier.on(EditorEventType.ToolDisabled, event => {
|
58
|
-
if (event.kind === EditorEventType.ToolDisabled) {
|
59
|
-
editor.announceForAccessibility(localization.toolDisabledAnnouncement(event.tool.description));
|
60
|
-
}
|
61
|
-
});
|
62
|
-
this.activeTool = null;
|
63
|
-
}
|
64
|
-
// Replaces the current set of tools with `tools`. This should only be done before
|
65
|
-
// the creation of the app's toolbar (if using `HTMLToolbar`).
|
66
|
-
setTools(tools, primaryToolGroup) {
|
67
|
-
this.tools = tools;
|
68
|
-
this.primaryToolGroup = primaryToolGroup !== null && primaryToolGroup !== void 0 ? primaryToolGroup : new ToolEnabledGroup();
|
69
|
-
}
|
70
|
-
// Add a tool that acts like one of the primary tools (only one primary tool can be enabled at a time).
|
71
|
-
// This should be called before creating the app's toolbar.
|
72
|
-
addPrimaryTool(tool) {
|
73
|
-
tool.setToolGroup(this.primaryToolGroup);
|
74
|
-
if (tool.isEnabled()) {
|
75
|
-
this.primaryToolGroup.notifyEnabled(tool);
|
76
|
-
}
|
77
|
-
this.addTool(tool);
|
78
|
-
}
|
79
|
-
getPrimaryTools() {
|
80
|
-
return this.tools.filter(tool => {
|
81
|
-
return tool.getToolGroup() === this.primaryToolGroup;
|
82
|
-
});
|
83
|
-
}
|
84
|
-
// Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
|
85
|
-
// This should be called before creating the app's toolbar.
|
86
|
-
addTool(tool) {
|
87
|
-
this.tools.push(tool);
|
88
|
-
}
|
89
|
-
// Returns true if the event was handled
|
90
|
-
dispatchInputEvent(event) {
|
91
|
-
var _a, _b;
|
92
|
-
let handled = false;
|
93
|
-
if (event.kind === InputEvtType.PointerDownEvt) {
|
94
|
-
for (const tool of this.tools) {
|
95
|
-
if (tool.isEnabled() && tool.onPointerDown(event)) {
|
96
|
-
if (this.activeTool !== tool) {
|
97
|
-
(_a = this.activeTool) === null || _a === void 0 ? void 0 : _a.onGestureCancel();
|
98
|
-
}
|
99
|
-
this.activeTool = tool;
|
100
|
-
handled = true;
|
101
|
-
break;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
}
|
105
|
-
else if (event.kind === InputEvtType.PointerUpEvt) {
|
106
|
-
(_b = this.activeTool) === null || _b === void 0 ? void 0 : _b.onPointerUp(event);
|
107
|
-
this.activeTool = null;
|
108
|
-
handled = true;
|
109
|
-
}
|
110
|
-
else if (event.kind === InputEvtType.PointerMoveEvt) {
|
111
|
-
if (this.activeTool !== null) {
|
112
|
-
this.activeTool.onPointerMove(event);
|
113
|
-
handled = true;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
else if (event.kind === InputEvtType.GestureCancelEvt) {
|
117
|
-
if (this.activeTool !== null) {
|
118
|
-
this.activeTool.onGestureCancel();
|
119
|
-
this.activeTool = null;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
else {
|
123
|
-
let allCasesHandledGuard;
|
124
|
-
for (const tool of this.tools) {
|
125
|
-
if (!tool.isEnabled()) {
|
126
|
-
continue;
|
127
|
-
}
|
128
|
-
switch (event.kind) {
|
129
|
-
case InputEvtType.KeyPressEvent:
|
130
|
-
handled = tool.onKeyPress(event);
|
131
|
-
break;
|
132
|
-
case InputEvtType.KeyUpEvent:
|
133
|
-
handled = tool.onKeyUp(event);
|
134
|
-
break;
|
135
|
-
case InputEvtType.WheelEvt:
|
136
|
-
handled = tool.onWheel(event);
|
137
|
-
break;
|
138
|
-
case InputEvtType.CopyEvent:
|
139
|
-
handled = tool.onCopy(event);
|
140
|
-
break;
|
141
|
-
case InputEvtType.PasteEvent:
|
142
|
-
handled = tool.onPaste(event);
|
143
|
-
break;
|
144
|
-
default:
|
145
|
-
allCasesHandledGuard = event;
|
146
|
-
return allCasesHandledGuard;
|
147
|
-
}
|
148
|
-
if (handled) {
|
149
|
-
break;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
return handled;
|
154
|
-
}
|
155
|
-
getMatchingTools(type) {
|
156
|
-
return this.tools.filter(tool => tool instanceof type);
|
157
|
-
}
|
158
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// Connects a group of tools -- at most one tool in the group can be enabled.
|
2
|
-
export default class ToolEnabledGroup {
|
3
|
-
constructor() { }
|
4
|
-
notifyEnabled(tool) {
|
5
|
-
var _a;
|
6
|
-
if (tool !== this.activeTool) {
|
7
|
-
(_a = this.activeTool) === null || _a === void 0 ? void 0 : _a.setEnabled(false);
|
8
|
-
this.activeTool = tool;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import Editor from '../Editor';
|
2
|
-
import { KeyPressEvent } from '../types';
|
3
|
-
import BaseTool from './BaseTool';
|
4
|
-
/**
|
5
|
-
* Handles keyboard events used, by default, to select tools. By default,
|
6
|
-
* 1 maps to the first primary tool, 2 to the second primary tool, ... .
|
7
|
-
*
|
8
|
-
* This is in the default set of {@link ToolController} tools.
|
9
|
-
*
|
10
|
-
* @deprecated This may be replaced in the future.
|
11
|
-
*/
|
12
|
-
export default class ToolSwitcherShortcut extends BaseTool {
|
13
|
-
private editor;
|
14
|
-
constructor(editor: Editor);
|
15
|
-
onKeyPress({ key }: KeyPressEvent): boolean;
|
16
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import BaseTool from './BaseTool';
|
2
|
-
/**
|
3
|
-
* Handles keyboard events used, by default, to select tools. By default,
|
4
|
-
* 1 maps to the first primary tool, 2 to the second primary tool, ... .
|
5
|
-
*
|
6
|
-
* This is in the default set of {@link ToolController} tools.
|
7
|
-
*
|
8
|
-
* @deprecated This may be replaced in the future.
|
9
|
-
*/
|
10
|
-
export default class ToolSwitcherShortcut extends BaseTool {
|
11
|
-
constructor(editor) {
|
12
|
-
super(editor.notifier, editor.localization.changeTool);
|
13
|
-
this.editor = editor;
|
14
|
-
}
|
15
|
-
// @internal
|
16
|
-
onKeyPress({ key }) {
|
17
|
-
const toolController = this.editor.toolController;
|
18
|
-
const primaryTools = toolController.getPrimaryTools();
|
19
|
-
// Map keys 0-9 to primary tools.
|
20
|
-
const keyMatch = /^[0-9]$/.exec(key);
|
21
|
-
let targetTool;
|
22
|
-
if (keyMatch) {
|
23
|
-
const targetIdx = parseInt(keyMatch[0], 10) - 1;
|
24
|
-
targetTool = primaryTools[targetIdx];
|
25
|
-
}
|
26
|
-
if (targetTool) {
|
27
|
-
targetTool.setEnabled(true);
|
28
|
-
return true;
|
29
|
-
}
|
30
|
-
return false;
|
31
|
-
}
|
32
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import Editor from '../Editor';
|
2
|
-
import { KeyPressEvent } from '../types';
|
3
|
-
import BaseTool from './BaseTool';
|
4
|
-
type KeyPressListener = (event: KeyPressEvent) => boolean;
|
5
|
-
export default class ToolbarShortcutHandler extends BaseTool {
|
6
|
-
private listeners;
|
7
|
-
constructor(editor: Editor);
|
8
|
-
registerListener(listener: KeyPressListener): void;
|
9
|
-
removeListener(listener: KeyPressListener): void;
|
10
|
-
onKeyPress(event: KeyPressEvent): boolean;
|
11
|
-
}
|
12
|
-
export {};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
// Allows the toolbar to register keyboard events.
|
2
|
-
// @packageDocumentation
|
3
|
-
import BaseTool from './BaseTool';
|
4
|
-
export default class ToolbarShortcutHandler extends BaseTool {
|
5
|
-
constructor(editor) {
|
6
|
-
super(editor.notifier, editor.localization.changeTool);
|
7
|
-
this.listeners = new Set([]);
|
8
|
-
}
|
9
|
-
registerListener(listener) {
|
10
|
-
this.listeners.add(listener);
|
11
|
-
}
|
12
|
-
removeListener(listener) {
|
13
|
-
this.listeners.delete(listener);
|
14
|
-
}
|
15
|
-
onKeyPress(event) {
|
16
|
-
for (const listener of this.listeners) {
|
17
|
-
if (listener(event)) {
|
18
|
-
return true;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
return false;
|
22
|
-
}
|
23
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import Editor from '../Editor';
|
2
|
-
import { KeyPressEvent } from '../types';
|
3
|
-
import BaseTool from './BaseTool';
|
4
|
-
export default class UndoRedoShortcut extends BaseTool {
|
5
|
-
private editor;
|
6
|
-
constructor(editor: Editor);
|
7
|
-
onKeyPress({ key, ctrlKey }: KeyPressEvent): boolean;
|
8
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import BaseTool from './BaseTool';
|
2
|
-
// Handles ctrl+Z, ctrl+Shift+Z keyboard shortcuts.
|
3
|
-
export default class UndoRedoShortcut extends BaseTool {
|
4
|
-
constructor(editor) {
|
5
|
-
super(editor.notifier, editor.localization.undoRedoTool);
|
6
|
-
this.editor = editor;
|
7
|
-
}
|
8
|
-
// @internal
|
9
|
-
onKeyPress({ key, ctrlKey }) {
|
10
|
-
if (ctrlKey) {
|
11
|
-
if (key === 'z') {
|
12
|
-
this.editor.history.undo();
|
13
|
-
return true;
|
14
|
-
}
|
15
|
-
else if (key === 'Z') {
|
16
|
-
this.editor.history.redo();
|
17
|
-
return true;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
return false;
|
21
|
-
}
|
22
|
-
}
|
package/dist/src/tools/lib.d.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @packageDocumentation
|
3
|
-
*/
|
4
|
-
export { default as BaseTool } from './BaseTool';
|
5
|
-
export { default as ToolController } from './ToolController';
|
6
|
-
export { default as ToolEnabledGroup } from './ToolEnabledGroup';
|
7
|
-
export { default as UndoRedoShortcut } from './UndoRedoShortcut';
|
8
|
-
export { default as ToolSwitcherShortcut } from './ToolSwitcherShortcut';
|
9
|
-
export { default as PanZoomTool, PanZoomMode } from './PanZoom';
|
10
|
-
export { default as PenTool, PenStyle } from './Pen';
|
11
|
-
export { default as TextTool } from './TextTool';
|
12
|
-
export { default as SelectionTool } from './SelectionTool/SelectionTool';
|
13
|
-
export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler';
|
14
|
-
export { default as EraserTool } from './Eraser';
|
15
|
-
export { default as PasteHandler } from './PasteHandler';
|
16
|
-
export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler';
|
package/dist/src/tools/lib.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @packageDocumentation
|
3
|
-
*/
|
4
|
-
export { default as BaseTool } from './BaseTool';
|
5
|
-
export { default as ToolController } from './ToolController';
|
6
|
-
export { default as ToolEnabledGroup } from './ToolEnabledGroup';
|
7
|
-
export { default as UndoRedoShortcut } from './UndoRedoShortcut';
|
8
|
-
export { default as ToolSwitcherShortcut } from './ToolSwitcherShortcut';
|
9
|
-
export { default as PanZoomTool, PanZoomMode } from './PanZoom';
|
10
|
-
export { default as PenTool } from './Pen';
|
11
|
-
export { default as TextTool } from './TextTool';
|
12
|
-
export { default as SelectionTool } from './SelectionTool/SelectionTool';
|
13
|
-
export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler';
|
14
|
-
export { default as EraserTool } from './Eraser';
|
15
|
-
export { default as PasteHandler } from './PasteHandler';
|
16
|
-
export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler';
|
@@ -1,28 +0,0 @@
|
|
1
|
-
export interface ToolLocalization {
|
2
|
-
keyboardPanZoom: string;
|
3
|
-
penTool: (penId: number) => string;
|
4
|
-
selectionTool: string;
|
5
|
-
selectAllTool: string;
|
6
|
-
eraserTool: string;
|
7
|
-
touchPanTool: string;
|
8
|
-
twoFingerPanZoomTool: string;
|
9
|
-
undoRedoTool: string;
|
10
|
-
pipetteTool: string;
|
11
|
-
rightClickDragPanTool: string;
|
12
|
-
textTool: string;
|
13
|
-
enterTextToInsert: string;
|
14
|
-
changeTool: string;
|
15
|
-
pasteHandler: string;
|
16
|
-
findLabel: string;
|
17
|
-
toNextMatch: string;
|
18
|
-
closeFindDialog: string;
|
19
|
-
findDialogShown: string;
|
20
|
-
findDialogHidden: string;
|
21
|
-
focusedFoundText: (currentMatchNumber: number, totalMatches: number) => string;
|
22
|
-
anyDevicePanning: string;
|
23
|
-
copied: (count: number, description: string) => string;
|
24
|
-
pasted: (count: number, description: string) => string;
|
25
|
-
toolEnabledAnnouncement: (toolName: string) => string;
|
26
|
-
toolDisabledAnnouncement: (toolName: string) => string;
|
27
|
-
}
|
28
|
-
export declare const defaultToolLocalization: ToolLocalization;
|
@@ -1,27 +0,0 @@
|
|
1
|
-
export const defaultToolLocalization = {
|
2
|
-
penTool: (penId) => `Pen ${penId}`,
|
3
|
-
selectionTool: 'Selection',
|
4
|
-
selectAllTool: 'Select all shortcut',
|
5
|
-
eraserTool: 'Eraser',
|
6
|
-
touchPanTool: 'Touch panning',
|
7
|
-
twoFingerPanZoomTool: 'Panning and zooming',
|
8
|
-
undoRedoTool: 'Undo/Redo',
|
9
|
-
rightClickDragPanTool: 'Right-click drag',
|
10
|
-
pipetteTool: 'Pick color from screen',
|
11
|
-
keyboardPanZoom: 'Keyboard pan/zoom shortcuts',
|
12
|
-
textTool: 'Text',
|
13
|
-
enterTextToInsert: 'Text to insert',
|
14
|
-
changeTool: 'Change tool',
|
15
|
-
pasteHandler: 'Copy paste handler',
|
16
|
-
findLabel: 'Find',
|
17
|
-
toNextMatch: 'Next',
|
18
|
-
closeFindDialog: 'Close',
|
19
|
-
findDialogShown: 'Find dialog shown',
|
20
|
-
findDialogHidden: 'Find dialog hidden',
|
21
|
-
focusedFoundText: (matchIdx, totalMatches) => `Viewing match ${matchIdx} of ${totalMatches}`,
|
22
|
-
anyDevicePanning: 'Any device panning',
|
23
|
-
copied: (count, description) => `Copied ${count} ${description}`,
|
24
|
-
pasted: (count, description) => `Pasted ${count} ${description}`,
|
25
|
-
toolEnabledAnnouncement: (toolName) => `${toolName} enabled`,
|
26
|
-
toolDisabledAnnouncement: (toolName) => `${toolName} disabled`,
|
27
|
-
};
|