@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,182 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
4
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
|
+
import { setNodeSelection, setTextSelection, withImageLoader } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
|
+
import { Card, CardLoading } from '@atlaskit/media-card';
|
|
8
|
+
import { stateKey as mediaStateKey } from '../../pm-plugins/plugin-key';
|
|
9
|
+
import { MediaCardWrapper } from '../styles';
|
|
10
|
+
|
|
11
|
+
// This is being used by DropPlaceholder now
|
|
12
|
+
export const MEDIA_HEIGHT = 125;
|
|
13
|
+
export const FILE_WIDTH = 156;
|
|
14
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
15
|
+
export class MediaNode extends Component {
|
|
16
|
+
constructor(_props) {
|
|
17
|
+
super(_props);
|
|
18
|
+
_defineProperty(this, "state", {});
|
|
19
|
+
_defineProperty(this, "setViewMediaClientConfig", async () => {
|
|
20
|
+
const mediaProvider = await this.props.mediaProvider;
|
|
21
|
+
if (mediaProvider) {
|
|
22
|
+
const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
23
|
+
this.setState({
|
|
24
|
+
viewMediaClientConfig
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "selectMediaSingleFromCard", ({
|
|
29
|
+
event
|
|
30
|
+
}) => {
|
|
31
|
+
this.selectMediaSingle(event);
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "selectMediaSingle", event => {
|
|
34
|
+
const propPos = this.props.getPos();
|
|
35
|
+
if (typeof propPos !== 'number') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
40
|
+
// another URL if the media node is wrapped in a link mark.
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
const {
|
|
43
|
+
state
|
|
44
|
+
} = this.props.view;
|
|
45
|
+
if (event.shiftKey) {
|
|
46
|
+
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
47
|
+
if (state.selection instanceof CellSelection) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setTextSelection(this.props.view, state.selection.from < propPos ? state.selection.from : propPos - 1,
|
|
51
|
+
// + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
|
|
52
|
+
state.selection.to > propPos ? state.selection.to : propPos + 2);
|
|
53
|
+
} else {
|
|
54
|
+
setNodeSelection(this.props.view, propPos - 1);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
_defineProperty(this, "onFullscreenChange", fullscreen => {
|
|
58
|
+
var _this$mediaPluginStat;
|
|
59
|
+
(_this$mediaPluginStat = this.mediaPluginState) === null || _this$mediaPluginStat === void 0 ? void 0 : _this$mediaPluginStat.updateAndDispatch({
|
|
60
|
+
isFullscreen: fullscreen
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
_defineProperty(this, "handleNewNode", props => {
|
|
64
|
+
var _this$mediaPluginStat2;
|
|
65
|
+
const {
|
|
66
|
+
node
|
|
67
|
+
} = props;
|
|
68
|
+
(_this$mediaPluginStat2 = this.mediaPluginState) === null || _this$mediaPluginStat2 === void 0 ? void 0 : _this$mediaPluginStat2.handleMediaNodeMount(node, () => this.props.getPos());
|
|
69
|
+
});
|
|
70
|
+
const {
|
|
71
|
+
view
|
|
72
|
+
} = this.props;
|
|
73
|
+
this.mediaPluginState = mediaStateKey.getState(view.state);
|
|
74
|
+
}
|
|
75
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
76
|
+
const hasNewViewMediaClientConfig = !this.state.viewMediaClientConfig && nextState.viewMediaClientConfig;
|
|
77
|
+
if (this.props.selected !== nextProps.selected || this.props.node.attrs.id !== nextProps.node.attrs.id || this.props.node.attrs.collection !== nextProps.node.attrs.collection || this.props.maxDimensions.height !== nextProps.maxDimensions.height || this.props.maxDimensions.width !== nextProps.maxDimensions.width || this.props.contextIdentifierProvider !== nextProps.contextIdentifierProvider || this.props.isLoading !== nextProps.isLoading || this.props.mediaProvider !== nextProps.mediaProvider || hasNewViewMediaClientConfig) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
async componentDidMount() {
|
|
83
|
+
this.handleNewNode(this.props);
|
|
84
|
+
const {
|
|
85
|
+
contextIdentifierProvider
|
|
86
|
+
} = this.props;
|
|
87
|
+
this.setState({
|
|
88
|
+
contextIdentifierProvider: await contextIdentifierProvider
|
|
89
|
+
});
|
|
90
|
+
await this.setViewMediaClientConfig();
|
|
91
|
+
}
|
|
92
|
+
componentWillUnmount() {
|
|
93
|
+
var _this$mediaPluginStat3;
|
|
94
|
+
const {
|
|
95
|
+
node
|
|
96
|
+
} = this.props;
|
|
97
|
+
(_this$mediaPluginStat3 = this.mediaPluginState) === null || _this$mediaPluginStat3 === void 0 ? void 0 : _this$mediaPluginStat3.handleMediaNodeUnmount(node);
|
|
98
|
+
}
|
|
99
|
+
componentDidUpdate(prevProps) {
|
|
100
|
+
var _this$mediaPluginStat5;
|
|
101
|
+
if (prevProps.node.attrs.id !== this.props.node.attrs.id) {
|
|
102
|
+
var _this$mediaPluginStat4;
|
|
103
|
+
(_this$mediaPluginStat4 = this.mediaPluginState) === null || _this$mediaPluginStat4 === void 0 ? void 0 : _this$mediaPluginStat4.handleMediaNodeUnmount(prevProps.node);
|
|
104
|
+
this.handleNewNode(this.props);
|
|
105
|
+
}
|
|
106
|
+
(_this$mediaPluginStat5 = this.mediaPluginState) === null || _this$mediaPluginStat5 === void 0 ? void 0 : _this$mediaPluginStat5.updateElement();
|
|
107
|
+
this.setViewMediaClientConfig();
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
const {
|
|
111
|
+
node,
|
|
112
|
+
selected,
|
|
113
|
+
originalDimensions,
|
|
114
|
+
isLoading,
|
|
115
|
+
maxDimensions,
|
|
116
|
+
mediaOptions
|
|
117
|
+
} = this.props;
|
|
118
|
+
const borderMark = node.marks.find(m => m.type.name === 'border');
|
|
119
|
+
const {
|
|
120
|
+
viewMediaClientConfig,
|
|
121
|
+
contextIdentifierProvider
|
|
122
|
+
} = this.state;
|
|
123
|
+
const {
|
|
124
|
+
id,
|
|
125
|
+
type,
|
|
126
|
+
collection,
|
|
127
|
+
url,
|
|
128
|
+
alt
|
|
129
|
+
} = node.attrs;
|
|
130
|
+
if (isLoading || type !== 'external' && !viewMediaClientConfig) {
|
|
131
|
+
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
132
|
+
dimensions: originalDimensions
|
|
133
|
+
}, /*#__PURE__*/React.createElement(CardLoading, null));
|
|
134
|
+
}
|
|
135
|
+
const contextId = contextIdentifierProvider && contextIdentifierProvider.objectId;
|
|
136
|
+
const identifier = type === 'external' ? {
|
|
137
|
+
dataURI: url,
|
|
138
|
+
name: url,
|
|
139
|
+
mediaItemType: 'external-image'
|
|
140
|
+
} : {
|
|
141
|
+
id,
|
|
142
|
+
mediaItemType: 'file',
|
|
143
|
+
collectionName: collection
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// mediaClientConfig is not needed for "external" case. So we have to cheat here.
|
|
147
|
+
// there is a possibility mediaClientConfig will be part of a identifier,
|
|
148
|
+
// so this might be not an issue
|
|
149
|
+
const mediaClientConfig = viewMediaClientConfig || {
|
|
150
|
+
authProvider: () => ({})
|
|
151
|
+
};
|
|
152
|
+
return /*#__PURE__*/React.createElement(MediaCardWrapper, {
|
|
153
|
+
dimensions: originalDimensions,
|
|
154
|
+
onContextMenu: this.selectMediaSingle,
|
|
155
|
+
borderWidth: borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size,
|
|
156
|
+
selected: selected
|
|
157
|
+
}, /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
158
|
+
data: {
|
|
159
|
+
[MEDIA_CONTEXT]: {
|
|
160
|
+
border: !!borderMark
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Card, {
|
|
164
|
+
mediaClientConfig: mediaClientConfig,
|
|
165
|
+
resizeMode: "stretchy-fit",
|
|
166
|
+
dimensions: maxDimensions,
|
|
167
|
+
originalDimensions: originalDimensions,
|
|
168
|
+
identifier: identifier,
|
|
169
|
+
selectable: true,
|
|
170
|
+
selected: selected,
|
|
171
|
+
disableOverlay: true,
|
|
172
|
+
onFullscreenChange: this.onFullscreenChange,
|
|
173
|
+
onClick: this.selectMediaSingleFromCard,
|
|
174
|
+
useInlinePlayer: mediaOptions && mediaOptions.allowLazyLoading,
|
|
175
|
+
isLazy: mediaOptions && mediaOptions.allowLazyLoading,
|
|
176
|
+
featureFlags: mediaOptions && mediaOptions.featureFlags,
|
|
177
|
+
contextId: contextId,
|
|
178
|
+
alt: alt
|
|
179
|
+
})));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export default withImageLoader(MediaNode);
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
|
+
import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
|
|
9
|
+
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
10
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
11
|
+
import { MediaSingle } from '@atlaskit/editor-common/ui';
|
|
12
|
+
import { browser, isNodeSelectedOrInRange, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
13
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
14
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
15
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
16
|
+
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
17
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
18
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
19
|
+
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
20
|
+
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
21
|
+
import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
22
|
+
import ResizableMediaSingle from '../ui/ResizableMediaSingle';
|
|
23
|
+
import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
|
|
24
|
+
import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
|
|
25
|
+
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
26
|
+
import { figureWrapper, MediaSingleNodeSelector } from './styles';
|
|
27
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
28
|
+
export default class MediaSingleNode extends Component {
|
|
29
|
+
constructor(...args) {
|
|
30
|
+
super(...args);
|
|
31
|
+
_defineProperty(this, "state", {
|
|
32
|
+
width: undefined,
|
|
33
|
+
height: undefined,
|
|
34
|
+
viewMediaClientConfig: undefined,
|
|
35
|
+
isCopying: false
|
|
36
|
+
});
|
|
37
|
+
_defineProperty(this, "mediaSingleWrapperRef", /*#__PURE__*/React.createRef());
|
|
38
|
+
_defineProperty(this, "captionPlaceHolderRef", /*#__PURE__*/React.createRef());
|
|
39
|
+
_defineProperty(this, "createMediaNodeUpdater", props => {
|
|
40
|
+
const node = this.props.node.firstChild;
|
|
41
|
+
return new MediaNodeUpdater({
|
|
42
|
+
...props,
|
|
43
|
+
isMediaSingle: true,
|
|
44
|
+
node: node ? node : this.props.node,
|
|
45
|
+
dispatchAnalyticsEvent: this.props.dispatchAnalyticsEvent
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
_defineProperty(this, "setViewMediaClientConfig", async props => {
|
|
49
|
+
const mediaProvider = await props.mediaProvider;
|
|
50
|
+
if (mediaProvider) {
|
|
51
|
+
const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
52
|
+
this.setState({
|
|
53
|
+
viewMediaClientConfig
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
_defineProperty(this, "updateMediaNodeAttributes", async props => {
|
|
58
|
+
const mediaNodeUpdater = this.createMediaNodeUpdater(props);
|
|
59
|
+
const {
|
|
60
|
+
addPendingTask
|
|
61
|
+
} = this.props.mediaPluginState;
|
|
62
|
+
|
|
63
|
+
// we want the first child of MediaSingle (type "media")
|
|
64
|
+
const node = this.props.node.firstChild;
|
|
65
|
+
if (!node) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const updatedDimensions = await mediaNodeUpdater.getRemoteDimensions();
|
|
69
|
+
if (updatedDimensions) {
|
|
70
|
+
mediaNodeUpdater.updateDimensions(updatedDimensions);
|
|
71
|
+
}
|
|
72
|
+
if (node.attrs.type === 'external' && node.attrs.__external) {
|
|
73
|
+
const updatingNode = mediaNodeUpdater.handleExternalMedia(this.props.getPos);
|
|
74
|
+
addPendingTask(updatingNode);
|
|
75
|
+
await updatingNode;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const contextId = mediaNodeUpdater.getNodeContextId();
|
|
79
|
+
if (!contextId) {
|
|
80
|
+
await mediaNodeUpdater.updateContextId();
|
|
81
|
+
}
|
|
82
|
+
const hasDifferentContextId = await mediaNodeUpdater.hasDifferentContextId();
|
|
83
|
+
if (hasDifferentContextId) {
|
|
84
|
+
this.setState({
|
|
85
|
+
isCopying: true
|
|
86
|
+
});
|
|
87
|
+
try {
|
|
88
|
+
const copyNode = mediaNodeUpdater.copyNode({
|
|
89
|
+
traceId: node.attrs.__mediaTraceId
|
|
90
|
+
});
|
|
91
|
+
addPendingTask(copyNode);
|
|
92
|
+
await copyNode;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
// if copyNode fails, let's set isCopying false so we can show the eventual error
|
|
95
|
+
this.setState({
|
|
96
|
+
isCopying: false
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
_defineProperty(this, "selectMediaSingle", ({
|
|
102
|
+
event
|
|
103
|
+
}) => {
|
|
104
|
+
const propPos = this.props.getPos();
|
|
105
|
+
if (typeof propPos !== 'number') {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
110
|
+
// another URL if the media node is wrapped in a link mark.
|
|
111
|
+
event.stopPropagation();
|
|
112
|
+
const {
|
|
113
|
+
state
|
|
114
|
+
} = this.props.view;
|
|
115
|
+
if (event.shiftKey) {
|
|
116
|
+
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
117
|
+
if (state.selection instanceof CellSelection) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setTextSelection(this.props.view, state.selection.from < propPos ? state.selection.from : propPos,
|
|
121
|
+
// + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
|
|
122
|
+
state.selection.to > propPos ? state.selection.to : propPos + 3);
|
|
123
|
+
} else {
|
|
124
|
+
setNodeSelection(this.props.view, propPos);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
_defineProperty(this, "updateSize", (width, layout) => {
|
|
128
|
+
const {
|
|
129
|
+
state,
|
|
130
|
+
dispatch
|
|
131
|
+
} = this.props.view;
|
|
132
|
+
const pos = this.props.getPos();
|
|
133
|
+
if (typeof pos === 'undefined') {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
137
|
+
...this.props.node.attrs,
|
|
138
|
+
layout,
|
|
139
|
+
width,
|
|
140
|
+
widthType: 'pixel'
|
|
141
|
+
});
|
|
142
|
+
tr.setMeta('scrollIntoView', false);
|
|
143
|
+
/**
|
|
144
|
+
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
145
|
+
* This makes it so Prosemirror resets the selection to the child i.e. "media" instead of "media-single"
|
|
146
|
+
* The recommended fix is to reset the selection.[2]
|
|
147
|
+
*
|
|
148
|
+
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
149
|
+
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
150
|
+
*/
|
|
151
|
+
tr.setSelection(NodeSelection.create(tr.doc, pos));
|
|
152
|
+
return dispatch(tr);
|
|
153
|
+
});
|
|
154
|
+
// Workaround for iOS 16 Caption selection issue
|
|
155
|
+
// @see https://product-fabric.atlassian.net/browse/MEX-2012
|
|
156
|
+
_defineProperty(this, "onMediaSingleClicked", event => {
|
|
157
|
+
var _this$captionPlaceHol;
|
|
158
|
+
if (!browser.ios) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (this.mediaSingleWrapperRef.current !== event.target) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
(_this$captionPlaceHol = this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 ? void 0 : _this$captionPlaceHol.click();
|
|
165
|
+
});
|
|
166
|
+
_defineProperty(this, "clickPlaceholder", () => {
|
|
167
|
+
var _pluginInjectionApi$a;
|
|
168
|
+
const {
|
|
169
|
+
view,
|
|
170
|
+
getPos,
|
|
171
|
+
node,
|
|
172
|
+
pluginInjectionApi
|
|
173
|
+
} = this.props;
|
|
174
|
+
if (typeof getPos === 'boolean') {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
insertAndSelectCaptionFromMediaSinglePos(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(getPos(), node)(view.state, view.dispatch);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
181
|
+
if (nextProps.mediaProvider !== this.props.mediaProvider) {
|
|
182
|
+
this.setViewMediaClientConfig(nextProps);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Forced updates not required on mobile
|
|
186
|
+
if (nextProps.isCopyPasteEnabled === false) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// We need to call this method on any prop change since attrs can get removed with collab editing
|
|
191
|
+
// the method internally checks if we already have all attrs
|
|
192
|
+
this.createMediaNodeUpdater(nextProps).updateMediaSingleFileAttrs();
|
|
193
|
+
}
|
|
194
|
+
async componentDidMount() {
|
|
195
|
+
const {
|
|
196
|
+
contextIdentifierProvider
|
|
197
|
+
} = this.props;
|
|
198
|
+
await Promise.all([this.setViewMediaClientConfig(this.props), this.updateMediaNodeAttributes(this.props)]);
|
|
199
|
+
this.setState({
|
|
200
|
+
contextIdentifierProvider: await contextIdentifierProvider
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
render() {
|
|
204
|
+
var _pluginInjectionApi$m;
|
|
205
|
+
const {
|
|
206
|
+
selected,
|
|
207
|
+
getPos,
|
|
208
|
+
node,
|
|
209
|
+
mediaOptions,
|
|
210
|
+
fullWidthMode,
|
|
211
|
+
view: {
|
|
212
|
+
state
|
|
213
|
+
},
|
|
214
|
+
view,
|
|
215
|
+
pluginInjectionApi,
|
|
216
|
+
width: containerWidth,
|
|
217
|
+
lineLength,
|
|
218
|
+
dispatchAnalyticsEvent
|
|
219
|
+
} = this.props;
|
|
220
|
+
const {
|
|
221
|
+
layout,
|
|
222
|
+
widthType,
|
|
223
|
+
width: mediaSingleWidthAttribute
|
|
224
|
+
} = node.attrs;
|
|
225
|
+
const childNode = node.firstChild;
|
|
226
|
+
const attrs = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs) || {};
|
|
227
|
+
|
|
228
|
+
// original width and height of child media node (scaled)
|
|
229
|
+
let {
|
|
230
|
+
width,
|
|
231
|
+
height
|
|
232
|
+
} = attrs;
|
|
233
|
+
if (attrs.type === 'external') {
|
|
234
|
+
if (isMediaBlobUrlFromAttrs(attrs)) {
|
|
235
|
+
const urlAttrs = getAttrsFromUrl(attrs.url);
|
|
236
|
+
if (urlAttrs) {
|
|
237
|
+
const {
|
|
238
|
+
width: urlWidth,
|
|
239
|
+
height: urlHeight
|
|
240
|
+
} = urlAttrs;
|
|
241
|
+
width = width || urlWidth;
|
|
242
|
+
height = height || urlHeight;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const {
|
|
246
|
+
width: stateWidth,
|
|
247
|
+
height: stateHeight
|
|
248
|
+
} = this.state;
|
|
249
|
+
if (width === null) {
|
|
250
|
+
width = stateWidth || DEFAULT_IMAGE_WIDTH;
|
|
251
|
+
}
|
|
252
|
+
if (height === null) {
|
|
253
|
+
height = stateHeight || DEFAULT_IMAGE_HEIGHT;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (!width || !height) {
|
|
257
|
+
width = DEFAULT_IMAGE_WIDTH;
|
|
258
|
+
height = DEFAULT_IMAGE_HEIGHT;
|
|
259
|
+
}
|
|
260
|
+
const isSelected = selected();
|
|
261
|
+
const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
|
|
262
|
+
const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
|
|
263
|
+
const contentWidth = currentMaxWidth || lineLength;
|
|
264
|
+
const mediaSingleProps = {
|
|
265
|
+
layout,
|
|
266
|
+
width,
|
|
267
|
+
height,
|
|
268
|
+
containerWidth: containerWidth,
|
|
269
|
+
lineLength: contentWidth,
|
|
270
|
+
fullWidthMode,
|
|
271
|
+
hasFallbackContainer: false,
|
|
272
|
+
mediaSingleWidth: calcMediaSinglePixelWidth({
|
|
273
|
+
width: mediaSingleWidthAttribute,
|
|
274
|
+
widthType,
|
|
275
|
+
origWidth: width,
|
|
276
|
+
layout,
|
|
277
|
+
// This will only be used when calculating legacy media single width
|
|
278
|
+
// thus we use the legacy value (exclude table as container node)
|
|
279
|
+
contentWidth: contentWidthForLegacyExperience,
|
|
280
|
+
containerWidth,
|
|
281
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
282
|
+
}),
|
|
283
|
+
allowCaptions: mediaOptions.allowCaptions
|
|
284
|
+
};
|
|
285
|
+
const resizableMediaSingleProps = {
|
|
286
|
+
view: view,
|
|
287
|
+
getPos: getPos,
|
|
288
|
+
updateSize: this.updateSize,
|
|
289
|
+
gridSize: 12,
|
|
290
|
+
viewMediaClientConfig: this.state.viewMediaClientConfig,
|
|
291
|
+
allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
|
|
292
|
+
selected: isSelected,
|
|
293
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
294
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
295
|
+
...mediaSingleProps
|
|
296
|
+
};
|
|
297
|
+
let canResize = !!this.props.mediaOptions.allowResizing;
|
|
298
|
+
if (!this.props.mediaOptions.allowResizingInTables) {
|
|
299
|
+
// If resizing not allowed in tables, check parents for tables
|
|
300
|
+
const pos = getPos();
|
|
301
|
+
if (pos) {
|
|
302
|
+
const $pos = state.doc.resolve(pos);
|
|
303
|
+
const {
|
|
304
|
+
table
|
|
305
|
+
} = state.schema.nodes;
|
|
306
|
+
const disabledNode = !!findParentNodeOfTypeClosestToPos($pos, [table]);
|
|
307
|
+
canResize = canResize && !disabledNode;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const shouldShowPlaceholder = (mediaOptions.allowCaptions || getMediaFeatureFlag('captions', mediaOptions.featureFlags)) && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
311
|
+
const MediaChildren = jsx("figure", {
|
|
312
|
+
ref: this.mediaSingleWrapperRef,
|
|
313
|
+
css: [figureWrapper],
|
|
314
|
+
className: MediaSingleNodeSelector,
|
|
315
|
+
onClick: this.onMediaSingleClicked
|
|
316
|
+
}, jsx("div", {
|
|
317
|
+
ref: this.props.forwardRef
|
|
318
|
+
}), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
|
|
319
|
+
ref: this.captionPlaceHolderRef,
|
|
320
|
+
onClick: this.clickPlaceholder
|
|
321
|
+
}));
|
|
322
|
+
return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
|
|
323
|
+
showLegacyNotification: widthType !== 'pixel'
|
|
324
|
+
}), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
|
|
325
|
+
lineLength: contentWidthForLegacyExperience,
|
|
326
|
+
pctWidth: mediaSingleWidthAttribute
|
|
327
|
+
}), MediaChildren) : jsx(MediaSingle, _extends({}, mediaSingleProps, {
|
|
328
|
+
pctWidth: mediaSingleWidthAttribute
|
|
329
|
+
}), MediaChildren);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
_defineProperty(MediaSingleNode, "defaultProps", {
|
|
333
|
+
mediaOptions: {}
|
|
334
|
+
});
|
|
335
|
+
_defineProperty(MediaSingleNode, "displayName", 'MediaSingleNode');
|
|
336
|
+
const MediaSingleNodeWrapper = ({
|
|
337
|
+
pluginInjectionApi,
|
|
338
|
+
mediaProvider,
|
|
339
|
+
contextIdentifierProvider,
|
|
340
|
+
node,
|
|
341
|
+
getPos,
|
|
342
|
+
mediaOptions,
|
|
343
|
+
view,
|
|
344
|
+
fullWidthMode,
|
|
345
|
+
selected,
|
|
346
|
+
eventDispatcher,
|
|
347
|
+
dispatchAnalyticsEvent,
|
|
348
|
+
forwardRef
|
|
349
|
+
}) => {
|
|
350
|
+
const {
|
|
351
|
+
widthState,
|
|
352
|
+
mediaState
|
|
353
|
+
} = useSharedPluginState(pluginInjectionApi, ['width', 'media']);
|
|
354
|
+
return jsx(MediaSingleNode, {
|
|
355
|
+
width: widthState.width,
|
|
356
|
+
lineLength: widthState.lineLength,
|
|
357
|
+
node: node,
|
|
358
|
+
getPos: getPos,
|
|
359
|
+
mediaProvider: mediaProvider,
|
|
360
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
361
|
+
mediaOptions: mediaOptions,
|
|
362
|
+
view: view,
|
|
363
|
+
fullWidthMode: fullWidthMode,
|
|
364
|
+
selected: selected,
|
|
365
|
+
eventDispatcher: eventDispatcher,
|
|
366
|
+
mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
|
|
367
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
368
|
+
forwardRef: forwardRef,
|
|
369
|
+
pluginInjectionApi: pluginInjectionApi
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
class MediaSingleNodeView extends ReactNodeView {
|
|
373
|
+
constructor(...args) {
|
|
374
|
+
super(...args);
|
|
375
|
+
_defineProperty(this, "lastOffsetLeft", 0);
|
|
376
|
+
_defineProperty(this, "forceViewUpdate", false);
|
|
377
|
+
_defineProperty(this, "selectionType", null);
|
|
378
|
+
_defineProperty(this, "checkAndUpdateSelectionType", () => {
|
|
379
|
+
const getPos = this.getPos;
|
|
380
|
+
const {
|
|
381
|
+
selection
|
|
382
|
+
} = this.view.state;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* ED-19831
|
|
386
|
+
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
387
|
+
* directly to confluence since this bug is now in production.
|
|
388
|
+
*/
|
|
389
|
+
let pos;
|
|
390
|
+
try {
|
|
391
|
+
pos = getPos ? getPos() : undefined;
|
|
392
|
+
} catch (e) {
|
|
393
|
+
pos = undefined;
|
|
394
|
+
}
|
|
395
|
+
const isNodeSelected = isNodeSelectedOrInRange(selection.$anchor.pos, selection.$head.pos, pos, this.node.nodeSize);
|
|
396
|
+
this.selectionType = isNodeSelected;
|
|
397
|
+
return isNodeSelected;
|
|
398
|
+
});
|
|
399
|
+
_defineProperty(this, "isNodeSelected", () => {
|
|
400
|
+
this.checkAndUpdateSelectionType();
|
|
401
|
+
return this.selectionType !== null;
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
createDomRef() {
|
|
405
|
+
const domRef = document.createElement('div');
|
|
406
|
+
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
407
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
408
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
409
|
+
domRef.contentEditable = 'true';
|
|
410
|
+
}
|
|
411
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
412
|
+
domRef.classList.add('media-extended-resize-experience');
|
|
413
|
+
}
|
|
414
|
+
return domRef;
|
|
415
|
+
}
|
|
416
|
+
getContentDOM() {
|
|
417
|
+
const dom = document.createElement('div');
|
|
418
|
+
dom.classList.add(MEDIA_CONTENT_WRAP_CLASS_NAME);
|
|
419
|
+
return {
|
|
420
|
+
dom
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
viewShouldUpdate(nextNode) {
|
|
424
|
+
if (this.forceViewUpdate) {
|
|
425
|
+
this.forceViewUpdate = false;
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
if (this.node.attrs !== nextNode.attrs) {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
if (this.selectionType !== this.checkAndUpdateSelectionType()) {
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
if (this.node.childCount !== nextNode.childCount) {
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
return super.viewShouldUpdate(nextNode);
|
|
438
|
+
}
|
|
439
|
+
getNodeMediaId(node) {
|
|
440
|
+
if (node.firstChild) {
|
|
441
|
+
return node.firstChild.attrs.id;
|
|
442
|
+
}
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
update(node, decorations, _innerDecorations, isValidUpdate) {
|
|
446
|
+
if (!isValidUpdate) {
|
|
447
|
+
isValidUpdate = (currentNode, newNode) => this.getNodeMediaId(currentNode) === this.getNodeMediaId(newNode);
|
|
448
|
+
}
|
|
449
|
+
return super.update(node, decorations, _innerDecorations, isValidUpdate);
|
|
450
|
+
}
|
|
451
|
+
render(props, forwardRef) {
|
|
452
|
+
const {
|
|
453
|
+
eventDispatcher,
|
|
454
|
+
fullWidthMode,
|
|
455
|
+
providerFactory,
|
|
456
|
+
mediaOptions,
|
|
457
|
+
dispatchAnalyticsEvent,
|
|
458
|
+
pluginInjectionApi
|
|
459
|
+
} = this.reactComponentProps;
|
|
460
|
+
|
|
461
|
+
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
462
|
+
const getPos = this.getPos;
|
|
463
|
+
return jsx(WithProviders, {
|
|
464
|
+
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
465
|
+
providerFactory: providerFactory,
|
|
466
|
+
renderNode: ({
|
|
467
|
+
mediaProvider,
|
|
468
|
+
contextIdentifierProvider
|
|
469
|
+
}) => {
|
|
470
|
+
return jsx(MediaSingleNodeWrapper, {
|
|
471
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
472
|
+
mediaProvider: mediaProvider,
|
|
473
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
474
|
+
node: this.node,
|
|
475
|
+
getPos: getPos,
|
|
476
|
+
mediaOptions: mediaOptions,
|
|
477
|
+
view: this.view,
|
|
478
|
+
fullWidthMode: fullWidthMode,
|
|
479
|
+
selected: this.isNodeSelected,
|
|
480
|
+
eventDispatcher: eventDispatcher,
|
|
481
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
482
|
+
forwardRef: forwardRef
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
ignoreMutation() {
|
|
488
|
+
// DOM has changed; recalculate if we need to re-render
|
|
489
|
+
if (this.dom) {
|
|
490
|
+
const offsetLeft = this.dom.offsetLeft;
|
|
491
|
+
if (offsetLeft !== this.lastOffsetLeft) {
|
|
492
|
+
this.lastOffsetLeft = offsetLeft;
|
|
493
|
+
this.forceViewUpdate = true;
|
|
494
|
+
this.update(this.node, [], undefined, () => true);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
export const ReactMediaSingleNode = (portalProviderAPI, eventDispatcher, providerFactory, pluginInjectionApi, dispatchAnalyticsEvent, mediaOptions = {}) => (node, view, getPos) => {
|
|
501
|
+
const hasIntlContext = true;
|
|
502
|
+
return new MediaSingleNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
503
|
+
eventDispatcher,
|
|
504
|
+
fullWidthMode: mediaOptions.fullWidthEnabled,
|
|
505
|
+
providerFactory,
|
|
506
|
+
mediaOptions,
|
|
507
|
+
dispatchAnalyticsEvent,
|
|
508
|
+
isCopyPasteEnabled: mediaOptions.isCopyPasteEnabled,
|
|
509
|
+
pluginInjectionApi
|
|
510
|
+
}, undefined, undefined, undefined, hasIntlContext).init();
|
|
511
|
+
};
|