@atlaskit/editor-plugin-media 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/commands/captions.js +59 -0
- package/dist/cjs/commands/helpers.js +127 -0
- package/dist/cjs/commands/index.js +24 -0
- package/dist/cjs/commands/linking.js +181 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/media-plugin-options.js +5 -0
- package/dist/cjs/next-plugin-type.js +5 -0
- package/dist/cjs/nodeviews/mediaGroup.js +376 -0
- package/dist/cjs/nodeviews/mediaInline.js +288 -0
- package/dist/cjs/nodeviews/mediaNodeUpdater.js +739 -0
- package/dist/cjs/nodeviews/mediaNodeView/index.js +177 -0
- package/dist/cjs/nodeviews/mediaNodeView/media.js +242 -0
- package/dist/cjs/nodeviews/mediaSingle.js +629 -0
- package/dist/cjs/nodeviews/messages.js +14 -0
- package/dist/cjs/nodeviews/styles.js +46 -0
- package/dist/cjs/nodeviews/types.js +5 -0
- package/dist/cjs/picker-facade.js +192 -0
- package/dist/cjs/plugin.js +293 -0
- package/dist/cjs/pm-plugins/alt-text/actions.js +5 -0
- package/dist/cjs/pm-plugins/alt-text/commands.js +59 -0
- package/dist/cjs/pm-plugins/alt-text/index.js +36 -0
- package/dist/cjs/pm-plugins/alt-text/keymap.js +15 -0
- package/dist/cjs/pm-plugins/alt-text/messages.js +44 -0
- package/dist/cjs/pm-plugins/alt-text/reducer.js +32 -0
- package/dist/cjs/pm-plugins/alt-text/types.js +5 -0
- package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +209 -0
- package/dist/cjs/pm-plugins/keymap-media-single.js +163 -0
- package/dist/cjs/pm-plugins/keymap.js +88 -0
- package/dist/cjs/pm-plugins/linking/actions.js +13 -0
- package/dist/cjs/pm-plugins/linking/index.js +65 -0
- package/dist/cjs/pm-plugins/linking/keymap.js +14 -0
- package/dist/cjs/pm-plugins/linking/reducer.js +43 -0
- package/dist/cjs/pm-plugins/linking/types.js +5 -0
- package/dist/cjs/pm-plugins/main.js +813 -0
- package/dist/cjs/pm-plugins/media-editor-plugin-factory.js +8 -0
- package/dist/cjs/pm-plugins/mediaTaskManager.js +101 -0
- package/dist/cjs/pm-plugins/plugin-key.js +8 -0
- package/dist/cjs/pm-plugins/types.js +5 -0
- package/dist/cjs/toolbar/alt-text.js +80 -0
- package/dist/cjs/toolbar/commands.js +236 -0
- package/dist/cjs/toolbar/filePreviewItem.js +66 -0
- package/dist/cjs/toolbar/imageBorder.js +20 -0
- package/dist/cjs/toolbar/index.js +523 -0
- package/dist/cjs/toolbar/linking-toolbar-appearance.js +100 -0
- package/dist/cjs/toolbar/linking.js +96 -0
- package/dist/cjs/toolbar/utils.js +110 -0
- package/dist/cjs/ui/CaptionPlaceholder/index.js +27 -0
- package/dist/cjs/ui/CaptionPlaceholder/messages.js +14 -0
- package/dist/cjs/ui/ImageBorder/index.js +226 -0
- package/dist/cjs/ui/ImageBorder/messages.js +49 -0
- package/dist/cjs/ui/ImageBorder/styles.js +52 -0
- package/dist/cjs/ui/Media/DropPlaceholder.js +38 -0
- package/dist/cjs/ui/Media/drop-placeholder-messages.js +14 -0
- package/dist/cjs/ui/MediaLinkingToolbar.js +196 -0
- package/dist/cjs/ui/MediaPicker/BrowserWrapper.js +40 -0
- package/dist/cjs/ui/MediaPicker/ClipboardWrapper.js +39 -0
- package/dist/cjs/ui/MediaPicker/DropzoneWrapper.js +51 -0
- package/dist/cjs/ui/MediaPicker/PickerFacadeProvider.js +151 -0
- package/dist/cjs/ui/MediaPicker/index.js +103 -0
- package/dist/cjs/ui/PixelEntry/constants.js +7 -0
- package/dist/cjs/ui/PixelEntry/index.js +185 -0
- package/dist/cjs/ui/PixelEntry/messages.js +54 -0
- package/dist/cjs/ui/PixelEntry/styles.js +19 -0
- package/dist/cjs/ui/PixelEntry/types.js +5 -0
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +16 -0
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +541 -0
- package/dist/cjs/ui/ResizableMediaSingle/index.js +422 -0
- package/dist/cjs/ui/ResizableMediaSingle/styled.js +14 -0
- package/dist/cjs/ui/ResizableMediaSingle/styles.js +17 -0
- package/dist/cjs/ui/ResizableMediaSingle/types.js +5 -0
- package/dist/cjs/ui/ToolbarMedia/index.js +42 -0
- package/dist/cjs/ui/ToolbarMedia/toolbar-media-messages.js +14 -0
- package/dist/cjs/ui/media-linking-toolbar-messages.js +14 -0
- package/dist/cjs/utils/analytics.js +53 -0
- package/dist/cjs/utils/check-media-type.js +56 -0
- package/dist/cjs/utils/current-media-node.js +41 -0
- package/dist/cjs/utils/is-image.js +9 -0
- package/dist/cjs/utils/media-common.js +181 -0
- package/dist/cjs/utils/media-files.js +297 -0
- package/dist/cjs/utils/media-single.js +181 -0
- package/dist/es2019/commands/captions.js +47 -0
- package/dist/es2019/commands/helpers.js +113 -0
- package/dist/es2019/commands/index.js +1 -0
- package/dist/es2019/commands/linking.js +169 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/media-plugin-options.js +1 -0
- package/dist/es2019/next-plugin-type.js +1 -0
- package/dist/es2019/nodeviews/mediaGroup.js +314 -0
- package/dist/es2019/nodeviews/mediaInline.js +201 -0
- package/dist/es2019/nodeviews/mediaNodeUpdater.js +384 -0
- package/dist/es2019/nodeviews/mediaNodeView/index.js +149 -0
- package/dist/es2019/nodeviews/mediaNodeView/media.js +182 -0
- package/dist/es2019/nodeviews/mediaSingle.js +511 -0
- package/dist/es2019/nodeviews/messages.js +8 -0
- package/dist/es2019/nodeviews/styles.js +46 -0
- package/dist/es2019/nodeviews/types.js +1 -0
- package/dist/es2019/picker-facade.js +146 -0
- package/dist/es2019/plugin.js +284 -0
- package/dist/es2019/pm-plugins/alt-text/actions.js +1 -0
- package/dist/es2019/pm-plugins/alt-text/commands.js +42 -0
- package/dist/es2019/pm-plugins/alt-text/index.js +33 -0
- package/dist/es2019/pm-plugins/alt-text/keymap.js +9 -0
- package/dist/es2019/pm-plugins/alt-text/messages.js +38 -0
- package/dist/es2019/pm-plugins/alt-text/reducer.js +26 -0
- package/dist/es2019/pm-plugins/alt-text/types.js +1 -0
- package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +228 -0
- package/dist/es2019/pm-plugins/keymap-media-single.js +172 -0
- package/dist/es2019/pm-plugins/keymap.js +84 -0
- package/dist/es2019/pm-plugins/linking/actions.js +7 -0
- package/dist/es2019/pm-plugins/linking/index.js +56 -0
- package/dist/es2019/pm-plugins/linking/keymap.js +8 -0
- package/dist/es2019/pm-plugins/linking/reducer.js +37 -0
- package/dist/es2019/pm-plugins/linking/types.js +1 -0
- package/dist/es2019/pm-plugins/main.js +695 -0
- package/dist/es2019/pm-plugins/media-editor-plugin-factory.js +2 -0
- package/dist/es2019/pm-plugins/mediaTaskManager.js +64 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/types.js +1 -0
- package/dist/es2019/toolbar/alt-text.js +72 -0
- package/dist/es2019/toolbar/commands.js +212 -0
- package/dist/es2019/toolbar/filePreviewItem.js +54 -0
- package/dist/es2019/toolbar/imageBorder.js +15 -0
- package/dist/es2019/toolbar/index.js +538 -0
- package/dist/es2019/toolbar/linking-toolbar-appearance.js +90 -0
- package/dist/es2019/toolbar/linking.js +98 -0
- package/dist/es2019/toolbar/utils.js +86 -0
- package/dist/es2019/ui/CaptionPlaceholder/index.js +25 -0
- package/dist/es2019/ui/CaptionPlaceholder/messages.js +8 -0
- package/dist/es2019/ui/ImageBorder/index.js +213 -0
- package/dist/es2019/ui/ImageBorder/messages.js +43 -0
- package/dist/es2019/ui/ImageBorder/styles.js +126 -0
- package/dist/es2019/ui/Media/DropPlaceholder.js +47 -0
- package/dist/es2019/ui/Media/drop-placeholder-messages.js +8 -0
- package/dist/es2019/ui/MediaLinkingToolbar.js +190 -0
- package/dist/es2019/ui/MediaPicker/BrowserWrapper.js +31 -0
- package/dist/es2019/ui/MediaPicker/ClipboardWrapper.js +32 -0
- package/dist/es2019/ui/MediaPicker/DropzoneWrapper.js +42 -0
- package/dist/es2019/ui/MediaPicker/PickerFacadeProvider.js +85 -0
- package/dist/es2019/ui/MediaPicker/index.js +82 -0
- package/dist/es2019/ui/PixelEntry/constants.js +1 -0
- package/dist/es2019/ui/PixelEntry/index.js +170 -0
- package/dist/es2019/ui/PixelEntry/messages.js +48 -0
- package/dist/es2019/ui/PixelEntry/styles.js +51 -0
- package/dist/es2019/ui/PixelEntry/types.js +1 -0
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +9 -0
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +454 -0
- package/dist/es2019/ui/ResizableMediaSingle/index.js +344 -0
- package/dist/es2019/ui/ResizableMediaSingle/styled.js +9 -0
- package/dist/es2019/ui/ResizableMediaSingle/styles.js +14 -0
- package/dist/es2019/ui/ResizableMediaSingle/types.js +1 -0
- package/dist/es2019/ui/ToolbarMedia/index.js +37 -0
- package/dist/es2019/ui/ToolbarMedia/toolbar-media-messages.js +8 -0
- package/dist/es2019/ui/media-linking-toolbar-messages.js +8 -0
- package/dist/es2019/utils/analytics.js +51 -0
- package/dist/es2019/utils/check-media-type.js +19 -0
- package/dist/es2019/utils/current-media-node.js +35 -0
- package/dist/es2019/utils/is-image.js +3 -0
- package/dist/es2019/utils/media-common.js +189 -0
- package/dist/es2019/utils/media-files.js +321 -0
- package/dist/es2019/utils/media-single.js +176 -0
- package/dist/esm/commands/captions.js +53 -0
- package/dist/esm/commands/helpers.js +120 -0
- package/dist/esm/commands/index.js +1 -0
- package/dist/esm/commands/linking.js +174 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/media-plugin-options.js +1 -0
- package/dist/esm/next-plugin-type.js +1 -0
- package/dist/esm/nodeviews/mediaGroup.js +369 -0
- package/dist/esm/nodeviews/mediaInline.js +278 -0
- package/dist/esm/nodeviews/mediaNodeUpdater.js +732 -0
- package/dist/esm/nodeviews/mediaNodeView/index.js +170 -0
- package/dist/esm/nodeviews/mediaNodeView/media.js +233 -0
- package/dist/esm/nodeviews/mediaSingle.js +622 -0
- package/dist/esm/nodeviews/messages.js +8 -0
- package/dist/esm/nodeviews/styles.js +39 -0
- package/dist/esm/nodeviews/types.js +1 -0
- package/dist/esm/picker-facade.js +186 -0
- package/dist/esm/plugin.js +282 -0
- package/dist/esm/pm-plugins/alt-text/actions.js +1 -0
- package/dist/esm/pm-plugins/alt-text/commands.js +52 -0
- package/dist/esm/pm-plugins/alt-text/index.js +31 -0
- package/dist/esm/pm-plugins/alt-text/keymap.js +9 -0
- package/dist/esm/pm-plugins/alt-text/messages.js +38 -0
- package/dist/esm/pm-plugins/alt-text/reducer.js +25 -0
- package/dist/esm/pm-plugins/alt-text/types.js +1 -0
- package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +206 -0
- package/dist/esm/pm-plugins/keymap-media-single.js +158 -0
- package/dist/esm/pm-plugins/keymap.js +81 -0
- package/dist/esm/pm-plugins/linking/actions.js +7 -0
- package/dist/esm/pm-plugins/linking/index.js +59 -0
- package/dist/esm/pm-plugins/linking/keymap.js +8 -0
- package/dist/esm/pm-plugins/linking/reducer.js +36 -0
- package/dist/esm/pm-plugins/linking/types.js +1 -0
- package/dist/esm/pm-plugins/main.js +798 -0
- package/dist/esm/pm-plugins/media-editor-plugin-factory.js +2 -0
- package/dist/esm/pm-plugins/mediaTaskManager.js +94 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/types.js +1 -0
- package/dist/esm/toolbar/alt-text.js +70 -0
- package/dist/esm/toolbar/commands.js +229 -0
- package/dist/esm/toolbar/filePreviewItem.js +56 -0
- package/dist/esm/toolbar/imageBorder.js +14 -0
- package/dist/esm/toolbar/index.js +513 -0
- package/dist/esm/toolbar/linking-toolbar-appearance.js +91 -0
- package/dist/esm/toolbar/linking.js +88 -0
- package/dist/esm/toolbar/utils.js +103 -0
- package/dist/esm/ui/CaptionPlaceholder/index.js +20 -0
- package/dist/esm/ui/CaptionPlaceholder/messages.js +8 -0
- package/dist/esm/ui/ImageBorder/index.js +218 -0
- package/dist/esm/ui/ImageBorder/messages.js +43 -0
- package/dist/esm/ui/ImageBorder/styles.js +42 -0
- package/dist/esm/ui/Media/DropPlaceholder.js +31 -0
- package/dist/esm/ui/Media/drop-placeholder-messages.js +8 -0
- package/dist/esm/ui/MediaLinkingToolbar.js +188 -0
- package/dist/esm/ui/MediaPicker/BrowserWrapper.js +33 -0
- package/dist/esm/ui/MediaPicker/ClipboardWrapper.js +32 -0
- package/dist/esm/ui/MediaPicker/DropzoneWrapper.js +44 -0
- package/dist/esm/ui/MediaPicker/PickerFacadeProvider.js +145 -0
- package/dist/esm/ui/MediaPicker/index.js +96 -0
- package/dist/esm/ui/PixelEntry/constants.js +1 -0
- package/dist/esm/ui/PixelEntry/index.js +174 -0
- package/dist/esm/ui/PixelEntry/messages.js +48 -0
- package/dist/esm/ui/PixelEntry/styles.js +12 -0
- package/dist/esm/ui/PixelEntry/types.js +1 -0
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +9 -0
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +535 -0
- package/dist/esm/ui/ResizableMediaSingle/index.js +417 -0
- package/dist/esm/ui/ResizableMediaSingle/styled.js +7 -0
- package/dist/esm/ui/ResizableMediaSingle/styles.js +7 -0
- package/dist/esm/ui/ResizableMediaSingle/types.js +1 -0
- package/dist/esm/ui/ToolbarMedia/index.js +35 -0
- package/dist/esm/ui/ToolbarMedia/toolbar-media-messages.js +8 -0
- package/dist/esm/ui/media-linking-toolbar-messages.js +8 -0
- package/dist/esm/utils/analytics.js +47 -0
- package/dist/esm/utils/check-media-type.js +49 -0
- package/dist/esm/utils/current-media-node.js +35 -0
- package/dist/esm/utils/is-image.js +3 -0
- package/dist/esm/utils/media-common.js +175 -0
- package/dist/esm/utils/media-files.js +291 -0
- package/dist/esm/utils/media-single.js +172 -0
- package/dist/types/commands/captions.d.ts +5 -0
- package/dist/types/commands/helpers.d.ts +15 -0
- package/dist/types/commands/index.d.ts +1 -0
- package/dist/types/commands/linking.d.ts +9 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/media-plugin-options.d.ts +17 -0
- package/dist/types/next-plugin-type.d.ts +33 -0
- package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +24 -0
- package/dist/types/nodeviews/mediaGroup.d.ts +33 -0
- package/dist/types/nodeviews/mediaInline.d.ts +50 -0
- package/dist/types/nodeviews/mediaNodeUpdater.d.ts +45 -0
- package/dist/types/nodeviews/mediaNodeView/index.d.ts +28 -0
- package/dist/types/nodeviews/mediaNodeView/media.d.ts +44 -0
- package/dist/types/nodeviews/mediaSingle.d.ts +62 -0
- package/dist/types/nodeviews/messages.d.ts +7 -0
- package/dist/types/nodeviews/styles.d.ts +16 -0
- package/dist/types/nodeviews/types.d.ts +42 -0
- package/dist/types/picker-facade.d.ts +44 -0
- package/dist/types/plugin.d.ts +7 -0
- package/dist/types/pm-plugins/alt-text/actions.d.ts +10 -0
- package/dist/types/pm-plugins/alt-text/commands.d.ts +4 -0
- package/dist/types/pm-plugins/alt-text/index.d.ts +7 -0
- package/dist/types/pm-plugins/alt-text/keymap.d.ts +4 -0
- package/dist/types/pm-plugins/alt-text/messages.d.ts +37 -0
- package/dist/types/pm-plugins/alt-text/reducer.d.ts +4 -0
- package/dist/types/pm-plugins/alt-text/types.d.ts +3 -0
- package/dist/types/pm-plugins/alt-text/ui/AltTextEdit.d.ts +41 -0
- package/dist/types/pm-plugins/keymap-media-single.d.ts +3 -0
- package/dist/types/pm-plugins/keymap.d.ts +6 -0
- package/dist/types/pm-plugins/linking/actions.d.ts +20 -0
- package/dist/types/pm-plugins/linking/index.d.ts +10 -0
- package/dist/types/pm-plugins/linking/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/linking/reducer.d.ts +4 -0
- package/dist/types/pm-plugins/linking/types.d.ts +12 -0
- package/dist/types/pm-plugins/main.d.ts +120 -0
- package/dist/types/pm-plugins/media-editor-plugin-factory.d.ts +3 -0
- package/dist/types/pm-plugins/mediaTaskManager.d.ts +9 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/types.d.ts +65 -0
- package/dist/types/toolbar/alt-text.d.ts +13 -0
- package/dist/types/toolbar/commands.d.ts +12 -0
- package/dist/types/toolbar/filePreviewItem.d.ts +9 -0
- package/dist/types/toolbar/imageBorder.d.ts +2 -0
- package/dist/types/toolbar/index.d.ts +6 -0
- package/dist/types/toolbar/linking-toolbar-appearance.d.ts +14 -0
- package/dist/types/toolbar/linking.d.ts +10 -0
- package/dist/types/toolbar/utils.d.ts +11 -0
- package/dist/types/types.d.ts +2 -1
- package/dist/types/ui/CaptionPlaceholder/index.d.ts +6 -0
- package/dist/types/ui/CaptionPlaceholder/messages.d.ts +7 -0
- package/dist/types/ui/ImageBorder/index.d.ts +11 -0
- package/dist/types/ui/ImageBorder/messages.d.ts +42 -0
- package/dist/types/ui/ImageBorder/styles.d.ts +15 -0
- package/dist/types/ui/Media/DropPlaceholder.d.ts +8 -0
- package/dist/types/ui/Media/drop-placeholder-messages.d.ts +7 -0
- package/dist/types/ui/MediaLinkingToolbar.d.ts +35 -0
- package/dist/types/ui/MediaPicker/BrowserWrapper.d.ts +11 -0
- package/dist/types/ui/MediaPicker/ClipboardWrapper.d.ts +10 -0
- package/dist/types/ui/MediaPicker/DropzoneWrapper.d.ts +13 -0
- package/dist/types/ui/MediaPicker/PickerFacadeProvider.d.ts +28 -0
- package/dist/types/ui/MediaPicker/index.d.ts +23 -0
- package/dist/types/ui/PixelEntry/constants.d.ts +1 -0
- package/dist/types/ui/PixelEntry/index.d.ts +8 -0
- package/dist/types/ui/PixelEntry/messages.d.ts +47 -0
- package/dist/types/ui/PixelEntry/styles.d.ts +8 -0
- package/dist/types/ui/PixelEntry/types.d.ts +58 -0
- package/dist/types/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +3 -0
- package/dist/types/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +59 -0
- package/dist/types/ui/ResizableMediaSingle/index.d.ts +45 -0
- package/dist/types/ui/ResizableMediaSingle/styled.d.ts +2 -0
- package/dist/types/ui/ResizableMediaSingle/styles.d.ts +1 -0
- package/dist/types/ui/ResizableMediaSingle/types.d.ts +27 -0
- package/dist/types/ui/ToolbarMedia/index.d.ts +13 -0
- package/dist/types/ui/ToolbarMedia/toolbar-media-messages.d.ts +7 -0
- package/dist/types/ui/media-linking-toolbar-messages.d.ts +7 -0
- package/dist/types/utils/analytics.d.ts +3 -0
- package/dist/types/utils/check-media-type.d.ts +4 -0
- package/dist/types/utils/current-media-node.d.ts +9 -0
- package/dist/types/utils/is-image.d.ts +1 -0
- package/dist/types/utils/media-common.d.ts +20 -0
- package/dist/types/utils/media-files.d.ts +30 -0
- package/dist/types/utils/media-single.d.ts +20 -0
- package/package.json +32 -20
- package/report.api.md +430 -0
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -118
- package/tmp/api-report-tmp.d.ts +0 -9
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
/** @jsx jsx */
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { jsx } from '@emotion/react';
|
|
16
|
+
import classnames from 'classnames';
|
|
17
|
+
import throttle from 'lodash/throttle';
|
|
18
|
+
import memoizeOne from 'memoize-one';
|
|
19
|
+
import { findClosestSnap, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps, getGuidelinesWithHighlights, getGuidelineTypeFromKey, getRelativeGuidelines, getRelativeGuideSnaps } from '@atlaskit/editor-common/guideline';
|
|
20
|
+
import { calcMediaSingleMaxWidth, DEFAULT_IMAGE_WIDTH, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
21
|
+
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
22
|
+
import { resizerStyles, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
23
|
+
import { calcPctFromPx, handleSides, imageAlignmentMap, wrappedLayouts } from '@atlaskit/editor-common/ui';
|
|
24
|
+
import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
25
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
26
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
|
|
27
|
+
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
28
|
+
import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
|
|
29
|
+
import { checkMediaType } from '../../utils/check-media-type';
|
|
30
|
+
import { ResizableMediaMigrationNotification } from './ResizableMediaMigrationNotification';
|
|
31
|
+
import { wrapperStyle } from './styled';
|
|
32
|
+
export var resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
34
|
+
var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
35
|
+
_inherits(ResizableMediaSingleNext, _React$Component);
|
|
36
|
+
var _super = _createSuper(ResizableMediaSingleNext);
|
|
37
|
+
function ResizableMediaSingleNext(props) {
|
|
38
|
+
var _this;
|
|
39
|
+
_classCallCheck(this, ResizableMediaSingleNext);
|
|
40
|
+
_this = _super.call(this, props);
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "lastSnappedGuidelineKeys", []);
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "updateGuidelines", function () {
|
|
43
|
+
var _this$props = _this.props,
|
|
44
|
+
view = _this$props.view,
|
|
45
|
+
lineLength = _this$props.lineLength;
|
|
46
|
+
var defaultGuidelines = _this.getDefaultGuidelines();
|
|
47
|
+
var _generateDynamicGuide = generateDynamicGuidelines(view.state, lineLength, {
|
|
48
|
+
styles: {
|
|
49
|
+
lineStyle: 'dashed'
|
|
50
|
+
},
|
|
51
|
+
show: false
|
|
52
|
+
}),
|
|
53
|
+
relativeGuides = _generateDynamicGuide.relativeGuides,
|
|
54
|
+
dynamicGuides = _generateDynamicGuide.dynamicGuides;
|
|
55
|
+
|
|
56
|
+
// disable guidelines for nested media single node
|
|
57
|
+
var dynamicGuidelines = _this.isNestedNode() ? [] : dynamicGuides;
|
|
58
|
+
_this.setState({
|
|
59
|
+
relativeGuides: relativeGuides,
|
|
60
|
+
guidelines: [].concat(_toConsumableArray(defaultGuidelines), _toConsumableArray(dynamicGuidelines))
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "calcNewLayout", function (newWidth, stop) {
|
|
64
|
+
var _this$props2 = _this.props,
|
|
65
|
+
layout = _this$props2.layout,
|
|
66
|
+
containerWidth = _this$props2.containerWidth,
|
|
67
|
+
lineLength = _this$props2.lineLength,
|
|
68
|
+
fullWidthMode = _this$props2.fullWidthMode;
|
|
69
|
+
var newPct = calcPctFromPx(newWidth, lineLength) * 100;
|
|
70
|
+
if (newPct <= 100 && _this.wrappedLayout) {
|
|
71
|
+
if (!stop || newPct !== 100) {
|
|
72
|
+
return layout;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode, _this.isNestedNode());
|
|
76
|
+
});
|
|
77
|
+
_defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode, isNestedNode) {
|
|
78
|
+
if (isNestedNode) {
|
|
79
|
+
return 'center';
|
|
80
|
+
}
|
|
81
|
+
if (fullWidthMode) {
|
|
82
|
+
if (width < contentWidth) {
|
|
83
|
+
return 'center';
|
|
84
|
+
}
|
|
85
|
+
return 'full-width';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// handle top-level node in fixed-width editor
|
|
89
|
+
if (width <= contentWidth) {
|
|
90
|
+
return 'center';
|
|
91
|
+
}
|
|
92
|
+
if (width < Math.min(containerWidth - akEditorGutterPadding * 2, akEditorFullWidthLayoutWidth)) {
|
|
93
|
+
return 'wide';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// set full width to be containerWidth - akEditorGutterPadding * 2
|
|
97
|
+
// instead of containerWidth - akEditorBreakoutPadding,
|
|
98
|
+
// so that we have image aligned with text
|
|
99
|
+
return 'full-width';
|
|
100
|
+
});
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "calcPxHeight", function (newWidth) {
|
|
102
|
+
var _this$props3 = _this.props,
|
|
103
|
+
_this$props3$width = _this$props3.width,
|
|
104
|
+
width = _this$props3$width === void 0 ? newWidth : _this$props3$width,
|
|
105
|
+
height = _this$props3.height;
|
|
106
|
+
return Math.round(height / width * newWidth);
|
|
107
|
+
});
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "displayGuideline", function (guidelines) {
|
|
109
|
+
var _this$props$pluginInj;
|
|
110
|
+
return (_this$props$pluginInj = _this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.guideline) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.actions) === null || _this$props$pluginInj === void 0 ? void 0 : _this$props$pluginInj.displayGuideline(_this.props.view)({
|
|
111
|
+
guidelines: guidelines
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(_assertThisInitialized(_this), "setIsResizing", function (isResizing) {
|
|
115
|
+
var _this$props$view = _this.props.view,
|
|
116
|
+
state = _this$props$view.state,
|
|
117
|
+
dispatch = _this$props$view.dispatch;
|
|
118
|
+
var tr = state.tr;
|
|
119
|
+
tr.setMeta(MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
|
|
120
|
+
return dispatch(tr);
|
|
121
|
+
});
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "updateSizeInPluginState", throttle(function (width) {
|
|
123
|
+
var _this$props$view2 = _this.props.view,
|
|
124
|
+
state = _this$props$view2.state,
|
|
125
|
+
dispatch = _this$props$view2.dispatch;
|
|
126
|
+
var tr = state.tr;
|
|
127
|
+
tr.setMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
|
|
128
|
+
return dispatch(tr);
|
|
129
|
+
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "calcMaxWidth", memoizeOne(function (contentWidth, containerWidth, fullWidthMode) {
|
|
131
|
+
if (_this.isNestedNode() || fullWidthMode) {
|
|
132
|
+
return contentWidth;
|
|
133
|
+
}
|
|
134
|
+
return calcMediaSingleMaxWidth(containerWidth);
|
|
135
|
+
}));
|
|
136
|
+
_defineProperty(_assertThisInitialized(_this), "calcMinWidth", memoizeOne(function (isVideoFile, contentWidth) {
|
|
137
|
+
return Math.min(contentWidth || akEditorDefaultLayoutWidth, isVideoFile ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH);
|
|
138
|
+
}));
|
|
139
|
+
_defineProperty(_assertThisInitialized(_this), "getRelativeGuides", function () {
|
|
140
|
+
var _this$props$pluginInj2;
|
|
141
|
+
var guidelinePluginState = (_this$props$pluginInj2 = _this.props.pluginInjectionApi) === null || _this$props$pluginInj2 === void 0 || (_this$props$pluginInj2 = _this$props$pluginInj2.guideline) === null || _this$props$pluginInj2 === void 0 || (_this$props$pluginInj2 = _this$props$pluginInj2.sharedState) === null || _this$props$pluginInj2 === void 0 ? void 0 : _this$props$pluginInj2.currentState();
|
|
142
|
+
var _ref = (guidelinePluginState === null || guidelinePluginState === void 0 ? void 0 : guidelinePluginState.rect) || {
|
|
143
|
+
top: 0,
|
|
144
|
+
left: 0
|
|
145
|
+
},
|
|
146
|
+
topOffset = _ref.top;
|
|
147
|
+
var $pos = _this.$pos;
|
|
148
|
+
var relativeGuides = $pos && $pos.nodeAfter && _this.state.size.width ? getRelativeGuidelines(_this.state.relativeGuides, {
|
|
149
|
+
node: $pos.nodeAfter,
|
|
150
|
+
pos: $pos.pos
|
|
151
|
+
}, _this.props.view, _this.props.lineLength, topOffset, _this.state.size) : [];
|
|
152
|
+
return relativeGuides;
|
|
153
|
+
});
|
|
154
|
+
_defineProperty(_assertThisInitialized(_this), "updateActiveGuidelines", function () {
|
|
155
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
156
|
+
var guidelines = arguments.length > 1 ? arguments[1] : undefined;
|
|
157
|
+
var guidelineSnapsReference = arguments.length > 2 ? arguments[2] : undefined;
|
|
158
|
+
if (guidelineSnapsReference.snaps.x) {
|
|
159
|
+
var _findClosestSnap = findClosestSnap(width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, MEDIA_SINGLE_SNAP_GAP),
|
|
160
|
+
gap = _findClosestSnap.gap,
|
|
161
|
+
activeGuidelineKeys = _findClosestSnap.keys;
|
|
162
|
+
var relativeGuidelines = activeGuidelineKeys.length ? [] : _this.getRelativeGuides();
|
|
163
|
+
_this.lastSnappedGuidelineKeys = activeGuidelineKeys.length ? activeGuidelineKeys : relativeGuidelines.map(function (rg) {
|
|
164
|
+
return rg.key;
|
|
165
|
+
});
|
|
166
|
+
_this.displayGuideline([].concat(_toConsumableArray(getGuidelinesWithHighlights(gap, MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines)), _toConsumableArray(relativeGuidelines)));
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
_defineProperty(_assertThisInitialized(_this), "calculateSizeState", function (size, delta) {
|
|
170
|
+
var onResizeStop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
171
|
+
var calculatedWidth = Math.round(size.width + delta.width);
|
|
172
|
+
var calculatedWidthWithLayout = _this.calcNewLayout(calculatedWidth, onResizeStop);
|
|
173
|
+
return {
|
|
174
|
+
width: calculatedWidth,
|
|
175
|
+
height: calculatedWidth / _this.aspectRatio,
|
|
176
|
+
layout: calculatedWidthWithLayout
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
_defineProperty(_assertThisInitialized(_this), "selectCurrentMediaNode", function () {
|
|
180
|
+
// TODO: if adding !this.props.selected, it doesn't work if media single node is at top postion
|
|
181
|
+
if (_this.pos === null) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
setNodeSelection(_this.props.view, _this.pos);
|
|
185
|
+
});
|
|
186
|
+
_defineProperty(_assertThisInitialized(_this), "handleResizeStart", function () {
|
|
187
|
+
_this.setState({
|
|
188
|
+
isResizing: true
|
|
189
|
+
});
|
|
190
|
+
_this.selectCurrentMediaNode();
|
|
191
|
+
_this.setIsResizing(true);
|
|
192
|
+
_this.updateSizeInPluginState(_this.state.size.width);
|
|
193
|
+
// re-calculate guidelines
|
|
194
|
+
if (_this.isGuidelineEnabled) {
|
|
195
|
+
_this.updateGuidelines();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
_defineProperty(_assertThisInitialized(_this), "handleResize", function (size, delta) {
|
|
199
|
+
var _this$props4 = _this.props,
|
|
200
|
+
layout = _this$props4.layout,
|
|
201
|
+
updateSize = _this$props4.updateSize,
|
|
202
|
+
lineLength = _this$props4.lineLength;
|
|
203
|
+
var _this$calculateSizeSt = _this.calculateSizeState(size, delta),
|
|
204
|
+
width = _this$calculateSizeSt.width,
|
|
205
|
+
height = _this$calculateSizeSt.height,
|
|
206
|
+
newLayout = _this$calculateSizeSt.layout;
|
|
207
|
+
if (_this.isGuidelineEnabled) {
|
|
208
|
+
var guidelineSnaps = getGuidelineSnaps(_this.state.guidelines, lineLength, layout);
|
|
209
|
+
_this.updateActiveGuidelines(width, _this.state.guidelines, guidelineSnaps);
|
|
210
|
+
var relativeSnaps = getRelativeGuideSnaps(_this.state.relativeGuides, _this.aspectRatio);
|
|
211
|
+
_this.setState({
|
|
212
|
+
size: {
|
|
213
|
+
width: width,
|
|
214
|
+
height: height
|
|
215
|
+
},
|
|
216
|
+
snaps: {
|
|
217
|
+
x: [].concat(_toConsumableArray(guidelineSnaps.snaps.x || []), _toConsumableArray(relativeSnaps))
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
_this.setState({
|
|
222
|
+
size: {
|
|
223
|
+
width: width,
|
|
224
|
+
height: height
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
_this.updateSizeInPluginState(width);
|
|
229
|
+
if (newLayout !== layout) {
|
|
230
|
+
updateSize(width, newLayout);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
_defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (size, delta) {
|
|
234
|
+
var _this$props5 = _this.props,
|
|
235
|
+
updateSize = _this$props5.updateSize,
|
|
236
|
+
dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent,
|
|
237
|
+
nodeType = _this$props5.nodeType;
|
|
238
|
+
var _this$calculateSizeSt2 = _this.calculateSizeState(size, delta, true),
|
|
239
|
+
width = _this$calculateSizeSt2.width,
|
|
240
|
+
height = _this$calculateSizeSt2.height,
|
|
241
|
+
newLayout = _this$calculateSizeSt2.layout;
|
|
242
|
+
if (dispatchAnalyticsEvent) {
|
|
243
|
+
var $pos = _this.$pos;
|
|
244
|
+
var event = getMediaResizeAnalyticsEvent(nodeType || 'mediaSingle', {
|
|
245
|
+
width: width,
|
|
246
|
+
layout: newLayout,
|
|
247
|
+
widthType: 'pixel',
|
|
248
|
+
snapType: getGuidelineTypeFromKey(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
|
|
249
|
+
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
250
|
+
});
|
|
251
|
+
if (event) {
|
|
252
|
+
dispatchAnalyticsEvent(event);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
_this.setIsResizing(false);
|
|
256
|
+
_this.displayGuideline([]);
|
|
257
|
+
var newWidth = width;
|
|
258
|
+
if (newLayout === 'full-width') {
|
|
259
|
+
// When a node reaches full width in current viewport,
|
|
260
|
+
// update its width with 1800 to align with pixel entry
|
|
261
|
+
newWidth = akEditorFullWidthLayoutWidth;
|
|
262
|
+
}
|
|
263
|
+
_this.setState({
|
|
264
|
+
isResizing: false,
|
|
265
|
+
size: {
|
|
266
|
+
width: newWidth,
|
|
267
|
+
height: height
|
|
268
|
+
}
|
|
269
|
+
}, function () {
|
|
270
|
+
updateSize(newWidth, newLayout);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
var initialWidth = props.mediaSingleWidth || DEFAULT_IMAGE_WIDTH;
|
|
274
|
+
_this.state = {
|
|
275
|
+
isVideoFile: true,
|
|
276
|
+
isResizing: false,
|
|
277
|
+
size: {
|
|
278
|
+
width: initialWidth,
|
|
279
|
+
height: _this.calcPxHeight(initialWidth)
|
|
280
|
+
},
|
|
281
|
+
snaps: {},
|
|
282
|
+
relativeGuides: {},
|
|
283
|
+
guidelines: []
|
|
284
|
+
};
|
|
285
|
+
return _this;
|
|
286
|
+
}
|
|
287
|
+
_createClass(ResizableMediaSingleNext, [{
|
|
288
|
+
key: "componentDidUpdate",
|
|
289
|
+
value: function componentDidUpdate(prevProps) {
|
|
290
|
+
if (prevProps.mediaSingleWidth !== this.props.mediaSingleWidth && this.props.mediaSingleWidth) {
|
|
291
|
+
// update size when lineLength becomes defined later
|
|
292
|
+
// ensures extended experience renders legacy image with the same size as the legacy experience
|
|
293
|
+
var initialWidth = this.props.mediaSingleWidth;
|
|
294
|
+
this.setState({
|
|
295
|
+
size: {
|
|
296
|
+
width: initialWidth,
|
|
297
|
+
height: this.calcPxHeight(initialWidth)
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "componentDidMount",
|
|
305
|
+
value: function () {
|
|
306
|
+
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
307
|
+
var viewMediaClientConfig;
|
|
308
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
309
|
+
while (1) switch (_context.prev = _context.next) {
|
|
310
|
+
case 0:
|
|
311
|
+
viewMediaClientConfig = this.props.viewMediaClientConfig;
|
|
312
|
+
if (!viewMediaClientConfig) {
|
|
313
|
+
_context.next = 4;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
_context.next = 4;
|
|
317
|
+
return this.checkVideoFile(viewMediaClientConfig);
|
|
318
|
+
case 4:
|
|
319
|
+
case "end":
|
|
320
|
+
return _context.stop();
|
|
321
|
+
}
|
|
322
|
+
}, _callee, this);
|
|
323
|
+
}));
|
|
324
|
+
function componentDidMount() {
|
|
325
|
+
return _componentDidMount.apply(this, arguments);
|
|
326
|
+
}
|
|
327
|
+
return componentDidMount;
|
|
328
|
+
}()
|
|
329
|
+
}, {
|
|
330
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
331
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
332
|
+
if (this.props.viewMediaClientConfig !== nextProps.viewMediaClientConfig) {
|
|
333
|
+
this.checkVideoFile(nextProps.viewMediaClientConfig);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}, {
|
|
337
|
+
key: "wrappedLayout",
|
|
338
|
+
get: function get() {
|
|
339
|
+
return wrappedLayouts.indexOf(this.props.layout) > -1;
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "pos",
|
|
343
|
+
get: function get() {
|
|
344
|
+
if (typeof this.props.getPos !== 'function') {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
var pos = this.props.getPos();
|
|
348
|
+
if (Number.isNaN(pos) || typeof pos !== 'number') {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
return pos;
|
|
352
|
+
}
|
|
353
|
+
}, {
|
|
354
|
+
key: "$pos",
|
|
355
|
+
get: function get() {
|
|
356
|
+
var pos = this.pos;
|
|
357
|
+
// need to pass view because we may not get updated props in time
|
|
358
|
+
return pos === null ? pos : this.props.view.state.doc.resolve(pos);
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
key: "aspectRatio",
|
|
362
|
+
get: function get() {
|
|
363
|
+
var _this$props6 = this.props,
|
|
364
|
+
width = _this$props6.width,
|
|
365
|
+
height = _this$props6.height;
|
|
366
|
+
if (width) {
|
|
367
|
+
return width / height;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// TODO handle this case
|
|
371
|
+
return 1;
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "insideInlineLike",
|
|
375
|
+
get: function get() {
|
|
376
|
+
var $pos = this.$pos;
|
|
377
|
+
if (!$pos) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
var listItem = this.props.view.state.schema.nodes.listItem;
|
|
381
|
+
return !!findParentNodeOfTypeClosestToPos($pos, [listItem]);
|
|
382
|
+
}
|
|
383
|
+
}, {
|
|
384
|
+
key: "insideLayout",
|
|
385
|
+
get: function get() {
|
|
386
|
+
var $pos = this.$pos;
|
|
387
|
+
if (!$pos) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
var layoutColumn = this.props.view.state.schema.nodes.layoutColumn;
|
|
391
|
+
return !!findParentNodeOfTypeClosestToPos($pos, [layoutColumn]);
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "isGuidelineEnabled",
|
|
395
|
+
get: function get() {
|
|
396
|
+
var _this$props$pluginInj3;
|
|
397
|
+
return !!((_this$props$pluginInj3 = this.props.pluginInjectionApi) !== null && _this$props$pluginInj3 !== void 0 && _this$props$pluginInj3.guideline);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// check if is inside of layout, table, expand, nestedExpand and list item
|
|
401
|
+
}, {
|
|
402
|
+
key: "isNestedNode",
|
|
403
|
+
value: function isNestedNode() {
|
|
404
|
+
var $pos = this.$pos;
|
|
405
|
+
return !!($pos && $pos.depth !== 0);
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: "getDefaultGuidelines",
|
|
409
|
+
value: function getDefaultGuidelines() {
|
|
410
|
+
var _this$props7 = this.props,
|
|
411
|
+
lineLength = _this$props7.lineLength,
|
|
412
|
+
containerWidth = _this$props7.containerWidth,
|
|
413
|
+
fullWidthMode = _this$props7.fullWidthMode;
|
|
414
|
+
|
|
415
|
+
// disable guidelines for nested media single node
|
|
416
|
+
return this.isNestedNode() ? [] : generateDefaultGuidelines(lineLength, containerWidth, fullWidthMode);
|
|
417
|
+
}
|
|
418
|
+
}, {
|
|
419
|
+
key: "checkVideoFile",
|
|
420
|
+
value: function () {
|
|
421
|
+
var _checkVideoFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(viewMediaClientConfig) {
|
|
422
|
+
var mediaNode, mediaType, isVideoFile;
|
|
423
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
424
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
425
|
+
case 0:
|
|
426
|
+
if (!(this.pos === null || !viewMediaClientConfig)) {
|
|
427
|
+
_context2.next = 2;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
return _context2.abrupt("return");
|
|
431
|
+
case 2:
|
|
432
|
+
mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
|
|
433
|
+
if (!mediaNode) {
|
|
434
|
+
_context2.next = 9;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
_context2.next = 6;
|
|
438
|
+
return checkMediaType(mediaNode, viewMediaClientConfig);
|
|
439
|
+
case 6:
|
|
440
|
+
_context2.t0 = _context2.sent;
|
|
441
|
+
_context2.next = 10;
|
|
442
|
+
break;
|
|
443
|
+
case 9:
|
|
444
|
+
_context2.t0 = undefined;
|
|
445
|
+
case 10:
|
|
446
|
+
mediaType = _context2.t0;
|
|
447
|
+
isVideoFile = mediaType !== 'external' && mediaType !== 'image';
|
|
448
|
+
if (this.state.isVideoFile !== isVideoFile) {
|
|
449
|
+
this.setState({
|
|
450
|
+
isVideoFile: isVideoFile
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
case 13:
|
|
454
|
+
case "end":
|
|
455
|
+
return _context2.stop();
|
|
456
|
+
}
|
|
457
|
+
}, _callee2, this);
|
|
458
|
+
}));
|
|
459
|
+
function checkVideoFile(_x) {
|
|
460
|
+
return _checkVideoFile.apply(this, arguments);
|
|
461
|
+
}
|
|
462
|
+
return checkVideoFile;
|
|
463
|
+
}()
|
|
464
|
+
}, {
|
|
465
|
+
key: "render",
|
|
466
|
+
value: function render() {
|
|
467
|
+
var _this2 = this;
|
|
468
|
+
var _this$props8 = this.props,
|
|
469
|
+
origWidth = _this$props8.width,
|
|
470
|
+
layout = _this$props8.layout,
|
|
471
|
+
containerWidth = _this$props8.containerWidth,
|
|
472
|
+
fullWidthMode = _this$props8.fullWidthMode,
|
|
473
|
+
selected = _this$props8.selected,
|
|
474
|
+
children = _this$props8.children,
|
|
475
|
+
lineLength = _this$props8.lineLength,
|
|
476
|
+
showLegacyNotification = _this$props8.showLegacyNotification;
|
|
477
|
+
var _this$state = this.state,
|
|
478
|
+
isResizing = _this$state.isResizing,
|
|
479
|
+
size = _this$state.size,
|
|
480
|
+
isVideoFile = _this$state.isVideoFile;
|
|
481
|
+
var enable = {};
|
|
482
|
+
handleSides.forEach(function (side) {
|
|
483
|
+
var oppositeSide = side === 'left' ? 'right' : 'left';
|
|
484
|
+
enable[side] = nonWrappedLayouts.concat("wrap-".concat(oppositeSide)).concat("align-".concat(imageAlignmentMap[oppositeSide])).indexOf(layout) > -1;
|
|
485
|
+
if (side === 'left' && _this2.insideInlineLike) {
|
|
486
|
+
enable[side] = false;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// TODO: Clean up where this lives and how it gets generated
|
|
491
|
+
var className = classnames(richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', this.props.className, {
|
|
492
|
+
'richMedia-selected': selected,
|
|
493
|
+
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
494
|
+
});
|
|
495
|
+
// @ts-expect-error - TS2339 Lodash get() now infers types.
|
|
496
|
+
var resizerNextClassName = classnames(className, resizerStyles);
|
|
497
|
+
var isNestedNode = this.isNestedNode();
|
|
498
|
+
var maxWidth = !isResizing && isNestedNode ?
|
|
499
|
+
// set undefined to fall back to 100%
|
|
500
|
+
undefined : this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
|
|
501
|
+
var minWidth = this.calcMinWidth(isVideoFile, lineLength);
|
|
502
|
+
|
|
503
|
+
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|
|
504
|
+
var minViewWidth = isResizing ? minWidth : "min(".concat(minWidth, "px, 100%)");
|
|
505
|
+
return jsx("div", {
|
|
506
|
+
css: wrapperStyle({
|
|
507
|
+
layout: layout,
|
|
508
|
+
containerWidth: containerWidth || origWidth,
|
|
509
|
+
fullWidthMode: fullWidthMode,
|
|
510
|
+
mediaSingleWidth: this.state.size.width,
|
|
511
|
+
isNestedNode: isNestedNode,
|
|
512
|
+
isExtendedResizeExperienceOn: true
|
|
513
|
+
})
|
|
514
|
+
}, jsx(ResizerNext, {
|
|
515
|
+
minWidth: minViewWidth,
|
|
516
|
+
maxWidth: maxWidth,
|
|
517
|
+
className: resizerNextClassName,
|
|
518
|
+
snapGap: MEDIA_SINGLE_SNAP_GAP,
|
|
519
|
+
enable: enable,
|
|
520
|
+
width: size.width,
|
|
521
|
+
handleResizeStart: this.handleResizeStart,
|
|
522
|
+
handleResize: this.handleResize,
|
|
523
|
+
handleResizeStop: this.handleResizeStop,
|
|
524
|
+
snap: this.state.snaps,
|
|
525
|
+
resizeRatio: nonWrappedLayouts.includes(layout) ? 2 : 1,
|
|
526
|
+
"data-testid": resizerNextTestId,
|
|
527
|
+
isHandleVisible: selected,
|
|
528
|
+
handlePositioning: isNestedNode ? 'adjacent' : undefined,
|
|
529
|
+
handleHighlight: "full-height"
|
|
530
|
+
}, children, showLegacyNotification && jsx(ResizableMediaMigrationNotification, null)));
|
|
531
|
+
}
|
|
532
|
+
}]);
|
|
533
|
+
return ResizableMediaSingleNext;
|
|
534
|
+
}(React.Component);
|
|
535
|
+
export default ResizableMediaSingleNext;
|