@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,629 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.ReactMediaSingleNode = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
var _react2 = require("@emotion/react");
|
|
22
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
23
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
24
|
+
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
25
|
+
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
26
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
27
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
28
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
29
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
30
|
+
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
31
|
+
var _mediaClient = require("@atlaskit/media-client");
|
|
32
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
33
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
34
|
+
var _captions = require("../commands/captions");
|
|
35
|
+
var _main = require("../pm-plugins/main");
|
|
36
|
+
var _CaptionPlaceholder = _interopRequireDefault(require("../ui/CaptionPlaceholder"));
|
|
37
|
+
var _ResizableMediaSingle = _interopRequireDefault(require("../ui/ResizableMediaSingle"));
|
|
38
|
+
var _ResizableMediaSingleNext = _interopRequireDefault(require("../ui/ResizableMediaSingle/ResizableMediaSingleNext"));
|
|
39
|
+
var _mediaCommon2 = require("../utils/media-common");
|
|
40
|
+
var _mediaNodeUpdater = require("./mediaNodeUpdater");
|
|
41
|
+
var _styles = require("./styles");
|
|
42
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
44
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
45
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
46
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
47
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
48
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
49
|
+
var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
50
|
+
(0, _inherits2.default)(MediaSingleNode, _Component);
|
|
51
|
+
var _super = _createSuper(MediaSingleNode);
|
|
52
|
+
function MediaSingleNode() {
|
|
53
|
+
var _this;
|
|
54
|
+
(0, _classCallCheck2.default)(this, MediaSingleNode);
|
|
55
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
|
+
args[_key] = arguments[_key];
|
|
57
|
+
}
|
|
58
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
59
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
60
|
+
width: undefined,
|
|
61
|
+
height: undefined,
|
|
62
|
+
viewMediaClientConfig: undefined,
|
|
63
|
+
isCopying: false
|
|
64
|
+
});
|
|
65
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mediaSingleWrapperRef", /*#__PURE__*/_react.default.createRef());
|
|
66
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "captionPlaceHolderRef", /*#__PURE__*/_react.default.createRef());
|
|
67
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createMediaNodeUpdater", function (props) {
|
|
68
|
+
var node = _this.props.node.firstChild;
|
|
69
|
+
return new _mediaNodeUpdater.MediaNodeUpdater(_objectSpread(_objectSpread({}, props), {}, {
|
|
70
|
+
isMediaSingle: true,
|
|
71
|
+
node: node ? node : _this.props.node,
|
|
72
|
+
dispatchAnalyticsEvent: _this.props.dispatchAnalyticsEvent
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setViewMediaClientConfig", /*#__PURE__*/function () {
|
|
76
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(props) {
|
|
77
|
+
var mediaProvider, viewMediaClientConfig;
|
|
78
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
_context.next = 2;
|
|
82
|
+
return props.mediaProvider;
|
|
83
|
+
case 2:
|
|
84
|
+
mediaProvider = _context.sent;
|
|
85
|
+
if (mediaProvider) {
|
|
86
|
+
viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
87
|
+
_this.setState({
|
|
88
|
+
viewMediaClientConfig: viewMediaClientConfig
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
case 4:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}));
|
|
97
|
+
return function (_x) {
|
|
98
|
+
return _ref.apply(this, arguments);
|
|
99
|
+
};
|
|
100
|
+
}());
|
|
101
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateMediaNodeAttributes", /*#__PURE__*/function () {
|
|
102
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(props) {
|
|
103
|
+
var mediaNodeUpdater, addPendingTask, node, updatedDimensions, updatingNode, contextId, hasDifferentContextId, copyNode;
|
|
104
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
105
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
mediaNodeUpdater = _this.createMediaNodeUpdater(props);
|
|
108
|
+
addPendingTask = _this.props.mediaPluginState.addPendingTask; // we want the first child of MediaSingle (type "media")
|
|
109
|
+
node = _this.props.node.firstChild;
|
|
110
|
+
if (node) {
|
|
111
|
+
_context2.next = 5;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return _context2.abrupt("return");
|
|
115
|
+
case 5:
|
|
116
|
+
_context2.next = 7;
|
|
117
|
+
return mediaNodeUpdater.getRemoteDimensions();
|
|
118
|
+
case 7:
|
|
119
|
+
updatedDimensions = _context2.sent;
|
|
120
|
+
if (updatedDimensions) {
|
|
121
|
+
mediaNodeUpdater.updateDimensions(updatedDimensions);
|
|
122
|
+
}
|
|
123
|
+
if (!(node.attrs.type === 'external' && node.attrs.__external)) {
|
|
124
|
+
_context2.next = 15;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
updatingNode = mediaNodeUpdater.handleExternalMedia(_this.props.getPos);
|
|
128
|
+
addPendingTask(updatingNode);
|
|
129
|
+
_context2.next = 14;
|
|
130
|
+
return updatingNode;
|
|
131
|
+
case 14:
|
|
132
|
+
return _context2.abrupt("return");
|
|
133
|
+
case 15:
|
|
134
|
+
contextId = mediaNodeUpdater.getNodeContextId();
|
|
135
|
+
if (contextId) {
|
|
136
|
+
_context2.next = 19;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
_context2.next = 19;
|
|
140
|
+
return mediaNodeUpdater.updateContextId();
|
|
141
|
+
case 19:
|
|
142
|
+
_context2.next = 21;
|
|
143
|
+
return mediaNodeUpdater.hasDifferentContextId();
|
|
144
|
+
case 21:
|
|
145
|
+
hasDifferentContextId = _context2.sent;
|
|
146
|
+
if (!hasDifferentContextId) {
|
|
147
|
+
_context2.next = 34;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
_this.setState({
|
|
151
|
+
isCopying: true
|
|
152
|
+
});
|
|
153
|
+
_context2.prev = 24;
|
|
154
|
+
copyNode = mediaNodeUpdater.copyNode({
|
|
155
|
+
traceId: node.attrs.__mediaTraceId
|
|
156
|
+
});
|
|
157
|
+
addPendingTask(copyNode);
|
|
158
|
+
_context2.next = 29;
|
|
159
|
+
return copyNode;
|
|
160
|
+
case 29:
|
|
161
|
+
_context2.next = 34;
|
|
162
|
+
break;
|
|
163
|
+
case 31:
|
|
164
|
+
_context2.prev = 31;
|
|
165
|
+
_context2.t0 = _context2["catch"](24);
|
|
166
|
+
// if copyNode fails, let's set isCopying false so we can show the eventual error
|
|
167
|
+
_this.setState({
|
|
168
|
+
isCopying: false
|
|
169
|
+
});
|
|
170
|
+
case 34:
|
|
171
|
+
case "end":
|
|
172
|
+
return _context2.stop();
|
|
173
|
+
}
|
|
174
|
+
}, _callee2, null, [[24, 31]]);
|
|
175
|
+
}));
|
|
176
|
+
return function (_x2) {
|
|
177
|
+
return _ref2.apply(this, arguments);
|
|
178
|
+
};
|
|
179
|
+
}());
|
|
180
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectMediaSingle", function (_ref3) {
|
|
181
|
+
var event = _ref3.event;
|
|
182
|
+
var propPos = _this.props.getPos();
|
|
183
|
+
if (typeof propPos !== 'number') {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
188
|
+
// another URL if the media node is wrapped in a link mark.
|
|
189
|
+
event.stopPropagation();
|
|
190
|
+
var state = _this.props.view.state;
|
|
191
|
+
if (event.shiftKey) {
|
|
192
|
+
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
193
|
+
if (state.selection instanceof _cellSelection.CellSelection) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
(0, _utils.setTextSelection)(_this.props.view, state.selection.from < propPos ? state.selection.from : propPos,
|
|
197
|
+
// + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
|
|
198
|
+
state.selection.to > propPos ? state.selection.to : propPos + 3);
|
|
199
|
+
} else {
|
|
200
|
+
(0, _utils.setNodeSelection)(_this.props.view, propPos);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateSize", function (width, layout) {
|
|
204
|
+
var _this$props$view = _this.props.view,
|
|
205
|
+
state = _this$props$view.state,
|
|
206
|
+
dispatch = _this$props$view.dispatch;
|
|
207
|
+
var pos = _this.props.getPos();
|
|
208
|
+
if (typeof pos === 'undefined') {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, _this.props.node.attrs), {}, {
|
|
212
|
+
layout: layout,
|
|
213
|
+
width: width,
|
|
214
|
+
widthType: 'pixel'
|
|
215
|
+
}));
|
|
216
|
+
tr.setMeta('scrollIntoView', false);
|
|
217
|
+
/**
|
|
218
|
+
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
219
|
+
* This makes it so Prosemirror resets the selection to the child i.e. "media" instead of "media-single"
|
|
220
|
+
* The recommended fix is to reset the selection.[2]
|
|
221
|
+
*
|
|
222
|
+
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
223
|
+
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
224
|
+
*/
|
|
225
|
+
tr.setSelection(_state.NodeSelection.create(tr.doc, pos));
|
|
226
|
+
return dispatch(tr);
|
|
227
|
+
});
|
|
228
|
+
// Workaround for iOS 16 Caption selection issue
|
|
229
|
+
// @see https://product-fabric.atlassian.net/browse/MEX-2012
|
|
230
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMediaSingleClicked", function (event) {
|
|
231
|
+
var _this$captionPlaceHol;
|
|
232
|
+
if (!_utils.browser.ios) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (_this.mediaSingleWrapperRef.current !== event.target) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
(_this$captionPlaceHol = _this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 || _this$captionPlaceHol.click();
|
|
239
|
+
});
|
|
240
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clickPlaceholder", function () {
|
|
241
|
+
var _pluginInjectionApi$a;
|
|
242
|
+
var _this$props = _this.props,
|
|
243
|
+
view = _this$props.view,
|
|
244
|
+
getPos = _this$props.getPos,
|
|
245
|
+
node = _this$props.node,
|
|
246
|
+
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
247
|
+
if (typeof getPos === 'boolean') {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(getPos(), node)(view.state, view.dispatch);
|
|
251
|
+
});
|
|
252
|
+
return _this;
|
|
253
|
+
}
|
|
254
|
+
(0, _createClass2.default)(MediaSingleNode, [{
|
|
255
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
256
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
257
|
+
if (nextProps.mediaProvider !== this.props.mediaProvider) {
|
|
258
|
+
this.setViewMediaClientConfig(nextProps);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Forced updates not required on mobile
|
|
262
|
+
if (nextProps.isCopyPasteEnabled === false) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// We need to call this method on any prop change since attrs can get removed with collab editing
|
|
267
|
+
// the method internally checks if we already have all attrs
|
|
268
|
+
this.createMediaNodeUpdater(nextProps).updateMediaSingleFileAttrs();
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "componentDidMount",
|
|
272
|
+
value: function () {
|
|
273
|
+
var _componentDidMount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
274
|
+
var contextIdentifierProvider;
|
|
275
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
276
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
277
|
+
case 0:
|
|
278
|
+
contextIdentifierProvider = this.props.contextIdentifierProvider;
|
|
279
|
+
_context3.next = 3;
|
|
280
|
+
return Promise.all([this.setViewMediaClientConfig(this.props), this.updateMediaNodeAttributes(this.props)]);
|
|
281
|
+
case 3:
|
|
282
|
+
_context3.t0 = this;
|
|
283
|
+
_context3.next = 6;
|
|
284
|
+
return contextIdentifierProvider;
|
|
285
|
+
case 6:
|
|
286
|
+
_context3.t1 = _context3.sent;
|
|
287
|
+
_context3.t2 = {
|
|
288
|
+
contextIdentifierProvider: _context3.t1
|
|
289
|
+
};
|
|
290
|
+
_context3.t0.setState.call(_context3.t0, _context3.t2);
|
|
291
|
+
case 9:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context3.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee3, this);
|
|
296
|
+
}));
|
|
297
|
+
function componentDidMount() {
|
|
298
|
+
return _componentDidMount.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return componentDidMount;
|
|
301
|
+
}()
|
|
302
|
+
}, {
|
|
303
|
+
key: "render",
|
|
304
|
+
value: function render() {
|
|
305
|
+
var _pluginInjectionApi$m;
|
|
306
|
+
var _this$props2 = this.props,
|
|
307
|
+
selected = _this$props2.selected,
|
|
308
|
+
getPos = _this$props2.getPos,
|
|
309
|
+
node = _this$props2.node,
|
|
310
|
+
mediaOptions = _this$props2.mediaOptions,
|
|
311
|
+
fullWidthMode = _this$props2.fullWidthMode,
|
|
312
|
+
state = _this$props2.view.state,
|
|
313
|
+
view = _this$props2.view,
|
|
314
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
315
|
+
containerWidth = _this$props2.width,
|
|
316
|
+
lineLength = _this$props2.lineLength,
|
|
317
|
+
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent;
|
|
318
|
+
var _ref4 = node.attrs,
|
|
319
|
+
layout = _ref4.layout,
|
|
320
|
+
widthType = _ref4.widthType,
|
|
321
|
+
mediaSingleWidthAttribute = _ref4.width;
|
|
322
|
+
var childNode = node.firstChild;
|
|
323
|
+
var attrs = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs) || {};
|
|
324
|
+
|
|
325
|
+
// original width and height of child media node (scaled)
|
|
326
|
+
var width = attrs.width,
|
|
327
|
+
height = attrs.height;
|
|
328
|
+
if (attrs.type === 'external') {
|
|
329
|
+
if ((0, _mediaCommon2.isMediaBlobUrlFromAttrs)(attrs)) {
|
|
330
|
+
var urlAttrs = (0, _mediaClient.getAttrsFromUrl)(attrs.url);
|
|
331
|
+
if (urlAttrs) {
|
|
332
|
+
var urlWidth = urlAttrs.width,
|
|
333
|
+
urlHeight = urlAttrs.height;
|
|
334
|
+
width = width || urlWidth;
|
|
335
|
+
height = height || urlHeight;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
var _this$state = this.state,
|
|
339
|
+
stateWidth = _this$state.width,
|
|
340
|
+
stateHeight = _this$state.height;
|
|
341
|
+
if (width === null) {
|
|
342
|
+
width = stateWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
343
|
+
}
|
|
344
|
+
if (height === null) {
|
|
345
|
+
height = stateHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (!width || !height) {
|
|
349
|
+
width = _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
350
|
+
height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
351
|
+
}
|
|
352
|
+
var isSelected = selected();
|
|
353
|
+
var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
|
|
354
|
+
var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
|
|
355
|
+
var contentWidth = currentMaxWidth || lineLength;
|
|
356
|
+
var mediaSingleProps = {
|
|
357
|
+
layout: layout,
|
|
358
|
+
width: width,
|
|
359
|
+
height: height,
|
|
360
|
+
containerWidth: containerWidth,
|
|
361
|
+
lineLength: contentWidth,
|
|
362
|
+
fullWidthMode: fullWidthMode,
|
|
363
|
+
hasFallbackContainer: false,
|
|
364
|
+
mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
365
|
+
width: mediaSingleWidthAttribute,
|
|
366
|
+
widthType: widthType,
|
|
367
|
+
origWidth: width,
|
|
368
|
+
layout: layout,
|
|
369
|
+
// This will only be used when calculating legacy media single width
|
|
370
|
+
// thus we use the legacy value (exclude table as container node)
|
|
371
|
+
contentWidth: contentWidthForLegacyExperience,
|
|
372
|
+
containerWidth: containerWidth,
|
|
373
|
+
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
374
|
+
}),
|
|
375
|
+
allowCaptions: mediaOptions.allowCaptions
|
|
376
|
+
};
|
|
377
|
+
var resizableMediaSingleProps = _objectSpread({
|
|
378
|
+
view: view,
|
|
379
|
+
getPos: getPos,
|
|
380
|
+
updateSize: this.updateSize,
|
|
381
|
+
gridSize: 12,
|
|
382
|
+
viewMediaClientConfig: this.state.viewMediaClientConfig,
|
|
383
|
+
allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
|
|
384
|
+
selected: isSelected,
|
|
385
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
386
|
+
pluginInjectionApi: pluginInjectionApi
|
|
387
|
+
}, mediaSingleProps);
|
|
388
|
+
var canResize = !!this.props.mediaOptions.allowResizing;
|
|
389
|
+
if (!this.props.mediaOptions.allowResizingInTables) {
|
|
390
|
+
// If resizing not allowed in tables, check parents for tables
|
|
391
|
+
var pos = getPos();
|
|
392
|
+
if (pos) {
|
|
393
|
+
var $pos = state.doc.resolve(pos);
|
|
394
|
+
var table = state.schema.nodes.table;
|
|
395
|
+
var disabledNode = !!(0, _utils2.findParentNodeOfTypeClosestToPos)($pos, [table]);
|
|
396
|
+
canResize = canResize && !disabledNode;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
var shouldShowPlaceholder = (mediaOptions.allowCaptions || (0, _mediaCommon.getMediaFeatureFlag)('captions', mediaOptions.featureFlags)) && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
|
|
400
|
+
var MediaChildren = (0, _react2.jsx)("figure", {
|
|
401
|
+
ref: this.mediaSingleWrapperRef,
|
|
402
|
+
css: [_styles.figureWrapper],
|
|
403
|
+
className: _styles.MediaSingleNodeSelector,
|
|
404
|
+
onClick: this.onMediaSingleClicked
|
|
405
|
+
}, (0, _react2.jsx)("div", {
|
|
406
|
+
ref: this.props.forwardRef
|
|
407
|
+
}), shouldShowPlaceholder && (0, _react2.jsx)(_CaptionPlaceholder.default, {
|
|
408
|
+
ref: this.captionPlaceHolderRef,
|
|
409
|
+
onClick: this.clickPlaceholder
|
|
410
|
+
}));
|
|
411
|
+
return canResize ? (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? (0, _react2.jsx)(_ResizableMediaSingleNext.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
412
|
+
showLegacyNotification: widthType !== 'pixel'
|
|
413
|
+
}), MediaChildren) : (0, _react2.jsx)(_ResizableMediaSingle.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
414
|
+
lineLength: contentWidthForLegacyExperience,
|
|
415
|
+
pctWidth: mediaSingleWidthAttribute
|
|
416
|
+
}), MediaChildren) : (0, _react2.jsx)(_ui.MediaSingle, (0, _extends2.default)({}, mediaSingleProps, {
|
|
417
|
+
pctWidth: mediaSingleWidthAttribute
|
|
418
|
+
}), MediaChildren);
|
|
419
|
+
}
|
|
420
|
+
}]);
|
|
421
|
+
return MediaSingleNode;
|
|
422
|
+
}(_react.Component);
|
|
423
|
+
(0, _defineProperty2.default)(MediaSingleNode, "defaultProps", {
|
|
424
|
+
mediaOptions: {}
|
|
425
|
+
});
|
|
426
|
+
(0, _defineProperty2.default)(MediaSingleNode, "displayName", 'MediaSingleNode');
|
|
427
|
+
var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref5) {
|
|
428
|
+
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
429
|
+
mediaProvider = _ref5.mediaProvider,
|
|
430
|
+
contextIdentifierProvider = _ref5.contextIdentifierProvider,
|
|
431
|
+
node = _ref5.node,
|
|
432
|
+
getPos = _ref5.getPos,
|
|
433
|
+
mediaOptions = _ref5.mediaOptions,
|
|
434
|
+
view = _ref5.view,
|
|
435
|
+
fullWidthMode = _ref5.fullWidthMode,
|
|
436
|
+
selected = _ref5.selected,
|
|
437
|
+
eventDispatcher = _ref5.eventDispatcher,
|
|
438
|
+
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent,
|
|
439
|
+
forwardRef = _ref5.forwardRef;
|
|
440
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['width', 'media']),
|
|
441
|
+
widthState = _useSharedPluginState.widthState,
|
|
442
|
+
mediaState = _useSharedPluginState.mediaState;
|
|
443
|
+
return (0, _react2.jsx)(MediaSingleNode, {
|
|
444
|
+
width: widthState.width,
|
|
445
|
+
lineLength: widthState.lineLength,
|
|
446
|
+
node: node,
|
|
447
|
+
getPos: getPos,
|
|
448
|
+
mediaProvider: mediaProvider,
|
|
449
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
450
|
+
mediaOptions: mediaOptions,
|
|
451
|
+
view: view,
|
|
452
|
+
fullWidthMode: fullWidthMode,
|
|
453
|
+
selected: selected,
|
|
454
|
+
eventDispatcher: eventDispatcher,
|
|
455
|
+
mediaPluginState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined,
|
|
456
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
457
|
+
forwardRef: forwardRef,
|
|
458
|
+
pluginInjectionApi: pluginInjectionApi
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
462
|
+
(0, _inherits2.default)(MediaSingleNodeView, _ReactNodeView);
|
|
463
|
+
var _super2 = _createSuper(MediaSingleNodeView);
|
|
464
|
+
function MediaSingleNodeView() {
|
|
465
|
+
var _this2;
|
|
466
|
+
(0, _classCallCheck2.default)(this, MediaSingleNodeView);
|
|
467
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
468
|
+
args[_key2] = arguments[_key2];
|
|
469
|
+
}
|
|
470
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
471
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "lastOffsetLeft", 0);
|
|
472
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "forceViewUpdate", false);
|
|
473
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "selectionType", null);
|
|
474
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "checkAndUpdateSelectionType", function () {
|
|
475
|
+
var getPos = _this2.getPos;
|
|
476
|
+
var selection = _this2.view.state.selection;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* ED-19831
|
|
480
|
+
* There is a getPos issue coming from this code. We need to apply this workaround for now and apply a patch
|
|
481
|
+
* directly to confluence since this bug is now in production.
|
|
482
|
+
*/
|
|
483
|
+
var pos;
|
|
484
|
+
try {
|
|
485
|
+
pos = getPos ? getPos() : undefined;
|
|
486
|
+
} catch (e) {
|
|
487
|
+
pos = undefined;
|
|
488
|
+
}
|
|
489
|
+
var isNodeSelected = (0, _utils.isNodeSelectedOrInRange)(selection.$anchor.pos, selection.$head.pos, pos, _this2.node.nodeSize);
|
|
490
|
+
_this2.selectionType = isNodeSelected;
|
|
491
|
+
return isNodeSelected;
|
|
492
|
+
});
|
|
493
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "isNodeSelected", function () {
|
|
494
|
+
_this2.checkAndUpdateSelectionType();
|
|
495
|
+
return _this2.selectionType !== null;
|
|
496
|
+
});
|
|
497
|
+
return _this2;
|
|
498
|
+
}
|
|
499
|
+
(0, _createClass2.default)(MediaSingleNodeView, [{
|
|
500
|
+
key: "createDomRef",
|
|
501
|
+
value: function createDomRef() {
|
|
502
|
+
var domRef = document.createElement('div');
|
|
503
|
+
if (this.reactComponentProps.mediaOptions && this.reactComponentProps.mediaOptions.allowMediaSingleEditable) {
|
|
504
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
505
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
506
|
+
domRef.contentEditable = 'true';
|
|
507
|
+
}
|
|
508
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience')) {
|
|
509
|
+
domRef.classList.add('media-extended-resize-experience');
|
|
510
|
+
}
|
|
511
|
+
return domRef;
|
|
512
|
+
}
|
|
513
|
+
}, {
|
|
514
|
+
key: "getContentDOM",
|
|
515
|
+
value: function getContentDOM() {
|
|
516
|
+
var dom = document.createElement('div');
|
|
517
|
+
dom.classList.add(_main.MEDIA_CONTENT_WRAP_CLASS_NAME);
|
|
518
|
+
return {
|
|
519
|
+
dom: dom
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
}, {
|
|
523
|
+
key: "viewShouldUpdate",
|
|
524
|
+
value: function viewShouldUpdate(nextNode) {
|
|
525
|
+
if (this.forceViewUpdate) {
|
|
526
|
+
this.forceViewUpdate = false;
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
if (this.node.attrs !== nextNode.attrs) {
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
if (this.selectionType !== this.checkAndUpdateSelectionType()) {
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
if (this.node.childCount !== nextNode.childCount) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(MediaSingleNodeView.prototype), "viewShouldUpdate", this).call(this, nextNode);
|
|
539
|
+
}
|
|
540
|
+
}, {
|
|
541
|
+
key: "getNodeMediaId",
|
|
542
|
+
value: function getNodeMediaId(node) {
|
|
543
|
+
if (node.firstChild) {
|
|
544
|
+
return node.firstChild.attrs.id;
|
|
545
|
+
}
|
|
546
|
+
return undefined;
|
|
547
|
+
}
|
|
548
|
+
}, {
|
|
549
|
+
key: "update",
|
|
550
|
+
value: function update(node, decorations, _innerDecorations, isValidUpdate) {
|
|
551
|
+
var _this3 = this;
|
|
552
|
+
if (!isValidUpdate) {
|
|
553
|
+
isValidUpdate = function isValidUpdate(currentNode, newNode) {
|
|
554
|
+
return _this3.getNodeMediaId(currentNode) === _this3.getNodeMediaId(newNode);
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(MediaSingleNodeView.prototype), "update", this).call(this, node, decorations, _innerDecorations, isValidUpdate);
|
|
558
|
+
}
|
|
559
|
+
}, {
|
|
560
|
+
key: "render",
|
|
561
|
+
value: function render(props, forwardRef) {
|
|
562
|
+
var _this4 = this;
|
|
563
|
+
var _this$reactComponentP = this.reactComponentProps,
|
|
564
|
+
eventDispatcher = _this$reactComponentP.eventDispatcher,
|
|
565
|
+
fullWidthMode = _this$reactComponentP.fullWidthMode,
|
|
566
|
+
providerFactory = _this$reactComponentP.providerFactory,
|
|
567
|
+
mediaOptions = _this$reactComponentP.mediaOptions,
|
|
568
|
+
dispatchAnalyticsEvent = _this$reactComponentP.dispatchAnalyticsEvent,
|
|
569
|
+
pluginInjectionApi = _this$reactComponentP.pluginInjectionApi;
|
|
570
|
+
|
|
571
|
+
// getPos is a boolean for marks, since this is a node we know it must be a function
|
|
572
|
+
var getPos = this.getPos;
|
|
573
|
+
return (0, _react2.jsx)(_providerFactory.WithProviders, {
|
|
574
|
+
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
575
|
+
providerFactory: providerFactory,
|
|
576
|
+
renderNode: function renderNode(_ref6) {
|
|
577
|
+
var mediaProvider = _ref6.mediaProvider,
|
|
578
|
+
contextIdentifierProvider = _ref6.contextIdentifierProvider;
|
|
579
|
+
return (0, _react2.jsx)(MediaSingleNodeWrapper, {
|
|
580
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
581
|
+
mediaProvider: mediaProvider,
|
|
582
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
583
|
+
node: _this4.node,
|
|
584
|
+
getPos: getPos,
|
|
585
|
+
mediaOptions: mediaOptions,
|
|
586
|
+
view: _this4.view,
|
|
587
|
+
fullWidthMode: fullWidthMode,
|
|
588
|
+
selected: _this4.isNodeSelected,
|
|
589
|
+
eventDispatcher: eventDispatcher,
|
|
590
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
591
|
+
forwardRef: forwardRef
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}, {
|
|
597
|
+
key: "ignoreMutation",
|
|
598
|
+
value: function ignoreMutation() {
|
|
599
|
+
// DOM has changed; recalculate if we need to re-render
|
|
600
|
+
if (this.dom) {
|
|
601
|
+
var offsetLeft = this.dom.offsetLeft;
|
|
602
|
+
if (offsetLeft !== this.lastOffsetLeft) {
|
|
603
|
+
this.lastOffsetLeft = offsetLeft;
|
|
604
|
+
this.forceViewUpdate = true;
|
|
605
|
+
this.update(this.node, [], undefined, function () {
|
|
606
|
+
return true;
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
}]);
|
|
613
|
+
return MediaSingleNodeView;
|
|
614
|
+
}(_reactNodeView.default);
|
|
615
|
+
var ReactMediaSingleNode = exports.ReactMediaSingleNode = function ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, pluginInjectionApi, dispatchAnalyticsEvent) {
|
|
616
|
+
var mediaOptions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
617
|
+
return function (node, view, getPos) {
|
|
618
|
+
var hasIntlContext = true;
|
|
619
|
+
return new MediaSingleNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
620
|
+
eventDispatcher: eventDispatcher,
|
|
621
|
+
fullWidthMode: mediaOptions.fullWidthEnabled,
|
|
622
|
+
providerFactory: providerFactory,
|
|
623
|
+
mediaOptions: mediaOptions,
|
|
624
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
625
|
+
isCopyPasteEnabled: mediaOptions.isCopyPasteEnabled,
|
|
626
|
+
pluginInjectionApi: pluginInjectionApi
|
|
627
|
+
}, undefined, undefined, undefined, hasIntlContext).init();
|
|
628
|
+
};
|
|
629
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.messages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
mediaGroupDeleteLabel: {
|
|
10
|
+
id: 'fabric.editor.mediaGroupDeleteLabel',
|
|
11
|
+
defaultMessage: 'delete',
|
|
12
|
+
description: 'a label for an icon that deletes media'
|
|
13
|
+
}
|
|
14
|
+
});
|