js-draw 1.21.3 → 1.23.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +104 -76
- 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.d.ts +1 -3
- package/dist/cjs/Editor.js +38 -26
- package/dist/cjs/EventDispatcher.js +1 -1
- package/dist/cjs/Pointer.js +3 -3
- package/dist/cjs/SVGLoader/SVGLoader.js +15 -6
- package/dist/cjs/UndoRedoHistory.js +1 -1
- package/dist/cjs/Viewport.d.ts +1 -1
- package/dist/cjs/Viewport.js +5 -3
- 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 +2 -2
- package/dist/cjs/components/AbstractComponent.js +4 -4
- 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.d.ts +30 -7
- package/dist/cjs/image/EditorImage.js +43 -22
- 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.d.ts +2 -25
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +6 -28
- package/dist/cjs/rendering/renderers/DummyRenderer.js +1 -1
- package/dist/cjs/rendering/renderers/SVGRenderer.js +39 -21
- 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.d.ts +19 -0
- package/dist/cjs/toolbar/AbstractToolbar.js +26 -11
- package/dist/cjs/toolbar/EdgeToolbar.js +11 -15
- package/dist/cjs/toolbar/IconProvider.d.ts +5 -1
- package/dist/cjs/toolbar/IconProvider.js +117 -149
- package/dist/cjs/toolbar/localization.js +5 -5
- 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.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/BaseWidget.js +8 -8
- 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.js +5 -3
- package/dist/cjs/tools/Eraser.js +25 -20
- package/dist/cjs/tools/FindTool.js +2 -2
- package/dist/cjs/tools/InputFilter/ContextMenuRecognizer.js +1 -3
- package/dist/cjs/tools/InputFilter/InputMapper.js +1 -1
- package/dist/cjs/tools/InputFilter/InputPipeline.js +1 -1
- package/dist/cjs/tools/InputFilter/InputStabilizer.js +12 -5
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +7 -4
- package/dist/cjs/tools/PanZoom.d.ts +1 -1
- package/dist/cjs/tools/PanZoom.js +18 -13
- package/dist/cjs/tools/PasteHandler.js +8 -2
- package/dist/cjs/tools/Pen.d.ts +13 -0
- package/dist/cjs/tools/Pen.js +30 -9
- package/dist/cjs/tools/ScrollbarTool.js +8 -7
- package/dist/cjs/tools/SelectionTool/Selection.js +16 -12
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +5 -2
- package/dist/cjs/tools/SelectionTool/SelectionMenuShortcut.js +3 -1
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +25 -16
- package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.js +1 -1
- package/dist/cjs/tools/SelectionTool/TransformMode.js +6 -7
- package/dist/cjs/tools/SelectionTool/util/makeClipboardErrorHandlers.js +23 -2
- package/dist/cjs/tools/SelectionTool/util/showSelectionContextMenu.js +29 -20
- package/dist/cjs/tools/SoundUITool.js +5 -3
- package/dist/cjs/tools/TextTool.js +8 -6
- package/dist/cjs/tools/ToolController.js +16 -10
- package/dist/cjs/tools/lib.d.ts +1 -0
- package/dist/cjs/tools/lib.js +3 -1
- package/dist/cjs/tools/localization.d.ts +2 -0
- package/dist/cjs/tools/localization.js +3 -1
- package/dist/cjs/tools/util/StationaryPenDetector.js +3 -3
- package/dist/cjs/tools/util/createMenuOverlay.js +2 -2
- 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/cloneElementWithStyles.js +1 -1
- package/dist/cjs/util/createElement.d.ts +62 -0
- package/dist/cjs/util/createElement.js +53 -0
- 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.d.ts +1 -3
- package/dist/mjs/Editor.mjs +39 -27
- package/dist/mjs/EventDispatcher.mjs +1 -1
- package/dist/mjs/Pointer.mjs +3 -3
- package/dist/mjs/SVGLoader/SVGLoader.mjs +16 -7
- package/dist/mjs/UndoRedoHistory.mjs +1 -1
- package/dist/mjs/Viewport.d.ts +1 -1
- package/dist/mjs/Viewport.mjs +5 -3
- 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 +2 -2
- package/dist/mjs/components/AbstractComponent.mjs +4 -4
- 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.d.ts +30 -7
- package/dist/mjs/image/EditorImage.mjs +43 -22
- 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.d.ts +2 -25
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +6 -28
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +1 -1
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +40 -22
- 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.d.ts +19 -0
- package/dist/mjs/toolbar/AbstractToolbar.mjs +26 -11
- package/dist/mjs/toolbar/EdgeToolbar.mjs +11 -15
- package/dist/mjs/toolbar/IconProvider.d.ts +5 -1
- package/dist/mjs/toolbar/IconProvider.mjs +117 -149
- package/dist/mjs/toolbar/localization.mjs +5 -5
- 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.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +9 -9
- 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.mjs +6 -4
- package/dist/mjs/tools/Eraser.mjs +25 -20
- package/dist/mjs/tools/FindTool.mjs +2 -2
- package/dist/mjs/tools/InputFilter/ContextMenuRecognizer.mjs +2 -4
- package/dist/mjs/tools/InputFilter/InputMapper.mjs +1 -1
- package/dist/mjs/tools/InputFilter/InputPipeline.mjs +1 -1
- package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +13 -6
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +7 -4
- package/dist/mjs/tools/PanZoom.d.ts +1 -1
- package/dist/mjs/tools/PanZoom.mjs +19 -14
- package/dist/mjs/tools/PasteHandler.mjs +8 -2
- package/dist/mjs/tools/Pen.d.ts +13 -0
- package/dist/mjs/tools/Pen.mjs +31 -10
- package/dist/mjs/tools/ScrollbarTool.mjs +8 -7
- package/dist/mjs/tools/SelectionTool/Selection.mjs +16 -12
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +5 -2
- package/dist/mjs/tools/SelectionTool/SelectionMenuShortcut.mjs +3 -1
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +26 -17
- package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.mjs +1 -1
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +6 -7
- package/dist/mjs/tools/SelectionTool/util/makeClipboardErrorHandlers.mjs +23 -2
- package/dist/mjs/tools/SelectionTool/util/showSelectionContextMenu.mjs +29 -20
- package/dist/mjs/tools/SoundUITool.mjs +5 -3
- package/dist/mjs/tools/TextTool.mjs +8 -6
- package/dist/mjs/tools/ToolController.mjs +16 -10
- package/dist/mjs/tools/lib.d.ts +1 -0
- package/dist/mjs/tools/lib.mjs +1 -0
- package/dist/mjs/tools/localization.d.ts +2 -0
- package/dist/mjs/tools/localization.mjs +3 -1
- package/dist/mjs/tools/util/StationaryPenDetector.mjs +3 -3
- package/dist/mjs/tools/util/createMenuOverlay.mjs +2 -2
- 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/cloneElementWithStyles.mjs +1 -1
- package/dist/mjs/util/createElement.d.ts +62 -0
- package/dist/mjs/util/createElement.mjs +47 -0
- 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 +1 -2
- package/src/tools/ScrollbarTool.scss +9 -5
- package/src/tools/SelectionTool/SelectionTool.scss +15 -7
- package/src/tools/SelectionTool/util/makeClipboardErrorHandlers.scss +1 -2
- package/src/tools/SoundUITool.scss +4 -4
- package/src/tools/tools.scss +5 -6
- package/src/tools/util/createMenuOverlay.scss +10 -4
- package/tsconfig.json +1 -3
- package/typedoc.json +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Mat33, Vec2, toRoundedString } from '@js-draw/math';
|
2
|
-
import { svgAttributesDataKey, svgLoaderAttributeContainerID, svgStyleAttributesDataKey } from '../../SVGLoader/SVGLoader.mjs';
|
2
|
+
import { svgAttributesDataKey, svgLoaderAttributeContainerID, svgStyleAttributesDataKey, } from '../../SVGLoader/SVGLoader.mjs';
|
3
3
|
import { stylesEqual } from '../RenderingStyle.mjs';
|
4
4
|
import AbstractRenderer from './AbstractRenderer.mjs';
|
5
5
|
import { pathFromRenderable } from '../RenderablePathSpec.mjs';
|
@@ -43,7 +43,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
43
43
|
if (!this.elem.querySelector(`#${renderedStylesheetId}`)) {
|
44
44
|
// Default to rounded strokes.
|
45
45
|
const styleSheet = document.createElementNS('http://www.w3.org/2000/svg', 'style');
|
46
|
-
styleSheet.
|
46
|
+
styleSheet.appendChild(document.createTextNode(`
|
47
47
|
path {
|
48
48
|
stroke-linecap: round;
|
49
49
|
stroke-linejoin: round;
|
@@ -52,7 +52,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
52
52
|
text {
|
53
53
|
white-space: pre;
|
54
54
|
}
|
55
|
-
`.replace(/\s+/g, '');
|
55
|
+
`.replace(/\s+/g, '')));
|
56
56
|
styleSheet.setAttribute('id', renderedStylesheetId);
|
57
57
|
this.elem.appendChild(styleSheet);
|
58
58
|
}
|
@@ -120,7 +120,9 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
120
120
|
const style = pathSpec.style;
|
121
121
|
const path = pathFromRenderable(pathSpec).transformedBy(this.getCanvasToScreenTransform());
|
122
122
|
// Try to extend the previous path, if possible
|
123
|
-
if (this.lastPathString.length === 0 ||
|
123
|
+
if (this.lastPathString.length === 0 ||
|
124
|
+
!this.lastPathStyle ||
|
125
|
+
!stylesEqual(this.lastPathStyle, style)) {
|
124
126
|
this.addPathToSVG();
|
125
127
|
this.lastPathStyle = style;
|
126
128
|
this.lastPathString = [];
|
@@ -130,7 +132,9 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
130
132
|
// Apply [elemTransform] to [elem]. Uses both a `matrix` and `.x`, `.y` properties if `setXY` is true.
|
131
133
|
// Otherwise, just uses a `matrix`.
|
132
134
|
transformFrom(elemTransform, elem, inCanvasSpace = false) {
|
133
|
-
const transform = !inCanvasSpace
|
135
|
+
const transform = !inCanvasSpace
|
136
|
+
? this.getCanvasToScreenTransform().rightMul(elemTransform)
|
137
|
+
: elemTransform;
|
134
138
|
if (!transform.eq(Mat33.identity)) {
|
135
139
|
const matrixString = transform.toCSSMatrix();
|
136
140
|
elem.style.transform = matrixString;
|
@@ -255,15 +259,15 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
255
259
|
containerIDList = containerIDData[0];
|
256
260
|
}
|
257
261
|
}
|
258
|
-
if (containerIDList.length > 0
|
262
|
+
if (containerIDList.length > 0 &&
|
259
263
|
// containerIDList must share a prefix with the last ID list
|
260
264
|
// otherwise, the z order of elements may have been changed from
|
261
265
|
// the original image.
|
262
266
|
// In the case that the z order has been changed, keep the current
|
263
267
|
// element as a child of the root to preserve z order.
|
264
|
-
|
268
|
+
listPrefixMatch(this.lastContainerIDList, containerIDList) &&
|
265
269
|
// The component can add at most one more parent than the previous item.
|
266
|
-
|
270
|
+
this.lastContainerIDList.length >= containerIDList.length - 1) {
|
267
271
|
// Select the last
|
268
272
|
const containerID = containerIDList[containerIDList.length - 1];
|
269
273
|
const containerCandidates = this.elem.querySelectorAll(`g#${containerID}`);
|
@@ -272,7 +276,8 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
272
276
|
// If this is the first time we're entering the group, the
|
273
277
|
// group should be empty.
|
274
278
|
// Otherwise, this may be a case that would break z-ordering.
|
275
|
-
if (container.children.length === 0 ||
|
279
|
+
if (container.children.length === 0 ||
|
280
|
+
this.lastContainerIDList.length >= containerIDList.length) {
|
276
281
|
// Move all objectElems to the found container
|
277
282
|
for (const elem of this.objectElems) {
|
278
283
|
elem.remove();
|
@@ -306,15 +311,29 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
306
311
|
}
|
307
312
|
}
|
308
313
|
// Not implemented -- use drawPath instead.
|
309
|
-
unimplementedMessage() {
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
314
|
+
unimplementedMessage() {
|
315
|
+
throw new Error('Not implemenented!');
|
316
|
+
}
|
317
|
+
beginPath(_startPoint) {
|
318
|
+
this.unimplementedMessage();
|
319
|
+
}
|
320
|
+
endPath(_style) {
|
321
|
+
this.unimplementedMessage();
|
322
|
+
}
|
323
|
+
lineTo(_point) {
|
324
|
+
this.unimplementedMessage();
|
325
|
+
}
|
326
|
+
moveTo(_point) {
|
327
|
+
this.unimplementedMessage();
|
328
|
+
}
|
329
|
+
traceCubicBezierCurve(_controlPoint1, _controlPoint2, _endPoint) {
|
330
|
+
this.unimplementedMessage();
|
331
|
+
}
|
332
|
+
traceQuadraticBezierCurve(_controlPoint, _endPoint) {
|
333
|
+
this.unimplementedMessage();
|
334
|
+
}
|
316
335
|
drawPoints(...points) {
|
317
|
-
points.map(point => {
|
336
|
+
points.map((point) => {
|
318
337
|
const elem = document.createElementNS(svgNameSpace, 'circle');
|
319
338
|
elem.setAttribute('cx', `${point.x}`);
|
320
339
|
elem.setAttribute('cy', `${point.y}`);
|
@@ -328,7 +347,8 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
328
347
|
return;
|
329
348
|
}
|
330
349
|
// Don't add multiple copies of the default stylesheet.
|
331
|
-
if (elem.tagName.toLowerCase() === 'style' &&
|
350
|
+
if (elem.tagName.toLowerCase() === 'style' &&
|
351
|
+
elem.getAttribute('id') === renderedStylesheetId) {
|
332
352
|
return;
|
333
353
|
}
|
334
354
|
const elemToDraw = elem.cloneNode(true);
|
@@ -363,9 +383,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
363
383
|
let viewBoxComponents;
|
364
384
|
if (useViewBoxForPositioning) {
|
365
385
|
const exportRect = viewport.visibleRect;
|
366
|
-
viewBoxComponents = [
|
367
|
-
exportRect.x, exportRect.y, exportRect.w, exportRect.h,
|
368
|
-
];
|
386
|
+
viewBoxComponents = [exportRect.x, exportRect.y, exportRect.w, exportRect.h];
|
369
387
|
// Replace the viewport with a copy that has a modified transform.
|
370
388
|
// (Avoids modifying the original viewport).
|
371
389
|
viewport = viewport.getTemporaryClone();
|
@@ -377,7 +395,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
377
395
|
viewBoxComponents = [0, 0, screenRectSize.x, screenRectSize.y];
|
378
396
|
}
|
379
397
|
// rect.x -> size of rect in x direction, rect.y -> size of rect in y direction.
|
380
|
-
result.setAttribute('viewBox', viewBoxComponents.map(part => toRoundedString(part)).join(' '));
|
398
|
+
result.setAttribute('viewBox', viewBoxComponents.map((part) => toRoundedString(part)).join(' '));
|
381
399
|
result.setAttribute('width', toRoundedString(screenRectSize.x));
|
382
400
|
result.setAttribute('height', toRoundedString(screenRectSize.y));
|
383
401
|
// Ensure the image can be identified as an SVG if downloaded.
|
@@ -24,35 +24,33 @@ export default class TextOnlyRenderer extends AbstractRenderer {
|
|
24
24
|
return [
|
25
25
|
this.localizationTable.pathNodeCount(this.pathCount),
|
26
26
|
...(this.textNodeCount > 0 ? [this.localizationTable.textNodeCount(this.textNodeCount)] : []),
|
27
|
-
...(this.imageNodeCount > 0
|
28
|
-
|
27
|
+
...(this.imageNodeCount > 0
|
28
|
+
? [this.localizationTable.imageNodeCount(this.imageNodeCount)]
|
29
|
+
: []),
|
30
|
+
...this.descriptionBuilder,
|
29
31
|
].join('\n');
|
30
32
|
}
|
31
|
-
beginPath(_startPoint) {
|
32
|
-
}
|
33
|
+
beginPath(_startPoint) { }
|
33
34
|
endPath(_style) {
|
34
35
|
this.pathCount++;
|
35
36
|
}
|
36
|
-
lineTo(_point) {
|
37
|
-
}
|
38
|
-
|
39
|
-
}
|
40
|
-
traceCubicBezierCurve(_p1, _p2, _p3) {
|
41
|
-
}
|
42
|
-
traceQuadraticBezierCurve(_controlPoint, _endPoint) {
|
43
|
-
}
|
37
|
+
lineTo(_point) { }
|
38
|
+
moveTo(_point) { }
|
39
|
+
traceCubicBezierCurve(_p1, _p2, _p3) { }
|
40
|
+
traceQuadraticBezierCurve(_controlPoint, _endPoint) { }
|
44
41
|
drawText(text, _transform, _style) {
|
45
42
|
this.descriptionBuilder.push(this.localizationTable.textNode(text));
|
46
43
|
this.textNodeCount++;
|
47
44
|
}
|
48
45
|
drawImage(image) {
|
49
|
-
const label = image.label
|
46
|
+
const label = image.label
|
47
|
+
? this.localizationTable.imageNode(image.label)
|
48
|
+
: this.localizationTable.unlabeledImageNode;
|
50
49
|
this.descriptionBuilder.push(label);
|
51
50
|
this.imageNodeCount++;
|
52
51
|
}
|
53
52
|
isTooSmallToRender(rect) {
|
54
53
|
return rect.maxDimension < 15 / this.getSizeOfCanvasPixelOnScreen();
|
55
54
|
}
|
56
|
-
drawPoints(..._points) {
|
57
|
-
}
|
55
|
+
drawPoints(..._points) { }
|
58
56
|
}
|
@@ -1,12 +1,8 @@
|
|
1
1
|
const isUppercaseLetter = (text) => {
|
2
|
-
return text.toUpperCase() === text
|
3
|
-
&& text.toLowerCase() !== text
|
4
|
-
&& text.length === 1;
|
2
|
+
return text.toUpperCase() === text && text.toLowerCase() !== text && text.length === 1;
|
5
3
|
};
|
6
4
|
const isLowercaseLetter = (text) => {
|
7
|
-
return text.toLowerCase() === text
|
8
|
-
&& text.toUpperCase() !== text
|
9
|
-
&& text.length === 1;
|
5
|
+
return text.toLowerCase() === text && text.toUpperCase() !== text && text.length === 1;
|
10
6
|
};
|
11
7
|
/** Represents a key combination that can trigger a keyboard shortcut. */
|
12
8
|
export default class KeyBinding {
|
@@ -49,12 +45,10 @@ export default class KeyBinding {
|
|
49
45
|
const shortcutControlOrMeta = this.controlOrMeta;
|
50
46
|
// Match ctrl/meta if the shortcut doesn't have controlOrMeta specified
|
51
47
|
// (controlOrMeta should match either).
|
52
|
-
const ctrlAndMetaMatches = ctrlKey === this.ctrlKey
|
53
|
-
|
54
|
-
&&
|
55
|
-
|
56
|
-
&& altKey === this.altKey
|
57
|
-
&& (shiftKey === this.shiftKey || this.shiftKey === undefined);
|
48
|
+
const ctrlAndMetaMatches = ctrlKey === this.ctrlKey && metaKey === this.metaKey && !shortcutControlOrMeta;
|
49
|
+
const matches = (ctrlAndMetaMatches || (shortcutControlOrMeta && keyEventHasCtrlOrMeta)) &&
|
50
|
+
altKey === this.altKey &&
|
51
|
+
(shiftKey === this.shiftKey || this.shiftKey === undefined);
|
58
52
|
return matches;
|
59
53
|
}
|
60
54
|
/**
|
@@ -77,8 +77,8 @@ class KeyboardShortcutManager {
|
|
77
77
|
return false;
|
78
78
|
}
|
79
79
|
// Convert the strings to shortcut maps.
|
80
|
-
const shortcutsAsShortcuts = shortcuts.map(shortcut => {
|
81
|
-
if (typeof
|
80
|
+
const shortcutsAsShortcuts = shortcuts.map((shortcut) => {
|
81
|
+
if (typeof shortcut === 'string') {
|
82
82
|
return KeyBinding.fromString(shortcut);
|
83
83
|
}
|
84
84
|
return shortcut;
|
@@ -1,9 +1,14 @@
|
|
1
1
|
import { RenderingMode } from '../rendering/Display.mjs';
|
2
2
|
import Editor from '../Editor.mjs';
|
3
|
+
import getLocalizationTable from '../localizations/getLocalizationTable.mjs';
|
3
4
|
/** Creates an editor. Should only be used in test files. */
|
4
5
|
export default (settings) => {
|
5
6
|
if (jest === undefined) {
|
6
7
|
throw new Error('Files in the testing/ folder should only be used in tests!');
|
7
8
|
}
|
8
|
-
return new Editor(document.body, {
|
9
|
+
return new Editor(document.body, {
|
10
|
+
renderingMode: RenderingMode.DummyRenderer,
|
11
|
+
localization: getLocalizationTable(['en']),
|
12
|
+
...settings,
|
13
|
+
});
|
9
14
|
};
|
@@ -1,3 +1,6 @@
|
|
1
|
+
interface Options {
|
2
|
+
tag?: string;
|
3
|
+
}
|
1
4
|
/** Returns the first node or element with `textContent` matching `expectedText`. */
|
2
|
-
declare const findNodeWithText: (expectedText: string, parent: Node) => Node | null;
|
5
|
+
declare const findNodeWithText: (expectedText: string, parent: Node, options?: Options) => Node | null;
|
3
6
|
export default findNodeWithText;
|
@@ -1,10 +1,19 @@
|
|
1
1
|
/** Returns the first node or element with `textContent` matching `expectedText`. */
|
2
|
-
const findNodeWithText = (expectedText, parent) => {
|
2
|
+
const findNodeWithText = (expectedText, parent, options = {}) => {
|
3
|
+
const { tag } = options;
|
3
4
|
if (parent.textContent === expectedText) {
|
4
|
-
|
5
|
+
const matchesTag = (() => {
|
6
|
+
// No tag check necessary?
|
7
|
+
if (!tag)
|
8
|
+
return true;
|
9
|
+
return parent instanceof Element && tag.toUpperCase() === parent.tagName;
|
10
|
+
})();
|
11
|
+
if (matchesTag) {
|
12
|
+
return parent;
|
13
|
+
}
|
5
14
|
}
|
6
15
|
for (const child of parent.childNodes) {
|
7
|
-
const results = findNodeWithText(expectedText, child);
|
16
|
+
const results = findNodeWithText(expectedText, child, options);
|
8
17
|
if (results) {
|
9
18
|
return results;
|
10
19
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/** Returns the smallest ID not used by the pointers in the given list. */
|
2
2
|
const getUniquePointerId = (pointers) => {
|
3
3
|
let ptrId = 0;
|
4
|
-
const pointerIds = pointers.map(ptr => ptr.id);
|
4
|
+
const pointerIds = pointers.map((ptr) => ptr.id);
|
5
5
|
pointerIds.sort();
|
6
6
|
for (const pointerId of pointerIds) {
|
7
7
|
if (ptrId === pointerId) {
|
@@ -1,12 +1,16 @@
|
|
1
1
|
/** Swipes `element` using HTML pointer events. */
|
2
2
|
const sendHtmlSwipe = async (element, start, end, timeMs = 300) => {
|
3
|
-
element.dispatchEvent(new PointerEvent('pointerdown', { isPrimary: true, clientX: start.x, clientY: start.y
|
3
|
+
element.dispatchEvent(new PointerEvent('pointerdown', { isPrimary: true, clientX: start.x, clientY: start.y }));
|
4
4
|
const step = 0.1;
|
5
5
|
for (let i = 0; i < 1; i += step) {
|
6
6
|
await jest.advanceTimersByTimeAsync(timeMs * step);
|
7
7
|
const currentPoint = start.lerp(end, i);
|
8
|
-
element.dispatchEvent(new PointerEvent('pointermove', {
|
8
|
+
element.dispatchEvent(new PointerEvent('pointermove', {
|
9
|
+
isPrimary: true,
|
10
|
+
clientX: currentPoint.x,
|
11
|
+
clientY: currentPoint.y,
|
12
|
+
}));
|
9
13
|
}
|
10
|
-
element.dispatchEvent(new PointerEvent('pointerup', { isPrimary: true, clientX: end.x, clientY: end.y
|
14
|
+
element.dispatchEvent(new PointerEvent('pointerup', { isPrimary: true, clientX: end.x, clientY: end.y }));
|
11
15
|
};
|
12
16
|
export default sendHtmlSwipe;
|
@@ -12,9 +12,7 @@ const sendPenEvent = (editor, eventType, point, allPointers, deviceType = Pointe
|
|
12
12
|
const mainPointer = Pointer.ofCanvasPoint(point, eventType !== InputEvtType.PointerUpEvt, editor.viewport, id, deviceType);
|
13
13
|
editor.toolController.dispatchInputEvent({
|
14
14
|
kind: eventType,
|
15
|
-
allPointers: allPointers ?? [
|
16
|
-
mainPointer,
|
17
|
-
],
|
15
|
+
allPointers: allPointers ?? [mainPointer],
|
18
16
|
current: mainPointer,
|
19
17
|
});
|
20
18
|
return mainPointer;
|
@@ -45,10 +45,7 @@ const sendTouchEvent = (editor, eventType, screenPos, allOtherPointers) => {
|
|
45
45
|
const mainPointer = Pointer.ofCanvasPoint(canvasPos, eventType !== InputEvtType.PointerUpEvt, editor.viewport, ptrId, PointerDevice.Touch);
|
46
46
|
editor.toolController.dispatchInputEvent({
|
47
47
|
kind: eventType,
|
48
|
-
allPointers: [
|
49
|
-
...(allOtherPointers ?? []),
|
50
|
-
mainPointer,
|
51
|
-
],
|
48
|
+
allPointers: [...(allOtherPointers ?? []), mainPointer],
|
52
49
|
current: mainPointer,
|
53
50
|
});
|
54
51
|
return mainPointer;
|
@@ -17,7 +17,9 @@ const startPinchGesture = (editor, center, initialDistance, initialRotation) =>
|
|
17
17
|
};
|
18
18
|
let [touchPoint1, touchPoint2] = computeTouchPoints(center, initialDistance, initialRotation);
|
19
19
|
let firstPointer = sendTouchEvent(editor, InputEvtType.PointerDownEvt, touchPoint1);
|
20
|
-
let secondPointer = sendTouchEvent(editor, InputEvtType.PointerDownEvt, touchPoint2, [
|
20
|
+
let secondPointer = sendTouchEvent(editor, InputEvtType.PointerDownEvt, touchPoint2, [
|
21
|
+
firstPointer,
|
22
|
+
]);
|
21
23
|
return {
|
22
24
|
update(center, distance, rotation) {
|
23
25
|
const eventType = InputEvtType.PointerMoveEvt;
|
@@ -110,6 +110,25 @@ export default abstract class AbstractToolbar {
|
|
110
110
|
* as being the value of `mustBeToplevel`.
|
111
111
|
*
|
112
112
|
* @return The added button.
|
113
|
+
*
|
114
|
+
* **Example**:
|
115
|
+
* ```ts,runnable
|
116
|
+
* import { Editor } from 'js-draw';
|
117
|
+
* const editor = new Editor(document.body);
|
118
|
+
* const toolbar = editor.addToolbar();
|
119
|
+
*
|
120
|
+
* function makeTrashIcon() {
|
121
|
+
* const container = document.createElement('div');
|
122
|
+
* container.textContent = '🗑️';
|
123
|
+
* return container;
|
124
|
+
* }
|
125
|
+
*
|
126
|
+
* toolbar.addActionButton({
|
127
|
+
* icon: makeTrashIcon(), // can be any Element not in the DOM
|
128
|
+
* label: 'Delete all',
|
129
|
+
* }, () => {
|
130
|
+
* alert('to-do!');
|
131
|
+
* });
|
113
132
|
*/
|
114
133
|
addActionButton(title: string | ActionButtonIcon, command: () => void, options?: ToolbarActionButtonOptions | boolean): BaseWidget;
|
115
134
|
/**
|
@@ -133,7 +133,7 @@ class AbstractToolbar {
|
|
133
133
|
initColoris();
|
134
134
|
}
|
135
135
|
};
|
136
|
-
__classPrivateFieldGet(this, _AbstractToolbar_listeners, "f").push(this.editor.notifier.on(EditorEventType.ColorPickerToggled, event => {
|
136
|
+
__classPrivateFieldGet(this, _AbstractToolbar_listeners, "f").push(this.editor.notifier.on(EditorEventType.ColorPickerToggled, (event) => {
|
137
137
|
if (event.kind !== EditorEventType.ColorPickerToggled) {
|
138
138
|
return;
|
139
139
|
}
|
@@ -144,7 +144,7 @@ class AbstractToolbar {
|
|
144
144
|
}
|
145
145
|
}));
|
146
146
|
// Add newly-selected colors to the swatch.
|
147
|
-
__classPrivateFieldGet(this, _AbstractToolbar_listeners, "f").push(this.editor.notifier.on(EditorEventType.ColorPickerColorSelected, event => {
|
147
|
+
__classPrivateFieldGet(this, _AbstractToolbar_listeners, "f").push(this.editor.notifier.on(EditorEventType.ColorPickerColorSelected, (event) => {
|
148
148
|
if (event.kind === EditorEventType.ColorPickerColorSelected) {
|
149
149
|
addColorToSwatch(event.color.toHexString());
|
150
150
|
}
|
@@ -188,7 +188,7 @@ class AbstractToolbar {
|
|
188
188
|
const id = widget.getUniqueIdIn(__classPrivateFieldGet(this, _AbstractToolbar_widgetsById, "f"));
|
189
189
|
this.removeWidgetInternal(widget);
|
190
190
|
delete __classPrivateFieldGet(this, _AbstractToolbar_widgetsById, "f")[id];
|
191
|
-
__classPrivateFieldSet(this, _AbstractToolbar_widgetList, __classPrivateFieldGet(this, _AbstractToolbar_widgetList, "f").filter(otherWidget => otherWidget !== widget), "f");
|
191
|
+
__classPrivateFieldSet(this, _AbstractToolbar_widgetList, __classPrivateFieldGet(this, _AbstractToolbar_widgetList, "f").filter((otherWidget) => otherWidget !== widget), "f");
|
192
192
|
}
|
193
193
|
/** Returns a snapshot of the state of widgets in the toolbar. */
|
194
194
|
serializeState() {
|
@@ -264,6 +264,25 @@ class AbstractToolbar {
|
|
264
264
|
* as being the value of `mustBeToplevel`.
|
265
265
|
*
|
266
266
|
* @return The added button.
|
267
|
+
*
|
268
|
+
* **Example**:
|
269
|
+
* ```ts,runnable
|
270
|
+
* import { Editor } from 'js-draw';
|
271
|
+
* const editor = new Editor(document.body);
|
272
|
+
* const toolbar = editor.addToolbar();
|
273
|
+
*
|
274
|
+
* function makeTrashIcon() {
|
275
|
+
* const container = document.createElement('div');
|
276
|
+
* container.textContent = '🗑️';
|
277
|
+
* return container;
|
278
|
+
* }
|
279
|
+
*
|
280
|
+
* toolbar.addActionButton({
|
281
|
+
* icon: makeTrashIcon(), // can be any Element not in the DOM
|
282
|
+
* label: 'Delete all',
|
283
|
+
* }, () => {
|
284
|
+
* alert('to-do!');
|
285
|
+
* });
|
267
286
|
*/
|
268
287
|
addActionButton(title, command, options = true) {
|
269
288
|
const widget = this.makeActionButton(title, command, options);
|
@@ -331,19 +350,15 @@ class AbstractToolbar {
|
|
331
350
|
*/
|
332
351
|
addUndoRedoButtons(undoFirst = true) {
|
333
352
|
const makeUndo = () => {
|
334
|
-
return this.addTaggedActionButton([
|
335
|
-
ToolbarWidgetTag.Undo,
|
336
|
-
], {
|
353
|
+
return this.addTaggedActionButton([ToolbarWidgetTag.Undo], {
|
337
354
|
label: this.localizationTable.undo,
|
338
|
-
icon: this.editor.icons.makeUndoIcon()
|
355
|
+
icon: this.editor.icons.makeUndoIcon(),
|
339
356
|
}, () => {
|
340
357
|
this.editor.history.undo();
|
341
358
|
});
|
342
359
|
};
|
343
360
|
const makeRedo = () => {
|
344
|
-
return this.addTaggedActionButton([
|
345
|
-
ToolbarWidgetTag.Redo,
|
346
|
-
], {
|
361
|
+
return this.addTaggedActionButton([ToolbarWidgetTag.Redo], {
|
347
362
|
label: this.localizationTable.redo,
|
348
363
|
icon: this.editor.icons.makeRedoIcon(),
|
349
364
|
}, () => {
|
@@ -362,7 +377,7 @@ class AbstractToolbar {
|
|
362
377
|
}
|
363
378
|
undoButton.setDisabled(true);
|
364
379
|
redoButton.setDisabled(true);
|
365
|
-
this.editor.notifier.on(EditorEventType.UndoRedoStackUpdated, event => {
|
380
|
+
this.editor.notifier.on(EditorEventType.UndoRedoStackUpdated, (event) => {
|
366
381
|
if (event.kind !== EditorEventType.UndoRedoStackUpdated) {
|
367
382
|
throw new Error('Wrong event type!');
|
368
383
|
}
|
@@ -72,7 +72,7 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
72
72
|
this.sidebarContainer.classList.add(`${toolbarCSSPrefix}tool-properties`);
|
73
73
|
this.sidebarContent = document.createElement('div');
|
74
74
|
// Setup resizing/dragging
|
75
|
-
this.sidebarY.onUpdateAndNow(y => {
|
75
|
+
this.sidebarY.onUpdateAndNow((y) => {
|
76
76
|
const belowEdgeClassName = 'dropdown-below-edge';
|
77
77
|
if (y > 0) {
|
78
78
|
this.sidebarContainer.style.transform = `translate(0, ${y}px)`;
|
@@ -89,12 +89,12 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
89
89
|
this.closeButton.classList.add('drag-elem');
|
90
90
|
// The close button has default focus -- forward its events to the main editor so that keyboard
|
91
91
|
// shortcuts still work.
|
92
|
-
this.editor.handleKeyEventsFrom(this.closeButton, event => {
|
92
|
+
this.editor.handleKeyEventsFrom(this.closeButton, (event) => {
|
93
93
|
// Don't send
|
94
94
|
return event.code !== 'Space' && event.code !== 'Enter' && event.code !== 'Tab';
|
95
95
|
});
|
96
96
|
// Close the sidebar when pressing escape
|
97
|
-
this.sidebarContainer.addEventListener('keyup', event => {
|
97
|
+
this.sidebarContainer.addEventListener('keyup', (event) => {
|
98
98
|
if (!event.defaultPrevented && event.code === 'Escape') {
|
99
99
|
this.sidebarVisible.set(false);
|
100
100
|
event.preventDefault();
|
@@ -108,7 +108,7 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
108
108
|
};
|
109
109
|
this.sidebarTitle = MutableReactiveValue.fromInitialValue('');
|
110
110
|
this.layoutManager = new EdgeToolbarLayoutManager(setSidebarContent, this.sidebarTitle, this.sidebarVisible, editor.announceForAccessibility.bind(editor), localizationTable);
|
111
|
-
this.sidebarTitle.onUpdateAndNow(title => {
|
111
|
+
this.sidebarTitle.onUpdateAndNow((title) => {
|
112
112
|
this.closeButton.setAttribute('aria-label', localizationTable.closeSidebar(title));
|
113
113
|
});
|
114
114
|
// Make things visible/keep hidden.
|
@@ -127,7 +127,7 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
127
127
|
this.menuContainer.style.opacity = '0';
|
128
128
|
}
|
129
129
|
const prefersReduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)') ?? '';
|
130
|
-
this.sidebarVisible.onUpdate(visible => {
|
130
|
+
this.sidebarVisible.onUpdate((visible) => {
|
131
131
|
const animationProperties = `${animationDuration}ms ease`;
|
132
132
|
// We need to use different animations when reducing motion.
|
133
133
|
const reduceMotion = prefersReduceMotion.matches ? '-reduce-motion' : '';
|
@@ -138,23 +138,19 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
138
138
|
animationTimeout = null;
|
139
139
|
}
|
140
140
|
this.menuContainer.style.display = '';
|
141
|
-
this.sidebarContainer.style.animation =
|
142
|
-
|
143
|
-
this.menuContainer.style.animation =
|
144
|
-
`${animationProperties} ${toolbarCSSPrefix}-edgemenu-container-transition-in${reduceMotion}`;
|
141
|
+
this.sidebarContainer.style.animation = `${animationProperties} ${toolbarCSSPrefix}-edgemenu-transition-in${reduceMotion}`;
|
142
|
+
this.menuContainer.style.animation = `${animationProperties} ${toolbarCSSPrefix}-edgemenu-container-transition-in${reduceMotion}`;
|
145
143
|
this.menuContainer.style.opacity = '1';
|
146
144
|
// Focus the close button when first shown, but prevent scroll because the button
|
147
145
|
// is likely at the bottom of the screen (and we want the full sidebar to remain
|
148
146
|
// visible).
|
149
|
-
this.closeButton.focus({ preventScroll: true
|
147
|
+
this.closeButton.focus({ preventScroll: true });
|
150
148
|
}
|
151
149
|
else {
|
152
150
|
this.closeColorPickers();
|
153
151
|
if (animationTimeout === null) {
|
154
|
-
this.sidebarContainer.style.animation =
|
155
|
-
|
156
|
-
this.menuContainer.style.animation =
|
157
|
-
`${animationProperties} ${toolbarCSSPrefix}-edgemenu-container-transition-out${reduceMotion}`;
|
152
|
+
this.sidebarContainer.style.animation = `${animationProperties} ${toolbarCSSPrefix}-edgemenu-transition-out${reduceMotion}`;
|
153
|
+
this.menuContainer.style.animation = `${animationProperties} ${toolbarCSSPrefix}-edgemenu-container-transition-out${reduceMotion}`;
|
158
154
|
// Manually set the container's opacity to prevent flickering when closing
|
159
155
|
// the toolbar.
|
160
156
|
this.menuContainer.style.opacity = '0';
|
@@ -197,7 +193,7 @@ export default class EdgeToolbar extends AbstractToolbar {
|
|
197
193
|
break;
|
198
194
|
}
|
199
195
|
}
|
200
|
-
const perButtonPadding = Math.round(extraPadding / numVisibleButtons * 10) / 10;
|
196
|
+
const perButtonPadding = Math.round((extraPadding / numVisibleButtons) * 10) / 10;
|
201
197
|
this.toolbarToolRow.style.setProperty('--extra-left-right-padding', `${perButtonPadding}px`);
|
202
198
|
};
|
203
199
|
const actionRowBBox = this.toolbarActionRow.getBoundingClientRect();
|
@@ -80,9 +80,13 @@ export default class IconProvider {
|
|
80
80
|
* @returns An object with both the definition of a checkerboard pattern and the syntax to
|
81
81
|
* reference that pattern. The defs provided by this function should be wrapped within a
|
82
82
|
* `<defs></defs>` element.
|
83
|
+
*
|
84
|
+
* **Note**: This function's return value includes both `patternDefElement` (which returns
|
85
|
+
* an Element) and a (deprecated) `patternDef` string. Avoid using the `patternDef` result.
|
83
86
|
*/
|
84
87
|
protected makeCheckerboardPattern(): {
|
85
|
-
|
88
|
+
patternDefElement: SVGElement;
|
89
|
+
readonly patternDef: string;
|
86
90
|
patternRef: string;
|
87
91
|
};
|
88
92
|
/**
|