@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,732 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import uuidV4 from 'uuid/v4';
|
|
7
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
9
|
+
import { getAttrsFromUrl, getMediaClient, isImageRepresentationReady, isMediaBlobUrl as _isMediaBlobUrl } from '@atlaskit/media-client';
|
|
10
|
+
import { replaceExternalMedia, updateAllMediaSingleNodesAttrs, updateCurrentMediaNodeAttrs, updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
11
|
+
export var MediaNodeUpdater = /*#__PURE__*/function () {
|
|
12
|
+
function MediaNodeUpdater(props) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
_classCallCheck(this, MediaNodeUpdater);
|
|
15
|
+
// Updates the node with contextId if it doesn't have one already
|
|
16
|
+
// TODO [MS-2258]: remove updateContextId in order to only use updateMediaSingleFileAttrs
|
|
17
|
+
_defineProperty(this, "updateContextId", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
18
|
+
var attrs, id, objectId;
|
|
19
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
attrs = _this.getAttrs();
|
|
23
|
+
if (!(!attrs || attrs.type !== 'file')) {
|
|
24
|
+
_context.next = 3;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return _context.abrupt("return");
|
|
28
|
+
case 3:
|
|
29
|
+
id = attrs.id;
|
|
30
|
+
_context.next = 6;
|
|
31
|
+
return _this.getObjectId();
|
|
32
|
+
case 6:
|
|
33
|
+
objectId = _context.sent;
|
|
34
|
+
updateAllMediaSingleNodesAttrs(id, {
|
|
35
|
+
__contextId: objectId
|
|
36
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
37
|
+
case 8:
|
|
38
|
+
case "end":
|
|
39
|
+
return _context.stop();
|
|
40
|
+
}
|
|
41
|
+
}, _callee);
|
|
42
|
+
})));
|
|
43
|
+
_defineProperty(this, "updateNodeContextId", /*#__PURE__*/function () {
|
|
44
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(getPos) {
|
|
45
|
+
var attrs, objectId;
|
|
46
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
47
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
attrs = _this.getAttrs();
|
|
50
|
+
if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
|
|
51
|
+
_context2.next = 3;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return _context2.abrupt("return");
|
|
55
|
+
case 3:
|
|
56
|
+
_context2.next = 5;
|
|
57
|
+
return _this.getObjectId();
|
|
58
|
+
case 5:
|
|
59
|
+
objectId = _context2.sent;
|
|
60
|
+
updateCurrentMediaNodeAttrs({
|
|
61
|
+
__contextId: objectId
|
|
62
|
+
}, {
|
|
63
|
+
node: _this.props.node,
|
|
64
|
+
getPos: getPos
|
|
65
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
66
|
+
case 7:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context2.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _callee2);
|
|
71
|
+
}));
|
|
72
|
+
return function (_x) {
|
|
73
|
+
return _ref2.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}());
|
|
76
|
+
_defineProperty(this, "hasFileAttributesDefined", function (attrs) {
|
|
77
|
+
return attrs && attrs.type === 'file' && attrs.__fileName && attrs.__fileMimeType && attrs.__fileSize && attrs.__contextId;
|
|
78
|
+
});
|
|
79
|
+
_defineProperty(this, "getNewFileAttrsForNode", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
80
|
+
var attrs, mediaProvider, mediaClientConfig, mediaClient, fileState, id, collectionName, contextId, _fileState, name, mimeType, size, newAttrs;
|
|
81
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
82
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
attrs = _this.getAttrs();
|
|
85
|
+
_context3.next = 3;
|
|
86
|
+
return _this.props.mediaProvider;
|
|
87
|
+
case 3:
|
|
88
|
+
mediaProvider = _context3.sent;
|
|
89
|
+
if (!(!mediaProvider || !mediaProvider.uploadParams || !attrs || attrs.type !== 'file' || _this.hasFileAttributesDefined(attrs))) {
|
|
90
|
+
_context3.next = 6;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return _context3.abrupt("return");
|
|
94
|
+
case 6:
|
|
95
|
+
mediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
96
|
+
mediaClient = getMediaClient(mediaClientConfig);
|
|
97
|
+
id = attrs.id, collectionName = attrs.collection;
|
|
98
|
+
_context3.prev = 9;
|
|
99
|
+
_context3.next = 12;
|
|
100
|
+
return mediaClient.file.getCurrentState(id, {
|
|
101
|
+
collectionName: collectionName
|
|
102
|
+
});
|
|
103
|
+
case 12:
|
|
104
|
+
fileState = _context3.sent;
|
|
105
|
+
if (!(fileState.status === 'error')) {
|
|
106
|
+
_context3.next = 15;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return _context3.abrupt("return");
|
|
110
|
+
case 15:
|
|
111
|
+
_context3.next = 20;
|
|
112
|
+
break;
|
|
113
|
+
case 17:
|
|
114
|
+
_context3.prev = 17;
|
|
115
|
+
_context3.t0 = _context3["catch"](9);
|
|
116
|
+
return _context3.abrupt("return");
|
|
117
|
+
case 20:
|
|
118
|
+
_context3.t1 = _this.getNodeContextId();
|
|
119
|
+
if (_context3.t1) {
|
|
120
|
+
_context3.next = 25;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
_context3.next = 24;
|
|
124
|
+
return _this.getObjectId();
|
|
125
|
+
case 24:
|
|
126
|
+
_context3.t1 = _context3.sent;
|
|
127
|
+
case 25:
|
|
128
|
+
contextId = _context3.t1;
|
|
129
|
+
_fileState = fileState, name = _fileState.name, mimeType = _fileState.mimeType, size = _fileState.size;
|
|
130
|
+
newAttrs = {
|
|
131
|
+
__fileName: name,
|
|
132
|
+
__fileMimeType: mimeType,
|
|
133
|
+
__fileSize: size,
|
|
134
|
+
__contextId: contextId
|
|
135
|
+
};
|
|
136
|
+
if (hasPrivateAttrsChanged(attrs, newAttrs)) {
|
|
137
|
+
_context3.next = 30;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context3.abrupt("return");
|
|
141
|
+
case 30:
|
|
142
|
+
return _context3.abrupt("return", newAttrs);
|
|
143
|
+
case 31:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context3.stop();
|
|
146
|
+
}
|
|
147
|
+
}, _callee3, null, [[9, 17]]);
|
|
148
|
+
})));
|
|
149
|
+
_defineProperty(this, "updateMediaSingleFileAttrs", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
150
|
+
var newAttrs, _ref5, id;
|
|
151
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
152
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
_context4.next = 2;
|
|
155
|
+
return _this.getNewFileAttrsForNode();
|
|
156
|
+
case 2:
|
|
157
|
+
newAttrs = _context4.sent;
|
|
158
|
+
_ref5 = _this.getAttrs(), id = _ref5.id;
|
|
159
|
+
if (id && newAttrs) {
|
|
160
|
+
updateAllMediaSingleNodesAttrs(id, newAttrs)(_this.props.view.state, _this.props.view.dispatch);
|
|
161
|
+
}
|
|
162
|
+
case 5:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context4.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee4);
|
|
167
|
+
})));
|
|
168
|
+
_defineProperty(this, "updateNodeAttrs", /*#__PURE__*/function () {
|
|
169
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(getPos) {
|
|
170
|
+
var newAttrs;
|
|
171
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
172
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
_context5.next = 2;
|
|
175
|
+
return _this.getNewFileAttrsForNode();
|
|
176
|
+
case 2:
|
|
177
|
+
newAttrs = _context5.sent;
|
|
178
|
+
if (newAttrs) {
|
|
179
|
+
updateCurrentMediaNodeAttrs(newAttrs, {
|
|
180
|
+
node: _this.props.node,
|
|
181
|
+
getPos: getPos
|
|
182
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
183
|
+
}
|
|
184
|
+
case 4:
|
|
185
|
+
case "end":
|
|
186
|
+
return _context5.stop();
|
|
187
|
+
}
|
|
188
|
+
}, _callee5);
|
|
189
|
+
}));
|
|
190
|
+
return function (_x2) {
|
|
191
|
+
return _ref6.apply(this, arguments);
|
|
192
|
+
};
|
|
193
|
+
}());
|
|
194
|
+
_defineProperty(this, "getAttrs", function () {
|
|
195
|
+
var attrs = _this.props.node.attrs;
|
|
196
|
+
if (attrs) {
|
|
197
|
+
return attrs;
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
});
|
|
201
|
+
_defineProperty(this, "getObjectId", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
202
|
+
var contextIdentifierProvider;
|
|
203
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
204
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
205
|
+
case 0:
|
|
206
|
+
_context6.next = 2;
|
|
207
|
+
return _this.props.contextIdentifierProvider;
|
|
208
|
+
case 2:
|
|
209
|
+
contextIdentifierProvider = _context6.sent;
|
|
210
|
+
return _context6.abrupt("return", (contextIdentifierProvider === null || contextIdentifierProvider === void 0 ? void 0 : contextIdentifierProvider.objectId) || null);
|
|
211
|
+
case 4:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context6.stop();
|
|
214
|
+
}
|
|
215
|
+
}, _callee6);
|
|
216
|
+
})));
|
|
217
|
+
_defineProperty(this, "uploadExternalMedia", /*#__PURE__*/function () {
|
|
218
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(getPos) {
|
|
219
|
+
var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
|
|
220
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
221
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
222
|
+
case 0:
|
|
223
|
+
node = _this.props.node;
|
|
224
|
+
_context7.next = 3;
|
|
225
|
+
return _this.props.mediaProvider;
|
|
226
|
+
case 3:
|
|
227
|
+
mediaProvider = _context7.sent;
|
|
228
|
+
if (!(node && mediaProvider)) {
|
|
229
|
+
_context7.next = 24;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
233
|
+
if (!(!uploadMediaClientConfig || !node.attrs.url)) {
|
|
234
|
+
_context7.next = 8;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
return _context7.abrupt("return");
|
|
238
|
+
case 8:
|
|
239
|
+
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
240
|
+
collection = mediaProvider.uploadParams && mediaProvider.uploadParams.collection;
|
|
241
|
+
_context7.prev = 10;
|
|
242
|
+
_context7.next = 13;
|
|
243
|
+
return mediaClient.file.uploadExternal(node.attrs.url, collection);
|
|
244
|
+
case 13:
|
|
245
|
+
uploader = _context7.sent;
|
|
246
|
+
uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
|
|
247
|
+
pos = getPos();
|
|
248
|
+
if (!(typeof pos !== 'number')) {
|
|
249
|
+
_context7.next = 18;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
return _context7.abrupt("return");
|
|
253
|
+
case 18:
|
|
254
|
+
replaceExternalMedia(pos + 1, {
|
|
255
|
+
id: uploadableFileUpfrontIds.id,
|
|
256
|
+
collection: collection,
|
|
257
|
+
height: dimensions.height,
|
|
258
|
+
width: dimensions.width,
|
|
259
|
+
occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
|
|
260
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
261
|
+
_context7.next = 24;
|
|
262
|
+
break;
|
|
263
|
+
case 21:
|
|
264
|
+
_context7.prev = 21;
|
|
265
|
+
_context7.t0 = _context7["catch"](10);
|
|
266
|
+
//keep it as external media
|
|
267
|
+
if (_this.props.dispatchAnalyticsEvent) {
|
|
268
|
+
_this.props.dispatchAnalyticsEvent({
|
|
269
|
+
action: ACTION.UPLOAD_EXTERNAL_FAIL,
|
|
270
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
271
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
case 24:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context7.stop();
|
|
277
|
+
}
|
|
278
|
+
}, _callee7, null, [[10, 21]]);
|
|
279
|
+
}));
|
|
280
|
+
return function (_x3) {
|
|
281
|
+
return _ref8.apply(this, arguments);
|
|
282
|
+
};
|
|
283
|
+
}());
|
|
284
|
+
_defineProperty(this, "getNodeContextId", function () {
|
|
285
|
+
var attrs = _this.getAttrs();
|
|
286
|
+
if (!attrs || attrs.type !== 'file') {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
return attrs.__contextId || null;
|
|
290
|
+
});
|
|
291
|
+
_defineProperty(this, "updateDimensions", function (dimensions) {
|
|
292
|
+
updateAllMediaSingleNodesAttrs(dimensions.id, {
|
|
293
|
+
height: dimensions.height,
|
|
294
|
+
width: dimensions.width
|
|
295
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
296
|
+
});
|
|
297
|
+
_defineProperty(this, "hasDifferentContextId", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
298
|
+
var nodeContextId, currentContextId;
|
|
299
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
300
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
301
|
+
case 0:
|
|
302
|
+
nodeContextId = _this.getNodeContextId();
|
|
303
|
+
_context8.next = 3;
|
|
304
|
+
return _this.getObjectId();
|
|
305
|
+
case 3:
|
|
306
|
+
currentContextId = _context8.sent;
|
|
307
|
+
if (!(nodeContextId && currentContextId && nodeContextId !== currentContextId)) {
|
|
308
|
+
_context8.next = 6;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
return _context8.abrupt("return", true);
|
|
312
|
+
case 6:
|
|
313
|
+
return _context8.abrupt("return", false);
|
|
314
|
+
case 7:
|
|
315
|
+
case "end":
|
|
316
|
+
return _context8.stop();
|
|
317
|
+
}
|
|
318
|
+
}, _callee8);
|
|
319
|
+
})));
|
|
320
|
+
_defineProperty(this, "isNodeFromDifferentCollection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
321
|
+
var mediaProvider, currentCollectionName, attrs, nodeCollection, __contextId, contextId;
|
|
322
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
323
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
324
|
+
case 0:
|
|
325
|
+
_context9.next = 2;
|
|
326
|
+
return _this.props.mediaProvider;
|
|
327
|
+
case 2:
|
|
328
|
+
mediaProvider = _context9.sent;
|
|
329
|
+
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
330
|
+
_context9.next = 5;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
return _context9.abrupt("return", false);
|
|
334
|
+
case 5:
|
|
335
|
+
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
336
|
+
attrs = _this.getAttrs();
|
|
337
|
+
if (!(!attrs || attrs.type !== 'file')) {
|
|
338
|
+
_context9.next = 9;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
return _context9.abrupt("return", false);
|
|
342
|
+
case 9:
|
|
343
|
+
nodeCollection = attrs.collection, __contextId = attrs.__contextId;
|
|
344
|
+
_context9.t0 = __contextId;
|
|
345
|
+
if (_context9.t0) {
|
|
346
|
+
_context9.next = 15;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
_context9.next = 14;
|
|
350
|
+
return _this.getObjectId();
|
|
351
|
+
case 14:
|
|
352
|
+
_context9.t0 = _context9.sent;
|
|
353
|
+
case 15:
|
|
354
|
+
contextId = _context9.t0;
|
|
355
|
+
if (!(contextId && currentCollectionName !== nodeCollection)) {
|
|
356
|
+
_context9.next = 18;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
return _context9.abrupt("return", true);
|
|
360
|
+
case 18:
|
|
361
|
+
return _context9.abrupt("return", false);
|
|
362
|
+
case 19:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context9.stop();
|
|
365
|
+
}
|
|
366
|
+
}, _callee9);
|
|
367
|
+
})));
|
|
368
|
+
_defineProperty(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
|
|
369
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(getPos) {
|
|
370
|
+
var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile, pos;
|
|
371
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
372
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
373
|
+
case 0:
|
|
374
|
+
attrs = _this.getAttrs();
|
|
375
|
+
if (!(!attrs || attrs.type !== 'external')) {
|
|
376
|
+
_context10.next = 3;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
return _context10.abrupt("return");
|
|
380
|
+
case 3:
|
|
381
|
+
url = attrs.url;
|
|
382
|
+
mediaAttrs = getAttrsFromUrl(url);
|
|
383
|
+
if (mediaAttrs) {
|
|
384
|
+
_context10.next = 7;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
return _context10.abrupt("return");
|
|
388
|
+
case 7:
|
|
389
|
+
_context10.next = 9;
|
|
390
|
+
return _this.props.mediaProvider;
|
|
391
|
+
case 9:
|
|
392
|
+
mediaProvider = _context10.sent;
|
|
393
|
+
if (!(!mediaProvider || !mediaProvider.uploadParams)) {
|
|
394
|
+
_context10.next = 12;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
return _context10.abrupt("return");
|
|
398
|
+
case 12:
|
|
399
|
+
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
400
|
+
contextId = mediaAttrs.contextId, id = mediaAttrs.id, collection = mediaAttrs.collection, height = mediaAttrs.height, width = mediaAttrs.width, mimeType = mediaAttrs.mimeType, name = mediaAttrs.name, size = mediaAttrs.size;
|
|
401
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
402
|
+
if (!(!uploadMediaClientConfig || !uploadMediaClientConfig.getAuthFromContext)) {
|
|
403
|
+
_context10.next = 17;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
return _context10.abrupt("return");
|
|
407
|
+
case 17:
|
|
408
|
+
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
409
|
+
_context10.next = 20;
|
|
410
|
+
return uploadMediaClientConfig.getAuthFromContext(contextId);
|
|
411
|
+
case 20:
|
|
412
|
+
auth = _context10.sent;
|
|
413
|
+
source = {
|
|
414
|
+
id: id,
|
|
415
|
+
collection: collection,
|
|
416
|
+
authProvider: function authProvider() {
|
|
417
|
+
return Promise.resolve(auth);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
destination = {
|
|
421
|
+
collection: currentCollectionName,
|
|
422
|
+
authProvider: uploadMediaClientConfig.authProvider,
|
|
423
|
+
occurrenceKey: uuidV4()
|
|
424
|
+
};
|
|
425
|
+
_context10.next = 25;
|
|
426
|
+
return mediaClient.file.copyFile(source, destination);
|
|
427
|
+
case 25:
|
|
428
|
+
mediaFile = _context10.sent;
|
|
429
|
+
pos = getPos();
|
|
430
|
+
if (!(typeof pos !== 'number')) {
|
|
431
|
+
_context10.next = 29;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
return _context10.abrupt("return");
|
|
435
|
+
case 29:
|
|
436
|
+
replaceExternalMedia(pos + 1, {
|
|
437
|
+
id: mediaFile.id,
|
|
438
|
+
collection: currentCollectionName,
|
|
439
|
+
height: height,
|
|
440
|
+
width: width,
|
|
441
|
+
__fileName: name,
|
|
442
|
+
__fileMimeType: mimeType,
|
|
443
|
+
__fileSize: size
|
|
444
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
445
|
+
case 30:
|
|
446
|
+
case "end":
|
|
447
|
+
return _context10.stop();
|
|
448
|
+
}
|
|
449
|
+
}, _callee10);
|
|
450
|
+
}));
|
|
451
|
+
return function (_x4) {
|
|
452
|
+
return _ref11.apply(this, arguments);
|
|
453
|
+
};
|
|
454
|
+
}());
|
|
455
|
+
// Copies the pasted node into the current collection using a getPos handler
|
|
456
|
+
_defineProperty(this, "copyNodeFromPos", /*#__PURE__*/function () {
|
|
457
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(getPos, traceContext) {
|
|
458
|
+
var attrs, copiedAttrs;
|
|
459
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
460
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
attrs = _this.getAttrs();
|
|
463
|
+
if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
|
|
464
|
+
_context11.next = 3;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
return _context11.abrupt("return");
|
|
468
|
+
case 3:
|
|
469
|
+
_context11.next = 5;
|
|
470
|
+
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
471
|
+
case 5:
|
|
472
|
+
copiedAttrs = _context11.sent;
|
|
473
|
+
if (copiedAttrs) {
|
|
474
|
+
_context11.next = 8;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
return _context11.abrupt("return");
|
|
478
|
+
case 8:
|
|
479
|
+
updateCurrentMediaNodeAttrs(copiedAttrs, {
|
|
480
|
+
node: _this.props.node,
|
|
481
|
+
getPos: getPos
|
|
482
|
+
})(_this.props.view.state, _this.props.view.dispatch);
|
|
483
|
+
case 9:
|
|
484
|
+
case "end":
|
|
485
|
+
return _context11.stop();
|
|
486
|
+
}
|
|
487
|
+
}, _callee11);
|
|
488
|
+
}));
|
|
489
|
+
return function (_x5, _x6) {
|
|
490
|
+
return _ref12.apply(this, arguments);
|
|
491
|
+
};
|
|
492
|
+
}());
|
|
493
|
+
// Copies the pasted node into the current collection
|
|
494
|
+
_defineProperty(this, "copyNode", /*#__PURE__*/function () {
|
|
495
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(traceContext) {
|
|
496
|
+
var attrs, view, copiedAttrs;
|
|
497
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
498
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
499
|
+
case 0:
|
|
500
|
+
attrs = _this.getAttrs();
|
|
501
|
+
view = _this.props.view;
|
|
502
|
+
if (!((attrs === null || attrs === void 0 ? void 0 : attrs.type) !== 'file')) {
|
|
503
|
+
_context12.next = 4;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
return _context12.abrupt("return");
|
|
507
|
+
case 4:
|
|
508
|
+
_context12.next = 6;
|
|
509
|
+
return _this.copyFile(attrs.id, attrs.collection, traceContext);
|
|
510
|
+
case 6:
|
|
511
|
+
copiedAttrs = _context12.sent;
|
|
512
|
+
if (copiedAttrs) {
|
|
513
|
+
_context12.next = 9;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
return _context12.abrupt("return");
|
|
517
|
+
case 9:
|
|
518
|
+
updateMediaSingleNodeAttrs(attrs.id, copiedAttrs)(view.state, view.dispatch);
|
|
519
|
+
case 10:
|
|
520
|
+
case "end":
|
|
521
|
+
return _context12.stop();
|
|
522
|
+
}
|
|
523
|
+
}, _callee12);
|
|
524
|
+
}));
|
|
525
|
+
return function (_x7) {
|
|
526
|
+
return _ref13.apply(this, arguments);
|
|
527
|
+
};
|
|
528
|
+
}());
|
|
529
|
+
_defineProperty(this, "copyFile", /*#__PURE__*/function () {
|
|
530
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, collection, traceContext) {
|
|
531
|
+
var mediaProvider, nodeContextId, uploadMediaClientConfig, mediaClient, auth, objectId, source, currentCollectionName, destination, mediaFile;
|
|
532
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
533
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
534
|
+
case 0:
|
|
535
|
+
_context13.next = 2;
|
|
536
|
+
return _this.props.mediaProvider;
|
|
537
|
+
case 2:
|
|
538
|
+
mediaProvider = _context13.sent;
|
|
539
|
+
if (mediaProvider !== null && mediaProvider !== void 0 && mediaProvider.uploadParams) {
|
|
540
|
+
_context13.next = 5;
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
return _context13.abrupt("return");
|
|
544
|
+
case 5:
|
|
545
|
+
nodeContextId = _this.getNodeContextId();
|
|
546
|
+
uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
|
|
547
|
+
if (!(!(uploadMediaClientConfig !== null && uploadMediaClientConfig !== void 0 && uploadMediaClientConfig.getAuthFromContext) || !nodeContextId)) {
|
|
548
|
+
_context13.next = 9;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
return _context13.abrupt("return");
|
|
552
|
+
case 9:
|
|
553
|
+
mediaClient = getMediaClient(uploadMediaClientConfig);
|
|
554
|
+
_context13.next = 12;
|
|
555
|
+
return uploadMediaClientConfig.getAuthFromContext(nodeContextId);
|
|
556
|
+
case 12:
|
|
557
|
+
auth = _context13.sent;
|
|
558
|
+
_context13.next = 15;
|
|
559
|
+
return _this.getObjectId();
|
|
560
|
+
case 15:
|
|
561
|
+
objectId = _context13.sent;
|
|
562
|
+
source = {
|
|
563
|
+
id: id,
|
|
564
|
+
collection: collection,
|
|
565
|
+
authProvider: function authProvider() {
|
|
566
|
+
return Promise.resolve(auth);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
currentCollectionName = mediaProvider.uploadParams.collection;
|
|
570
|
+
destination = {
|
|
571
|
+
collection: currentCollectionName,
|
|
572
|
+
authProvider: uploadMediaClientConfig.authProvider,
|
|
573
|
+
occurrenceKey: uuidV4()
|
|
574
|
+
};
|
|
575
|
+
_context13.next = 21;
|
|
576
|
+
return mediaClient.file.copyFile(source, destination, undefined, traceContext);
|
|
577
|
+
case 21:
|
|
578
|
+
mediaFile = _context13.sent;
|
|
579
|
+
return _context13.abrupt("return", {
|
|
580
|
+
id: mediaFile.id,
|
|
581
|
+
collection: currentCollectionName,
|
|
582
|
+
__contextId: objectId
|
|
583
|
+
});
|
|
584
|
+
case 23:
|
|
585
|
+
case "end":
|
|
586
|
+
return _context13.stop();
|
|
587
|
+
}
|
|
588
|
+
}, _callee13);
|
|
589
|
+
}));
|
|
590
|
+
return function (_x8, _x9, _x10) {
|
|
591
|
+
return _ref14.apply(this, arguments);
|
|
592
|
+
};
|
|
593
|
+
}());
|
|
594
|
+
this.props = props;
|
|
595
|
+
}
|
|
596
|
+
_createClass(MediaNodeUpdater, [{
|
|
597
|
+
key: "isMediaBlobUrl",
|
|
598
|
+
value: function isMediaBlobUrl() {
|
|
599
|
+
var attrs = this.getAttrs();
|
|
600
|
+
return !!(attrs && attrs.type === 'external' && _isMediaBlobUrl(attrs.url));
|
|
601
|
+
}
|
|
602
|
+
}, {
|
|
603
|
+
key: "getRemoteDimensions",
|
|
604
|
+
value: function () {
|
|
605
|
+
var _getRemoteDimensions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
606
|
+
var mediaProvider, mediaOptions, attrs, height, width, id, collection, viewMediaClientConfig, mediaClient, currentState, imageMetadata;
|
|
607
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
608
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
609
|
+
case 0:
|
|
610
|
+
_context14.next = 2;
|
|
611
|
+
return this.props.mediaProvider;
|
|
612
|
+
case 2:
|
|
613
|
+
mediaProvider = _context14.sent;
|
|
614
|
+
mediaOptions = this.props.mediaOptions;
|
|
615
|
+
attrs = this.getAttrs();
|
|
616
|
+
if (!(!mediaProvider || !attrs)) {
|
|
617
|
+
_context14.next = 7;
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
return _context14.abrupt("return", false);
|
|
621
|
+
case 7:
|
|
622
|
+
height = attrs.height, width = attrs.width;
|
|
623
|
+
if (!(attrs.type === 'external' || !attrs.id)) {
|
|
624
|
+
_context14.next = 10;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
return _context14.abrupt("return", false);
|
|
628
|
+
case 10:
|
|
629
|
+
id = attrs.id, collection = attrs.collection;
|
|
630
|
+
if (!(height && width)) {
|
|
631
|
+
_context14.next = 13;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
return _context14.abrupt("return", false);
|
|
635
|
+
case 13:
|
|
636
|
+
if (!(mediaOptions && !mediaOptions.allowRemoteDimensionsFetch)) {
|
|
637
|
+
_context14.next = 15;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
return _context14.abrupt("return", {
|
|
641
|
+
id: id,
|
|
642
|
+
height: DEFAULT_IMAGE_HEIGHT,
|
|
643
|
+
width: DEFAULT_IMAGE_WIDTH
|
|
644
|
+
});
|
|
645
|
+
case 15:
|
|
646
|
+
viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
647
|
+
mediaClient = getMediaClient(viewMediaClientConfig);
|
|
648
|
+
_context14.next = 19;
|
|
649
|
+
return mediaClient.file.getCurrentState(id, {
|
|
650
|
+
collectionName: collection
|
|
651
|
+
});
|
|
652
|
+
case 19:
|
|
653
|
+
currentState = _context14.sent;
|
|
654
|
+
if (isImageRepresentationReady(currentState)) {
|
|
655
|
+
_context14.next = 22;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
return _context14.abrupt("return", false);
|
|
659
|
+
case 22:
|
|
660
|
+
_context14.next = 24;
|
|
661
|
+
return mediaClient.getImageMetadata(id, {
|
|
662
|
+
collection: collection
|
|
663
|
+
});
|
|
664
|
+
case 24:
|
|
665
|
+
imageMetadata = _context14.sent;
|
|
666
|
+
if (!(!imageMetadata || !imageMetadata.original)) {
|
|
667
|
+
_context14.next = 27;
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
return _context14.abrupt("return", false);
|
|
671
|
+
case 27:
|
|
672
|
+
return _context14.abrupt("return", {
|
|
673
|
+
id: id,
|
|
674
|
+
height: imageMetadata.original.height || DEFAULT_IMAGE_HEIGHT,
|
|
675
|
+
width: imageMetadata.original.width || DEFAULT_IMAGE_WIDTH
|
|
676
|
+
});
|
|
677
|
+
case 28:
|
|
678
|
+
case "end":
|
|
679
|
+
return _context14.stop();
|
|
680
|
+
}
|
|
681
|
+
}, _callee14, this);
|
|
682
|
+
}));
|
|
683
|
+
function getRemoteDimensions() {
|
|
684
|
+
return _getRemoteDimensions.apply(this, arguments);
|
|
685
|
+
}
|
|
686
|
+
return getRemoteDimensions;
|
|
687
|
+
}()
|
|
688
|
+
}, {
|
|
689
|
+
key: "handleExternalMedia",
|
|
690
|
+
value: function () {
|
|
691
|
+
var _handleExternalMedia = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(getPos) {
|
|
692
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
693
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
694
|
+
case 0:
|
|
695
|
+
if (!this.isMediaBlobUrl()) {
|
|
696
|
+
_context15.next = 12;
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
699
|
+
_context15.prev = 1;
|
|
700
|
+
_context15.next = 4;
|
|
701
|
+
return this.copyNodeFromBlobUrl(getPos);
|
|
702
|
+
case 4:
|
|
703
|
+
_context15.next = 10;
|
|
704
|
+
break;
|
|
705
|
+
case 6:
|
|
706
|
+
_context15.prev = 6;
|
|
707
|
+
_context15.t0 = _context15["catch"](1);
|
|
708
|
+
_context15.next = 10;
|
|
709
|
+
return this.uploadExternalMedia(getPos);
|
|
710
|
+
case 10:
|
|
711
|
+
_context15.next = 14;
|
|
712
|
+
break;
|
|
713
|
+
case 12:
|
|
714
|
+
_context15.next = 14;
|
|
715
|
+
return this.uploadExternalMedia(getPos);
|
|
716
|
+
case 14:
|
|
717
|
+
case "end":
|
|
718
|
+
return _context15.stop();
|
|
719
|
+
}
|
|
720
|
+
}, _callee15, this, [[1, 6]]);
|
|
721
|
+
}));
|
|
722
|
+
function handleExternalMedia(_x11) {
|
|
723
|
+
return _handleExternalMedia.apply(this, arguments);
|
|
724
|
+
}
|
|
725
|
+
return handleExternalMedia;
|
|
726
|
+
}()
|
|
727
|
+
}]);
|
|
728
|
+
return MediaNodeUpdater;
|
|
729
|
+
}();
|
|
730
|
+
var hasPrivateAttrsChanged = function hasPrivateAttrsChanged(currentAttrs, newAttrs) {
|
|
731
|
+
return currentAttrs.__fileName !== newAttrs.__fileName || currentAttrs.__fileMimeType !== newAttrs.__fileMimeType || currentAttrs.__fileSize !== newAttrs.__fileSize || currentAttrs.__contextId !== newAttrs.__contextId;
|
|
732
|
+
};
|