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
@@ -10,31 +10,32 @@ import Viewport from '../Viewport.mjs';
|
|
10
10
|
import { makeFreehandLineBuilder } from '../components/builders/FreehandLineBuilder.mjs';
|
11
11
|
import { makePolylineBuilder } from '../components/builders/PolylineBuilder.mjs';
|
12
12
|
import { EraserMode } from '../tools/Eraser.mjs';
|
13
|
+
import { createSvgElement, createSvgElements, createSvgPaths } from '../util/createElement.mjs';
|
13
14
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
14
|
-
const iconColorFill = `
|
15
|
-
style='fill: var(--icon-color);'
|
16
|
-
`;
|
17
|
-
const iconColorStrokeFill = `
|
18
|
-
style='fill: var(--icon-color); stroke: var(--icon-color);'
|
19
|
-
`;
|
20
15
|
let checkerboardIdCounter = 0;
|
21
16
|
const makeCheckerboardPattern = () => {
|
22
17
|
const id = `checkerboard-${checkerboardIdCounter++}`;
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
`;
|
18
|
+
const patternElement = createSvgElement('pattern', {
|
19
|
+
id: id,
|
20
|
+
viewBox: '0,0,10,10',
|
21
|
+
width: '20%',
|
22
|
+
height: '20%',
|
23
|
+
patternUnits: 'userSpaceOnUse',
|
24
|
+
children: createSvgElements('rect', [
|
25
|
+
{ x: 0, y: 0, width: 10, height: 10, fill: 'white' },
|
26
|
+
{ x: 0, y: 0, width: 5, height: 5, fill: 'gray' },
|
27
|
+
{ x: 5, y: 5, width: 5, height: 5, fill: 'gray' },
|
28
|
+
]),
|
29
|
+
});
|
36
30
|
const patternRef = `url(#${id})`;
|
37
|
-
return {
|
31
|
+
return {
|
32
|
+
patternDefElement: patternElement,
|
33
|
+
// @deprecated use patternDefElement
|
34
|
+
get patternDef() {
|
35
|
+
return patternElement.innerHTML;
|
36
|
+
},
|
37
|
+
patternRef,
|
38
|
+
};
|
38
39
|
};
|
39
40
|
const makeRedoIcon = (mirror) => {
|
40
41
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
@@ -50,11 +51,14 @@ const makeRedoIcon = (mirror) => {
|
|
50
51
|
transform-origin: center;
|
51
52
|
}
|
52
53
|
</style>
|
53
|
-
<path
|
54
|
-
d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
|
55
|
-
class='toolbar-svg-undo-redo-icon'
|
56
|
-
style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
|
57
54
|
`;
|
55
|
+
const path = document.createElementNS(svgNamespace, 'path');
|
56
|
+
path.setAttribute('d', 'M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80');
|
57
|
+
path.classList.add('toolbar-svg-undo-redo-icon');
|
58
|
+
if (mirror) {
|
59
|
+
path.style.transform = 'scale(-1, 1)';
|
60
|
+
}
|
61
|
+
icon.appendChild(path);
|
58
62
|
icon.setAttribute('viewBox', '0 0 100 100');
|
59
63
|
return icon;
|
60
64
|
};
|
@@ -102,65 +106,62 @@ class IconProvider {
|
|
102
106
|
return makeRedoIcon(false);
|
103
107
|
}
|
104
108
|
makeDropdownIcon() {
|
105
|
-
const icon =
|
106
|
-
icon.innerHTML = `
|
107
|
-
<g>
|
108
|
-
<path
|
109
|
-
d='M5,10 L50,90 L95,10 Z'
|
110
|
-
${iconColorFill}
|
111
|
-
/>
|
112
|
-
</g>
|
113
|
-
`;
|
109
|
+
const icon = this.makeIconFromPath('M5,10 L50,90 L95,10 Z');
|
114
110
|
icon.setAttribute('viewBox', '-10 -10 110 110');
|
115
111
|
return icon;
|
116
112
|
}
|
117
113
|
makeEraserIcon(eraserSize, mode) {
|
118
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
119
114
|
eraserSize ??= 10;
|
120
115
|
const scaledSize = eraserSize / 4;
|
121
116
|
const eraserColor = '#ff70af';
|
122
117
|
// Draw an eraser-like shape. Created with Inkscape
|
123
|
-
icon
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
118
|
+
const icon = createSvgElement('svg', {
|
119
|
+
viewBox: '0 0 120 120',
|
120
|
+
children: [
|
121
|
+
createSvgElement('defs', {
|
122
|
+
children: [
|
123
|
+
createSvgElement('linearGradient', {
|
124
|
+
id: 'dash-pattern',
|
125
|
+
children: createSvgElements('stop', [
|
126
|
+
{ offset: '80%', 'stop-color': eraserColor },
|
127
|
+
{ offset: '85%', 'stop-color': 'white' },
|
128
|
+
{ offset: '90%', 'stop-color': eraserColor },
|
129
|
+
]),
|
130
|
+
}),
|
131
|
+
],
|
132
|
+
}),
|
133
|
+
createSvgElement('path', {
|
134
|
+
fill: mode === EraserMode.PartialStroke ? 'url(#dash-pattern)' : eraserColor,
|
135
|
+
stroke: 'black',
|
136
|
+
transform: 'rotate(41.35)',
|
137
|
+
d: `
|
138
|
+
M 52.5 27
|
139
|
+
C 50 28.9 48.9 31.7 48.9 34.8
|
140
|
+
L 48.9 39.8
|
141
|
+
C 48.9 45.3 53.4 49.8 58.9 49.8
|
142
|
+
L 103.9 49.8
|
143
|
+
C 105.8 49.8 107.6 49.2 109.1 48.3
|
144
|
+
L 110.2 ${scaledSize + 49.5} L 159.7 ${scaledSize + 5}
|
145
|
+
L 157.7 ${-scaledSize + 5.2} L 112.4 ${49.5 - scaledSize}
|
146
|
+
C 113.4 43.5 113.9 41.7 113.9 39.8
|
147
|
+
L 113.9 34.8
|
148
|
+
C 113.9 29.3 109.4 24.8 103.9 24.8
|
149
|
+
L 58.9 24.8
|
150
|
+
C 56.5 24.8 54.3 25.7 52.5 27
|
151
|
+
z
|
152
|
+
`,
|
153
|
+
}),
|
154
|
+
createSvgElement('rect', {
|
155
|
+
stroke: '#cc8077',
|
156
|
+
fill: 'var(--icon-color)',
|
157
|
+
width: 65,
|
158
|
+
height: 75,
|
159
|
+
x: 48.9,
|
160
|
+
y: -38.7,
|
161
|
+
transform: 'rotate(41.35)',
|
162
|
+
}),
|
163
|
+
],
|
164
|
+
});
|
164
165
|
return icon;
|
165
166
|
}
|
166
167
|
makeSelectionIcon() {
|
@@ -168,8 +169,8 @@ class IconProvider {
|
|
168
169
|
// Draw a cursor-like shape
|
169
170
|
icon.innerHTML = `
|
170
171
|
<g>
|
171
|
-
<rect x=10 y=10 width=70 height=70 fill=
|
172
|
-
<rect x=75 y=75 width=10 height=10 fill=
|
172
|
+
<rect x="10" y="10" width="70" height="70" fill="pink" stroke="black"/>
|
173
|
+
<rect x="75" y="75" width="10" height="10" fill="white" stroke="black"/>
|
173
174
|
</g>
|
174
175
|
`;
|
175
176
|
icon.setAttribute('viewBox', '0 0 100 100');
|
@@ -432,8 +433,6 @@ class IconProvider {
|
|
432
433
|
const strokeSize = Math.round(Math.sqrt(penStyle.thickness) * 4);
|
433
434
|
const color = penStyle.color;
|
434
435
|
const rounded = this.isRoundedTipPen(penStyle);
|
435
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
436
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
437
436
|
const tipThickness = strokeSize / 2;
|
438
437
|
const inkTipPath = `
|
439
438
|
M ${15 - tipThickness},${80 - tipThickness}
|
@@ -466,71 +465,35 @@ class IconProvider {
|
|
466
465
|
const pencilTipColor = Color4.fromHex('#f4d7d7');
|
467
466
|
const tipColor = pencilTipColor.mix(color, tipThickness / 40 - 0.1).toHexString();
|
468
467
|
const checkerboardPattern = makeCheckerboardPattern();
|
469
|
-
const
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
const grip = `
|
499
|
-
<path
|
500
|
-
${iconColorStrokeFill}
|
501
|
-
d="${gripMainPath}"
|
502
|
-
/>
|
503
|
-
|
504
|
-
<!-- shadows -->
|
505
|
-
<path
|
506
|
-
fill="rgba(150, 150, 150, 0.3)"
|
507
|
-
d="${gripShadow1Path}"
|
508
|
-
/>
|
509
|
-
<path
|
510
|
-
fill="rgba(100, 100, 100, 0.2)"
|
511
|
-
d="${gripShadow2Path}"
|
512
|
-
/>
|
513
|
-
|
514
|
-
<!-- color bubble -->
|
515
|
-
<path
|
516
|
-
fill="${checkerboardPattern.patternRef}"
|
517
|
-
d="${colorBubblePath}"
|
518
|
-
/>
|
519
|
-
<path
|
520
|
-
fill="${color}"
|
521
|
-
d="${colorBubblePath}"
|
522
|
-
/>
|
523
|
-
`;
|
524
|
-
icon.innerHTML = `
|
525
|
-
<defs>
|
526
|
-
${checkerboardPattern.patternDef}
|
527
|
-
</defs>
|
528
|
-
<g>
|
529
|
-
${ink}
|
530
|
-
${penTip}
|
531
|
-
${grip}
|
532
|
-
</g>
|
533
|
-
`;
|
468
|
+
const colorString = color.toHexString();
|
469
|
+
const ink = createSvgPaths({
|
470
|
+
fill: checkerboardPattern.patternRef,
|
471
|
+
d: inkTipPath,
|
472
|
+
}, {
|
473
|
+
fill: checkerboardPattern.patternRef,
|
474
|
+
d: inkTrailPath,
|
475
|
+
}, {
|
476
|
+
fill: colorString,
|
477
|
+
d: inkTipPath,
|
478
|
+
}, {
|
479
|
+
fill: colorString,
|
480
|
+
d: inkTrailPath,
|
481
|
+
});
|
482
|
+
const penTip = createSvgPaths({ fill: checkerboardPattern.patternRef, d: penTipPath }, { fill: tipColor, stroke: colorString, d: penTipPath });
|
483
|
+
const grip = createSvgPaths({ fill: 'var(--icon-color)', stroke: 'var(--icon-color)', d: gripMainPath },
|
484
|
+
// Shadows
|
485
|
+
{ fill: 'rgba(150, 150, 150, 0.3)', d: gripShadow1Path }, { fill: 'rgba(100, 100, 100, 0.2)', d: gripShadow2Path },
|
486
|
+
// Color bubble
|
487
|
+
{ fill: checkerboardPattern.patternRef, d: colorBubblePath }, { fill: colorString, d: colorBubblePath });
|
488
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
489
|
+
icon.setAttribute('viewBox', '0 0 100 100');
|
490
|
+
const iconMainContent = createSvgElement('g', {
|
491
|
+
children: [ink, penTip, grip].flat(),
|
492
|
+
});
|
493
|
+
const defs = createSvgElement('defs', {
|
494
|
+
children: [checkerboardPattern.patternDefElement],
|
495
|
+
});
|
496
|
+
icon.replaceChildren(defs, iconMainContent);
|
534
497
|
return icon;
|
535
498
|
}
|
536
499
|
makeIconFromFactory(penStyle) {
|
@@ -562,11 +525,11 @@ class IconProvider {
|
|
562
525
|
if (includeTransparencyGrid) {
|
563
526
|
const checkerboardPattern = makeCheckerboardPattern();
|
564
527
|
const defs = document.createElementNS(svgNamespace, 'defs');
|
565
|
-
defs.
|
528
|
+
defs.appendChild(checkerboardPattern.patternDefElement);
|
566
529
|
icon.appendChild(defs);
|
567
530
|
const background = document.createElementNS(svgNamespace, 'g');
|
568
531
|
icon.appendChild(background);
|
569
|
-
renderer = new class extends SVGRenderer {
|
532
|
+
renderer = new (class extends SVGRenderer {
|
570
533
|
constructor() {
|
571
534
|
super(icon, viewport);
|
572
535
|
}
|
@@ -588,7 +551,7 @@ class IconProvider {
|
|
588
551
|
}
|
589
552
|
return addedPath;
|
590
553
|
}
|
591
|
-
}();
|
554
|
+
})();
|
592
555
|
}
|
593
556
|
else {
|
594
557
|
renderer = new SVGRenderer(icon, viewport);
|
@@ -636,7 +599,7 @@ class IconProvider {
|
|
636
599
|
if (color) {
|
637
600
|
const checkerboardPattern = makeCheckerboardPattern();
|
638
601
|
const defs = document.createElementNS(svgNamespace, 'defs');
|
639
|
-
defs.
|
602
|
+
defs.appendChild(checkerboardPattern.patternDefElement);
|
640
603
|
icon.appendChild(defs);
|
641
604
|
const fluidBackground = document.createElementNS(svgNamespace, 'path');
|
642
605
|
const fluid = document.createElementNS(svgNamespace, 'path');
|
@@ -841,6 +804,9 @@ class IconProvider {
|
|
841
804
|
* @returns An object with both the definition of a checkerboard pattern and the syntax to
|
842
805
|
* reference that pattern. The defs provided by this function should be wrapped within a
|
843
806
|
* `<defs></defs>` element.
|
807
|
+
*
|
808
|
+
* **Note**: This function's return value includes both `patternDefElement` (which returns
|
809
|
+
* an Element) and a (deprecated) `patternDef` string. Avoid using the `patternDef` result.
|
844
810
|
*/
|
845
811
|
makeCheckerboardPattern() {
|
846
812
|
return makeCheckerboardPattern();
|
@@ -855,7 +821,9 @@ class IconProvider {
|
|
855
821
|
return penStyle.factory === makePolylineBuilder;
|
856
822
|
}
|
857
823
|
/** Must be overridden by icon packs that need attribution. */
|
858
|
-
licenseInfo() {
|
824
|
+
licenseInfo() {
|
825
|
+
return null;
|
826
|
+
}
|
859
827
|
}
|
860
828
|
_IconProvider_instances = new WeakSet(), _IconProvider_makeXIcon = function _IconProvider_makeXIcon() {
|
861
829
|
const strokeWidth = '6px';
|
@@ -45,7 +45,7 @@ export const defaultToolbarLocalization = {
|
|
45
45
|
about: 'About',
|
46
46
|
inputStabilization: 'Stabilization',
|
47
47
|
strokeAutocorrect: 'Autocorrect',
|
48
|
-
touchPanning: '
|
48
|
+
touchPanning: 'Scroll with touch',
|
49
49
|
roundedTipPen: 'Round',
|
50
50
|
roundedTipPen2: 'Polyline',
|
51
51
|
flatTipPen: 'Flat',
|
@@ -62,7 +62,7 @@ export const defaultToolbarLocalization = {
|
|
62
62
|
fileInput__andNMoreFiles: (n) => `(...${n} more)`,
|
63
63
|
// Help text
|
64
64
|
penDropdown__baseHelpText: 'This tool draws shapes or freehand lines.',
|
65
|
-
penDropdown__colorHelpText:
|
65
|
+
penDropdown__colorHelpText: "Changes the pen's color",
|
66
66
|
penDropdown__thicknessHelpText: 'Changes the thickness of strokes drawn by the pen.',
|
67
67
|
penDropdown__penTypeHelpText: 'Changes the pen style.\n\nEither a “pen” style or “shape” can be chosen. Choosing a “pen” style draws freehand lines. Choosing a “shape” draws shapes.',
|
68
68
|
penDropdown__autocorrectHelpText: 'Converts approximate freehand lines and rectangles to perfect ones.\n\nThe pen must be held stationary at the end of a stroke to trigger a correction.',
|
@@ -72,17 +72,17 @@ export const defaultToolbarLocalization = {
|
|
72
72
|
handDropdown__zoomOutHelpText: 'Zooms out.',
|
73
73
|
handDropdown__resetViewHelpText: 'Resets the zoom level to 100% and resets scroll.',
|
74
74
|
handDropdown__zoomDisplayHelpText: 'Shows the current zoom level. 100% shows the image at its actual size.',
|
75
|
-
handDropdown__touchPanningHelpText: 'When enabled,
|
75
|
+
handDropdown__touchPanningHelpText: 'When enabled, touchscreen gestures move the image rather than select or draw.',
|
76
76
|
handDropdown__lockRotationHelpText: 'When enabled, prevents touch gestures from rotating the screen.',
|
77
77
|
eraserDropdown__baseHelpText: 'This tool removes strokes, images, and text under the cursor.',
|
78
78
|
eraserDropdown__thicknessHelpText: 'Changes the size of the eraser.',
|
79
79
|
eraserDropdown__fullStrokeEraserHelpText: 'When in full-stroke mode, entire shapes are erased.\n\nWhen not in full-stroke mode, shapes can be partially erased.',
|
80
80
|
selectionDropdown__baseHelpText: 'Selects content and manipulates the selection',
|
81
|
-
selectionDropdown__resizeToHelpText:
|
81
|
+
selectionDropdown__resizeToHelpText: "Crops the drawing to the size of what's currently selected.\n\nIf auto-resize is enabled, it will be disabled.",
|
82
82
|
selectionDropdown__deleteHelpText: 'Erases selected items.',
|
83
83
|
selectionDropdown__duplicateHelpText: 'Makes a copy of selected items.',
|
84
84
|
selectionDropdown__changeColorHelpText: 'Changes the color of selected items.',
|
85
|
-
pageDropdown__baseHelpText:
|
85
|
+
pageDropdown__baseHelpText: "Controls the drawing canvas' background color, pattern, and size.",
|
86
86
|
pageDropdown__backgroundColorHelpText: 'Changes the background color of the drawing canvas.',
|
87
87
|
pageDropdown__gridCheckboxHelpText: 'Enables/disables a background grid pattern.',
|
88
88
|
pageDropdown__autoresizeCheckboxHelpText: 'When checked, the page grows to fit the drawing.\n\nWhen unchecked, the page is visible and its size can be set manually.',
|
@@ -41,7 +41,7 @@ const createHelpPage = (helpItems, onItemClick, onBackgroundClick, context) => {
|
|
41
41
|
let clonedElementContainers = [];
|
42
42
|
// Clicking on the background of the help area should send an event (e.g. to allow the
|
43
43
|
// help container to be closed).
|
44
|
-
container.addEventListener('click', event => {
|
44
|
+
container.addEventListener('click', (event) => {
|
45
45
|
// If clicking directly on the container (and not on a child)
|
46
46
|
if (event.target === container) {
|
47
47
|
onBackgroundClick();
|
@@ -53,7 +53,7 @@ const createHelpPage = (helpItems, onItemClick, onBackgroundClick, context) => {
|
|
53
53
|
if (!currentItem) {
|
54
54
|
return Rect2.empty;
|
55
55
|
}
|
56
|
-
const itemBoundingBoxes = currentItem.targetElements.map(element => Rect2.of(element.getBoundingClientRect()));
|
56
|
+
const itemBoundingBoxes = currentItem.targetElements.map((element) => Rect2.of(element.getBoundingClientRect()));
|
57
57
|
return Rect2.union(...itemBoundingBoxes);
|
58
58
|
};
|
59
59
|
// Updates each cloned element's click listener and CSS classes based on whether
|
@@ -218,7 +218,9 @@ class HelpDisplay {
|
|
218
218
|
const label = this.context.localization.close;
|
219
219
|
closeButton.setAttribute('aria-label', label);
|
220
220
|
closeButton.setAttribute('title', label);
|
221
|
-
closeButton.onclick = () => {
|
221
|
+
closeButton.onclick = () => {
|
222
|
+
closeOverlay();
|
223
|
+
};
|
222
224
|
return closeButton;
|
223
225
|
};
|
224
226
|
// Wraps the label and clickable help elements
|
@@ -226,7 +228,7 @@ class HelpDisplay {
|
|
226
228
|
const currentPage = MutableReactiveValue.fromInitialValue(0);
|
227
229
|
const content = document.createElement('div');
|
228
230
|
content.classList.add('navigation-content');
|
229
|
-
const helpPage = createHelpPage(__classPrivateFieldGet(this, _HelpDisplay_helpData, "f"), newPageIndex => currentPage.set(newPageIndex), onBackgroundClick, this.context);
|
231
|
+
const helpPage = createHelpPage(__classPrivateFieldGet(this, _HelpDisplay_helpData, "f"), (newPageIndex) => currentPage.set(newPageIndex), onBackgroundClick, this.context);
|
230
232
|
helpPage.addToParent(content);
|
231
233
|
const showPage = (pageIndex) => {
|
232
234
|
if (pageIndex >= __classPrivateFieldGet(this, _HelpDisplay_helpData, "f").length || pageIndex < 0) {
|
@@ -375,12 +377,12 @@ class HelpDisplay {
|
|
375
377
|
// Close the overlay when clicking on the background (*directly* on any of the
|
376
378
|
// elements in closeOverlayTriggers).
|
377
379
|
const closeOverlayTriggers = [navigation.content, navigationButtons, overlay];
|
378
|
-
overlay.onclick = event => {
|
380
|
+
overlay.onclick = (event) => {
|
379
381
|
if (closeOverlayTriggers.includes(event.target)) {
|
380
382
|
onBackgroundClick();
|
381
383
|
}
|
382
384
|
};
|
383
|
-
overlay.onkeyup = event => {
|
385
|
+
overlay.onkeyup = (event) => {
|
384
386
|
if (event.code === 'Escape') {
|
385
387
|
closeOverlay();
|
386
388
|
event.preventDefault();
|
@@ -1,9 +1,6 @@
|
|
1
1
|
import { Vec2 } from '@js-draw/math';
|
2
2
|
const makeDraggable = (dragElement, options) => {
|
3
|
-
const dragElements = [
|
4
|
-
...options.draggableChildElements,
|
5
|
-
dragElement,
|
6
|
-
];
|
3
|
+
const dragElements = [...options.draggableChildElements, dragElement];
|
7
4
|
let lastX = 0;
|
8
5
|
let lastY = 0;
|
9
6
|
let startX = 0;
|
@@ -49,7 +46,7 @@ const makeDraggable = (dragElement, options) => {
|
|
49
46
|
return Math.hypot(lastX - startX, lastY - startY) < clickThreshold;
|
50
47
|
};
|
51
48
|
let startedDragging = false;
|
52
|
-
addEventListener('pointerdown', event => {
|
49
|
+
addEventListener('pointerdown', (event) => {
|
53
50
|
if (event.defaultPrevented || !isDraggableElement(event.target)) {
|
54
51
|
return;
|
55
52
|
}
|
@@ -80,7 +77,7 @@ const makeDraggable = (dragElement, options) => {
|
|
80
77
|
pointerDown = false;
|
81
78
|
startedDragging = false;
|
82
79
|
};
|
83
|
-
addEventListener('pointermove', event => {
|
80
|
+
addEventListener('pointermove', (event) => {
|
84
81
|
if (!event.isPrimary || !pointerDown) {
|
85
82
|
return undefined;
|
86
83
|
}
|
@@ -108,7 +105,7 @@ const makeDraggable = (dragElement, options) => {
|
|
108
105
|
startedDragging = true;
|
109
106
|
}
|
110
107
|
});
|
111
|
-
addEventListener('pointerleave', event => {
|
108
|
+
addEventListener('pointerleave', (event) => {
|
112
109
|
// Capture the pointer if it exits the container while dragging.
|
113
110
|
if (capturedPointerId === null && pointerDown && event.isPrimary) {
|
114
111
|
dragElement.setPointerCapture(event.pointerId);
|
@@ -2,13 +2,14 @@ import BaseWidget from './BaseWidget.mjs';
|
|
2
2
|
import { toolbarCSSPrefix } from '../constants.mjs';
|
3
3
|
const isToolWidgetFocused = () => {
|
4
4
|
const currentFocus = [...document.querySelectorAll('*:focus')];
|
5
|
-
return currentFocus.length &&
|
5
|
+
return (currentFocus.length &&
|
6
|
+
currentFocus.some((elem) => elem.classList.contains(`${toolbarCSSPrefix}button`)));
|
6
7
|
};
|
7
8
|
export default class BaseToolWidget extends BaseWidget {
|
8
9
|
constructor(editor, targetTool, id, localizationTable) {
|
9
10
|
super(editor, id, localizationTable);
|
10
11
|
this.targetTool = targetTool;
|
11
|
-
this.targetTool.enabledValue().onUpdateAndNow(enabled => {
|
12
|
+
this.targetTool.enabledValue().onUpdateAndNow((enabled) => {
|
12
13
|
if (enabled) {
|
13
14
|
this.setSelected(true);
|
14
15
|
// Transfer focus to the current button, only if another toolbar button is
|
@@ -98,7 +98,7 @@ export default abstract class BaseWidget {
|
|
98
98
|
addTo(parent: HTMLElement): HTMLElement;
|
99
99
|
/**
|
100
100
|
* Remove this. This allows the widget to be added to a toolbar again
|
101
|
-
* in the future using
|
101
|
+
* in the future using `addTo`.
|
102
102
|
*/
|
103
103
|
remove(): void;
|
104
104
|
focus(): void;
|
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
11
11
|
};
|
12
12
|
var _BaseWidget_instances, _a, _BaseWidget_hasDropdown, _BaseWidget_disabledDueToReadOnlyEditor, _BaseWidget_tags, _BaseWidget_removeEditorListeners, _BaseWidget_addEditorListeners;
|
13
13
|
import ToolbarShortcutHandler from '../../tools/ToolbarShortcutHandler.mjs';
|
14
|
-
import { keyPressEventFromHTMLEvent, keyUpEventFromHTMLEvent } from '../../inputEvents.mjs';
|
14
|
+
import { keyPressEventFromHTMLEvent, keyUpEventFromHTMLEvent, } from '../../inputEvents.mjs';
|
15
15
|
import { toolbarCSSPrefix } from '../constants.mjs';
|
16
16
|
import DropdownLayoutManager from './layout/DropdownLayoutManager.mjs';
|
17
17
|
import addLongPressOrHoverCssClasses from '../../util/addLongPressOrHoverCssClasses.mjs';
|
@@ -67,7 +67,7 @@ class BaseWidget {
|
|
67
67
|
this.button.tabIndex = 0;
|
68
68
|
// Disable the context menu. This allows long-press gestures to trigger the button's
|
69
69
|
// tooltip instead.
|
70
|
-
this.button.oncontextmenu = event => {
|
70
|
+
this.button.oncontextmenu = (event) => {
|
71
71
|
event.preventDefault();
|
72
72
|
};
|
73
73
|
addLongPressOrHoverCssClasses(this.button);
|
@@ -165,7 +165,7 @@ class BaseWidget {
|
|
165
165
|
return this.setUpButtonEventListeners(button);
|
166
166
|
}
|
167
167
|
setUpButtonEventListeners(button) {
|
168
|
-
const clickTriggers = { Enter: true, ' ': true
|
168
|
+
const clickTriggers = { Enter: true, ' ': true };
|
169
169
|
button.onkeydown = (evt) => {
|
170
170
|
let handled = false;
|
171
171
|
if (evt.key in clickTriggers) {
|
@@ -183,7 +183,7 @@ class BaseWidget {
|
|
183
183
|
evt.preventDefault();
|
184
184
|
}
|
185
185
|
};
|
186
|
-
button.onkeyup = htmlEvent => {
|
186
|
+
button.onkeyup = (htmlEvent) => {
|
187
187
|
if (htmlEvent.key in clickTriggers) {
|
188
188
|
return;
|
189
189
|
}
|
@@ -199,7 +199,7 @@ class BaseWidget {
|
|
199
199
|
}
|
200
200
|
};
|
201
201
|
// Prevent double-click zoom on some devices.
|
202
|
-
button.ondblclick = event => {
|
202
|
+
button.ondblclick = (event) => {
|
203
203
|
event.preventDefault();
|
204
204
|
};
|
205
205
|
}
|
@@ -251,7 +251,7 @@ class BaseWidget {
|
|
251
251
|
this.container.replaceChildren();
|
252
252
|
this.button.replaceChildren(this.icon, this.label);
|
253
253
|
this.container.appendChild(this.button);
|
254
|
-
const helpDisplay = new HelpDisplay(content => this.editor.createHTMLOverlay(content), this.editor);
|
254
|
+
const helpDisplay = new HelpDisplay((content) => this.editor.createHTMLOverlay(content), this.editor);
|
255
255
|
const helpText = this.getHelpText();
|
256
256
|
if (helpText) {
|
257
257
|
helpDisplay.registerTextHelpForElement(this.dropdownContent, [this.getTitle(), helpText].join('\n\n'));
|
@@ -271,7 +271,7 @@ class BaseWidget {
|
|
271
271
|
getTitle: () => this.getTitle(),
|
272
272
|
isToplevel: () => this.toplevel,
|
273
273
|
});
|
274
|
-
this.dropdown.visible.onUpdate(visible => {
|
274
|
+
this.dropdown.visible.onUpdate((visible) => {
|
275
275
|
if (visible) {
|
276
276
|
this.container.classList.add('dropdownVisible');
|
277
277
|
}
|
@@ -300,7 +300,7 @@ class BaseWidget {
|
|
300
300
|
}
|
301
301
|
/**
|
302
302
|
* Remove this. This allows the widget to be added to a toolbar again
|
303
|
-
* in the future using
|
303
|
+
* in the future using `addTo`.
|
304
304
|
*/
|
305
305
|
remove() {
|
306
306
|
this.container.remove();
|
@@ -469,7 +469,7 @@ _a = BaseWidget, _BaseWidget_hasDropdown = new WeakMap(), _BaseWidget_disabledDu
|
|
469
469
|
handler.removeListener(keyPressListener);
|
470
470
|
};
|
471
471
|
}
|
472
|
-
const readOnlyListener = this.editor.isReadOnlyReactiveValue().onUpdateAndNow(readOnly => {
|
472
|
+
const readOnlyListener = this.editor.isReadOnlyReactiveValue().onUpdateAndNow((readOnly) => {
|
473
473
|
if (readOnly && this.shouldAutoDisableInReadOnlyEditor() && !this.disabled) {
|
474
474
|
this.setDisabled(true);
|
475
475
|
__classPrivateFieldSet(this, _BaseWidget_disabledDueToReadOnlyEditor, true, "f");
|
@@ -101,7 +101,7 @@ class DocumentPropertiesWidget extends BaseWidget {
|
|
101
101
|
const backgroundColorRow = document.createElement('div');
|
102
102
|
const backgroundColorLabel = document.createElement('label');
|
103
103
|
backgroundColorLabel.innerText = this.localizationTable.backgroundColor;
|
104
|
-
const { input: colorInput, container: backgroundColorInputContainer, setValue: setBgColorInputValue, registerWithHelpTextDisplay: registerHelpForInputs, } = makeColorInput(this.editor, color => {
|
104
|
+
const { input: colorInput, container: backgroundColorInputContainer, setValue: setBgColorInputValue, registerWithHelpTextDisplay: registerHelpForInputs, } = makeColorInput(this.editor, (color) => {
|
105
105
|
if (!color.eq(this.getBackgroundColor())) {
|
106
106
|
this.setBackgroundColor(color);
|
107
107
|
}
|
@@ -116,7 +116,7 @@ class DocumentPropertiesWidget extends BaseWidget {
|
|
116
116
|
helpDisplay?.registerTextHelpForElement(backgroundColorRow, this.localizationTable.pageDropdown__backgroundColorHelpText);
|
117
117
|
registerHelpForInputs(helpDisplay);
|
118
118
|
};
|
119
|
-
return { setBgColorInputValue, backgroundColorRow, registerWithHelp
|
119
|
+
return { setBgColorInputValue, backgroundColorRow, registerWithHelp };
|
120
120
|
};
|
121
121
|
const { backgroundColorRow, setBgColorInputValue, registerWithHelp: registerBackgroundRowWithHelp, } = makeBackgroundColorInput();
|
122
122
|
const makeCheckboxRow = (labelText, onChange) => {
|
@@ -8,7 +8,7 @@ class EraserToolWidget extends BaseToolWidget {
|
|
8
8
|
super(editor, tool, 'eraser-tool-widget', localizationTable);
|
9
9
|
this.tool = tool;
|
10
10
|
this.updateInputs = () => { };
|
11
|
-
this.editor.notifier.on(EditorEventType.ToolUpdated, toolEvt => {
|
11
|
+
this.editor.notifier.on(EditorEventType.ToolUpdated, (toolEvt) => {
|
12
12
|
if (toolEvt.kind === EditorEventType.ToolUpdated && toolEvt.tool === this.tool) {
|
13
13
|
this.updateInputs();
|
14
14
|
this.updateIcon();
|
@@ -36,7 +36,9 @@ class EraserToolWidget extends BaseToolWidget {
|
|
36
36
|
labelElement.innerText = this.localizationTable.fullStrokeEraser;
|
37
37
|
checkboxElement.type = 'checkbox';
|
38
38
|
checkboxElement.oninput = () => {
|
39
|
-
this.tool
|
39
|
+
this.tool
|
40
|
+
.getModeValue()
|
41
|
+
.set(checkboxElement.checked ? EraserMode.FullStroke : EraserMode.PartialStroke);
|
40
42
|
};
|
41
43
|
const updateValue = () => {
|
42
44
|
checkboxElement.checked = this.tool.getModeValue().get() === EraserMode.FullStroke;
|
@@ -53,7 +55,7 @@ class EraserToolWidget extends BaseToolWidget {
|
|
53
55
|
fillDropdown(dropdown, helpDisplay) {
|
54
56
|
const container = document.createElement('div');
|
55
57
|
container.classList.add(`${toolbarCSSPrefix}spacedList`, `${toolbarCSSPrefix}nonbutton-controls-main-list`);
|
56
|
-
const thicknessSlider = makeThicknessSlider(this.editor, thickness => {
|
58
|
+
const thicknessSlider = makeThicknessSlider(this.editor, (thickness) => {
|
57
59
|
this.tool.setThickness(thickness);
|
58
60
|
});
|
59
61
|
thicknessSlider.setBounds(10, 55);
|