js-draw 0.25.0 → 1.0.0
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 +60 -20
- 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 +44 -45
- 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 +43 -45
- 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/package.json +11 -22
- package/src/Coloris.css +8 -8
- package/src/Editor.scss +148 -0
- package/src/dialogs/dialogs.scss +36 -0
- package/src/dialogs/makeAboutDialog.scss +41 -0
- package/src/styles.js +1 -1
- package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
- package/src/toolbar/DropdownToolbar.scss +46 -0
- package/src/toolbar/EdgeToolbar.scss +511 -0
- package/src/toolbar/toolbar.scss +11 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
- package/src/toolbar/widgets/HandToolWidget.scss +14 -0
- package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
- package/src/toolbar/widgets/PenToolWidget.css +0 -51
- package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
- package/src/toolbar/widgets/components/components.scss +5 -0
- package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
- package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
- package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
- package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
- package/src/tools/FindTool.css +3 -3
- package/src/tools/SelectionTool/SelectionTool.css +23 -11
- package/src/tools/tools.scss +4 -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/Editor.loadFrom.test.d.ts +0 -1
- package/dist/cjs/Editor.toSVG.test.d.ts +0 -1
- package/dist/cjs/EditorImage.test.d.ts +0 -1
- package/dist/cjs/EventDispatcher.test.d.ts +0 -1
- package/dist/cjs/SVGLoader.test.d.ts +0 -1
- package/dist/cjs/UndoRedoHistory.test.d.ts +0 -1
- package/dist/cjs/commands/uniteCommands.test.d.ts +0 -1
- package/dist/cjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
- package/dist/cjs/components/BackgroundComponent.test.d.ts +0 -1
- package/dist/cjs/components/Stroke.test.d.ts +0 -1
- package/dist/cjs/components/TextComponent.test.d.ts +0 -1
- package/dist/cjs/components/UnknownSVGObject.test.d.ts +0 -1
- package/dist/cjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
- package/dist/cjs/localizations/getLocalizationTable.test.d.ts +0 -1
- package/dist/cjs/math/Mat33.d.ts +0 -123
- package/dist/cjs/math/Mat33.js +0 -340
- package/dist/cjs/math/Mat33.test.d.ts +0 -1
- package/dist/cjs/math/Vec2.d.ts +0 -33
- package/dist/cjs/math/Vec2.js +0 -37
- package/dist/cjs/math/Vec2.test.d.ts +0 -1
- package/dist/cjs/math/Vec3.d.ts +0 -106
- package/dist/cjs/math/Vec3.js +0 -183
- package/dist/cjs/math/Vec3.test.d.ts +0 -1
- 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/polynomial/solveQuadratic.test.d.ts +0 -1
- package/dist/cjs/math/rounding.d.ts +0 -4
- package/dist/cjs/math/rounding.js +0 -140
- package/dist/cjs/math/rounding.test.d.ts +0 -1
- 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/LineSegment2.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.d.ts +0 -93
- package/dist/cjs/math/shapes/Path.fromString.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.js +0 -865
- package/dist/cjs/math/shapes/Path.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.toString.test.d.ts +0 -1
- 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/QuadraticBezier.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Rect2.d.ts +0 -57
- package/dist/cjs/math/shapes/Rect2.js +0 -311
- package/dist/cjs/math/shapes/Rect2.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/cjs/math/shapes/Triangle.js +0 -148
- package/dist/cjs/math/shapes/Triangle.test.d.ts +0 -1
- package/dist/cjs/rendering/RenderingStyle.test.d.ts +0 -1
- package/dist/cjs/rendering/caching/CacheRecord.test.d.ts +0 -1
- package/dist/cjs/rendering/caching/RenderingCache.test.d.ts +0 -1
- package/dist/cjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
- package/dist/cjs/shortcuts/KeyBinding.test.d.ts +0 -1
- package/dist/cjs/shortcuts/KeyboardShortcutManager.test.d.ts +0 -1
- 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/cjs/tools/Eraser.test.d.ts +0 -1
- package/dist/cjs/tools/PanZoom.test.d.ts +0 -1
- package/dist/cjs/tools/Pen.test.d.ts +0 -1
- package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
- package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +0 -1
- 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/Editor.loadFrom.test.d.ts +0 -1
- package/dist/mjs/Editor.toSVG.test.d.ts +0 -1
- package/dist/mjs/EditorImage.test.d.ts +0 -1
- package/dist/mjs/EventDispatcher.test.d.ts +0 -1
- package/dist/mjs/SVGLoader.test.d.ts +0 -1
- package/dist/mjs/UndoRedoHistory.test.d.ts +0 -1
- package/dist/mjs/commands/uniteCommands.test.d.ts +0 -1
- package/dist/mjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
- package/dist/mjs/components/BackgroundComponent.test.d.ts +0 -1
- package/dist/mjs/components/Stroke.test.d.ts +0 -1
- package/dist/mjs/components/TextComponent.test.d.ts +0 -1
- package/dist/mjs/components/UnknownSVGObject.test.d.ts +0 -1
- package/dist/mjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
- package/dist/mjs/localizations/getLocalizationTable.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/rendering/RenderingStyle.test.d.ts +0 -1
- package/dist/mjs/rendering/caching/CacheRecord.test.d.ts +0 -1
- package/dist/mjs/rendering/caching/RenderingCache.test.d.ts +0 -1
- package/dist/mjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
- package/dist/mjs/shortcuts/KeyBinding.test.d.ts +0 -1
- package/dist/mjs/shortcuts/KeyboardShortcutManager.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/dist/mjs/tools/Eraser.test.d.ts +0 -1
- package/dist/mjs/tools/PanZoom.test.d.ts +0 -1
- package/dist/mjs/tools/Pen.test.d.ts +0 -1
- package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
- package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +0 -1
- package/dist-test/test_imports/package-lock.json +0 -13
- package/dist-test/test_imports/package.json +0 -12
- package/dist-test/test_imports/test-imports.js +0 -17
- package/dist-test/test_imports/test-require.cjs +0 -19
- package/src/Color4.test.ts +0 -47
- package/src/Color4.ts +0 -304
- package/src/Editor.css +0 -98
- package/src/Editor.loadFrom.test.ts +0 -24
- package/src/Editor.toSVG.test.ts +0 -111
- package/src/Editor.ts +0 -1171
- package/src/EditorImage.test.ts +0 -120
- package/src/EditorImage.ts +0 -603
- package/src/EventDispatcher.test.ts +0 -123
- package/src/EventDispatcher.ts +0 -72
- package/src/Pointer.ts +0 -167
- package/src/SVGLoader.test.ts +0 -114
- package/src/SVGLoader.ts +0 -610
- package/src/UndoRedoHistory.test.ts +0 -33
- package/src/UndoRedoHistory.ts +0 -102
- package/src/Viewport.ts +0 -325
- package/src/bundle/bundled.ts +0 -7
- package/src/commands/Command.ts +0 -45
- package/src/commands/Duplicate.ts +0 -75
- package/src/commands/Erase.ts +0 -94
- package/src/commands/SerializableCommand.ts +0 -49
- package/src/commands/UnresolvedCommand.ts +0 -37
- package/src/commands/invertCommand.ts +0 -58
- package/src/commands/lib.ts +0 -16
- package/src/commands/localization.ts +0 -47
- package/src/commands/uniteCommands.test.ts +0 -23
- package/src/commands/uniteCommands.ts +0 -140
- package/src/components/AbstractComponent.transformBy.test.ts +0 -22
- package/src/components/AbstractComponent.ts +0 -374
- package/src/components/BackgroundComponent.test.ts +0 -45
- package/src/components/BackgroundComponent.ts +0 -353
- package/src/components/ImageComponent.ts +0 -178
- package/src/components/RestylableComponent.ts +0 -161
- package/src/components/SVGGlobalAttributesObject.ts +0 -81
- package/src/components/Stroke.test.ts +0 -139
- package/src/components/Stroke.ts +0 -296
- package/src/components/TextComponent.test.ts +0 -204
- package/src/components/TextComponent.ts +0 -432
- package/src/components/UnknownSVGObject.test.ts +0 -10
- package/src/components/UnknownSVGObject.ts +0 -60
- package/src/components/builders/ArrowBuilder.ts +0 -107
- package/src/components/builders/CircleBuilder.ts +0 -102
- package/src/components/builders/FreehandLineBuilder.test.ts +0 -25
- package/src/components/builders/FreehandLineBuilder.ts +0 -212
- package/src/components/builders/LineBuilder.ts +0 -77
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
- package/src/components/builders/RectangleBuilder.ts +0 -74
- package/src/components/builders/types.ts +0 -15
- package/src/components/lib.ts +0 -31
- package/src/components/localization.ts +0 -24
- package/src/components/util/StrokeSmoother.ts +0 -302
- package/src/components/util/describeComponentList.ts +0 -18
- package/src/lib.ts +0 -69
- package/src/localization.ts +0 -34
- package/src/localizations/de.ts +0 -146
- package/src/localizations/en.ts +0 -8
- package/src/localizations/es.ts +0 -74
- package/src/localizations/getLocalizationTable.test.ts +0 -27
- package/src/localizations/getLocalizationTable.ts +0 -74
- 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/rendering/Display.ts +0 -248
- package/src/rendering/RenderingStyle.test.ts +0 -68
- package/src/rendering/RenderingStyle.ts +0 -55
- package/src/rendering/TextRenderingStyle.ts +0 -55
- package/src/rendering/caching/CacheRecord.test.ts +0 -49
- package/src/rendering/caching/CacheRecord.ts +0 -77
- package/src/rendering/caching/CacheRecordManager.ts +0 -71
- package/src/rendering/caching/RenderingCache.test.ts +0 -44
- package/src/rendering/caching/RenderingCache.ts +0 -66
- package/src/rendering/caching/RenderingCacheNode.ts +0 -405
- package/src/rendering/caching/testUtils.ts +0 -35
- package/src/rendering/caching/types.ts +0 -34
- package/src/rendering/lib.ts +0 -8
- package/src/rendering/localization.ts +0 -20
- package/src/rendering/renderers/AbstractRenderer.ts +0 -242
- package/src/rendering/renderers/CanvasRenderer.ts +0 -307
- package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
- package/src/rendering/renderers/DummyRenderer.ts +0 -145
- package/src/rendering/renderers/SVGRenderer.ts +0 -377
- package/src/rendering/renderers/TextOnlyRenderer.test.ts +0 -34
- package/src/rendering/renderers/TextOnlyRenderer.ts +0 -71
- package/src/shortcuts/KeyBinding.test.ts +0 -51
- package/src/shortcuts/KeyBinding.ts +0 -218
- package/src/shortcuts/KeyboardShortcutManager.test.ts +0 -95
- package/src/shortcuts/KeyboardShortcutManager.ts +0 -163
- package/src/shortcuts/lib.ts +0 -3
- package/src/testing/createEditor.ts +0 -11
- package/src/testing/getUniquePointerId.ts +0 -18
- package/src/testing/lib.ts +0 -3
- package/src/testing/sendPenEvent.ts +0 -36
- package/src/testing/sendTouchEvent.ts +0 -71
- package/src/toolbar/HTMLToolbar.ts +0 -567
- package/src/toolbar/IconProvider.ts +0 -805
- package/src/toolbar/lib.ts +0 -4
- package/src/toolbar/localization.ts +0 -114
- package/src/toolbar/makeColorInput.ts +0 -159
- package/src/toolbar/types.ts +0 -5
- package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
- package/src/toolbar/widgets/BaseToolWidget.ts +0 -65
- package/src/toolbar/widgets/BaseWidget.ts +0 -428
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -234
- package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
- package/src/toolbar/widgets/HandToolWidget.ts +0 -250
- package/src/toolbar/widgets/InsertImageWidget.css +0 -44
- package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
- package/src/toolbar/widgets/OverflowWidget.ts +0 -92
- package/src/toolbar/widgets/PenToolWidget.ts +0 -409
- package/src/toolbar/widgets/SelectionToolWidget.ts +0 -197
- package/src/toolbar/widgets/TextToolWidget.ts +0 -145
- package/src/toolbar/widgets/keybindings.ts +0 -21
- package/src/toolbar/widgets/lib.ts +0 -13
- package/src/tools/BaseTool.ts +0 -97
- package/src/tools/Eraser.test.ts +0 -103
- package/src/tools/Eraser.ts +0 -160
- package/src/tools/FindTool.ts +0 -153
- package/src/tools/PanZoom.test.ts +0 -349
- package/src/tools/PanZoom.ts +0 -502
- package/src/tools/PasteHandler.ts +0 -95
- package/src/tools/Pen.test.ts +0 -262
- package/src/tools/Pen.ts +0 -300
- package/src/tools/PipetteTool.ts +0 -55
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -29
- package/src/tools/SelectionTool/Selection.ts +0 -611
- package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
- package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
- package/src/tools/SelectionTool/SelectionTool.ts +0 -496
- package/src/tools/SelectionTool/TransformMode.ts +0 -114
- package/src/tools/SelectionTool/types.ts +0 -11
- package/src/tools/SoundUITool.ts +0 -212
- package/src/tools/TextTool.ts +0 -340
- package/src/tools/ToolController.ts +0 -200
- package/src/tools/ToolEnabledGroup.ts +0 -14
- package/src/tools/ToolSwitcherShortcut.ts +0 -39
- package/src/tools/ToolbarShortcutHandler.ts +0 -39
- package/src/tools/UndoRedoShortcut.test.ts +0 -56
- package/src/tools/UndoRedoShortcut.ts +0 -24
- package/src/tools/keybindings.ts +0 -85
- package/src/tools/lib.ts +0 -22
- package/src/tools/localization.ts +0 -74
- package/src/tools/tools.css +0 -4
- package/src/types.ts +0 -239
- package/src/util/assertions.ts +0 -55
- package/src/util/fileToBase64.ts +0 -18
- package/src/util/untilNextAnimationFrame.ts +0 -9
- package/src/util/waitForAll.ts +0 -18
- package/src/util/waitForTimeout.ts +0 -9
- /package/dist/{cjs/Color4.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
@@ -1,145 +0,0 @@
|
|
1
|
-
import Color4 from '../../Color4';
|
2
|
-
import Editor from '../../Editor';
|
3
|
-
import TextTool from '../../tools/TextTool';
|
4
|
-
import { EditorEventType } from '../../types';
|
5
|
-
import { toolbarCSSPrefix } from '../HTMLToolbar';
|
6
|
-
import { ToolbarLocalization } from '../localization';
|
7
|
-
import makeColorInput from '../makeColorInput';
|
8
|
-
import BaseToolWidget from './BaseToolWidget';
|
9
|
-
import { SavedToolbuttonState } from './BaseWidget';
|
10
|
-
|
11
|
-
export default class TextToolWidget extends BaseToolWidget {
|
12
|
-
private updateDropdownInputs: (()=>void)|null = null;
|
13
|
-
public constructor(editor: Editor, private tool: TextTool, localization?: ToolbarLocalization) {
|
14
|
-
super(editor, tool, 'text-tool-widget', localization);
|
15
|
-
|
16
|
-
editor.notifier.on(EditorEventType.ToolUpdated, evt => {
|
17
|
-
if (evt.kind === EditorEventType.ToolUpdated && evt.tool === tool) {
|
18
|
-
this.updateIcon();
|
19
|
-
this.updateDropdownInputs?.();
|
20
|
-
}
|
21
|
-
});
|
22
|
-
}
|
23
|
-
|
24
|
-
protected getTitle(): string {
|
25
|
-
return this.targetTool.description;
|
26
|
-
}
|
27
|
-
|
28
|
-
protected createIcon(): Element {
|
29
|
-
const textStyle = this.tool.getTextStyle();
|
30
|
-
return this.editor.icons.makeTextIcon(textStyle);
|
31
|
-
}
|
32
|
-
|
33
|
-
private static idCounter: number = 0;
|
34
|
-
protected override fillDropdown(dropdown: HTMLElement): boolean {
|
35
|
-
const container = document.createElement('div');
|
36
|
-
container.classList.add(`${toolbarCSSPrefix}spacedList`);
|
37
|
-
const fontRow = document.createElement('div');
|
38
|
-
const colorRow = document.createElement('div');
|
39
|
-
const sizeRow = document.createElement('div');
|
40
|
-
|
41
|
-
const fontInput = document.createElement('select');
|
42
|
-
const fontLabel = document.createElement('label');
|
43
|
-
|
44
|
-
const sizeInput = document.createElement('input');
|
45
|
-
const sizeLabel = document.createElement('label');
|
46
|
-
|
47
|
-
const [ colorInput, colorInputContainer, setColorInputValue ] = makeColorInput(this.editor, color => {
|
48
|
-
this.tool.setColor(color);
|
49
|
-
});
|
50
|
-
const colorLabel = document.createElement('label');
|
51
|
-
|
52
|
-
const fontsInInput = new Set();
|
53
|
-
const addFontToInput = (fontName: string) => {
|
54
|
-
const option = document.createElement('option');
|
55
|
-
option.value = fontName;
|
56
|
-
option.textContent = fontName;
|
57
|
-
fontInput.appendChild(option);
|
58
|
-
fontsInInput.add(fontName);
|
59
|
-
};
|
60
|
-
|
61
|
-
sizeInput.setAttribute('type', 'number');
|
62
|
-
sizeInput.min = '1';
|
63
|
-
sizeInput.max = '128';
|
64
|
-
|
65
|
-
fontLabel.innerText = this.localizationTable.fontLabel;
|
66
|
-
colorLabel.innerText = this.localizationTable.colorLabel;
|
67
|
-
sizeLabel.innerText = this.localizationTable.textSize;
|
68
|
-
|
69
|
-
colorInput.id = `${toolbarCSSPrefix}-text-color-input-${TextToolWidget.idCounter++}`;
|
70
|
-
colorLabel.setAttribute('for', colorInput.id);
|
71
|
-
|
72
|
-
sizeInput.id = `${toolbarCSSPrefix}-text-size-input-${TextToolWidget.idCounter++}`;
|
73
|
-
sizeLabel.setAttribute('for', sizeInput.id);
|
74
|
-
|
75
|
-
addFontToInput('monospace');
|
76
|
-
addFontToInput('serif');
|
77
|
-
addFontToInput('sans-serif');
|
78
|
-
fontInput.id = `${toolbarCSSPrefix}-text-font-input-${TextToolWidget.idCounter++}`;
|
79
|
-
fontLabel.setAttribute('for', fontInput.id);
|
80
|
-
|
81
|
-
fontInput.onchange = () => {
|
82
|
-
this.tool.setFontFamily(fontInput.value);
|
83
|
-
};
|
84
|
-
|
85
|
-
sizeInput.onchange = () => {
|
86
|
-
const size = parseInt(sizeInput.value);
|
87
|
-
if (!isNaN(size) && size > 0) {
|
88
|
-
this.tool.setFontSize(size);
|
89
|
-
}
|
90
|
-
};
|
91
|
-
|
92
|
-
colorRow.appendChild(colorLabel);
|
93
|
-
colorRow.appendChild(colorInputContainer);
|
94
|
-
|
95
|
-
fontRow.appendChild(fontLabel);
|
96
|
-
fontRow.appendChild(fontInput);
|
97
|
-
|
98
|
-
sizeRow.appendChild(sizeLabel);
|
99
|
-
sizeRow.appendChild(sizeInput);
|
100
|
-
|
101
|
-
this.updateDropdownInputs = () => {
|
102
|
-
const style = this.tool.getTextStyle();
|
103
|
-
setColorInputValue(style.renderingStyle.fill);
|
104
|
-
|
105
|
-
if (!fontsInInput.has(style.fontFamily)) {
|
106
|
-
addFontToInput(style.fontFamily);
|
107
|
-
}
|
108
|
-
fontInput.value = style.fontFamily;
|
109
|
-
sizeInput.value = `${style.size}`;
|
110
|
-
};
|
111
|
-
this.updateDropdownInputs();
|
112
|
-
|
113
|
-
container.replaceChildren(colorRow, sizeRow, fontRow);
|
114
|
-
dropdown.appendChild(container);
|
115
|
-
return true;
|
116
|
-
}
|
117
|
-
|
118
|
-
public override serializeState(): SavedToolbuttonState {
|
119
|
-
const textStyle = this.tool.getTextStyle();
|
120
|
-
|
121
|
-
return {
|
122
|
-
...super.serializeState(),
|
123
|
-
|
124
|
-
fontFamily: textStyle.fontFamily,
|
125
|
-
textSize: textStyle.size,
|
126
|
-
color: textStyle.renderingStyle.fill.toHexString(),
|
127
|
-
};
|
128
|
-
}
|
129
|
-
|
130
|
-
public override deserializeFrom(state: SavedToolbuttonState) {
|
131
|
-
if (state.fontFamily && typeof(state.fontFamily) === 'string') {
|
132
|
-
this.tool.setFontFamily(state.fontFamily);
|
133
|
-
}
|
134
|
-
|
135
|
-
if (state.color && typeof(state.color) === 'string') {
|
136
|
-
this.tool.setColor(Color4.fromHex(state.color));
|
137
|
-
}
|
138
|
-
|
139
|
-
if (state.textSize && typeof(state.textSize) === 'number') {
|
140
|
-
this.tool.setFontSize(state.textSize);
|
141
|
-
}
|
142
|
-
|
143
|
-
super.deserializeFrom(state);
|
144
|
-
}
|
145
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import KeyboardShortcutManager from '../../shortcuts/KeyboardShortcutManager';
|
4
|
-
|
5
|
-
// Selection
|
6
|
-
export const resizeImageToSelectionKeyboardShortcut =
|
7
|
-
'jsdraw.toolbar.SelectionTool.resizeImageToSelection';
|
8
|
-
KeyboardShortcutManager.registerDefaultKeyboardShortcut(
|
9
|
-
resizeImageToSelectionKeyboardShortcut, [ 'ctrlOrMeta+r' ], 'Resize image to selection'
|
10
|
-
);
|
11
|
-
|
12
|
-
// Pen tool
|
13
|
-
export const selectStrokeTypeKeyboardShortcutIds: string[] =
|
14
|
-
[1, 2, 3, 4, 5, 6, 7].map(id => `jsdraw.toolbar.PenTool.select-pen-${id}`);
|
15
|
-
|
16
|
-
for (let i = 0; i < selectStrokeTypeKeyboardShortcutIds.length; i++) {
|
17
|
-
const id = selectStrokeTypeKeyboardShortcutIds[i];
|
18
|
-
KeyboardShortcutManager.registerDefaultKeyboardShortcut(
|
19
|
-
id, [ `ctrlOrMeta+${(i + 1)}` ], 'Select pen style ' + (i + 1),
|
20
|
-
);
|
21
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
|
2
|
-
export { default as ActionButtonWidget } from './ActionButtonWidget';
|
3
|
-
export { default as BaseToolWidget } from './BaseToolWidget';
|
4
|
-
export { default as BaseWidget } from './BaseWidget';
|
5
|
-
|
6
|
-
export { default as PenToolWidget } from './PenToolWidget';
|
7
|
-
export { default as TextToolWidget } from './TextToolWidget';
|
8
|
-
export { default as HandToolWidget } from './HandToolWidget';
|
9
|
-
export { default as SelectionToolWidget } from './SelectionToolWidget';
|
10
|
-
export { default as EraserToolWidget } from './EraserToolWidget';
|
11
|
-
|
12
|
-
export { default as InsertImageWidget } from './InsertImageWidget';
|
13
|
-
export { default as DocumentPropertiesWidget } from './DocumentPropertiesWidget';
|
package/src/tools/BaseTool.ts
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
import { PointerEvtListener, WheelEvt, PointerEvt, EditorNotifier, EditorEventType, KeyPressEvent, KeyUpEvent, PasteEvent, CopyEvent } from '../types';
|
2
|
-
import ToolEnabledGroup from './ToolEnabledGroup';
|
3
|
-
|
4
|
-
export default abstract class BaseTool implements PointerEvtListener {
|
5
|
-
private enabled: boolean = true;
|
6
|
-
private group: ToolEnabledGroup|null = null;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Returns true iff the tool handled the event and thus should receive additional
|
10
|
-
* events.
|
11
|
-
*/
|
12
|
-
public onPointerDown(_event: PointerEvt): boolean { return false; }
|
13
|
-
public onPointerMove(_event: PointerEvt) { }
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Returns true iff there are additional pointers down and the tool should
|
17
|
-
* remain active to handle the additional events.
|
18
|
-
*
|
19
|
-
* For most purposes, this should return `false` or nothing.
|
20
|
-
*/
|
21
|
-
public onPointerUp(_event: PointerEvt): boolean|void { }
|
22
|
-
|
23
|
-
public onGestureCancel() { }
|
24
|
-
|
25
|
-
protected constructor(private notifier: EditorNotifier, public readonly description: string) {
|
26
|
-
}
|
27
|
-
|
28
|
-
public onWheel(_event: WheelEvt): boolean {
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
|
32
|
-
public onCopy(_event: CopyEvent): boolean {
|
33
|
-
return false;
|
34
|
-
}
|
35
|
-
|
36
|
-
public onPaste(_event: PasteEvent): boolean {
|
37
|
-
return false;
|
38
|
-
}
|
39
|
-
|
40
|
-
public onKeyPress(_event: KeyPressEvent): boolean {
|
41
|
-
return false;
|
42
|
-
}
|
43
|
-
|
44
|
-
public onKeyUp(_event: KeyUpEvent): boolean {
|
45
|
-
return false;
|
46
|
-
}
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Return true if, while this tool is active, `_event` can be delivered to
|
50
|
-
* another tool that is higher priority than this.
|
51
|
-
* @internal May be renamed
|
52
|
-
*/
|
53
|
-
public eventCanBeDeliveredToNonActiveTool(_event: PointerEvt) {
|
54
|
-
return true;
|
55
|
-
}
|
56
|
-
|
57
|
-
public setEnabled(enabled: boolean) {
|
58
|
-
this.enabled = 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
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
public isEnabled(): boolean {
|
76
|
-
return this.enabled;
|
77
|
-
}
|
78
|
-
|
79
|
-
// Connect this tool to a set of other tools, ensuring that at most one
|
80
|
-
// of the tools in the group is enabled.
|
81
|
-
public setToolGroup(group: ToolEnabledGroup) {
|
82
|
-
if (this.isEnabled()) {
|
83
|
-
group.notifyEnabled(this);
|
84
|
-
}
|
85
|
-
|
86
|
-
this.group = group;
|
87
|
-
}
|
88
|
-
|
89
|
-
public getToolGroup(): ToolEnabledGroup|null {
|
90
|
-
if (this.group) {
|
91
|
-
return this.group;
|
92
|
-
}
|
93
|
-
|
94
|
-
return null;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
package/src/tools/Eraser.test.ts
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
import UnknownSVGObject from '../components/UnknownSVGObject';
|
2
|
-
import Editor from '../Editor';
|
3
|
-
import { EditorImage, Rect2, StrokeComponent } from '../lib';
|
4
|
-
import { Vec2 } from '../math/Vec2';
|
5
|
-
import createEditor from '../testing/createEditor';
|
6
|
-
import sendPenEvent from '../testing/sendPenEvent';
|
7
|
-
import { InputEvtType } from '../types';
|
8
|
-
import Eraser from './Eraser';
|
9
|
-
|
10
|
-
const selectEraser = (editor: Editor) => {
|
11
|
-
const tools = editor.toolController;
|
12
|
-
const eraser = tools.getMatchingTools(Eraser)[0];
|
13
|
-
eraser.setEnabled(true);
|
14
|
-
|
15
|
-
return eraser;
|
16
|
-
};
|
17
|
-
|
18
|
-
const getAllStrokes = (editor: Editor) => {
|
19
|
-
return editor.image.getAllElements().filter(elem => elem instanceof StrokeComponent);
|
20
|
-
};
|
21
|
-
|
22
|
-
describe('Eraser', () => {
|
23
|
-
it('should erase object between locations of events', () => {
|
24
|
-
const editor = createEditor();
|
25
|
-
|
26
|
-
// Draw a line
|
27
|
-
sendPenEvent(editor, InputEvtType.PointerDownEvt, Vec2.of(0, 0));
|
28
|
-
jest.advanceTimersByTime(100);
|
29
|
-
sendPenEvent(editor, InputEvtType.PointerUpEvt, Vec2.of(200, 200));
|
30
|
-
|
31
|
-
// Should have drawn a line
|
32
|
-
const strokes = getAllStrokes(editor);
|
33
|
-
expect(strokes).toHaveLength(1);
|
34
|
-
expect(strokes[0].getBBox().area).toBeGreaterThanOrEqual(200 * 200);
|
35
|
-
|
36
|
-
selectEraser(editor);
|
37
|
-
|
38
|
-
// Erase the line.
|
39
|
-
sendPenEvent(editor, InputEvtType.PointerDownEvt, Vec2.of(200, 0));
|
40
|
-
jest.advanceTimersByTime(400);
|
41
|
-
sendPenEvent(editor, InputEvtType.PointerUpEvt, Vec2.of(0, 200));
|
42
|
-
|
43
|
-
// Should have erased the line
|
44
|
-
expect(getAllStrokes(editor)).toHaveLength(0);
|
45
|
-
});
|
46
|
-
|
47
|
-
it('should erase objects within eraser.thickness of an event when not zoomed', async () => {
|
48
|
-
const editor = createEditor();
|
49
|
-
|
50
|
-
await editor.loadFromSVG(`
|
51
|
-
<svg>
|
52
|
-
<path d='m0,0 l2,0 l0,2 l-2,0 z' fill="#ff0000"/>
|
53
|
-
<path d='m50,50 l2,0 l0,2 l-2,0 z' fill="#ff0000"/>
|
54
|
-
</svg>
|
55
|
-
`, true);
|
56
|
-
|
57
|
-
editor.viewport.resetTransform();
|
58
|
-
|
59
|
-
const allStrokes = getAllStrokes(editor);
|
60
|
-
expect(allStrokes).toHaveLength(2);
|
61
|
-
expect(allStrokes[0].getBBox()).objEq(new Rect2(0, 0, 2, 2));
|
62
|
-
expect(allStrokes[1].getBBox()).objEq(new Rect2(50, 50, 2, 2));
|
63
|
-
|
64
|
-
const eraser = selectEraser(editor);
|
65
|
-
eraser.setThickness(10);
|
66
|
-
|
67
|
-
// Erase the first stroke
|
68
|
-
sendPenEvent(editor, InputEvtType.PointerDownEvt, Vec2.of(3, 0));
|
69
|
-
jest.advanceTimersByTime(100);
|
70
|
-
sendPenEvent(editor, InputEvtType.PointerUpEvt, Vec2.of(3, 0));
|
71
|
-
|
72
|
-
expect(getAllStrokes(editor)).toHaveLength(1);
|
73
|
-
|
74
|
-
// Erase the remaining stroke
|
75
|
-
sendPenEvent(editor, InputEvtType.PointerDownEvt, Vec2.of(47, 47));
|
76
|
-
jest.advanceTimersByTime(100);
|
77
|
-
sendPenEvent(editor, InputEvtType.PointerUpEvt, Vec2.of(47, 47));
|
78
|
-
|
79
|
-
expect(getAllStrokes(editor)).toHaveLength(0);
|
80
|
-
});
|
81
|
-
|
82
|
-
it('should not erase unselectable objects', () => {
|
83
|
-
const editor = createEditor();
|
84
|
-
const unerasableObj = new UnknownSVGObject(document.createElementNS('http://www.w3.org/2000/svg', 'arc'));
|
85
|
-
|
86
|
-
// Add to the image
|
87
|
-
expect(editor.image.getAllElements()).toHaveLength(0);
|
88
|
-
editor.dispatch(EditorImage.addElement(unerasableObj));
|
89
|
-
expect(editor.image.getAllElements()).toHaveLength(1);
|
90
|
-
|
91
|
-
|
92
|
-
const eraser = selectEraser(editor);
|
93
|
-
eraser.setThickness(100);
|
94
|
-
|
95
|
-
// Try to erase it.
|
96
|
-
sendPenEvent(editor, InputEvtType.PointerDownEvt, Vec2.of(0, 0));
|
97
|
-
jest.advanceTimersByTime(100);
|
98
|
-
sendPenEvent(editor, InputEvtType.PointerUpEvt, Vec2.of(3, 0));
|
99
|
-
|
100
|
-
// Should not have been erased
|
101
|
-
expect(editor.image.getAllElements()).toHaveLength(1);
|
102
|
-
});
|
103
|
-
});
|
package/src/tools/Eraser.ts
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
import { EditorEventType, KeyPressEvent, PointerEvt } from '../types';
|
2
|
-
import BaseTool from './BaseTool';
|
3
|
-
import Editor from '../Editor';
|
4
|
-
import { Point2, Vec2 } from '../math/Vec2';
|
5
|
-
import LineSegment2 from '../math/shapes/LineSegment2';
|
6
|
-
import Erase from '../commands/Erase';
|
7
|
-
import AbstractComponent from '../components/AbstractComponent';
|
8
|
-
import { PointerDevice } from '../Pointer';
|
9
|
-
import Color4 from '../Color4';
|
10
|
-
import Rect2 from '../math/shapes/Rect2';
|
11
|
-
import RenderingStyle from '../rendering/RenderingStyle';
|
12
|
-
import { decreaseSizeKeyboardShortcutId, increaseSizeKeyboardShortcutId } from './keybindings';
|
13
|
-
|
14
|
-
export default class Eraser extends BaseTool {
|
15
|
-
private lastPoint: Point2|null = null;
|
16
|
-
private isFirstEraseEvt: boolean = true;
|
17
|
-
private toRemove: AbstractComponent[];
|
18
|
-
private thickness: number = 10;
|
19
|
-
|
20
|
-
// Commands that each remove one element
|
21
|
-
private partialCommands: Erase[] = [];
|
22
|
-
|
23
|
-
public constructor(private editor: Editor, description: string) {
|
24
|
-
super(editor.notifier, description);
|
25
|
-
}
|
26
|
-
|
27
|
-
private clearPreview() {
|
28
|
-
this.editor.clearWetInk();
|
29
|
-
}
|
30
|
-
|
31
|
-
private getSizeOnCanvas() {
|
32
|
-
return this.thickness / this.editor.viewport.getScaleFactor();
|
33
|
-
}
|
34
|
-
|
35
|
-
private drawPreviewAt(point: Point2) {
|
36
|
-
this.clearPreview();
|
37
|
-
|
38
|
-
const size = this.getSizeOnCanvas();
|
39
|
-
|
40
|
-
const renderer = this.editor.display.getWetInkRenderer();
|
41
|
-
const rect = this.getEraserRect(point);
|
42
|
-
const fill: RenderingStyle = {
|
43
|
-
fill: Color4.gray,
|
44
|
-
};
|
45
|
-
renderer.drawRect(rect, size / 4, fill);
|
46
|
-
}
|
47
|
-
|
48
|
-
private getEraserRect(centerPoint: Point2) {
|
49
|
-
const size = this.getSizeOnCanvas();
|
50
|
-
const halfSize = Vec2.of(size / 2, size / 2);
|
51
|
-
return Rect2.fromCorners(centerPoint.minus(halfSize), centerPoint.plus(halfSize));
|
52
|
-
}
|
53
|
-
|
54
|
-
private eraseTo(currentPoint: Point2) {
|
55
|
-
if (!this.isFirstEraseEvt && currentPoint.minus(this.lastPoint!).magnitude() === 0) {
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
this.isFirstEraseEvt = false;
|
59
|
-
|
60
|
-
// Currently only objects within eraserRect or that intersect a straight line
|
61
|
-
// from the center of the current rect to the previous are erased. TODO: Erase
|
62
|
-
// all objects as if there were pointerMove events between the two points.
|
63
|
-
const eraserRect = this.getEraserRect(currentPoint);
|
64
|
-
const line = new LineSegment2(this.lastPoint!, currentPoint);
|
65
|
-
const region = Rect2.union(line.bbox, eraserRect);
|
66
|
-
|
67
|
-
const intersectingElems = this.editor.image.getElementsIntersectingRegion(region).filter(component => {
|
68
|
-
return component.intersects(line) || component.intersectsRect(eraserRect);
|
69
|
-
});
|
70
|
-
|
71
|
-
// Only erase components that could be selected (and thus interacted with)
|
72
|
-
// by the user.
|
73
|
-
const toErase = intersectingElems.filter(elem => elem.isSelectable());
|
74
|
-
|
75
|
-
// Remove any intersecting elements.
|
76
|
-
this.toRemove.push(...toErase);
|
77
|
-
|
78
|
-
// Create new Erase commands for the now-to-be-erased elements and apply them.
|
79
|
-
const newPartialCommands = toErase.map(elem => new Erase([ elem ]));
|
80
|
-
newPartialCommands.forEach(cmd => cmd.apply(this.editor));
|
81
|
-
|
82
|
-
this.partialCommands.push(...newPartialCommands);
|
83
|
-
|
84
|
-
this.drawPreviewAt(currentPoint);
|
85
|
-
this.lastPoint = currentPoint;
|
86
|
-
}
|
87
|
-
|
88
|
-
public override onPointerDown(event: PointerEvt): boolean {
|
89
|
-
if (event.allPointers.length === 1 || event.current.device === PointerDevice.Eraser) {
|
90
|
-
this.lastPoint = event.current.canvasPos;
|
91
|
-
this.toRemove = [];
|
92
|
-
this.isFirstEraseEvt = true;
|
93
|
-
|
94
|
-
this.drawPreviewAt(event.current.canvasPos);
|
95
|
-
return true;
|
96
|
-
}
|
97
|
-
|
98
|
-
return false;
|
99
|
-
}
|
100
|
-
|
101
|
-
public override onPointerMove(event: PointerEvt): void {
|
102
|
-
const currentPoint = event.current.canvasPos;
|
103
|
-
|
104
|
-
this.eraseTo(currentPoint);
|
105
|
-
}
|
106
|
-
|
107
|
-
public override onPointerUp(event: PointerEvt): void {
|
108
|
-
this.eraseTo(event.current.canvasPos);
|
109
|
-
|
110
|
-
if (this.toRemove.length > 0) {
|
111
|
-
// Undo commands for each individual component and unite into a single command.
|
112
|
-
this.partialCommands.forEach(cmd => cmd.unapply(this.editor));
|
113
|
-
this.partialCommands = [];
|
114
|
-
|
115
|
-
const command = new Erase(this.toRemove);
|
116
|
-
this.editor.dispatch(command); // dispatch: Makes undo-able.
|
117
|
-
}
|
118
|
-
|
119
|
-
this.clearPreview();
|
120
|
-
}
|
121
|
-
|
122
|
-
public override onGestureCancel(): void {
|
123
|
-
this.partialCommands.forEach(cmd => cmd.unapply(this.editor));
|
124
|
-
this.partialCommands = [];
|
125
|
-
this.clearPreview();
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
public override onKeyPress(event: KeyPressEvent): boolean {
|
130
|
-
const shortcuts = this.editor.shortcuts;
|
131
|
-
|
132
|
-
let newThickness: number|undefined;
|
133
|
-
if (shortcuts.matchesShortcut(decreaseSizeKeyboardShortcutId, event)) {
|
134
|
-
newThickness = this.getThickness() * 2/3;
|
135
|
-
} else if (shortcuts.matchesShortcut(increaseSizeKeyboardShortcutId, event)) {
|
136
|
-
newThickness = this.getThickness() * 3/2;
|
137
|
-
}
|
138
|
-
|
139
|
-
if (newThickness !== undefined) {
|
140
|
-
newThickness = Math.min(Math.max(1, newThickness), 200);
|
141
|
-
this.setThickness(newThickness);
|
142
|
-
return true;
|
143
|
-
}
|
144
|
-
|
145
|
-
return false;
|
146
|
-
}
|
147
|
-
|
148
|
-
public getThickness() {
|
149
|
-
return this.thickness;
|
150
|
-
}
|
151
|
-
|
152
|
-
public setThickness(thickness: number) {
|
153
|
-
this.thickness = thickness;
|
154
|
-
|
155
|
-
this.editor.notifier.dispatch(EditorEventType.ToolUpdated, {
|
156
|
-
kind: EditorEventType.ToolUpdated,
|
157
|
-
tool: this,
|
158
|
-
});
|
159
|
-
}
|
160
|
-
}
|
package/src/tools/FindTool.ts
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
// Displays a find dialog that allows the user to search for and focus text.
|
2
|
-
//
|
3
|
-
// @packageDocumentation
|
4
|
-
|
5
|
-
import Editor from '../Editor';
|
6
|
-
import TextComponent from '../components/TextComponent';
|
7
|
-
import Rect2 from '../math/shapes/Rect2';
|
8
|
-
import { KeyPressEvent } from '../types';
|
9
|
-
import BaseTool from './BaseTool';
|
10
|
-
import { toggleFindVisibleShortcutId } from './keybindings';
|
11
|
-
|
12
|
-
const cssPrefix = 'find-tool';
|
13
|
-
|
14
|
-
export default class FindTool extends BaseTool {
|
15
|
-
private overlay: HTMLElement;
|
16
|
-
private searchInput: HTMLInputElement;
|
17
|
-
private currentMatchIdx: number = 0;
|
18
|
-
|
19
|
-
public constructor(private editor: Editor) {
|
20
|
-
super(editor.notifier, editor.localization.findLabel);
|
21
|
-
|
22
|
-
this.overlay = document.createElement('div');
|
23
|
-
this.fillOverlay();
|
24
|
-
editor.createHTMLOverlay(this.overlay);
|
25
|
-
|
26
|
-
this.overlay.style.display = 'none';
|
27
|
-
this.overlay.classList.add(`${cssPrefix}-overlay`);
|
28
|
-
}
|
29
|
-
|
30
|
-
private getMatches(searchFor: string): Rect2[] {
|
31
|
-
searchFor = searchFor.toLocaleLowerCase();
|
32
|
-
const allTextComponents = this.editor.image.getAllElements()
|
33
|
-
.filter(
|
34
|
-
elem => elem instanceof TextComponent
|
35
|
-
) as TextComponent[];
|
36
|
-
|
37
|
-
const matches = allTextComponents.filter(
|
38
|
-
text => text.getText().toLocaleLowerCase().indexOf(searchFor) !== -1
|
39
|
-
);
|
40
|
-
|
41
|
-
return matches.map(match => match.getBBox());
|
42
|
-
}
|
43
|
-
|
44
|
-
private focusCurrentMatch() {
|
45
|
-
const matches = this.getMatches(this.searchInput.value);
|
46
|
-
let matchIdx = this.currentMatchIdx % matches.length;
|
47
|
-
|
48
|
-
if (matchIdx < 0) {
|
49
|
-
matchIdx = matches.length + matchIdx;
|
50
|
-
}
|
51
|
-
|
52
|
-
if (matchIdx < matches.length) {
|
53
|
-
const undoable = false;
|
54
|
-
this.editor.dispatch(this.editor.viewport.zoomTo(matches[matchIdx], true, true), undoable);
|
55
|
-
this.editor.announceForAccessibility(
|
56
|
-
this.editor.localization.focusedFoundText(matchIdx + 1, matches.length)
|
57
|
-
);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
private toNextMatch() {
|
62
|
-
this.currentMatchIdx ++;
|
63
|
-
this.focusCurrentMatch();
|
64
|
-
}
|
65
|
-
|
66
|
-
private toPrevMatch() {
|
67
|
-
this.currentMatchIdx --;
|
68
|
-
this.focusCurrentMatch();
|
69
|
-
}
|
70
|
-
|
71
|
-
private fillOverlay() {
|
72
|
-
const label = document.createElement('label');
|
73
|
-
this.searchInput = document.createElement('input');
|
74
|
-
const nextBtn = document.createElement('button');
|
75
|
-
const closeBtn = document.createElement('button');
|
76
|
-
|
77
|
-
// Math.random() ensures that the ID is unique (to allow us to refer to it
|
78
|
-
// with an htmlFor).
|
79
|
-
this.searchInput.setAttribute('id', `${cssPrefix}-searchInput-${Math.random()}`);
|
80
|
-
label.htmlFor = this.searchInput.getAttribute('id')!;
|
81
|
-
|
82
|
-
label.innerText = this.editor.localization.findLabel;
|
83
|
-
nextBtn.innerText = this.editor.localization.toNextMatch;
|
84
|
-
closeBtn.innerText = this.editor.localization.closeFindDialog;
|
85
|
-
|
86
|
-
this.searchInput.onkeydown = (ev: KeyboardEvent) => {
|
87
|
-
if (ev.key === 'Enter') {
|
88
|
-
if (ev.shiftKey) {
|
89
|
-
this.toPrevMatch();
|
90
|
-
} else {
|
91
|
-
this.toNextMatch();
|
92
|
-
}
|
93
|
-
}
|
94
|
-
else if (ev.key === 'Escape') {
|
95
|
-
this.setVisible(false);
|
96
|
-
}
|
97
|
-
else if (this.editor.shortcuts.matchesShortcut(toggleFindVisibleShortcutId, ev)) {
|
98
|
-
ev.preventDefault();
|
99
|
-
this.toggleVisible();
|
100
|
-
}
|
101
|
-
};
|
102
|
-
|
103
|
-
nextBtn.onclick = () => {
|
104
|
-
this.toNextMatch();
|
105
|
-
};
|
106
|
-
|
107
|
-
closeBtn.onclick = () => {
|
108
|
-
this.setVisible(false);
|
109
|
-
};
|
110
|
-
|
111
|
-
this.overlay.replaceChildren(label, this.searchInput, nextBtn, closeBtn);
|
112
|
-
}
|
113
|
-
|
114
|
-
private isVisible() {
|
115
|
-
return this.overlay.style.display !== 'none';
|
116
|
-
}
|
117
|
-
|
118
|
-
private setVisible(visible: boolean) {
|
119
|
-
if (visible !== this.isVisible()) {
|
120
|
-
this.overlay.style.display = visible ? 'block' : 'none';
|
121
|
-
|
122
|
-
if (visible) {
|
123
|
-
this.searchInput.focus();
|
124
|
-
this.editor.announceForAccessibility(this.editor.localization.findDialogShown);
|
125
|
-
} else {
|
126
|
-
this.editor.focus();
|
127
|
-
this.editor.announceForAccessibility(this.editor.localization.findDialogHidden);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
private toggleVisible() {
|
133
|
-
this.setVisible(!this.isVisible());
|
134
|
-
}
|
135
|
-
|
136
|
-
public override onKeyPress(event: KeyPressEvent): boolean {
|
137
|
-
if (this.editor.shortcuts.matchesShortcut(toggleFindVisibleShortcutId, event)) {
|
138
|
-
this.toggleVisible();
|
139
|
-
|
140
|
-
return true;
|
141
|
-
}
|
142
|
-
|
143
|
-
return false;
|
144
|
-
}
|
145
|
-
|
146
|
-
public override setEnabled(enabled: boolean) {
|
147
|
-
super.setEnabled(enabled);
|
148
|
-
|
149
|
-
if (enabled) {
|
150
|
-
this.setVisible(false);
|
151
|
-
}
|
152
|
-
}
|
153
|
-
}
|