js-draw 0.25.1 → 1.0.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/README.md +80 -26
- package/build-config.json +22 -21
- package/dist/Editor.css +1281 -0
- package/dist/bundle.js +3 -3
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.d.ts +91 -12
- package/dist/cjs/Editor.js +619 -590
- package/dist/cjs/EditorImage.d.ts +5 -2
- package/dist/cjs/EditorImage.js +258 -297
- package/dist/cjs/EventDispatcher.js +17 -19
- package/dist/cjs/Pointer.d.ts +3 -1
- package/dist/cjs/Pointer.js +41 -44
- package/dist/cjs/SVGLoader.d.ts +7 -1
- package/dist/cjs/SVGLoader.js +373 -474
- package/dist/cjs/UndoRedoHistory.js +28 -40
- package/dist/cjs/Viewport.d.ts +1 -4
- package/dist/cjs/Viewport.js +150 -193
- package/dist/cjs/bundle/bundled.js +4 -1
- package/dist/cjs/commands/Command.js +22 -49
- package/dist/cjs/commands/Duplicate.js +28 -44
- package/dist/cjs/commands/Erase.js +36 -54
- package/dist/cjs/commands/SerializableCommand.js +20 -35
- package/dist/cjs/commands/UnresolvedCommand.js +14 -29
- package/dist/cjs/commands/invertCommand.js +29 -51
- package/dist/cjs/commands/lib.js +9 -6
- package/dist/cjs/commands/localization.d.ts +1 -1
- package/dist/cjs/commands/localization.js +9 -9
- package/dist/cjs/commands/uniteCommands.js +57 -87
- package/dist/cjs/components/AbstractComponent.d.ts +11 -3
- package/dist/cjs/components/AbstractComponent.js +141 -169
- package/dist/cjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/cjs/components/BackgroundComponent.js +124 -149
- package/dist/cjs/components/ImageComponent.d.ts +3 -5
- package/dist/cjs/components/ImageComponent.js +95 -175
- package/dist/cjs/components/RestylableComponent.d.ts +1 -1
- package/dist/cjs/components/RestylableComponent.js +41 -56
- package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/cjs/components/SVGGlobalAttributesObject.js +34 -51
- package/dist/cjs/components/Stroke.d.ts +4 -6
- package/dist/cjs/components/Stroke.js +95 -121
- package/dist/cjs/components/TextComponent.d.ts +2 -4
- package/dist/cjs/components/TextComponent.js +189 -234
- package/dist/cjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/cjs/components/UnknownSVGObject.js +30 -43
- package/dist/cjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/ArrowBuilder.js +43 -42
- package/dist/cjs/components/builders/CircleBuilder.js +43 -43
- package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/cjs/components/builders/FreehandLineBuilder.js +73 -86
- package/dist/cjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/LineBuilder.js +38 -36
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +131 -139
- package/dist/cjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/RectangleBuilder.js +31 -31
- package/dist/cjs/components/builders/types.d.ts +1 -1
- package/dist/cjs/components/lib.d.ts +3 -1
- package/dist/cjs/components/lib.js +10 -7
- package/dist/cjs/components/localization.js +4 -4
- package/dist/cjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/cjs/components/util/StrokeSmoother.js +67 -72
- package/dist/cjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/cjs/components/util/describeComponentList.js +4 -5
- package/dist/cjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/cjs/dialogs/makeAboutDialog.js +54 -0
- package/dist/cjs/inputEvents.d.ts +84 -0
- package/dist/cjs/inputEvents.js +40 -0
- package/dist/cjs/lib.d.ts +29 -13
- package/dist/cjs/lib.js +38 -23
- package/dist/cjs/localization.js +19 -18
- package/dist/cjs/localizations/de.js +117 -13
- package/dist/cjs/localizations/en.js +4 -13
- package/dist/cjs/localizations/es.js +62 -23
- package/dist/cjs/localizations/getLocalizationTable.js +15 -13
- package/dist/cjs/rendering/Display.d.ts +1 -2
- package/dist/cjs/rendering/Display.js +70 -83
- package/dist/cjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/cjs/rendering/RenderablePathSpec.js +70 -0
- package/dist/cjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/cjs/rendering/RenderingStyle.js +18 -28
- package/dist/cjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/cjs/rendering/TextRenderingStyle.js +13 -18
- package/dist/cjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/cjs/rendering/caching/CacheRecord.js +20 -22
- package/dist/cjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/cjs/rendering/caching/CacheRecordManager.js +17 -15
- package/dist/cjs/rendering/caching/RenderingCache.js +19 -19
- package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +98 -118
- package/dist/cjs/rendering/caching/testUtils.js +24 -23
- package/dist/cjs/rendering/caching/types.d.ts +3 -3
- package/dist/cjs/rendering/lib.js +8 -5
- package/dist/cjs/rendering/localization.js +5 -5
- package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +53 -57
- package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +91 -106
- package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/cjs/rendering/renderers/DummyRenderer.js +56 -76
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/cjs/rendering/renderers/SVGRenderer.js +194 -176
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +47 -72
- package/dist/cjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/cjs/shortcuts/KeyBinding.js +94 -70
- package/dist/cjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/cjs/shortcuts/KeyboardShortcutManager.js +36 -45
- package/dist/cjs/shortcuts/lib.js +5 -2
- package/dist/cjs/testing/createEditor.js +7 -4
- package/dist/cjs/testing/getUniquePointerId.js +4 -5
- package/dist/cjs/testing/lib.js +5 -2
- package/dist/cjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/cjs/testing/sendPenEvent.js +10 -7
- package/dist/cjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/cjs/testing/sendTouchEvent.js +34 -16
- package/dist/cjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/cjs/toolbar/AbstractToolbar.js +410 -0
- package/dist/cjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/cjs/toolbar/DropdownToolbar.js +176 -0
- package/dist/cjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/cjs/toolbar/EdgeToolbar.js +422 -0
- package/dist/cjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/cjs/toolbar/IconProvider.js +652 -224
- package/dist/cjs/toolbar/constants.d.ts +1 -0
- package/dist/cjs/toolbar/constants.js +4 -0
- package/dist/cjs/toolbar/lib.d.ts +4 -2
- package/dist/cjs/toolbar/lib.js +10 -3
- package/dist/cjs/toolbar/localization.d.ts +9 -2
- package/dist/cjs/toolbar/localization.js +26 -19
- package/dist/cjs/toolbar/types.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +23 -39
- package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +35 -37
- package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/cjs/toolbar/widgets/BaseWidget.js +232 -177
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +130 -117
- package/dist/cjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/cjs/toolbar/widgets/EraserToolWidget.js +45 -73
- package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +126 -141
- package/dist/cjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/cjs/toolbar/widgets/InsertImageWidget.js +147 -212
- package/dist/cjs/toolbar/widgets/OverflowWidget.js +33 -61
- package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +162 -234
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +105 -177
- package/dist/cjs/toolbar/widgets/TextToolWidget.js +64 -87
- package/dist/cjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/cjs/toolbar/{makeColorInput.js → widgets/components/makeColorInput.js} +57 -34
- package/dist/cjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/cjs/toolbar/widgets/components/makeFileInput.js +111 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.js +127 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.js +16 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.js +47 -0
- package/dist/cjs/toolbar/widgets/keybindings.js +8 -5
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.js +199 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.js +60 -0
- package/dist/cjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/cjs/toolbar/widgets/layout/types.js +2 -0
- package/dist/cjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/lib.js +15 -11
- package/dist/cjs/tools/BaseTool.d.ts +28 -9
- package/dist/cjs/tools/BaseTool.js +128 -51
- package/dist/cjs/tools/Eraser.d.ts +8 -1
- package/dist/cjs/tools/Eraser.js +82 -92
- package/dist/cjs/tools/FindTool.d.ts +1 -1
- package/dist/cjs/tools/FindTool.js +61 -77
- package/dist/cjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/cjs/tools/InputFilter/FunctionMapper.js +21 -0
- package/dist/cjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/cjs/tools/InputFilter/InputMapper.js +38 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.js +54 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.js +181 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +84 -0
- package/dist/cjs/tools/PanZoom.d.ts +4 -2
- package/dist/cjs/tools/PanZoom.js +186 -248
- package/dist/cjs/tools/PasteHandler.d.ts +1 -1
- package/dist/cjs/tools/PasteHandler.js +49 -148
- package/dist/cjs/tools/Pen.d.ts +12 -11
- package/dist/cjs/tools/Pen.js +123 -158
- package/dist/cjs/tools/PipetteTool.d.ts +11 -2
- package/dist/cjs/tools/PipetteTool.js +51 -48
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +15 -30
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/cjs/tools/SelectionTool/Selection.js +308 -415
- package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +63 -37
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +164 -187
- package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/TransformMode.js +65 -66
- package/dist/cjs/tools/SoundUITool.d.ts +2 -1
- package/dist/cjs/tools/SoundUITool.js +70 -84
- package/dist/cjs/tools/TextTool.d.ts +5 -3
- package/dist/cjs/tools/TextTool.js +169 -173
- package/dist/cjs/tools/ToolController.d.ts +16 -2
- package/dist/cjs/tools/ToolController.js +124 -100
- package/dist/cjs/tools/ToolEnabledGroup.js +6 -9
- package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/cjs/tools/ToolSwitcherShortcut.js +16 -32
- package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/ToolbarShortcutHandler.js +17 -33
- package/dist/cjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/cjs/tools/UndoRedoShortcut.js +12 -27
- package/dist/cjs/tools/keybindings.js +21 -18
- package/dist/cjs/tools/lib.js +17 -14
- package/dist/cjs/tools/localization.d.ts +2 -1
- package/dist/cjs/tools/localization.js +8 -7
- package/dist/cjs/types.d.ts +22 -80
- package/dist/cjs/types.js +8 -16
- package/dist/cjs/util/ReactiveValue.d.ts +65 -0
- package/dist/cjs/util/ReactiveValue.js +166 -0
- package/dist/cjs/util/assertions.js +5 -8
- package/dist/cjs/util/fileToBase64.js +6 -6
- package/dist/cjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/cjs/util/guessKeyCodeFromKey.js +32 -0
- package/dist/cjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/cjs/util/listPrefixMatch.js +17 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.js +17 -0
- package/dist/cjs/util/untilNextAnimationFrame.js +3 -3
- package/dist/cjs/util/waitForAll.js +3 -3
- package/dist/cjs/util/waitForTimeout.js +3 -3
- package/dist/cjs/version.d.ts +4 -0
- package/dist/cjs/version.js +5 -0
- package/dist/mjs/Editor.d.ts +91 -12
- package/dist/mjs/Editor.mjs +565 -563
- package/dist/mjs/EditorImage.d.ts +5 -2
- package/dist/mjs/EditorImage.mjs +248 -291
- package/dist/mjs/EventDispatcher.mjs +17 -20
- package/dist/mjs/Pointer.d.ts +3 -1
- package/dist/mjs/Pointer.mjs +40 -44
- package/dist/mjs/SVGLoader.d.ts +7 -1
- package/dist/mjs/SVGLoader.mjs +338 -466
- package/dist/mjs/UndoRedoHistory.mjs +27 -39
- package/dist/mjs/Viewport.d.ts +1 -4
- package/dist/mjs/Viewport.mjs +139 -187
- package/dist/mjs/commands/Command.mjs +21 -49
- package/dist/mjs/commands/Duplicate.mjs +22 -41
- package/dist/mjs/commands/Erase.mjs +30 -51
- package/dist/mjs/commands/SerializableCommand.mjs +16 -34
- package/dist/mjs/commands/UnresolvedCommand.mjs +10 -29
- package/dist/mjs/commands/invertCommand.mjs +24 -49
- package/dist/mjs/commands/localization.d.ts +1 -1
- package/dist/mjs/commands/localization.mjs +10 -10
- package/dist/mjs/commands/uniteCommands.mjs +52 -85
- package/dist/mjs/components/AbstractComponent.d.ts +11 -3
- package/dist/mjs/components/AbstractComponent.mjs +135 -166
- package/dist/mjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/mjs/components/BackgroundComponent.mjs +107 -136
- package/dist/mjs/components/ImageComponent.d.ts +3 -5
- package/dist/mjs/components/ImageComponent.mjs +90 -174
- package/dist/mjs/components/RestylableComponent.d.ts +1 -1
- package/dist/mjs/components/RestylableComponent.mjs +35 -53
- package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +29 -50
- package/dist/mjs/components/Stroke.d.ts +4 -6
- package/dist/mjs/components/Stroke.mjs +89 -119
- package/dist/mjs/components/TextComponent.d.ts +2 -4
- package/dist/mjs/components/TextComponent.mjs +180 -228
- package/dist/mjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/mjs/components/UnknownSVGObject.mjs +26 -43
- package/dist/mjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/ArrowBuilder.mjs +32 -35
- package/dist/mjs/components/builders/CircleBuilder.mjs +35 -38
- package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/mjs/components/builders/FreehandLineBuilder.mjs +52 -69
- package/dist/mjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/LineBuilder.mjs +30 -32
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +103 -115
- package/dist/mjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/RectangleBuilder.mjs +27 -31
- package/dist/mjs/components/builders/types.d.ts +1 -1
- package/dist/mjs/components/lib.d.ts +3 -1
- package/dist/mjs/components/lib.mjs +1 -1
- package/dist/mjs/components/localization.mjs +5 -5
- package/dist/mjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/mjs/components/util/StrokeSmoother.mjs +63 -69
- package/dist/mjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/mjs/components/util/describeComponentList.mjs +4 -5
- package/dist/mjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/mjs/dialogs/makeAboutDialog.mjs +52 -0
- package/dist/mjs/inputEvents.d.ts +84 -0
- package/dist/mjs/inputEvents.mjs +34 -0
- package/dist/mjs/lib.d.ts +29 -13
- package/dist/mjs/lib.mjs +30 -13
- package/dist/mjs/localization.mjs +14 -13
- package/dist/mjs/localizations/de.mjs +116 -12
- package/dist/mjs/localizations/en.mjs +3 -12
- package/dist/mjs/localizations/es.mjs +61 -22
- package/dist/mjs/localizations/getLocalizationTable.mjs +12 -13
- package/dist/mjs/rendering/Display.d.ts +1 -2
- package/dist/mjs/rendering/Display.mjs +62 -79
- package/dist/mjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/mjs/rendering/RenderablePathSpec.mjs +64 -0
- package/dist/mjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/mjs/rendering/RenderingStyle.mjs +16 -26
- package/dist/mjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/mjs/rendering/TextRenderingStyle.mjs +12 -17
- package/dist/mjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/mjs/rendering/caching/CacheRecord.mjs +20 -23
- package/dist/mjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/mjs/rendering/caching/CacheRecordManager.mjs +13 -15
- package/dist/mjs/rendering/caching/RenderingCache.mjs +13 -17
- package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +94 -115
- package/dist/mjs/rendering/caching/testUtils.mjs +19 -21
- package/dist/mjs/rendering/caching/types.d.ts +3 -3
- package/dist/mjs/rendering/localization.mjs +6 -6
- package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +47 -52
- package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +84 -103
- package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +51 -75
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +185 -171
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +43 -72
- package/dist/mjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/mjs/shortcuts/KeyBinding.mjs +94 -71
- package/dist/mjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +32 -44
- package/dist/mjs/testing/createEditor.mjs +2 -2
- package/dist/mjs/testing/getUniquePointerId.mjs +4 -5
- package/dist/mjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/mjs/testing/sendPenEvent.mjs +5 -5
- package/dist/mjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/mjs/testing/sendTouchEvent.mjs +8 -16
- package/dist/mjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/mjs/toolbar/AbstractToolbar.mjs +405 -0
- package/dist/mjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/mjs/toolbar/DropdownToolbar.mjs +168 -0
- package/dist/mjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/mjs/toolbar/EdgeToolbar.mjs +414 -0
- package/dist/mjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/mjs/toolbar/IconProvider.mjs +644 -219
- package/dist/mjs/toolbar/constants.d.ts +1 -0
- package/dist/mjs/toolbar/constants.mjs +1 -0
- package/dist/mjs/toolbar/lib.d.ts +4 -2
- package/dist/mjs/toolbar/lib.mjs +3 -1
- package/dist/mjs/toolbar/localization.d.ts +9 -2
- package/dist/mjs/toolbar/localization.mjs +27 -20
- package/dist/mjs/toolbar/types.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +19 -39
- package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +30 -36
- package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +227 -176
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +98 -111
- package/dist/mjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +41 -73
- package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +94 -136
- package/dist/mjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +140 -208
- package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +30 -62
- package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +150 -225
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +97 -173
- package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +59 -85
- package/dist/mjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/mjs/toolbar/{makeColorInput.mjs → widgets/components/makeColorInput.mjs} +53 -33
- package/dist/mjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +106 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.mjs +122 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.mjs +14 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.mjs +45 -0
- package/dist/mjs/toolbar/widgets/keybindings.mjs +5 -5
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.mjs +193 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.mjs +57 -0
- package/dist/mjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/mjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/lib.mjs +1 -1
- package/dist/mjs/tools/BaseTool.d.ts +28 -9
- package/dist/mjs/tools/BaseTool.mjs +127 -50
- package/dist/mjs/tools/Eraser.d.ts +8 -1
- package/dist/mjs/tools/Eraser.mjs +72 -86
- package/dist/mjs/tools/FindTool.d.ts +1 -1
- package/dist/mjs/tools/FindTool.mjs +55 -75
- package/dist/mjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/mjs/tools/InputFilter/FunctionMapper.mjs +15 -0
- package/dist/mjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/mjs/tools/InputFilter/InputMapper.mjs +36 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.mjs +49 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +175 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +78 -0
- package/dist/mjs/tools/PanZoom.d.ts +4 -2
- package/dist/mjs/tools/PanZoom.mjs +169 -235
- package/dist/mjs/tools/PasteHandler.d.ts +1 -1
- package/dist/mjs/tools/PasteHandler.mjs +42 -145
- package/dist/mjs/tools/Pen.d.ts +12 -11
- package/dist/mjs/tools/Pen.mjs +115 -154
- package/dist/mjs/tools/PipetteTool.d.ts +11 -2
- package/dist/mjs/tools/PipetteTool.mjs +47 -48
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +9 -28
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/mjs/tools/SelectionTool/Selection.mjs +268 -401
- package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +62 -37
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +153 -179
- package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +52 -59
- package/dist/mjs/tools/SoundUITool.d.ts +2 -1
- package/dist/mjs/tools/SoundUITool.mjs +66 -84
- package/dist/mjs/tools/TextTool.d.ts +5 -3
- package/dist/mjs/tools/TextTool.mjs +155 -163
- package/dist/mjs/tools/ToolController.d.ts +16 -2
- package/dist/mjs/tools/ToolController.mjs +81 -84
- package/dist/mjs/tools/ToolEnabledGroup.mjs +6 -10
- package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +12 -32
- package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/ToolbarShortcutHandler.mjs +13 -33
- package/dist/mjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/mjs/tools/UndoRedoShortcut.mjs +7 -26
- package/dist/mjs/tools/keybindings.mjs +34 -34
- package/dist/mjs/tools/localization.d.ts +2 -1
- package/dist/mjs/tools/localization.mjs +9 -8
- package/dist/mjs/types.d.ts +22 -80
- package/dist/mjs/types.mjs +7 -15
- package/dist/mjs/util/ReactiveValue.d.ts +65 -0
- package/dist/mjs/util/ReactiveValue.mjs +161 -0
- package/dist/mjs/util/assertions.mjs +5 -8
- package/dist/mjs/util/fileToBase64.mjs +6 -6
- package/dist/mjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/mjs/util/guessKeyCodeFromKey.mjs +30 -0
- package/dist/mjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/mjs/util/listPrefixMatch.mjs +15 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.mjs +15 -0
- package/dist/mjs/util/untilNextAnimationFrame.mjs +3 -3
- package/dist/mjs/util/waitForAll.mjs +3 -3
- package/dist/mjs/util/waitForTimeout.mjs +3 -3
- package/dist/mjs/version.d.ts +4 -0
- package/dist/mjs/version.mjs +3 -0
- package/dist-test/test_imports/package.json +1 -1
- package/dist-test/test_imports/test-imports.js +5 -11
- package/dist-test/test_imports/test-require.cjs +6 -11
- package/package.json +11 -22
- package/src/Coloris.css +8 -8
- package/src/Editor.loadFrom.test.ts +1 -1
- package/src/Editor.scss +148 -0
- package/src/Editor.test.ts +107 -0
- package/src/Editor.toSVG.test.ts +184 -1
- package/src/Editor.ts +325 -53
- package/src/EditorImage.test.ts +4 -7
- package/src/EditorImage.ts +10 -4
- package/src/Pointer.ts +18 -5
- package/src/SVGLoader.ts +77 -15
- package/src/UndoRedoHistory.test.ts +2 -1
- package/src/Viewport.ts +1 -4
- package/src/commands/Erase.ts +1 -0
- package/src/commands/localization.ts +1 -1
- package/src/commands/uniteCommands.test.ts +3 -3
- package/src/components/AbstractComponent.transformBy.test.ts +2 -1
- package/src/components/AbstractComponent.ts +12 -3
- package/src/components/BackgroundComponent.test.ts +1 -2
- package/src/components/BackgroundComponent.ts +3 -8
- package/src/components/ImageComponent.ts +1 -3
- package/src/components/RestylableComponent.ts +1 -1
- package/src/components/SVGGlobalAttributesObject.ts +1 -3
- package/src/components/Stroke.test.ts +4 -6
- package/src/components/Stroke.ts +5 -7
- package/src/components/TextComponent.test.ts +1 -3
- package/src/components/TextComponent.ts +1 -4
- package/src/components/UnknownSVGObject.ts +3 -3
- package/src/components/builders/ArrowBuilder.ts +1 -2
- package/src/components/builders/CircleBuilder.ts +3 -5
- package/src/components/builders/FreehandLineBuilder.test.ts +2 -3
- package/src/components/builders/FreehandLineBuilder.ts +3 -5
- package/src/components/builders/LineBuilder.ts +3 -3
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +3 -4
- package/src/components/builders/RectangleBuilder.ts +3 -4
- package/src/components/builders/types.ts +1 -1
- package/src/components/lib.ts +1 -1
- package/src/components/util/StrokeSmoother.ts +7 -7
- package/src/dialogs/dialogs.scss +36 -0
- package/src/dialogs/makeAboutDialog.scss +41 -0
- package/src/dialogs/makeAboutDialog.ts +82 -0
- package/src/inputEvents.ts +143 -0
- package/src/lib.ts +35 -13
- package/src/localizations/de.ts +2 -2
- package/src/localizations/es.ts +5 -5
- package/src/rendering/Display.ts +1 -2
- package/src/rendering/RenderablePathSpec.ts +88 -0
- package/src/rendering/RenderingStyle.test.ts +1 -1
- package/src/rendering/RenderingStyle.ts +1 -1
- package/src/rendering/caching/CacheRecord.test.ts +1 -2
- package/src/rendering/caching/CacheRecord.ts +1 -2
- package/src/rendering/caching/CacheRecordManager.ts +1 -1
- package/src/rendering/caching/RenderingCache.test.ts +3 -4
- package/src/rendering/caching/RenderingCache.ts +1 -1
- package/src/rendering/caching/RenderingCacheNode.ts +1 -2
- package/src/rendering/caching/testUtils.ts +1 -1
- package/src/rendering/caching/types.ts +3 -3
- package/src/rendering/renderers/AbstractRenderer.ts +4 -14
- package/src/rendering/renderers/CanvasRenderer.ts +17 -12
- package/src/rendering/renderers/DummyRenderer.test.ts +1 -2
- package/src/rendering/renderers/DummyRenderer.ts +1 -4
- package/src/rendering/renderers/SVGRenderer.ts +68 -11
- package/src/rendering/renderers/TextOnlyRenderer.ts +1 -4
- package/src/shortcuts/KeyBinding.test.ts +10 -0
- package/src/shortcuts/KeyBinding.ts +74 -35
- package/src/shortcuts/KeyboardShortcutManager.test.ts +1 -1
- package/src/styles.js +1 -1
- package/src/testing/sendPenEvent.ts +2 -2
- package/src/testing/sendTouchEvent.ts +2 -2
- package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
- package/src/toolbar/AbstractToolbar.ts +542 -0
- package/src/toolbar/DropdownToolbar.scss +46 -0
- package/src/toolbar/DropdownToolbar.ts +220 -0
- package/src/toolbar/EdgeToolbar.scss +511 -0
- package/src/toolbar/EdgeToolbar.test.ts +54 -0
- package/src/toolbar/EdgeToolbar.ts +543 -0
- package/src/toolbar/IconProvider.ts +189 -133
- package/src/toolbar/constants.ts +1 -0
- package/src/toolbar/lib.ts +4 -2
- package/src/toolbar/localization.ts +39 -17
- package/src/toolbar/toolbar.scss +11 -0
- package/src/toolbar/types.ts +8 -0
- package/src/toolbar/widgets/ActionButtonWidget.ts +2 -2
- package/src/toolbar/widgets/BaseToolWidget.ts +17 -1
- package/src/toolbar/widgets/BaseWidget.ts +179 -112
- package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +26 -10
- package/src/toolbar/widgets/EraserToolWidget.ts +21 -22
- package/src/toolbar/widgets/HandToolWidget.scss +14 -0
- package/src/toolbar/widgets/HandToolWidget.ts +21 -32
- package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
- package/src/toolbar/widgets/InsertImageWidget.ts +90 -65
- package/src/toolbar/widgets/PenToolWidget.css +0 -51
- package/src/toolbar/widgets/PenToolWidget.ts +106 -146
- package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
- package/src/toolbar/widgets/SelectionToolWidget.ts +83 -85
- package/src/toolbar/widgets/TextToolWidget.ts +9 -5
- package/src/toolbar/widgets/components/components.scss +5 -0
- package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
- package/src/toolbar/{makeColorInput.ts → widgets/components/makeColorInput.ts} +39 -14
- package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
- package/src/toolbar/widgets/components/makeFileInput.ts +128 -0
- package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
- package/src/toolbar/widgets/components/makeGridSelector.ts +179 -0
- package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
- package/src/toolbar/widgets/components/makeSeparator.ts +17 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.ts +62 -0
- package/src/toolbar/widgets/keybindings.ts +1 -3
- package/src/toolbar/widgets/layout/DropdownLayoutManager.ts +262 -0
- package/src/toolbar/widgets/layout/EdgeToolbarLayoutManager.ts +71 -0
- package/src/toolbar/widgets/layout/types.ts +74 -0
- package/src/toolbar/widgets/lib.ts +2 -2
- package/src/tools/BaseTool.ts +102 -30
- package/src/tools/Eraser.test.ts +2 -2
- package/src/tools/Eraser.ts +24 -11
- package/src/tools/FindTool.css +3 -3
- package/src/tools/FindTool.test.ts +67 -0
- package/src/tools/FindTool.ts +3 -3
- package/src/tools/InputFilter/FunctionMapper.ts +17 -0
- package/src/tools/InputFilter/InputMapper.ts +41 -0
- package/src/tools/InputFilter/InputPipeline.test.ts +41 -0
- package/src/tools/InputFilter/InputPipeline.ts +34 -0
- package/src/tools/InputFilter/InputStabilizer.ts +254 -0
- package/src/tools/InputFilter/StrokeKeyboardControl.ts +104 -0
- package/src/tools/PanZoom.test.ts +3 -13
- package/src/tools/PanZoom.ts +33 -10
- package/src/tools/PasteHandler.ts +2 -3
- package/src/tools/Pen.test.ts +2 -4
- package/src/tools/Pen.ts +54 -70
- package/src/tools/PipetteTool.ts +31 -2
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +1 -1
- package/src/tools/SelectionTool/Selection.ts +52 -16
- package/src/tools/SelectionTool/SelectionHandle.ts +46 -12
- package/src/tools/SelectionTool/SelectionTool.css +23 -11
- package/src/tools/SelectionTool/SelectionTool.test.ts +130 -21
- package/src/tools/SelectionTool/SelectionTool.ts +62 -48
- package/src/tools/SelectionTool/TransformMode.ts +1 -3
- package/src/tools/SoundUITool.ts +13 -4
- package/src/tools/TextTool.ts +29 -30
- package/src/tools/ToolController.ts +60 -36
- package/src/tools/ToolSwitcherShortcut.ts +1 -1
- package/src/tools/ToolbarShortcutHandler.ts +1 -1
- package/src/tools/UndoRedoShortcut.test.ts +10 -4
- package/src/tools/UndoRedoShortcut.ts +1 -1
- package/src/tools/keybindings.ts +17 -17
- package/src/tools/localization.ts +4 -2
- package/src/tools/tools.scss +4 -0
- package/src/types.ts +25 -113
- package/src/util/ReactiveValue.test.ts +168 -0
- package/src/util/ReactiveValue.ts +241 -0
- package/src/util/guessKeyCodeFromKey.ts +36 -0
- package/src/util/listPrefixMatch.ts +19 -0
- package/src/util/stopPropagationOfScrollingWheelEvents.ts +20 -0
- package/src/version.test.ts +12 -0
- package/src/version.ts +3 -0
- package/tsconfig.json +1 -1
- package/typedoc.json +4 -0
- package/dist/cjs/Color4.d.ts +0 -69
- package/dist/cjs/Color4.js +0 -263
- package/dist/cjs/math/Mat33.d.ts +0 -123
- package/dist/cjs/math/Mat33.js +0 -340
- package/dist/cjs/math/Vec2.d.ts +0 -33
- package/dist/cjs/math/Vec2.js +0 -37
- package/dist/cjs/math/Vec3.d.ts +0 -106
- package/dist/cjs/math/Vec3.js +0 -183
- package/dist/cjs/math/lib.d.ts +0 -7
- package/dist/cjs/math/lib.js +0 -15
- package/dist/cjs/math/polynomial/solveQuadratic.d.ts +0 -9
- package/dist/cjs/math/polynomial/solveQuadratic.js +0 -39
- package/dist/cjs/math/rounding.d.ts +0 -4
- package/dist/cjs/math/rounding.js +0 -140
- package/dist/cjs/math/shapes/Abstract2DShape.d.ts +0 -49
- package/dist/cjs/math/shapes/Abstract2DShape.js +0 -42
- package/dist/cjs/math/shapes/BezierJSWrapper.d.ts +0 -36
- package/dist/cjs/math/shapes/BezierJSWrapper.js +0 -109
- package/dist/cjs/math/shapes/CubicBezier.d.ts +0 -17
- package/dist/cjs/math/shapes/CubicBezier.js +0 -50
- package/dist/cjs/math/shapes/LineSegment2.d.ts +0 -70
- package/dist/cjs/math/shapes/LineSegment2.js +0 -204
- package/dist/cjs/math/shapes/Path.d.ts +0 -93
- package/dist/cjs/math/shapes/Path.js +0 -865
- package/dist/cjs/math/shapes/PointShape2D.d.ts +0 -18
- package/dist/cjs/math/shapes/PointShape2D.js +0 -46
- package/dist/cjs/math/shapes/QuadraticBezier.d.ts +0 -34
- package/dist/cjs/math/shapes/QuadraticBezier.js +0 -133
- package/dist/cjs/math/shapes/Rect2.d.ts +0 -57
- package/dist/cjs/math/shapes/Rect2.js +0 -311
- package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/cjs/math/shapes/Triangle.js +0 -148
- package/dist/cjs/toolbar/HTMLToolbar.d.ts +0 -105
- package/dist/cjs/toolbar/HTMLToolbar.js +0 -465
- package/dist/cjs/toolbar/makeColorInput.d.ts +0 -6
- package/dist/mjs/Color4.d.ts +0 -69
- package/dist/mjs/Color4.mjs +0 -260
- package/dist/mjs/Color4.test.d.ts +0 -1
- package/dist/mjs/math/Mat33.d.ts +0 -123
- package/dist/mjs/math/Mat33.mjs +0 -338
- package/dist/mjs/math/Mat33.test.d.ts +0 -1
- package/dist/mjs/math/Vec2.d.ts +0 -33
- package/dist/mjs/math/Vec2.mjs +0 -34
- package/dist/mjs/math/Vec2.test.d.ts +0 -1
- package/dist/mjs/math/Vec3.d.ts +0 -106
- package/dist/mjs/math/Vec3.mjs +0 -181
- package/dist/mjs/math/Vec3.test.d.ts +0 -1
- package/dist/mjs/math/lib.d.ts +0 -7
- package/dist/mjs/math/lib.mjs +0 -7
- package/dist/mjs/math/polynomial/solveQuadratic.d.ts +0 -9
- package/dist/mjs/math/polynomial/solveQuadratic.mjs +0 -37
- package/dist/mjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
- package/dist/mjs/math/rounding.d.ts +0 -4
- package/dist/mjs/math/rounding.mjs +0 -133
- package/dist/mjs/math/rounding.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Abstract2DShape.d.ts +0 -49
- package/dist/mjs/math/shapes/Abstract2DShape.mjs +0 -40
- package/dist/mjs/math/shapes/BezierJSWrapper.d.ts +0 -36
- package/dist/mjs/math/shapes/BezierJSWrapper.mjs +0 -107
- package/dist/mjs/math/shapes/CubicBezier.d.ts +0 -17
- package/dist/mjs/math/shapes/CubicBezier.mjs +0 -48
- package/dist/mjs/math/shapes/LineSegment2.d.ts +0 -70
- package/dist/mjs/math/shapes/LineSegment2.mjs +0 -202
- package/dist/mjs/math/shapes/LineSegment2.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.d.ts +0 -93
- package/dist/mjs/math/shapes/Path.fromString.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.mjs +0 -862
- package/dist/mjs/math/shapes/Path.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.toString.test.d.ts +0 -1
- package/dist/mjs/math/shapes/PointShape2D.d.ts +0 -18
- package/dist/mjs/math/shapes/PointShape2D.mjs +0 -44
- package/dist/mjs/math/shapes/QuadraticBezier.d.ts +0 -34
- package/dist/mjs/math/shapes/QuadraticBezier.mjs +0 -131
- package/dist/mjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Rect2.d.ts +0 -57
- package/dist/mjs/math/shapes/Rect2.mjs +0 -309
- package/dist/mjs/math/shapes/Rect2.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/mjs/math/shapes/Triangle.mjs +0 -146
- package/dist/mjs/math/shapes/Triangle.test.d.ts +0 -1
- package/dist/mjs/toolbar/HTMLToolbar.d.ts +0 -105
- package/dist/mjs/toolbar/HTMLToolbar.mjs +0 -462
- package/dist/mjs/toolbar/makeColorInput.d.ts +0 -6
- package/src/Color4.test.ts +0 -47
- package/src/Color4.ts +0 -304
- package/src/Editor.css +0 -98
- package/src/math/Mat33.test.ts +0 -244
- package/src/math/Mat33.ts +0 -442
- package/src/math/Vec2.test.ts +0 -30
- package/src/math/Vec2.ts +0 -40
- 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/polynomial/solveQuadratic.test.ts +0 -39
- package/src/math/polynomial/solveQuadratic.ts +0 -43
- package/src/math/rounding.test.ts +0 -65
- package/src/math/rounding.ts +0 -156
- package/src/math/shapes/Abstract2DShape.ts +0 -63
- package/src/math/shapes/BezierJSWrapper.ts +0 -93
- package/src/math/shapes/CubicBezier.ts +0 -35
- package/src/math/shapes/LineSegment2.test.ts +0 -99
- package/src/math/shapes/LineSegment2.ts +0 -231
- package/src/math/shapes/Path.fromString.test.ts +0 -223
- package/src/math/shapes/Path.test.ts +0 -309
- package/src/math/shapes/Path.toString.test.ts +0 -77
- package/src/math/shapes/Path.ts +0 -1027
- package/src/math/shapes/PointShape2D.ts +0 -33
- package/src/math/shapes/QuadraticBezier.test.ts +0 -31
- package/src/math/shapes/QuadraticBezier.ts +0 -141
- package/src/math/shapes/Rect2.test.ts +0 -209
- package/src/math/shapes/Rect2.ts +0 -344
- package/src/math/shapes/Triangle.test.ts +0 -61
- package/src/math/shapes/Triangle.ts +0 -139
- package/src/toolbar/HTMLToolbar.ts +0 -567
- package/src/toolbar/widgets/InsertImageWidget.css +0 -44
- package/src/tools/tools.css +0 -4
- /package/dist/cjs/{Color4.test.d.ts → Editor.test.d.ts} +0 -0
- /package/dist/cjs/{math/Mat33.test.d.ts → toolbar/EdgeToolbar.test.d.ts} +0 -0
- /package/dist/cjs/{math/Vec2.test.d.ts → tools/FindTool.test.d.ts} +0 -0
- /package/dist/cjs/{math/Vec3.test.d.ts → tools/InputFilter/InputPipeline.test.d.ts} +0 -0
- /package/dist/cjs/{math/polynomial/solveQuadratic.test.d.ts → util/ReactiveValue.test.d.ts} +0 -0
- /package/dist/cjs/{math/rounding.test.d.ts → version.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/LineSegment2.test.d.ts → mjs/Editor.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Path.fromString.test.d.ts → mjs/toolbar/EdgeToolbar.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Path.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
- /package/dist/{cjs/math/shapes/Path.toString.test.d.ts → mjs/tools/FindTool.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/QuadraticBezier.test.d.ts → mjs/tools/InputFilter/InputPipeline.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Rect2.test.d.ts → mjs/util/ReactiveValue.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Triangle.test.d.ts → mjs/version.test.d.ts} +0 -0
@@ -1,13 +1,12 @@
|
|
1
|
-
import Color4 from '
|
2
|
-
import { ComponentBuilderFactory } from '../components/builders/types';
|
3
|
-
import { Vec2 } from '../math/Vec2';
|
1
|
+
import { Vec2, Color4 } from '@js-draw/math';
|
4
2
|
import SVGRenderer from '../rendering/renderers/SVGRenderer';
|
5
3
|
import TextRenderingStyle from '../rendering/TextRenderingStyle';
|
6
|
-
import
|
4
|
+
import { PenStyle } from '../tools/Pen';
|
7
5
|
import { StrokeDataPoint } from '../types';
|
8
6
|
import Viewport from '../Viewport';
|
7
|
+
import { makeFreehandLineBuilder } from '../components/builders/FreehandLineBuilder';
|
9
8
|
|
10
|
-
export type
|
9
|
+
export type IconElemType = HTMLImageElement|SVGElement;
|
11
10
|
|
12
11
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
13
12
|
const iconColorFill = `
|
@@ -28,9 +27,9 @@ const makeCheckerboardPattern = () => {
|
|
28
27
|
height='20%'
|
29
28
|
patternUnits='userSpaceOnUse'
|
30
29
|
>
|
31
|
-
<rect x=0 y=0 width=10 height=10 fill='white'/>
|
32
|
-
<rect x=0 y=0 width=5 height=5 fill='gray'/>
|
33
|
-
<rect x=5 y=5 width=5 height=5 fill='gray'/>
|
30
|
+
<rect x='0' y='0' width='10' height='10' fill='white'/>
|
31
|
+
<rect x='0' y='0' width='5' height='5' fill='gray'/>
|
32
|
+
<rect x='5' y='5' width='5' height='5' fill='gray'/>
|
34
33
|
</pattern>
|
35
34
|
`;
|
36
35
|
const patternRef = `url(#${id})`;
|
@@ -38,13 +37,38 @@ const makeCheckerboardPattern = () => {
|
|
38
37
|
return { patternDef, patternRef };
|
39
38
|
};
|
40
39
|
|
40
|
+
const makeRedoIcon = (mirror: boolean) => {
|
41
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
42
|
+
icon.innerHTML = `
|
43
|
+
<style>
|
44
|
+
.toolbar-svg-undo-redo-icon {
|
45
|
+
stroke: var(--icon-color);
|
46
|
+
stroke-width: 12;
|
47
|
+
stroke-linejoin: round;
|
48
|
+
stroke-linecap: round;
|
49
|
+
fill: none;
|
50
|
+
|
51
|
+
transform-origin: center;
|
52
|
+
}
|
53
|
+
</style>
|
54
|
+
<path
|
55
|
+
d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
|
56
|
+
class='toolbar-svg-undo-redo-icon'
|
57
|
+
style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
|
58
|
+
`;
|
59
|
+
icon.setAttribute('viewBox', '0 0 100 100');
|
60
|
+
return icon;
|
61
|
+
};
|
62
|
+
|
41
63
|
|
42
64
|
/**
|
43
65
|
* Provides icons that can be used in the toolbar, etc.
|
44
66
|
* Extend this class and override methods to customize icons.
|
45
67
|
*
|
46
68
|
* @example
|
47
|
-
* ```ts
|
69
|
+
* ```ts,runnable
|
70
|
+
* import * as jsdraw from 'js-draw';
|
71
|
+
*
|
48
72
|
* class CustomIconProvider extends jsdraw.IconProvider {
|
49
73
|
* // Use '☺' instead of the default dropdown symbol.
|
50
74
|
* public makeDropdownIcon() {
|
@@ -63,41 +87,21 @@ const makeCheckerboardPattern = () => {
|
|
63
87
|
* });
|
64
88
|
*
|
65
89
|
* // Add a toolbar that uses these icons
|
66
|
-
* editor.
|
90
|
+
* jsdraw.makeDropdownToolbar(editor).addDefaults();
|
67
91
|
* ```
|
68
92
|
*/
|
69
93
|
export default class IconProvider {
|
70
|
-
|
71
|
-
|
72
|
-
return this.makeRedoIcon(true);
|
94
|
+
public makeUndoIcon(): IconElemType {
|
95
|
+
return makeRedoIcon(true);
|
73
96
|
}
|
74
97
|
|
75
98
|
// @param mirror - reflect across the x-axis. This parameter is internal.
|
76
99
|
// @returns a redo icon.
|
77
|
-
public makeRedoIcon(
|
78
|
-
|
79
|
-
icon.innerHTML = `
|
80
|
-
<style>
|
81
|
-
.toolbar-svg-undo-redo-icon {
|
82
|
-
stroke: var(--icon-color);
|
83
|
-
stroke-width: 12;
|
84
|
-
stroke-linejoin: round;
|
85
|
-
stroke-linecap: round;
|
86
|
-
fill: none;
|
87
|
-
|
88
|
-
transform-origin: center;
|
89
|
-
}
|
90
|
-
</style>
|
91
|
-
<path
|
92
|
-
d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
|
93
|
-
class='toolbar-svg-undo-redo-icon'
|
94
|
-
style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
|
95
|
-
`;
|
96
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
97
|
-
return icon;
|
100
|
+
public makeRedoIcon(): IconElemType {
|
101
|
+
return makeRedoIcon(false);
|
98
102
|
}
|
99
103
|
|
100
|
-
public makeDropdownIcon():
|
104
|
+
public makeDropdownIcon(): IconElemType {
|
101
105
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
102
106
|
icon.innerHTML = `
|
103
107
|
<g>
|
@@ -107,11 +111,11 @@ export default class IconProvider {
|
|
107
111
|
/>
|
108
112
|
</g>
|
109
113
|
`;
|
110
|
-
icon.setAttribute('viewBox', '
|
114
|
+
icon.setAttribute('viewBox', '-10 -10 110 110');
|
111
115
|
return icon;
|
112
116
|
}
|
113
117
|
|
114
|
-
public makeEraserIcon(eraserSize?: number):
|
118
|
+
public makeEraserIcon(eraserSize?: number): IconElemType {
|
115
119
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
116
120
|
eraserSize ??= 10;
|
117
121
|
|
@@ -156,7 +160,7 @@ export default class IconProvider {
|
|
156
160
|
return icon;
|
157
161
|
}
|
158
162
|
|
159
|
-
public makeSelectionIcon():
|
163
|
+
public makeSelectionIcon(): IconElemType {
|
160
164
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
161
165
|
|
162
166
|
// Draw a cursor-like shape
|
@@ -171,29 +175,7 @@ export default class IconProvider {
|
|
171
175
|
return icon;
|
172
176
|
}
|
173
177
|
|
174
|
-
|
175
|
-
* @param pathData - SVG path data (e.g. `m10,10l30,30z`)
|
176
|
-
* @param fill - A valid CSS color (e.g. `var(--icon-color)` or `#f0f`). This can be `none`.
|
177
|
-
*/
|
178
|
-
protected makeIconFromPath(
|
179
|
-
pathData: string,
|
180
|
-
fill: string = 'var(--icon-color)',
|
181
|
-
strokeColor: string = 'none',
|
182
|
-
strokeWidth: string = '0px',
|
183
|
-
): IconType {
|
184
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
185
|
-
const path = document.createElementNS(svgNamespace, 'path');
|
186
|
-
path.setAttribute('d', pathData);
|
187
|
-
path.style.fill = fill;
|
188
|
-
path.style.stroke = strokeColor;
|
189
|
-
path.style.strokeWidth = strokeWidth;
|
190
|
-
icon.appendChild(path);
|
191
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
192
|
-
|
193
|
-
return icon;
|
194
|
-
}
|
195
|
-
|
196
|
-
public makeHandToolIcon(): IconType {
|
178
|
+
public makeHandToolIcon(): IconElemType {
|
197
179
|
const fill = 'none';
|
198
180
|
const strokeColor = 'var(--icon-color)';
|
199
181
|
const strokeWidth = '3';
|
@@ -222,7 +204,7 @@ export default class IconProvider {
|
|
222
204
|
`, fill, strokeColor, strokeWidth);
|
223
205
|
}
|
224
206
|
|
225
|
-
public makeTouchPanningIcon():
|
207
|
+
public makeTouchPanningIcon(): IconElemType {
|
226
208
|
const fill = 'none';
|
227
209
|
const strokeColor = 'var(--icon-color)';
|
228
210
|
const strokeWidth = '3';
|
@@ -256,7 +238,8 @@ export default class IconProvider {
|
|
256
238
|
`, fill, strokeColor, strokeWidth);
|
257
239
|
}
|
258
240
|
|
259
|
-
|
241
|
+
/** Unused by js-draw. @deprecated */
|
242
|
+
public makeAllDevicePanningIcon(): IconElemType {
|
260
243
|
const fill = 'none';
|
261
244
|
const strokeColor = 'var(--icon-color)';
|
262
245
|
const strokeWidth = '3';
|
@@ -312,7 +295,7 @@ export default class IconProvider {
|
|
312
295
|
`, fill, strokeColor, strokeWidth);
|
313
296
|
}
|
314
297
|
|
315
|
-
public makeZoomIcon():
|
298
|
+
public makeZoomIcon(): IconElemType {
|
316
299
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
317
300
|
icon.setAttribute('viewBox', '0 0 100 100');
|
318
301
|
|
@@ -336,7 +319,7 @@ export default class IconProvider {
|
|
336
319
|
return icon;
|
337
320
|
}
|
338
321
|
|
339
|
-
public makeRotationLockIcon():
|
322
|
+
public makeRotationLockIcon(): IconElemType {
|
340
323
|
const icon = this.makeIconFromPath(`
|
341
324
|
M 40.1 25.1
|
342
325
|
C 32.5 25 27.9 34.1 27.9 34.1
|
@@ -381,7 +364,7 @@ export default class IconProvider {
|
|
381
364
|
return icon;
|
382
365
|
}
|
383
366
|
|
384
|
-
public makeInsertImageIcon():
|
367
|
+
public makeInsertImageIcon(): IconElemType {
|
385
368
|
return this.makeIconFromPath(`
|
386
369
|
M 5 10 L 5 90 L 95 90 L 95 10 L 5 10 z
|
387
370
|
M 10 15 L 90 15 L 90 50 L 70 75 L 40 50 L 10 75 L 10 15 z
|
@@ -389,7 +372,17 @@ export default class IconProvider {
|
|
389
372
|
`);
|
390
373
|
}
|
391
374
|
|
392
|
-
public
|
375
|
+
public makeUploadFileIcon(): IconElemType {
|
376
|
+
return this.makeIconFromPath(`
|
377
|
+
M 48,10 32,34 43,33 42,68
|
378
|
+
H 54
|
379
|
+
L 53,33 64,34 Z
|
380
|
+
|
381
|
+
M 8,66 V 86 H 88 V 66 H 78 V 76 H 18 V 66 Z
|
382
|
+
`);
|
383
|
+
}
|
384
|
+
|
385
|
+
public makeTextIcon(textStyle: TextRenderingStyle): IconElemType {
|
393
386
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
394
387
|
icon.setAttribute('viewBox', '0 0 100 100');
|
395
388
|
|
@@ -405,17 +398,18 @@ export default class IconProvider {
|
|
405
398
|
textNode.setAttribute('x', '50');
|
406
399
|
textNode.setAttribute('y', '75');
|
407
400
|
textNode.style.fontSize = '65px';
|
408
|
-
textNode.style.filter = 'drop-shadow(0px 0px 10px var(--
|
401
|
+
textNode.style.filter = 'drop-shadow(0px 0px 10px var(--shadow-color))';
|
409
402
|
|
410
403
|
icon.appendChild(textNode);
|
411
404
|
|
412
405
|
return icon;
|
413
406
|
}
|
414
407
|
|
415
|
-
public makePenIcon(
|
416
|
-
|
417
|
-
|
418
|
-
|
408
|
+
public makePenIcon(penStyle: PenStyle): IconElemType {
|
409
|
+
// Use a square-root scale to prevent the pen's tip from overflowing.
|
410
|
+
const strokeSize = Math.round(Math.sqrt(penStyle.thickness) * 4);
|
411
|
+
const color = penStyle.color;
|
412
|
+
const rounded = this.isRoundedTipPen(penStyle);
|
419
413
|
|
420
414
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
421
415
|
icon.setAttribute('viewBox', '0 0 100 100');
|
@@ -456,7 +450,7 @@ export default class IconProvider {
|
|
456
450
|
|
457
451
|
const pencilTipColor = Color4.fromHex('#f4d7d7');
|
458
452
|
const tipColor = pencilTipColor.mix(
|
459
|
-
|
453
|
+
color, tipThickness / 40 - 0.1
|
460
454
|
).toHexString();
|
461
455
|
|
462
456
|
const checkerboardPattern = makeCheckerboardPattern();
|
@@ -533,32 +527,28 @@ export default class IconProvider {
|
|
533
527
|
}
|
534
528
|
|
535
529
|
public makeIconFromFactory(
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
// If true, attempts to guess the location of a transparency grid
|
540
|
-
includeTransparencyGrid: boolean = false
|
541
|
-
): IconType {
|
530
|
+
penStyle: PenStyle,
|
531
|
+
): IconElemType {
|
542
532
|
// Increase the thickness we use to generate the icon less with larger actual thicknesses.
|
543
533
|
// We want the icon to be recognisable with a large range of thicknesses.
|
544
|
-
const thickness = Math.sqrt(
|
534
|
+
const thickness = Math.sqrt(penStyle.thickness) * 3;
|
545
535
|
|
546
|
-
const nowTime =
|
536
|
+
const nowTime = performance.now();
|
547
537
|
const startPoint: StrokeDataPoint = {
|
548
538
|
pos: Vec2.of(10, 10),
|
549
539
|
width: thickness,
|
550
|
-
color:
|
540
|
+
color: penStyle.color,
|
551
541
|
time: nowTime - 100,
|
552
542
|
};
|
553
543
|
const endPoint: StrokeDataPoint = {
|
554
544
|
pos: Vec2.of(90, 90),
|
555
545
|
width: thickness,
|
556
|
-
color:
|
546
|
+
color: penStyle.color,
|
557
547
|
time: nowTime,
|
558
548
|
};
|
559
549
|
|
560
550
|
const viewport = new Viewport(() => {});
|
561
|
-
const builder = factory(startPoint, viewport);
|
551
|
+
const builder = penStyle.factory(startPoint, viewport);
|
562
552
|
builder.addPoint(endPoint);
|
563
553
|
|
564
554
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
@@ -567,6 +557,8 @@ export default class IconProvider {
|
|
567
557
|
|
568
558
|
let renderer;
|
569
559
|
|
560
|
+
// Any transparency? Include a checkerboard grid.
|
561
|
+
const includeTransparencyGrid = penStyle.color.a < 1;
|
570
562
|
if (includeTransparencyGrid) {
|
571
563
|
const checkerboardPattern = makeCheckerboardPattern();
|
572
564
|
|
@@ -590,16 +582,14 @@ export default class IconProvider {
|
|
590
582
|
const copy = addedPath.cloneNode(true) as SVGPathElement;
|
591
583
|
copy.style.zIndex = '-1';
|
592
584
|
|
593
|
-
// Make the
|
594
|
-
if (copy.hasAttribute('fill')
|
595
|
-
&& copy.getAttribute('fill') !== 'transparent'
|
596
|
-
&& copy.getAttribute('fill') !== 'none') {
|
597
|
-
copy.setAttribute('fill', checkerboardPattern.patternRef);
|
598
|
-
}
|
599
|
-
|
600
585
|
if (copy.hasAttribute('stroke')) {
|
601
586
|
copy.setAttribute('stroke', checkerboardPattern.patternRef);
|
602
587
|
}
|
588
|
+
// Note: Assumes that the component wouldn't normally be both stroked
|
589
|
+
// and filled.
|
590
|
+
else if (copy.hasAttribute('fill')) {
|
591
|
+
copy.setAttribute('fill', checkerboardPattern.patternRef);
|
592
|
+
}
|
603
593
|
|
604
594
|
background.appendChild(copy);
|
605
595
|
}
|
@@ -622,32 +612,41 @@ export default class IconProvider {
|
|
622
612
|
return icon;
|
623
613
|
}
|
624
614
|
|
625
|
-
public makePipetteIcon(color?: Color4):
|
615
|
+
public makePipetteIcon(color?: Color4): IconElemType {
|
626
616
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
617
|
+
|
618
|
+
const mainGroup = document.createElementNS(svgNamespace, 'g');
|
619
|
+
mainGroup.style.rotate = '45deg';
|
620
|
+
mainGroup.style.transformOrigin = 'center';
|
621
|
+
|
622
|
+
const pipette = document.createElementNS(svgNamespace, 'g');
|
623
|
+
pipette.innerHTML = `
|
624
|
+
<path
|
625
|
+
style="fill: var(--icon-color); stroke-linecap:round; stroke-linejoin:round;"
|
626
|
+
d="
|
627
|
+
m 32,12 v 68
|
628
|
+
c 0,1 0.5,2 1.33,2.5 1.67,1.15 3.67,2.1 5.17,3.2 1.4,1.1 2.3,2.1 2.5,3.1 0.6,2.1 1,4.6 1,6.2 0,3.7 5.45,4.1 6,0.4 l 0.9,-6.8
|
629
|
+
c 0.3,-0.9 1.1,-1.9 2.6,-2.9 1.5,-1.1 3.4,-2 5.1,-3.2
|
630
|
+
C 57.5,82 58,81 58,80
|
631
|
+
V 12 Z m 20,25 v 41.3
|
632
|
+
c 0,1.7 -2.5,1.6 -4,2.7 -1,0.76 -2.1,1.5 -3,2.6
|
633
|
+
C 44,82.5 43.02,81.75 42,81 40.51,79.92 38,80 38,78.34
|
634
|
+
V 51 Z
|
635
|
+
"
|
636
|
+
/>
|
637
|
+
<rect
|
638
|
+
style="fill: var(--icon-color);"
|
639
|
+
width="32"
|
640
|
+
height="9"
|
641
|
+
x="29"
|
642
|
+
y="2"
|
643
|
+
ry="4.5"
|
644
|
+
/>
|
645
|
+
<path
|
646
|
+
style="fill: var(--icon-color);"
|
647
|
+
d="m 45,-25 c -5.54,0 -11,4.26 -11,9 V 0 h 22 v -16 c 0,-4.74 -5.46,-9 -11,-9 z"
|
648
|
+
/>
|
649
|
+
`;
|
651
650
|
|
652
651
|
if (color) {
|
653
652
|
const checkerboardPattern = makeCheckerboardPattern();
|
@@ -660,7 +659,7 @@ export default class IconProvider {
|
|
660
659
|
const fluid = document.createElementNS(svgNamespace, 'path');
|
661
660
|
|
662
661
|
const fluidPathData = `
|
663
|
-
|
662
|
+
M 35,36 H 55 V 78.678012 83 L 45,87 35,83 Z
|
664
663
|
`;
|
665
664
|
|
666
665
|
fluid.setAttribute('d', fluidPathData);
|
@@ -669,16 +668,19 @@ export default class IconProvider {
|
|
669
668
|
fluid.style.fill = color.toHexString();
|
670
669
|
fluidBackground.style.fill = checkerboardPattern.patternRef;
|
671
670
|
|
672
|
-
|
673
|
-
|
671
|
+
mainGroup.appendChild(fluidBackground);
|
672
|
+
mainGroup.appendChild(fluid);
|
674
673
|
}
|
675
|
-
icon.appendChild(pipette);
|
676
674
|
|
677
|
-
|
675
|
+
mainGroup.appendChild(pipette);
|
676
|
+
icon.appendChild(mainGroup);
|
677
|
+
|
678
|
+
icon.setAttribute('viewBox', '5 -40 140 140');
|
678
679
|
return icon;
|
679
680
|
}
|
680
681
|
|
681
|
-
|
682
|
+
/** Unused. @deprecated */
|
683
|
+
public makeFormatSelectionIcon(): IconElemType {
|
682
684
|
return this.makeIconFromPath(`
|
683
685
|
M 5 10
|
684
686
|
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
|
@@ -689,7 +691,7 @@ export default class IconProvider {
|
|
689
691
|
`);
|
690
692
|
}
|
691
693
|
|
692
|
-
public
|
694
|
+
public makeResizeImageToSelectionIcon(): IconElemType {
|
693
695
|
return this.makeIconFromPath(`
|
694
696
|
M 75 5 75 10 90 10 90 25 95 25 95 5 75 5 z
|
695
697
|
M 15 15 15 30 20 30 20 20 30 20 30 15 15 15 z
|
@@ -702,14 +704,20 @@ export default class IconProvider {
|
|
702
704
|
`);
|
703
705
|
}
|
704
706
|
|
705
|
-
|
707
|
+
/** Renamed to {@link makeResizeImageToSelectionIcon} @deprecated */
|
708
|
+
public makeResizeViewportIcon(): IconElemType {
|
709
|
+
return this.makeResizeImageToSelectionIcon();
|
710
|
+
}
|
711
|
+
|
712
|
+
public makeDuplicateSelectionIcon(): IconElemType {
|
706
713
|
return this.makeIconFromPath(`
|
707
714
|
M 45,10 45,55 90,55 90,10 45,10 z
|
708
715
|
M 10,25 10,90 70,90 70,60 40,60 40,25 10,25 z
|
709
716
|
`);
|
710
717
|
}
|
711
718
|
|
712
|
-
|
719
|
+
/** Unused. @deprecated */
|
720
|
+
public makePasteIcon(): IconElemType {
|
713
721
|
const icon = this.makeIconFromPath(`
|
714
722
|
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
|
715
723
|
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
|
@@ -722,24 +730,32 @@ export default class IconProvider {
|
|
722
730
|
return icon;
|
723
731
|
}
|
724
732
|
|
725
|
-
|
726
|
-
const strokeWidth = '
|
733
|
+
#makeXIcon(): IconElemType {
|
734
|
+
const strokeWidth = '6px';
|
727
735
|
const strokeColor = 'var(--icon-color)';
|
728
736
|
const fillColor = 'none';
|
729
737
|
|
730
738
|
return this.makeIconFromPath(`
|
731
|
-
M
|
732
|
-
M
|
739
|
+
M 15,15 85,85
|
740
|
+
M 15,85 85,15
|
733
741
|
`, fillColor, strokeColor, strokeWidth);
|
734
742
|
}
|
735
743
|
|
736
|
-
public
|
744
|
+
public makeDeleteSelectionIcon(): IconElemType {
|
745
|
+
return this.#makeXIcon();
|
746
|
+
}
|
747
|
+
|
748
|
+
public makeCloseIcon(): IconElemType {
|
749
|
+
return this.#makeXIcon();
|
750
|
+
}
|
751
|
+
|
752
|
+
public makeSaveIcon(): IconElemType {
|
737
753
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
738
754
|
svg.innerHTML = `
|
739
755
|
<style>
|
740
756
|
.toolbar-save-icon {
|
741
757
|
stroke: var(--icon-color);
|
742
|
-
stroke-width:
|
758
|
+
stroke-width: 6;
|
743
759
|
stroke-linejoin: round;
|
744
760
|
stroke-linecap: round;
|
745
761
|
fill: none;
|
@@ -756,7 +772,7 @@ export default class IconProvider {
|
|
756
772
|
return svg;
|
757
773
|
}
|
758
774
|
|
759
|
-
public makeConfigureDocumentIcon():
|
775
|
+
public makeConfigureDocumentIcon(): IconElemType {
|
760
776
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
761
777
|
svg.innerHTML = `
|
762
778
|
<path
|
@@ -777,7 +793,7 @@ export default class IconProvider {
|
|
777
793
|
return svg;
|
778
794
|
}
|
779
795
|
|
780
|
-
public makeOverflowIcon():
|
796
|
+
public makeOverflowIcon(): IconElemType {
|
781
797
|
return this.makeIconFromPath(`
|
782
798
|
M 15 40
|
783
799
|
A 12.5 12.5 0 0 0 2.5 52.5
|
@@ -802,4 +818,44 @@ export default class IconProvider {
|
|
802
818
|
`);
|
803
819
|
}
|
804
820
|
|
821
|
+
/**
|
822
|
+
* @param pathData - SVG path data (e.g. `m10,10l30,30z`)
|
823
|
+
* @param fill - A valid CSS color (e.g. `var(--icon-color)` or `#f0f`). This can be `none`.
|
824
|
+
*/
|
825
|
+
protected makeIconFromPath(
|
826
|
+
pathData: string,
|
827
|
+
fill: string = 'var(--icon-color)',
|
828
|
+
strokeColor: string = 'none',
|
829
|
+
strokeWidth: string = '0px',
|
830
|
+
): IconElemType {
|
831
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
832
|
+
const path = document.createElementNS(svgNamespace, 'path');
|
833
|
+
path.setAttribute('d', pathData);
|
834
|
+
path.style.fill = fill;
|
835
|
+
path.style.stroke = strokeColor;
|
836
|
+
path.style.strokeWidth = strokeWidth;
|
837
|
+
icon.appendChild(path);
|
838
|
+
icon.setAttribute('viewBox', '0 0 100 100');
|
839
|
+
|
840
|
+
return icon;
|
841
|
+
}
|
842
|
+
|
843
|
+
/**
|
844
|
+
* @returns An object with both the definition of a checkerboard pattern and the syntax to
|
845
|
+
* reference that pattern. The defs provided by this function should be wrapped within a
|
846
|
+
* `<defs></defs>` element.
|
847
|
+
*/
|
848
|
+
protected makeCheckerboardPattern() {
|
849
|
+
return makeCheckerboardPattern();
|
850
|
+
}
|
851
|
+
|
852
|
+
/**
|
853
|
+
* @returns true if the given `penStyle` is known to match a rounded tip type of pen.
|
854
|
+
*/
|
855
|
+
protected isRoundedTipPen(penStyle: PenStyle) {
|
856
|
+
return penStyle.factory === makeFreehandLineBuilder;
|
857
|
+
}
|
858
|
+
|
859
|
+
/** Must be overridden by icon packs that need attribution. */
|
860
|
+
public licenseInfo(): string|null { return null; }
|
805
861
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export const toolbarCSSPrefix = 'toolbar-';
|
package/src/toolbar/lib.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
2
|
export * from './widgets/lib';
|
3
|
-
export * from './makeColorInput';
|
4
|
-
export { default as IconProvider } from './IconProvider';
|
3
|
+
export * from './widgets/components/makeColorInput';
|
4
|
+
export { default as IconProvider, IconElemType } from './IconProvider';
|
5
|
+
export { makeDropdownToolbar } from './DropdownToolbar';
|
6
|
+
export { makeEdgeToolbar } from './EdgeToolbar';
|