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
@@ -15,31 +15,32 @@ const Viewport_1 = __importDefault(require("../Viewport"));
|
|
15
15
|
const FreehandLineBuilder_1 = require("../components/builders/FreehandLineBuilder");
|
16
16
|
const PolylineBuilder_1 = require("../components/builders/PolylineBuilder");
|
17
17
|
const Eraser_1 = require("../tools/Eraser");
|
18
|
+
const createElement_1 = require("../util/createElement");
|
18
19
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
19
|
-
const iconColorFill = `
|
20
|
-
style='fill: var(--icon-color);'
|
21
|
-
`;
|
22
|
-
const iconColorStrokeFill = `
|
23
|
-
style='fill: var(--icon-color); stroke: var(--icon-color);'
|
24
|
-
`;
|
25
20
|
let checkerboardIdCounter = 0;
|
26
21
|
const makeCheckerboardPattern = () => {
|
27
22
|
const id = `checkerboard-${checkerboardIdCounter++}`;
|
28
|
-
const
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
`;
|
23
|
+
const patternElement = (0, createElement_1.createSvgElement)('pattern', {
|
24
|
+
id: id,
|
25
|
+
viewBox: '0,0,10,10',
|
26
|
+
width: '20%',
|
27
|
+
height: '20%',
|
28
|
+
patternUnits: 'userSpaceOnUse',
|
29
|
+
children: (0, createElement_1.createSvgElements)('rect', [
|
30
|
+
{ x: 0, y: 0, width: 10, height: 10, fill: 'white' },
|
31
|
+
{ x: 0, y: 0, width: 5, height: 5, fill: 'gray' },
|
32
|
+
{ x: 5, y: 5, width: 5, height: 5, fill: 'gray' },
|
33
|
+
]),
|
34
|
+
});
|
41
35
|
const patternRef = `url(#${id})`;
|
42
|
-
return {
|
36
|
+
return {
|
37
|
+
patternDefElement: patternElement,
|
38
|
+
// @deprecated use patternDefElement
|
39
|
+
get patternDef() {
|
40
|
+
return patternElement.innerHTML;
|
41
|
+
},
|
42
|
+
patternRef,
|
43
|
+
};
|
43
44
|
};
|
44
45
|
const makeRedoIcon = (mirror) => {
|
45
46
|
const icon = document.createElementNS(svgNamespace, 'svg');
|
@@ -55,11 +56,14 @@ const makeRedoIcon = (mirror) => {
|
|
55
56
|
transform-origin: center;
|
56
57
|
}
|
57
58
|
</style>
|
58
|
-
<path
|
59
|
-
d='M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80'
|
60
|
-
class='toolbar-svg-undo-redo-icon'
|
61
|
-
style='${mirror ? 'transform: scale(-1, 1);' : ''}'/>
|
62
59
|
`;
|
60
|
+
const path = document.createElementNS(svgNamespace, 'path');
|
61
|
+
path.setAttribute('d', 'M20,20 A15,15 0 0 1 70,80 L80,90 L60,70 L65,90 L87,90 L65,80');
|
62
|
+
path.classList.add('toolbar-svg-undo-redo-icon');
|
63
|
+
if (mirror) {
|
64
|
+
path.style.transform = 'scale(-1, 1)';
|
65
|
+
}
|
66
|
+
icon.appendChild(path);
|
63
67
|
icon.setAttribute('viewBox', '0 0 100 100');
|
64
68
|
return icon;
|
65
69
|
};
|
@@ -107,65 +111,62 @@ class IconProvider {
|
|
107
111
|
return makeRedoIcon(false);
|
108
112
|
}
|
109
113
|
makeDropdownIcon() {
|
110
|
-
const icon =
|
111
|
-
icon.innerHTML = `
|
112
|
-
<g>
|
113
|
-
<path
|
114
|
-
d='M5,10 L50,90 L95,10 Z'
|
115
|
-
${iconColorFill}
|
116
|
-
/>
|
117
|
-
</g>
|
118
|
-
`;
|
114
|
+
const icon = this.makeIconFromPath('M5,10 L50,90 L95,10 Z');
|
119
115
|
icon.setAttribute('viewBox', '-10 -10 110 110');
|
120
116
|
return icon;
|
121
117
|
}
|
122
118
|
makeEraserIcon(eraserSize, mode) {
|
123
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
124
119
|
eraserSize ??= 10;
|
125
120
|
const scaledSize = eraserSize / 4;
|
126
121
|
const eraserColor = '#ff70af';
|
127
122
|
// Draw an eraser-like shape. Created with Inkscape
|
128
|
-
icon
|
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
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
123
|
+
const icon = (0, createElement_1.createSvgElement)('svg', {
|
124
|
+
viewBox: '0 0 120 120',
|
125
|
+
children: [
|
126
|
+
(0, createElement_1.createSvgElement)('defs', {
|
127
|
+
children: [
|
128
|
+
(0, createElement_1.createSvgElement)('linearGradient', {
|
129
|
+
id: 'dash-pattern',
|
130
|
+
children: (0, createElement_1.createSvgElements)('stop', [
|
131
|
+
{ offset: '80%', 'stop-color': eraserColor },
|
132
|
+
{ offset: '85%', 'stop-color': 'white' },
|
133
|
+
{ offset: '90%', 'stop-color': eraserColor },
|
134
|
+
]),
|
135
|
+
}),
|
136
|
+
],
|
137
|
+
}),
|
138
|
+
(0, createElement_1.createSvgElement)('path', {
|
139
|
+
fill: mode === Eraser_1.EraserMode.PartialStroke ? 'url(#dash-pattern)' : eraserColor,
|
140
|
+
stroke: 'black',
|
141
|
+
transform: 'rotate(41.35)',
|
142
|
+
d: `
|
143
|
+
M 52.5 27
|
144
|
+
C 50 28.9 48.9 31.7 48.9 34.8
|
145
|
+
L 48.9 39.8
|
146
|
+
C 48.9 45.3 53.4 49.8 58.9 49.8
|
147
|
+
L 103.9 49.8
|
148
|
+
C 105.8 49.8 107.6 49.2 109.1 48.3
|
149
|
+
L 110.2 ${scaledSize + 49.5} L 159.7 ${scaledSize + 5}
|
150
|
+
L 157.7 ${-scaledSize + 5.2} L 112.4 ${49.5 - scaledSize}
|
151
|
+
C 113.4 43.5 113.9 41.7 113.9 39.8
|
152
|
+
L 113.9 34.8
|
153
|
+
C 113.9 29.3 109.4 24.8 103.9 24.8
|
154
|
+
L 58.9 24.8
|
155
|
+
C 56.5 24.8 54.3 25.7 52.5 27
|
156
|
+
z
|
157
|
+
`,
|
158
|
+
}),
|
159
|
+
(0, createElement_1.createSvgElement)('rect', {
|
160
|
+
stroke: '#cc8077',
|
161
|
+
fill: 'var(--icon-color)',
|
162
|
+
width: 65,
|
163
|
+
height: 75,
|
164
|
+
x: 48.9,
|
165
|
+
y: -38.7,
|
166
|
+
transform: 'rotate(41.35)',
|
167
|
+
}),
|
168
|
+
],
|
169
|
+
});
|
169
170
|
return icon;
|
170
171
|
}
|
171
172
|
makeSelectionIcon() {
|
@@ -173,8 +174,8 @@ class IconProvider {
|
|
173
174
|
// Draw a cursor-like shape
|
174
175
|
icon.innerHTML = `
|
175
176
|
<g>
|
176
|
-
<rect x=10 y=10 width=70 height=70 fill=
|
177
|
-
<rect x=75 y=75 width=10 height=10 fill=
|
177
|
+
<rect x="10" y="10" width="70" height="70" fill="pink" stroke="black"/>
|
178
|
+
<rect x="75" y="75" width="10" height="10" fill="white" stroke="black"/>
|
178
179
|
</g>
|
179
180
|
`;
|
180
181
|
icon.setAttribute('viewBox', '0 0 100 100');
|
@@ -437,8 +438,6 @@ class IconProvider {
|
|
437
438
|
const strokeSize = Math.round(Math.sqrt(penStyle.thickness) * 4);
|
438
439
|
const color = penStyle.color;
|
439
440
|
const rounded = this.isRoundedTipPen(penStyle);
|
440
|
-
const icon = document.createElementNS(svgNamespace, 'svg');
|
441
|
-
icon.setAttribute('viewBox', '0 0 100 100');
|
442
441
|
const tipThickness = strokeSize / 2;
|
443
442
|
const inkTipPath = `
|
444
443
|
M ${15 - tipThickness},${80 - tipThickness}
|
@@ -471,71 +470,35 @@ class IconProvider {
|
|
471
470
|
const pencilTipColor = math_1.Color4.fromHex('#f4d7d7');
|
472
471
|
const tipColor = pencilTipColor.mix(color, tipThickness / 40 - 0.1).toHexString();
|
473
472
|
const checkerboardPattern = makeCheckerboardPattern();
|
474
|
-
const
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
const grip = `
|
504
|
-
<path
|
505
|
-
${iconColorStrokeFill}
|
506
|
-
d="${gripMainPath}"
|
507
|
-
/>
|
508
|
-
|
509
|
-
<!-- shadows -->
|
510
|
-
<path
|
511
|
-
fill="rgba(150, 150, 150, 0.3)"
|
512
|
-
d="${gripShadow1Path}"
|
513
|
-
/>
|
514
|
-
<path
|
515
|
-
fill="rgba(100, 100, 100, 0.2)"
|
516
|
-
d="${gripShadow2Path}"
|
517
|
-
/>
|
518
|
-
|
519
|
-
<!-- color bubble -->
|
520
|
-
<path
|
521
|
-
fill="${checkerboardPattern.patternRef}"
|
522
|
-
d="${colorBubblePath}"
|
523
|
-
/>
|
524
|
-
<path
|
525
|
-
fill="${color}"
|
526
|
-
d="${colorBubblePath}"
|
527
|
-
/>
|
528
|
-
`;
|
529
|
-
icon.innerHTML = `
|
530
|
-
<defs>
|
531
|
-
${checkerboardPattern.patternDef}
|
532
|
-
</defs>
|
533
|
-
<g>
|
534
|
-
${ink}
|
535
|
-
${penTip}
|
536
|
-
${grip}
|
537
|
-
</g>
|
538
|
-
`;
|
473
|
+
const colorString = color.toHexString();
|
474
|
+
const ink = (0, createElement_1.createSvgPaths)({
|
475
|
+
fill: checkerboardPattern.patternRef,
|
476
|
+
d: inkTipPath,
|
477
|
+
}, {
|
478
|
+
fill: checkerboardPattern.patternRef,
|
479
|
+
d: inkTrailPath,
|
480
|
+
}, {
|
481
|
+
fill: colorString,
|
482
|
+
d: inkTipPath,
|
483
|
+
}, {
|
484
|
+
fill: colorString,
|
485
|
+
d: inkTrailPath,
|
486
|
+
});
|
487
|
+
const penTip = (0, createElement_1.createSvgPaths)({ fill: checkerboardPattern.patternRef, d: penTipPath }, { fill: tipColor, stroke: colorString, d: penTipPath });
|
488
|
+
const grip = (0, createElement_1.createSvgPaths)({ fill: 'var(--icon-color)', stroke: 'var(--icon-color)', d: gripMainPath },
|
489
|
+
// Shadows
|
490
|
+
{ fill: 'rgba(150, 150, 150, 0.3)', d: gripShadow1Path }, { fill: 'rgba(100, 100, 100, 0.2)', d: gripShadow2Path },
|
491
|
+
// Color bubble
|
492
|
+
{ fill: checkerboardPattern.patternRef, d: colorBubblePath }, { fill: colorString, d: colorBubblePath });
|
493
|
+
const icon = document.createElementNS(svgNamespace, 'svg');
|
494
|
+
icon.setAttribute('viewBox', '0 0 100 100');
|
495
|
+
const iconMainContent = (0, createElement_1.createSvgElement)('g', {
|
496
|
+
children: [ink, penTip, grip].flat(),
|
497
|
+
});
|
498
|
+
const defs = (0, createElement_1.createSvgElement)('defs', {
|
499
|
+
children: [checkerboardPattern.patternDefElement],
|
500
|
+
});
|
501
|
+
icon.replaceChildren(defs, iconMainContent);
|
539
502
|
return icon;
|
540
503
|
}
|
541
504
|
makeIconFromFactory(penStyle) {
|
@@ -567,11 +530,11 @@ class IconProvider {
|
|
567
530
|
if (includeTransparencyGrid) {
|
568
531
|
const checkerboardPattern = makeCheckerboardPattern();
|
569
532
|
const defs = document.createElementNS(svgNamespace, 'defs');
|
570
|
-
defs.
|
533
|
+
defs.appendChild(checkerboardPattern.patternDefElement);
|
571
534
|
icon.appendChild(defs);
|
572
535
|
const background = document.createElementNS(svgNamespace, 'g');
|
573
536
|
icon.appendChild(background);
|
574
|
-
renderer = new class extends SVGRenderer_1.default {
|
537
|
+
renderer = new (class extends SVGRenderer_1.default {
|
575
538
|
constructor() {
|
576
539
|
super(icon, viewport);
|
577
540
|
}
|
@@ -593,7 +556,7 @@ class IconProvider {
|
|
593
556
|
}
|
594
557
|
return addedPath;
|
595
558
|
}
|
596
|
-
}();
|
559
|
+
})();
|
597
560
|
}
|
598
561
|
else {
|
599
562
|
renderer = new SVGRenderer_1.default(icon, viewport);
|
@@ -641,7 +604,7 @@ class IconProvider {
|
|
641
604
|
if (color) {
|
642
605
|
const checkerboardPattern = makeCheckerboardPattern();
|
643
606
|
const defs = document.createElementNS(svgNamespace, 'defs');
|
644
|
-
defs.
|
607
|
+
defs.appendChild(checkerboardPattern.patternDefElement);
|
645
608
|
icon.appendChild(defs);
|
646
609
|
const fluidBackground = document.createElementNS(svgNamespace, 'path');
|
647
610
|
const fluid = document.createElementNS(svgNamespace, 'path');
|
@@ -846,6 +809,9 @@ class IconProvider {
|
|
846
809
|
* @returns An object with both the definition of a checkerboard pattern and the syntax to
|
847
810
|
* reference that pattern. The defs provided by this function should be wrapped within a
|
848
811
|
* `<defs></defs>` element.
|
812
|
+
*
|
813
|
+
* **Note**: This function's return value includes both `patternDefElement` (which returns
|
814
|
+
* an Element) and a (deprecated) `patternDef` string. Avoid using the `patternDef` result.
|
849
815
|
*/
|
850
816
|
makeCheckerboardPattern() {
|
851
817
|
return makeCheckerboardPattern();
|
@@ -860,7 +826,9 @@ class IconProvider {
|
|
860
826
|
return penStyle.factory === PolylineBuilder_1.makePolylineBuilder;
|
861
827
|
}
|
862
828
|
/** Must be overridden by icon packs that need attribution. */
|
863
|
-
licenseInfo() {
|
829
|
+
licenseInfo() {
|
830
|
+
return null;
|
831
|
+
}
|
864
832
|
}
|
865
833
|
_IconProvider_instances = new WeakSet(), _IconProvider_makeXIcon = function _IconProvider_makeXIcon() {
|
866
834
|
const strokeWidth = '6px';
|
@@ -48,7 +48,7 @@ exports.defaultToolbarLocalization = {
|
|
48
48
|
about: 'About',
|
49
49
|
inputStabilization: 'Stabilization',
|
50
50
|
strokeAutocorrect: 'Autocorrect',
|
51
|
-
touchPanning: '
|
51
|
+
touchPanning: 'Scroll with touch',
|
52
52
|
roundedTipPen: 'Round',
|
53
53
|
roundedTipPen2: 'Polyline',
|
54
54
|
flatTipPen: 'Flat',
|
@@ -65,7 +65,7 @@ exports.defaultToolbarLocalization = {
|
|
65
65
|
fileInput__andNMoreFiles: (n) => `(...${n} more)`,
|
66
66
|
// Help text
|
67
67
|
penDropdown__baseHelpText: 'This tool draws shapes or freehand lines.',
|
68
|
-
penDropdown__colorHelpText:
|
68
|
+
penDropdown__colorHelpText: "Changes the pen's color",
|
69
69
|
penDropdown__thicknessHelpText: 'Changes the thickness of strokes drawn by the pen.',
|
70
70
|
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.',
|
71
71
|
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.',
|
@@ -75,17 +75,17 @@ exports.defaultToolbarLocalization = {
|
|
75
75
|
handDropdown__zoomOutHelpText: 'Zooms out.',
|
76
76
|
handDropdown__resetViewHelpText: 'Resets the zoom level to 100% and resets scroll.',
|
77
77
|
handDropdown__zoomDisplayHelpText: 'Shows the current zoom level. 100% shows the image at its actual size.',
|
78
|
-
handDropdown__touchPanningHelpText: 'When enabled,
|
78
|
+
handDropdown__touchPanningHelpText: 'When enabled, touchscreen gestures move the image rather than select or draw.',
|
79
79
|
handDropdown__lockRotationHelpText: 'When enabled, prevents touch gestures from rotating the screen.',
|
80
80
|
eraserDropdown__baseHelpText: 'This tool removes strokes, images, and text under the cursor.',
|
81
81
|
eraserDropdown__thicknessHelpText: 'Changes the size of the eraser.',
|
82
82
|
eraserDropdown__fullStrokeEraserHelpText: 'When in full-stroke mode, entire shapes are erased.\n\nWhen not in full-stroke mode, shapes can be partially erased.',
|
83
83
|
selectionDropdown__baseHelpText: 'Selects content and manipulates the selection',
|
84
|
-
selectionDropdown__resizeToHelpText:
|
84
|
+
selectionDropdown__resizeToHelpText: "Crops the drawing to the size of what's currently selected.\n\nIf auto-resize is enabled, it will be disabled.",
|
85
85
|
selectionDropdown__deleteHelpText: 'Erases selected items.',
|
86
86
|
selectionDropdown__duplicateHelpText: 'Makes a copy of selected items.',
|
87
87
|
selectionDropdown__changeColorHelpText: 'Changes the color of selected items.',
|
88
|
-
pageDropdown__baseHelpText:
|
88
|
+
pageDropdown__baseHelpText: "Controls the drawing canvas' background color, pattern, and size.",
|
89
89
|
pageDropdown__backgroundColorHelpText: 'Changes the background color of the drawing canvas.',
|
90
90
|
pageDropdown__gridCheckboxHelpText: 'Enables/disables a background grid pattern.',
|
91
91
|
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.',
|
@@ -46,7 +46,7 @@ const createHelpPage = (helpItems, onItemClick, onBackgroundClick, context) => {
|
|
46
46
|
let clonedElementContainers = [];
|
47
47
|
// Clicking on the background of the help area should send an event (e.g. to allow the
|
48
48
|
// help container to be closed).
|
49
|
-
container.addEventListener('click', event => {
|
49
|
+
container.addEventListener('click', (event) => {
|
50
50
|
// If clicking directly on the container (and not on a child)
|
51
51
|
if (event.target === container) {
|
52
52
|
onBackgroundClick();
|
@@ -58,7 +58,7 @@ const createHelpPage = (helpItems, onItemClick, onBackgroundClick, context) => {
|
|
58
58
|
if (!currentItem) {
|
59
59
|
return math_1.Rect2.empty;
|
60
60
|
}
|
61
|
-
const itemBoundingBoxes = currentItem.targetElements.map(element => math_1.Rect2.of(element.getBoundingClientRect()));
|
61
|
+
const itemBoundingBoxes = currentItem.targetElements.map((element) => math_1.Rect2.of(element.getBoundingClientRect()));
|
62
62
|
return math_1.Rect2.union(...itemBoundingBoxes);
|
63
63
|
};
|
64
64
|
// Updates each cloned element's click listener and CSS classes based on whether
|
@@ -223,7 +223,9 @@ class HelpDisplay {
|
|
223
223
|
const label = this.context.localization.close;
|
224
224
|
closeButton.setAttribute('aria-label', label);
|
225
225
|
closeButton.setAttribute('title', label);
|
226
|
-
closeButton.onclick = () => {
|
226
|
+
closeButton.onclick = () => {
|
227
|
+
closeOverlay();
|
228
|
+
};
|
227
229
|
return closeButton;
|
228
230
|
};
|
229
231
|
// Wraps the label and clickable help elements
|
@@ -231,7 +233,7 @@ class HelpDisplay {
|
|
231
233
|
const currentPage = ReactiveValue_1.MutableReactiveValue.fromInitialValue(0);
|
232
234
|
const content = document.createElement('div');
|
233
235
|
content.classList.add('navigation-content');
|
234
|
-
const helpPage = createHelpPage(__classPrivateFieldGet(this, _HelpDisplay_helpData, "f"), newPageIndex => currentPage.set(newPageIndex), onBackgroundClick, this.context);
|
236
|
+
const helpPage = createHelpPage(__classPrivateFieldGet(this, _HelpDisplay_helpData, "f"), (newPageIndex) => currentPage.set(newPageIndex), onBackgroundClick, this.context);
|
235
237
|
helpPage.addToParent(content);
|
236
238
|
const showPage = (pageIndex) => {
|
237
239
|
if (pageIndex >= __classPrivateFieldGet(this, _HelpDisplay_helpData, "f").length || pageIndex < 0) {
|
@@ -380,12 +382,12 @@ class HelpDisplay {
|
|
380
382
|
// Close the overlay when clicking on the background (*directly* on any of the
|
381
383
|
// elements in closeOverlayTriggers).
|
382
384
|
const closeOverlayTriggers = [navigation.content, navigationButtons, overlay];
|
383
|
-
overlay.onclick = event => {
|
385
|
+
overlay.onclick = (event) => {
|
384
386
|
if (closeOverlayTriggers.includes(event.target)) {
|
385
387
|
onBackgroundClick();
|
386
388
|
}
|
387
389
|
};
|
388
|
-
overlay.onkeyup = event => {
|
390
|
+
overlay.onkeyup = (event) => {
|
389
391
|
if (event.code === 'Escape') {
|
390
392
|
closeOverlay();
|
391
393
|
event.preventDefault();
|
@@ -2,10 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const math_1 = require("@js-draw/math");
|
4
4
|
const makeDraggable = (dragElement, options) => {
|
5
|
-
const dragElements = [
|
6
|
-
...options.draggableChildElements,
|
7
|
-
dragElement,
|
8
|
-
];
|
5
|
+
const dragElements = [...options.draggableChildElements, dragElement];
|
9
6
|
let lastX = 0;
|
10
7
|
let lastY = 0;
|
11
8
|
let startX = 0;
|
@@ -51,7 +48,7 @@ const makeDraggable = (dragElement, options) => {
|
|
51
48
|
return Math.hypot(lastX - startX, lastY - startY) < clickThreshold;
|
52
49
|
};
|
53
50
|
let startedDragging = false;
|
54
|
-
addEventListener('pointerdown', event => {
|
51
|
+
addEventListener('pointerdown', (event) => {
|
55
52
|
if (event.defaultPrevented || !isDraggableElement(event.target)) {
|
56
53
|
return;
|
57
54
|
}
|
@@ -82,7 +79,7 @@ const makeDraggable = (dragElement, options) => {
|
|
82
79
|
pointerDown = false;
|
83
80
|
startedDragging = false;
|
84
81
|
};
|
85
|
-
addEventListener('pointermove', event => {
|
82
|
+
addEventListener('pointermove', (event) => {
|
86
83
|
if (!event.isPrimary || !pointerDown) {
|
87
84
|
return undefined;
|
88
85
|
}
|
@@ -110,7 +107,7 @@ const makeDraggable = (dragElement, options) => {
|
|
110
107
|
startedDragging = true;
|
111
108
|
}
|
112
109
|
});
|
113
|
-
addEventListener('pointerleave', event => {
|
110
|
+
addEventListener('pointerleave', (event) => {
|
114
111
|
// Capture the pointer if it exits the container while dragging.
|
115
112
|
if (capturedPointerId === null && pointerDown && event.isPrimary) {
|
116
113
|
dragElement.setPointerCapture(event.pointerId);
|
@@ -7,13 +7,14 @@ const BaseWidget_1 = __importDefault(require("./BaseWidget"));
|
|
7
7
|
const constants_1 = require("../constants");
|
8
8
|
const isToolWidgetFocused = () => {
|
9
9
|
const currentFocus = [...document.querySelectorAll('*:focus')];
|
10
|
-
return currentFocus.length &&
|
10
|
+
return (currentFocus.length &&
|
11
|
+
currentFocus.some((elem) => elem.classList.contains(`${constants_1.toolbarCSSPrefix}button`)));
|
11
12
|
};
|
12
13
|
class BaseToolWidget extends BaseWidget_1.default {
|
13
14
|
constructor(editor, targetTool, id, localizationTable) {
|
14
15
|
super(editor, id, localizationTable);
|
15
16
|
this.targetTool = targetTool;
|
16
|
-
this.targetTool.enabledValue().onUpdateAndNow(enabled => {
|
17
|
+
this.targetTool.enabledValue().onUpdateAndNow((enabled) => {
|
17
18
|
if (enabled) {
|
18
19
|
this.setSelected(true);
|
19
20
|
// 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;
|
@@ -73,7 +73,7 @@ class BaseWidget {
|
|
73
73
|
this.button.tabIndex = 0;
|
74
74
|
// Disable the context menu. This allows long-press gestures to trigger the button's
|
75
75
|
// tooltip instead.
|
76
|
-
this.button.oncontextmenu = event => {
|
76
|
+
this.button.oncontextmenu = (event) => {
|
77
77
|
event.preventDefault();
|
78
78
|
};
|
79
79
|
(0, addLongPressOrHoverCssClasses_1.default)(this.button);
|
@@ -171,7 +171,7 @@ class BaseWidget {
|
|
171
171
|
return this.setUpButtonEventListeners(button);
|
172
172
|
}
|
173
173
|
setUpButtonEventListeners(button) {
|
174
|
-
const clickTriggers = { Enter: true, ' ': true
|
174
|
+
const clickTriggers = { Enter: true, ' ': true };
|
175
175
|
button.onkeydown = (evt) => {
|
176
176
|
let handled = false;
|
177
177
|
if (evt.key in clickTriggers) {
|
@@ -189,7 +189,7 @@ class BaseWidget {
|
|
189
189
|
evt.preventDefault();
|
190
190
|
}
|
191
191
|
};
|
192
|
-
button.onkeyup = htmlEvent => {
|
192
|
+
button.onkeyup = (htmlEvent) => {
|
193
193
|
if (htmlEvent.key in clickTriggers) {
|
194
194
|
return;
|
195
195
|
}
|
@@ -205,7 +205,7 @@ class BaseWidget {
|
|
205
205
|
}
|
206
206
|
};
|
207
207
|
// Prevent double-click zoom on some devices.
|
208
|
-
button.ondblclick = event => {
|
208
|
+
button.ondblclick = (event) => {
|
209
209
|
event.preventDefault();
|
210
210
|
};
|
211
211
|
}
|
@@ -257,7 +257,7 @@ class BaseWidget {
|
|
257
257
|
this.container.replaceChildren();
|
258
258
|
this.button.replaceChildren(this.icon, this.label);
|
259
259
|
this.container.appendChild(this.button);
|
260
|
-
const helpDisplay = new HelpDisplay_1.default(content => this.editor.createHTMLOverlay(content), this.editor);
|
260
|
+
const helpDisplay = new HelpDisplay_1.default((content) => this.editor.createHTMLOverlay(content), this.editor);
|
261
261
|
const helpText = this.getHelpText();
|
262
262
|
if (helpText) {
|
263
263
|
helpDisplay.registerTextHelpForElement(this.dropdownContent, [this.getTitle(), helpText].join('\n\n'));
|
@@ -277,7 +277,7 @@ class BaseWidget {
|
|
277
277
|
getTitle: () => this.getTitle(),
|
278
278
|
isToplevel: () => this.toplevel,
|
279
279
|
});
|
280
|
-
this.dropdown.visible.onUpdate(visible => {
|
280
|
+
this.dropdown.visible.onUpdate((visible) => {
|
281
281
|
if (visible) {
|
282
282
|
this.container.classList.add('dropdownVisible');
|
283
283
|
}
|
@@ -306,7 +306,7 @@ class BaseWidget {
|
|
306
306
|
}
|
307
307
|
/**
|
308
308
|
* Remove this. This allows the widget to be added to a toolbar again
|
309
|
-
* in the future using
|
309
|
+
* in the future using `addTo`.
|
310
310
|
*/
|
311
311
|
remove() {
|
312
312
|
this.container.remove();
|
@@ -475,7 +475,7 @@ _a = BaseWidget, _BaseWidget_hasDropdown = new WeakMap(), _BaseWidget_disabledDu
|
|
475
475
|
handler.removeListener(keyPressListener);
|
476
476
|
};
|
477
477
|
}
|
478
|
-
const readOnlyListener = this.editor.isReadOnlyReactiveValue().onUpdateAndNow(readOnly => {
|
478
|
+
const readOnlyListener = this.editor.isReadOnlyReactiveValue().onUpdateAndNow((readOnly) => {
|
479
479
|
if (readOnly && this.shouldAutoDisableInReadOnlyEditor() && !this.disabled) {
|
480
480
|
this.setDisabled(true);
|
481
481
|
__classPrivateFieldSet(this, _BaseWidget_disabledDueToReadOnlyEditor, true, "f");
|
@@ -129,7 +129,7 @@ class DocumentPropertiesWidget extends BaseWidget_1.default {
|
|
129
129
|
const backgroundColorRow = document.createElement('div');
|
130
130
|
const backgroundColorLabel = document.createElement('label');
|
131
131
|
backgroundColorLabel.innerText = this.localizationTable.backgroundColor;
|
132
|
-
const { input: colorInput, container: backgroundColorInputContainer, setValue: setBgColorInputValue, registerWithHelpTextDisplay: registerHelpForInputs, } = (0, makeColorInput_1.default)(this.editor, color => {
|
132
|
+
const { input: colorInput, container: backgroundColorInputContainer, setValue: setBgColorInputValue, registerWithHelpTextDisplay: registerHelpForInputs, } = (0, makeColorInput_1.default)(this.editor, (color) => {
|
133
133
|
if (!color.eq(this.getBackgroundColor())) {
|
134
134
|
this.setBackgroundColor(color);
|
135
135
|
}
|
@@ -144,7 +144,7 @@ class DocumentPropertiesWidget extends BaseWidget_1.default {
|
|
144
144
|
helpDisplay?.registerTextHelpForElement(backgroundColorRow, this.localizationTable.pageDropdown__backgroundColorHelpText);
|
145
145
|
registerHelpForInputs(helpDisplay);
|
146
146
|
};
|
147
|
-
return { setBgColorInputValue, backgroundColorRow, registerWithHelp
|
147
|
+
return { setBgColorInputValue, backgroundColorRow, registerWithHelp };
|
148
148
|
};
|
149
149
|
const { backgroundColorRow, setBgColorInputValue, registerWithHelp: registerBackgroundRowWithHelp, } = makeBackgroundColorInput();
|
150
150
|
const makeCheckboxRow = (labelText, onChange) => {
|
@@ -13,7 +13,7 @@ class EraserToolWidget extends BaseToolWidget_1.default {
|
|
13
13
|
super(editor, tool, 'eraser-tool-widget', localizationTable);
|
14
14
|
this.tool = tool;
|
15
15
|
this.updateInputs = () => { };
|
16
|
-
this.editor.notifier.on(types_1.EditorEventType.ToolUpdated, toolEvt => {
|
16
|
+
this.editor.notifier.on(types_1.EditorEventType.ToolUpdated, (toolEvt) => {
|
17
17
|
if (toolEvt.kind === types_1.EditorEventType.ToolUpdated && toolEvt.tool === this.tool) {
|
18
18
|
this.updateInputs();
|
19
19
|
this.updateIcon();
|
@@ -41,7 +41,9 @@ class EraserToolWidget extends BaseToolWidget_1.default {
|
|
41
41
|
labelElement.innerText = this.localizationTable.fullStrokeEraser;
|
42
42
|
checkboxElement.type = 'checkbox';
|
43
43
|
checkboxElement.oninput = () => {
|
44
|
-
this.tool
|
44
|
+
this.tool
|
45
|
+
.getModeValue()
|
46
|
+
.set(checkboxElement.checked ? Eraser_1.EraserMode.FullStroke : Eraser_1.EraserMode.PartialStroke);
|
45
47
|
};
|
46
48
|
const updateValue = () => {
|
47
49
|
checkboxElement.checked = this.tool.getModeValue().get() === Eraser_1.EraserMode.FullStroke;
|
@@ -58,7 +60,7 @@ class EraserToolWidget extends BaseToolWidget_1.default {
|
|
58
60
|
fillDropdown(dropdown, helpDisplay) {
|
59
61
|
const container = document.createElement('div');
|
60
62
|
container.classList.add(`${constants_1.toolbarCSSPrefix}spacedList`, `${constants_1.toolbarCSSPrefix}nonbutton-controls-main-list`);
|
61
|
-
const thicknessSlider = (0, makeThicknessSlider_1.default)(this.editor, thickness => {
|
63
|
+
const thicknessSlider = (0, makeThicknessSlider_1.default)(this.editor, (thickness) => {
|
62
64
|
this.tool.setThickness(thickness);
|
63
65
|
});
|
64
66
|
thicknessSlider.setBounds(10, 55);
|