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,654 +0,0 @@
|
|
1
|
-
import Color4 from '../Color4';
|
2
|
-
import { Vec2 } from '../math/Vec2';
|
3
|
-
import SVGRenderer from '../rendering/renderers/SVGRenderer';
|
4
|
-
import Viewport from '../Viewport';
|
5
|
-
const svgNamespace = 'http://www.w3.org/2000/svg';
|
6
|
-
const iconColorFill = `
|
7
|
-
style='fill: var(--icon-color);'
|
8
|
-
`;
|
9
|
-
const iconColorStrokeFill = `
|
10
|
-
style='fill: var(--icon-color); stroke: var(--icon-color);'
|
11
|
-
`;
|
12
|
-
const checkerboardPatternDef = `
|
13
|
-
<pattern
|
14
|
-
id='checkerboard'
|
15
|
-
viewBox='0,0,10,10'
|
16
|
-
width='20%'
|
17
|
-
height='20%'
|
18
|
-
patternUnits='userSpaceOnUse'
|
19
|
-
>
|
20
|
-
<rect x=0 y=0 width=10 height=10 fill='white'/>
|
21
|
-
<rect x=0 y=0 width=5 height=5 fill='gray'/>
|
22
|
-
<rect x=5 y=5 width=5 height=5 fill='gray'/>
|
23
|
-
</pattern>
|
24
|
-
`;
|
25
|
-
const checkerboardPatternRef = 'url(#checkerboard)';
|
26
|
-
/**
|
27
|
-
* Provides icons that can be used in the toolbar, etc.
|
28
|
-
* Extend this class and override methods to customize icons.
|
29
|
-
*
|
30
|
-
* @example
|
31
|
-
* ```ts
|
32
|
-
* class CustomIconProvider extends jsdraw.IconProvider {
|
33
|
-
* // Use '☺' instead of the default dropdown symbol.
|
34
|
-
* public makeDropdownIcon() {
|
35
|
-
* const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
36
|
-
* icon.innerHTML = `
|
37
|
-
* <text x='5' y='55' style='fill: var(--icon-color); font-size: 50pt;'>☺</text>
|
38
|
-
* `;
|
39
|
-
* icon.setAttribute('viewBox', '0 0 100 100');
|
40
|
-
* return icon;
|
41
|
-
* }
|
42
|
-
* }
|
43
|
-
*
|
44
|
-
* const icons = new CustomIconProvider();
|
45
|
-
* const editor = new jsdraw.Editor(document.body, {
|
46
|
-
* iconProvider: icons,
|
47
|
-
* });
|
48
|
-
*
|
49
|
-
* // Add a toolbar that uses these icons
|
50
|
-
* editor.addToolbar();
|
51
|
-
* ```
|
52
|
-
*/
|
53
|
-
export default class IconProvider {
|
54
|
-
makeUndoIcon() {
|
55
|
-
return this.makeRedoIcon(true);
|
56
|
-
}
|
57
|
-
// @param mirror - reflect across the x-axis. This parameter is internal.
|
58
|
-
// @returns a redo icon.
|
59
|
-
makeRedoIcon(mirror = false) {
|
60
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
61
|
-
icon.innerHTML = `
|
62
|
-
<style>
|
63
|
-
.toolbar-svg-undo-redo-icon {
|
64
|
-
stroke: var(--icon-color);
|
65
|
-
stroke-width: 12;
|
66
|
-
stroke-linejoin: round;
|
67
|
-
stroke-linecap: round;
|
68
|
-
fill: none;
|
69
|
-
|
70
|
-
transform-origin: center;
|
71
|
-
}
|
72
|
-
</style>
|
73
|
-
<path
|
74
|
-
d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
|
75
|
-
class='toolbar-svg-undo-redo-icon'
|
76
|
-
style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
|
77
|
-
`;
|
78
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
79
|
-
return icon;
|
80
|
-
}
|
81
|
-
makeDropdownIcon() {
|
82
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
83
|
-
icon.innerHTML = `
|
84
|
-
<g>
|
85
|
-
<path
|
86
|
-
d='M5,10 L50,90 L95,10 Z'
|
87
|
-
${iconColorFill}
|
88
|
-
/>
|
89
|
-
</g>
|
90
|
-
`;
|
91
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
92
|
-
return icon;
|
93
|
-
}
|
94
|
-
makeEraserIcon(eraserSize) {
|
95
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
96
|
-
eraserSize !== null && eraserSize !== void 0 ? eraserSize : (eraserSize = 10);
|
97
|
-
const scaledSize = eraserSize / 4;
|
98
|
-
const eraserColor = '#ff70af';
|
99
|
-
// Draw an eraser-like shape. Created with Inkscape
|
100
|
-
icon.innerHTML = `
|
101
|
-
<g>
|
102
|
-
<path
|
103
|
-
style="fill:${eraserColor}"
|
104
|
-
stroke="black"
|
105
|
-
transform="rotate(41.35)"
|
106
|
-
d="M 52.5 27
|
107
|
-
C 50 28.9 48.9 31.7 48.9 34.8
|
108
|
-
L 48.9 39.8
|
109
|
-
C 48.9 45.3 53.4 49.8 58.9 49.8
|
110
|
-
L 103.9 49.8
|
111
|
-
C 105.8 49.8 107.6 49.2 109.1 48.3
|
112
|
-
L 110.2 ${scaledSize + 49.5} L 159.7 ${scaledSize + 5}
|
113
|
-
L 157.7 ${-scaledSize + 5.2} L 112.4 ${49.5 - scaledSize}
|
114
|
-
C 113.4 43.5 113.9 41.7 113.9 39.8
|
115
|
-
L 113.9 34.8
|
116
|
-
C 113.9 29.3 109.4 24.8 103.9 24.8
|
117
|
-
L 58.9 24.8
|
118
|
-
C 56.5 24.8 54.3 25.7 52.5 27
|
119
|
-
z "
|
120
|
-
id="path438" />
|
121
|
-
|
122
|
-
<rect
|
123
|
-
stroke="#cc8077"
|
124
|
-
${iconColorFill}
|
125
|
-
id="rect218"
|
126
|
-
width="65"
|
127
|
-
height="75"
|
128
|
-
x="48.9"
|
129
|
-
y="-38.7"
|
130
|
-
transform="rotate(41.35)" />
|
131
|
-
</g>
|
132
|
-
`;
|
133
|
-
icon.setAttribute('viewBox', '0 0 120 120');
|
134
|
-
return icon;
|
135
|
-
}
|
136
|
-
makeSelectionIcon() {
|
137
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
138
|
-
// Draw a cursor-like shape
|
139
|
-
icon.innerHTML = `
|
140
|
-
<g>
|
141
|
-
<rect x=10 y=10 width=70 height=70 fill='pink' stroke='black'/>
|
142
|
-
<rect x=75 y=75 width=10 height=10 fill='white' stroke='black'/>
|
143
|
-
</g>
|
144
|
-
`;
|
145
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
146
|
-
return icon;
|
147
|
-
}
|
148
|
-
/**
|
149
|
-
* @param pathData - SVG path data (e.g. `m10,10l30,30z`)
|
150
|
-
* @param fill - A valid CSS color (e.g. `var(--icon-color)` or `#f0f`). This can be `none`.
|
151
|
-
*/
|
152
|
-
makeIconFromPath(pathData, fill = 'var(--icon-color)', strokeColor = 'none', strokeWidth = '0px') {
|
153
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
154
|
-
const path = document.createElementNS(svgNamespace, 'path');
|
155
|
-
path.setAttribute('d', pathData);
|
156
|
-
path.style.fill = fill;
|
157
|
-
path.style.stroke = strokeColor;
|
158
|
-
path.style.strokeWidth = strokeWidth;
|
159
|
-
icon.appendChild(path);
|
160
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
161
|
-
return icon;
|
162
|
-
}
|
163
|
-
makeHandToolIcon() {
|
164
|
-
const fill = 'none';
|
165
|
-
const strokeColor = 'var(--icon-color)';
|
166
|
-
const strokeWidth = '3';
|
167
|
-
// Draw a cursor-like shape
|
168
|
-
return this.makeIconFromPath(`
|
169
|
-
m 10,60
|
170
|
-
5,30
|
171
|
-
H 90
|
172
|
-
V 30
|
173
|
-
C 90,20 75,20 75,30
|
174
|
-
V 60
|
175
|
-
20
|
176
|
-
C 75,10 60,10 60,20
|
177
|
-
V 60
|
178
|
-
15
|
179
|
-
C 60,5 45,5 45,15
|
180
|
-
V 60
|
181
|
-
25
|
182
|
-
C 45,15 30,15 30,25
|
183
|
-
V 60
|
184
|
-
75
|
185
|
-
L 25,60
|
186
|
-
C 20,45 10,50 10,60
|
187
|
-
Z
|
188
|
-
`, fill, strokeColor, strokeWidth);
|
189
|
-
}
|
190
|
-
makeTouchPanningIcon() {
|
191
|
-
const fill = 'none';
|
192
|
-
const strokeColor = 'var(--icon-color)';
|
193
|
-
const strokeWidth = '3';
|
194
|
-
return this.makeIconFromPath(`
|
195
|
-
M 5,5.5
|
196
|
-
V 17.2
|
197
|
-
L 16.25,5.46
|
198
|
-
Z
|
199
|
-
|
200
|
-
m 33.75,0
|
201
|
-
L 50,17
|
202
|
-
V 5.5
|
203
|
-
Z
|
204
|
-
|
205
|
-
M 5,40.7
|
206
|
-
v 11.7
|
207
|
-
h 11.25
|
208
|
-
z
|
209
|
-
|
210
|
-
M 26,19
|
211
|
-
C 19.8,19.4 17.65,30.4 21.9,34.8
|
212
|
-
L 50,70
|
213
|
-
H 27.5
|
214
|
-
c -11.25,0 -11.25,17.6 0,17.6
|
215
|
-
H 61.25
|
216
|
-
C 94.9,87.8 95,87.6 95,40.7 78.125,23 67,29 55.6,46.5
|
217
|
-
L 33.1,23
|
218
|
-
C 30.3125,20.128192 27.9,19 25.830078,19.119756
|
219
|
-
Z
|
220
|
-
`, fill, strokeColor, strokeWidth);
|
221
|
-
}
|
222
|
-
makeAllDevicePanningIcon() {
|
223
|
-
const fill = 'none';
|
224
|
-
const strokeColor = 'var(--icon-color)';
|
225
|
-
const strokeWidth = '3';
|
226
|
-
return this.makeIconFromPath(`
|
227
|
-
M 5 5
|
228
|
-
L 5 17.5
|
229
|
-
17.5 5
|
230
|
-
5 5
|
231
|
-
z
|
232
|
-
|
233
|
-
M 42.5 5
|
234
|
-
L 55 17.5
|
235
|
-
55 5
|
236
|
-
42.5 5
|
237
|
-
z
|
238
|
-
|
239
|
-
M 70 10
|
240
|
-
L 70 21
|
241
|
-
61 15
|
242
|
-
55.5 23
|
243
|
-
66 30
|
244
|
-
56 37
|
245
|
-
61 45
|
246
|
-
70 39
|
247
|
-
70 50
|
248
|
-
80 50
|
249
|
-
80 39
|
250
|
-
89 45
|
251
|
-
95 36
|
252
|
-
84 30
|
253
|
-
95 23
|
254
|
-
89 15
|
255
|
-
80 21
|
256
|
-
80 10
|
257
|
-
70 10
|
258
|
-
z
|
259
|
-
|
260
|
-
M 27.5 26.25
|
261
|
-
L 27.5 91.25
|
262
|
-
L 43.75 83.125
|
263
|
-
L 52 99
|
264
|
-
L 68 91
|
265
|
-
L 60 75
|
266
|
-
L 76.25 66.875
|
267
|
-
L 27.5 26.25
|
268
|
-
z
|
269
|
-
|
270
|
-
M 5 42.5
|
271
|
-
L 5 55
|
272
|
-
L 17.5 55
|
273
|
-
L 5 42.5
|
274
|
-
z
|
275
|
-
`, fill, strokeColor, strokeWidth);
|
276
|
-
}
|
277
|
-
makeZoomIcon() {
|
278
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
279
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
280
|
-
const addTextNode = (text, x, y) => {
|
281
|
-
const textNode = document.createElementNS(svgNamespace, 'text');
|
282
|
-
textNode.appendChild(document.createTextNode(text));
|
283
|
-
textNode.setAttribute('x', x.toString());
|
284
|
-
textNode.setAttribute('y', y.toString());
|
285
|
-
textNode.style.textAlign = 'center';
|
286
|
-
textNode.style.textAnchor = 'middle';
|
287
|
-
textNode.style.fontSize = '55px';
|
288
|
-
textNode.style.fill = 'var(--icon-color)';
|
289
|
-
textNode.style.fontFamily = 'monospace';
|
290
|
-
icon.appendChild(textNode);
|
291
|
-
};
|
292
|
-
addTextNode('+', 40, 45);
|
293
|
-
addTextNode('-', 70, 75);
|
294
|
-
return icon;
|
295
|
-
}
|
296
|
-
makeRotationLockIcon() {
|
297
|
-
const icon = this.makeIconFromPath(`
|
298
|
-
M 40.1 25.1
|
299
|
-
C 32.5 25 27.9 34.1 27.9 34.1
|
300
|
-
L 25.7 30
|
301
|
-
L 28 44.7
|
302
|
-
L 36.6 40.3
|
303
|
-
L 32.3 38.3
|
304
|
-
C 33.6 28 38.1 25.2 45.1 31.8
|
305
|
-
L 49.4 29.6
|
306
|
-
C 45.9 26.3 42.8 25.1 40.1 25.1
|
307
|
-
z
|
308
|
-
|
309
|
-
M 51.7 34.2
|
310
|
-
L 43.5 39.1
|
311
|
-
L 48 40.8
|
312
|
-
C 47.4 51.1 43.1 54.3 35.7 48.2
|
313
|
-
L 31.6 50.7
|
314
|
-
C 45.5 62.1 52.6 44.6 52.6 44.6
|
315
|
-
L 55.1 48.6
|
316
|
-
L 51.7 34.2
|
317
|
-
z
|
318
|
-
|
319
|
-
M 56.9 49.9
|
320
|
-
C 49.8 49.9 49.2 57.3 49.3 60.9
|
321
|
-
L 47.6 60.9
|
322
|
-
L 47.6 73.7
|
323
|
-
L 66.1 73.7
|
324
|
-
L 66.1 60.9
|
325
|
-
L 64.4 60.9
|
326
|
-
C 64.5 57.3 63.9 49.9 56.9 49.9
|
327
|
-
z
|
328
|
-
|
329
|
-
M 56.9 53.5
|
330
|
-
C 60.8 53.5 61 58.2 60.8 60.9
|
331
|
-
L 52.9 60.9
|
332
|
-
C 52.7 58.2 52.9 53.5 56.9 53.5
|
333
|
-
z
|
334
|
-
`);
|
335
|
-
icon.setAttribute('viewBox', '10 10 70 70');
|
336
|
-
return icon;
|
337
|
-
}
|
338
|
-
makeInsertImageIcon() {
|
339
|
-
return this.makeIconFromPath(`
|
340
|
-
M 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z
|
341
|
-
M 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z
|
342
|
-
M 22.5 25 A 7.5 7.5 0 0 0 15 32.5 A 7.5 7.5 0 0 0 22.5 40 A 7.5 7.5 0 0 0 30 32.5 A 7.5 7.5 0 0 0 22.5 25 z
|
343
|
-
`);
|
344
|
-
}
|
345
|
-
makeTextIcon(textStyle) {
|
346
|
-
var _a, _b;
|
347
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
348
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
349
|
-
const textNode = document.createElementNS(svgNamespace, 'text');
|
350
|
-
textNode.appendChild(document.createTextNode('T'));
|
351
|
-
textNode.style.fontFamily = textStyle.fontFamily;
|
352
|
-
textNode.style.fontWeight = (_a = textStyle.fontWeight) !== null && _a !== void 0 ? _a : '';
|
353
|
-
textNode.style.fontVariant = (_b = textStyle.fontVariant) !== null && _b !== void 0 ? _b : '';
|
354
|
-
textNode.style.fill = textStyle.renderingStyle.fill.toHexString();
|
355
|
-
textNode.style.textAnchor = 'middle';
|
356
|
-
textNode.setAttribute('x', '50');
|
357
|
-
textNode.setAttribute('y', '75');
|
358
|
-
textNode.style.fontSize = '65px';
|
359
|
-
textNode.style.filter = 'drop-shadow(0px 0px 10px var(--primary-shadow-color))';
|
360
|
-
icon.appendChild(textNode);
|
361
|
-
return icon;
|
362
|
-
}
|
363
|
-
makePenIcon(strokeSize, color, rounded) {
|
364
|
-
if (color instanceof Color4) {
|
365
|
-
color = color.toHexString();
|
366
|
-
}
|
367
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
368
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
369
|
-
const tipThickness = strokeSize / 2;
|
370
|
-
const inkTipPath = `
|
371
|
-
M ${15 - tipThickness},${80 - tipThickness}
|
372
|
-
${15 - tipThickness},${80 + tipThickness}
|
373
|
-
30,83
|
374
|
-
15,65
|
375
|
-
Z
|
376
|
-
`;
|
377
|
-
const trailStartEndY = 80 + tipThickness;
|
378
|
-
const inkTrailPath = `
|
379
|
-
m ${15 - tipThickness * 1.1},${trailStartEndY}
|
380
|
-
c 35,10 55,15 60,30
|
381
|
-
l ${35 + tipThickness * 1.2},${-10 - tipThickness}
|
382
|
-
C 80.47,98.32 50.5,${90 + tipThickness} 20,${trailStartEndY} Z
|
383
|
-
`;
|
384
|
-
const colorBubblePath = `
|
385
|
-
M 72.45,35.67
|
386
|
-
A 10,15 41.8 0 1 55,40.2 10,15 41.8 0 1 57.55,22.3 10,15 41.8 0 1 75,17.8 10,15 41.8 0 1 72.5,35.67
|
387
|
-
Z
|
388
|
-
`;
|
389
|
-
let gripMainPath = 'M 85,-25 25,35 h 10 v 10 h 10 v 10 h 10 v 10 h 10 l -5,10 60,-60 z';
|
390
|
-
let gripShadow1Path = 'M 25,35 H 35 L 90,-15 85,-25 Z';
|
391
|
-
let gripShadow2Path = 'M 60,75 65,65 H 55 l 55,-55 10,5 z';
|
392
|
-
if (rounded) {
|
393
|
-
gripMainPath = 'M 85,-25 25,35 c 15,0 40,30 35,40 l 60,-60 z';
|
394
|
-
gripShadow1Path = 'm 25,35 c 3.92361,0.384473 7.644275,0.980572 10,3 l 55,-53 -5,-10 z';
|
395
|
-
gripShadow2Path = 'M 60,75 C 61,66 59,65 56,59 l 54,-54 10,10 z';
|
396
|
-
}
|
397
|
-
const penTipPath = `M 25,35 ${10 - tipThickness / 4},${70 - tipThickness / 2} 20,75 25,85 60,75 70,55 45,25 Z`;
|
398
|
-
const pencilTipColor = Color4.fromHex('#f4d7d7');
|
399
|
-
const tipColor = pencilTipColor.mix(Color4.fromString(color), tipThickness / 40 - 0.1).toHexString();
|
400
|
-
const ink = `
|
401
|
-
<path
|
402
|
-
fill="${checkerboardPatternRef}"
|
403
|
-
d="${inkTipPath}"
|
404
|
-
/>
|
405
|
-
<path
|
406
|
-
fill="${checkerboardPatternRef}"
|
407
|
-
d="${inkTrailPath}"
|
408
|
-
/>
|
409
|
-
<path
|
410
|
-
fill="${color}"
|
411
|
-
d="${inkTipPath}"
|
412
|
-
/>
|
413
|
-
<path
|
414
|
-
fill="${color}"
|
415
|
-
d="${inkTrailPath}"
|
416
|
-
/>
|
417
|
-
`;
|
418
|
-
const penTip = `
|
419
|
-
<path
|
420
|
-
fill="${checkerboardPatternRef}"
|
421
|
-
d="${penTipPath}"
|
422
|
-
/>
|
423
|
-
<path
|
424
|
-
fill="${tipColor}"
|
425
|
-
stroke="${color}"
|
426
|
-
d="${penTipPath}"
|
427
|
-
/>
|
428
|
-
`;
|
429
|
-
const grip = `
|
430
|
-
<path
|
431
|
-
${iconColorStrokeFill}
|
432
|
-
d="${gripMainPath}"
|
433
|
-
/>
|
434
|
-
|
435
|
-
<!-- shadows -->
|
436
|
-
<path
|
437
|
-
fill="rgba(150, 150, 150, 0.3)"
|
438
|
-
d="${gripShadow1Path}"
|
439
|
-
/>
|
440
|
-
<path
|
441
|
-
fill="rgba(100, 100, 100, 0.2)"
|
442
|
-
d="${gripShadow2Path}"
|
443
|
-
/>
|
444
|
-
|
445
|
-
<!-- color bubble -->
|
446
|
-
<path
|
447
|
-
fill="${checkerboardPatternRef}"
|
448
|
-
d="${colorBubblePath}"
|
449
|
-
/>
|
450
|
-
<path
|
451
|
-
fill="${color}"
|
452
|
-
d="${colorBubblePath}"
|
453
|
-
/>
|
454
|
-
`;
|
455
|
-
icon.innerHTML = `
|
456
|
-
<defs>
|
457
|
-
${checkerboardPatternDef}
|
458
|
-
</defs>
|
459
|
-
<g>
|
460
|
-
${ink}
|
461
|
-
${penTip}
|
462
|
-
${grip}
|
463
|
-
</g>
|
464
|
-
`;
|
465
|
-
return icon;
|
466
|
-
}
|
467
|
-
makeIconFromFactory(pen, factory) {
|
468
|
-
// Increase the thickness we use to generate the icon less with larger actual thicknesses.
|
469
|
-
// We want the icon to be recognisable with a large range of thicknesses.
|
470
|
-
const thickness = Math.sqrt(pen.getThickness()) * 3;
|
471
|
-
const nowTime = (new Date()).getTime();
|
472
|
-
const startPoint = {
|
473
|
-
pos: Vec2.of(10, 10),
|
474
|
-
width: thickness,
|
475
|
-
color: pen.getColor(),
|
476
|
-
time: nowTime - 100,
|
477
|
-
};
|
478
|
-
const endPoint = {
|
479
|
-
pos: Vec2.of(90, 90),
|
480
|
-
width: thickness,
|
481
|
-
color: pen.getColor(),
|
482
|
-
time: nowTime,
|
483
|
-
};
|
484
|
-
const viewport = new Viewport(() => { });
|
485
|
-
const builder = factory(startPoint, viewport);
|
486
|
-
builder.addPoint(endPoint);
|
487
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
488
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
489
|
-
viewport.updateScreenSize(Vec2.of(100, 100));
|
490
|
-
const renderer = new SVGRenderer(icon, viewport);
|
491
|
-
builder.preview(renderer);
|
492
|
-
return icon;
|
493
|
-
}
|
494
|
-
makePipetteIcon(color) {
|
495
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
496
|
-
const pipette = document.createElementNS(svgNamespace, 'path');
|
497
|
-
pipette.setAttribute('d', `
|
498
|
-
M 47,6
|
499
|
-
C 35,5 25,15 35,30
|
500
|
-
c -9.2,1.3 -15,0 -15,3
|
501
|
-
0,2 5,5 15,7
|
502
|
-
V 81
|
503
|
-
L 40,90
|
504
|
-
h 6
|
505
|
-
L 40,80
|
506
|
-
V 40
|
507
|
-
h 15
|
508
|
-
v 40
|
509
|
-
l -6,10
|
510
|
-
h 6
|
511
|
-
l 5,-9.2
|
512
|
-
V 40
|
513
|
-
C 70,38 75,35 75,33
|
514
|
-
75,30 69.2,31.2 60,30
|
515
|
-
65,15 65,5 47,6
|
516
|
-
Z
|
517
|
-
`);
|
518
|
-
pipette.style.fill = 'var(--icon-color)';
|
519
|
-
if (color) {
|
520
|
-
const defs = document.createElementNS(svgNamespace, 'defs');
|
521
|
-
defs.innerHTML = checkerboardPatternDef;
|
522
|
-
icon.appendChild(defs);
|
523
|
-
const fluidBackground = document.createElementNS(svgNamespace, 'path');
|
524
|
-
const fluid = document.createElementNS(svgNamespace, 'path');
|
525
|
-
const fluidPathData = `
|
526
|
-
m 40,50 c 5,5 10,0 15,-5 V 80 L 50,90 H 45 L 40,80 Z
|
527
|
-
`;
|
528
|
-
fluid.setAttribute('d', fluidPathData);
|
529
|
-
fluidBackground.setAttribute('d', fluidPathData);
|
530
|
-
fluid.style.fill = color.toHexString();
|
531
|
-
fluidBackground.style.fill = checkerboardPatternRef;
|
532
|
-
icon.appendChild(fluidBackground);
|
533
|
-
icon.appendChild(fluid);
|
534
|
-
}
|
535
|
-
icon.appendChild(pipette);
|
536
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
537
|
-
return icon;
|
538
|
-
}
|
539
|
-
makeFormatSelectionIcon() {
|
540
|
-
return this.makeIconFromPath(`
|
541
|
-
M 5 10
|
542
|
-
L 5 20 L 10 20 L 10 15 L 20 15 L 20 40 L 15 40 L 15 45 L 35 45 L 35 40 L 30 40 L 30 15 L 40 15 L 40 20 L 45 20 L 45 15 L 45 10 L 5 10 z
|
543
|
-
M 90 10 C 90 10 86.5 13.8 86 14 C 86 14 76.2 24.8 76 25 L 60 25 L 60 65 C 75 70 85 70 90 65 L 90 25 L 80 25 L 76.7 25 L 90 10 z
|
544
|
-
M 60 25 L 55 25 L 50 30 L 60 25 z
|
545
|
-
M 10 55 L 10 90 L 41 90 L 41 86 L 45 86 L 45 55 L 10 55 z
|
546
|
-
M 42 87 L 42 93 L 48 93 L 48 87 L 42 87 z
|
547
|
-
`);
|
548
|
-
}
|
549
|
-
makeResizeViewportIcon() {
|
550
|
-
return this.makeIconFromPath(`
|
551
|
-
M 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z
|
552
|
-
M 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z
|
553
|
-
M 84 15 82 17 81 16 81 20 85 20 84 19 86 17 84 15 z
|
554
|
-
M 26 24 24 26 26 28 25 29 29 29 29 25 28 26 26 24 z
|
555
|
-
M 25 71 26 72 24 74 26 76 28 74 29 75 29 71 25 71 z
|
556
|
-
M 15 75 15 85 25 85 25 80 20 80 20 75 15 75 z
|
557
|
-
M 90 75 90 90 75 90 75 95 95 95 95 75 90 75 z
|
558
|
-
M 81 81 81 85 82 84 84 86 86 84 84 82 85 81 81 81 z
|
559
|
-
`);
|
560
|
-
}
|
561
|
-
makeDuplicateSelectionIcon() {
|
562
|
-
return this.makeIconFromPath(`
|
563
|
-
M 45,10 45,55 90,55 90,10 45,10 z
|
564
|
-
M 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z
|
565
|
-
`);
|
566
|
-
}
|
567
|
-
makePasteIcon() {
|
568
|
-
const icon = this.makeIconFromPath(`
|
569
|
-
M 50 0 L 50 5 L 35 5 L 40 24.75 L 20 25 L 20 100 L 85 100 L 100 90 L 100 24 L 75.1 24.3 L 80 5 L 65 5 L 65 0 L 50 0 z
|
570
|
-
M 10 15 L 10 115 L 110 115 L 110 15 L 85 15 L 83 20 L 105 20 L 105 110 L 15 110 L 15 20 L 32 20 L 30 15 L 10 15 z
|
571
|
-
M 25 35 L 90 35 L 90 40 L 25 40 L 25 35 z
|
572
|
-
M 25 45 L 90 45 L 90 50 L 25 50 L 25 45 z
|
573
|
-
M 25 55 L 85 55 L 85 60 L 25 60 L 25 55 z
|
574
|
-
M 25 65 L 90 65 L 90 70 L 25 70 L 25 65 z
|
575
|
-
`);
|
576
|
-
icon.setAttribute('viewBox', '0 0 120 120');
|
577
|
-
return icon;
|
578
|
-
}
|
579
|
-
makeDeleteSelectionIcon() {
|
580
|
-
const strokeWidth = '5px';
|
581
|
-
const strokeColor = 'var(--icon-color)';
|
582
|
-
const fillColor = 'none';
|
583
|
-
return this.makeIconFromPath(`
|
584
|
-
M 10,10 90,90
|
585
|
-
M 10,90 90,10
|
586
|
-
`, fillColor, strokeColor, strokeWidth);
|
587
|
-
}
|
588
|
-
makeSaveIcon() {
|
589
|
-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
590
|
-
svg.innerHTML = `
|
591
|
-
<style>
|
592
|
-
.toolbar-save-icon {
|
593
|
-
stroke: var(--icon-color);
|
594
|
-
stroke-width: 10;
|
595
|
-
stroke-linejoin: round;
|
596
|
-
stroke-linecap: round;
|
597
|
-
fill: none;
|
598
|
-
}
|
599
|
-
</style>
|
600
|
-
<path
|
601
|
-
d='
|
602
|
-
M 15,55 30,70 85,20
|
603
|
-
'
|
604
|
-
class='toolbar-save-icon'
|
605
|
-
/>
|
606
|
-
`;
|
607
|
-
svg.setAttribute('viewBox', '0 0 100 100');
|
608
|
-
return svg;
|
609
|
-
}
|
610
|
-
makeConfigureDocumentIcon() {
|
611
|
-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
612
|
-
svg.innerHTML = `
|
613
|
-
<path
|
614
|
-
d='
|
615
|
-
M 5,5 V 95 H 95 V 5 Z m 5,5 H 90 V 90 H 10 Z
|
616
|
-
m 5,10 V 30 H 50 V 25 H 20 v -5 z
|
617
|
-
m 40,0 V 50 H 85 V 20 Z
|
618
|
-
m 2,2 H 83 V 39 L 77,28 70,42 64,35 57,45 Z
|
619
|
-
m 8.5,5 C 64.67,27 64,27.67 64,28.5 64,29.33 64.67,30 65.5,30 66.33,30 67,29.33 67,28.5 67,27.67 66.33,27 65.5,27 Z
|
620
|
-
M 15,40 v 5 h 35 v -5 z
|
621
|
-
m 0,15 v 5 h 70 v -5 z
|
622
|
-
m 0,15 v 5 h 70 v -5 z
|
623
|
-
'
|
624
|
-
style='fill: var(--icon-color);'
|
625
|
-
/>
|
626
|
-
`;
|
627
|
-
svg.setAttribute('viewBox', '0 0 100 100');
|
628
|
-
return svg;
|
629
|
-
}
|
630
|
-
makeOverflowIcon() {
|
631
|
-
return this.makeIconFromPath(`
|
632
|
-
M 15 40
|
633
|
-
A 12.5 12.5 0 0 0 2.5 52.5
|
634
|
-
A 12.5 12.5 0 0 0 15 65
|
635
|
-
A 12.5 12.5 0 0 0 27.5 52.5
|
636
|
-
A 12.5 12.5 0 0 0 15 40
|
637
|
-
z
|
638
|
-
|
639
|
-
M 50 40
|
640
|
-
A 12.5 12.5 0 0 0 37.5 52.5
|
641
|
-
A 12.5 12.5 0 0 0 50 65
|
642
|
-
A 12.5 12.5 0 0 0 62.5 52.5
|
643
|
-
A 12.5 12.5 0 0 0 50 40
|
644
|
-
z
|
645
|
-
|
646
|
-
M 85 40
|
647
|
-
A 12.5 12.5 0 0 0 72.5 52.5
|
648
|
-
A 12.5 12.5 0 0 0 85 65
|
649
|
-
A 12.5 12.5 0 0 0 97.5 52.5
|
650
|
-
A 12.5 12.5 0 0 0 85 40
|
651
|
-
z
|
652
|
-
`);
|
653
|
-
}
|
654
|
-
}
|
package/dist/src/toolbar/lib.js
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
export interface ToolbarLocalization {
|
2
|
-
fontLabel: string;
|
3
|
-
textSize: string;
|
4
|
-
touchPanning: string;
|
5
|
-
lockRotation: string;
|
6
|
-
outlinedRectanglePen: string;
|
7
|
-
filledRectanglePen: string;
|
8
|
-
linePen: string;
|
9
|
-
arrowPen: string;
|
10
|
-
image: string;
|
11
|
-
inputAltText: string;
|
12
|
-
chooseFile: string;
|
13
|
-
cancel: string;
|
14
|
-
submit: string;
|
15
|
-
freehandPen: string;
|
16
|
-
pressureSensitiveFreehandPen: string;
|
17
|
-
selectObjectType: string;
|
18
|
-
colorLabel: string;
|
19
|
-
pen: string;
|
20
|
-
eraser: string;
|
21
|
-
select: string;
|
22
|
-
handTool: string;
|
23
|
-
thicknessLabel: string;
|
24
|
-
resizeImageToSelection: string;
|
25
|
-
deleteSelection: string;
|
26
|
-
duplicateSelection: string;
|
27
|
-
pickColorFromScreen: string;
|
28
|
-
clickToPickColorAnnouncement: string;
|
29
|
-
reformatSelection: string;
|
30
|
-
undo: string;
|
31
|
-
redo: string;
|
32
|
-
zoom: string;
|
33
|
-
resetView: string;
|
34
|
-
selectionToolKeyboardShortcuts: string;
|
35
|
-
paste: string;
|
36
|
-
documentProperties: string;
|
37
|
-
backgroundColor: string;
|
38
|
-
imageWidthOption: string;
|
39
|
-
imageHeightOption: string;
|
40
|
-
toggleOverflow: string;
|
41
|
-
errorImageHasZeroSize: string;
|
42
|
-
dropdownShown: (toolName: string) => string;
|
43
|
-
dropdownHidden: (toolName: string) => string;
|
44
|
-
zoomLevel: (zoomPercentage: number) => string;
|
45
|
-
colorChangedAnnouncement: (color: string) => string;
|
46
|
-
imageSize: (size: number, units: string) => string;
|
47
|
-
imageLoadError: (message: string) => string;
|
48
|
-
}
|
49
|
-
export declare const defaultToolbarLocalization: ToolbarLocalization;
|