@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,314 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
|
+
import { isNodeSelectedOrInRange, SelectedState, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
|
|
9
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
10
|
+
import { Filmstrip } from '@atlaskit/media-filmstrip';
|
|
11
|
+
import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
|
|
12
|
+
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
13
|
+
import { messages } from './messages';
|
|
14
|
+
const isMediaGroupSelectedFromProps = props => {
|
|
15
|
+
/**
|
|
16
|
+
* ED-19831
|
|
17
|
+
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
18
|
+
* directly to confluence since this bug is now in production.
|
|
19
|
+
*/
|
|
20
|
+
let pos;
|
|
21
|
+
try {
|
|
22
|
+
pos = props.getPos ? props.getPos() : undefined;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
pos = undefined;
|
|
25
|
+
}
|
|
26
|
+
if (typeof pos !== 'number') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return isNodeSelectedOrInRange(props.anchorPos, props.headPos, pos, props.node.nodeSize);
|
|
30
|
+
};
|
|
31
|
+
const hasSelectionChanged = (oldProps, newProps) => {
|
|
32
|
+
if (isMediaGroupSelectedFromProps(oldProps) !== isMediaGroupSelectedFromProps(newProps)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (isMediaGroupSelectedFromProps(newProps) === SelectedState.selectedInside) {
|
|
36
|
+
return oldProps.anchorPos !== newProps.anchorPos;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
42
|
+
class MediaGroup extends React.Component {
|
|
43
|
+
constructor(_props) {
|
|
44
|
+
super(_props);
|
|
45
|
+
_defineProperty(this, "state", {
|
|
46
|
+
viewMediaClientConfig: undefined
|
|
47
|
+
});
|
|
48
|
+
_defineProperty(this, "updateNodeAttrs", (props, node, getPos) => {
|
|
49
|
+
const {
|
|
50
|
+
view,
|
|
51
|
+
mediaProvider,
|
|
52
|
+
contextIdentifierProvider
|
|
53
|
+
} = props;
|
|
54
|
+
const mediaNodeUpdater = new MediaNodeUpdater({
|
|
55
|
+
view,
|
|
56
|
+
mediaProvider,
|
|
57
|
+
contextIdentifierProvider,
|
|
58
|
+
node,
|
|
59
|
+
isMediaSingle: false
|
|
60
|
+
});
|
|
61
|
+
mediaNodeUpdater.updateNodeAttrs(getPos);
|
|
62
|
+
});
|
|
63
|
+
_defineProperty(this, "setMediaItems", (props, updatedAttrs = false) => {
|
|
64
|
+
var _this$mediaPluginStat;
|
|
65
|
+
const {
|
|
66
|
+
node
|
|
67
|
+
} = props;
|
|
68
|
+
const oldMediaNodes = this.mediaNodes;
|
|
69
|
+
this.mediaNodes = [];
|
|
70
|
+
node.forEach((item, childOffset) => {
|
|
71
|
+
const getPos = () => {
|
|
72
|
+
const pos = props.getPos();
|
|
73
|
+
if (typeof pos !== 'number') {
|
|
74
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
75
|
+
// Because the original code would return NaN on runtime
|
|
76
|
+
// We are just make it explict now.
|
|
77
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
78
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
79
|
+
return NaN;
|
|
80
|
+
}
|
|
81
|
+
return pos + childOffset + 1;
|
|
82
|
+
};
|
|
83
|
+
this.mediaNodes.push(item);
|
|
84
|
+
if (updatedAttrs) {
|
|
85
|
+
this.updateNodeAttrs(props, item, getPos);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
(_this$mediaPluginStat = this.mediaPluginState) === null || _this$mediaPluginStat === void 0 ? void 0 : _this$mediaPluginStat.handleMediaGroupUpdate(oldMediaNodes, this.mediaNodes);
|
|
89
|
+
});
|
|
90
|
+
_defineProperty(this, "getIdentifier", item => {
|
|
91
|
+
if (item.attrs.type === 'external') {
|
|
92
|
+
return {
|
|
93
|
+
mediaItemType: 'external-image',
|
|
94
|
+
dataURI: item.attrs.url
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
id: item.attrs.id,
|
|
99
|
+
mediaItemType: 'file',
|
|
100
|
+
collectionName: item.attrs.collection
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(this, "isNodeSelected", nodePos => {
|
|
104
|
+
const selected = isMediaGroupSelectedFromProps(this.props);
|
|
105
|
+
if (selected === SelectedState.selectedInRange) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
if (selected === SelectedState.selectedInside && this.props.anchorPos === nodePos) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
});
|
|
113
|
+
_defineProperty(this, "renderChildNodes", () => {
|
|
114
|
+
const {
|
|
115
|
+
viewMediaClientConfig
|
|
116
|
+
} = this.state;
|
|
117
|
+
const {
|
|
118
|
+
getPos,
|
|
119
|
+
allowLazyLoading,
|
|
120
|
+
disabled,
|
|
121
|
+
mediaOptions
|
|
122
|
+
} = this.props;
|
|
123
|
+
const items = this.mediaNodes.map((item, idx) => {
|
|
124
|
+
// We declared this to get a fresh position every time
|
|
125
|
+
const getNodePos = () => {
|
|
126
|
+
const pos = getPos();
|
|
127
|
+
if (typeof pos !== 'number') {
|
|
128
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
129
|
+
// Because the original code would return NaN on runtime
|
|
130
|
+
// We are just make it explict now.
|
|
131
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
132
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
133
|
+
return NaN;
|
|
134
|
+
}
|
|
135
|
+
return pos + idx + 1;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Media Inline creates a floating toolbar with the same options, excludes these options if enabled
|
|
139
|
+
const mediaInlineOptions = (allowMediaInline = false) => {
|
|
140
|
+
if (!allowMediaInline) {
|
|
141
|
+
return {
|
|
142
|
+
shouldEnableDownloadButton: mediaOptions.enableDownloadButton,
|
|
143
|
+
actions: [{
|
|
144
|
+
handler: disabled || !this.mediaPluginState ? () => {} : this.mediaPluginState.handleMediaNodeRemoval.bind(null, undefined, getNodePos),
|
|
145
|
+
icon: /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
146
|
+
label: this.props.intl.formatMessage(messages.mediaGroupDeleteLabel)
|
|
147
|
+
})
|
|
148
|
+
}]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
identifier: this.getIdentifier(item),
|
|
154
|
+
isLazy: allowLazyLoading,
|
|
155
|
+
selected: this.isNodeSelected(getNodePos()),
|
|
156
|
+
onClick: () => {
|
|
157
|
+
setNodeSelection(this.props.view, getNodePos());
|
|
158
|
+
},
|
|
159
|
+
...mediaInlineOptions(getMediaFeatureFlag('mediaInline', mediaOptions.featureFlags))
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
return /*#__PURE__*/React.createElement(Filmstrip, {
|
|
163
|
+
items: items,
|
|
164
|
+
mediaClientConfig: viewMediaClientConfig,
|
|
165
|
+
featureFlags: mediaOptions.featureFlags
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
this.mediaNodes = [];
|
|
169
|
+
this.mediaPluginState = mediaStateKey.getState(_props.view.state);
|
|
170
|
+
this.setMediaItems(_props);
|
|
171
|
+
this.state = {
|
|
172
|
+
viewMediaClientConfig: undefined
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
componentDidMount() {
|
|
176
|
+
this.updateMediaClientConfig();
|
|
177
|
+
this.mediaNodes.forEach(async node => {
|
|
178
|
+
if (node.attrs.type === 'external') {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const {
|
|
182
|
+
view,
|
|
183
|
+
mediaProvider,
|
|
184
|
+
contextIdentifierProvider
|
|
185
|
+
} = this.props;
|
|
186
|
+
const mediaNodeUpdater = new MediaNodeUpdater({
|
|
187
|
+
view,
|
|
188
|
+
mediaProvider,
|
|
189
|
+
contextIdentifierProvider,
|
|
190
|
+
node,
|
|
191
|
+
isMediaSingle: false
|
|
192
|
+
});
|
|
193
|
+
const getPos = () => {
|
|
194
|
+
const pos = this.props.getPos();
|
|
195
|
+
if (typeof pos !== 'number') {
|
|
196
|
+
// That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
|
|
197
|
+
// Because the original code would return NaN on runtime
|
|
198
|
+
// We are just make it explict now.
|
|
199
|
+
// We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
|
|
200
|
+
// TODO: ED-13910 prosemirror-bump leftovers
|
|
201
|
+
return NaN;
|
|
202
|
+
}
|
|
203
|
+
return pos + 1;
|
|
204
|
+
};
|
|
205
|
+
const contextId = mediaNodeUpdater.getNodeContextId();
|
|
206
|
+
if (!contextId) {
|
|
207
|
+
await mediaNodeUpdater.updateNodeContextId(getPos);
|
|
208
|
+
}
|
|
209
|
+
const hasDifferentContextId = await mediaNodeUpdater.hasDifferentContextId();
|
|
210
|
+
if (hasDifferentContextId) {
|
|
211
|
+
await mediaNodeUpdater.copyNodeFromPos(getPos, {
|
|
212
|
+
traceId: node.attrs.__mediaTraceId
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
componentWillUnmount() {
|
|
218
|
+
var _this$mediaPluginStat2;
|
|
219
|
+
(_this$mediaPluginStat2 = this.mediaPluginState) === null || _this$mediaPluginStat2 === void 0 ? void 0 : _this$mediaPluginStat2.handleMediaGroupUpdate(this.mediaNodes, []);
|
|
220
|
+
}
|
|
221
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
222
|
+
this.updateMediaClientConfig();
|
|
223
|
+
this.setMediaItems(props, props.isCopyPasteEnabled || props.isCopyPasteEnabled === undefined);
|
|
224
|
+
}
|
|
225
|
+
shouldComponentUpdate(nextProps) {
|
|
226
|
+
var _this$mediaPluginStat3;
|
|
227
|
+
if (hasSelectionChanged(this.props, nextProps) || this.props.node !== nextProps.node || this.state.viewMediaClientConfig !== ((_this$mediaPluginStat3 = this.mediaPluginState) === null || _this$mediaPluginStat3 === void 0 ? void 0 : _this$mediaPluginStat3.mediaClientConfig)) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
updateMediaClientConfig() {
|
|
233
|
+
const {
|
|
234
|
+
viewMediaClientConfig
|
|
235
|
+
} = this.state;
|
|
236
|
+
const {
|
|
237
|
+
mediaClientConfig
|
|
238
|
+
} = this.mediaPluginState || {};
|
|
239
|
+
if (!viewMediaClientConfig && mediaClientConfig) {
|
|
240
|
+
this.setState({
|
|
241
|
+
viewMediaClientConfig: mediaClientConfig
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
render() {
|
|
246
|
+
return this.renderChildNodes();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
_defineProperty(MediaGroup, "displayName", 'MediaGroup');
|
|
250
|
+
const IntlMediaGroup = injectIntl(MediaGroup);
|
|
251
|
+
export default IntlMediaGroup;
|
|
252
|
+
function MediaGroupNodeViewInternal({
|
|
253
|
+
renderFn,
|
|
254
|
+
pluginInjectionApi
|
|
255
|
+
}) {
|
|
256
|
+
const {
|
|
257
|
+
editorDisabledState: editorDisabledPlugin
|
|
258
|
+
} = useSharedPluginState(pluginInjectionApi, ['editorDisabled']);
|
|
259
|
+
return renderFn({
|
|
260
|
+
editorDisabledPlugin
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
class MediaGroupNodeView extends ReactNodeView {
|
|
264
|
+
render(props, forwardRef) {
|
|
265
|
+
const {
|
|
266
|
+
providerFactory,
|
|
267
|
+
mediaOptions,
|
|
268
|
+
pluginInjectionApi
|
|
269
|
+
} = props;
|
|
270
|
+
const getPos = this.getPos;
|
|
271
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
272
|
+
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
273
|
+
providerFactory: providerFactory,
|
|
274
|
+
renderNode: ({
|
|
275
|
+
mediaProvider,
|
|
276
|
+
contextIdentifierProvider
|
|
277
|
+
}) => {
|
|
278
|
+
const renderFn = ({
|
|
279
|
+
editorDisabledPlugin
|
|
280
|
+
}) => {
|
|
281
|
+
if (!mediaProvider) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
return /*#__PURE__*/React.createElement(IntlMediaGroup, {
|
|
285
|
+
node: this.node,
|
|
286
|
+
getPos: getPos,
|
|
287
|
+
view: this.view,
|
|
288
|
+
forwardRef: forwardRef,
|
|
289
|
+
disabled: (editorDisabledPlugin || {}).editorDisabled,
|
|
290
|
+
allowLazyLoading: mediaOptions.allowLazyLoading,
|
|
291
|
+
mediaProvider: mediaProvider,
|
|
292
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
293
|
+
isCopyPasteEnabled: mediaOptions.isCopyPasteEnabled,
|
|
294
|
+
anchorPos: this.view.state.selection.$anchor.pos,
|
|
295
|
+
headPos: this.view.state.selection.$head.pos,
|
|
296
|
+
mediaOptions: mediaOptions
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
return /*#__PURE__*/React.createElement(MediaGroupNodeViewInternal, {
|
|
300
|
+
renderFn: renderFn,
|
|
301
|
+
pluginInjectionApi: pluginInjectionApi
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
export const ReactMediaGroupNode = (portalProviderAPI, eventDispatcher, providerFactory, mediaOptions = {}, pluginInjectionApi) => (node, view, getPos) => {
|
|
308
|
+
const hasIntlContext = true;
|
|
309
|
+
return new MediaGroupNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
310
|
+
providerFactory,
|
|
311
|
+
mediaOptions,
|
|
312
|
+
pluginInjectionApi
|
|
313
|
+
}, undefined, undefined, undefined, hasIntlContext).init();
|
|
314
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
5
|
+
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
6
|
+
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
7
|
+
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
8
|
+
import { MediaInlineNodeSelector } from './styles';
|
|
9
|
+
export const createMediaNodeUpdater = props => {
|
|
10
|
+
const node = props.node;
|
|
11
|
+
return new MediaNodeUpdater({
|
|
12
|
+
...props,
|
|
13
|
+
isMediaSingle: true,
|
|
14
|
+
node: node ? node : props.node,
|
|
15
|
+
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
16
|
+
contextIdentifierProvider: props.contextIdentifierProvider
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Handles updating the media inline node attributes
|
|
22
|
+
* but also handling copy-paste for cross-editor of the same instance
|
|
23
|
+
* using the contextid
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export const updateMediaNodeAttributes = async (props, mediaNodeUpdater) => {
|
|
27
|
+
const {
|
|
28
|
+
addPendingTask
|
|
29
|
+
} = props.mediaPluginState;
|
|
30
|
+
const node = props.node;
|
|
31
|
+
if (!node) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const contextId = mediaNodeUpdater.getNodeContextId();
|
|
35
|
+
if (!contextId) {
|
|
36
|
+
await mediaNodeUpdater.updateContextId();
|
|
37
|
+
}
|
|
38
|
+
const hasDifferentContextId = await mediaNodeUpdater.hasDifferentContextId();
|
|
39
|
+
if (hasDifferentContextId) {
|
|
40
|
+
// Copy paste flow (different pages)
|
|
41
|
+
try {
|
|
42
|
+
const copyNode = mediaNodeUpdater.copyNode({
|
|
43
|
+
traceId: node.attrs.__mediaTraceId
|
|
44
|
+
});
|
|
45
|
+
addPendingTask(copyNode);
|
|
46
|
+
await copyNode;
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
await mediaNodeUpdater.updateMediaSingleFileAttrs();
|
|
52
|
+
};
|
|
53
|
+
export const handleNewNode = props => {
|
|
54
|
+
const {
|
|
55
|
+
node,
|
|
56
|
+
mediaPluginState,
|
|
57
|
+
getPos
|
|
58
|
+
} = props;
|
|
59
|
+
mediaPluginState.handleMediaNodeMount(node, () => getPos());
|
|
60
|
+
};
|
|
61
|
+
export const MediaInline = props => {
|
|
62
|
+
const [viewMediaClientConfig, setViewMediaClientConfig] = useState();
|
|
63
|
+
const [isContextIdUnsync, setIsContextIdUnsync] = useState(true);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const mediaNodeUpdater = createMediaNodeUpdater(props);
|
|
66
|
+
mediaNodeUpdater.hasDifferentContextId().then(setIsContextIdUnsync);
|
|
67
|
+
handleNewNode(props);
|
|
68
|
+
updateMediaNodeAttributes(props, mediaNodeUpdater);
|
|
69
|
+
updateViewMediaClientConfig(props);
|
|
70
|
+
return () => {
|
|
71
|
+
const {
|
|
72
|
+
mediaPluginState
|
|
73
|
+
} = props;
|
|
74
|
+
mediaPluginState.handleMediaNodeUnmount(props.node);
|
|
75
|
+
};
|
|
76
|
+
}, [props]);
|
|
77
|
+
const updateViewMediaClientConfig = async props => {
|
|
78
|
+
const mediaProvider = await props.mediaProvider;
|
|
79
|
+
if (mediaProvider) {
|
|
80
|
+
const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
81
|
+
setViewMediaClientConfig(viewMediaClientConfig);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const {
|
|
85
|
+
id,
|
|
86
|
+
collection
|
|
87
|
+
} = props.node.attrs;
|
|
88
|
+
const identifier = {
|
|
89
|
+
id,
|
|
90
|
+
mediaItemType: 'file',
|
|
91
|
+
collectionName: collection
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* Show the loading view if
|
|
96
|
+
* 1. The media provider is not ready
|
|
97
|
+
* 2. Context Id is not synced
|
|
98
|
+
* to prevent calling the media API (in mounting of `MediaInlineCard`)
|
|
99
|
+
* before the prerequisites meet
|
|
100
|
+
*/
|
|
101
|
+
if (!viewMediaClientConfig || isContextIdUnsync) {
|
|
102
|
+
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
103
|
+
message: "",
|
|
104
|
+
isSelected: false
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React.createElement(MediaInlineCard, {
|
|
108
|
+
isSelected: props.isSelected,
|
|
109
|
+
identifier: identifier,
|
|
110
|
+
mediaClientConfig: viewMediaClientConfig
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const MediaInlineSharedState = ({
|
|
114
|
+
identifier,
|
|
115
|
+
mediaProvider,
|
|
116
|
+
node,
|
|
117
|
+
isSelected,
|
|
118
|
+
getPos,
|
|
119
|
+
contextIdentifierProvider,
|
|
120
|
+
api,
|
|
121
|
+
view
|
|
122
|
+
}) => {
|
|
123
|
+
const {
|
|
124
|
+
mediaState
|
|
125
|
+
} = useSharedPluginState(api, ['media']);
|
|
126
|
+
if (!mediaState) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return /*#__PURE__*/React.createElement(MediaInline, {
|
|
130
|
+
identifier: identifier,
|
|
131
|
+
mediaProvider: mediaProvider,
|
|
132
|
+
mediaPluginState: mediaState,
|
|
133
|
+
node: node,
|
|
134
|
+
isSelected: isSelected,
|
|
135
|
+
view: view,
|
|
136
|
+
getPos: getPos,
|
|
137
|
+
contextIdentifierProvider: contextIdentifierProvider
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
export class MediaInlineNodeView extends SelectionBasedNodeView {
|
|
141
|
+
createDomRef() {
|
|
142
|
+
const domRef = document.createElement('span');
|
|
143
|
+
domRef.contentEditable = 'false';
|
|
144
|
+
return domRef;
|
|
145
|
+
}
|
|
146
|
+
getContentDOM() {
|
|
147
|
+
const dom = document.createElement('span');
|
|
148
|
+
dom.classList.add(MediaInlineNodeSelector);
|
|
149
|
+
return {
|
|
150
|
+
dom
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
ignoreMutation() {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
viewShouldUpdate(nextNode) {
|
|
157
|
+
if (this.node.attrs !== nextNode.attrs) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return super.viewShouldUpdate(nextNode);
|
|
161
|
+
}
|
|
162
|
+
render(props) {
|
|
163
|
+
const {
|
|
164
|
+
providerFactory,
|
|
165
|
+
api
|
|
166
|
+
} = props;
|
|
167
|
+
const {
|
|
168
|
+
view
|
|
169
|
+
} = this;
|
|
170
|
+
const getPos = this.getPos;
|
|
171
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
172
|
+
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
173
|
+
providerFactory: providerFactory,
|
|
174
|
+
renderNode: ({
|
|
175
|
+
mediaProvider,
|
|
176
|
+
contextIdentifierProvider
|
|
177
|
+
}) => {
|
|
178
|
+
if (!mediaProvider) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return /*#__PURE__*/React.createElement(MediaInlineSharedState, {
|
|
182
|
+
identifier: this.node.attrs.id,
|
|
183
|
+
mediaProvider: mediaProvider,
|
|
184
|
+
node: this.node,
|
|
185
|
+
isSelected: this.nodeInsideSelection(),
|
|
186
|
+
view: view,
|
|
187
|
+
getPos: getPos,
|
|
188
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
189
|
+
api: api
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export const ReactMediaInlineNode = (portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) => (node, view, getPos) => {
|
|
196
|
+
return new MediaInlineNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
197
|
+
providerFactory,
|
|
198
|
+
dispatchAnalyticsEvent,
|
|
199
|
+
api
|
|
200
|
+
}).init();
|
|
201
|
+
};
|