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,94 +0,0 @@
|
|
1
|
-
import * as fs from 'fs';
|
2
|
-
import * as path from 'path';
|
3
|
-
import { defaultEditorLocalization } from '../src/localization';
|
4
|
-
// Adds markdown formatting to format text like code.
|
5
|
-
const codeFormat = (text) => {
|
6
|
-
let maxConsecutiveBackticks = 0;
|
7
|
-
// Find the longest number of consecutive backticks — we need to have more
|
8
|
-
// than that for the delimiters.
|
9
|
-
const backtickRuns = text.matchAll(/[`]+/g);
|
10
|
-
for (const backticks of backtickRuns) {
|
11
|
-
if (backticks.length > maxConsecutiveBackticks) {
|
12
|
-
maxConsecutiveBackticks = backticks.length;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
let codeStartEnd = '';
|
16
|
-
for (let i = 0; i < maxConsecutiveBackticks + 1; i++) {
|
17
|
-
codeStartEnd += '`';
|
18
|
-
}
|
19
|
-
// If the text already starts with a `, add a space to prevent the
|
20
|
-
// markdown parser from treating it as part of the delimiter.
|
21
|
-
if (text.startsWith('`')) {
|
22
|
-
text = ' ' + text;
|
23
|
-
}
|
24
|
-
if (text.endsWith('`')) {
|
25
|
-
text = text + ' ';
|
26
|
-
}
|
27
|
-
return `${codeStartEnd}${text}${codeStartEnd}`;
|
28
|
-
};
|
29
|
-
const collapseSpaces = (text) => text.replace(/\s+/g, ' ');
|
30
|
-
const generateTranslationTemplate = () => {
|
31
|
-
const bodyContentLines = [];
|
32
|
-
const addInput = (type, id, attrs, required = false) => {
|
33
|
-
const lines = [];
|
34
|
-
lines.push(` - type: ${type}`);
|
35
|
-
lines.push(` id: ${id}`);
|
36
|
-
lines.push(' attributes:');
|
37
|
-
for (const key in attrs) {
|
38
|
-
const value = `${attrs[key]}`;
|
39
|
-
const escapedValue = value.replace(/[\\]/g, '\\\\').replace(/"/g, '\\"');
|
40
|
-
lines.push(` ${key}: "${escapedValue}"`);
|
41
|
-
}
|
42
|
-
lines.push(' validations:');
|
43
|
-
lines.push(` required: ${required}`);
|
44
|
-
bodyContentLines.push(...lines);
|
45
|
-
};
|
46
|
-
const addLabel = (text) => {
|
47
|
-
bodyContentLines.push(' - type: markdown');
|
48
|
-
bodyContentLines.push(' attributes:');
|
49
|
-
bodyContentLines.push(' value: |');
|
50
|
-
bodyContentLines.push(' ' + text);
|
51
|
-
};
|
52
|
-
addLabel(collapseSpaces(`
|
53
|
-
Thank you for taking the time to translate \`js-draw\`! If you don't have time to translate
|
54
|
-
all of the strings below, feel free to submit an incomplete translation and edit it later.
|
55
|
-
Use this template to update an existing translation or to create a new translation.
|
56
|
-
`));
|
57
|
-
addLabel(collapseSpaces(`
|
58
|
-
(Optional) If you would like to submit a pull request that applies this translation,
|
59
|
-
note that existing translations are present in
|
60
|
-
[src/localizations/](https://github.com/personalizedrefrigerator/js-draw/tree/main/src/localizations).
|
61
|
-
`));
|
62
|
-
addInput('input', 'language-name', {
|
63
|
-
label: 'Language',
|
64
|
-
description: 'The name of the language to translate to in English (e.g. Spanish)',
|
65
|
-
}, true);
|
66
|
-
for (const key in defaultEditorLocalization) {
|
67
|
-
const englishTranslation = `${defaultEditorLocalization[key]}`;
|
68
|
-
addInput('input', `translation-${key}`, {
|
69
|
-
label: `${key}`,
|
70
|
-
description: `Translate ${codeFormat(englishTranslation)}.`,
|
71
|
-
placeholder: englishTranslation,
|
72
|
-
});
|
73
|
-
}
|
74
|
-
addInput('textarea', 'additional-comments', {
|
75
|
-
label: 'Additional information',
|
76
|
-
placeholder: 'Any additional information/comments on the translation can go here.',
|
77
|
-
});
|
78
|
-
return `name: Translation
|
79
|
-
# This template is auto-generated by build_tools/buildTranslationTemplate.ts
|
80
|
-
# Do not modify it directly.
|
81
|
-
description: Translate the editor to a new language!
|
82
|
-
title: "[Translation]: <language>"
|
83
|
-
labels: [localization]
|
84
|
-
assignees: []
|
85
|
-
body:
|
86
|
-
${bodyContentLines.join('\n')}`;
|
87
|
-
};
|
88
|
-
const template = generateTranslationTemplate();
|
89
|
-
// According to https://stackoverflow.com/a/13650454, fs should
|
90
|
-
// be able to handle forward and back slashes (both) on Windows (so extra
|
91
|
-
// path logic shouldn't be needed here.)
|
92
|
-
const rootDir = path.dirname(__dirname);
|
93
|
-
const translationTempaltePath = path.join(rootDir, '.github/ISSUE_TEMPLATE/translation.yml');
|
94
|
-
fs.writeFileSync(translationTempaltePath, template);
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/src/Color4.d.ts
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
export default class Color4 {
|
2
|
-
/** Red component. Should be in the range [0, 1]. */
|
3
|
-
readonly r: number;
|
4
|
-
/** Green component. `g` ∈ [0, 1] */
|
5
|
-
readonly g: number;
|
6
|
-
/** Blue component. `b` ∈ [0, 1] */
|
7
|
-
readonly b: number;
|
8
|
-
/** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
|
9
|
-
readonly a: number;
|
10
|
-
private constructor();
|
11
|
-
/**
|
12
|
-
* Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
|
13
|
-
*
|
14
|
-
* Each component should be in the range [0, 1].
|
15
|
-
*/
|
16
|
-
static ofRGB(red: number, green: number, blue: number): Color4;
|
17
|
-
static ofRGBA(red: number, green: number, blue: number, alpha: number): Color4;
|
18
|
-
static fromHex(hexString: string): Color4;
|
19
|
-
/** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
|
20
|
-
static fromString(text: string): Color4;
|
21
|
-
/** @returns true if `this` and `other` are approximately equal. */
|
22
|
-
eq(other: Color4 | null | undefined): boolean;
|
23
|
-
/**
|
24
|
-
* If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
|
25
|
-
* in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
|
26
|
-
*
|
27
|
-
* @returns a color `fractionTo` of the way from this color to `other`.
|
28
|
-
*
|
29
|
-
* @example
|
30
|
-
* ```ts
|
31
|
-
* Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
|
32
|
-
* ```
|
33
|
-
*/
|
34
|
-
mix(other: Color4, fractionTo: number): Color4;
|
35
|
-
/**
|
36
|
-
* @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
|
37
|
-
*/
|
38
|
-
static average(colors: Color4[]): Color4;
|
39
|
-
private hexString;
|
40
|
-
/**
|
41
|
-
* @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
|
42
|
-
*
|
43
|
-
* @example
|
44
|
-
* ```
|
45
|
-
* Color4.red.toHexString(); // -> #ff0000ff
|
46
|
-
* ```
|
47
|
-
*/
|
48
|
-
toHexString(): string;
|
49
|
-
toString(): string;
|
50
|
-
static transparent: Color4;
|
51
|
-
static red: Color4;
|
52
|
-
static green: Color4;
|
53
|
-
static blue: Color4;
|
54
|
-
static purple: Color4;
|
55
|
-
static yellow: Color4;
|
56
|
-
static clay: Color4;
|
57
|
-
static black: Color4;
|
58
|
-
static gray: Color4;
|
59
|
-
static white: Color4;
|
60
|
-
}
|
package/dist/src/Color4.js
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
export default class Color4 {
|
2
|
-
constructor(
|
3
|
-
/** Red component. Should be in the range [0, 1]. */
|
4
|
-
r,
|
5
|
-
/** Green component. `g` ∈ [0, 1] */
|
6
|
-
g,
|
7
|
-
/** Blue component. `b` ∈ [0, 1] */
|
8
|
-
b,
|
9
|
-
/** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
|
10
|
-
a) {
|
11
|
-
this.r = r;
|
12
|
-
this.g = g;
|
13
|
-
this.b = b;
|
14
|
-
this.a = a;
|
15
|
-
this.hexString = null;
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
|
19
|
-
*
|
20
|
-
* Each component should be in the range [0, 1].
|
21
|
-
*/
|
22
|
-
static ofRGB(red, green, blue) {
|
23
|
-
return Color4.ofRGBA(red, green, blue, 1.0);
|
24
|
-
}
|
25
|
-
static ofRGBA(red, green, blue, alpha) {
|
26
|
-
red = Math.max(0, Math.min(red, 1));
|
27
|
-
green = Math.max(0, Math.min(green, 1));
|
28
|
-
blue = Math.max(0, Math.min(blue, 1));
|
29
|
-
alpha = Math.max(0, Math.min(alpha, 1));
|
30
|
-
return new Color4(red, green, blue, alpha);
|
31
|
-
}
|
32
|
-
static fromHex(hexString) {
|
33
|
-
var _a;
|
34
|
-
// Remove starting '#' (if present)
|
35
|
-
hexString = ((_a = hexString.match(/^[#]?(.*)$/)) !== null && _a !== void 0 ? _a : [])[1];
|
36
|
-
hexString = hexString.toUpperCase();
|
37
|
-
if (!hexString.match(/^[0-9A-F]+$/)) {
|
38
|
-
throw new Error(`${hexString} is not in a valid format.`);
|
39
|
-
}
|
40
|
-
// RGBA or RGB
|
41
|
-
if (hexString.length === 3 || hexString.length === 4) {
|
42
|
-
// Each character is a component
|
43
|
-
const components = hexString.split('');
|
44
|
-
// Convert to RRGGBBAA or RRGGBB format
|
45
|
-
hexString = components.map(component => `${component}0`).join('');
|
46
|
-
}
|
47
|
-
if (hexString.length === 6) {
|
48
|
-
// Alpha component
|
49
|
-
hexString += 'FF';
|
50
|
-
}
|
51
|
-
const components = [];
|
52
|
-
for (let i = 2; i <= hexString.length; i += 2) {
|
53
|
-
const chunk = hexString.substring(i - 2, i);
|
54
|
-
components.push(parseInt(chunk, 16) / 255);
|
55
|
-
}
|
56
|
-
if (components.length !== 4) {
|
57
|
-
throw new Error(`Unable to parse ${hexString}: Wrong number of components.`);
|
58
|
-
}
|
59
|
-
return Color4.ofRGBA(components[0], components[1], components[2], components[3]);
|
60
|
-
}
|
61
|
-
/** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
|
62
|
-
static fromString(text) {
|
63
|
-
if (text.startsWith('#')) {
|
64
|
-
return Color4.fromHex(text);
|
65
|
-
}
|
66
|
-
if (text === 'none' || text === 'transparent') {
|
67
|
-
return Color4.transparent;
|
68
|
-
}
|
69
|
-
// rgba?: Match both rgb and rgba strings.
|
70
|
-
// ([,0-9.]+): Match any string of only numeric, '.' and ',' characters.
|
71
|
-
const rgbRegex = /^rgba?\(([,0-9.]+)\)$/i;
|
72
|
-
const rgbMatch = text.replace(/\s*/g, '').match(rgbRegex);
|
73
|
-
if (rgbMatch) {
|
74
|
-
const componentsListStr = rgbMatch[1];
|
75
|
-
const componentsList = JSON.parse(`[ ${componentsListStr} ]`);
|
76
|
-
if (componentsList.length === 3) {
|
77
|
-
return Color4.ofRGB(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255);
|
78
|
-
}
|
79
|
-
else if (componentsList.length === 4) {
|
80
|
-
return Color4.ofRGBA(componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255, componentsList[3]);
|
81
|
-
}
|
82
|
-
else {
|
83
|
-
throw new Error(`RGB string, ${text}, has wrong number of components: ${componentsList.length}`);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
// Otherwise, try to use an HTMLCanvasElement to determine the color.
|
87
|
-
// Note: We may be unable to create an HTMLCanvasElement if running as a unit test.
|
88
|
-
const canvas = document.createElement('canvas');
|
89
|
-
canvas.width = 1;
|
90
|
-
canvas.height = 1;
|
91
|
-
const ctx = canvas.getContext('2d');
|
92
|
-
ctx.fillStyle = text;
|
93
|
-
ctx.fillRect(0, 0, 1, 1);
|
94
|
-
const data = ctx.getImageData(0, 0, 1, 1);
|
95
|
-
const red = data.data[0] / 255;
|
96
|
-
const green = data.data[1] / 255;
|
97
|
-
const blue = data.data[2] / 255;
|
98
|
-
const alpha = data.data[3] / 255;
|
99
|
-
return Color4.ofRGBA(red, green, blue, alpha);
|
100
|
-
}
|
101
|
-
/** @returns true if `this` and `other` are approximately equal. */
|
102
|
-
eq(other) {
|
103
|
-
if (other == null) {
|
104
|
-
return false;
|
105
|
-
}
|
106
|
-
// If both completely transparent,
|
107
|
-
if (this.a === 0 && other.a === 0) {
|
108
|
-
return true;
|
109
|
-
}
|
110
|
-
return this.toHexString() === other.toHexString();
|
111
|
-
}
|
112
|
-
/**
|
113
|
-
* If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
|
114
|
-
* in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
|
115
|
-
*
|
116
|
-
* @returns a color `fractionTo` of the way from this color to `other`.
|
117
|
-
*
|
118
|
-
* @example
|
119
|
-
* ```ts
|
120
|
-
* Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
|
121
|
-
* ```
|
122
|
-
*/
|
123
|
-
mix(other, fractionTo) {
|
124
|
-
fractionTo = Math.min(Math.max(fractionTo, 0), 1);
|
125
|
-
const fractionOfThis = 1 - fractionTo;
|
126
|
-
return new Color4(this.r * fractionOfThis + other.r * fractionTo, this.g * fractionOfThis + other.g * fractionTo, this.b * fractionOfThis + other.b * fractionTo, this.a * fractionOfThis + other.a * fractionTo);
|
127
|
-
}
|
128
|
-
/**
|
129
|
-
* @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
|
130
|
-
*/
|
131
|
-
static average(colors) {
|
132
|
-
let averageA = 0;
|
133
|
-
let averageR = 0;
|
134
|
-
let averageG = 0;
|
135
|
-
let averageB = 0;
|
136
|
-
for (const color of colors) {
|
137
|
-
averageA += color.a;
|
138
|
-
averageR += color.r;
|
139
|
-
averageG += color.g;
|
140
|
-
averageB += color.b;
|
141
|
-
}
|
142
|
-
if (colors.length > 0) {
|
143
|
-
averageA /= colors.length;
|
144
|
-
averageR /= colors.length;
|
145
|
-
averageG /= colors.length;
|
146
|
-
averageB /= colors.length;
|
147
|
-
}
|
148
|
-
return new Color4(averageR, averageG, averageB, averageA);
|
149
|
-
}
|
150
|
-
/**
|
151
|
-
* @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
|
152
|
-
*
|
153
|
-
* @example
|
154
|
-
* ```
|
155
|
-
* Color4.red.toHexString(); // -> #ff0000ff
|
156
|
-
* ```
|
157
|
-
*/
|
158
|
-
toHexString() {
|
159
|
-
if (this.hexString) {
|
160
|
-
return this.hexString;
|
161
|
-
}
|
162
|
-
const componentToHex = (component) => {
|
163
|
-
const res = Math.round(255 * component).toString(16);
|
164
|
-
if (res.length === 1) {
|
165
|
-
return `0${res}`;
|
166
|
-
}
|
167
|
-
return res;
|
168
|
-
};
|
169
|
-
const alpha = componentToHex(this.a);
|
170
|
-
const red = componentToHex(this.r);
|
171
|
-
const green = componentToHex(this.g);
|
172
|
-
const blue = componentToHex(this.b);
|
173
|
-
if (alpha === 'ff') {
|
174
|
-
return `#${red}${green}${blue}`;
|
175
|
-
}
|
176
|
-
this.hexString = `#${red}${green}${blue}${alpha}`;
|
177
|
-
return this.hexString;
|
178
|
-
}
|
179
|
-
toString() {
|
180
|
-
return this.toHexString();
|
181
|
-
}
|
182
|
-
}
|
183
|
-
Color4.transparent = Color4.ofRGBA(0, 0, 0, 0);
|
184
|
-
Color4.red = Color4.ofRGB(1.0, 0.0, 0.0);
|
185
|
-
Color4.green = Color4.ofRGB(0.0, 1.0, 0.0);
|
186
|
-
Color4.blue = Color4.ofRGB(0.0, 0.0, 1.0);
|
187
|
-
Color4.purple = Color4.ofRGB(0.5, 0.2, 0.5);
|
188
|
-
Color4.yellow = Color4.ofRGB(1, 1, 0.1);
|
189
|
-
Color4.clay = Color4.ofRGB(0.8, 0.4, 0.2);
|
190
|
-
Color4.black = Color4.ofRGB(0, 0, 0);
|
191
|
-
Color4.gray = Color4.ofRGB(0.5, 0.5, 0.5);
|
192
|
-
Color4.white = Color4.ofRGB(1, 1, 1);
|
package/dist/src/Editor.d.ts
DELETED
@@ -1,308 +0,0 @@
|
|
1
|
-
import EditorImage from './EditorImage';
|
2
|
-
import ToolController from './tools/ToolController';
|
3
|
-
import { InputEvtType, EditorNotifier, ImageLoader } from './types';
|
4
|
-
import Command from './commands/Command';
|
5
|
-
import UndoRedoHistory from './UndoRedoHistory';
|
6
|
-
import Viewport from './Viewport';
|
7
|
-
import { Point2 } from './math/Vec2';
|
8
|
-
import HTMLToolbar from './toolbar/HTMLToolbar';
|
9
|
-
import { RenderablePathSpec } from './rendering/renderers/AbstractRenderer';
|
10
|
-
import Display, { RenderingMode } from './rendering/Display';
|
11
|
-
import Color4 from './Color4';
|
12
|
-
import Pointer from './Pointer';
|
13
|
-
import Rect2 from './math/Rect2';
|
14
|
-
import { EditorLocalization } from './localization';
|
15
|
-
import IconProvider from './toolbar/IconProvider';
|
16
|
-
import AbstractComponent from './components/AbstractComponent';
|
17
|
-
type HTMLPointerEventType = 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel';
|
18
|
-
type HTMLPointerEventFilter = (eventName: HTMLPointerEventType, event: PointerEvent) => boolean;
|
19
|
-
export interface EditorSettings {
|
20
|
-
/** Defaults to `RenderingMode.CanvasRenderer` */
|
21
|
-
renderingMode: RenderingMode;
|
22
|
-
/** Uses a default English localization if a translation is not given. */
|
23
|
-
localization: Partial<EditorLocalization>;
|
24
|
-
/**
|
25
|
-
* `true` if touchpad/mousewheel scrolling should scroll the editor instead of the document.
|
26
|
-
* This does not include pinch-zoom events.
|
27
|
-
* Defaults to true.
|
28
|
-
*/
|
29
|
-
wheelEventsEnabled: boolean | 'only-if-focused';
|
30
|
-
/** Minimum zoom fraction (e.g. 0.5 → 50% zoom). */
|
31
|
-
minZoom: number;
|
32
|
-
maxZoom: number;
|
33
|
-
iconProvider: IconProvider;
|
34
|
-
}
|
35
|
-
/**
|
36
|
-
* The main entrypoint for the full editor.
|
37
|
-
*
|
38
|
-
* @example
|
39
|
-
* To create an editor with a toolbar,
|
40
|
-
* ```
|
41
|
-
* const editor = new Editor(document.body);
|
42
|
-
*
|
43
|
-
* const toolbar = editor.addToolbar();
|
44
|
-
* toolbar.addActionButton('Save', () => {
|
45
|
-
* const saveData = editor.toSVG().outerHTML;
|
46
|
-
* // Do something with saveData...
|
47
|
-
* });
|
48
|
-
* ```
|
49
|
-
*
|
50
|
-
* See also
|
51
|
-
* [`docs/example/example.ts`](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/example/example.ts#L15).
|
52
|
-
*/
|
53
|
-
export declare class Editor {
|
54
|
-
private container;
|
55
|
-
private renderingRegion;
|
56
|
-
/** Manages drawing surfaces/{@link lib!AbstractRenderer}s. */
|
57
|
-
display: Display;
|
58
|
-
/**
|
59
|
-
* Handles undo/redo.
|
60
|
-
*
|
61
|
-
* @example
|
62
|
-
* ```
|
63
|
-
* const editor = new Editor(document.body);
|
64
|
-
*
|
65
|
-
* // Do something undoable.
|
66
|
-
* // ...
|
67
|
-
*
|
68
|
-
* // Undo the last action
|
69
|
-
* editor.history.undo();
|
70
|
-
* ```
|
71
|
-
*/
|
72
|
-
history: UndoRedoHistory;
|
73
|
-
/**
|
74
|
-
* Data structure for adding/removing/querying objects in the image.
|
75
|
-
*
|
76
|
-
* @example
|
77
|
-
* ```
|
78
|
-
* const editor = new Editor(document.body);
|
79
|
-
*
|
80
|
-
* // Create a path.
|
81
|
-
* const stroke = new Stroke([
|
82
|
-
* Path.fromString('M0,0 L30,30 z').toRenderable({ fill: Color4.black }),
|
83
|
-
* ]);
|
84
|
-
* const addElementCommand = editor.image.addElement(stroke);
|
85
|
-
*
|
86
|
-
* // Add the stroke to the editor
|
87
|
-
* editor.dispatch(addElementCommand);
|
88
|
-
* ```
|
89
|
-
*/
|
90
|
-
readonly image: EditorImage;
|
91
|
-
/**
|
92
|
-
* Allows transforming the view and querying information about
|
93
|
-
* what is currently visible.
|
94
|
-
*/
|
95
|
-
readonly viewport: Viewport;
|
96
|
-
/** @internal */
|
97
|
-
readonly localization: EditorLocalization;
|
98
|
-
/** {@link lib!EditorSettings.iconProvider} */
|
99
|
-
readonly icons: IconProvider;
|
100
|
-
/**
|
101
|
-
* Controls the list of tools. See
|
102
|
-
* [the custom tool example](https://github.com/personalizedrefrigerator/js-draw/tree/main/docs/example-custom-tools)
|
103
|
-
* for more.
|
104
|
-
*/
|
105
|
-
readonly toolController: ToolController;
|
106
|
-
/**
|
107
|
-
* Global event dispatcher/subscriber.
|
108
|
-
*/
|
109
|
-
readonly notifier: EditorNotifier;
|
110
|
-
private loadingWarning;
|
111
|
-
private accessibilityAnnounceArea;
|
112
|
-
private accessibilityControlArea;
|
113
|
-
private eventListenerTargets;
|
114
|
-
private settings;
|
115
|
-
/**
|
116
|
-
* @example
|
117
|
-
* ```
|
118
|
-
* const container = document.body;
|
119
|
-
*
|
120
|
-
* // Create an editor
|
121
|
-
* const editor = new Editor(container, {
|
122
|
-
* // 2e-10 and 1e12 are the default values for minimum/maximum zoom.
|
123
|
-
* minZoom: 2e-10,
|
124
|
-
* maxZoom: 1e12,
|
125
|
-
* });
|
126
|
-
*
|
127
|
-
* // Add the default toolbar
|
128
|
-
* const toolbar = editor.addToolbar();
|
129
|
-
*
|
130
|
-
* // Add a save button
|
131
|
-
* toolbar.addActionButton({
|
132
|
-
* label: 'Save'
|
133
|
-
* icon: createSaveIcon(),
|
134
|
-
* }, () => {
|
135
|
-
* const saveData = editor.toSVG().outerHTML;
|
136
|
-
* // Do something with saveData
|
137
|
-
* });
|
138
|
-
* ```
|
139
|
-
*/
|
140
|
-
constructor(parent: HTMLElement, settings?: Partial<EditorSettings>);
|
141
|
-
/**
|
142
|
-
* @returns a reference to the editor's container.
|
143
|
-
*
|
144
|
-
* @example
|
145
|
-
* ```
|
146
|
-
* // Set the editor's height to 500px
|
147
|
-
* editor.getRootElement().style.height = '500px';
|
148
|
-
* ```
|
149
|
-
*/
|
150
|
-
getRootElement(): HTMLElement;
|
151
|
-
/** @param fractionLoaded - should be a number from 0 to 1, where 1 represents completely loaded. */
|
152
|
-
showLoadingWarning(fractionLoaded: number): void;
|
153
|
-
hideLoadingWarning(): void;
|
154
|
-
private previousAccessibilityAnnouncement;
|
155
|
-
/**
|
156
|
-
* Announce `message` for screen readers. If `message` is the same as the previous
|
157
|
-
* message, it is re-announced.
|
158
|
-
*/
|
159
|
-
announceForAccessibility(message: string): void;
|
160
|
-
/**
|
161
|
-
* Creates a toolbar. If `defaultLayout` is true, default buttons are used.
|
162
|
-
* @returns a reference to the toolbar.
|
163
|
-
*/
|
164
|
-
addToolbar(defaultLayout?: boolean): HTMLToolbar;
|
165
|
-
private registerListeners;
|
166
|
-
private pointers;
|
167
|
-
private getPointerList;
|
168
|
-
/**
|
169
|
-
* Dispatches a `PointerEvent` to the editor. The target element for `evt` must have the same top left
|
170
|
-
* as the content of the editor.
|
171
|
-
*/
|
172
|
-
handleHTMLPointerEvent(eventType: 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel', evt: PointerEvent): boolean;
|
173
|
-
private isEventSink;
|
174
|
-
private handlePaste;
|
175
|
-
/**
|
176
|
-
* Forward pointer events from `elem` to this editor. Such that right-click/right-click drag
|
177
|
-
* events are also forwarded, `elem`'s contextmenu is disabled.
|
178
|
-
*
|
179
|
-
* @example
|
180
|
-
* ```ts
|
181
|
-
* const overlay = document.createElement('div');
|
182
|
-
* editor.createHTMLOverlay(overlay);
|
183
|
-
*
|
184
|
-
* // Send all pointer events that don't have the control key pressed
|
185
|
-
* // to the editor.
|
186
|
-
* editor.handlePointerEventsFrom(overlay, (event) => {
|
187
|
-
* if (event.ctrlKey) {
|
188
|
-
* return false;
|
189
|
-
* }
|
190
|
-
* return true;
|
191
|
-
* });
|
192
|
-
* ```
|
193
|
-
*/
|
194
|
-
handlePointerEventsFrom(elem: HTMLElement, filter?: HTMLPointerEventFilter): void;
|
195
|
-
/** Adds event listners for keypresses to `elem` and forwards those events to the editor. */
|
196
|
-
handleKeyEventsFrom(elem: HTMLElement): void;
|
197
|
-
/** `apply` a command. `command` will be announced for accessibility. */
|
198
|
-
dispatch(command: Command, addToHistory?: boolean): void | Promise<void>;
|
199
|
-
/**
|
200
|
-
* Dispatches a command without announcing it. By default, does not add to history.
|
201
|
-
* Use this to show finalized commands that don't need to have `announceForAccessibility`
|
202
|
-
* called.
|
203
|
-
*
|
204
|
-
* Prefer `command.apply(editor)` for incomplete commands. `dispatchNoAnnounce` may allow
|
205
|
-
* clients to listen for the application of commands (e.g. `SerializableCommand`s so they can
|
206
|
-
* be sent across the network), while `apply` does not.
|
207
|
-
*
|
208
|
-
* @example
|
209
|
-
* ```
|
210
|
-
* const addToHistory = false;
|
211
|
-
* editor.dispatchNoAnnounce(editor.viewport.zoomTo(someRectangle), addToHistory);
|
212
|
-
* ```
|
213
|
-
*/
|
214
|
-
dispatchNoAnnounce(command: Command, addToHistory?: boolean): void | Promise<void>;
|
215
|
-
/**
|
216
|
-
* Apply a large transformation in chunks.
|
217
|
-
* If `apply` is `false`, the commands are unapplied.
|
218
|
-
* Triggers a re-render after each `updateChunkSize`-sized group of commands
|
219
|
-
* has been applied.
|
220
|
-
*/
|
221
|
-
asyncApplyOrUnapplyCommands(commands: Command[], apply: boolean, updateChunkSize: number): Promise<void>;
|
222
|
-
asyncApplyCommands(commands: Command[], chunkSize: number): Promise<void>;
|
223
|
-
asyncUnapplyCommands(commands: Command[], chunkSize: number, unapplyInReverseOrder?: boolean): Promise<void>;
|
224
|
-
private announceUndoCallback;
|
225
|
-
private announceRedoCallback;
|
226
|
-
private nextRerenderListeners;
|
227
|
-
private rerenderQueued;
|
228
|
-
/**
|
229
|
-
* Schedule a re-render for some time in the near future. Does not schedule an additional
|
230
|
-
* re-render if a re-render is already queued.
|
231
|
-
*
|
232
|
-
* @returns a promise that resolves when re-rendering has completed.
|
233
|
-
*/
|
234
|
-
queueRerender(): Promise<void>;
|
235
|
-
isRerenderQueued(): boolean;
|
236
|
-
/**
|
237
|
-
* Re-renders the entire image.
|
238
|
-
*
|
239
|
-
* @see {@link Editor.queueRerender}
|
240
|
-
*/
|
241
|
-
rerender(showImageBounds?: boolean): void;
|
242
|
-
/**
|
243
|
-
* Draws the given path onto the wet ink renderer. The given path will
|
244
|
-
* be displayed on top of the main image.
|
245
|
-
*
|
246
|
-
* @see {@link Display.getWetInkRenderer} {@link Display.flatten}
|
247
|
-
*/
|
248
|
-
drawWetInk(...path: RenderablePathSpec[]): void;
|
249
|
-
/**
|
250
|
-
* Clears the wet ink display.
|
251
|
-
*
|
252
|
-
* @see {@link Display.getWetInkRenderer}
|
253
|
-
*/
|
254
|
-
clearWetInk(): void;
|
255
|
-
/**
|
256
|
-
* Focuses the region used for text input/key commands.
|
257
|
-
*/
|
258
|
-
focus(): void;
|
259
|
-
/**
|
260
|
-
* Creates an element that will be positioned on top of the dry/wet ink
|
261
|
-
* renderers.
|
262
|
-
*
|
263
|
-
* This is useful for displaying content on top of the rendered content
|
264
|
-
* (e.g. a selection box).
|
265
|
-
*/
|
266
|
-
createHTMLOverlay(overlay: HTMLElement): {
|
267
|
-
remove: () => void;
|
268
|
-
};
|
269
|
-
addStyleSheet(content: string): HTMLStyleElement;
|
270
|
-
sendKeyboardEvent(eventType: InputEvtType.KeyPressEvent | InputEvtType.KeyUpEvent, key: string, ctrlKey?: boolean, altKey?: boolean): void;
|
271
|
-
/**
|
272
|
-
* Dispatch a pen event to the currently selected tool.
|
273
|
-
* Intended primarially for unit tests.
|
274
|
-
*
|
275
|
-
* @deprecated
|
276
|
-
* @see {@link sendPenEvent} {@link sendTouchEvent}
|
277
|
-
*/
|
278
|
-
sendPenEvent(eventType: InputEvtType.PointerDownEvt | InputEvtType.PointerMoveEvt | InputEvtType.PointerUpEvt, point: Point2, allPointers?: Pointer[]): void;
|
279
|
-
addAndCenterComponents(components: AbstractComponent[], selectComponents?: boolean): Promise<void>;
|
280
|
-
toDataURL(format?: 'image/png' | 'image/jpeg' | 'image/webp'): string;
|
281
|
-
toSVG(): SVGElement;
|
282
|
-
/**
|
283
|
-
* Load editor data from an `ImageLoader` (e.g. an {@link SVGLoader}).
|
284
|
-
*
|
285
|
-
* @see loadFromSVG
|
286
|
-
*/
|
287
|
-
loadFrom(loader: ImageLoader): Promise<void>;
|
288
|
-
private getTopmostBackgroundComponent;
|
289
|
-
/**
|
290
|
-
* Set the background color of the image.
|
291
|
-
*/
|
292
|
-
setBackgroundColor(color: Color4): Command;
|
293
|
-
/**
|
294
|
-
* @returns the average of the colors of all background components. Use this to get the current background
|
295
|
-
* color.
|
296
|
-
*/
|
297
|
-
estimateBackgroundColor(): Color4;
|
298
|
-
getImportExportRect(): Rect2;
|
299
|
-
setImportExportRect(imageRect: Rect2): Command;
|
300
|
-
/**
|
301
|
-
* Alias for loadFrom(SVGLoader.fromString).
|
302
|
-
*
|
303
|
-
* This is particularly useful when accessing a bundled version of the editor,
|
304
|
-
* where `SVGLoader.fromString` is unavailable.
|
305
|
-
*/
|
306
|
-
loadFromSVG(svgData: string, sanitize?: boolean): Promise<void>;
|
307
|
-
}
|
308
|
-
export default Editor;
|