js-draw 1.21.2 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +103 -75
- package/build-config.json +2 -2
- package/dist/Editor.css +29 -16
- package/dist/bundle.js +2 -2
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.js +36 -22
- package/dist/cjs/EventDispatcher.js +1 -1
- package/dist/cjs/Pointer.js +3 -3
- package/dist/cjs/SVGLoader/SVGLoader.js +13 -6
- package/dist/cjs/UndoRedoHistory.js +1 -1
- package/dist/cjs/Viewport.js +4 -2
- package/dist/cjs/commands/Command.js +7 -5
- package/dist/cjs/commands/Duplicate.js +2 -2
- package/dist/cjs/commands/Erase.js +3 -4
- package/dist/cjs/commands/invertCommand.js +4 -4
- package/dist/cjs/commands/lib.d.ts +1 -1
- package/dist/cjs/commands/uniteCommands.js +4 -4
- package/dist/cjs/components/AbstractComponent.d.ts +1 -1
- package/dist/cjs/components/AbstractComponent.js +3 -3
- package/dist/cjs/components/BackgroundComponent.js +8 -6
- package/dist/cjs/components/ImageComponent.js +12 -5
- package/dist/cjs/components/RestylableComponent.js +1 -1
- package/dist/cjs/components/SVGGlobalAttributesObject.js +1 -2
- package/dist/cjs/components/Stroke.js +37 -24
- package/dist/cjs/components/TextComponent.js +13 -10
- package/dist/cjs/components/UnknownSVGObject.js +2 -3
- package/dist/cjs/components/builders/ArrowBuilder.d.ts +6 -0
- package/dist/cjs/components/builders/ArrowBuilder.js +9 -3
- package/dist/cjs/components/builders/CircleBuilder.d.ts +6 -0
- package/dist/cjs/components/builders/CircleBuilder.js +11 -4
- package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +6 -0
- package/dist/cjs/components/builders/FreehandLineBuilder.js +10 -4
- package/dist/cjs/components/builders/LineBuilder.d.ts +6 -0
- package/dist/cjs/components/builders/LineBuilder.js +8 -4
- package/dist/cjs/components/builders/PolylineBuilder.d.ts +4 -1
- package/dist/cjs/components/builders/PolylineBuilder.js +9 -5
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +16 -10
- package/dist/cjs/components/builders/RectangleBuilder.d.ts +12 -0
- package/dist/cjs/components/builders/RectangleBuilder.js +17 -3
- package/dist/cjs/components/builders/autocorrect/makeShapeFitAutocorrect.js +5 -8
- package/dist/cjs/components/builders/autocorrect/makeSnapToGridAutocorrect.js +1 -1
- package/dist/cjs/components/builders/lib.d.ts +7 -0
- package/dist/cjs/components/builders/lib.js +18 -0
- package/dist/cjs/components/lib.d.ts +1 -4
- package/dist/cjs/components/lib.js +2 -9
- package/dist/cjs/components/util/StrokeSmoother.js +5 -6
- package/dist/cjs/dialogs/makeAboutDialog.js +1 -1
- package/dist/cjs/dialogs/makeMessageDialog.js +2 -2
- package/dist/cjs/image/EditorImage.js +13 -15
- package/dist/cjs/image/export/editorImageToSVG.js +1 -1
- package/dist/cjs/inputEvents.js +3 -3
- package/dist/cjs/lib.d.ts +2 -2
- package/dist/cjs/localizations/de.js +2 -2
- package/dist/cjs/localizations/es.js +7 -3
- package/dist/cjs/rendering/Display.js +7 -3
- package/dist/cjs/rendering/RenderablePathSpec.js +26 -11
- package/dist/cjs/rendering/RenderingStyle.js +22 -15
- package/dist/cjs/rendering/TextRenderingStyle.js +1 -1
- package/dist/cjs/rendering/caching/CacheRecord.js +1 -1
- package/dist/cjs/rendering/caching/CacheRecordManager.js +1 -1
- package/dist/cjs/rendering/caching/RenderingCache.js +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +26 -15
- package/dist/cjs/rendering/caching/testUtils.js +2 -2
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +3 -1
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +4 -3
- package/dist/cjs/rendering/renderers/DummyRenderer.js +1 -1
- package/dist/cjs/rendering/renderers/SVGRenderer.js +37 -19
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +13 -15
- package/dist/cjs/shortcuts/KeyBinding.js +6 -12
- package/dist/cjs/shortcuts/KeyboardShortcutManager.js +2 -2
- package/dist/cjs/testing/createEditor.js +6 -1
- package/dist/cjs/testing/findNodeWithText.d.ts +4 -1
- package/dist/cjs/testing/findNodeWithText.js +12 -3
- package/dist/cjs/testing/getUniquePointerId.js +1 -1
- package/dist/cjs/testing/sendHtmlSwipe.js +7 -3
- package/dist/cjs/testing/sendPenEvent.js +1 -3
- package/dist/cjs/testing/sendTouchEvent.js +1 -4
- package/dist/cjs/testing/startPinchGesture.js +3 -1
- package/dist/cjs/toolbar/AbstractToolbar.js +7 -11
- package/dist/cjs/toolbar/EdgeToolbar.js +11 -15
- package/dist/cjs/toolbar/IconProvider.js +5 -3
- package/dist/cjs/toolbar/localization.js +3 -3
- package/dist/cjs/toolbar/utils/HelpDisplay.js +8 -6
- package/dist/cjs/toolbar/utils/makeDraggable.js +4 -7
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +3 -2
- package/dist/cjs/toolbar/widgets/BaseWidget.js +7 -7
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +2 -2
- package/dist/cjs/toolbar/widgets/EraserToolWidget.js +5 -3
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +8 -6
- package/dist/cjs/toolbar/widgets/InsertImageWidget/InsertImageWidget.js +9 -10
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +22 -13
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +2 -2
- package/dist/cjs/toolbar/widgets/TextToolWidget.js +5 -5
- package/dist/cjs/toolbar/widgets/components/makeFileInput.js +7 -7
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.js +5 -5
- package/dist/cjs/toolbar/widgets/components/makeSnappedList.js +9 -5
- package/dist/cjs/toolbar/widgets/keybindings.js +2 -2
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.js +6 -6
- package/dist/cjs/tools/BaseTool.d.ts +61 -0
- package/dist/cjs/tools/BaseTool.js +181 -0
- package/dist/cjs/tools/Eraser.d.ts +60 -0
- package/dist/cjs/tools/Eraser.js +304 -0
- package/dist/cjs/tools/Eraser.test.d.ts +1 -0
- package/dist/cjs/tools/FindTool.d.ts +21 -0
- package/dist/cjs/tools/FindTool.js +137 -0
- package/dist/cjs/tools/FindTool.test.d.ts +1 -0
- package/dist/cjs/tools/InputFilter/ContextMenuRecognizer.d.ts +17 -0
- package/dist/cjs/tools/InputFilter/ContextMenuRecognizer.js +103 -0
- package/dist/cjs/tools/InputFilter/ContextMenuRecognizer.test.d.ts +1 -0
- 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/InputPipeline.test.d.ts +1 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.js +188 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +87 -0
- package/dist/cjs/tools/PanZoom.d.ts +125 -0
- package/dist/cjs/tools/PanZoom.js +522 -0
- package/dist/cjs/tools/PanZoom.test.d.ts +1 -0
- package/dist/cjs/tools/PasteHandler.d.ts +23 -0
- package/dist/cjs/tools/PasteHandler.js +115 -0
- package/dist/cjs/tools/Pen.d.ts +54 -0
- package/dist/cjs/tools/Pen.js +343 -0
- package/dist/cjs/tools/Pen.test.d.ts +1 -0
- package/dist/cjs/tools/PipetteTool.d.ts +28 -0
- package/dist/cjs/tools/PipetteTool.js +69 -0
- package/dist/cjs/tools/ScrollbarTool.d.ts +18 -0
- package/dist/cjs/tools/ScrollbarTool.js +86 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +9 -0
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +32 -0
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +72 -0
- package/dist/cjs/tools/SelectionTool/Selection.js +638 -0
- package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +62 -0
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +144 -0
- package/dist/cjs/tools/SelectionTool/SelectionMenuShortcut.d.ts +32 -0
- package/dist/cjs/tools/SelectionTool/SelectionMenuShortcut.js +88 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +42 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +509 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.selecting.test.d.ts +1 -0
- package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +1 -0
- package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.d.ts +23 -0
- package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.js +83 -0
- package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +42 -0
- package/dist/cjs/tools/SelectionTool/TransformMode.js +154 -0
- package/dist/cjs/tools/SelectionTool/keybindings.d.ts +15 -0
- package/dist/cjs/tools/SelectionTool/keybindings.js +38 -0
- package/dist/cjs/tools/SelectionTool/types.d.ts +35 -0
- package/dist/cjs/tools/SelectionTool/types.js +14 -0
- package/dist/cjs/tools/SelectionTool/util/makeClipboardErrorHandlers.d.ts +6 -0
- package/dist/cjs/tools/SelectionTool/util/makeClipboardErrorHandlers.js +71 -0
- package/dist/cjs/tools/SelectionTool/util/showSelectionContextMenu.d.ts +5 -0
- package/dist/cjs/tools/SelectionTool/util/showSelectionContextMenu.js +52 -0
- package/dist/cjs/tools/SoundUITool.d.ts +26 -0
- package/dist/cjs/tools/SoundUITool.js +173 -0
- package/dist/cjs/tools/TextTool.d.ts +36 -0
- package/dist/cjs/tools/TextTool.js +287 -0
- package/dist/cjs/tools/TextTool.test.d.ts +1 -0
- package/dist/cjs/tools/ToolController.d.ts +73 -0
- package/dist/cjs/tools/ToolController.js +310 -0
- package/dist/cjs/tools/ToolController.test.d.ts +1 -0
- package/dist/cjs/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/cjs/tools/ToolEnabledGroup.js +13 -0
- package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/cjs/tools/ToolSwitcherShortcut.js +40 -0
- package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/cjs/tools/ToolbarShortcutHandler.js +34 -0
- package/dist/cjs/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/cjs/tools/UndoRedoShortcut.js +27 -0
- package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +1 -0
- package/dist/cjs/tools/keybindings.d.ts +16 -0
- package/dist/cjs/tools/keybindings.js +58 -0
- package/dist/cjs/tools/lib.d.ts +14 -0
- package/dist/cjs/tools/lib.js +36 -0
- package/dist/cjs/tools/localization.d.ts +45 -0
- package/dist/cjs/tools/localization.js +47 -0
- package/dist/cjs/tools/util/StationaryPenDetector.d.ts +25 -0
- package/dist/cjs/tools/util/StationaryPenDetector.js +107 -0
- package/dist/cjs/tools/util/createMenuOverlay.d.ts +10 -0
- package/dist/cjs/tools/util/createMenuOverlay.js +126 -0
- package/dist/cjs/tools/util/createMenuOverlay.test.d.ts +1 -0
- package/dist/cjs/util/ClipboardHandler.d.ts +1 -1
- package/dist/cjs/util/ClipboardHandler.js +19 -18
- package/dist/cjs/util/ReactiveValue.js +16 -12
- package/dist/cjs/util/adjustEditorThemeForContrast.js +6 -2
- package/dist/cjs/util/guessKeyCodeFromKey.js +1 -1
- package/dist/cjs/util/listenForKeyboardEventsFrom.js +8 -6
- package/dist/cjs/util/waitForAll.js +3 -3
- package/dist/cjs/util/waitForImageLoaded.js +3 -3
- package/dist/cjs/util/waitForTimeout.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/Editor.mjs +37 -23
- package/dist/mjs/EventDispatcher.mjs +1 -1
- package/dist/mjs/Pointer.mjs +3 -3
- package/dist/mjs/SVGLoader/SVGLoader.mjs +14 -7
- package/dist/mjs/UndoRedoHistory.mjs +1 -1
- package/dist/mjs/Viewport.mjs +4 -2
- package/dist/mjs/commands/Command.mjs +7 -5
- package/dist/mjs/commands/Duplicate.mjs +2 -2
- package/dist/mjs/commands/Erase.mjs +3 -4
- package/dist/mjs/commands/invertCommand.mjs +4 -4
- package/dist/mjs/commands/lib.d.ts +1 -1
- package/dist/mjs/commands/lib.mjs +1 -1
- package/dist/mjs/commands/uniteCommands.mjs +4 -4
- package/dist/mjs/components/AbstractComponent.d.ts +1 -1
- package/dist/mjs/components/AbstractComponent.mjs +3 -3
- package/dist/mjs/components/BackgroundComponent.mjs +10 -8
- package/dist/mjs/components/ImageComponent.mjs +12 -5
- package/dist/mjs/components/RestylableComponent.mjs +2 -2
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +1 -2
- package/dist/mjs/components/Stroke.mjs +40 -27
- package/dist/mjs/components/TextComponent.mjs +15 -12
- package/dist/mjs/components/UnknownSVGObject.mjs +2 -3
- package/dist/mjs/components/builders/ArrowBuilder.d.ts +6 -0
- package/dist/mjs/components/builders/ArrowBuilder.mjs +9 -3
- package/dist/mjs/components/builders/CircleBuilder.d.ts +6 -0
- package/dist/mjs/components/builders/CircleBuilder.mjs +11 -4
- package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +6 -0
- package/dist/mjs/components/builders/FreehandLineBuilder.mjs +10 -4
- package/dist/mjs/components/builders/LineBuilder.d.ts +6 -0
- package/dist/mjs/components/builders/LineBuilder.mjs +8 -4
- package/dist/mjs/components/builders/PolylineBuilder.d.ts +4 -1
- package/dist/mjs/components/builders/PolylineBuilder.mjs +10 -6
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +17 -11
- package/dist/mjs/components/builders/RectangleBuilder.d.ts +12 -0
- package/dist/mjs/components/builders/RectangleBuilder.mjs +17 -3
- package/dist/mjs/components/builders/autocorrect/makeShapeFitAutocorrect.mjs +5 -8
- package/dist/mjs/components/builders/autocorrect/makeSnapToGridAutocorrect.mjs +1 -1
- package/dist/mjs/components/builders/lib.d.ts +7 -0
- package/dist/mjs/components/builders/lib.mjs +7 -0
- package/dist/mjs/components/lib.d.ts +1 -4
- package/dist/mjs/components/lib.mjs +2 -5
- package/dist/mjs/components/util/StrokeSmoother.mjs +5 -6
- package/dist/mjs/dialogs/makeAboutDialog.mjs +1 -1
- package/dist/mjs/dialogs/makeMessageDialog.mjs +2 -2
- package/dist/mjs/image/EditorImage.mjs +13 -15
- package/dist/mjs/image/export/editorImageToSVG.mjs +1 -1
- package/dist/mjs/inputEvents.mjs +3 -3
- package/dist/mjs/lib.d.ts +2 -2
- package/dist/mjs/lib.mjs +2 -2
- package/dist/mjs/localization.mjs +2 -2
- package/dist/mjs/localizations/de.mjs +2 -2
- package/dist/mjs/localizations/es.mjs +7 -3
- package/dist/mjs/rendering/Display.mjs +7 -3
- package/dist/mjs/rendering/RenderablePathSpec.mjs +26 -11
- package/dist/mjs/rendering/RenderingStyle.mjs +22 -15
- package/dist/mjs/rendering/TextRenderingStyle.mjs +1 -1
- package/dist/mjs/rendering/caching/CacheRecord.mjs +1 -1
- package/dist/mjs/rendering/caching/CacheRecordManager.mjs +1 -1
- package/dist/mjs/rendering/caching/RenderingCache.mjs +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +26 -15
- package/dist/mjs/rendering/caching/testUtils.mjs +2 -2
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +3 -1
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +4 -3
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +1 -1
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +38 -20
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +13 -15
- package/dist/mjs/shortcuts/KeyBinding.mjs +6 -12
- package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +2 -2
- package/dist/mjs/testing/createEditor.mjs +6 -1
- package/dist/mjs/testing/findNodeWithText.d.ts +4 -1
- package/dist/mjs/testing/findNodeWithText.mjs +12 -3
- package/dist/mjs/testing/getUniquePointerId.mjs +1 -1
- package/dist/mjs/testing/sendHtmlSwipe.mjs +7 -3
- package/dist/mjs/testing/sendPenEvent.mjs +1 -3
- package/dist/mjs/testing/sendTouchEvent.mjs +1 -4
- package/dist/mjs/testing/startPinchGesture.mjs +3 -1
- package/dist/mjs/toolbar/AbstractToolbar.mjs +7 -11
- package/dist/mjs/toolbar/EdgeToolbar.mjs +11 -15
- package/dist/mjs/toolbar/IconProvider.mjs +5 -3
- package/dist/mjs/toolbar/localization.mjs +3 -3
- package/dist/mjs/toolbar/utils/HelpDisplay.mjs +8 -6
- package/dist/mjs/toolbar/utils/makeDraggable.mjs +4 -7
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +3 -2
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +8 -8
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +2 -2
- package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +5 -3
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +8 -6
- package/dist/mjs/toolbar/widgets/InsertImageWidget/InsertImageWidget.mjs +9 -10
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +23 -14
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +2 -2
- package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +5 -5
- package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +7 -7
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.mjs +5 -5
- package/dist/mjs/toolbar/widgets/components/makeSnappedList.mjs +9 -5
- package/dist/mjs/toolbar/widgets/keybindings.mjs +2 -2
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.mjs +6 -6
- package/dist/mjs/tools/BaseTool.d.ts +61 -0
- package/dist/mjs/tools/BaseTool.mjs +179 -0
- package/dist/mjs/tools/Eraser.d.ts +60 -0
- package/dist/mjs/tools/Eraser.mjs +297 -0
- package/dist/mjs/tools/Eraser.test.d.ts +1 -0
- package/dist/mjs/tools/FindTool.d.ts +21 -0
- package/dist/mjs/tools/FindTool.mjs +131 -0
- package/dist/mjs/tools/FindTool.test.d.ts +1 -0
- package/dist/mjs/tools/InputFilter/ContextMenuRecognizer.d.ts +17 -0
- package/dist/mjs/tools/InputFilter/ContextMenuRecognizer.mjs +74 -0
- package/dist/mjs/tools/InputFilter/ContextMenuRecognizer.test.d.ts +1 -0
- 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/InputPipeline.test.d.ts +1 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +182 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +81 -0
- package/dist/mjs/tools/PanZoom.d.ts +125 -0
- package/dist/mjs/tools/PanZoom.mjs +515 -0
- package/dist/mjs/tools/PanZoom.test.d.ts +1 -0
- package/dist/mjs/tools/PasteHandler.d.ts +23 -0
- package/dist/mjs/tools/PasteHandler.mjs +109 -0
- package/dist/mjs/tools/Pen.d.ts +54 -0
- package/dist/mjs/tools/Pen.mjs +314 -0
- package/dist/mjs/tools/Pen.test.d.ts +1 -0
- package/dist/mjs/tools/PipetteTool.d.ts +28 -0
- package/dist/mjs/tools/PipetteTool.mjs +63 -0
- package/dist/mjs/tools/ScrollbarTool.d.ts +18 -0
- package/dist/mjs/tools/ScrollbarTool.mjs +80 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +9 -0
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +26 -0
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +72 -0
- package/dist/mjs/tools/SelectionTool/Selection.mjs +610 -0
- package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +62 -0
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +140 -0
- package/dist/mjs/tools/SelectionTool/SelectionMenuShortcut.d.ts +32 -0
- package/dist/mjs/tools/SelectionTool/SelectionMenuShortcut.mjs +85 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +42 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +502 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.selecting.test.d.ts +1 -0
- package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +1 -0
- package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.d.ts +23 -0
- package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.mjs +77 -0
- package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +42 -0
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +145 -0
- package/dist/mjs/tools/SelectionTool/keybindings.d.ts +15 -0
- package/dist/mjs/tools/SelectionTool/keybindings.mjs +32 -0
- package/dist/mjs/tools/SelectionTool/types.d.ts +35 -0
- package/dist/mjs/tools/SelectionTool/types.mjs +11 -0
- package/dist/mjs/tools/SelectionTool/util/makeClipboardErrorHandlers.d.ts +6 -0
- package/dist/mjs/tools/SelectionTool/util/makeClipboardErrorHandlers.mjs +66 -0
- package/dist/mjs/tools/SelectionTool/util/showSelectionContextMenu.d.ts +5 -0
- package/dist/mjs/tools/SelectionTool/util/showSelectionContextMenu.mjs +47 -0
- package/dist/mjs/tools/SoundUITool.d.ts +26 -0
- package/dist/mjs/tools/SoundUITool.mjs +167 -0
- package/dist/mjs/tools/TextTool.d.ts +36 -0
- package/dist/mjs/tools/TextTool.mjs +281 -0
- package/dist/mjs/tools/TextTool.test.d.ts +1 -0
- package/dist/mjs/tools/ToolController.d.ts +73 -0
- package/dist/mjs/tools/ToolController.mjs +281 -0
- package/dist/mjs/tools/ToolController.test.d.ts +1 -0
- package/dist/mjs/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/mjs/tools/ToolEnabledGroup.mjs +10 -0
- package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +34 -0
- package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/mjs/tools/ToolbarShortcutHandler.mjs +28 -0
- package/dist/mjs/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/mjs/tools/UndoRedoShortcut.mjs +21 -0
- package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +1 -0
- package/dist/mjs/tools/keybindings.d.ts +16 -0
- package/dist/mjs/tools/keybindings.mjs +38 -0
- package/dist/mjs/tools/lib.d.ts +14 -0
- package/dist/mjs/tools/lib.mjs +14 -0
- package/dist/mjs/tools/localization.d.ts +45 -0
- package/dist/mjs/tools/localization.mjs +44 -0
- package/dist/mjs/tools/util/StationaryPenDetector.d.ts +25 -0
- package/dist/mjs/tools/util/StationaryPenDetector.mjs +103 -0
- package/dist/mjs/tools/util/createMenuOverlay.d.ts +10 -0
- package/dist/mjs/tools/util/createMenuOverlay.mjs +121 -0
- package/dist/mjs/tools/util/createMenuOverlay.test.d.ts +1 -0
- package/dist/mjs/util/ClipboardHandler.d.ts +1 -1
- package/dist/mjs/util/ClipboardHandler.mjs +19 -18
- package/dist/mjs/util/ReactiveValue.mjs +16 -12
- package/dist/mjs/util/adjustEditorThemeForContrast.mjs +6 -2
- package/dist/mjs/util/guessKeyCodeFromKey.mjs +1 -1
- package/dist/mjs/util/listenForKeyboardEventsFrom.mjs +8 -6
- package/dist/mjs/util/waitForAll.mjs +3 -3
- package/dist/mjs/util/waitForImageLoaded.mjs +3 -3
- package/dist/mjs/util/waitForTimeout.mjs +1 -1
- package/dist/mjs/version.mjs +1 -1
- package/package.json +88 -88
- package/src/Coloris.css +6 -6
- package/src/Editor.scss +7 -5
- package/src/dialogs/dialogs.scss +3 -4
- package/src/dialogs/makeAboutDialog.scss +2 -2
- package/src/dialogs/makeMessageDialog.scss +11 -7
- package/src/styles.js +1 -1
- package/src/toolbar/AbstractToolbar.scss +20 -12
- package/src/toolbar/DropdownToolbar.scss +5 -4
- package/src/toolbar/EdgeToolbar.scss +65 -31
- package/src/toolbar/toolbar.scss +5 -5
- package/src/toolbar/utils/HelpDisplay.scss +48 -25
- package/src/toolbar/utils/labelVisibleOnHover.scss +39 -16
- package/src/toolbar/widgets/DocumentPropertiesWidget.scss +0 -1
- package/src/toolbar/widgets/HandToolWidget.scss +0 -1
- package/src/toolbar/widgets/InsertImageWidget/InsertImageWidget.scss +2 -3
- package/src/toolbar/widgets/OverflowWidget.css +1 -2
- package/src/toolbar/widgets/PenToolWidget.scss +0 -2
- package/src/toolbar/widgets/SelectionToolWidget.scss +1 -2
- package/src/toolbar/widgets/components/components.scss +6 -6
- package/src/toolbar/widgets/components/makeColorInput.scss +0 -2
- package/src/toolbar/widgets/components/makeFileInput.scss +5 -7
- package/src/toolbar/widgets/components/makeGridSelector.scss +6 -9
- package/src/toolbar/widgets/components/makeSnappedList.scss +3 -4
- package/src/toolbar/widgets/components/makeThicknessSlider.scss +1 -2
- package/src/toolbar/widgets/widgets.scss +7 -7
- package/src/tools/FindTool.css +6 -0
- package/src/tools/ScrollbarTool.scss +61 -0
- package/src/tools/SelectionTool/SelectionTool.scss +173 -0
- package/src/tools/SelectionTool/util/makeClipboardErrorHandlers.scss +14 -0
- package/src/tools/SoundUITool.scss +22 -0
- package/src/tools/tools.scss +5 -0
- package/src/tools/util/createMenuOverlay.scss +73 -0
- package/tsconfig.json +1 -3
- package/typedoc.json +1 -1
@@ -121,7 +121,7 @@ class EditorImage {
|
|
121
121
|
getAllElements() {
|
122
122
|
const leaves = this.root.getLeaves();
|
123
123
|
sortLeavesByZIndex(leaves);
|
124
|
-
return leaves.map(leaf => leaf.getContent());
|
124
|
+
return leaves.map((leaf) => leaf.getContent());
|
125
125
|
}
|
126
126
|
/** Returns the number of elements added to this image. @internal */
|
127
127
|
estimateNumElements() {
|
@@ -134,7 +134,7 @@ class EditorImage {
|
|
134
134
|
leaves = leaves.concat(this.background.getLeavesIntersectingRegion(region));
|
135
135
|
}
|
136
136
|
sortLeavesByZIndex(leaves);
|
137
|
-
return leaves.map(leaf => leaf.getContent());
|
137
|
+
return leaves.map((leaf) => leaf.getContent());
|
138
138
|
}
|
139
139
|
/** Called whenever (just after) an element is completely removed. @internal */
|
140
140
|
onDestroyElement(elem) {
|
@@ -474,8 +474,8 @@ export const computeFirstIndexToRender = (sortedLeaves, visibleRect) => {
|
|
474
474
|
for (let i = sortedLeaves.length - 1; i >= 1; i--) {
|
475
475
|
if (
|
476
476
|
// Check for occlusion
|
477
|
-
sortedLeaves[i].getBBox().containsRect(visibleRect)
|
478
|
-
|
477
|
+
sortedLeaves[i].getBBox().containsRect(visibleRect) &&
|
478
|
+
sortedLeaves[i].getContent()?.occludesEverythingBelowWhenRenderedInRect(visibleRect)) {
|
479
479
|
startIndex = i;
|
480
480
|
break;
|
481
481
|
}
|
@@ -510,7 +510,7 @@ export class ImageNode {
|
|
510
510
|
}
|
511
511
|
// Override this to change how children are considered within a given region.
|
512
512
|
getChildrenIntersectingRegion(region, isTooSmallFilter) {
|
513
|
-
return this.children.filter(child => {
|
513
|
+
return this.children.filter((child) => {
|
514
514
|
const bbox = child.getBBox();
|
515
515
|
return !isTooSmallFilter?.(bbox) && bbox.intersects(region);
|
516
516
|
});
|
@@ -601,7 +601,7 @@ export class ImageNode {
|
|
601
601
|
}
|
602
602
|
return nodeForNewLeaf.addLeaf(leaf);
|
603
603
|
}
|
604
|
-
const containingNodes = this.children.filter(child => child.getBBox().containsRect(leafBBox));
|
604
|
+
const containingNodes = this.children.filter((child) => child.getBBox().containsRect(leafBBox));
|
605
605
|
// Does the leaf already fit within one of the children?
|
606
606
|
if (containingNodes.length > 0 && this.children.length >= this.targetChildCount) {
|
607
607
|
// Sort the containers in ascending order by area
|
@@ -639,7 +639,7 @@ export class ImageNode {
|
|
639
639
|
this.bbox = this.content.getBBox();
|
640
640
|
}
|
641
641
|
else {
|
642
|
-
this.bbox = Rect2.union(...this.children.map(child => child.getBBox()));
|
642
|
+
this.bbox = Rect2.union(...this.children.map((child) => child.getBBox()));
|
643
643
|
}
|
644
644
|
if (bubbleUp && !oldBBox.eq(this.bbox)) {
|
645
645
|
if (this.bbox.containsRect(oldBBox)) {
|
@@ -674,7 +674,7 @@ export class ImageNode {
|
|
674
674
|
const oldParent = this.parent;
|
675
675
|
if (oldParent.parent !== null) {
|
676
676
|
const newParent = oldParent.parent;
|
677
|
-
newParent.children = newParent.children.filter(c => c !== oldParent);
|
677
|
+
newParent.children = newParent.children.filter((c) => c !== oldParent);
|
678
678
|
oldParent.parent = null;
|
679
679
|
oldParent.children = [];
|
680
680
|
this.parent = newParent;
|
@@ -746,11 +746,11 @@ export class ImageNode {
|
|
746
746
|
removeChild(child) {
|
747
747
|
this.checkRep();
|
748
748
|
const oldChildCount = this.children.length;
|
749
|
-
this.children = this.children.filter(node => {
|
749
|
+
this.children = this.children.filter((node) => {
|
750
750
|
return node !== child;
|
751
751
|
});
|
752
752
|
console.assert(this.children.length === oldChildCount - 1, `${oldChildCount - 1} ≠ ${this.children.length} after removing all nodes equal to ${child}. Nodes should only be removed once.`);
|
753
|
-
this.children.forEach(child => {
|
753
|
+
this.children.forEach((child) => {
|
754
754
|
child.rebalance();
|
755
755
|
});
|
756
756
|
this.recomputeBBox(true);
|
@@ -799,7 +799,7 @@ export class ImageNode {
|
|
799
799
|
render(renderer, visibleRect) {
|
800
800
|
let leaves;
|
801
801
|
if (visibleRect) {
|
802
|
-
leaves = this.getLeavesIntersectingRegion(visibleRect, rect => renderer.isTooSmallToRender(rect));
|
802
|
+
leaves = this.getLeavesIntersectingRegion(visibleRect, (rect) => renderer.isTooSmallToRender(rect));
|
803
803
|
}
|
804
804
|
else {
|
805
805
|
leaves = this.getLeaves();
|
@@ -909,10 +909,8 @@ export class RootImageNode extends ImageNode {
|
|
909
909
|
};
|
910
910
|
// Check whether the child is stored in the data/fullscreen
|
911
911
|
// component arrays first.
|
912
|
-
this.dataComponents = this.dataComponents
|
913
|
-
|
914
|
-
this.fullscreenChildren = this.fullscreenChildren
|
915
|
-
.filter(checkTargetChild);
|
912
|
+
this.dataComponents = this.dataComponents.filter(checkTargetChild);
|
913
|
+
this.fullscreenChildren = this.fullscreenChildren.filter(checkTargetChild);
|
916
914
|
if (!removed) {
|
917
915
|
super.removeChild(child);
|
918
916
|
}
|
@@ -45,7 +45,7 @@ export const editorImageToSVGSync = (image, options) => {
|
|
45
45
|
}, options);
|
46
46
|
};
|
47
47
|
export const editorImageToSVGAsync = (image, preRenderComponent, options) => {
|
48
|
-
return new Promise(resolve => {
|
48
|
+
return new Promise((resolve) => {
|
49
49
|
toSVGInternal(image, async (renderer, onComplete) => {
|
50
50
|
await image.renderAllAsync(renderer, preRenderComponent);
|
51
51
|
const result = onComplete();
|
package/dist/mjs/inputEvents.mjs
CHANGED
@@ -29,7 +29,7 @@ export const keyPressEventFromHTMLEvent = (event) => {
|
|
29
29
|
return keyEventFromHTMLEvent(InputEvtType.KeyPressEvent, event);
|
30
30
|
};
|
31
31
|
export const isPointerEvt = (event) => {
|
32
|
-
return event.kind === InputEvtType.PointerDownEvt
|
33
|
-
|
34
|
-
|
32
|
+
return (event.kind === InputEvtType.PointerDownEvt ||
|
33
|
+
event.kind === InputEvtType.PointerMoveEvt ||
|
34
|
+
event.kind === InputEvtType.PointerUpEvt);
|
35
35
|
};
|
package/dist/mjs/lib.d.ts
CHANGED
@@ -18,7 +18,7 @@ import Editor, { EditorSettings } from './Editor';
|
|
18
18
|
export * from './image/lib';
|
19
19
|
export * from './types';
|
20
20
|
export * from './inputEvents';
|
21
|
-
export { default as getLocalizationTable, matchingLocalizationTable } from './localizations/getLocalizationTable';
|
21
|
+
export { default as getLocalizationTable, matchingLocalizationTable, } from './localizations/getLocalizationTable';
|
22
22
|
export * from './localization';
|
23
23
|
export { default as SVGLoader } from './SVGLoader/SVGLoader';
|
24
24
|
export { default as Viewport } from './Viewport';
|
@@ -36,7 +36,7 @@ export { default as UndoRedoHistory } from './UndoRedoHistory';
|
|
36
36
|
export * from './util/lib';
|
37
37
|
export { default as __js_draw__version } from './version';
|
38
38
|
import AbstractToolbar from './toolbar/AbstractToolbar';
|
39
|
-
export { Editor, EditorSettings, AbstractToolbar
|
39
|
+
export { Editor, EditorSettings, AbstractToolbar };
|
40
40
|
/**
|
41
41
|
* Using the HTMLToolbar alias is deprecated. Use
|
42
42
|
* `AbstractToolbar` instead.
|
package/dist/mjs/lib.mjs
CHANGED
@@ -18,7 +18,7 @@ import Editor from './Editor.mjs';
|
|
18
18
|
export * from './image/lib.mjs';
|
19
19
|
export * from './types.mjs';
|
20
20
|
export * from './inputEvents.mjs';
|
21
|
-
export { default as getLocalizationTable, matchingLocalizationTable } from './localizations/getLocalizationTable.mjs';
|
21
|
+
export { default as getLocalizationTable, matchingLocalizationTable, } from './localizations/getLocalizationTable.mjs';
|
22
22
|
export * from './localization.mjs';
|
23
23
|
export { default as SVGLoader } from './SVGLoader/SVGLoader.mjs';
|
24
24
|
export { default as Viewport } from './Viewport.mjs';
|
@@ -37,7 +37,7 @@ export * from './util/lib.mjs';
|
|
37
37
|
// @internal
|
38
38
|
export { default as __js_draw__version } from './version.mjs';
|
39
39
|
import AbstractToolbar from './toolbar/AbstractToolbar.mjs';
|
40
|
-
export { Editor, AbstractToolbar
|
40
|
+
export { Editor, AbstractToolbar };
|
41
41
|
/**
|
42
42
|
* Using the HTMLToolbar alias is deprecated. Use
|
43
43
|
* `AbstractToolbar` instead.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { defaultCommandLocalization } from './commands/localization.mjs';
|
2
|
-
import { defaultComponentLocalization } from './components/localization.mjs';
|
3
|
-
import { defaultTextRendererLocalization } from './rendering/localization.mjs';
|
2
|
+
import { defaultComponentLocalization, } from './components/localization.mjs';
|
3
|
+
import { defaultTextRendererLocalization, } from './rendering/localization.mjs';
|
4
4
|
import { defaultToolbarLocalization } from './toolbar/localization.mjs';
|
5
5
|
import { defaultToolLocalization } from './tools/localization.mjs';
|
6
6
|
export const defaultEditorLocalization = {
|
@@ -89,11 +89,11 @@ const localization = {
|
|
89
89
|
textNodeCount: (count) => `Es gibt ${count} sichtbare Text-Knotenpunkte.`,
|
90
90
|
textNode: (content) => `Text: ${content}`,
|
91
91
|
imageNodeCount: (nodeCount) => `Es gibt ${nodeCount} sichtbare Bild-Knoten.`,
|
92
|
-
imageNode: label => `Bild: ${label}`,
|
92
|
+
imageNode: (label) => `Bild: ${label}`,
|
93
93
|
unlabeledImageNode: 'Bild ohne Label',
|
94
94
|
rerenderAsText: 'Als Text darstellen',
|
95
95
|
accessibilityInputInstructions: 'Drücke ‚t‘, um den Inhalt des Ansichtsfensters als Text zu lesen. Verwende die Pfeiltasten, um die Ansicht zu verschieben, und klicke und ziehe, um Striche zu zeichnen. Drücke ‚w‘ zum Vergrößern und ‚s‘ zum Verkleinern der Ansicht.',
|
96
|
-
loading: percentage => `Laden ${percentage}%...`,
|
96
|
+
loading: (percentage) => `Laden ${percentage}%...`,
|
97
97
|
doneLoading: 'Laden fertig',
|
98
98
|
imageEditor: 'Bild-Editor',
|
99
99
|
undoAnnouncement: (commandDescription) => `${commandDescription} rückgängig gemacht`,
|
@@ -46,9 +46,13 @@ const localization = {
|
|
46
46
|
selectionMenu__duplicate: 'Duplicar',
|
47
47
|
closeSidebar: (toolName) => `Close sidebar for ${toolName}`,
|
48
48
|
dropdownShown: (toolName) => `Menú por ${toolName} es visible`,
|
49
|
-
dropdownHidden: (toolName) => {
|
49
|
+
dropdownHidden: (toolName) => {
|
50
|
+
return `Menú por ${toolName} fue ocultado`;
|
51
|
+
},
|
50
52
|
zoomLevel: (zoomPercent) => `Zoom: ${zoomPercent}%`,
|
51
|
-
colorChangedAnnouncement: (color) => {
|
53
|
+
colorChangedAnnouncement: (color) => {
|
54
|
+
return `Color fue cambiado a ${color}`;
|
55
|
+
},
|
52
56
|
imageSize: (size, units) => `Tamaño del imagen: ${size} ${units}`,
|
53
57
|
imageLoadError: (message) => `Error cargando imagen: ${message}`,
|
54
58
|
penTool: (penId) => `Lapiz ${penId}`,
|
@@ -65,7 +69,7 @@ const localization = {
|
|
65
69
|
closeDialog: 'Cerrar',
|
66
70
|
anyDevicePanning: 'Mover la pantalla con todo dispotivo',
|
67
71
|
copied: (count) => `${count} cosas fueron copiados`,
|
68
|
-
pasted: (count) => count === 1 ? 'Pegado' : `${count} cosas fueron pegados
|
72
|
+
pasted: (count) => (count === 1 ? 'Pegado' : `${count} cosas fueron pegados`),
|
69
73
|
toolEnabledAnnouncement: (toolName) => `${toolName} fue activado`,
|
70
74
|
toolDisabledAnnouncement: (toolName) => `${toolName} fue desactivado`,
|
71
75
|
resizeOutputCommand: (newSize) => `Tamaño de imagen fue cambiado a ${newSize.w}x${newSize.h}`,
|
@@ -79,7 +79,7 @@ export default class Display {
|
|
79
79
|
// Require about 105 strokes with 4 parts each to use the cache at all.
|
80
80
|
minProportionalRenderTimeToUseCache: 105 * 4,
|
81
81
|
});
|
82
|
-
this.editor.notifier.on(EditorEventType.DisplayResized, event => {
|
82
|
+
this.editor.notifier.on(EditorEventType.DisplayResized, (event) => {
|
83
83
|
if (event.kind !== EditorEventType.DisplayResized) {
|
84
84
|
throw new Error('Mismatched event.kinds!');
|
85
85
|
}
|
@@ -117,10 +117,14 @@ export default class Display {
|
|
117
117
|
}
|
118
118
|
this.resizeSurfacesCallback = () => {
|
119
119
|
const expectedWidth = (canvas) => {
|
120
|
-
|
120
|
+
const widthInPixels = Math.ceil(canvas.clientWidth * this.devicePixelRatio);
|
121
|
+
// Avoid setting the canvas width to zero -- doing so can cause errors when attempting
|
122
|
+
// to use the canvas:
|
123
|
+
return widthInPixels || canvas.width;
|
121
124
|
};
|
122
125
|
const expectedHeight = (canvas) => {
|
123
|
-
|
126
|
+
const heightInPixels = Math.ceil(canvas.clientHeight * this.devicePixelRatio);
|
127
|
+
return heightInPixels || canvas.height; // Zero-size canvases can cause errors.
|
124
128
|
};
|
125
129
|
const hasSizeMismatch = (canvas) => {
|
126
130
|
return expectedHeight(canvas) !== canvas.height || expectedWidth(canvas) !== canvas.width;
|
@@ -37,15 +37,18 @@ const pathIncluded = (renderablePath, path) => {
|
|
37
37
|
*
|
38
38
|
* @internal
|
39
39
|
*/
|
40
|
-
export const simplifyPathToFullScreenOrEmpty = (renderablePath, visibleRect, options = {
|
40
|
+
export const simplifyPathToFullScreenOrEmpty = (renderablePath, visibleRect, options = {
|
41
|
+
fastCheck: true,
|
42
|
+
expensiveCheck: true,
|
43
|
+
}) => {
|
41
44
|
const path = pathFromRenderable(renderablePath);
|
42
45
|
const strokeWidth = renderablePath.style.stroke?.width ?? 0;
|
43
46
|
const onlyStroked = strokeWidth > 0 && renderablePath.style.fill.a === 0;
|
44
47
|
const styledPathBBox = path.bbox.grownBy(strokeWidth);
|
45
48
|
// Are we close enough to the path that it fills the entire screen?
|
46
|
-
const isOnlyStrokedAndCouldFillScreen =
|
47
|
-
|
48
|
-
|
49
|
+
const isOnlyStrokedAndCouldFillScreen = onlyStroked &&
|
50
|
+
strokeWidth > visibleRect.maxDimension &&
|
51
|
+
styledPathBBox.containsRect(visibleRect);
|
49
52
|
if (options.fastCheck && isOnlyStrokedAndCouldFillScreen && renderablePath.style.stroke) {
|
50
53
|
const strokeRadius = strokeWidth / 2;
|
51
54
|
// Are we completely within the stroke?
|
@@ -55,7 +58,9 @@ export const simplifyPathToFullScreenOrEmpty = (renderablePath, visibleRect, opt
|
|
55
58
|
if (visibleRect.isWithinRadiusOf(strokeRadius, point)) {
|
56
59
|
return {
|
57
60
|
rectangle: visibleRect,
|
58
|
-
path: pathToRenderable(Path.fromRect(visibleRect), {
|
61
|
+
path: pathToRenderable(Path.fromRect(visibleRect), {
|
62
|
+
fill: renderablePath.style.stroke.color,
|
63
|
+
}),
|
59
64
|
fullScreen: true,
|
60
65
|
};
|
61
66
|
}
|
@@ -63,13 +68,16 @@ export const simplifyPathToFullScreenOrEmpty = (renderablePath, visibleRect, opt
|
|
63
68
|
}
|
64
69
|
// Try filtering again, but with slightly more expensive checks
|
65
70
|
if (options.expensiveCheck &&
|
66
|
-
isOnlyStrokedAndCouldFillScreen &&
|
67
|
-
|
71
|
+
isOnlyStrokedAndCouldFillScreen &&
|
72
|
+
renderablePath.style.stroke &&
|
73
|
+
strokeWidth > visibleRect.maxDimension * 3) {
|
68
74
|
const signedDist = path.signedDistance(visibleRect.center, strokeWidth / 2);
|
69
75
|
const margin = strokeWidth / 6;
|
70
76
|
if (signedDist < -visibleRect.maxDimension / 2 - margin) {
|
71
77
|
return {
|
72
|
-
path: pathToRenderable(Path.fromRect(visibleRect), {
|
78
|
+
path: pathToRenderable(Path.fromRect(visibleRect), {
|
79
|
+
fill: renderablePath.style.stroke.color,
|
80
|
+
}),
|
73
81
|
rectangle: visibleRect,
|
74
82
|
fullScreen: true,
|
75
83
|
};
|
@@ -92,12 +100,16 @@ export const visualEquivalent = (renderablePath, visibleRect) => {
|
|
92
100
|
const strokeWidth = renderablePath.style.stroke?.width ?? 0;
|
93
101
|
const onlyStroked = strokeWidth > 0 && renderablePath.style.fill.a === 0;
|
94
102
|
const styledPathBBox = path.bbox.grownBy(strokeWidth);
|
95
|
-
let rectangleSimplification = simplifyPathToFullScreenOrEmpty(renderablePath, visibleRect, {
|
103
|
+
let rectangleSimplification = simplifyPathToFullScreenOrEmpty(renderablePath, visibleRect, {
|
104
|
+
fastCheck: true,
|
105
|
+
expensiveCheck: false,
|
106
|
+
});
|
96
107
|
if (rectangleSimplification) {
|
97
108
|
return rectangleSimplification.path;
|
98
109
|
}
|
99
110
|
// Scale the expanded rect --- the visual equivalent is only close for huge strokes.
|
100
|
-
const expandedRect = visibleRect
|
111
|
+
const expandedRect = visibleRect
|
112
|
+
.grownBy(strokeWidth)
|
101
113
|
.transformedBoundingBox(Mat33.scaling2D(4, visibleRect.center));
|
102
114
|
// TODO: Handle simplifying very small paths.
|
103
115
|
if (expandedRect.containsRect(styledPathBBox)) {
|
@@ -138,7 +150,10 @@ export const visualEquivalent = (renderablePath, visibleRect) => {
|
|
138
150
|
}
|
139
151
|
const newPath = new Path(path.startPoint, parts);
|
140
152
|
const newStyle = renderablePath.style;
|
141
|
-
rectangleSimplification = simplifyPathToFullScreenOrEmpty(renderablePath, visibleRect, {
|
153
|
+
rectangleSimplification = simplifyPathToFullScreenOrEmpty(renderablePath, visibleRect, {
|
154
|
+
fastCheck: false,
|
155
|
+
expensiveCheck: true,
|
156
|
+
});
|
142
157
|
if (rectangleSimplification) {
|
143
158
|
return rectangleSimplification.path;
|
144
159
|
}
|
@@ -2,36 +2,43 @@ import { Color4 } from '@js-draw/math';
|
|
2
2
|
export const cloneStyle = (style) => {
|
3
3
|
return {
|
4
4
|
fill: style.fill,
|
5
|
-
stroke: style.stroke
|
6
|
-
|
7
|
-
|
5
|
+
stroke: style.stroke
|
6
|
+
? {
|
7
|
+
...style.stroke,
|
8
|
+
}
|
9
|
+
: undefined,
|
8
10
|
};
|
9
11
|
};
|
10
12
|
export const stylesEqual = (a, b) => {
|
11
|
-
const result = a === b ||
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
const result = a === b ||
|
14
|
+
(a.fill.eq(b.fill) &&
|
15
|
+
(a.stroke == undefined) === (b.stroke == undefined) &&
|
16
|
+
(a.stroke?.color?.eq(b.stroke?.color) ?? true) &&
|
17
|
+
a.stroke?.width === b.stroke?.width);
|
15
18
|
// Map undefined/null -> false
|
16
19
|
return result ?? false;
|
17
20
|
};
|
18
21
|
// Returns an object that can be converted to a JSON string with
|
19
22
|
// JSON.stringify.
|
20
23
|
export const styleToJSON = (style) => {
|
21
|
-
const stroke = !style.stroke
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
const stroke = !style.stroke
|
25
|
+
? undefined
|
26
|
+
: {
|
27
|
+
color: style.stroke.color.toHexString(),
|
28
|
+
width: style.stroke.width,
|
29
|
+
};
|
25
30
|
return {
|
26
31
|
fill: style.fill.toHexString(),
|
27
32
|
stroke,
|
28
33
|
};
|
29
34
|
};
|
30
35
|
export const styleFromJSON = (json) => {
|
31
|
-
const stroke = json.stroke
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
const stroke = json.stroke
|
37
|
+
? {
|
38
|
+
color: Color4.fromHex(json.stroke.color),
|
39
|
+
width: json.stroke.width,
|
40
|
+
}
|
41
|
+
: undefined;
|
35
42
|
return {
|
36
43
|
fill: Color4.fromHex(json.fill),
|
37
44
|
stroke,
|
@@ -10,7 +10,7 @@ export const textStyleFromJSON = (json) => {
|
|
10
10
|
if (typeof json === 'string') {
|
11
11
|
json = JSON.parse(json);
|
12
12
|
}
|
13
|
-
if (typeof
|
13
|
+
if (typeof json.fontFamily !== 'string') {
|
14
14
|
throw new Error('Serialized textStyle missing string fontFamily attribute!');
|
15
15
|
}
|
16
16
|
const style = {
|
@@ -15,7 +15,7 @@ export default class CacheRecord {
|
|
15
15
|
startRender() {
|
16
16
|
this.lastUsedCycle = this.cacheState.currentRenderingCycle;
|
17
17
|
if (!this.allocd) {
|
18
|
-
throw new Error(
|
18
|
+
throw new Error("Only alloc'd canvases can be rendered to");
|
19
19
|
}
|
20
20
|
return this.renderer;
|
21
21
|
}
|
@@ -28,7 +28,7 @@ export class CacheRecordManager {
|
|
28
28
|
lru.realloc(onDealloc);
|
29
29
|
lru.setRenderingRegion(drawTo);
|
30
30
|
if (this.cacheState.debugMode) {
|
31
|
-
console.log(
|
31
|
+
console.log("[Cache] Now re-alloc'd. Last used cycle: ", lru.getLastUsedCycle());
|
32
32
|
console.assert(lru['cacheState'] === this.cacheState, '[Cache] Unequal cache states! cacheState should be a shared object!');
|
33
33
|
}
|
34
34
|
return lru;
|
@@ -30,7 +30,7 @@ export default class RenderingCache {
|
|
30
30
|
this.rootNode = this.rootNode.generateParent();
|
31
31
|
}
|
32
32
|
this.rootNode = this.rootNode.smallestChildContaining(visibleRect) ?? this.rootNode;
|
33
|
-
const visibleLeaves = image.getLeavesIntersectingRegion(viewport.visibleRect, rect => screenRenderer.isTooSmallToRender(rect));
|
33
|
+
const visibleLeaves = image.getLeavesIntersectingRegion(viewport.visibleRect, (rect) => screenRenderer.isTooSmallToRender(rect));
|
34
34
|
let approxVisibleRenderTime = 0;
|
35
35
|
for (const leaf of visibleLeaves) {
|
36
36
|
approxVisibleRenderTime += leaf.getContent().getProportionalRenderingTime();
|
@@ -30,7 +30,7 @@ export default class RenderingCacheNode {
|
|
30
30
|
const middleChildIdx = (parent.instantiatedChildren.length - 1) / 2;
|
31
31
|
if (!parent.instantiatedChildren[middleChildIdx].region.eq(this.region, checkTolerance)) {
|
32
32
|
console.error(parent.instantiatedChildren[middleChildIdx].region, '≠', this.region);
|
33
|
-
throw new Error(
|
33
|
+
throw new Error("Logic error: [this] is not contained within its parent's center child");
|
34
34
|
}
|
35
35
|
// Replace the middle child
|
36
36
|
parent.instantiatedChildren[middleChildIdx] = this;
|
@@ -40,7 +40,8 @@ export default class RenderingCacheNode {
|
|
40
40
|
// Generates children, if missing.
|
41
41
|
generateChildren() {
|
42
42
|
if (this.instantiatedChildren.length === 0) {
|
43
|
-
if (this.region.size.x / cacheDivisionSize === 0 ||
|
43
|
+
if (this.region.size.x / cacheDivisionSize === 0 ||
|
44
|
+
this.region.size.y / cacheDivisionSize === 0) {
|
44
45
|
console.warn('Cache element has zero size! Not generating children.');
|
45
46
|
return;
|
46
47
|
}
|
@@ -135,8 +136,7 @@ export default class RenderingCacheNode {
|
|
135
136
|
}
|
136
137
|
// Render all [items] within [viewport]
|
137
138
|
renderItems(screenRenderer, items, viewport) {
|
138
|
-
if (!viewport.visibleRect.intersects(this.region)
|
139
|
-
|| items.length === 0) {
|
139
|
+
if (!viewport.visibleRect.intersects(this.region) || items.length === 0) {
|
140
140
|
return;
|
141
141
|
}
|
142
142
|
// Divide [items] until nodes are smaller than this, or are leaves.
|
@@ -165,13 +165,15 @@ export default class RenderingCacheNode {
|
|
165
165
|
return;
|
166
166
|
}
|
167
167
|
if (this.cacheState.debugMode) {
|
168
|
-
screenRenderer.drawRect(this.region, viewport.getSizeOfPixelOnCanvas(), {
|
168
|
+
screenRenderer.drawRect(this.region, viewport.getSizeOfPixelOnCanvas(), {
|
169
|
+
fill: Color4.yellow,
|
170
|
+
});
|
169
171
|
}
|
170
172
|
// Could we render direclty from [this] or do we need to recurse?
|
171
173
|
const couldRender = this.renderingWouldBeHighEnoughResolution(viewport);
|
172
174
|
if (!couldRender) {
|
173
175
|
for (const child of this.getChildren()) {
|
174
|
-
child.renderItems(screenRenderer, items.filter(item => {
|
176
|
+
child.renderItems(screenRenderer, items.filter((item) => {
|
175
177
|
return item.getBBox().intersects(child.region);
|
176
178
|
}), viewport);
|
177
179
|
}
|
@@ -189,7 +191,7 @@ export default class RenderingCacheNode {
|
|
189
191
|
if (leavesByIds.length === 0) {
|
190
192
|
return;
|
191
193
|
}
|
192
|
-
const leafIds = leavesByIds.map(leaf => leaf.getId());
|
194
|
+
const leafIds = leavesByIds.map((leaf) => leaf.getId());
|
193
195
|
let thisRenderer;
|
194
196
|
if (!this.renderingIsUpToDate(leafIds)) {
|
195
197
|
if (this.allChildrenCanRender(viewport, leavesByIds)) {
|
@@ -210,7 +212,9 @@ export default class RenderingCacheNode {
|
|
210
212
|
if (!this.cachedRenderer) {
|
211
213
|
this.cachedRenderer = this.cacheState.recordManager.allocCanvas(this.region, () => this.onRegionDealloc());
|
212
214
|
}
|
213
|
-
else if (leavesByIds.length > this.renderedIds.length &&
|
215
|
+
else if (leavesByIds.length > this.renderedIds.length &&
|
216
|
+
this.allRenderedIdsIn(leafIds) &&
|
217
|
+
this.renderedMaxZIndex !== null) {
|
214
218
|
// We often don't need to do a full re-render even if something's changed.
|
215
219
|
// Check whether we can just draw on top of the existing cache.
|
216
220
|
const newLeaves = [];
|
@@ -240,7 +244,9 @@ export default class RenderingCacheNode {
|
|
240
244
|
}
|
241
245
|
if (this.cacheState.debugMode) {
|
242
246
|
// Clay for adding new elements
|
243
|
-
screenRenderer.drawRect(this.region, 2 * viewport.getSizeOfPixelOnCanvas(), {
|
247
|
+
screenRenderer.drawRect(this.region, 2 * viewport.getSizeOfPixelOnCanvas(), {
|
248
|
+
fill: Color4.clay,
|
249
|
+
});
|
244
250
|
}
|
245
251
|
}
|
246
252
|
}
|
@@ -261,7 +267,9 @@ export default class RenderingCacheNode {
|
|
261
267
|
}
|
262
268
|
if (this.cacheState.debugMode) {
|
263
269
|
// Red for full rerender
|
264
|
-
screenRenderer.drawRect(this.region, 3 * viewport.getSizeOfPixelOnCanvas(), {
|
270
|
+
screenRenderer.drawRect(this.region, 3 * viewport.getSizeOfPixelOnCanvas(), {
|
271
|
+
fill: Color4.red,
|
272
|
+
});
|
265
273
|
}
|
266
274
|
}
|
267
275
|
this.renderedIds = leafIds;
|
@@ -280,7 +288,9 @@ export default class RenderingCacheNode {
|
|
280
288
|
screenRenderer.endObject();
|
281
289
|
if (this.cacheState.debugMode) {
|
282
290
|
// Green for no cache needed render
|
283
|
-
screenRenderer.drawRect(this.region, 2 * viewport.getSizeOfPixelOnCanvas(), {
|
291
|
+
screenRenderer.drawRect(this.region, 2 * viewport.getSizeOfPixelOnCanvas(), {
|
292
|
+
fill: Color4.green,
|
293
|
+
});
|
284
294
|
}
|
285
295
|
}
|
286
296
|
}
|
@@ -292,7 +302,7 @@ export default class RenderingCacheNode {
|
|
292
302
|
screenRenderer.renderFromOtherOfSameType(transformMat, thisRenderer);
|
293
303
|
}
|
294
304
|
// Can we clean up this' children? (Are they unused?)
|
295
|
-
if (this.instantiatedChildren.every(child => child.isEmpty())) {
|
305
|
+
if (this.instantiatedChildren.every((child) => child.isEmpty())) {
|
296
306
|
this.instantiatedChildren = [];
|
297
307
|
}
|
298
308
|
}
|
@@ -303,7 +313,7 @@ export default class RenderingCacheNode {
|
|
303
313
|
if (this.cachedRenderer !== null) {
|
304
314
|
return false;
|
305
315
|
}
|
306
|
-
return this.instantiatedChildren.every(child => child.isEmpty());
|
316
|
+
return this.instantiatedChildren.every((child) => child.isEmpty());
|
307
317
|
}
|
308
318
|
onRegionDealloc() {
|
309
319
|
this.cachedRenderer = null;
|
@@ -312,7 +322,8 @@ export default class RenderingCacheNode {
|
|
312
322
|
}
|
313
323
|
}
|
314
324
|
checkRep() {
|
315
|
-
if (this.instantiatedChildren.length !== cacheDivisionSize * cacheDivisionSize &&
|
325
|
+
if (this.instantiatedChildren.length !== cacheDivisionSize * cacheDivisionSize &&
|
326
|
+
this.instantiatedChildren.length !== 0) {
|
316
327
|
throw new Error(`Repcheck: Wrong number of children. Got ${this.instantiatedChildren.length}`);
|
317
328
|
}
|
318
329
|
if (this.renderedIds[1] !== undefined && this.renderedIds[0] >= this.renderedIds[1]) {
|
@@ -325,7 +336,7 @@ export default class RenderingCacheNode {
|
|
325
336
|
}
|
326
337
|
}
|
327
338
|
if (this.cachedRenderer && !this.cachedRenderer.isAllocd()) {
|
328
|
-
throw new Error(
|
339
|
+
throw new Error("this' cachedRenderer != null, but is dealloc'd");
|
329
340
|
}
|
330
341
|
}
|
331
342
|
}
|
@@ -19,10 +19,10 @@ export const createCache = (onRenderAlloc, cacheOptions) => {
|
|
19
19
|
maxScale: 2,
|
20
20
|
minProportionalRenderTimePerCache: 0,
|
21
21
|
minProportionalRenderTimeToUseCache: 0,
|
22
|
-
...cacheOptions
|
22
|
+
...cacheOptions,
|
23
23
|
});
|
24
24
|
return {
|
25
25
|
cache,
|
26
|
-
editor
|
26
|
+
editor,
|
27
27
|
};
|
28
28
|
};
|
@@ -20,7 +20,9 @@ export default class AbstractRenderer {
|
|
20
20
|
* methods on `Viewport`, because the viewport may not accurately reflect
|
21
21
|
* what is rendered.
|
22
22
|
*/
|
23
|
-
getViewport() {
|
23
|
+
getViewport() {
|
24
|
+
return this.viewport;
|
25
|
+
}
|
24
26
|
setDraftMode(_draftMode) { }
|
25
27
|
flushPath() {
|
26
28
|
if (!this.currentPaths) {
|
@@ -131,8 +131,8 @@ export default class CanvasRenderer extends AbstractRenderer {
|
|
131
131
|
// Approximate the curve if small enough.
|
132
132
|
const delta1 = p2.minus(p1);
|
133
133
|
const delta2 = p3.minus(p2);
|
134
|
-
if (delta1.magnitudeSquared() < this.minSquareCurveApproxDist
|
135
|
-
|
134
|
+
if (delta1.magnitudeSquared() < this.minSquareCurveApproxDist &&
|
135
|
+
delta2.magnitudeSquared() < this.minSquareCurveApproxDist) {
|
136
136
|
this.ctx.lineTo(p3.x, p3.y);
|
137
137
|
}
|
138
138
|
else {
|
@@ -225,7 +225,8 @@ export default class CanvasRenderer extends AbstractRenderer {
|
|
225
225
|
}
|
226
226
|
}
|
227
227
|
// If exiting an object with a too-small-to-draw bounding box,
|
228
|
-
if (this.ignoreObjectsAboveLevel !== null &&
|
228
|
+
if (this.ignoreObjectsAboveLevel !== null &&
|
229
|
+
this.getNestingLevel() <= this.ignoreObjectsAboveLevel) {
|
229
230
|
this.ignoreObjectsAboveLevel = null;
|
230
231
|
this.ignoringObject = false;
|
231
232
|
}
|
@@ -99,7 +99,7 @@ export default class DummyRenderer extends AbstractRenderer {
|
|
99
99
|
this.renderedPathCount += other.renderedPathCount;
|
100
100
|
this.lastFillStyle = other.lastFillStyle;
|
101
101
|
this.lastPoint = other.lastPoint;
|
102
|
-
this.pointBuffer.push(...other.pointBuffer.map(point => {
|
102
|
+
this.pointBuffer.push(...other.pointBuffer.map((point) => {
|
103
103
|
return transform.transformVec2(point);
|
104
104
|
}));
|
105
105
|
}
|