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
@@ -9,7 +9,7 @@ const makeClipboardErrorHandlers = (editor) => {
|
|
9
9
|
const makeErrorDialog = (error) => {
|
10
10
|
const dialog = (0, makeMessageDialog_1.default)(editor, {
|
11
11
|
title: editor.localization.copyPasteError__heading,
|
12
|
-
classNames: ['clipboard-error-dialog']
|
12
|
+
classNames: ['clipboard-error-dialog'],
|
13
13
|
});
|
14
14
|
dialog.appendChild(document.createTextNode(editor.localization.copyPasteError__description));
|
15
15
|
const errorDetailsElement = document.createElement('details');
|
@@ -22,7 +22,26 @@ const makeClipboardErrorHandlers = (editor) => {
|
|
22
22
|
};
|
23
23
|
return {
|
24
24
|
async onCopyError(error) {
|
25
|
-
makeErrorDialog(error);
|
25
|
+
const dialog = makeErrorDialog(error);
|
26
|
+
const textboxLabel = document.createElement('label');
|
27
|
+
textboxLabel.textContent = editor.localization.copyPasteError__copyRetry;
|
28
|
+
const copyTextbox = document.createElement('textarea');
|
29
|
+
textboxLabel.appendChild(copyTextbox);
|
30
|
+
const retryHandler = new ClipboardHandler_1.default(editor);
|
31
|
+
const handleCopy = (event) => {
|
32
|
+
event.preventDefault();
|
33
|
+
// Use .then to ensure that .copy runs within the event handler.
|
34
|
+
// Copy can fail if certain logic is run async.
|
35
|
+
return retryHandler.copy(event).then(() => {
|
36
|
+
dialog.close();
|
37
|
+
});
|
38
|
+
};
|
39
|
+
copyTextbox.oncopy = handleCopy;
|
40
|
+
copyTextbox.ondragstart = handleCopy;
|
41
|
+
copyTextbox.value = editor.localization.copyPasteError__copyMe;
|
42
|
+
dialog.appendChild(textboxLabel);
|
43
|
+
copyTextbox.select();
|
44
|
+
document.execCommand('copy');
|
26
45
|
},
|
27
46
|
onPasteError(error) {
|
28
47
|
const dialog = makeErrorDialog(error);
|
@@ -44,6 +63,8 @@ const makeClipboardErrorHandlers = (editor) => {
|
|
44
63
|
pasteTextbox.onpaste = handlePaste;
|
45
64
|
pasteTextbox.ondrop = handlePaste;
|
46
65
|
dialog.appendChild(textboxLabel);
|
66
|
+
pasteTextbox.focus();
|
67
|
+
document.execCommand('paste');
|
47
68
|
},
|
48
69
|
};
|
49
70
|
};
|
@@ -9,35 +9,44 @@ const makeClipboardErrorHandlers_1 = __importDefault(require("./makeClipboardErr
|
|
9
9
|
const showSelectionContextMenu = async (selectionBox, editor, canvasAnchor, preferSelectionMenu, clearSelection) => {
|
10
10
|
const localization = editor.localization;
|
11
11
|
const showSelectionMenu = selectionBox?.getSelectedItemCount() && preferSelectionMenu;
|
12
|
-
const noSelectionMenu = [
|
12
|
+
const noSelectionMenu = [
|
13
|
+
{
|
13
14
|
text: localization.selectionMenu__paste,
|
14
15
|
icon: () => editor.icons.makePasteIcon(),
|
15
16
|
key: () => {
|
16
17
|
const clipboardHandler = new ClipboardHandler_1.default(editor, (0, makeClipboardErrorHandlers_1.default)(editor));
|
17
18
|
void clipboardHandler.paste();
|
18
19
|
},
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
},
|
21
|
+
];
|
22
|
+
const onActivated = await (0, createMenuOverlay_1.default)(editor, canvasAnchor, showSelectionMenu
|
23
|
+
? [
|
24
|
+
{
|
25
|
+
text: localization.selectionMenu__duplicate,
|
26
|
+
icon: () => editor.icons.makeDuplicateSelectionIcon(),
|
27
|
+
key: async () => {
|
28
|
+
await editor.dispatch(await selectionBox.duplicateSelectedObjects());
|
29
|
+
},
|
25
30
|
},
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
{
|
32
|
+
text: localization.selectionMenu__delete,
|
33
|
+
icon: () => editor.icons.makeDeleteSelectionIcon(),
|
34
|
+
key: async () => {
|
35
|
+
await editor.dispatch(selectionBox.deleteSelectedObjects());
|
36
|
+
clearSelection();
|
37
|
+
},
|
32
38
|
},
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
{
|
40
|
+
text: localization.selectionMenu__copyToClipboard,
|
41
|
+
icon: () => editor.icons.makeCopyIcon(),
|
42
|
+
key: () => {
|
43
|
+
const clipboardHandler = new ClipboardHandler_1.default(editor, (0, makeClipboardErrorHandlers_1.default)(editor));
|
44
|
+
void clipboardHandler.copy();
|
45
|
+
},
|
39
46
|
},
|
40
|
-
|
47
|
+
...noSelectionMenu,
|
48
|
+
]
|
49
|
+
: noSelectionMenu);
|
41
50
|
onActivated?.();
|
42
51
|
};
|
43
52
|
exports.default = showSelectionContextMenu;
|
@@ -58,12 +58,12 @@ class SoundFeedback {
|
|
58
58
|
setColor(color) {
|
59
59
|
const hsv = color.asHSV();
|
60
60
|
// Choose frequencies that roughly correspond to hue, saturation, and value.
|
61
|
-
const hueFrequency =
|
61
|
+
const hueFrequency = -Math.cos(hsv.x / 2) * 220 + 440;
|
62
62
|
const saturationFrequency = hsv.y * 440 + 220;
|
63
63
|
const valueFrequency = (hsv.z + 0.1) * 440;
|
64
64
|
// Sigmoid with maximum 0.25 * alpha.
|
65
65
|
// Louder for greater value.
|
66
|
-
const gain = 0.25 * Math.min(1, color.a) / (1 + Math.exp(-(hsv.z - 0.5) * 3));
|
66
|
+
const gain = (0.25 * Math.min(1, color.a)) / (1 + Math.exp(-(hsv.z - 0.5) * 3));
|
67
67
|
this.colorOscHue.frequency.setValueAtTime(hueFrequency, this.ctx.currentTime);
|
68
68
|
this.colorOscSaturation.frequency.setValueAtTime(saturationFrequency, this.ctx.currentTime);
|
69
69
|
this.colorOscValue.frequency.setValueAtTime(valueFrequency, this.ctx.currentTime);
|
@@ -155,7 +155,9 @@ class SoundUITool extends BaseTool_1.default {
|
|
155
155
|
onPointerMove({ current }) {
|
156
156
|
this.soundFeedback?.setColor(this.editor.display.getColorAt(current.screenPos) ?? math_1.Color4.black);
|
157
157
|
const pointerMotionLine = new math_1.LineSegment2(this.lastPointerPos, current.canvasPos);
|
158
|
-
const collisions = this.editor.image
|
158
|
+
const collisions = this.editor.image
|
159
|
+
.getElementsIntersectingRegion(pointerMotionLine.bbox)
|
160
|
+
.filter((component) => component.intersects(pointerMotionLine));
|
159
161
|
this.lastPointerPos = current.canvasPos;
|
160
162
|
if (collisions.length > 0) {
|
161
163
|
this.soundFeedback?.announceBoundaryCross(collisions.length);
|
@@ -81,7 +81,7 @@ class TextTool extends BaseTool_1.default {
|
|
81
81
|
return measurement.fontBoundingBoxAscent ?? measurement.actualBoundingBoxAscent;
|
82
82
|
}
|
83
83
|
// Estimate
|
84
|
-
return style.size * 2 / 3;
|
84
|
+
return (style.size * 2) / 3;
|
85
85
|
}
|
86
86
|
// Take input from this' textInputElem and add it to the EditorImage.
|
87
87
|
// If [removeInput], the HTML input element is removed. Otherwise, its value
|
@@ -100,7 +100,10 @@ class TextTool extends BaseTool_1.default {
|
|
100
100
|
if (content === '') {
|
101
101
|
return;
|
102
102
|
}
|
103
|
-
const textTransform = math_1.Mat33.translation(this.textTargetPosition)
|
103
|
+
const textTransform = math_1.Mat33.translation(this.textTargetPosition)
|
104
|
+
.rightMul(this.getTextScaleMatrix())
|
105
|
+
.rightMul(math_1.Mat33.scaling2D(this.editor.viewport.getSizeOfPixelOnCanvas()))
|
106
|
+
.rightMul(math_1.Mat33.zRotation(this.textRotation));
|
104
107
|
const textComponent = TextComponent_1.default.fromLines(content.split('\n'), textTransform, this.textStyle);
|
105
108
|
const action = EditorImage_1.default.addElement(textComponent);
|
106
109
|
if (this.removeExistingCommand) {
|
@@ -144,8 +147,7 @@ class TextTool extends BaseTool_1.default {
|
|
144
147
|
const vertAdjust = ascent;
|
145
148
|
const rotation = this.textRotation + viewport.getRotationAngle();
|
146
149
|
const scale = this.getTextScaleMatrix();
|
147
|
-
this.textInputElem.style.transform =
|
148
|
-
`${scale.toCSSMatrix()} rotate(${rotation * 180 / Math.PI}deg) translate(0, ${-vertAdjust}px)`;
|
150
|
+
this.textInputElem.style.transform = `${scale.toCSSMatrix()} rotate(${(rotation * 180) / Math.PI}deg) translate(0, ${-vertAdjust}px)`;
|
149
151
|
this.textInputElem.style.transformOrigin = 'top left';
|
150
152
|
// Match the line height of default rendered text.
|
151
153
|
const lineHeight = Math.floor(this.textStyle.size);
|
@@ -213,11 +215,11 @@ class TextTool extends BaseTool_1.default {
|
|
213
215
|
const halfTestRegionSize = math_1.Vec2.of(2.5, 2.5).times(this.editor.viewport.getSizeOfPixelOnCanvas());
|
214
216
|
const testRegion = math_1.Rect2.fromCorners(canvasPos.minus(halfTestRegionSize), canvasPos.plus(halfTestRegionSize));
|
215
217
|
const targetNodes = this.editor.image.getElementsIntersectingRegion(testRegion);
|
216
|
-
let targetTextNodes = targetNodes.filter(node => node instanceof TextComponent_1.default);
|
218
|
+
let targetTextNodes = targetNodes.filter((node) => node instanceof TextComponent_1.default);
|
217
219
|
// Don't try to edit text nodes that contain the viewport (this allows us
|
218
220
|
// to zoom in on text nodes and add text on top of them.)
|
219
221
|
const visibleRect = this.editor.viewport.visibleRect;
|
220
|
-
targetTextNodes = targetTextNodes.filter(node => !node.getBBox().containsRect(visibleRect));
|
222
|
+
targetTextNodes = targetTextNodes.filter((node) => !node.getBBox().containsRect(visibleRect));
|
221
223
|
// End any TextNodes we're currently editing.
|
222
224
|
this.flushInput();
|
223
225
|
if (targetTextNodes.length > 0) {
|
@@ -53,13 +53,19 @@ class ToolController {
|
|
53
53
|
this.activeTool = null;
|
54
54
|
this.isEditorReadOnly = editor.isReadOnlyReactiveValue();
|
55
55
|
this.inputPipeline = new InputPipeline_1.default();
|
56
|
-
this.inputPipeline.setEmitListener(event => this.onEventInternal(event));
|
56
|
+
this.inputPipeline.setEmitListener((event) => this.onEventInternal(event));
|
57
57
|
const primaryToolGroup = new ToolEnabledGroup_1.default();
|
58
58
|
this.primaryToolGroup = primaryToolGroup;
|
59
59
|
const panZoomTool = new PanZoom_1.default(editor, PanZoom_1.PanZoomMode.TwoFingerTouchGestures | PanZoom_1.PanZoomMode.RightClickDrags, localization.touchPanTool);
|
60
60
|
const keyboardPanZoomTool = new PanZoom_1.default(editor, PanZoom_1.PanZoomMode.Keyboard, localization.keyboardPanZoom);
|
61
|
-
const primaryPenTool = new Pen_1.default(editor, localization.penTool(1), {
|
62
|
-
|
61
|
+
const primaryPenTool = new Pen_1.default(editor, localization.penTool(1), {
|
62
|
+
color: math_1.Color4.purple,
|
63
|
+
thickness: 8,
|
64
|
+
});
|
65
|
+
const secondaryPenTool = new Pen_1.default(editor, localization.penTool(2), {
|
66
|
+
color: math_1.Color4.clay,
|
67
|
+
thickness: 4,
|
68
|
+
});
|
63
69
|
// Stabilize the secondary pen tool.
|
64
70
|
secondaryPenTool.setInputMapper(new InputStabilizer_1.default(editor.viewport));
|
65
71
|
const eraser = new Eraser_1.default(editor, localization.eraserTool);
|
@@ -71,7 +77,7 @@ class ToolController {
|
|
71
77
|
new Pen_1.default(editor, localization.penTool(3), {
|
72
78
|
color: math_1.Color4.ofRGBA(1, 1, 0, 0.5),
|
73
79
|
thickness: 40,
|
74
|
-
factory: PressureSensitiveFreehandLineBuilder_1.makePressureSensitiveFreehandLineBuilder
|
80
|
+
factory: PressureSensitiveFreehandLineBuilder_1.makePressureSensitiveFreehandLineBuilder,
|
75
81
|
}),
|
76
82
|
eraser,
|
77
83
|
new SelectionTool_1.default(editor, localization.selectionTool),
|
@@ -96,15 +102,15 @@ class ToolController {
|
|
96
102
|
new PasteHandler_1.default(editor),
|
97
103
|
new SelectAllShortcutHandler_1.default(editor),
|
98
104
|
];
|
99
|
-
primaryTools.forEach(tool => tool.setToolGroup(primaryToolGroup));
|
105
|
+
primaryTools.forEach((tool) => tool.setToolGroup(primaryToolGroup));
|
100
106
|
panZoomTool.setEnabled(true);
|
101
107
|
primaryPenTool.setEnabled(true);
|
102
|
-
editor.notifier.on(types_1.EditorEventType.ToolEnabled, event => {
|
108
|
+
editor.notifier.on(types_1.EditorEventType.ToolEnabled, (event) => {
|
103
109
|
if (event.kind === types_1.EditorEventType.ToolEnabled) {
|
104
110
|
editor.announceForAccessibility(localization.toolEnabledAnnouncement(event.tool.description));
|
105
111
|
}
|
106
112
|
});
|
107
|
-
editor.notifier.on(types_1.EditorEventType.ToolDisabled, event => {
|
113
|
+
editor.notifier.on(types_1.EditorEventType.ToolDisabled, (event) => {
|
108
114
|
if (event.kind === types_1.EditorEventType.ToolDisabled) {
|
109
115
|
editor.announceForAccessibility(localization.toolDisabledAnnouncement(event.tool.description));
|
110
116
|
}
|
@@ -138,7 +144,7 @@ class ToolController {
|
|
138
144
|
}
|
139
145
|
}
|
140
146
|
getPrimaryTools() {
|
141
|
-
return this.tools.filter(tool => {
|
147
|
+
return this.tools.filter((tool) => {
|
142
148
|
return tool.getToolGroup() === this.primaryToolGroup;
|
143
149
|
});
|
144
150
|
}
|
@@ -180,7 +186,7 @@ class ToolController {
|
|
180
186
|
this.tools = newTools;
|
181
187
|
}
|
182
188
|
insertTools(insertNear, toolsToInsert, mode) {
|
183
|
-
this.tools = this.tools.filter(tool => !toolsToInsert.includes(tool));
|
189
|
+
this.tools = this.tools.filter((tool) => !toolsToInsert.includes(tool));
|
184
190
|
const newTools = [];
|
185
191
|
for (const tool of this.tools) {
|
186
192
|
if (mode === 'after') {
|
@@ -292,7 +298,7 @@ class ToolController {
|
|
292
298
|
this.inputPipeline.addToTail(mapper);
|
293
299
|
}
|
294
300
|
getMatchingTools(type) {
|
295
|
-
return this.tools.filter(tool => tool instanceof type);
|
301
|
+
return this.tools.filter((tool) => tool instanceof type);
|
296
302
|
}
|
297
303
|
// @internal
|
298
304
|
onEditorDestroyed() {
|
package/dist/cjs/tools/lib.d.ts
CHANGED
package/dist/cjs/tools/lib.js
CHANGED
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.ToolbarShortcutHandler = exports.SoundUITool = exports.PasteHandler = exports.EraserMode = exports.EraserTool = exports.SelectAllShortcutHandler = exports.SelectionTool = exports.TextTool = exports.PenTool = exports.PanZoomMode = exports.PanZoomTool = exports.ToolSwitcherShortcut = exports.UndoRedoShortcut = exports.ToolEnabledGroup = exports.ToolController = exports.BaseTool = void 0;
|
6
|
+
exports.ToolbarShortcutHandler = exports.SoundUITool = exports.PasteHandler = exports.EraserMode = exports.EraserTool = exports.SelectAllShortcutHandler = exports.SelectionTool = exports.TextTool = exports.PenTool = exports.PanZoomMode = exports.PanZoomTool = exports.ToolSwitcherShortcut = exports.UndoRedoShortcut = exports.ToolEnabledGroup = exports.ToolController = exports.BaseTool = exports.InputMapper = void 0;
|
7
|
+
var InputMapper_1 = require("./InputFilter/InputMapper");
|
8
|
+
Object.defineProperty(exports, "InputMapper", { enumerable: true, get: function () { return __importDefault(InputMapper_1).default; } });
|
7
9
|
var BaseTool_1 = require("./BaseTool");
|
8
10
|
Object.defineProperty(exports, "BaseTool", { enumerable: true, get: function () { return __importDefault(BaseTool_1).default; } });
|
9
11
|
var ToolController_1 = require("./ToolController");
|
@@ -36,6 +36,8 @@ export interface ToolLocalization {
|
|
36
36
|
copyPasteError__heading: string;
|
37
37
|
copyPasteError__description: string;
|
38
38
|
copyPasteError__pasteRetry: string;
|
39
|
+
copyPasteError__copyRetry: string;
|
40
|
+
copyPasteError__copyMe: string;
|
39
41
|
copyPasteError__errorDetails: string;
|
40
42
|
toolEnabledAnnouncement: (toolName: string) => string;
|
41
43
|
toolDisabledAnnouncement: (toolName: string) => string;
|
@@ -17,10 +17,12 @@ exports.defaultToolLocalization = {
|
|
17
17
|
selectionMenu__duplicate: 'Duplicate',
|
18
18
|
selectionMenu__delete: 'Delete',
|
19
19
|
selectionMenu__paste: 'Paste',
|
20
|
-
copyPasteError__heading: '
|
20
|
+
copyPasteError__heading: 'Copy/paste',
|
21
21
|
copyPasteError__description: 'Something went wrong — this tool may not have clipboard access.',
|
22
22
|
copyPasteError__errorDetails: 'Show error',
|
23
23
|
copyPasteError__pasteRetry: 'To retry, please paste into the input box below:',
|
24
|
+
copyPasteError__copyRetry: 'To retry, please copy the text in the input box below:',
|
25
|
+
copyPasteError__copyMe: 'Copy me!',
|
24
26
|
autocorrectedTo: (strokeDescription) => `Autocorrected to ${strokeDescription}`,
|
25
27
|
autocorrectionCanceled: 'Autocorrect cancelled',
|
26
28
|
textTool: 'Text',
|
@@ -48,9 +48,9 @@ class StationaryPenDetector {
|
|
48
48
|
const movedOutOfRadius = dxFromStationaryStart.length() > this.config.maxRadius;
|
49
49
|
this.hasMovedOutOfRadius ||= movedOutOfRadius;
|
50
50
|
// If not stationary
|
51
|
-
if (movedOutOfRadius
|
52
|
-
|
53
|
-
|
51
|
+
if (movedOutOfRadius ||
|
52
|
+
this.averageVelocity.length() > this.config.maxSpeed ||
|
53
|
+
dtFromStart < this.config.minTimeSeconds) {
|
54
54
|
this.stationaryStartPointer = currentPointer;
|
55
55
|
this.lastPointer = currentPointer;
|
56
56
|
this.setStationaryTimeout(this.config.minTimeSeconds * 1000);
|
@@ -32,7 +32,7 @@ const createMenuOverlay = async (editor, canvasAnchor, options) => {
|
|
32
32
|
await (0, waitForTimeout_1.default)(hideMenuTimeout);
|
33
33
|
menuModal.close();
|
34
34
|
};
|
35
|
-
return new Promise(resolve => {
|
35
|
+
return new Promise((resolve) => {
|
36
36
|
let resolved = false;
|
37
37
|
let result = null;
|
38
38
|
const resolveWithSelectedResult = () => {
|
@@ -75,7 +75,7 @@ const createMenuOverlay = async (editor, canvasAnchor, options) => {
|
|
75
75
|
// - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menu_role and
|
76
76
|
// - https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/
|
77
77
|
contentElement.addEventListener('keydown', (event) => {
|
78
|
-
const focusedIndex = optionElements.findIndex(item => item === document.activeElement);
|
78
|
+
const focusedIndex = optionElements.findIndex((item) => item === document.activeElement);
|
79
79
|
if (focusedIndex === -1)
|
80
80
|
return;
|
81
81
|
let newFocusedIndex = focusedIndex;
|
@@ -29,7 +29,7 @@ export default class ClipboardHandler {
|
|
29
29
|
* is to be copied. This is done because `ClipboardEvent`s seem to not support attaching
|
30
30
|
* images.
|
31
31
|
*/
|
32
|
-
copy(event?: ClipboardEvent): Promise<void>;
|
32
|
+
copy(event?: ClipboardEvent | DragEvent): Promise<void>;
|
33
33
|
private copyInternal;
|
34
34
|
}
|
35
35
|
export {};
|
@@ -63,20 +63,15 @@ class ClipboardHandler {
|
|
63
63
|
const clipboardData = event?.dataTransfer ?? event?.clipboardData ?? null;
|
64
64
|
const hasEvent = !!clipboardData;
|
65
65
|
const sendPasteEvent = (mime, data) => {
|
66
|
-
return data &&
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
return (data &&
|
67
|
+
editor.toolController.dispatchInputEvent({
|
68
|
+
kind: inputEvents_1.InputEvtType.PasteEvent,
|
69
|
+
mime,
|
70
|
+
data,
|
71
|
+
}));
|
71
72
|
};
|
72
73
|
// Listed in order of precedence
|
73
|
-
const supportedMIMEs = [
|
74
|
-
'image/svg+xml',
|
75
|
-
'text/html',
|
76
|
-
'image/png',
|
77
|
-
'image/jpeg',
|
78
|
-
'text/plain',
|
79
|
-
];
|
74
|
+
const supportedMIMEs = ['image/svg+xml', 'text/html', 'image/png', 'image/jpeg', 'text/plain'];
|
80
75
|
let files = [];
|
81
76
|
const textData = new Map();
|
82
77
|
if (hasEvent) {
|
@@ -110,7 +105,7 @@ class ClipboardHandler {
|
|
110
105
|
}
|
111
106
|
}
|
112
107
|
for (const file of files) {
|
113
|
-
const fileType = file
|
108
|
+
const fileType = file?.type?.toLowerCase();
|
114
109
|
if (fileType !== mime) {
|
115
110
|
continue;
|
116
111
|
}
|
@@ -186,14 +181,19 @@ class ClipboardHandler {
|
|
186
181
|
event?.preventDefault();
|
187
182
|
}
|
188
183
|
const mimeTypes = [...mimeToData.keys()];
|
189
|
-
const hasNonTextMimeTypes = mimeTypes.some(mime => !isTextMimeType(mime));
|
184
|
+
const hasNonTextMimeTypes = mimeTypes.some((mime) => !isTextMimeType(mime));
|
190
185
|
const copyToEvent = (reason) => {
|
191
186
|
if (!event) {
|
192
187
|
throw new Error(`Unable to copy -- no event provided${reason ? `. Original error: ${reason}` : ''}`);
|
193
188
|
}
|
194
189
|
for (const [key, value] of mimeToData.entries()) {
|
195
190
|
if (typeof value === 'string') {
|
196
|
-
|
191
|
+
if ('clipboardData' in event) {
|
192
|
+
event.clipboardData?.setData(key, value);
|
193
|
+
}
|
194
|
+
else {
|
195
|
+
event.dataTransfer?.setData(key, value);
|
196
|
+
}
|
197
197
|
}
|
198
198
|
}
|
199
199
|
};
|
@@ -224,7 +224,9 @@ class ClipboardHandler {
|
|
224
224
|
// Browser support for ClipboardItem.supports is limited as of mid 2024. However, some browsers
|
225
225
|
// that do support `.supports` throw an exception when attempting to copy an unsupported MIME type
|
226
226
|
// (e.g. Firefox).
|
227
|
-
const unsupported = 'supports' in ClipboardItem &&
|
227
|
+
const unsupported = 'supports' in ClipboardItem &&
|
228
|
+
typeof ClipboardItem.supports === 'function' &&
|
229
|
+
!ClipboardItem.supports(key);
|
228
230
|
if (!unsupported) {
|
229
231
|
filteredMimeToData[key] = data;
|
230
232
|
}
|
@@ -234,8 +236,7 @@ class ClipboardHandler {
|
|
234
236
|
const browserMimeToData = removeUnsupportedMime(mapInternalDataToBrowserData(mimeToData));
|
235
237
|
return navigator.clipboard.write([new ClipboardItem(browserMimeToData)]);
|
236
238
|
};
|
237
|
-
const supportsClipboardApi =
|
238
|
-
&& typeof navigator?.clipboard?.write !== 'undefined');
|
239
|
+
const supportsClipboardApi = typeof ClipboardItem !== 'undefined' && typeof navigator?.clipboard?.write !== 'undefined';
|
239
240
|
if (!__classPrivateFieldGet(this, _ClipboardHandler_preferClipboardEvents, "f") && supportsClipboardApi && (hasNonTextMimeTypes || !event)) {
|
240
241
|
let clipboardApiPromise = null;
|
241
242
|
const fallBackToCopyEvent = (reason) => {
|
@@ -14,7 +14,7 @@ var _ReactiveValueImpl_value, _ReactiveValueImpl_onUpdateListeners;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.MutableReactiveValue = exports.ReactiveValue = void 0;
|
16
16
|
const noOpUpdateListenerResult = {
|
17
|
-
remove() { }
|
17
|
+
remove() { },
|
18
18
|
};
|
19
19
|
/**
|
20
20
|
* An update listener that does nothing. Useful for reactive values
|
@@ -40,8 +40,8 @@ const noOpSetUpdateListener = () => {
|
|
40
40
|
class ReactiveValue {
|
41
41
|
/** Returns a promise that resolves when this value is next changed. */
|
42
42
|
waitForNextUpdate() {
|
43
|
-
return new Promise(resolve => {
|
44
|
-
const listener = this.onUpdate(value => {
|
43
|
+
return new Promise((resolve) => {
|
44
|
+
const listener = this.onUpdate((value) => {
|
45
45
|
listener.remove();
|
46
46
|
resolve(value);
|
47
47
|
});
|
@@ -56,7 +56,7 @@ class ReactiveValue {
|
|
56
56
|
return {
|
57
57
|
get: () => value,
|
58
58
|
onUpdate: noOpSetUpdateListener,
|
59
|
-
onUpdateAndNow: callback => {
|
59
|
+
onUpdateAndNow: (callback) => {
|
60
60
|
callback(value);
|
61
61
|
return noOpUpdateListenerResult;
|
62
62
|
},
|
@@ -72,7 +72,9 @@ class ReactiveValue {
|
|
72
72
|
*/
|
73
73
|
static fromCallback(callback, sourceValues) {
|
74
74
|
const result = new ReactiveValueImpl(callback());
|
75
|
-
const resultRef = window.WeakRef
|
75
|
+
const resultRef = window.WeakRef
|
76
|
+
? new window.WeakRef(result)
|
77
|
+
: { deref: () => result };
|
76
78
|
for (const value of sourceValues) {
|
77
79
|
const listener = value.onUpdate(() => {
|
78
80
|
// Use resultRef to allow `result` to be garbage collected
|
@@ -91,12 +93,12 @@ class ReactiveValue {
|
|
91
93
|
static map(source, map, inverseMap) {
|
92
94
|
const result = ReactiveValue.fromInitialValue(map(source.get()));
|
93
95
|
let expectedResultValue = result.get();
|
94
|
-
source.onUpdate(newValue => {
|
96
|
+
source.onUpdate((newValue) => {
|
95
97
|
expectedResultValue = map(newValue);
|
96
98
|
result.set(expectedResultValue);
|
97
99
|
});
|
98
100
|
if (inverseMap) {
|
99
|
-
result.onUpdate(newValue => {
|
101
|
+
result.onUpdate((newValue) => {
|
100
102
|
// Prevent infinite loops if inverseMap is not a true
|
101
103
|
// inverse.
|
102
104
|
if (newValue !== expectedResultValue) {
|
@@ -108,7 +110,7 @@ class ReactiveValue {
|
|
108
110
|
}
|
109
111
|
static union(values) {
|
110
112
|
return ReactiveValue.fromCallback(() => {
|
111
|
-
return values.map(value => value.get());
|
113
|
+
return values.map((value) => value.get());
|
112
114
|
}, values);
|
113
115
|
}
|
114
116
|
}
|
@@ -116,9 +118,11 @@ exports.ReactiveValue = ReactiveValue;
|
|
116
118
|
class MutableReactiveValue extends ReactiveValue {
|
117
119
|
static fromProperty(sourceValue, propertyName) {
|
118
120
|
const child = ReactiveValue.fromInitialValue(sourceValue.get()[propertyName]);
|
119
|
-
const childRef = window.WeakRef
|
121
|
+
const childRef = window.WeakRef
|
122
|
+
? new window.WeakRef(child)
|
123
|
+
: { deref: () => child };
|
120
124
|
// When the source is updated...
|
121
|
-
const sourceListener = sourceValue.onUpdate(newValue => {
|
125
|
+
const sourceListener = sourceValue.onUpdate((newValue) => {
|
122
126
|
const childValue = childRef.deref();
|
123
127
|
if (childValue) {
|
124
128
|
childValue.set(newValue[propertyName]);
|
@@ -131,7 +135,7 @@ class MutableReactiveValue extends ReactiveValue {
|
|
131
135
|
});
|
132
136
|
// When the child is updated, also apply the update to the
|
133
137
|
// parent.
|
134
|
-
child.onUpdate(newValue => {
|
138
|
+
child.onUpdate((newValue) => {
|
135
139
|
sourceValue.set({
|
136
140
|
...sourceValue.get(),
|
137
141
|
[propertyName]: newValue,
|
@@ -169,7 +173,7 @@ class ReactiveValueImpl extends MutableReactiveValue {
|
|
169
173
|
__classPrivateFieldGet(this, _ReactiveValueImpl_onUpdateListeners, "f").push(listener);
|
170
174
|
return {
|
171
175
|
remove: () => {
|
172
|
-
__classPrivateFieldSet(this, _ReactiveValueImpl_onUpdateListeners, __classPrivateFieldGet(this, _ReactiveValueImpl_onUpdateListeners, "f").filter(otherListener => {
|
176
|
+
__classPrivateFieldSet(this, _ReactiveValueImpl_onUpdateListeners, __classPrivateFieldGet(this, _ReactiveValueImpl_onUpdateListeners, "f").filter((otherListener) => {
|
173
177
|
return otherListener !== listener;
|
174
178
|
}), "f");
|
175
179
|
},
|
@@ -75,8 +75,12 @@ const adjustEditorThemeForContrast = (editor, options) => {
|
|
75
75
|
// true if the variable can be updated
|
76
76
|
updateVar1, updateVar2) => {
|
77
77
|
// Fetch from updatedColors if available -- styles isn't updated dynamically.
|
78
|
-
let color1 = updatedColors[var1]
|
79
|
-
|
78
|
+
let color1 = updatedColors[var1]
|
79
|
+
? updatedColors[var1]
|
80
|
+
: math_1.Color4.fromString(styles.getPropertyValue(var1));
|
81
|
+
let color2 = updatedColors[var2]
|
82
|
+
? updatedColors[var2]
|
83
|
+
: math_1.Color4.fromString(styles.getPropertyValue(var2));
|
80
84
|
// Ensure that color1 has the lesser luminance
|
81
85
|
if (color1.relativeLuminance() < color2.relativeLuminance()) {
|
82
86
|
const tmp = color1;
|
@@ -12,7 +12,7 @@ const cloneElementWithStyles = (element) => {
|
|
12
12
|
for (let index = 0; index < originalComputedStyle.length; index++) {
|
13
13
|
const propertyName = originalComputedStyle.item(index);
|
14
14
|
const propertyValue = originalComputedStyle.getPropertyValue(propertyName);
|
15
|
-
clonedElement.style
|
15
|
+
clonedElement.style?.setProperty(propertyName, propertyValue);
|
16
16
|
}
|
17
17
|
for (let i = 0; i < originalElement.children.length; i++) {
|
18
18
|
const originalChild = originalElement.children.item(i);
|
@@ -0,0 +1,62 @@
|
|
1
|
+
type ElementTagNames = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;
|
2
|
+
/**
|
3
|
+
* Maps from known elment tag names to options that can be set with .setAttribute.
|
4
|
+
* New elements/properties should be added as necessary.
|
5
|
+
*/
|
6
|
+
interface ElementToPropertiesMap {
|
7
|
+
path: {
|
8
|
+
d: string;
|
9
|
+
fill: string;
|
10
|
+
stroke: string;
|
11
|
+
transform: string;
|
12
|
+
};
|
13
|
+
rect: {
|
14
|
+
stroke: string;
|
15
|
+
fill: string;
|
16
|
+
x: number;
|
17
|
+
y: number;
|
18
|
+
width: number;
|
19
|
+
height: number;
|
20
|
+
transform: string;
|
21
|
+
};
|
22
|
+
pattern: {
|
23
|
+
viewBox: string;
|
24
|
+
width: string;
|
25
|
+
height: string;
|
26
|
+
patternUnits: 'userSpaceOnUse';
|
27
|
+
};
|
28
|
+
stop: {
|
29
|
+
offset: string;
|
30
|
+
'stop-color': string;
|
31
|
+
};
|
32
|
+
svg: {
|
33
|
+
viewBox: `${number} ${number} ${number} ${number}`;
|
34
|
+
};
|
35
|
+
}
|
36
|
+
type EmptyObject = Record<never, never>;
|
37
|
+
type ElementProperties<Tag extends ElementTagNames> = Tag extends keyof ElementToPropertiesMap ? Partial<ElementToPropertiesMap[Tag]> : EmptyObject;
|
38
|
+
/** Contains options for creating an element with tag = `Tag`. */
|
39
|
+
type ElementConfig<Tag extends ElementTagNames> = ElementProperties<Tag> & {
|
40
|
+
id?: string;
|
41
|
+
children?: (HTMLElement | SVGElement)[];
|
42
|
+
};
|
43
|
+
/**
|
44
|
+
* Maps from element tag names (e.g. `Tag='button'`) to the corresponding element type
|
45
|
+
* (e.g. `HTMLButtonElement`).
|
46
|
+
*/
|
47
|
+
type ElementTagToType<Tag extends ElementTagNames> = Tag extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[Tag] : Tag extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[Tag] : never;
|
48
|
+
export declare enum ElementNamespace {
|
49
|
+
Html = "html",
|
50
|
+
Svg = "svg"
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Shorthand for creating an element with `document.createElement`, then assigning properties.
|
54
|
+
*
|
55
|
+
* Non-HTML elements (e.g. `svg` elements) should use the `elementType` parameter to select
|
56
|
+
* the element namespace.
|
57
|
+
*/
|
58
|
+
declare const createElement: <Tag extends ElementTagNames>(tag: Tag, props: ElementConfig<Tag>, elementType?: ElementNamespace) => ElementTagToType<Tag>;
|
59
|
+
export declare const createSvgElement: <Tag extends keyof SVGElementTagNameMap>(tag: Tag, props: ElementConfig<Tag>) => ElementTagToType<Tag>;
|
60
|
+
export declare const createSvgElements: <Tag extends keyof SVGElementTagNameMap>(tag: Tag, elements: ElementConfig<Tag>[]) => ElementTagToType<Tag>[];
|
61
|
+
export declare const createSvgPaths: (...paths: ElementConfig<"path">[]) => SVGPathElement[];
|
62
|
+
export default createElement;
|