@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,798 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
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; }
|
|
9
|
+
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) { _defineProperty(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; }
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
+
import assert from 'assert';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import ReactDOM from 'react-dom';
|
|
14
|
+
import { RawIntlProvider } from 'react-intl-next';
|
|
15
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
|
+
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
17
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
18
|
+
import { browser, ErrorReporter, isInEmptyLine, isInListItem } from '@atlaskit/editor-common/utils';
|
|
19
|
+
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
20
|
+
import { insertPoint } from '@atlaskit/editor-prosemirror/transform';
|
|
21
|
+
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
22
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
23
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
24
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
25
|
+
import * as helpers from '../commands/helpers';
|
|
26
|
+
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
27
|
+
import PickerFacade from '../picker-facade';
|
|
28
|
+
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
29
|
+
import { isInsidePotentialEmptyParagraph, removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
30
|
+
import { canInsertMediaInline, insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
31
|
+
import { insertMediaSingleNode, isMediaSingle } from '../utils/media-single';
|
|
32
|
+
import { MediaTaskManager } from './mediaTaskManager';
|
|
33
|
+
import { stateKey } from './plugin-key';
|
|
34
|
+
export { stateKey } from './plugin-key';
|
|
35
|
+
export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
36
|
+
export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
|
|
37
|
+
export var MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
|
|
38
|
+
var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine) {
|
|
39
|
+
var dropPlaceholder = document.createElement('div');
|
|
40
|
+
var createElement = React.createElement;
|
|
41
|
+
if (allowDropLine) {
|
|
42
|
+
ReactDOM.render(createElement(RawIntlProvider, {
|
|
43
|
+
value: intl
|
|
44
|
+
}, createElement(DropPlaceholder, {
|
|
45
|
+
type: 'single'
|
|
46
|
+
})), dropPlaceholder);
|
|
47
|
+
} else {
|
|
48
|
+
ReactDOM.render(createElement(RawIntlProvider, {
|
|
49
|
+
value: intl
|
|
50
|
+
}, createElement(DropPlaceholder)), dropPlaceholder);
|
|
51
|
+
}
|
|
52
|
+
return dropPlaceholder;
|
|
53
|
+
};
|
|
54
|
+
var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
55
|
+
export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
56
|
+
function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, pluginInjectionApi) {
|
|
57
|
+
var _this = this;
|
|
58
|
+
_classCallCheck(this, MediaPluginStateImplementation);
|
|
59
|
+
_defineProperty(this, "allowsUploads", false);
|
|
60
|
+
_defineProperty(this, "ignoreLinks", false);
|
|
61
|
+
_defineProperty(this, "waitForMediaUpload", true);
|
|
62
|
+
_defineProperty(this, "allUploadsFinished", true);
|
|
63
|
+
_defineProperty(this, "showDropzone", false);
|
|
64
|
+
_defineProperty(this, "isFullscreen", false);
|
|
65
|
+
_defineProperty(this, "layout", 'center');
|
|
66
|
+
_defineProperty(this, "mediaNodes", []);
|
|
67
|
+
_defineProperty(this, "isResizing", false);
|
|
68
|
+
_defineProperty(this, "resizingWidth", 0);
|
|
69
|
+
_defineProperty(this, "destroyed", false);
|
|
70
|
+
_defineProperty(this, "removeOnCloseListener", function () {});
|
|
71
|
+
_defineProperty(this, "onPopupToggleCallback", function () {});
|
|
72
|
+
_defineProperty(this, "nodeCount", new Map());
|
|
73
|
+
_defineProperty(this, "taskManager", new MediaTaskManager());
|
|
74
|
+
_defineProperty(this, "pickers", []);
|
|
75
|
+
_defineProperty(this, "pickerPromises", []);
|
|
76
|
+
_defineProperty(this, "onContextIdentifierProvider", /*#__PURE__*/function () {
|
|
77
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, provider) {
|
|
78
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
if (!provider) {
|
|
82
|
+
_context.next = 4;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
_context.next = 3;
|
|
86
|
+
return provider;
|
|
87
|
+
case 3:
|
|
88
|
+
_this.contextIdentifierProvider = _context.sent;
|
|
89
|
+
case 4:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee);
|
|
94
|
+
}));
|
|
95
|
+
return function (_x, _x2) {
|
|
96
|
+
return _ref.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}());
|
|
99
|
+
_defineProperty(this, "setMediaProvider", /*#__PURE__*/function () {
|
|
100
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaProvider) {
|
|
101
|
+
var viewMediaClientConfig, wrappedError, view, allowsUploads;
|
|
102
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (mediaProvider) {
|
|
106
|
+
_context2.next = 5;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
_this.destroyPickers();
|
|
110
|
+
_this.allowsUploads = false;
|
|
111
|
+
if (!_this.destroyed) {
|
|
112
|
+
_this.view.dispatch(_this.view.state.tr.setMeta(stateKey, {
|
|
113
|
+
allowsUploads: _this.allowsUploads
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
return _context2.abrupt("return");
|
|
117
|
+
case 5:
|
|
118
|
+
_context2.prev = 5;
|
|
119
|
+
_context2.next = 8;
|
|
120
|
+
return mediaProvider;
|
|
121
|
+
case 8:
|
|
122
|
+
_this.mediaProvider = _context2.sent;
|
|
123
|
+
// TODO [MS-2038]: remove once context api is removed
|
|
124
|
+
// We want to re assign the view and upload configs if they are missing for backwards compatibility
|
|
125
|
+
// as currently integrators can pass context || mediaClientConfig
|
|
126
|
+
if (!_this.mediaProvider.viewMediaClientConfig) {
|
|
127
|
+
viewMediaClientConfig = _this.mediaProvider.viewMediaClientConfig;
|
|
128
|
+
if (viewMediaClientConfig) {
|
|
129
|
+
_this.mediaProvider.viewMediaClientConfig = viewMediaClientConfig;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
assert(_this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(_this.mediaProvider));
|
|
133
|
+
_context2.next = 21;
|
|
134
|
+
break;
|
|
135
|
+
case 13:
|
|
136
|
+
_context2.prev = 13;
|
|
137
|
+
_context2.t0 = _context2["catch"](5);
|
|
138
|
+
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)));
|
|
139
|
+
_this.errorReporter.captureException(wrappedError);
|
|
140
|
+
_this.destroyPickers();
|
|
141
|
+
_this.allowsUploads = false;
|
|
142
|
+
if (!_this.destroyed) {
|
|
143
|
+
_this.view.dispatch(_this.view.state.tr.setMeta(stateKey, {
|
|
144
|
+
allowsUploads: _this.allowsUploads
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
return _context2.abrupt("return");
|
|
148
|
+
case 21:
|
|
149
|
+
_this.mediaClientConfig = _this.mediaProvider.viewMediaClientConfig;
|
|
150
|
+
_this.allowsUploads = !!_this.mediaProvider.uploadMediaClientConfig;
|
|
151
|
+
view = _this.view, allowsUploads = _this.allowsUploads; // make sure editable DOM node is mounted
|
|
152
|
+
if (!_this.destroyed && view && view.dom.parentNode) {
|
|
153
|
+
// make PM plugin aware of the state change to update UI during 'apply' hook
|
|
154
|
+
view.dispatch(view.state.tr.setMeta(stateKey, {
|
|
155
|
+
allowsUploads: allowsUploads
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
if (!_this.allowsUploads) {
|
|
159
|
+
_context2.next = 35;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
_this.uploadMediaClientConfig = _this.mediaProvider.uploadMediaClientConfig;
|
|
163
|
+
if (!(_this.mediaProvider.uploadParams && _this.uploadMediaClientConfig)) {
|
|
164
|
+
_context2.next = 32;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
_context2.next = 30;
|
|
168
|
+
return _this.initPickers(_this.mediaProvider.uploadParams, PickerFacade);
|
|
169
|
+
case 30:
|
|
170
|
+
_context2.next = 33;
|
|
171
|
+
break;
|
|
172
|
+
case 32:
|
|
173
|
+
_this.destroyPickers();
|
|
174
|
+
case 33:
|
|
175
|
+
_context2.next = 36;
|
|
176
|
+
break;
|
|
177
|
+
case 35:
|
|
178
|
+
_this.destroyPickers();
|
|
179
|
+
case 36:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context2.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee2, null, [[5, 13]]);
|
|
184
|
+
}));
|
|
185
|
+
return function (_x3) {
|
|
186
|
+
return _ref2.apply(this, arguments);
|
|
187
|
+
};
|
|
188
|
+
}());
|
|
189
|
+
_defineProperty(this, "getMediaOptions", function () {
|
|
190
|
+
return _this.options;
|
|
191
|
+
});
|
|
192
|
+
_defineProperty(this, "isMediaSchemaNode", function (_ref3) {
|
|
193
|
+
var _this$mediaOptions;
|
|
194
|
+
var type = _ref3.type;
|
|
195
|
+
var _this$view$state$sche = _this.view.state.schema.nodes,
|
|
196
|
+
mediaInline = _this$view$state$sche.mediaInline,
|
|
197
|
+
mediaSingle = _this$view$state$sche.mediaSingle,
|
|
198
|
+
media = _this$view$state$sche.media;
|
|
199
|
+
if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions = _this.mediaOptions) === null || _this$mediaOptions === void 0 ? void 0 : _this$mediaOptions.featureFlags)) {
|
|
200
|
+
return type === mediaSingle || type === media || type === mediaInline;
|
|
201
|
+
}
|
|
202
|
+
return type === mediaSingle;
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* we insert a new file by inserting a initial state for that file.
|
|
206
|
+
*
|
|
207
|
+
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
208
|
+
*/
|
|
209
|
+
_defineProperty(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
210
|
+
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2;
|
|
211
|
+
var state = _this.view.state;
|
|
212
|
+
var editorAnalyticsAPI = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 || (_this$pluginInjection = _this$pluginInjection.analytics) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.actions;
|
|
213
|
+
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
214
|
+
contextId: _this.contextIdentifierProvider ? _this.contextIdentifierProvider.objectId : undefined
|
|
215
|
+
});
|
|
216
|
+
var collection = (_mediaState$collectio = mediaState.collection) !== null && _mediaState$collectio !== void 0 ? _mediaState$collectio : _this.collectionFromProvider();
|
|
217
|
+
if (collection === undefined) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// We need to dispatch the change to event dispatcher only for successful files
|
|
222
|
+
if (mediaState.status !== 'error') {
|
|
223
|
+
_this.updateAndDispatch({
|
|
224
|
+
allUploadsFinished: false
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
228
|
+
var _this$pluginInjection2;
|
|
229
|
+
// read width state right before inserting to get up-to-date and define values
|
|
230
|
+
var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
|
|
231
|
+
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
232
|
+
} else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
|
|
233
|
+
insertMediaInlineNode(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
234
|
+
} else {
|
|
235
|
+
insertMediaGroupNode(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// do events when media state changes
|
|
239
|
+
onMediaStateChanged(_this.handleMediaState);
|
|
240
|
+
|
|
241
|
+
// handle waiting for upload complete
|
|
242
|
+
var isEndState = function isEndState(state) {
|
|
243
|
+
return state.status && MEDIA_RESOLVED_STATES.indexOf(state.status) !== -1;
|
|
244
|
+
};
|
|
245
|
+
if (!isEndState(mediaStateWithContext)) {
|
|
246
|
+
var uploadingPromise = new Promise(function (resolve) {
|
|
247
|
+
onMediaStateChanged(function (newState) {
|
|
248
|
+
// When media item reaches its final state, remove listener and resolve
|
|
249
|
+
if (isEndState(newState)) {
|
|
250
|
+
resolve(newState);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
_this.taskManager.addPendingTask(uploadingPromise, mediaStateWithContext.id).then(function () {
|
|
255
|
+
_this.updateAndDispatch({
|
|
256
|
+
allUploadsFinished: true
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// refocus the view
|
|
262
|
+
var view = _this.view;
|
|
263
|
+
if (!view.hasFocus()) {
|
|
264
|
+
view.focus();
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
_defineProperty(this, "addPendingTask", function (task) {
|
|
268
|
+
_this.taskManager.addPendingTask(task);
|
|
269
|
+
});
|
|
270
|
+
_defineProperty(this, "splitMediaGroup", function () {
|
|
271
|
+
return splitMediaGroup(_this.view);
|
|
272
|
+
});
|
|
273
|
+
_defineProperty(this, "onPopupPickerClose", function () {
|
|
274
|
+
_this.onPopupToggleCallback(false);
|
|
275
|
+
});
|
|
276
|
+
_defineProperty(this, "showMediaPicker", function () {
|
|
277
|
+
if (_this.openMediaPickerBrowser) {
|
|
278
|
+
return _this.openMediaPickerBrowser();
|
|
279
|
+
}
|
|
280
|
+
_this.onPopupToggleCallback(true);
|
|
281
|
+
});
|
|
282
|
+
_defineProperty(this, "setBrowseFn", function (browseFn) {
|
|
283
|
+
_this.openMediaPickerBrowser = browseFn;
|
|
284
|
+
});
|
|
285
|
+
_defineProperty(this, "onPopupToggle", function (onPopupToggleCallback) {
|
|
286
|
+
_this.onPopupToggleCallback = onPopupToggleCallback;
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* Returns a promise that is resolved after all pending operations have been finished.
|
|
290
|
+
* An optional timeout will cause the promise to reject if the operation takes too long
|
|
291
|
+
*
|
|
292
|
+
* NOTE: The promise will resolve even if some of the media have failed to process.
|
|
293
|
+
*/
|
|
294
|
+
_defineProperty(this, "waitForPendingTasks", this.taskManager.waitForPendingTasks);
|
|
295
|
+
/**
|
|
296
|
+
* Called from React UI Component when user clicks on "Delete" icon
|
|
297
|
+
* inside of it
|
|
298
|
+
*/
|
|
299
|
+
_defineProperty(this, "handleMediaNodeRemoval", function (node, getPos) {
|
|
300
|
+
var getNode = node;
|
|
301
|
+
if (!getNode) {
|
|
302
|
+
var pos = getPos();
|
|
303
|
+
if (typeof pos !== 'number') {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
getNode = _this.view.state.doc.nodeAt(pos);
|
|
307
|
+
}
|
|
308
|
+
removeMediaNode(_this.view, getNode, getPos);
|
|
309
|
+
});
|
|
310
|
+
_defineProperty(this, "trackMediaNodeAddition", function (node) {
|
|
311
|
+
var _this$nodeCount$get;
|
|
312
|
+
var id = node.attrs.id;
|
|
313
|
+
var count = (_this$nodeCount$get = _this.nodeCount.get(id)) !== null && _this$nodeCount$get !== void 0 ? _this$nodeCount$get : 0;
|
|
314
|
+
if (count === 0) {
|
|
315
|
+
_this.taskManager.resumePendingTask(id);
|
|
316
|
+
}
|
|
317
|
+
_this.nodeCount.set(id, count + 1);
|
|
318
|
+
});
|
|
319
|
+
_defineProperty(this, "trackMediaNodeRemoval", function (node) {
|
|
320
|
+
var _this$nodeCount$get2;
|
|
321
|
+
var id = node.attrs.id;
|
|
322
|
+
var count = (_this$nodeCount$get2 = _this.nodeCount.get(id)) !== null && _this$nodeCount$get2 !== void 0 ? _this$nodeCount$get2 : 0;
|
|
323
|
+
if (count === 1) {
|
|
324
|
+
_this.taskManager.cancelPendingTask(id);
|
|
325
|
+
}
|
|
326
|
+
_this.nodeCount.set(id, count - 1);
|
|
327
|
+
});
|
|
328
|
+
/**
|
|
329
|
+
* Called from React UI Component on componentDidMount
|
|
330
|
+
*/
|
|
331
|
+
_defineProperty(this, "handleMediaNodeMount", function (node, getPos) {
|
|
332
|
+
_this.trackMediaNodeAddition(node);
|
|
333
|
+
_this.mediaNodes.unshift({
|
|
334
|
+
node: node,
|
|
335
|
+
getPos: getPos
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
/**
|
|
339
|
+
* Called from React UI Component on componentWillUnmount and UNSAFE_componentWillReceiveProps
|
|
340
|
+
* when React component's underlying node property is replaced with a new node
|
|
341
|
+
*/
|
|
342
|
+
_defineProperty(this, "handleMediaNodeUnmount", function (oldNode) {
|
|
343
|
+
_this.trackMediaNodeRemoval(oldNode);
|
|
344
|
+
_this.mediaNodes = _this.mediaNodes.filter(function (_ref4) {
|
|
345
|
+
var node = _ref4.node;
|
|
346
|
+
return oldNode !== node;
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
_defineProperty(this, "handleMediaGroupUpdate", function (oldNodes, newNodes) {
|
|
350
|
+
var addedNodes = newNodes.filter(function (node) {
|
|
351
|
+
return oldNodes.every(function (oldNode) {
|
|
352
|
+
return oldNode.attrs.id !== node.attrs.id;
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
var removedNodes = oldNodes.filter(function (node) {
|
|
356
|
+
return newNodes.every(function (newNode) {
|
|
357
|
+
return newNode.attrs.id !== node.attrs.id;
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
addedNodes.forEach(function (node) {
|
|
361
|
+
_this.trackMediaNodeAddition(node);
|
|
362
|
+
});
|
|
363
|
+
removedNodes.forEach(function (oldNode) {
|
|
364
|
+
_this.trackMediaNodeRemoval(oldNode);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
_defineProperty(this, "findMediaNode", function (id) {
|
|
368
|
+
return helpers.findMediaSingleNode(_this, id);
|
|
369
|
+
});
|
|
370
|
+
_defineProperty(this, "destroyAllPickers", function (pickers) {
|
|
371
|
+
pickers.forEach(function (picker) {
|
|
372
|
+
return picker.destroy();
|
|
373
|
+
});
|
|
374
|
+
_this.pickers.splice(0, _this.pickers.length);
|
|
375
|
+
});
|
|
376
|
+
_defineProperty(this, "destroyPickers", function () {
|
|
377
|
+
var pickers = _this.pickers,
|
|
378
|
+
pickerPromises = _this.pickerPromises;
|
|
379
|
+
|
|
380
|
+
// If pickerPromises and pickers are the same length
|
|
381
|
+
// All pickers have resolved and we safely destroy them
|
|
382
|
+
// Otherwise wait for them to resolve then destroy.
|
|
383
|
+
if (pickerPromises.length === pickers.length) {
|
|
384
|
+
_this.destroyAllPickers(_this.pickers);
|
|
385
|
+
} else {
|
|
386
|
+
Promise.all(pickerPromises).then(function (resolvedPickers) {
|
|
387
|
+
return _this.destroyAllPickers(resolvedPickers);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
_this.customPicker = undefined;
|
|
391
|
+
});
|
|
392
|
+
_defineProperty(this, "getInputMethod", function (pickerType) {
|
|
393
|
+
switch (pickerType) {
|
|
394
|
+
case 'clipboard':
|
|
395
|
+
return INPUT_METHOD.CLIPBOARD;
|
|
396
|
+
case 'dropzone':
|
|
397
|
+
return INPUT_METHOD.DRAG_AND_DROP;
|
|
398
|
+
}
|
|
399
|
+
return;
|
|
400
|
+
});
|
|
401
|
+
_defineProperty(this, "updateMediaSingleNodeAttrs", function (id, attrs) {
|
|
402
|
+
var view = _this.view;
|
|
403
|
+
if (!view) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
return updateMediaSingleNodeAttrs(id, attrs)(view.state, view.dispatch);
|
|
407
|
+
});
|
|
408
|
+
_defineProperty(this, "handleMediaState", function (state) {
|
|
409
|
+
switch (state.status) {
|
|
410
|
+
case 'error':
|
|
411
|
+
var uploadErrorHandler = _this.options.uploadErrorHandler;
|
|
412
|
+
if (uploadErrorHandler) {
|
|
413
|
+
uploadErrorHandler(state);
|
|
414
|
+
}
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
_defineProperty(this, "removeSelectedMediaContainer", function () {
|
|
419
|
+
var view = _this.view;
|
|
420
|
+
var selectedNode = _this.selectedMediaContainerNode();
|
|
421
|
+
if (!selectedNode) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
var from = view.state.selection.from;
|
|
425
|
+
removeMediaNode(view, selectedNode.firstChild, function () {
|
|
426
|
+
return from + 1;
|
|
427
|
+
});
|
|
428
|
+
return true;
|
|
429
|
+
});
|
|
430
|
+
_defineProperty(this, "selectedMediaContainerNode", function () {
|
|
431
|
+
var selection = _this.view.state.selection;
|
|
432
|
+
if (selection instanceof NodeSelection && _this.isMediaSchemaNode(selection.node)) {
|
|
433
|
+
return selection.node;
|
|
434
|
+
}
|
|
435
|
+
return;
|
|
436
|
+
});
|
|
437
|
+
_defineProperty(this, "handleDrag", function (dragState) {
|
|
438
|
+
var isActive = dragState === 'enter';
|
|
439
|
+
if (_this.showDropzone === isActive) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
_this.showDropzone = isActive;
|
|
443
|
+
var _this$view = _this.view,
|
|
444
|
+
dispatch = _this$view.dispatch,
|
|
445
|
+
state = _this$view.state;
|
|
446
|
+
var tr = state.tr,
|
|
447
|
+
selection = state.selection,
|
|
448
|
+
doc = state.doc;
|
|
449
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
450
|
+
media = _state$schema$nodes.media,
|
|
451
|
+
mediaGroup = _state$schema$nodes.mediaGroup;
|
|
452
|
+
|
|
453
|
+
// Workaround for wrong upload position
|
|
454
|
+
// @see https://product-fabric.atlassian.net/browse/MEX-2457
|
|
455
|
+
// If the media node is the last selectable item in the current cursor position and it is located within a mediaGroup,
|
|
456
|
+
// we relocate the cursor to the first child of the mediaGroup.
|
|
457
|
+
var sel = Selection.findFrom(doc.resolve(selection.$from.pos - 1), -1);
|
|
458
|
+
if (sel && findSelectedNodeOfType(media)(sel)) {
|
|
459
|
+
var parent = findParentNodeOfType(mediaGroup)(sel);
|
|
460
|
+
if (parent) {
|
|
461
|
+
tr.setSelection(NodeSelection.create(tr.doc, parent.start));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Trigger state change to be able to pick it up in the decorations handler
|
|
466
|
+
dispatch(tr);
|
|
467
|
+
});
|
|
468
|
+
this.options = options;
|
|
469
|
+
this.mediaOptions = mediaOptions;
|
|
470
|
+
this.newInsertionBehaviour = newInsertionBehaviour;
|
|
471
|
+
this.dispatch = _dispatch;
|
|
472
|
+
this.pluginInjectionApi = pluginInjectionApi;
|
|
473
|
+
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
474
|
+
var nodes = _state.schema.nodes;
|
|
475
|
+
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
476
|
+
options.providerFactory.subscribe('mediaProvider', function (_name, provider) {
|
|
477
|
+
return _this.setMediaProvider(provider);
|
|
478
|
+
});
|
|
479
|
+
options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
|
|
480
|
+
this.errorReporter = options.errorReporter || new ErrorReporter();
|
|
481
|
+
this.singletonCreatedAt = (performance || Date).now();
|
|
482
|
+
}
|
|
483
|
+
_createClass(MediaPluginStateImplementation, [{
|
|
484
|
+
key: "clone",
|
|
485
|
+
value: function clone() {
|
|
486
|
+
var clonedAt = (performance || Date).now();
|
|
487
|
+
return new Proxy(this, {
|
|
488
|
+
get: function get(target, prop, receiver) {
|
|
489
|
+
if (prop === 'singletonCreatedAt') {
|
|
490
|
+
return clonedAt;
|
|
491
|
+
}
|
|
492
|
+
return Reflect.get(target, prop, receiver);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
}, {
|
|
497
|
+
key: "setIsResizing",
|
|
498
|
+
value: function setIsResizing(isResizing) {
|
|
499
|
+
this.isResizing = isResizing;
|
|
500
|
+
}
|
|
501
|
+
}, {
|
|
502
|
+
key: "setResizingWidth",
|
|
503
|
+
value: function setResizingWidth(width) {
|
|
504
|
+
this.resizingWidth = width;
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
key: "updateElement",
|
|
508
|
+
value: function updateElement() {
|
|
509
|
+
var newElement;
|
|
510
|
+
var selectedContainer = this.selectedMediaContainerNode();
|
|
511
|
+
if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
|
|
512
|
+
newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
|
|
513
|
+
if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
|
|
514
|
+
this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
|
|
515
|
+
} else {
|
|
516
|
+
this.currentMaxWidth = undefined;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (this.element !== newElement) {
|
|
520
|
+
this.element = newElement;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}, {
|
|
524
|
+
key: "getDomElement",
|
|
525
|
+
value: function getDomElement(domAtPos) {
|
|
526
|
+
var selection = this.view.state.selection;
|
|
527
|
+
if (!(selection instanceof NodeSelection)) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (!this.isMediaSchemaNode(selection.node)) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
var node = findDomRefAtPos(selection.from, domAtPos);
|
|
534
|
+
if (node) {
|
|
535
|
+
if (!node.childNodes.length) {
|
|
536
|
+
return node.parentNode;
|
|
537
|
+
}
|
|
538
|
+
return node;
|
|
539
|
+
}
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
key: "setView",
|
|
544
|
+
value: function setView(view) {
|
|
545
|
+
this.view = view;
|
|
546
|
+
}
|
|
547
|
+
}, {
|
|
548
|
+
key: "destroy",
|
|
549
|
+
value: function destroy() {
|
|
550
|
+
if (this.destroyed) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
this.destroyed = true;
|
|
554
|
+
var mediaNodes = this.mediaNodes;
|
|
555
|
+
mediaNodes.splice(0, mediaNodes.length);
|
|
556
|
+
this.removeOnCloseListener();
|
|
557
|
+
this.destroyPickers();
|
|
558
|
+
}
|
|
559
|
+
}, {
|
|
560
|
+
key: "initPickers",
|
|
561
|
+
value: function () {
|
|
562
|
+
var _initPickers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(uploadParams, Picker) {
|
|
563
|
+
var _this2 = this;
|
|
564
|
+
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker;
|
|
565
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
566
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
567
|
+
case 0:
|
|
568
|
+
if (!(this.destroyed || !this.uploadMediaClientConfig)) {
|
|
569
|
+
_context3.next = 2;
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
return _context3.abrupt("return");
|
|
573
|
+
case 2:
|
|
574
|
+
errorReporter = this.errorReporter, pickers = this.pickers, pickerPromises = this.pickerPromises; // create pickers if they don't exist, re-use otherwise
|
|
575
|
+
if (pickers.length) {
|
|
576
|
+
_context3.next = 14;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
pickerFacadeConfig = {
|
|
580
|
+
mediaClientConfig: this.uploadMediaClientConfig,
|
|
581
|
+
errorReporter: errorReporter
|
|
582
|
+
};
|
|
583
|
+
if (!this.options.customMediaPicker) {
|
|
584
|
+
_context3.next = 13;
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
customPicker = new Picker('customMediaPicker', pickerFacadeConfig, this.options.customMediaPicker).init();
|
|
588
|
+
pickerPromises.push(customPicker);
|
|
589
|
+
_context3.t0 = pickers;
|
|
590
|
+
_context3.next = 11;
|
|
591
|
+
return customPicker;
|
|
592
|
+
case 11:
|
|
593
|
+
_context3.t1 = this.customPicker = _context3.sent;
|
|
594
|
+
_context3.t0.push.call(_context3.t0, _context3.t1);
|
|
595
|
+
case 13:
|
|
596
|
+
pickers.forEach(function (picker) {
|
|
597
|
+
picker.onNewMedia(_this2.insertFile);
|
|
598
|
+
});
|
|
599
|
+
case 14:
|
|
600
|
+
// set new upload params for the pickers
|
|
601
|
+
pickers.forEach(function (picker) {
|
|
602
|
+
return picker.setUploadParams(uploadParams);
|
|
603
|
+
});
|
|
604
|
+
case 15:
|
|
605
|
+
case "end":
|
|
606
|
+
return _context3.stop();
|
|
607
|
+
}
|
|
608
|
+
}, _callee3, this);
|
|
609
|
+
}));
|
|
610
|
+
function initPickers(_x4, _x5) {
|
|
611
|
+
return _initPickers.apply(this, arguments);
|
|
612
|
+
}
|
|
613
|
+
return initPickers;
|
|
614
|
+
}()
|
|
615
|
+
}, {
|
|
616
|
+
key: "collectionFromProvider",
|
|
617
|
+
value: function collectionFromProvider() {
|
|
618
|
+
return this.mediaProvider && this.mediaProvider.uploadParams && this.mediaProvider.uploadParams.collection;
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
key: "updateAndDispatch",
|
|
622
|
+
value: function updateAndDispatch(props) {
|
|
623
|
+
var _this3 = this;
|
|
624
|
+
// update plugin state
|
|
625
|
+
Object.keys(props).forEach(function (_key) {
|
|
626
|
+
var key = _key;
|
|
627
|
+
var value = props[key];
|
|
628
|
+
if (value !== undefined) {
|
|
629
|
+
_this3[key] = value;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
if (this.dispatch) {
|
|
633
|
+
this.dispatch(stateKey, _objectSpread({}, this));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}]);
|
|
637
|
+
return MediaPluginStateImplementation;
|
|
638
|
+
}();
|
|
639
|
+
export var getMediaPluginState = function getMediaPluginState(state) {
|
|
640
|
+
return stateKey.getState(state);
|
|
641
|
+
};
|
|
642
|
+
export var createPlugin = function createPlugin(_schema, options, reactContext, getIntl, pluginInjectionApi, dispatch, mediaOptions, newInsertionBehaviour) {
|
|
643
|
+
var intl = getIntl();
|
|
644
|
+
var dropPlaceholder = createDropPlaceholder(intl, mediaOptions && mediaOptions.allowDropzoneDropLine);
|
|
645
|
+
return new SafePlugin({
|
|
646
|
+
state: {
|
|
647
|
+
init: function init(_config, state) {
|
|
648
|
+
return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch, pluginInjectionApi);
|
|
649
|
+
},
|
|
650
|
+
apply: function apply(tr, pluginState) {
|
|
651
|
+
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
652
|
+
var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
653
|
+
// Yes, I agree with you; this approach, using the clone() fuction, below is horrifying.
|
|
654
|
+
// However, we needed to implement this workaround to solve the singleton Media PluginState.
|
|
655
|
+
// The entire PluginInjectionAPI relies on the following axiom: "A PluginState that reflects a new EditorState.". We can not have the mutable singleton instance for all EditorState.
|
|
656
|
+
// Unfortunately, we can't implement a proper fix for this media state situation. So, we are faking a new object using a Proxy instance.
|
|
657
|
+
var nextPluginState = pluginState;
|
|
658
|
+
if (isResizing !== undefined) {
|
|
659
|
+
pluginState.setIsResizing(isResizing);
|
|
660
|
+
nextPluginState = nextPluginState.clone();
|
|
661
|
+
}
|
|
662
|
+
if (resizingWidth) {
|
|
663
|
+
pluginState.setResizingWidth(resizingWidth);
|
|
664
|
+
nextPluginState = nextPluginState.clone();
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// remap editing media single position if we're in collab
|
|
668
|
+
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
669
|
+
pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
|
|
670
|
+
nextPluginState = nextPluginState.clone();
|
|
671
|
+
}
|
|
672
|
+
var meta = tr.getMeta(stateKey);
|
|
673
|
+
if (meta) {
|
|
674
|
+
var allowsUploads = meta.allowsUploads;
|
|
675
|
+
pluginState.updateAndDispatch({
|
|
676
|
+
allowsUploads: typeof allowsUploads === 'undefined' ? pluginState.allowsUploads : allowsUploads
|
|
677
|
+
});
|
|
678
|
+
nextPluginState = nextPluginState.clone();
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
|
|
682
|
+
// throughout the lifetime of view. We injected the view into the plugin state, because we dispatch()
|
|
683
|
+
// transformations from within the plugin state (i.e. when adding a new file).
|
|
684
|
+
return nextPluginState;
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
688
|
+
var _iterator = _createForOfIteratorHelper(transactions),
|
|
689
|
+
_step;
|
|
690
|
+
try {
|
|
691
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
692
|
+
var transaction = _step.value;
|
|
693
|
+
var isSelectionOnMediaInsideMediaSingle = transaction.selectionSet && isNodeSelection(transaction.selection) && transaction.selection.node.type === newState.schema.nodes.media && transaction.selection.$anchor.parent.type === newState.schema.nodes.mediaSingle;
|
|
694
|
+
|
|
695
|
+
// Note: this causes an additional transaction when selecting a media node
|
|
696
|
+
// through clicking on it with the cursor.
|
|
697
|
+
if (isSelectionOnMediaInsideMediaSingle) {
|
|
698
|
+
// If a selection has been placed on a media inside a media single,
|
|
699
|
+
// we shift it to the media single parent as other code is opinionated about
|
|
700
|
+
// the selection landing there. In particular the caption insertion and selection
|
|
701
|
+
// action.
|
|
702
|
+
return newState.tr.setSelection(NodeSelection.create(newState.doc, transaction.selection.$from.pos - 1));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
} catch (err) {
|
|
706
|
+
_iterator.e(err);
|
|
707
|
+
} finally {
|
|
708
|
+
_iterator.f();
|
|
709
|
+
}
|
|
710
|
+
return;
|
|
711
|
+
},
|
|
712
|
+
key: stateKey,
|
|
713
|
+
view: function view(_view) {
|
|
714
|
+
var pluginState = getMediaPluginState(_view.state);
|
|
715
|
+
pluginState.setView(_view);
|
|
716
|
+
pluginState.updateElement();
|
|
717
|
+
return {
|
|
718
|
+
update: function update() {
|
|
719
|
+
pluginState.updateElement();
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
},
|
|
723
|
+
props: {
|
|
724
|
+
decorations: function decorations(state) {
|
|
725
|
+
// Use this to indicate that the media node is selected
|
|
726
|
+
var mediaNodes = [];
|
|
727
|
+
var schema = state.schema,
|
|
728
|
+
$anchor = state.selection.$anchor,
|
|
729
|
+
doc = state.doc;
|
|
730
|
+
|
|
731
|
+
// Find any media nodes in the current selection
|
|
732
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
733
|
+
doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
|
|
734
|
+
if (node.type === schema.nodes.media) {
|
|
735
|
+
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
736
|
+
type: 'media',
|
|
737
|
+
selected: true
|
|
738
|
+
}));
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
return true;
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
var pluginState = getMediaPluginState(state);
|
|
745
|
+
if (!pluginState.showDropzone) {
|
|
746
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// When a media is already selected
|
|
750
|
+
if (state.selection instanceof NodeSelection) {
|
|
751
|
+
var node = state.selection.node;
|
|
752
|
+
if (node.type === schema.nodes.mediaSingle) {
|
|
753
|
+
var deco = Decoration.node(state.selection.from, state.selection.to, {
|
|
754
|
+
class: 'richMedia-selected'
|
|
755
|
+
});
|
|
756
|
+
return DecorationSet.create(state.doc, [deco].concat(mediaNodes));
|
|
757
|
+
}
|
|
758
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
759
|
+
}
|
|
760
|
+
var pos = $anchor.pos;
|
|
761
|
+
if ($anchor.parent.type !== schema.nodes.paragraph && $anchor.parent.type !== schema.nodes.codeBlock) {
|
|
762
|
+
pos = insertPoint(state.doc, pos, schema.nodes.mediaGroup);
|
|
763
|
+
}
|
|
764
|
+
if (pos === null || pos === undefined) {
|
|
765
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
766
|
+
}
|
|
767
|
+
var dropPlaceholders = [Decoration.widget(pos, dropPlaceholder, {
|
|
768
|
+
key: 'drop-placeholder'
|
|
769
|
+
})].concat(mediaNodes);
|
|
770
|
+
return DecorationSet.create(state.doc, dropPlaceholders);
|
|
771
|
+
},
|
|
772
|
+
nodeViews: options.nodeViews,
|
|
773
|
+
handleTextInput: function handleTextInput(view) {
|
|
774
|
+
getMediaPluginState(view.state).splitMediaGroup();
|
|
775
|
+
return false;
|
|
776
|
+
},
|
|
777
|
+
handleClick: function handleClick(_editorView, _pos, event) {
|
|
778
|
+
var _event$target;
|
|
779
|
+
var clickedInsideCaptionPlaceholder = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest("[data-id=\"".concat(CAPTION_PLACEHOLDER_ID, "\"]"));
|
|
780
|
+
|
|
781
|
+
// Workaround for Chrome given a regression introduced in prosemirror-view@1.18.6
|
|
782
|
+
// Returning true prevents that updateSelection() is getting called in the commit below:
|
|
783
|
+
// @see https://github.com/ProseMirror/prosemirror-view/compare/1.18.5...1.18.6
|
|
784
|
+
if ((browser.chrome || browser.safari) && clickedInsideCaptionPlaceholder) {
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Workaound for iOS 16 Caption selection issue
|
|
789
|
+
// @see https://product-fabric.atlassian.net/browse/MEX-2012
|
|
790
|
+
if (browser.ios) {
|
|
791
|
+
var _event$target2;
|
|
792
|
+
return !!((_event$target2 = event.target) !== null && _event$target2 !== void 0 && _event$target2.closest("[class=\"".concat(MEDIA_CONTENT_WRAP_CLASS_NAME, "\"]")));
|
|
793
|
+
}
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
};
|