@atlaskit/editor-plugin-media 0.2.0 → 0.3.0
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 +10 -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 +31 -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 +5 -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/dist/types-ts4.5/commands/captions.d.ts +5 -0
- package/dist/types-ts4.5/commands/helpers.d.ts +15 -0
- package/dist/types-ts4.5/commands/index.d.ts +1 -0
- package/dist/types-ts4.5/commands/linking.d.ts +9 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/media-plugin-options.d.ts +17 -0
- package/dist/types-ts4.5/next-plugin-type.d.ts +31 -0
- package/dist/types-ts4.5/nodeviews/__mocks__/mediaNodeUpdater.d.ts +24 -0
- package/dist/types-ts4.5/nodeviews/mediaGroup.d.ts +33 -0
- package/dist/types-ts4.5/nodeviews/mediaInline.d.ts +50 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeUpdater.d.ts +45 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +28 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +44 -0
- package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +62 -0
- package/dist/types-ts4.5/nodeviews/messages.d.ts +7 -0
- package/dist/types-ts4.5/nodeviews/styles.d.ts +16 -0
- package/dist/types-ts4.5/nodeviews/types.d.ts +42 -0
- package/dist/types-ts4.5/picker-facade.d.ts +44 -0
- package/dist/types-ts4.5/plugin.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/actions.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/commands.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/index.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/keymap.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/messages.d.ts +37 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/reducer.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/types.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/alt-text/ui/AltTextEdit.d.ts +41 -0
- package/dist/types-ts4.5/pm-plugins/keymap-media-single.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/linking/actions.d.ts +20 -0
- package/dist/types-ts4.5/pm-plugins/linking/index.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/linking/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/linking/reducer.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/linking/types.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +120 -0
- package/dist/types-ts4.5/pm-plugins/media-editor-plugin-factory.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/mediaTaskManager.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +65 -0
- package/dist/types-ts4.5/toolbar/alt-text.d.ts +13 -0
- package/dist/types-ts4.5/toolbar/commands.d.ts +12 -0
- package/dist/types-ts4.5/toolbar/filePreviewItem.d.ts +9 -0
- package/dist/types-ts4.5/toolbar/imageBorder.d.ts +2 -0
- package/dist/types-ts4.5/toolbar/index.d.ts +6 -0
- package/dist/types-ts4.5/toolbar/linking-toolbar-appearance.d.ts +14 -0
- package/dist/types-ts4.5/toolbar/linking.d.ts +10 -0
- package/dist/types-ts4.5/toolbar/utils.d.ts +11 -0
- package/dist/types-ts4.5/types.d.ts +2 -1
- package/dist/types-ts4.5/ui/CaptionPlaceholder/index.d.ts +6 -0
- package/dist/types-ts4.5/ui/CaptionPlaceholder/messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/ImageBorder/index.d.ts +11 -0
- package/dist/types-ts4.5/ui/ImageBorder/messages.d.ts +42 -0
- package/dist/types-ts4.5/ui/ImageBorder/styles.d.ts +15 -0
- package/dist/types-ts4.5/ui/Media/DropPlaceholder.d.ts +8 -0
- package/dist/types-ts4.5/ui/Media/drop-placeholder-messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/MediaLinkingToolbar.d.ts +35 -0
- package/dist/types-ts4.5/ui/MediaPicker/BrowserWrapper.d.ts +11 -0
- package/dist/types-ts4.5/ui/MediaPicker/ClipboardWrapper.d.ts +10 -0
- package/dist/types-ts4.5/ui/MediaPicker/DropzoneWrapper.d.ts +13 -0
- package/dist/types-ts4.5/ui/MediaPicker/PickerFacadeProvider.d.ts +28 -0
- package/dist/types-ts4.5/ui/MediaPicker/index.d.ts +23 -0
- package/dist/types-ts4.5/ui/PixelEntry/constants.d.ts +1 -0
- package/dist/types-ts4.5/ui/PixelEntry/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/PixelEntry/messages.d.ts +47 -0
- package/dist/types-ts4.5/ui/PixelEntry/styles.d.ts +8 -0
- package/dist/types-ts4.5/ui/PixelEntry/types.d.ts +58 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +3 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +59 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/index.d.ts +45 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/styled.d.ts +2 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/styles.d.ts +1 -0
- package/dist/types-ts4.5/ui/ResizableMediaSingle/types.d.ts +27 -0
- package/dist/types-ts4.5/ui/ToolbarMedia/index.d.ts +13 -0
- package/dist/types-ts4.5/ui/ToolbarMedia/toolbar-media-messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/media-linking-toolbar-messages.d.ts +7 -0
- package/dist/types-ts4.5/utils/analytics.d.ts +3 -0
- package/dist/types-ts4.5/utils/check-media-type.d.ts +4 -0
- package/dist/types-ts4.5/utils/current-media-node.d.ts +9 -0
- package/dist/types-ts4.5/utils/is-image.d.ts +1 -0
- package/dist/types-ts4.5/utils/media-common.d.ts +20 -0
- package/dist/types-ts4.5/utils/media-files.d.ts +30 -0
- package/dist/types-ts4.5/utils/media-single.d.ts +20 -0
- package/package.json +32 -20
- package/report.api.md +430 -0
- package/tmp/api-report-tmp.d.ts +381 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#41187](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41187) [`c09b3a047f4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c09b3a047f4) - Extract media plugin from `@atlaskit/editor-core` to `@atlaskit/editor-plugin-media.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 0.2.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectCaptionFromMediaSinglePos = exports.insertAndSelectCaptionFromMediaSinglePos = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var selectCaptionFromMediaSinglePos = exports.selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSinglePos(mediaSingleNodePos, mediaSingleNode) {
|
|
10
|
+
return function (state, dispatch) {
|
|
11
|
+
// node should have two children, media and caption
|
|
12
|
+
if (mediaSingleNode.childCount !== 2) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (dispatch) {
|
|
16
|
+
var media = mediaSingleNode.child(0);
|
|
17
|
+
var caption = mediaSingleNode.child(1);
|
|
18
|
+
var tr = state.tr;
|
|
19
|
+
tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
|
|
20
|
+
tr.setMeta('scrollIntoView', false);
|
|
21
|
+
dispatch(tr);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var insertAndSelectCaptionFromMediaSinglePos = exports.insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(editorAnalyticsAPI) {
|
|
27
|
+
return function (mediaSingleNodePos, mediaSingleNode) {
|
|
28
|
+
return function (state, dispatch) {
|
|
29
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
var tr = state.tr;
|
|
33
|
+
|
|
34
|
+
// node should have one child, media
|
|
35
|
+
if (mediaSingleNode.childCount !== 1) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (dispatch) {
|
|
39
|
+
var schema = state.schema;
|
|
40
|
+
var media = mediaSingleNode.child(0);
|
|
41
|
+
var caption = schema.nodes.caption.create();
|
|
42
|
+
tr = state.tr.insert(mediaSingleNodePos + media.nodeSize + 1, caption);
|
|
43
|
+
tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
|
|
44
|
+
tr.setMeta('scrollIntoView', false);
|
|
45
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
46
|
+
action: _analytics.ACTION.ADDED,
|
|
47
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
48
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA_SINGLE,
|
|
49
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CAPTION
|
|
50
|
+
})(tr);
|
|
51
|
+
dispatch(tr);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var setSelectionAtEndOfCaption = function setSelectionAtEndOfCaption(tr, mediaSingleNodePos, mediaNodeSize, captionNodeSize) {
|
|
58
|
+
return (0, _utils.setTextSelection)(mediaSingleNodePos + mediaNodeSize + captionNodeSize)(tr);
|
|
59
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.updateMediaSingleNodeAttrs = exports.updateCurrentMediaNodeAttrs = exports.updateAllMediaSingleNodesAttrs = exports.replaceExternalMedia = exports.isMediaNode = exports.findMediaSingleNode = exports.findAllMediaSingleNodes = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _steps = require("@atlaskit/adf-schema/steps");
|
|
10
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
11
|
+
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; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
/**
|
|
14
|
+
* Note that Media Inline is inserted like a media single node into the media plugin state.
|
|
15
|
+
* Though it is not of type mediaSingle, it shares the same `findMediaSingleNode` method
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
var findMediaSingleNode = exports.findMediaSingleNode = function findMediaSingleNode(mediaPluginState, id) {
|
|
19
|
+
var mediaNodes = mediaPluginState.mediaNodes;
|
|
20
|
+
|
|
21
|
+
// Array#find... no IE support
|
|
22
|
+
return mediaNodes.reduce(function (memo, nodeWithPos) {
|
|
23
|
+
if (memo) {
|
|
24
|
+
return memo;
|
|
25
|
+
}
|
|
26
|
+
var node = nodeWithPos.node;
|
|
27
|
+
if (node.attrs.id === id) {
|
|
28
|
+
return nodeWithPos;
|
|
29
|
+
}
|
|
30
|
+
return memo;
|
|
31
|
+
}, null);
|
|
32
|
+
};
|
|
33
|
+
var findAllMediaSingleNodes = exports.findAllMediaSingleNodes = function findAllMediaSingleNodes(mediaPluginState, id) {
|
|
34
|
+
var mediaNodes = mediaPluginState.mediaNodes;
|
|
35
|
+
return mediaNodes.filter(function (nodeWithHandler) {
|
|
36
|
+
return nodeWithHandler.node.attrs.id === id;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var isMediaNode = exports.isMediaNode = function isMediaNode(pos, state) {
|
|
40
|
+
var node = state.doc.nodeAt(pos);
|
|
41
|
+
return node && ['media', 'mediaInline'].includes(node.type.name);
|
|
42
|
+
};
|
|
43
|
+
var updateAllMediaSingleNodesAttrs = exports.updateAllMediaSingleNodesAttrs = function updateAllMediaSingleNodesAttrs(id, attrs) {
|
|
44
|
+
return function (state, dispatch) {
|
|
45
|
+
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
46
|
+
if (!mediaPluginState) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
var mediaNodes;
|
|
50
|
+
mediaNodes = findAllMediaSingleNodes(mediaPluginState, id);
|
|
51
|
+
var validMediaNodePositions = mediaNodes.reduce(function (acc, _ref) {
|
|
52
|
+
var getPos = _ref.getPos;
|
|
53
|
+
var pos = getPos();
|
|
54
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
55
|
+
return acc;
|
|
56
|
+
}
|
|
57
|
+
acc.push(pos);
|
|
58
|
+
return acc;
|
|
59
|
+
}, []);
|
|
60
|
+
if (validMediaNodePositions.length === 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
var tr = state.tr;
|
|
64
|
+
validMediaNodePositions.forEach(function (pos) {
|
|
65
|
+
return tr.step(new _steps.SetAttrsStep(pos, attrs));
|
|
66
|
+
});
|
|
67
|
+
tr.setMeta('addToHistory', false);
|
|
68
|
+
if (dispatch) {
|
|
69
|
+
dispatch(tr);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
var updateCurrentMediaNodeAttrs = exports.updateCurrentMediaNodeAttrs = function updateCurrentMediaNodeAttrs(attrs, mediaNode) {
|
|
75
|
+
return function (state, dispatch) {
|
|
76
|
+
var pos = mediaNode.getPos();
|
|
77
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
var tr = state.tr;
|
|
81
|
+
tr.step(new _steps.SetAttrsStep(pos, attrs));
|
|
82
|
+
tr.setMeta('addToHistory', false);
|
|
83
|
+
if (dispatch) {
|
|
84
|
+
dispatch(tr);
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var updateMediaSingleNodeAttrs = exports.updateMediaSingleNodeAttrs = function updateMediaSingleNodeAttrs(id, attrs) {
|
|
90
|
+
return function (state, dispatch) {
|
|
91
|
+
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
92
|
+
if (!mediaPluginState) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var mediaNodeWithPos = findMediaSingleNode(mediaPluginState, id);
|
|
96
|
+
if (!mediaNodeWithPos) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
var tr = state.tr;
|
|
100
|
+
var pos = mediaNodeWithPos.getPos();
|
|
101
|
+
if (typeof pos !== 'number' || !isMediaNode(pos, state)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
tr.step(new _steps.SetAttrsStep(pos, attrs)).setMeta('addToHistory', false);
|
|
105
|
+
if (dispatch) {
|
|
106
|
+
dispatch(tr);
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
var replaceExternalMedia = exports.replaceExternalMedia = function replaceExternalMedia(pos, attrs) {
|
|
112
|
+
return function (state, dispatch) {
|
|
113
|
+
var tr = state.tr;
|
|
114
|
+
var node = tr.doc.nodeAt(pos);
|
|
115
|
+
if (!node || node.type.name !== 'media') {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
tr.step(new _steps.SetAttrsStep(pos, _objectSpread({
|
|
119
|
+
type: 'file',
|
|
120
|
+
url: null
|
|
121
|
+
}, attrs))).setMeta('addToHistory', false);
|
|
122
|
+
if (dispatch) {
|
|
123
|
+
dispatch(tr);
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "replaceExternalMedia", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _helpers.replaceExternalMedia;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "updateAllMediaSingleNodesAttrs", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _helpers.updateAllMediaSingleNodesAttrs;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "updateMediaSingleNodeAttrs", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _helpers.updateMediaSingleNodeAttrs;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _helpers = require("./helpers");
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.unlink = exports.showLinkingToolbarWithMediaTypeCheck = exports.showLinkingToolbar = exports.setUrlToMedia = exports.hideLinkingToolbar = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _commands = require("@atlaskit/editor-common/commands");
|
|
11
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
+
var _linking = require("../pm-plugins/linking");
|
|
13
|
+
var _actions = require("../pm-plugins/linking/actions");
|
|
14
|
+
var _main = require("../pm-plugins/main");
|
|
15
|
+
var _checkMediaType = require("../utils/check-media-type");
|
|
16
|
+
var _currentMediaNode = require("../utils/current-media-node");
|
|
17
|
+
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; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
var showLinkingToolbar = exports.showLinkingToolbar = (0, _linking.createMediaLinkingCommand)(function (state) {
|
|
20
|
+
var mediaLinkingState = (0, _linking.getMediaLinkingState)(state);
|
|
21
|
+
if (mediaLinkingState && mediaLinkingState.mediaPos !== null) {
|
|
22
|
+
var mediaSingle = state.doc.nodeAt(mediaLinkingState.mediaPos);
|
|
23
|
+
if (mediaSingle) {
|
|
24
|
+
return {
|
|
25
|
+
type: _actions.MediaLinkingActionsTypes.showToolbar
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
var showLinkingToolbarWithMediaTypeCheck = exports.showLinkingToolbarWithMediaTypeCheck = function showLinkingToolbarWithMediaTypeCheck(editorState, dispatch, editorView) {
|
|
32
|
+
if (dispatch && editorView) {
|
|
33
|
+
var mediaNode = (0, _currentMediaNode.currentMediaNode)(editorState);
|
|
34
|
+
if (!mediaNode) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
var _getMediaPluginState = (0, _main.getMediaPluginState)(editorState),
|
|
38
|
+
mediaClientConfig = _getMediaPluginState.mediaClientConfig;
|
|
39
|
+
if (!mediaClientConfig) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
(0, _checkMediaType.checkMediaType)(mediaNode, mediaClientConfig).then(function (mediaType) {
|
|
43
|
+
if ((mediaType === 'external' || mediaType === 'image') &&
|
|
44
|
+
// We make sure the selection and the node hasn't changed.
|
|
45
|
+
(0, _currentMediaNode.currentMediaNode)(editorView.state) === mediaNode) {
|
|
46
|
+
dispatch(editorView.state.tr.setMeta(_linking.mediaLinkingPluginKey, {
|
|
47
|
+
type: _actions.MediaLinkingActionsTypes.showToolbar
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
var hideLinkingToolbarCommand = (0, _linking.createMediaLinkingCommand)({
|
|
55
|
+
type: _actions.MediaLinkingActionsTypes.hideToolbar
|
|
56
|
+
});
|
|
57
|
+
var hideLinkingToolbar = exports.hideLinkingToolbar = function hideLinkingToolbar(state, dispatch, view, focusFloatingToolbar) {
|
|
58
|
+
hideLinkingToolbarCommand(state, dispatch, view);
|
|
59
|
+
|
|
60
|
+
// restore focus on the editor so keyboard shortcuts aren't lost to the browser
|
|
61
|
+
if (view && !focusFloatingToolbar) {
|
|
62
|
+
view.focus();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function getCurrentUrl(state) {
|
|
66
|
+
var linkType = state.schema.marks.link;
|
|
67
|
+
var mediaLinkingState = (0, _linking.getMediaLinkingState)(state);
|
|
68
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
72
|
+
var node = state.doc.nodeAt($pos.pos);
|
|
73
|
+
if (!node) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
var hasLink = linkType.isInSet(node.marks);
|
|
77
|
+
if (!hasLink) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var link = node.marks.find(function (mark) {
|
|
81
|
+
return mark.type === linkType;
|
|
82
|
+
}); // Already check exist
|
|
83
|
+
var url = link.attrs.href;
|
|
84
|
+
return url;
|
|
85
|
+
}
|
|
86
|
+
function toggleLinkMark(tr, state, _ref) {
|
|
87
|
+
var _ref$forceRemove = _ref.forceRemove,
|
|
88
|
+
forceRemove = _ref$forceRemove === void 0 ? false : _ref$forceRemove,
|
|
89
|
+
url = _ref.url;
|
|
90
|
+
var mediaLinkingState = (0, _linking.getMediaLinkingState)(state);
|
|
91
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
92
|
+
return tr;
|
|
93
|
+
}
|
|
94
|
+
var $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
95
|
+
var node = state.doc.nodeAt($pos.pos);
|
|
96
|
+
if (!node) {
|
|
97
|
+
return tr;
|
|
98
|
+
}
|
|
99
|
+
var linkMark = state.schema.marks.link;
|
|
100
|
+
var media = state.schema.nodes.media;
|
|
101
|
+
var toggleBlockLinkMark = (0, _commands.createToggleBlockMarkOnRange)(linkMark, function (prevAttrs, node) {
|
|
102
|
+
// Only add mark to media
|
|
103
|
+
if (!node || node.type !== media) {
|
|
104
|
+
return; //No op
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (forceRemove) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
var href = (0, _utils.normalizeUrl)(url);
|
|
111
|
+
if (prevAttrs && prevAttrs.href === href) {
|
|
112
|
+
return; //No op
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (href.trim() === '') {
|
|
116
|
+
return false; // remove
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return _objectSpread(_objectSpread({}, prevAttrs), {}, {
|
|
120
|
+
href: href
|
|
121
|
+
});
|
|
122
|
+
}, [media]);
|
|
123
|
+
toggleBlockLinkMark($pos.pos, $pos.pos + node.nodeSize, tr, state);
|
|
124
|
+
return tr;
|
|
125
|
+
}
|
|
126
|
+
var fireAnalyticForMediaLink = function fireAnalyticForMediaLink(tr, action) {
|
|
127
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
128
|
+
var editorAnalyticsAPI = arguments.length > 3 ? arguments[3] : undefined;
|
|
129
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
130
|
+
action: action,
|
|
131
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
132
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
133
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LINK,
|
|
134
|
+
attributes: attributes
|
|
135
|
+
})(tr);
|
|
136
|
+
return tr;
|
|
137
|
+
};
|
|
138
|
+
var unlink = exports.unlink = function unlink(editorAnalyticsAPI) {
|
|
139
|
+
return (0, _linking.createMediaLinkingCommand)({
|
|
140
|
+
type: _actions.MediaLinkingActionsTypes.unlink
|
|
141
|
+
}, function (tr, state) {
|
|
142
|
+
var transaction = toggleLinkMark(tr, state, {
|
|
143
|
+
forceRemove: true
|
|
144
|
+
});
|
|
145
|
+
return fireAnalyticForMediaLink(transaction, _analytics.ACTION.DELETED, undefined, editorAnalyticsAPI);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var getAction = function getAction(newUrl, state) {
|
|
149
|
+
var currentUrl = getCurrentUrl(state);
|
|
150
|
+
if (!currentUrl) {
|
|
151
|
+
return _analytics.ACTION.ADDED;
|
|
152
|
+
} else if (newUrl !== currentUrl) {
|
|
153
|
+
return _analytics.ACTION.EDITED;
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
};
|
|
157
|
+
var setUrlToMedia = exports.setUrlToMedia = function setUrlToMedia(url, inputMethod, editorAnalyticsAPI) {
|
|
158
|
+
return (0, _linking.createMediaLinkingCommand)({
|
|
159
|
+
type: _actions.MediaLinkingActionsTypes.setUrl,
|
|
160
|
+
payload: (0, _utils.normalizeUrl)(url)
|
|
161
|
+
}, function (tr, state) {
|
|
162
|
+
var action = getAction(url, state);
|
|
163
|
+
if (!action) {
|
|
164
|
+
return tr;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
var toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
168
|
+
url: url
|
|
169
|
+
});
|
|
170
|
+
fireAnalyticForMediaLink(tr, action, action === _analytics.ACTION.ADDED ? {
|
|
171
|
+
inputMethod: inputMethod
|
|
172
|
+
} : undefined, editorAnalyticsAPI);
|
|
173
|
+
return toggleLinkMarkResult;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
fireAnalyticForMediaLink(tr, _analytics.ACTION.ERRORED, {
|
|
176
|
+
action: action
|
|
177
|
+
}, editorAnalyticsAPI);
|
|
178
|
+
throw e;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
package/dist/cjs/index.js
CHANGED