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
package/dist/cjs/EditorImage.js
CHANGED
@@ -1,45 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
2
|
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
18
3
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
19
4
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
20
5
|
};
|
21
|
-
var
|
22
|
-
|
23
|
-
if (ar || !(i in from)) {
|
24
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
25
|
-
ar[i] = from[i];
|
26
|
-
}
|
27
|
-
}
|
28
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
29
8
|
};
|
9
|
+
var _a, _b, _c;
|
30
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
31
11
|
exports.ImageNode = exports.EditorImageEventType = exports.sortLeavesByZIndex = void 0;
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
var Mat33_1 = require("./math/Mat33");
|
39
|
-
var assertions_1 = require("./util/assertions");
|
12
|
+
const Viewport_1 = __importDefault(require("./Viewport"));
|
13
|
+
const AbstractComponent_1 = __importDefault(require("./components/AbstractComponent"));
|
14
|
+
const math_1 = require("@js-draw/math");
|
15
|
+
const SerializableCommand_1 = __importDefault(require("./commands/SerializableCommand"));
|
16
|
+
const EventDispatcher_1 = __importDefault(require("./EventDispatcher"));
|
17
|
+
const assertions_1 = require("./util/assertions");
|
40
18
|
// @internal Sort by z-index, low to high
|
41
|
-
|
42
|
-
leaves.sort(
|
19
|
+
const sortLeavesByZIndex = (leaves) => {
|
20
|
+
leaves.sort((a, b) => a.getContent().getZIndex() - b.getContent().getZIndex());
|
43
21
|
};
|
44
22
|
exports.sortLeavesByZIndex = sortLeavesByZIndex;
|
45
23
|
var EditorImageEventType;
|
@@ -47,114 +25,117 @@ var EditorImageEventType;
|
|
47
25
|
EditorImageEventType[EditorImageEventType["ExportViewportChanged"] = 0] = "ExportViewportChanged";
|
48
26
|
})(EditorImageEventType || (exports.EditorImageEventType = EditorImageEventType = {}));
|
49
27
|
// Handles lookup/storage of elements in the image
|
50
|
-
|
28
|
+
class EditorImage {
|
51
29
|
// @internal
|
52
|
-
|
53
|
-
|
30
|
+
constructor() {
|
31
|
+
this.componentCount = 0;
|
54
32
|
this.root = new ImageNode();
|
55
33
|
this.background = new ImageNode();
|
56
34
|
this.componentsById = {};
|
57
35
|
this.notifier = new EventDispatcher_1.default();
|
58
|
-
this.importExportViewport = new Viewport_1.default(
|
59
|
-
|
60
|
-
image:
|
36
|
+
this.importExportViewport = new Viewport_1.default(() => {
|
37
|
+
this.notifier.dispatch(EditorImageEventType.ExportViewportChanged, {
|
38
|
+
image: this,
|
61
39
|
});
|
62
40
|
});
|
63
41
|
// Default to a 500x500 image
|
64
|
-
this.importExportViewport.updateScreenSize(
|
42
|
+
this.importExportViewport.updateScreenSize(math_1.Vec2.of(500, 500));
|
65
43
|
}
|
66
44
|
// Returns all components that make up the background of this image. These
|
67
45
|
// components are rendered below all other components.
|
68
|
-
|
69
|
-
|
70
|
-
|
46
|
+
getBackgroundComponents() {
|
47
|
+
const result = [];
|
48
|
+
const leaves = this.background.getLeaves();
|
71
49
|
(0, exports.sortLeavesByZIndex)(leaves);
|
72
|
-
for (
|
73
|
-
|
74
|
-
var content = leaf.getContent();
|
50
|
+
for (const leaf of leaves) {
|
51
|
+
const content = leaf.getContent();
|
75
52
|
if (content) {
|
76
53
|
result.push(content);
|
77
54
|
}
|
78
55
|
}
|
79
56
|
return result;
|
80
|
-
}
|
57
|
+
}
|
81
58
|
// Returns the parent of the given element, if it exists.
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
};
|
59
|
+
findParent(elem) {
|
60
|
+
return this.background.getChildWithContent(elem) ?? this.root.getChildWithContent(elem);
|
61
|
+
}
|
86
62
|
// Forces a re-render of `elem` when the image is next re-rendered as a whole.
|
87
63
|
// Does nothing if `elem` is not in this.
|
88
|
-
|
64
|
+
queueRerenderOf(elem) {
|
89
65
|
// TODO: Make more efficient (e.g. increase IDs of all parents,
|
90
66
|
// make cache take into account last modified time instead of IDs, etc.)
|
91
|
-
|
67
|
+
const parent = this.findParent(elem);
|
92
68
|
if (parent) {
|
93
69
|
parent.remove();
|
94
70
|
this.addElementDirectly(elem);
|
95
71
|
}
|
96
|
-
}
|
72
|
+
}
|
97
73
|
/** @internal */
|
98
|
-
|
74
|
+
renderWithCache(screenRenderer, cache, viewport) {
|
99
75
|
this.background.render(screenRenderer, viewport.visibleRect);
|
100
76
|
cache.render(screenRenderer, this.root, viewport);
|
101
|
-
}
|
77
|
+
}
|
102
78
|
/**
|
103
79
|
* Renders all nodes visible from `viewport` (or all nodes if `viewport = null`).
|
104
80
|
*
|
105
81
|
* `viewport` is used to improve rendering performance. If given, it must match
|
106
82
|
* the viewport used by the `renderer` (if any).
|
107
83
|
*/
|
108
|
-
|
109
|
-
this.background.render(renderer, viewport
|
110
|
-
this.root.render(renderer, viewport
|
111
|
-
}
|
84
|
+
render(renderer, viewport) {
|
85
|
+
this.background.render(renderer, viewport?.visibleRect);
|
86
|
+
this.root.render(renderer, viewport?.visibleRect);
|
87
|
+
}
|
112
88
|
/** Renders all nodes, even ones not within the viewport. @internal */
|
113
|
-
|
89
|
+
renderAll(renderer) {
|
114
90
|
this.render(renderer, null);
|
115
|
-
}
|
91
|
+
}
|
116
92
|
/** @returns all elements in the image, sorted by z-index. This can be slow for large images. */
|
117
|
-
|
118
|
-
|
93
|
+
getAllElements() {
|
94
|
+
const leaves = this.root.getLeaves();
|
119
95
|
(0, exports.sortLeavesByZIndex)(leaves);
|
120
|
-
return leaves.map(
|
121
|
-
}
|
96
|
+
return leaves.map(leaf => leaf.getContent());
|
97
|
+
}
|
98
|
+
/** Returns the number of elements added to this image. @internal */
|
99
|
+
estimateNumElements() {
|
100
|
+
return this.componentCount;
|
101
|
+
}
|
122
102
|
/** @returns a list of `AbstractComponent`s intersecting `region`, sorted by z-index. */
|
123
|
-
|
124
|
-
|
103
|
+
getElementsIntersectingRegion(region) {
|
104
|
+
const leaves = this.root.getLeavesIntersectingRegion(region);
|
125
105
|
(0, exports.sortLeavesByZIndex)(leaves);
|
126
|
-
return leaves.map(
|
127
|
-
}
|
128
|
-
/** @internal */
|
129
|
-
|
106
|
+
return leaves.map(leaf => leaf.getContent());
|
107
|
+
}
|
108
|
+
/** Called whenever an element is completely removed. @internal */
|
109
|
+
onDestroyElement(elem) {
|
110
|
+
this.componentCount--;
|
130
111
|
delete this.componentsById[elem.getId()];
|
131
|
-
}
|
112
|
+
}
|
132
113
|
/**
|
133
114
|
* @returns the AbstractComponent with `id`, if it exists.
|
134
115
|
*
|
135
116
|
* @see {@link AbstractComponent.getId}
|
136
117
|
*/
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
EditorImage.prototype.addElementDirectly = function (elem) {
|
118
|
+
lookupElement(id) {
|
119
|
+
return this.componentsById[id] ?? null;
|
120
|
+
}
|
121
|
+
addElementDirectly(elem) {
|
142
122
|
elem.onAddToImage(this);
|
123
|
+
this.componentCount++;
|
143
124
|
this.componentsById[elem.getId()] = elem;
|
144
125
|
// If a background component, add to the background. Else,
|
145
126
|
// add to the normal component tree.
|
146
|
-
|
127
|
+
const parentTree = elem.isBackground() ? this.background : this.root;
|
147
128
|
return parentTree.addLeaf(elem);
|
148
|
-
}
|
149
|
-
|
150
|
-
|
151
|
-
container
|
129
|
+
}
|
130
|
+
removeElementDirectly(element) {
|
131
|
+
const container = this.findParent(element);
|
132
|
+
container?.remove();
|
152
133
|
if (container) {
|
153
134
|
this.onDestroyElement(element);
|
154
135
|
return true;
|
155
136
|
}
|
156
137
|
return false;
|
157
|
-
}
|
138
|
+
}
|
158
139
|
/**
|
159
140
|
* Returns a command that adds the given element to the `EditorImage`.
|
160
141
|
* If `applyByFlattening` is true, the content of the wet ink renderer is
|
@@ -162,233 +143,219 @@ var EditorImage = /** @class */ (function () {
|
|
162
143
|
*
|
163
144
|
* @see {@link Display.flatten}
|
164
145
|
*/
|
165
|
-
|
166
|
-
if (applyByFlattening === void 0) { applyByFlattening = false; }
|
146
|
+
static addElement(elem, applyByFlattening = false) {
|
167
147
|
return new EditorImage.AddElementCommand(elem, applyByFlattening);
|
168
|
-
}
|
148
|
+
}
|
169
149
|
/** @see EditorImage.addElement */
|
170
|
-
|
150
|
+
addElement(elem, applyByFlattening) {
|
171
151
|
return EditorImage.addElement(elem, applyByFlattening);
|
172
|
-
}
|
152
|
+
}
|
173
153
|
/**
|
174
154
|
* @returns a `Viewport` for rendering the image when importing/exporting.
|
175
155
|
*/
|
176
|
-
|
156
|
+
getImportExportViewport() {
|
177
157
|
return this.importExportViewport;
|
178
|
-
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
158
|
+
}
|
159
|
+
setImportExportRect(imageRect) {
|
160
|
+
const importExportViewport = this.getImportExportViewport();
|
161
|
+
const origSize = importExportViewport.visibleRect.size;
|
162
|
+
const origTransform = importExportViewport.canvasToScreenTransform;
|
183
163
|
return new EditorImage.SetImportExportRectCommand(origSize, origTransform, imageRect);
|
184
|
-
}
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
if (isNaN(element.getBBox().area)) {
|
206
|
-
throw new Error('Elements in the image cannot have NaN bounding boxes');
|
207
|
-
}
|
208
|
-
return _this;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
_a = EditorImage;
|
167
|
+
// A Command that can access private [EditorImage] functionality
|
168
|
+
EditorImage.AddElementCommand = (_b = class extends SerializableCommand_1.default {
|
169
|
+
// If [applyByFlattening], then the rendered content of this element
|
170
|
+
// is present on the display's wet ink canvas. As such, no re-render is necessary
|
171
|
+
// the first time this command is applied (the surfaces are joined instead).
|
172
|
+
constructor(element, applyByFlattening = false) {
|
173
|
+
super('add-element');
|
174
|
+
this.element = element;
|
175
|
+
this.applyByFlattening = applyByFlattening;
|
176
|
+
this.serializedElem = null;
|
177
|
+
// FIXME: The serialized version of this command may be inaccurate if this is
|
178
|
+
// serialized when this command is not on the top of the undo stack.
|
179
|
+
//
|
180
|
+
// Caching the element's serialized data leads to additional memory usage *and*
|
181
|
+
// sometimes incorrect behavior in collaborative editing.
|
182
|
+
this.serializedElem = null;
|
183
|
+
if (isNaN(element.getBBox().area)) {
|
184
|
+
throw new Error('Elements in the image cannot have NaN bounding boxes');
|
209
185
|
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
}
|
215
|
-
else {
|
216
|
-
this.applyByFlattening = false;
|
217
|
-
editor.display.flatten();
|
218
|
-
}
|
219
|
-
};
|
220
|
-
class_1.prototype.unapply = function (editor) {
|
221
|
-
editor.image.removeElementDirectly(this.element);
|
186
|
+
}
|
187
|
+
apply(editor) {
|
188
|
+
editor.image.addElementDirectly(this.element);
|
189
|
+
if (!this.applyByFlattening) {
|
222
190
|
editor.queueRerender();
|
223
|
-
};
|
224
|
-
class_1.prototype.description = function (_editor, localization) {
|
225
|
-
return localization.addElementAction(this.element.description(localization));
|
226
|
-
};
|
227
|
-
class_1.prototype.serializeToJSON = function () {
|
228
|
-
var _b;
|
229
|
-
return {
|
230
|
-
elemData: (_b = this.serializedElem) !== null && _b !== void 0 ? _b : this.element.serialize(),
|
231
|
-
};
|
232
|
-
};
|
233
|
-
return class_1;
|
234
|
-
}(SerializableCommand_1.default)),
|
235
|
-
__setFunctionName(_b, "AddElementCommand"),
|
236
|
-
(function () {
|
237
|
-
SerializableCommand_1.default.register('add-element', function (json, editor) {
|
238
|
-
var id = json.elemData.id;
|
239
|
-
var foundElem = editor.image.lookupElement(id);
|
240
|
-
var elem = foundElem !== null && foundElem !== void 0 ? foundElem : AbstractComponent_1.default.deserialize(json.elemData);
|
241
|
-
var result = new EditorImage.AddElementCommand(elem);
|
242
|
-
result.serializedElem = json.elemData;
|
243
|
-
return result;
|
244
|
-
});
|
245
|
-
})(),
|
246
|
-
_b);
|
247
|
-
// Handles resizing the background import/export region of the image.
|
248
|
-
EditorImage.SetImportExportRectCommand = (_c = /** @class */ (function (_super) {
|
249
|
-
__extends(class_2, _super);
|
250
|
-
function class_2(originalSize, originalTransform, finalRect) {
|
251
|
-
var _this = _super.call(this, EditorImage.SetImportExportRectCommand.commandId) || this;
|
252
|
-
_this.originalSize = originalSize;
|
253
|
-
_this.originalTransform = originalTransform;
|
254
|
-
_this.finalRect = finalRect;
|
255
|
-
return _this;
|
256
191
|
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
192
|
+
else {
|
193
|
+
this.applyByFlattening = false;
|
194
|
+
editor.display.flatten();
|
195
|
+
}
|
196
|
+
}
|
197
|
+
unapply(editor) {
|
198
|
+
editor.image.removeElementDirectly(this.element);
|
199
|
+
editor.queueRerender();
|
200
|
+
}
|
201
|
+
description(_editor, localization) {
|
202
|
+
return localization.addElementAction(this.element.description(localization));
|
203
|
+
}
|
204
|
+
serializeToJSON() {
|
205
|
+
return {
|
206
|
+
elemData: this.serializedElem ?? this.element.serialize(),
|
271
207
|
};
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
208
|
+
}
|
209
|
+
},
|
210
|
+
__setFunctionName(_b, "AddElementCommand"),
|
211
|
+
(() => {
|
212
|
+
SerializableCommand_1.default.register('add-element', (json, editor) => {
|
213
|
+
const id = json.elemData.id;
|
214
|
+
const foundElem = editor.image.lookupElement(id);
|
215
|
+
const elem = foundElem ?? AbstractComponent_1.default.deserialize(json.elemData);
|
216
|
+
const result = new EditorImage.AddElementCommand(elem);
|
217
|
+
result.serializedElem = json.elemData;
|
218
|
+
return result;
|
219
|
+
});
|
220
|
+
})(),
|
221
|
+
_b);
|
222
|
+
// Handles resizing the background import/export region of the image.
|
223
|
+
EditorImage.SetImportExportRectCommand = (_c = class extends SerializableCommand_1.default {
|
224
|
+
constructor(originalSize, originalTransform, finalRect) {
|
225
|
+
super(EditorImage.SetImportExportRectCommand.commandId);
|
226
|
+
this.originalSize = originalSize;
|
227
|
+
this.originalTransform = originalTransform;
|
228
|
+
this.finalRect = finalRect;
|
229
|
+
}
|
230
|
+
apply(editor) {
|
231
|
+
const viewport = editor.image.getImportExportViewport();
|
232
|
+
viewport.updateScreenSize(this.finalRect.size);
|
233
|
+
viewport.resetTransform(math_1.Mat33.translation(this.finalRect.topLeft.times(-1)));
|
234
|
+
editor.queueRerender();
|
235
|
+
}
|
236
|
+
unapply(editor) {
|
237
|
+
const viewport = editor.image.getImportExportViewport();
|
238
|
+
viewport.updateScreenSize(this.originalSize);
|
239
|
+
viewport.resetTransform(this.originalTransform);
|
240
|
+
editor.queueRerender();
|
241
|
+
}
|
242
|
+
description(_editor, localization) {
|
243
|
+
return localization.resizeOutputCommand(this.finalRect);
|
244
|
+
}
|
245
|
+
serializeToJSON() {
|
246
|
+
return {
|
247
|
+
originalSize: this.originalSize.xy,
|
248
|
+
originalTransform: this.originalTransform.toArray(),
|
249
|
+
newRegion: {
|
250
|
+
x: this.finalRect.x,
|
251
|
+
y: this.finalRect.y,
|
252
|
+
w: this.finalRect.w,
|
253
|
+
h: this.finalRect.h,
|
254
|
+
},
|
283
255
|
};
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
return EditorImage;
|
308
|
-
}());
|
256
|
+
}
|
257
|
+
},
|
258
|
+
__setFunctionName(_c, "SetImportExportRectCommand"),
|
259
|
+
_c.commandId = 'set-import-export-rect',
|
260
|
+
(() => {
|
261
|
+
const commandId = _c.commandId;
|
262
|
+
SerializableCommand_1.default.register(commandId, (json, _editor) => {
|
263
|
+
(0, assertions_1.assertIsNumber)(json.originalSize.x);
|
264
|
+
(0, assertions_1.assertIsNumber)(json.originalSize.y);
|
265
|
+
(0, assertions_1.assertIsNumberArray)(json.originalTransform);
|
266
|
+
(0, assertions_1.assertIsNumberArray)([
|
267
|
+
json.newRegion.x,
|
268
|
+
json.newRegion.y,
|
269
|
+
json.newRegion.w,
|
270
|
+
json.newRegion.h,
|
271
|
+
]);
|
272
|
+
const originalSize = math_1.Vec2.ofXY(json.originalSize);
|
273
|
+
const originalTransform = new math_1.Mat33(...json.originalTransform);
|
274
|
+
const finalRect = new math_1.Rect2(json.newRegion.x, json.newRegion.y, json.newRegion.w, json.newRegion.h);
|
275
|
+
return new EditorImage.SetImportExportRectCommand(originalSize, originalTransform, finalRect);
|
276
|
+
});
|
277
|
+
})(),
|
278
|
+
_c);
|
309
279
|
exports.default = EditorImage;
|
310
280
|
/** Part of the Editor's image. @internal */
|
311
|
-
|
312
|
-
|
313
|
-
if (parent === void 0) { parent = null; }
|
281
|
+
class ImageNode {
|
282
|
+
constructor(parent = null) {
|
314
283
|
this.parent = parent;
|
315
284
|
this.targetChildCount = 30;
|
316
285
|
this.children = [];
|
317
|
-
this.bbox =
|
286
|
+
this.bbox = math_1.Rect2.empty;
|
318
287
|
this.content = null;
|
319
288
|
this.id = ImageNode.idCounter++;
|
320
289
|
}
|
321
|
-
|
290
|
+
getId() {
|
322
291
|
return this.id;
|
323
|
-
}
|
324
|
-
|
292
|
+
}
|
293
|
+
onContentChange() {
|
325
294
|
this.id = ImageNode.idCounter++;
|
326
|
-
}
|
327
|
-
|
295
|
+
}
|
296
|
+
getContent() {
|
328
297
|
return this.content;
|
329
|
-
}
|
330
|
-
|
298
|
+
}
|
299
|
+
getParent() {
|
331
300
|
return this.parent;
|
332
|
-
}
|
333
|
-
|
334
|
-
return this.children.filter(
|
301
|
+
}
|
302
|
+
getChildrenIntersectingRegion(region) {
|
303
|
+
return this.children.filter(child => {
|
335
304
|
return child.getBBox().intersects(region);
|
336
305
|
});
|
337
|
-
}
|
338
|
-
|
306
|
+
}
|
307
|
+
getChildrenOrSelfIntersectingRegion(region) {
|
339
308
|
if (this.content) {
|
340
309
|
return [this];
|
341
310
|
}
|
342
311
|
return this.getChildrenIntersectingRegion(region);
|
343
|
-
}
|
312
|
+
}
|
344
313
|
// Returns a list of `ImageNode`s with content (and thus no children).
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
314
|
+
getLeavesIntersectingRegion(region, isTooSmall) {
|
315
|
+
const result = [];
|
316
|
+
let current;
|
317
|
+
const workList = [];
|
349
318
|
workList.push(this);
|
350
|
-
|
319
|
+
const toNext = () => {
|
351
320
|
current = undefined;
|
352
|
-
|
353
|
-
if (next && !
|
321
|
+
const next = workList.pop();
|
322
|
+
if (next && !isTooSmall?.(next.bbox)) {
|
354
323
|
current = next;
|
355
324
|
if (current.content !== null && current.getBBox().intersection(region)) {
|
356
325
|
result.push(current);
|
357
326
|
}
|
358
|
-
workList.push
|
327
|
+
workList.push(...current.getChildrenIntersectingRegion(region));
|
359
328
|
}
|
360
329
|
};
|
361
330
|
while (workList.length > 0) {
|
362
331
|
toNext();
|
363
332
|
}
|
364
333
|
return result;
|
365
|
-
}
|
334
|
+
}
|
366
335
|
// Returns the child of this with the target content or `null` if no
|
367
336
|
// such child exists.
|
368
|
-
|
369
|
-
|
370
|
-
for (
|
371
|
-
var candidate = candidates_1[_i];
|
337
|
+
getChildWithContent(target) {
|
338
|
+
const candidates = this.getLeavesIntersectingRegion(target.getBBox());
|
339
|
+
for (const candidate of candidates) {
|
372
340
|
if (candidate.getContent() === target) {
|
373
341
|
return candidate;
|
374
342
|
}
|
375
343
|
}
|
376
344
|
return null;
|
377
|
-
}
|
345
|
+
}
|
378
346
|
// Returns a list of leaves with this as an ancestor.
|
379
347
|
// Like getLeavesInRegion, but does not check whether ancestors are in a given rectangle
|
380
|
-
|
348
|
+
getLeaves() {
|
381
349
|
if (this.content) {
|
382
350
|
return [this];
|
383
351
|
}
|
384
|
-
|
385
|
-
for (
|
386
|
-
|
387
|
-
result.push.apply(result, child.getLeaves());
|
352
|
+
const result = [];
|
353
|
+
for (const child of this.children) {
|
354
|
+
result.push(...child.getLeaves());
|
388
355
|
}
|
389
356
|
return result;
|
390
|
-
}
|
391
|
-
|
357
|
+
}
|
358
|
+
addLeaf(leaf) {
|
392
359
|
this.onContentChange();
|
393
360
|
if (this.content === null && this.children.length === 0) {
|
394
361
|
this.content = leaf;
|
@@ -397,7 +364,7 @@ var ImageNode = exports.ImageNode = /** @class */ (function () {
|
|
397
364
|
}
|
398
365
|
if (this.content !== null) {
|
399
366
|
console.assert(this.children.length === 0);
|
400
|
-
|
367
|
+
const contentNode = new ImageNode(this);
|
401
368
|
contentNode.content = this.content;
|
402
369
|
this.content = null;
|
403
370
|
this.children.push(contentNode);
|
@@ -405,14 +372,14 @@ var ImageNode = exports.ImageNode = /** @class */ (function () {
|
|
405
372
|
}
|
406
373
|
// If this node is contained within the leaf, make this and the leaf
|
407
374
|
// share a parent.
|
408
|
-
|
375
|
+
const leafBBox = leaf.getBBox();
|
409
376
|
if (leafBBox.containsRect(this.getBBox())) {
|
410
|
-
|
377
|
+
const nodeForNewLeaf = new ImageNode(this);
|
411
378
|
if (this.children.length < this.targetChildCount) {
|
412
379
|
this.children.push(nodeForNewLeaf);
|
413
380
|
}
|
414
381
|
else {
|
415
|
-
|
382
|
+
const nodeForChildren = new ImageNode(this);
|
416
383
|
nodeForChildren.children = this.children;
|
417
384
|
this.children = [nodeForNewLeaf, nodeForChildren];
|
418
385
|
nodeForChildren.recomputeBBox(true);
|
@@ -420,58 +387,55 @@ var ImageNode = exports.ImageNode = /** @class */ (function () {
|
|
420
387
|
}
|
421
388
|
return nodeForNewLeaf.addLeaf(leaf);
|
422
389
|
}
|
423
|
-
|
390
|
+
const containingNodes = this.children.filter(child => child.getBBox().containsRect(leafBBox));
|
424
391
|
// Does the leaf already fit within one of the children?
|
425
392
|
if (containingNodes.length > 0 && this.children.length >= this.targetChildCount) {
|
426
393
|
// Sort the containers in ascending order by area
|
427
|
-
containingNodes.sort(
|
394
|
+
containingNodes.sort((a, b) => a.getBBox().area - b.getBBox().area);
|
428
395
|
// Choose the smallest child that contains the new element.
|
429
|
-
|
396
|
+
const result = containingNodes[0].addLeaf(leaf);
|
430
397
|
result.rebalance();
|
431
398
|
return result;
|
432
399
|
}
|
433
|
-
|
400
|
+
const newNode = new ImageNode(this);
|
434
401
|
this.children.push(newNode);
|
435
402
|
newNode.content = leaf;
|
436
403
|
newNode.recomputeBBox(true);
|
437
404
|
return newNode;
|
438
|
-
}
|
439
|
-
|
405
|
+
}
|
406
|
+
getBBox() {
|
440
407
|
return this.bbox;
|
441
|
-
}
|
408
|
+
}
|
442
409
|
// Recomputes this' bounding box. If [bubbleUp], also recompute
|
443
410
|
// this' ancestors bounding boxes. This also re-computes this' bounding box
|
444
411
|
// in the z-direction (z-indicies).
|
445
|
-
|
446
|
-
|
447
|
-
var oldBBox = this.bbox;
|
412
|
+
recomputeBBox(bubbleUp) {
|
413
|
+
const oldBBox = this.bbox;
|
448
414
|
if (this.content !== null) {
|
449
415
|
this.bbox = this.content.getBBox();
|
450
416
|
}
|
451
417
|
else {
|
452
|
-
this.bbox =
|
418
|
+
this.bbox = math_1.Rect2.union(...this.children.map(child => child.getBBox()));
|
453
419
|
}
|
454
420
|
if (bubbleUp && !oldBBox.eq(this.bbox)) {
|
455
|
-
|
421
|
+
this.parent?.recomputeBBox(true);
|
456
422
|
}
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
for (var _i = 0, _b = this.children; _i < _b.length; _i++) {
|
461
|
-
var child = _b[_i];
|
423
|
+
}
|
424
|
+
updateParents(recursive = false) {
|
425
|
+
for (const child of this.children) {
|
462
426
|
child.parent = this;
|
463
427
|
if (recursive) {
|
464
428
|
child.updateParents(recursive);
|
465
429
|
}
|
466
430
|
}
|
467
|
-
}
|
468
|
-
|
431
|
+
}
|
432
|
+
rebalance() {
|
469
433
|
// If the current node is its parent's only child,
|
470
434
|
if (this.parent && this.parent.children.length === 1) {
|
471
435
|
console.assert(this.parent.content === null);
|
472
436
|
console.assert(this.parent.children[0] === this);
|
473
437
|
// Remove this' parent, if this' parent isn't the root.
|
474
|
-
|
438
|
+
const oldParent = this.parent;
|
475
439
|
if (oldParent.parent !== null) {
|
476
440
|
oldParent.children = [];
|
477
441
|
this.parent = oldParent.parent;
|
@@ -486,23 +450,21 @@ var ImageNode = exports.ImageNode = /** @class */ (function () {
|
|
486
450
|
this.parent = null;
|
487
451
|
}
|
488
452
|
}
|
489
|
-
}
|
453
|
+
}
|
490
454
|
// Remove this node and all of its children
|
491
|
-
|
492
|
-
|
493
|
-
var _b;
|
494
|
-
(_b = this.content) === null || _b === void 0 ? void 0 : _b.onRemoveFromImage();
|
455
|
+
remove() {
|
456
|
+
this.content?.onRemoveFromImage();
|
495
457
|
if (!this.parent) {
|
496
458
|
this.content = null;
|
497
459
|
this.children = [];
|
498
460
|
return;
|
499
461
|
}
|
500
|
-
|
501
|
-
this.parent.children = this.parent.children.filter(
|
502
|
-
return node !==
|
462
|
+
const oldChildCount = this.parent.children.length;
|
463
|
+
this.parent.children = this.parent.children.filter(node => {
|
464
|
+
return node !== this;
|
503
465
|
});
|
504
|
-
console.assert(this.parent.children.length === oldChildCount - 1,
|
505
|
-
this.parent.children.forEach(
|
466
|
+
console.assert(this.parent.children.length === oldChildCount - 1, `${oldChildCount - 1} ≠ ${this.parent.children.length} after removing all nodes equal to ${this}. Nodes should only be removed once.`);
|
467
|
+
this.parent.children.forEach(child => {
|
506
468
|
child.rebalance();
|
507
469
|
});
|
508
470
|
this.parent.recomputeBBox(true);
|
@@ -510,22 +472,21 @@ var ImageNode = exports.ImageNode = /** @class */ (function () {
|
|
510
472
|
this.content = null;
|
511
473
|
this.parent = null;
|
512
474
|
this.children = [];
|
513
|
-
}
|
514
|
-
|
515
|
-
|
475
|
+
}
|
476
|
+
render(renderer, visibleRect) {
|
477
|
+
let leaves;
|
516
478
|
if (visibleRect) {
|
517
|
-
leaves = this.getLeavesIntersectingRegion(visibleRect,
|
479
|
+
leaves = this.getLeavesIntersectingRegion(visibleRect, rect => renderer.isTooSmallToRender(rect));
|
518
480
|
}
|
519
481
|
else {
|
520
482
|
leaves = this.getLeaves();
|
521
483
|
}
|
522
484
|
(0, exports.sortLeavesByZIndex)(leaves);
|
523
|
-
for (
|
524
|
-
var leaf = leaves_2[_i];
|
485
|
+
for (const leaf of leaves) {
|
525
486
|
// Leaves by definition have content
|
526
487
|
leaf.getContent().render(renderer, visibleRect);
|
527
488
|
}
|
528
|
-
}
|
529
|
-
|
530
|
-
|
531
|
-
|
489
|
+
}
|
490
|
+
}
|
491
|
+
exports.ImageNode = ImageNode;
|
492
|
+
ImageNode.idCounter = 0;
|