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
@@ -0,0 +1,62 @@
|
|
1
|
+
import { toRoundedString } from '@js-draw/math';
|
2
|
+
import { toolbarCSSPrefix } from '../../constants';
|
3
|
+
import { ToolbarContext } from '../../types';
|
4
|
+
|
5
|
+
let idCounter = 0;
|
6
|
+
|
7
|
+
const makeThicknessSlider = (
|
8
|
+
context: ToolbarContext,
|
9
|
+
onChange: (value: number)=>void
|
10
|
+
) => {
|
11
|
+
const container = document.createElement('div');
|
12
|
+
|
13
|
+
const thicknessLabel = document.createElement('label');
|
14
|
+
const thicknessInput = document.createElement('input');
|
15
|
+
|
16
|
+
container.classList.add(`${toolbarCSSPrefix}thicknessSliderContainer`);
|
17
|
+
|
18
|
+
// Give inputs IDs so we can label them with a <label for=...>Label text</label>
|
19
|
+
thicknessInput.id = `${toolbarCSSPrefix}thicknessInput${idCounter++}`;
|
20
|
+
|
21
|
+
thicknessLabel.innerText = context.localization.thicknessLabel;
|
22
|
+
thicknessLabel.setAttribute('for', thicknessInput.id);
|
23
|
+
|
24
|
+
// Use a logarithmic scale for thicknessInput (finer control over thinner strokewidths.)
|
25
|
+
const inverseThicknessInputFn = (t: number) => Math.log10(t);
|
26
|
+
const thicknessInputFn = (t: number) => 10**t;
|
27
|
+
|
28
|
+
thicknessInput.type = 'range';
|
29
|
+
thicknessInput.oninput = () => {
|
30
|
+
onChange(thicknessInputFn(parseFloat(thicknessInput.value)));
|
31
|
+
};
|
32
|
+
container.appendChild(thicknessLabel);
|
33
|
+
container.appendChild(thicknessInput);
|
34
|
+
|
35
|
+
const setBounds = (min: number, max: number) => {
|
36
|
+
const round = (value: number, roundUp: boolean) => {
|
37
|
+
const roundFn = roundUp ? Math.ceil : Math.floor;
|
38
|
+
return roundFn(value * 100) / 100;
|
39
|
+
};
|
40
|
+
const sliderMin = round(inverseThicknessInputFn(min), false);
|
41
|
+
const sliderMax = round(inverseThicknessInputFn(max), true);
|
42
|
+
|
43
|
+
thicknessInput.min = `${sliderMin}`;
|
44
|
+
thicknessInput.max = `${sliderMax}`;
|
45
|
+
thicknessInput.step = `${toRoundedString((sliderMax - sliderMin) / 20)}`;
|
46
|
+
};
|
47
|
+
|
48
|
+
setBounds(2, 262);
|
49
|
+
|
50
|
+
return {
|
51
|
+
container,
|
52
|
+
addTo: (parent: HTMLElement) => {
|
53
|
+
parent.appendChild(container);
|
54
|
+
},
|
55
|
+
setBounds,
|
56
|
+
setValue: (thickness: number) => {
|
57
|
+
thicknessInput.value = inverseThicknessInputFn(thickness).toString();
|
58
|
+
},
|
59
|
+
};
|
60
|
+
};
|
61
|
+
|
62
|
+
export default makeThicknessSlider;
|
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
import KeyboardShortcutManager from '../../shortcuts/KeyboardShortcutManager';
|
4
2
|
|
5
3
|
// Selection
|
@@ -16,6 +14,6 @@ export const selectStrokeTypeKeyboardShortcutIds: string[] =
|
|
16
14
|
for (let i = 0; i < selectStrokeTypeKeyboardShortcutIds.length; i++) {
|
17
15
|
const id = selectStrokeTypeKeyboardShortcutIds[i];
|
18
16
|
KeyboardShortcutManager.registerDefaultKeyboardShortcut(
|
19
|
-
id, [ `
|
17
|
+
id, [ `CtrlOrMeta+Digit${(i + 1)}` ], 'Select pen style ' + (i + 1),
|
20
18
|
);
|
21
19
|
}
|
@@ -0,0 +1,262 @@
|
|
1
|
+
import { EditorEventType, EditorNotifier } from '../../../types';
|
2
|
+
import EventDispatcher, { DispatcherEventListener } from '../../../EventDispatcher';
|
3
|
+
import { ToolbarLocalization } from '../../localization';
|
4
|
+
import { ToolMenu, WidgetContentLayoutManager, ToolMenuParent } from './types';
|
5
|
+
import { toolbarCSSPrefix } from '../../constants';
|
6
|
+
import { MutableReactiveValue, ReactiveValue } from '../../../util/ReactiveValue';
|
7
|
+
|
8
|
+
enum DropdownEventType {
|
9
|
+
DropdownShown,
|
10
|
+
DropdownHidden,
|
11
|
+
}
|
12
|
+
|
13
|
+
interface DropdownShownEvent {
|
14
|
+
// If undefined, the event is forwarded from a different layout manager
|
15
|
+
dropdown?: Dropdown;
|
16
|
+
|
17
|
+
fromToplevelDropdown: boolean;
|
18
|
+
}
|
19
|
+
|
20
|
+
type NotifierType = EventDispatcher<DropdownEventType, DropdownShownEvent>;
|
21
|
+
|
22
|
+
class Dropdown implements ToolMenu {
|
23
|
+
private dropdownContainer: HTMLElement;
|
24
|
+
public readonly visible: MutableReactiveValue<boolean>;
|
25
|
+
|
26
|
+
private dropdownToggleListener: DispatcherEventListener|null = null;
|
27
|
+
|
28
|
+
public constructor(
|
29
|
+
public parent: ToolMenuParent,
|
30
|
+
private notifier: NotifierType,
|
31
|
+
private onDestroy: ()=>void,
|
32
|
+
) {
|
33
|
+
this.visible = ReactiveValue.fromInitialValue(false);
|
34
|
+
|
35
|
+
this.dropdownContainer = document.createElement('div');
|
36
|
+
this.dropdownContainer.classList.add(`${toolbarCSSPrefix}dropdown`);
|
37
|
+
this.dropdownContainer.classList.add('hidden');
|
38
|
+
|
39
|
+
parent.target.insertAdjacentElement('afterend', this.dropdownContainer);
|
40
|
+
|
41
|
+
// When another dropdown is shown,
|
42
|
+
this.dropdownToggleListener = this.notifier.on(DropdownEventType.DropdownShown, (evt) => {
|
43
|
+
if (
|
44
|
+
evt.dropdown !== this &&
|
45
|
+
|
46
|
+
// Don't hide if a submenu was shown (it might be a submenu of
|
47
|
+
// the current menu).
|
48
|
+
evt.fromToplevelDropdown
|
49
|
+
) {
|
50
|
+
this.setVisible(false);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
public onActivated(): void {
|
56
|
+
// Do nothing.
|
57
|
+
}
|
58
|
+
|
59
|
+
protected repositionDropdown() {
|
60
|
+
const dropdownBBox = this.dropdownContainer.getBoundingClientRect();
|
61
|
+
const screenWidth = document.scrollingElement?.clientWidth ?? document.body.clientHeight;
|
62
|
+
const screenHeight = document.scrollingElement?.clientHeight ?? document.body.clientHeight;
|
63
|
+
|
64
|
+
let translateX = undefined;
|
65
|
+
let translateY = undefined;
|
66
|
+
|
67
|
+
if (dropdownBBox.left > screenWidth / 2) {
|
68
|
+
const targetElem = this.parent.target;
|
69
|
+
translateX = `calc(${targetElem.clientWidth + 'px'} - 100%)`;
|
70
|
+
}
|
71
|
+
|
72
|
+
// Shift the dropdown if it's off the screen, but only if doing so moves it on to the screen
|
73
|
+
// (prevents dropdowns from going almost completely offscreen on small screens).
|
74
|
+
if (dropdownBBox.bottom > screenHeight && (dropdownBBox.top - dropdownBBox.height > 0)) {
|
75
|
+
const targetElem = this.parent.target;
|
76
|
+
translateY = `calc(-${targetElem.clientHeight}px - 100%)`;
|
77
|
+
}
|
78
|
+
|
79
|
+
// Use .translate so as not to conflict with CSS animating the
|
80
|
+
// transform property.
|
81
|
+
if (translateX || translateY) {
|
82
|
+
this.dropdownContainer.style.translate = `${translateX ?? '0'} ${translateY ?? '0'}`;
|
83
|
+
} else {
|
84
|
+
this.dropdownContainer.style.translate = '';
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
private hideDropdownTimeout: any|null = null;
|
89
|
+
private setVisible(visible: boolean) {
|
90
|
+
const currentlyVisible = this.visible.get();
|
91
|
+
if (currentlyVisible === visible) {
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
|
95
|
+
// If waiting to hide the dropdown, cancel it.
|
96
|
+
if (this.hideDropdownTimeout) {
|
97
|
+
clearTimeout(this.hideDropdownTimeout);
|
98
|
+
this.hideDropdownTimeout = null;
|
99
|
+
this.dropdownContainer.classList.remove('hiding');
|
100
|
+
this.repositionDropdown();
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
const animationDuration = 150; // ms
|
105
|
+
|
106
|
+
this.visible.set(visible);
|
107
|
+
if (visible) {
|
108
|
+
this.dropdownContainer.classList.remove('hidden');
|
109
|
+
|
110
|
+
this.notifier.dispatch(DropdownEventType.DropdownShown, {
|
111
|
+
dropdown: this,
|
112
|
+
fromToplevelDropdown: this.parent.isToplevel(),
|
113
|
+
});
|
114
|
+
|
115
|
+
this.repositionDropdown();
|
116
|
+
} else {
|
117
|
+
this.notifier.dispatch(DropdownEventType.DropdownHidden, {
|
118
|
+
dropdown: this,
|
119
|
+
fromToplevelDropdown: this.parent.isToplevel(),
|
120
|
+
});
|
121
|
+
|
122
|
+
this.dropdownContainer.classList.add('hiding');
|
123
|
+
|
124
|
+
// Hide the dropdown *slightly* before the animation finishes. This
|
125
|
+
// prevents flickering in some browsers.
|
126
|
+
const hideDelay = animationDuration * 0.95;
|
127
|
+
|
128
|
+
this.hideDropdownTimeout = setTimeout(() => {
|
129
|
+
this.dropdownContainer.classList.add('hidden');
|
130
|
+
this.dropdownContainer.classList.remove('hiding');
|
131
|
+
this.repositionDropdown();
|
132
|
+
}, hideDelay);
|
133
|
+
}
|
134
|
+
|
135
|
+
// Animate
|
136
|
+
const animationName = `var(--dropdown-${
|
137
|
+
visible ? 'show' : 'hide'
|
138
|
+
}-animation)`;
|
139
|
+
this.dropdownContainer.style.animation = `${animationDuration}ms ease ${animationName}`;
|
140
|
+
}
|
141
|
+
|
142
|
+
public requestShow(): void {
|
143
|
+
this.setVisible(true);
|
144
|
+
}
|
145
|
+
|
146
|
+
public requestHide(): void {
|
147
|
+
this.setVisible(false);
|
148
|
+
}
|
149
|
+
|
150
|
+
public appendChild(item: HTMLElement): void {
|
151
|
+
this.dropdownContainer.appendChild(item);
|
152
|
+
}
|
153
|
+
|
154
|
+
public clearChildren(): void {
|
155
|
+
this.dropdownContainer.replaceChildren();
|
156
|
+
}
|
157
|
+
|
158
|
+
public destroy(): void {
|
159
|
+
this.setVisible(false);
|
160
|
+
this.dropdownContainer.remove();
|
161
|
+
this.dropdownToggleListener?.remove();
|
162
|
+
|
163
|
+
// Allow children to be added to other parents
|
164
|
+
this.clearChildren();
|
165
|
+
this.onDestroy();
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
export default class DropdownLayoutManager implements WidgetContentLayoutManager {
|
170
|
+
private notifier: NotifierType;
|
171
|
+
private dropdowns: Set<Dropdown> = new Set();
|
172
|
+
|
173
|
+
public constructor(
|
174
|
+
announceForAccessibility: (text: string)=>void,
|
175
|
+
private localization: ToolbarLocalization,
|
176
|
+
) {
|
177
|
+
this.notifier = new EventDispatcher();
|
178
|
+
this.notifier.on(DropdownEventType.DropdownShown, ({ dropdown, fromToplevelDropdown }) => {
|
179
|
+
if (!dropdown) return;
|
180
|
+
|
181
|
+
announceForAccessibility(
|
182
|
+
this.localization.dropdownShown(dropdown.parent.getTitle())
|
183
|
+
);
|
184
|
+
|
185
|
+
// Share the event with other connected notifiers
|
186
|
+
this.connectedNotifiers.forEach(notifier => {
|
187
|
+
notifier.dispatch(EditorEventType.ToolbarDropdownShown, {
|
188
|
+
kind: EditorEventType.ToolbarDropdownShown,
|
189
|
+
fromToplevelDropdown,
|
190
|
+
layoutManager: this,
|
191
|
+
});
|
192
|
+
});
|
193
|
+
});
|
194
|
+
|
195
|
+
this.notifier.on(DropdownEventType.DropdownHidden, ({ dropdown }) => {
|
196
|
+
if (!dropdown) return;
|
197
|
+
|
198
|
+
announceForAccessibility(
|
199
|
+
this.localization.dropdownHidden(dropdown.parent.getTitle())
|
200
|
+
);
|
201
|
+
});
|
202
|
+
}
|
203
|
+
|
204
|
+
private listeners: DispatcherEventListener[] = [];
|
205
|
+
private connectedNotifiers: EditorNotifier[] = [];
|
206
|
+
public connectToEditorNotifier(notifier: EditorNotifier) {
|
207
|
+
this.connectedNotifiers.push(notifier);
|
208
|
+
this.refreshListeners();
|
209
|
+
}
|
210
|
+
|
211
|
+
/** Creates a dropdown within `parent`. */
|
212
|
+
public createToolMenu(parent: ToolMenuParent): ToolMenu {
|
213
|
+
const dropdown = new Dropdown(
|
214
|
+
parent,
|
215
|
+
this.notifier,
|
216
|
+
() => {
|
217
|
+
this.dropdowns.delete(dropdown);
|
218
|
+
|
219
|
+
this.refreshListeners();
|
220
|
+
}
|
221
|
+
);
|
222
|
+
this.dropdowns.add(dropdown);
|
223
|
+
this.refreshListeners();
|
224
|
+
|
225
|
+
return dropdown;
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Adds/removes listeners based on whether we have any managed dropdowns.
|
230
|
+
*
|
231
|
+
* We attempt to clean up all resources when `dropdowns.size == 0`, at which
|
232
|
+
* point, an instance of this could be safely garbage collected.
|
233
|
+
*/
|
234
|
+
private refreshListeners() {
|
235
|
+
const clearListeners = () => {
|
236
|
+
// Remove all listeners & resources that won't be garbage collected.
|
237
|
+
this.listeners.forEach(l => l.remove());
|
238
|
+
this.listeners = [];
|
239
|
+
};
|
240
|
+
|
241
|
+
if (this.dropdowns.size === 0) {
|
242
|
+
clearListeners();
|
243
|
+
} else if (this.listeners.length !== this.connectedNotifiers.length) {
|
244
|
+
clearListeners();
|
245
|
+
|
246
|
+
this.listeners = this.connectedNotifiers.map(notifier => {
|
247
|
+
return notifier.on(EditorEventType.ToolbarDropdownShown, (evt) => {
|
248
|
+
if (evt.kind !== EditorEventType.ToolbarDropdownShown
|
249
|
+
|
250
|
+
// Don't forward to ourselves events that we originally triggered.
|
251
|
+
|| evt.layoutManager === this) {
|
252
|
+
return;
|
253
|
+
}
|
254
|
+
|
255
|
+
this.notifier.dispatch(DropdownEventType.DropdownShown, {
|
256
|
+
fromToplevelDropdown: evt.fromToplevelDropdown,
|
257
|
+
});
|
258
|
+
});
|
259
|
+
});
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { MutableReactiveValue, ReactiveValue } from '../../../util/ReactiveValue';
|
2
|
+
import { ToolbarLocalization } from '../../localization';
|
3
|
+
import { ToolMenu, WidgetContentLayoutManager, ToolMenuParent } from './types';
|
4
|
+
|
5
|
+
export default class EdgeToolbarLayoutManager implements WidgetContentLayoutManager {
|
6
|
+
private visibleWidgetContent: MutableReactiveValue<ToolMenu|null> = ReactiveValue.fromInitialValue(null);
|
7
|
+
|
8
|
+
// @internal
|
9
|
+
public constructor(
|
10
|
+
private setSidebarContent: (...content: HTMLElement[])=>void,
|
11
|
+
private sidebarTitle: MutableReactiveValue<string>,
|
12
|
+
private sidebarVisibility: MutableReactiveValue<boolean>,
|
13
|
+
private announceForAccessibility: (text: string)=>void,
|
14
|
+
private localization: ToolbarLocalization,
|
15
|
+
) {
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
/** Creates a dropdown within `parent`. */
|
20
|
+
public createToolMenu(parent: ToolMenuParent): ToolMenu {
|
21
|
+
const contentElem = document.createElement('div');
|
22
|
+
let result: ToolMenu|null = null;
|
23
|
+
|
24
|
+
const visible = ReactiveValue.fromCallback(() => {
|
25
|
+
return this.visibleWidgetContent.get() === result && this.sidebarVisibility.get();
|
26
|
+
}, [ this.visibleWidgetContent, this.sidebarVisibility ]);
|
27
|
+
|
28
|
+
result = {
|
29
|
+
visible,
|
30
|
+
requestShow: () => {
|
31
|
+
this.setSidebarContent(contentElem);
|
32
|
+
this.sidebarTitle.set(parent.getTitle());
|
33
|
+
|
34
|
+
// Set visibleWidgetContent first -- this causes the previously visible (if any)
|
35
|
+
// item to not be sent a shown event.
|
36
|
+
this.visibleWidgetContent.set(result);
|
37
|
+
this.sidebarVisibility.set(true);
|
38
|
+
|
39
|
+
this.announceForAccessibility(this.localization.dropdownShown(parent.getTitle()));
|
40
|
+
},
|
41
|
+
onActivated: () => {
|
42
|
+
// TODO: Only request show when in sidebar mode
|
43
|
+
//result?.requestShow();
|
44
|
+
},
|
45
|
+
requestHide: () => {
|
46
|
+
if (visible.get()) {
|
47
|
+
this.sidebarVisibility.set(false);
|
48
|
+
}
|
49
|
+
},
|
50
|
+
appendChild: (item: HTMLElement) => {
|
51
|
+
contentElem.appendChild(item);
|
52
|
+
},
|
53
|
+
clearChildren: () => {
|
54
|
+
contentElem.replaceChildren();
|
55
|
+
},
|
56
|
+
destroy: () => {
|
57
|
+
result?.requestHide();
|
58
|
+
|
59
|
+
if (contentElem.parentElement) {
|
60
|
+
contentElem.remove();
|
61
|
+
}
|
62
|
+
|
63
|
+
if (this.visibleWidgetContent.get() === result) {
|
64
|
+
this.visibleWidgetContent.set(null);
|
65
|
+
}
|
66
|
+
},
|
67
|
+
};
|
68
|
+
|
69
|
+
return result;
|
70
|
+
}
|
71
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import ReactiveValue from 'js-draw/src/util/ReactiveValue';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* A class that manages whether/what content is shown for a widget.
|
5
|
+
*
|
6
|
+
* This might be a dropdown menu or a sidebar.
|
7
|
+
*
|
8
|
+
* TODO: Shouldn't be an interface, unless always internal.
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
export interface ToolMenu {
|
12
|
+
/**
|
13
|
+
* Request that the layout manager show the dropdown. In general,
|
14
|
+
* this makes the content of the dropdown visible.
|
15
|
+
*/
|
16
|
+
requestShow(): void;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Request that the layout manager hide the dropdown. Even after calling this,
|
20
|
+
* the dropdown may still be visible.
|
21
|
+
*/
|
22
|
+
requestHide(): void;
|
23
|
+
|
24
|
+
/** Whether the dropdown is visible (not hidden). */
|
25
|
+
readonly visible: ReactiveValue<boolean>;
|
26
|
+
|
27
|
+
/** Note that the tool associated with this dropdown has been activated. */
|
28
|
+
onActivated(): void;
|
29
|
+
|
30
|
+
/** Adds the given `child` to the content of the dropdown. */
|
31
|
+
appendChild(child: HTMLElement): void;
|
32
|
+
|
33
|
+
/** Removes all children from this dropdown. */
|
34
|
+
clearChildren(): void;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Destroy the dropdown and remove it from the document. This should be called when
|
38
|
+
* the creator of the dropdown is destroyed.
|
39
|
+
*/
|
40
|
+
destroy(): void;
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Provides information about the element a tool menu is attached to.
|
45
|
+
*/
|
46
|
+
export interface ToolMenuParent {
|
47
|
+
/** The dropdown may be added **after** this element. */
|
48
|
+
target: HTMLElement;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @returns the title of the element the dropdown is associated with.
|
52
|
+
*
|
53
|
+
* This is used for accessibility announcements (and possibly to display
|
54
|
+
* a heading).
|
55
|
+
*/
|
56
|
+
getTitle(): string;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns true iff the parent is a toplevel element (not contained within
|
60
|
+
* a ContentLayoutManager of the same type as the current).
|
61
|
+
*/
|
62
|
+
isToplevel(): boolean;
|
63
|
+
}
|
64
|
+
|
65
|
+
export interface WidgetContentLayoutManager {
|
66
|
+
/**
|
67
|
+
* Creates a tool menu (e.g. a dropdown). The dropdown *may* be added to `parent` or addded
|
68
|
+
* elsewhere (this depends on the layout manager).
|
69
|
+
*
|
70
|
+
* Regardless, `parent` should be a place where an absolutely-positioned dropdown
|
71
|
+
* element could be added.
|
72
|
+
*/
|
73
|
+
createToolMenu(parent: ToolMenuParent): ToolMenu;
|
74
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
export { default as ActionButtonWidget } from './ActionButtonWidget';
|
3
3
|
export { default as BaseToolWidget } from './BaseToolWidget';
|
4
|
-
export { default as BaseWidget } from './BaseWidget';
|
4
|
+
export { default as BaseWidget, ToolbarWidgetTag } from './BaseWidget';
|
5
5
|
|
6
6
|
export { default as PenToolWidget } from './PenToolWidget';
|
7
7
|
export { default as TextToolWidget } from './TextToolWidget';
|
@@ -10,4 +10,4 @@ export { default as SelectionToolWidget } from './SelectionToolWidget';
|
|
10
10
|
export { default as EraserToolWidget } from './EraserToolWidget';
|
11
11
|
|
12
12
|
export { default as InsertImageWidget } from './InsertImageWidget';
|
13
|
-
export { default as DocumentPropertiesWidget } from './DocumentPropertiesWidget';
|
13
|
+
export { default as DocumentPropertiesWidget } from './DocumentPropertiesWidget';
|
package/src/tools/BaseTool.ts
CHANGED
@@ -1,16 +1,89 @@
|
|
1
|
-
import {
|
1
|
+
import { EditorNotifier, EditorEventType } from '../types';
|
2
|
+
import { WheelEvt, PointerEvt, KeyPressEvent, KeyUpEvent, PasteEvent, CopyEvent, InputEvt, InputEvtType, GestureCancelEvt, PointerDownEvt, PointerMoveEvt, PointerUpEvt } from '../inputEvents';
|
2
3
|
import ToolEnabledGroup from './ToolEnabledGroup';
|
4
|
+
import InputMapper, { InputEventListener } from './InputFilter/InputMapper';
|
5
|
+
import { MutableReactiveValue, ReactiveValue } from '../util/ReactiveValue';
|
3
6
|
|
4
|
-
export default abstract class BaseTool implements
|
5
|
-
|
6
|
-
|
7
|
+
export default abstract class BaseTool implements InputEventListener {
|
8
|
+
#enabled: MutableReactiveValue<boolean>;
|
9
|
+
#group: ToolEnabledGroup|null = null;
|
10
|
+
|
11
|
+
#inputMapper: InputMapper|null = null;
|
12
|
+
|
13
|
+
protected constructor(private notifier: EditorNotifier, public readonly description: string) {
|
14
|
+
this.#enabled = ReactiveValue.fromInitialValue(true);
|
15
|
+
this.#enabled.onUpdate(enabled => {
|
16
|
+
// Ensure that at most one tool in the group is enabled.
|
17
|
+
if (enabled) {
|
18
|
+
this.#group?.notifyEnabled(this);
|
19
|
+
this.notifier.dispatch(EditorEventType.ToolEnabled, {
|
20
|
+
kind: EditorEventType.ToolEnabled,
|
21
|
+
tool: this,
|
22
|
+
});
|
23
|
+
} else {
|
24
|
+
this.notifier.dispatch(EditorEventType.ToolDisabled, {
|
25
|
+
kind: EditorEventType.ToolDisabled,
|
26
|
+
tool: this,
|
27
|
+
});
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
public setInputMapper(mapper: InputMapper|null) {
|
33
|
+
this.#inputMapper = mapper;
|
34
|
+
if (mapper) {
|
35
|
+
mapper.setEmitListener(event => this.dispatchEventToCallback(event));
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
public getInputMapper() {
|
40
|
+
return this.#inputMapper;
|
41
|
+
}
|
42
|
+
|
43
|
+
private dispatchEventToCallback(event: InputEvt) {
|
44
|
+
let exhaustivenessCheck: never;
|
45
|
+
switch (event.kind) {
|
46
|
+
case InputEvtType.PointerDownEvt:
|
47
|
+
return this.onPointerDown(event);
|
48
|
+
case InputEvtType.PointerMoveEvt:
|
49
|
+
this.onPointerMove(event);
|
50
|
+
break;
|
51
|
+
case InputEvtType.PointerUpEvt:
|
52
|
+
return this.onPointerUp(event) ?? false;
|
53
|
+
case InputEvtType.GestureCancelEvt:
|
54
|
+
this.onGestureCancel(event);
|
55
|
+
break;
|
56
|
+
case InputEvtType.WheelEvt:
|
57
|
+
return this.onWheel(event);
|
58
|
+
case InputEvtType.KeyPressEvent:
|
59
|
+
return this.onKeyPress(event);
|
60
|
+
case InputEvtType.KeyUpEvent:
|
61
|
+
return this.onKeyUp(event);
|
62
|
+
case InputEvtType.CopyEvent:
|
63
|
+
return this.onCopy(event);
|
64
|
+
case InputEvtType.PasteEvent:
|
65
|
+
return this.onPaste(event);
|
66
|
+
default:
|
67
|
+
exhaustivenessCheck = event;
|
68
|
+
return exhaustivenessCheck;
|
69
|
+
}
|
70
|
+
return true;
|
71
|
+
}
|
72
|
+
|
73
|
+
// @internal
|
74
|
+
public onEvent(event: InputEvt): boolean {
|
75
|
+
if (this.#inputMapper) {
|
76
|
+
return this.#inputMapper.onEvent(event);
|
77
|
+
}
|
78
|
+
return this.dispatchEventToCallback(event);
|
79
|
+
}
|
7
80
|
|
8
81
|
/**
|
9
82
|
* Returns true iff the tool handled the event and thus should receive additional
|
10
83
|
* events.
|
11
84
|
*/
|
12
|
-
public onPointerDown(_event:
|
13
|
-
public onPointerMove(_event:
|
85
|
+
public onPointerDown(_event: PointerDownEvt): boolean { return false; }
|
86
|
+
public onPointerMove(_event: PointerMoveEvt) { }
|
14
87
|
|
15
88
|
/**
|
16
89
|
* Returns true iff there are additional pointers down and the tool should
|
@@ -18,12 +91,9 @@ export default abstract class BaseTool implements PointerEvtListener {
|
|
18
91
|
*
|
19
92
|
* For most purposes, this should return `false` or nothing.
|
20
93
|
*/
|
21
|
-
public onPointerUp(_event:
|
94
|
+
public onPointerUp(_event: PointerUpEvt): boolean|void { }
|
22
95
|
|
23
|
-
public onGestureCancel() { }
|
24
|
-
|
25
|
-
protected constructor(private notifier: EditorNotifier, public readonly description: string) {
|
26
|
-
}
|
96
|
+
public onGestureCancel(_event: GestureCancelEvt) { }
|
27
97
|
|
28
98
|
public onWheel(_event: WheelEvt): boolean {
|
29
99
|
return false;
|
@@ -55,25 +125,27 @@ export default abstract class BaseTool implements PointerEvtListener {
|
|
55
125
|
}
|
56
126
|
|
57
127
|
public setEnabled(enabled: boolean) {
|
58
|
-
this.enabled
|
59
|
-
|
60
|
-
// Ensure that at most one tool in the group is enabled.
|
61
|
-
if (enabled) {
|
62
|
-
this.group?.notifyEnabled(this);
|
63
|
-
this.notifier.dispatch(EditorEventType.ToolEnabled, {
|
64
|
-
kind: EditorEventType.ToolEnabled,
|
65
|
-
tool: this,
|
66
|
-
});
|
67
|
-
} else {
|
68
|
-
this.notifier.dispatch(EditorEventType.ToolDisabled, {
|
69
|
-
kind: EditorEventType.ToolDisabled,
|
70
|
-
tool: this,
|
71
|
-
});
|
72
|
-
}
|
128
|
+
this.#enabled.set(enabled);
|
73
129
|
}
|
74
130
|
|
75
131
|
public isEnabled(): boolean {
|
76
|
-
return this.
|
132
|
+
return this.#enabled.get();
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Returns a {@link ReactiveValue} that updates based on whether this tool is
|
137
|
+
* enabled.
|
138
|
+
*
|
139
|
+
* @example
|
140
|
+
* ```ts
|
141
|
+
* const tool = new SomeTool();
|
142
|
+
*
|
143
|
+
* // Watch for changes in enabled status
|
144
|
+
* tool.enabledValue().onUpdate(enabled => doSomething(enabled));
|
145
|
+
* ```
|
146
|
+
*/
|
147
|
+
public enabledValue(): ReactiveValue<boolean> {
|
148
|
+
return this.#enabled;
|
77
149
|
}
|
78
150
|
|
79
151
|
// Connect this tool to a set of other tools, ensuring that at most one
|
@@ -83,12 +155,12 @@ export default abstract class BaseTool implements PointerEvtListener {
|
|
83
155
|
group.notifyEnabled(this);
|
84
156
|
}
|
85
157
|
|
86
|
-
this
|
158
|
+
this.#group = group;
|
87
159
|
}
|
88
160
|
|
89
161
|
public getToolGroup(): ToolEnabledGroup|null {
|
90
|
-
if (this
|
91
|
-
return this
|
162
|
+
if (this.#group) {
|
163
|
+
return this.#group;
|
92
164
|
}
|
93
165
|
|
94
166
|
return null;
|
package/src/tools/Eraser.test.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import UnknownSVGObject from '../components/UnknownSVGObject';
|
2
2
|
import Editor from '../Editor';
|
3
3
|
import { EditorImage, Rect2, StrokeComponent } from '../lib';
|
4
|
-
import { Vec2 } from '
|
4
|
+
import { Vec2 } from '@js-draw/math';
|
5
5
|
import createEditor from '../testing/createEditor';
|
6
6
|
import sendPenEvent from '../testing/sendPenEvent';
|
7
|
-
import { InputEvtType } from '../
|
7
|
+
import { InputEvtType } from '../inputEvents';
|
8
8
|
import Eraser from './Eraser';
|
9
9
|
|
10
10
|
const selectEraser = (editor: Editor) => {
|