@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,513 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { buildLayoutButtons } from '@atlaskit/editor-common/card';
|
|
8
|
+
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
9
|
+
import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import { findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
12
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
13
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
14
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
15
|
+
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
16
|
+
import { messages } from '@atlaskit/media-ui';
|
|
17
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
18
|
+
import { showLinkingToolbar } from '../commands/linking';
|
|
19
|
+
import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/styles';
|
|
20
|
+
import { getPluginState as getMediaAltTextPluginState } from '../pm-plugins/alt-text';
|
|
21
|
+
import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
22
|
+
import { stateKey } from '../pm-plugins/plugin-key';
|
|
23
|
+
import ImageBorderItem from '../ui/ImageBorder';
|
|
24
|
+
import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
|
|
25
|
+
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
26
|
+
import { isVideo } from '../utils/media-single';
|
|
27
|
+
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
28
|
+
import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
29
|
+
import { FilePreviewItem } from './filePreviewItem';
|
|
30
|
+
import { shouldShowImageBorder } from './imageBorder';
|
|
31
|
+
import { getLinkingToolbar, shouldShowMediaLinkToolbar } from './linking';
|
|
32
|
+
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
33
|
+
import { calcNewLayout, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
34
|
+
var remove = function remove(state, dispatch) {
|
|
35
|
+
if (dispatch) {
|
|
36
|
+
dispatch(removeSelectedNode(state.tr));
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
|
|
41
|
+
var tr = removeMediaGroupNode(state);
|
|
42
|
+
if (dispatch) {
|
|
43
|
+
dispatch(tr);
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
48
|
+
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
49
|
+
var items = [{
|
|
50
|
+
id: 'editor.media.view.switcher',
|
|
51
|
+
type: 'dropdown',
|
|
52
|
+
title: intl.formatMessage(messages.changeView),
|
|
53
|
+
options: [{
|
|
54
|
+
id: 'editor.media.view.switcher.inline',
|
|
55
|
+
title: intl.formatMessage(cardMessages.inline),
|
|
56
|
+
selected: false,
|
|
57
|
+
disabled: false,
|
|
58
|
+
onClick: changeMediaCardToInline(editorAnalyticsAPI),
|
|
59
|
+
testId: 'inline-appearance'
|
|
60
|
+
}, {
|
|
61
|
+
id: 'editor.media.view.switcher.thumbnail',
|
|
62
|
+
title: intl.formatMessage(messages.displayThumbnail),
|
|
63
|
+
selected: true,
|
|
64
|
+
disabled: false,
|
|
65
|
+
onClick: function onClick() {
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
testId: 'thumbnail-appearance'
|
|
69
|
+
}]
|
|
70
|
+
}, {
|
|
71
|
+
type: 'separator'
|
|
72
|
+
}, {
|
|
73
|
+
type: 'custom',
|
|
74
|
+
fallback: [],
|
|
75
|
+
render: function render() {
|
|
76
|
+
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
77
|
+
key: "editor.media.card.preview",
|
|
78
|
+
mediaPluginState: mediaPluginState,
|
|
79
|
+
intl: intl
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
type: 'separator'
|
|
84
|
+
}, {
|
|
85
|
+
id: 'editor.media.card.download',
|
|
86
|
+
type: 'button',
|
|
87
|
+
icon: DownloadIcon,
|
|
88
|
+
onClick: function onClick() {
|
|
89
|
+
downloadMedia(mediaPluginState);
|
|
90
|
+
return true;
|
|
91
|
+
},
|
|
92
|
+
title: intl.formatMessage(messages.download)
|
|
93
|
+
}, {
|
|
94
|
+
type: 'separator'
|
|
95
|
+
}, {
|
|
96
|
+
type: 'copy-button',
|
|
97
|
+
items: [{
|
|
98
|
+
state: state,
|
|
99
|
+
formatMessage: intl.formatMessage,
|
|
100
|
+
nodeType: mediaGroup
|
|
101
|
+
}, {
|
|
102
|
+
type: 'separator'
|
|
103
|
+
}]
|
|
104
|
+
}, {
|
|
105
|
+
id: 'editor.media.delete',
|
|
106
|
+
type: 'button',
|
|
107
|
+
appearance: 'danger',
|
|
108
|
+
focusEditoronEnter: true,
|
|
109
|
+
icon: RemoveIcon,
|
|
110
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
|
|
111
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
|
|
112
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
|
|
113
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
|
|
114
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
115
|
+
onClick: handleRemoveMediaGroup,
|
|
116
|
+
testId: 'media-toolbar-remove-button'
|
|
117
|
+
}];
|
|
118
|
+
return items;
|
|
119
|
+
};
|
|
120
|
+
var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
121
|
+
var mediaInline = state.schema.nodes.mediaInline;
|
|
122
|
+
var items = [{
|
|
123
|
+
id: 'editor.media.view.switcher',
|
|
124
|
+
type: 'dropdown',
|
|
125
|
+
title: intl.formatMessage(messages.changeView),
|
|
126
|
+
options: [{
|
|
127
|
+
id: 'editor.media.view.switcher.inline',
|
|
128
|
+
title: intl.formatMessage(cardMessages.inline),
|
|
129
|
+
selected: true,
|
|
130
|
+
disabled: false,
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
return true;
|
|
133
|
+
},
|
|
134
|
+
testId: 'inline-appearance'
|
|
135
|
+
}, {
|
|
136
|
+
id: 'editor.media.view.switcher.thumbnail',
|
|
137
|
+
title: intl.formatMessage(messages.displayThumbnail),
|
|
138
|
+
selected: false,
|
|
139
|
+
disabled: false,
|
|
140
|
+
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
141
|
+
testId: 'thumbnail-appearance'
|
|
142
|
+
}]
|
|
143
|
+
}, {
|
|
144
|
+
type: 'separator'
|
|
145
|
+
}, {
|
|
146
|
+
type: 'custom',
|
|
147
|
+
fallback: [],
|
|
148
|
+
render: function render() {
|
|
149
|
+
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
150
|
+
key: "editor.media.card.preview",
|
|
151
|
+
mediaPluginState: mediaPluginState,
|
|
152
|
+
intl: intl
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
type: 'separator'
|
|
157
|
+
}, {
|
|
158
|
+
id: 'editor.media.card.download',
|
|
159
|
+
type: 'button',
|
|
160
|
+
icon: DownloadIcon,
|
|
161
|
+
onClick: function onClick() {
|
|
162
|
+
downloadMedia(mediaPluginState);
|
|
163
|
+
return true;
|
|
164
|
+
},
|
|
165
|
+
title: intl.formatMessage(messages.download)
|
|
166
|
+
}, {
|
|
167
|
+
type: 'separator'
|
|
168
|
+
}, {
|
|
169
|
+
type: 'copy-button',
|
|
170
|
+
items: [{
|
|
171
|
+
state: state,
|
|
172
|
+
formatMessage: intl.formatMessage,
|
|
173
|
+
nodeType: mediaInline
|
|
174
|
+
}, {
|
|
175
|
+
type: 'separator'
|
|
176
|
+
}]
|
|
177
|
+
}, {
|
|
178
|
+
id: 'editor.media.delete',
|
|
179
|
+
type: 'button',
|
|
180
|
+
appearance: 'danger',
|
|
181
|
+
focusEditoronEnter: true,
|
|
182
|
+
icon: RemoveIcon,
|
|
183
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
184
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
185
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
186
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
187
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
188
|
+
onClick: removeInlineCard,
|
|
189
|
+
testId: 'media-toolbar-remove-button'
|
|
190
|
+
}];
|
|
191
|
+
return items;
|
|
192
|
+
};
|
|
193
|
+
var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
|
|
194
|
+
var _pluginInjectionApi$d;
|
|
195
|
+
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
196
|
+
var allowResizing = options.allowResizing,
|
|
197
|
+
allowLinking = options.allowLinking,
|
|
198
|
+
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
|
|
199
|
+
allowResizingInTables = options.allowResizingInTables,
|
|
200
|
+
allowAltTextOnImages = options.allowAltTextOnImages;
|
|
201
|
+
var toolbarButtons = [];
|
|
202
|
+
var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
203
|
+
hoverDecoration = _ref.hoverDecoration;
|
|
204
|
+
if (shouldShowImageBorder(state)) {
|
|
205
|
+
toolbarButtons.push({
|
|
206
|
+
type: 'custom',
|
|
207
|
+
fallback: [],
|
|
208
|
+
render: function render(editorView) {
|
|
209
|
+
if (!editorView) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
var dispatch = editorView.dispatch,
|
|
213
|
+
state = editorView.state;
|
|
214
|
+
var borderMark = currentMediaNodeBorderMark(state);
|
|
215
|
+
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
216
|
+
toggleBorder: function toggleBorder() {
|
|
217
|
+
var _pluginInjectionApi$a;
|
|
218
|
+
toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(state, dispatch);
|
|
219
|
+
},
|
|
220
|
+
setBorder: function setBorder(attrs) {
|
|
221
|
+
var _pluginInjectionApi$a2;
|
|
222
|
+
setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(attrs)(state, dispatch);
|
|
223
|
+
},
|
|
224
|
+
borderMark: borderMark,
|
|
225
|
+
intl: intl
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
toolbarButtons.push({
|
|
230
|
+
type: 'separator'
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (allowAdvancedToolBarOptions) {
|
|
234
|
+
var _pluginInjectionApi$a3;
|
|
235
|
+
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
|
|
236
|
+
var isChangingLayoutDisabled = false;
|
|
237
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
238
|
+
var _widthPlugin$sharedSt;
|
|
239
|
+
var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
240
|
+
var selectedNode = getSelectedMediaSingle(state);
|
|
241
|
+
var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
|
|
242
|
+
if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
|
|
243
|
+
isChangingLayoutDisabled = true;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
|
|
247
|
+
toolbarButtons = [].concat(_toConsumableArray(toolbarButtons), _toConsumableArray(layoutButtons));
|
|
248
|
+
if (layoutButtons.length) {
|
|
249
|
+
toolbarButtons.push({
|
|
250
|
+
type: 'separator'
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Pixel Entry Toolbar Support
|
|
255
|
+
var selection = state.selection;
|
|
256
|
+
var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
257
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience') && allowResizing && (!isWithinTable || allowResizingInTables === true)) {
|
|
258
|
+
var selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
259
|
+
var sizeInput = {
|
|
260
|
+
type: 'custom',
|
|
261
|
+
fallback: [],
|
|
262
|
+
render: function render(editorView) {
|
|
263
|
+
var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
|
|
264
|
+
if (!editorView || !selectedMediaSingleNode) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
var state = editorView.state,
|
|
268
|
+
dispatch = editorView.dispatch;
|
|
269
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
|
|
270
|
+
var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
271
|
+
if (!selectedMediaNode) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
275
|
+
mediaSingleWidth = _selectedMediaSingleN.width,
|
|
276
|
+
widthType = _selectedMediaSingleN.widthType,
|
|
277
|
+
layout = _selectedMediaSingleN.layout;
|
|
278
|
+
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
279
|
+
mediaWidth = _selectedMediaNode$at.width,
|
|
280
|
+
mediaHeight = _selectedMediaNode$at.height;
|
|
281
|
+
var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
|
|
282
|
+
var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
283
|
+
var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
284
|
+
var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
285
|
+
var isLegacy = widthType !== 'pixel';
|
|
286
|
+
var pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
287
|
+
// get pos of media node
|
|
288
|
+
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
289
|
+
var pixelWidth = isLegacy ? pixelWidthFromElement : mediaSingleWidth;
|
|
290
|
+
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
291
|
+
intl: intl,
|
|
292
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
293
|
+
showMigration: !pluginState.isResizing && isLegacy,
|
|
294
|
+
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
295
|
+
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
296
|
+
minWidth: minWidth,
|
|
297
|
+
maxWidth: maxWidth,
|
|
298
|
+
onChange: function onChange(valid) {
|
|
299
|
+
if (valid) {
|
|
300
|
+
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
301
|
+
} else {
|
|
302
|
+
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
onSubmit: function onSubmit(_ref2) {
|
|
306
|
+
var _pluginInjectionApi$a4;
|
|
307
|
+
var width = _ref2.width,
|
|
308
|
+
validation = _ref2.validation;
|
|
309
|
+
var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled);
|
|
310
|
+
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
|
|
311
|
+
},
|
|
312
|
+
onMigrate: function onMigrate() {
|
|
313
|
+
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
314
|
+
width: pixelWidthFromElement,
|
|
315
|
+
widthType: 'pixel'
|
|
316
|
+
}));
|
|
317
|
+
tr.setMeta('scrollIntoView', false);
|
|
318
|
+
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
319
|
+
dispatch(tr);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
if (pluginState.isResizing) {
|
|
325
|
+
// If the image is resizing
|
|
326
|
+
// then return pixel entry component or full width label as the only toolbar item
|
|
327
|
+
if (!selectedMediaSingleNode) {
|
|
328
|
+
return [];
|
|
329
|
+
}
|
|
330
|
+
var layout = selectedMediaSingleNode.node.attrs.layout;
|
|
331
|
+
if (layout === 'full-width') {
|
|
332
|
+
var fullWidthLabel = {
|
|
333
|
+
type: 'custom',
|
|
334
|
+
fallback: [],
|
|
335
|
+
render: function render() {
|
|
336
|
+
return /*#__PURE__*/React.createElement(FullWidthDisplay, {
|
|
337
|
+
intl: intl
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
return [fullWidthLabel];
|
|
342
|
+
}
|
|
343
|
+
return [sizeInput];
|
|
344
|
+
}
|
|
345
|
+
toolbarButtons.push(sizeInput);
|
|
346
|
+
toolbarButtons.push({
|
|
347
|
+
type: 'separator'
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (allowLinking && shouldShowMediaLinkToolbar(state)) {
|
|
351
|
+
toolbarButtons.push({
|
|
352
|
+
type: 'custom',
|
|
353
|
+
fallback: [],
|
|
354
|
+
render: function render(editorView, idx) {
|
|
355
|
+
if (editorView !== null && editorView !== void 0 && editorView.state) {
|
|
356
|
+
var editLink = function editLink() {
|
|
357
|
+
if (editorView) {
|
|
358
|
+
var _state = editorView.state,
|
|
359
|
+
dispatch = editorView.dispatch;
|
|
360
|
+
showLinkingToolbar(_state, dispatch);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var openLink = function openLink() {
|
|
364
|
+
if (editorView) {
|
|
365
|
+
var _pluginInjectionApi$a5;
|
|
366
|
+
var tr = editorView.state.tr,
|
|
367
|
+
dispatch = editorView.dispatch;
|
|
368
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
|
|
369
|
+
eventType: EVENT_TYPE.TRACK,
|
|
370
|
+
action: ACTION.VISITED,
|
|
371
|
+
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
372
|
+
actionSubjectId: ACTION_SUBJECT_ID.LINK
|
|
373
|
+
})(tr);
|
|
374
|
+
dispatch(tr);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
379
|
+
key: idx,
|
|
380
|
+
editorState: editorView.state,
|
|
381
|
+
intl: intl,
|
|
382
|
+
mediaLinkingState: mediaLinkingState,
|
|
383
|
+
onAddLink: editLink,
|
|
384
|
+
onEditLink: editLink,
|
|
385
|
+
onOpenLink: openLink
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (allowAltTextOnImages) {
|
|
394
|
+
var _pluginInjectionApi$a6;
|
|
395
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions), {
|
|
396
|
+
type: 'separator'
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
var removeButton = {
|
|
400
|
+
id: 'editor.media.delete',
|
|
401
|
+
type: 'button',
|
|
402
|
+
appearance: 'danger',
|
|
403
|
+
focusEditoronEnter: true,
|
|
404
|
+
icon: RemoveIcon,
|
|
405
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
406
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
407
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
408
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
409
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
410
|
+
onClick: remove,
|
|
411
|
+
testId: 'media-toolbar-remove-button'
|
|
412
|
+
};
|
|
413
|
+
var items = [].concat(_toConsumableArray(toolbarButtons), [{
|
|
414
|
+
type: 'copy-button',
|
|
415
|
+
items: [{
|
|
416
|
+
state: state,
|
|
417
|
+
formatMessage: intl.formatMessage,
|
|
418
|
+
nodeType: mediaSingle
|
|
419
|
+
}, {
|
|
420
|
+
type: 'separator'
|
|
421
|
+
}]
|
|
422
|
+
}, removeButton]);
|
|
423
|
+
return items;
|
|
424
|
+
};
|
|
425
|
+
export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
426
|
+
var _pluginInjectionApi$d2;
|
|
427
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
428
|
+
var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
|
|
429
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
430
|
+
media = _state$schema$nodes.media,
|
|
431
|
+
mediaInline = _state$schema$nodes.mediaInline,
|
|
432
|
+
mediaSingle = _state$schema$nodes.mediaSingle,
|
|
433
|
+
mediaGroup = _state$schema$nodes.mediaGroup;
|
|
434
|
+
var altTextValidator = options.altTextValidator,
|
|
435
|
+
allowLinking = options.allowLinking,
|
|
436
|
+
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
437
|
+
providerFactory = options.providerFactory,
|
|
438
|
+
allowMediaInline = options.allowMediaInline,
|
|
439
|
+
allowResizing = options.allowResizing,
|
|
440
|
+
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
441
|
+
var mediaPluginState = stateKey.getState(state);
|
|
442
|
+
var mediaLinkingState = getMediaLinkingState(state);
|
|
443
|
+
var _ref3 = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {},
|
|
444
|
+
hoverDecoration = _ref3.hoverDecoration;
|
|
445
|
+
if (!mediaPluginState) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
449
|
+
var baseToolbar = {
|
|
450
|
+
title: 'Media floating controls',
|
|
451
|
+
nodeType: nodeType,
|
|
452
|
+
getDomRef: function getDomRef() {
|
|
453
|
+
return mediaPluginState.element;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
if (allowLinking && mediaLinkingState && mediaLinkingState.visible && shouldShowMediaLinkToolbar(state)) {
|
|
457
|
+
var linkingToolbar = getLinkingToolbar(baseToolbar, mediaLinkingState, state, intl, pluginInjectionApi, providerFactory);
|
|
458
|
+
if (linkingToolbar) {
|
|
459
|
+
return linkingToolbar;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (allowAltTextOnImages) {
|
|
463
|
+
var mediaAltTextPluginState = getMediaAltTextPluginState(state);
|
|
464
|
+
if (mediaAltTextPluginState.isAltTextEditorOpen) {
|
|
465
|
+
var _pluginInjectionApi$f;
|
|
466
|
+
return getAltTextToolbar(baseToolbar, {
|
|
467
|
+
altTextValidator: altTextValidator,
|
|
468
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
var items = [];
|
|
473
|
+
var parentMediaGroupNode = findParentNodeOfType(mediaGroup)(state.selection);
|
|
474
|
+
var selectedNodeType;
|
|
475
|
+
if (state.selection instanceof NodeSelection) {
|
|
476
|
+
selectedNodeType = state.selection.node.type;
|
|
477
|
+
}
|
|
478
|
+
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
479
|
+
var _pluginInjectionApi$a7;
|
|
480
|
+
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
481
|
+
baseToolbar.getDomRef = function () {
|
|
482
|
+
var _mediaPluginState$ele;
|
|
483
|
+
var selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
484
|
+
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
485
|
+
};
|
|
486
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions);
|
|
487
|
+
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
488
|
+
var _pluginInjectionApi$a8;
|
|
489
|
+
baseToolbar.getDomRef = function () {
|
|
490
|
+
var _mediaPluginState$ele2;
|
|
491
|
+
var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(MediaInlineNodeSelector));
|
|
492
|
+
return element || mediaPluginState.element;
|
|
493
|
+
};
|
|
494
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions);
|
|
495
|
+
} else {
|
|
496
|
+
baseToolbar.getDomRef = function () {
|
|
497
|
+
var _mediaPluginState$ele3;
|
|
498
|
+
var element = (_mediaPluginState$ele3 = mediaPluginState.element) === null || _mediaPluginState$ele3 === void 0 ? void 0 : _mediaPluginState$ele3.querySelector(".".concat(MediaSingleNodeSelector));
|
|
499
|
+
return element || mediaPluginState.element;
|
|
500
|
+
};
|
|
501
|
+
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags);
|
|
502
|
+
}
|
|
503
|
+
var toolbarConfig = _objectSpread(_objectSpread({}, baseToolbar), {}, {
|
|
504
|
+
items: items,
|
|
505
|
+
scrollable: true
|
|
506
|
+
});
|
|
507
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience') && allowResizing) {
|
|
508
|
+
return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
|
|
509
|
+
width: mediaPluginState.isResizing ? undefined : getMaxToolbarWidth()
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
return toolbarConfig;
|
|
513
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
+
var _templateObject;
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
8
|
+
import { addLink, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
9
|
+
import { linkMessages, linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { FloatingToolbarButton as ToolbarButton } from '@atlaskit/editor-common/ui';
|
|
11
|
+
import { FloatingToolbarSeparator as Separator } from '@atlaskit/editor-common/ui';
|
|
12
|
+
import LinkIcon from '@atlaskit/icon/glyph/editor/link';
|
|
13
|
+
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
14
|
+
import { stateKey } from '../pm-plugins/plugin-key';
|
|
15
|
+
import { checkMediaType } from '../utils/check-media-type';
|
|
16
|
+
import { currentMediaNode } from '../utils/current-media-node';
|
|
17
|
+
// need this wrapper, need to have 4px between items.
|
|
18
|
+
var wrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"])), "var(--ds-space-050, 4px)");
|
|
19
|
+
export var LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
|
|
20
|
+
var editorState = _ref.editorState,
|
|
21
|
+
mediaLinkingState = _ref.mediaLinkingState,
|
|
22
|
+
intl = _ref.intl,
|
|
23
|
+
onAddLink = _ref.onAddLink,
|
|
24
|
+
onEditLink = _ref.onEditLink,
|
|
25
|
+
onOpenLink = _ref.onOpenLink;
|
|
26
|
+
var _useState = useState(true),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
showLinkingControls = _useState2[0],
|
|
29
|
+
setShowLinkingControls = _useState2[1];
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
var _stateKey$getState;
|
|
32
|
+
var mediaNode = currentMediaNode(editorState);
|
|
33
|
+
if (!mediaNode) {
|
|
34
|
+
setShowLinkingControls(false);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var mediaClientConfig = (_stateKey$getState = stateKey.getState(editorState)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.mediaClientConfig;
|
|
38
|
+
if (!mediaClientConfig) {
|
|
39
|
+
setShowLinkingControls(false);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
checkMediaType(mediaNode, mediaClientConfig).then(function (mediaType) {
|
|
43
|
+
setShowLinkingControls(mediaType === 'external' || mediaType === 'image');
|
|
44
|
+
});
|
|
45
|
+
}, [editorState]);
|
|
46
|
+
if (!showLinkingControls) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (mediaLinkingState && mediaLinkingState.editable) {
|
|
50
|
+
var isValidUrl = isSafeUrl(mediaLinkingState.link);
|
|
51
|
+
var title = intl.formatMessage(linkToolbarMessages.editLink);
|
|
52
|
+
var linkTitle = intl.formatMessage(isValidUrl ? linkMessages.openLink : linkToolbarMessages.unableToOpenLink);
|
|
53
|
+
return jsx(Fragment, null, jsx("div", {
|
|
54
|
+
css: wrapper
|
|
55
|
+
}, jsx(ToolbarButton, {
|
|
56
|
+
onClick: onEditLink,
|
|
57
|
+
title: title,
|
|
58
|
+
tooltipContent: jsx(ToolTipContent, {
|
|
59
|
+
description: title,
|
|
60
|
+
keymap: addLink
|
|
61
|
+
}),
|
|
62
|
+
testId: "edit-link-button"
|
|
63
|
+
}, title)), jsx("div", {
|
|
64
|
+
css: wrapper
|
|
65
|
+
}, jsx(Separator, null)), jsx(ToolbarButton, {
|
|
66
|
+
target: "_blank",
|
|
67
|
+
href: isValidUrl ? mediaLinkingState.link : undefined,
|
|
68
|
+
disabled: !isValidUrl,
|
|
69
|
+
onClick: onOpenLink,
|
|
70
|
+
title: linkTitle,
|
|
71
|
+
icon: jsx(OpenIcon, {
|
|
72
|
+
label: linkTitle
|
|
73
|
+
}),
|
|
74
|
+
className: "hyperlink-open-link"
|
|
75
|
+
}), jsx(Separator, null));
|
|
76
|
+
} else {
|
|
77
|
+
var _title = intl.formatMessage(linkToolbarMessages.addLink);
|
|
78
|
+
return jsx(Fragment, null, jsx(ToolbarButton, {
|
|
79
|
+
testId: "add-link-button",
|
|
80
|
+
onClick: onAddLink,
|
|
81
|
+
title: _title,
|
|
82
|
+
tooltipContent: jsx(ToolTipContent, {
|
|
83
|
+
description: _title,
|
|
84
|
+
keymap: addLink
|
|
85
|
+
}),
|
|
86
|
+
icon: jsx(LinkIcon, {
|
|
87
|
+
label: _title
|
|
88
|
+
})
|
|
89
|
+
}), jsx(Separator, null));
|
|
90
|
+
}
|
|
91
|
+
};
|