@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
|
@@ -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.insertMediaSingleNode = exports.insertMediaAsMediaSingle = exports.createMediaSingleNode = void 0;
|
|
8
|
+
exports.isCaptionNode = isCaptionNode;
|
|
9
|
+
exports.isVideo = exports.isMediaSingle = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
+
var _insert = require("@atlaskit/editor-common/insert");
|
|
13
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
14
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
15
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
17
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
|
+
var _mediaCommon = require("../utils/media-common");
|
|
20
|
+
var _isImage = require("./is-image");
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
24
|
+
return {
|
|
25
|
+
action: _analytics.ACTION.INSERTED,
|
|
26
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
27
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.MEDIA,
|
|
28
|
+
attributes: {
|
|
29
|
+
inputMethod: inputMethod,
|
|
30
|
+
fileExtension: fileExtension,
|
|
31
|
+
type: _analytics.ACTION_SUBJECT_ID.MEDIA_SINGLE
|
|
32
|
+
},
|
|
33
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
function shouldAddParagraph(state) {
|
|
37
|
+
return (0, _selection.atTheBeginningOfBlock)(state) && !(0, _utils.checkNodeDown)(state.selection, state.doc, _utils.isEmptyParagraph);
|
|
38
|
+
}
|
|
39
|
+
function insertNodesWithOptionalParagraph(nodes) {
|
|
40
|
+
var analyticsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
|
+
var editorAnalyticsAPI = arguments.length > 2 ? arguments[2] : undefined;
|
|
42
|
+
return function (state, dispatch) {
|
|
43
|
+
var tr = state.tr,
|
|
44
|
+
schema = state.schema;
|
|
45
|
+
var paragraph = schema.nodes.paragraph;
|
|
46
|
+
var inputMethod = analyticsAttributes.inputMethod,
|
|
47
|
+
fileExtension = analyticsAttributes.fileExtension;
|
|
48
|
+
var openEnd = 0;
|
|
49
|
+
if (shouldAddParagraph(state)) {
|
|
50
|
+
nodes.push(paragraph.create());
|
|
51
|
+
openEnd = 1;
|
|
52
|
+
}
|
|
53
|
+
tr.replaceSelection(new _model.Slice(_model.Fragment.from(nodes), 0, openEnd));
|
|
54
|
+
if (inputMethod) {
|
|
55
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
56
|
+
}
|
|
57
|
+
if (dispatch) {
|
|
58
|
+
dispatch(tr);
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var isMediaSingle = exports.isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
64
|
+
return !!schema.nodes.mediaSingle && (0, _isImage.isImage)(fileMimeType);
|
|
65
|
+
};
|
|
66
|
+
var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
|
|
67
|
+
var state = view.state,
|
|
68
|
+
dispatch = view.dispatch;
|
|
69
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
70
|
+
mediaSingle = _state$schema$nodes.mediaSingle,
|
|
71
|
+
media = _state$schema$nodes.media;
|
|
72
|
+
if (!mediaSingle) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// if not an image type media node
|
|
77
|
+
if (node.type !== media || !(0, _isImage.isImage)(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
var mediaSingleNode = mediaSingle.create({}, node);
|
|
81
|
+
var nodes = [mediaSingleNode];
|
|
82
|
+
var analyticsAttributes = {
|
|
83
|
+
inputMethod: inputMethod,
|
|
84
|
+
fileExtension: node.attrs.__fileMimeType
|
|
85
|
+
};
|
|
86
|
+
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
|
|
87
|
+
};
|
|
88
|
+
var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) {
|
|
89
|
+
var _state$selection$$fro;
|
|
90
|
+
if (collection === undefined) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
var state = view.state,
|
|
94
|
+
dispatch = view.dispatch;
|
|
95
|
+
var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
|
|
96
|
+
var parentNodeType = state.selection.$from.parent.type;
|
|
97
|
+
|
|
98
|
+
// add undefined as fallback as we don't want media single width to have upper limit as 0
|
|
99
|
+
// if widthPluginState.width is 0, default 760 will be used
|
|
100
|
+
var contentWidth = (0, _mediaSingle.getMaxWidthForNestedNodeNext)(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
|
|
101
|
+
var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? _mediaSingle.MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
|
|
102
|
+
var fileExtension;
|
|
103
|
+
if (mediaState.fileName) {
|
|
104
|
+
var extensionIdx = mediaState.fileName.lastIndexOf('.');
|
|
105
|
+
fileExtension = extensionIdx >= 0 ? mediaState.fileName.substring(extensionIdx + 1) : undefined;
|
|
106
|
+
}
|
|
107
|
+
// should split if media is valid content for the grandparent of the selected node
|
|
108
|
+
// and the parent node is a paragraph
|
|
109
|
+
if ((0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
|
|
110
|
+
parentNodeType: parentNodeType,
|
|
111
|
+
grandParentNodeType: grandParentNodeType,
|
|
112
|
+
content: node
|
|
113
|
+
})) {
|
|
114
|
+
insertNodesWithOptionalParagraph([node], {
|
|
115
|
+
fileExtension: fileExtension,
|
|
116
|
+
inputMethod: inputMethod
|
|
117
|
+
}, editorAnalyticsAPI)(state, dispatch);
|
|
118
|
+
} else {
|
|
119
|
+
var tr = null;
|
|
120
|
+
if (newInsertionBehaviour) {
|
|
121
|
+
tr = (0, _insert.safeInsert)(node, state.selection.from)(state.tr);
|
|
122
|
+
}
|
|
123
|
+
if (!tr) {
|
|
124
|
+
var content = shouldAddParagraph(view.state) ? _model.Fragment.fromArray([node, state.schema.nodes.paragraph.create()]) : node;
|
|
125
|
+
tr = (0, _utils2.safeInsert)(content, undefined, true)(state.tr);
|
|
126
|
+
}
|
|
127
|
+
if (inputMethod) {
|
|
128
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
129
|
+
}
|
|
130
|
+
dispatch(tr);
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
};
|
|
134
|
+
var createMediaSingleNode = exports.createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
|
|
135
|
+
return function (mediaState) {
|
|
136
|
+
var id = mediaState.id,
|
|
137
|
+
dimensions = mediaState.dimensions,
|
|
138
|
+
contextId = mediaState.contextId,
|
|
139
|
+
_mediaState$scaleFact = mediaState.scaleFactor,
|
|
140
|
+
scaleFactor = _mediaState$scaleFact === void 0 ? 1 : _mediaState$scaleFact;
|
|
141
|
+
var _ref = dimensions || {
|
|
142
|
+
height: undefined,
|
|
143
|
+
width: undefined
|
|
144
|
+
},
|
|
145
|
+
width = _ref.width,
|
|
146
|
+
height = _ref.height;
|
|
147
|
+
var _schema$nodes = schema.nodes,
|
|
148
|
+
media = _schema$nodes.media,
|
|
149
|
+
mediaSingle = _schema$nodes.mediaSingle;
|
|
150
|
+
var scaledWidth = width && Math.round(width / scaleFactor);
|
|
151
|
+
var mediaNode = media.create({
|
|
152
|
+
id: id,
|
|
153
|
+
type: 'file',
|
|
154
|
+
collection: collection,
|
|
155
|
+
contextId: contextId,
|
|
156
|
+
width: scaledWidth,
|
|
157
|
+
height: height && Math.round(height / scaleFactor)
|
|
158
|
+
});
|
|
159
|
+
var mediaSingleAttrs = alignLeftOnInsert ? {
|
|
160
|
+
layout: 'align-start'
|
|
161
|
+
} : {};
|
|
162
|
+
var extendedMediaSingleAttrs = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
|
|
163
|
+
width: (0, _mediaSingle.getMediaSingleInitialWidth)(scaledWidth, maxWidth, minWidth),
|
|
164
|
+
// TODO: change to use enum
|
|
165
|
+
widthType: 'pixel'
|
|
166
|
+
}) : mediaSingleAttrs;
|
|
167
|
+
(0, _mediaCommon.copyOptionalAttrsFromMediaState)(mediaState, mediaNode);
|
|
168
|
+
return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
function isCaptionNode(editorView) {
|
|
172
|
+
var $from = editorView.state.selection.$from;
|
|
173
|
+
var immediateWrapperParentNode = editorView.state.doc.nodeAt($from.before(Math.max($from.depth, 1)));
|
|
174
|
+
if (immediateWrapperParentNode && immediateWrapperParentNode.type.name === 'caption') {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
var isVideo = exports.isVideo = function isVideo(fileType) {
|
|
180
|
+
return !!fileType && fileType.includes('video');
|
|
181
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
export const selectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
|
|
4
|
+
// node should have two children, media and caption
|
|
5
|
+
if (mediaSingleNode.childCount !== 2) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (dispatch) {
|
|
9
|
+
const media = mediaSingleNode.child(0);
|
|
10
|
+
const caption = mediaSingleNode.child(1);
|
|
11
|
+
let tr = state.tr;
|
|
12
|
+
tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
|
|
13
|
+
tr.setMeta('scrollIntoView', false);
|
|
14
|
+
dispatch(tr);
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
export const insertAndSelectCaptionFromMediaSinglePos = editorAnalyticsAPI => (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
|
|
19
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
let tr = state.tr;
|
|
23
|
+
|
|
24
|
+
// node should have one child, media
|
|
25
|
+
if (mediaSingleNode.childCount !== 1) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (dispatch) {
|
|
29
|
+
const schema = state.schema;
|
|
30
|
+
const media = mediaSingleNode.child(0);
|
|
31
|
+
const caption = schema.nodes.caption.create();
|
|
32
|
+
tr = state.tr.insert(mediaSingleNodePos + media.nodeSize + 1, caption);
|
|
33
|
+
tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
|
|
34
|
+
tr.setMeta('scrollIntoView', false);
|
|
35
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
36
|
+
action: ACTION.ADDED,
|
|
37
|
+
eventType: EVENT_TYPE.TRACK,
|
|
38
|
+
actionSubject: ACTION_SUBJECT.MEDIA_SINGLE,
|
|
39
|
+
actionSubjectId: ACTION_SUBJECT_ID.CAPTION
|
|
40
|
+
})(tr);
|
|
41
|
+
dispatch(tr);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
const setSelectionAtEndOfCaption = (tr, mediaSingleNodePos, mediaNodeSize, captionNodeSize) => {
|
|
46
|
+
return setTextSelection(mediaSingleNodePos + mediaNodeSize + captionNodeSize)(tr);
|
|
47
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
|
+
import { stateKey as mediaPluginKey } from '../pm-plugins/plugin-key';
|
|
3
|
+
/**
|
|
4
|
+
* Note that Media Inline is inserted like a media single node into the media plugin state.
|
|
5
|
+
* Though it is not of type mediaSingle, it shares the same `findMediaSingleNode` method
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export const findMediaSingleNode = (mediaPluginState, id) => {
|
|
9
|
+
const {
|
|
10
|
+
mediaNodes
|
|
11
|
+
} = mediaPluginState;
|
|
12
|
+
|
|
13
|
+
// Array#find... no IE support
|
|
14
|
+
return mediaNodes.reduce((memo, nodeWithPos) => {
|
|
15
|
+
if (memo) {
|
|
16
|
+
return memo;
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
node
|
|
20
|
+
} = nodeWithPos;
|
|
21
|
+
if (node.attrs.id === id) {
|
|
22
|
+
return nodeWithPos;
|
|
23
|
+
}
|
|
24
|
+
return memo;
|
|
25
|
+
}, null);
|
|
26
|
+
};
|
|
27
|
+
export const findAllMediaSingleNodes = (mediaPluginState, id) => {
|
|
28
|
+
const {
|
|
29
|
+
mediaNodes
|
|
30
|
+
} = mediaPluginState;
|
|
31
|
+
return mediaNodes.filter(nodeWithHandler => nodeWithHandler.node.attrs.id === id);
|
|
32
|
+
};
|
|
33
|
+
export const isMediaNode = (pos, state) => {
|
|
34
|
+
const node = state.doc.nodeAt(pos);
|
|
35
|
+
return node && ['media', 'mediaInline'].includes(node.type.name);
|
|
36
|
+
};
|
|
37
|
+
export const updateAllMediaSingleNodesAttrs = (id, attrs) => (state, dispatch) => {
|
|
38
|
+
const mediaPluginState = mediaPluginKey.getState(state);
|
|
39
|
+
if (!mediaPluginState) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
let mediaNodes;
|
|
43
|
+
mediaNodes = findAllMediaSingleNodes(mediaPluginState, id);
|
|
44
|
+
const validMediaNodePositions = mediaNodes.reduce((acc, {
|
|
45
|
+
getPos
|
|
46
|
+
}) => {
|
|
47
|
+
const pos = getPos();
|
|
48
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
49
|
+
return acc;
|
|
50
|
+
}
|
|
51
|
+
acc.push(pos);
|
|
52
|
+
return acc;
|
|
53
|
+
}, []);
|
|
54
|
+
if (validMediaNodePositions.length === 0) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const tr = state.tr;
|
|
58
|
+
validMediaNodePositions.forEach(pos => tr.step(new SetAttrsStep(pos, attrs)));
|
|
59
|
+
tr.setMeta('addToHistory', false);
|
|
60
|
+
if (dispatch) {
|
|
61
|
+
dispatch(tr);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
export const updateCurrentMediaNodeAttrs = (attrs, mediaNode) => (state, dispatch) => {
|
|
66
|
+
const pos = mediaNode.getPos();
|
|
67
|
+
if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const tr = state.tr;
|
|
71
|
+
tr.step(new SetAttrsStep(pos, attrs));
|
|
72
|
+
tr.setMeta('addToHistory', false);
|
|
73
|
+
if (dispatch) {
|
|
74
|
+
dispatch(tr);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
export const updateMediaSingleNodeAttrs = (id, attrs) => (state, dispatch) => {
|
|
79
|
+
const mediaPluginState = mediaPluginKey.getState(state);
|
|
80
|
+
if (!mediaPluginState) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const mediaNodeWithPos = findMediaSingleNode(mediaPluginState, id);
|
|
84
|
+
if (!mediaNodeWithPos) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const tr = state.tr;
|
|
88
|
+
const pos = mediaNodeWithPos.getPos();
|
|
89
|
+
if (typeof pos !== 'number' || !isMediaNode(pos, state)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
tr.step(new SetAttrsStep(pos, attrs)).setMeta('addToHistory', false);
|
|
93
|
+
if (dispatch) {
|
|
94
|
+
dispatch(tr);
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
export const replaceExternalMedia = (pos, attrs) => (state, dispatch) => {
|
|
99
|
+
const tr = state.tr;
|
|
100
|
+
const node = tr.doc.nodeAt(pos);
|
|
101
|
+
if (!node || node.type.name !== 'media') {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
tr.step(new SetAttrsStep(pos, {
|
|
105
|
+
type: 'file',
|
|
106
|
+
url: null,
|
|
107
|
+
...attrs
|
|
108
|
+
})).setMeta('addToHistory', false);
|
|
109
|
+
if (dispatch) {
|
|
110
|
+
dispatch(tr);
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { updateMediaSingleNodeAttrs, updateAllMediaSingleNodesAttrs, replaceExternalMedia } from './helpers';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { createToggleBlockMarkOnRange } from '@atlaskit/editor-common/commands';
|
|
3
|
+
import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { createMediaLinkingCommand, getMediaLinkingState, mediaLinkingPluginKey } from '../pm-plugins/linking';
|
|
5
|
+
import { MediaLinkingActionsTypes } from '../pm-plugins/linking/actions';
|
|
6
|
+
import { getMediaPluginState } from '../pm-plugins/main';
|
|
7
|
+
import { checkMediaType } from '../utils/check-media-type';
|
|
8
|
+
import { currentMediaNode } from '../utils/current-media-node';
|
|
9
|
+
export const showLinkingToolbar = createMediaLinkingCommand(state => {
|
|
10
|
+
const mediaLinkingState = getMediaLinkingState(state);
|
|
11
|
+
if (mediaLinkingState && mediaLinkingState.mediaPos !== null) {
|
|
12
|
+
const mediaSingle = state.doc.nodeAt(mediaLinkingState.mediaPos);
|
|
13
|
+
if (mediaSingle) {
|
|
14
|
+
return {
|
|
15
|
+
type: MediaLinkingActionsTypes.showToolbar
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
});
|
|
21
|
+
export const showLinkingToolbarWithMediaTypeCheck = (editorState, dispatch, editorView) => {
|
|
22
|
+
if (dispatch && editorView) {
|
|
23
|
+
const mediaNode = currentMediaNode(editorState);
|
|
24
|
+
if (!mediaNode) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
mediaClientConfig
|
|
29
|
+
} = getMediaPluginState(editorState);
|
|
30
|
+
if (!mediaClientConfig) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
checkMediaType(mediaNode, mediaClientConfig).then(mediaType => {
|
|
34
|
+
if ((mediaType === 'external' || mediaType === 'image') &&
|
|
35
|
+
// We make sure the selection and the node hasn't changed.
|
|
36
|
+
currentMediaNode(editorView.state) === mediaNode) {
|
|
37
|
+
dispatch(editorView.state.tr.setMeta(mediaLinkingPluginKey, {
|
|
38
|
+
type: MediaLinkingActionsTypes.showToolbar
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
const hideLinkingToolbarCommand = createMediaLinkingCommand({
|
|
46
|
+
type: MediaLinkingActionsTypes.hideToolbar
|
|
47
|
+
});
|
|
48
|
+
export const hideLinkingToolbar = (state, dispatch, view, focusFloatingToolbar) => {
|
|
49
|
+
hideLinkingToolbarCommand(state, dispatch, view);
|
|
50
|
+
|
|
51
|
+
// restore focus on the editor so keyboard shortcuts aren't lost to the browser
|
|
52
|
+
if (view && !focusFloatingToolbar) {
|
|
53
|
+
view.focus();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function getCurrentUrl(state) {
|
|
57
|
+
const {
|
|
58
|
+
link: linkType
|
|
59
|
+
} = state.schema.marks;
|
|
60
|
+
const mediaLinkingState = getMediaLinkingState(state);
|
|
61
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
65
|
+
const node = state.doc.nodeAt($pos.pos);
|
|
66
|
+
if (!node) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const hasLink = linkType.isInSet(node.marks);
|
|
70
|
+
if (!hasLink) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const link = node.marks.find(mark => mark.type === linkType); // Already check exist
|
|
74
|
+
const url = link.attrs.href;
|
|
75
|
+
return url;
|
|
76
|
+
}
|
|
77
|
+
function toggleLinkMark(tr, state, {
|
|
78
|
+
forceRemove = false,
|
|
79
|
+
url
|
|
80
|
+
}) {
|
|
81
|
+
const mediaLinkingState = getMediaLinkingState(state);
|
|
82
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
83
|
+
return tr;
|
|
84
|
+
}
|
|
85
|
+
const $pos = state.doc.resolve(mediaLinkingState.mediaPos);
|
|
86
|
+
const node = state.doc.nodeAt($pos.pos);
|
|
87
|
+
if (!node) {
|
|
88
|
+
return tr;
|
|
89
|
+
}
|
|
90
|
+
const linkMark = state.schema.marks.link;
|
|
91
|
+
const {
|
|
92
|
+
media
|
|
93
|
+
} = state.schema.nodes;
|
|
94
|
+
const toggleBlockLinkMark = createToggleBlockMarkOnRange(linkMark, (prevAttrs, node) => {
|
|
95
|
+
// Only add mark to media
|
|
96
|
+
if (!node || node.type !== media) {
|
|
97
|
+
return; //No op
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (forceRemove) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const href = normalizeUrl(url);
|
|
104
|
+
if (prevAttrs && prevAttrs.href === href) {
|
|
105
|
+
return; //No op
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (href.trim() === '') {
|
|
109
|
+
return false; // remove
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
...prevAttrs,
|
|
114
|
+
href: href
|
|
115
|
+
};
|
|
116
|
+
}, [media]);
|
|
117
|
+
toggleBlockLinkMark($pos.pos, $pos.pos + node.nodeSize, tr, state);
|
|
118
|
+
return tr;
|
|
119
|
+
}
|
|
120
|
+
const fireAnalyticForMediaLink = (tr, action, attributes = undefined, editorAnalyticsAPI) => {
|
|
121
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
122
|
+
action,
|
|
123
|
+
eventType: EVENT_TYPE.TRACK,
|
|
124
|
+
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
125
|
+
actionSubjectId: ACTION_SUBJECT_ID.LINK,
|
|
126
|
+
attributes
|
|
127
|
+
})(tr);
|
|
128
|
+
return tr;
|
|
129
|
+
};
|
|
130
|
+
export const unlink = editorAnalyticsAPI => createMediaLinkingCommand({
|
|
131
|
+
type: MediaLinkingActionsTypes.unlink
|
|
132
|
+
}, (tr, state) => {
|
|
133
|
+
const transaction = toggleLinkMark(tr, state, {
|
|
134
|
+
forceRemove: true
|
|
135
|
+
});
|
|
136
|
+
return fireAnalyticForMediaLink(transaction, ACTION.DELETED, undefined, editorAnalyticsAPI);
|
|
137
|
+
});
|
|
138
|
+
const getAction = (newUrl, state) => {
|
|
139
|
+
const currentUrl = getCurrentUrl(state);
|
|
140
|
+
if (!currentUrl) {
|
|
141
|
+
return ACTION.ADDED;
|
|
142
|
+
} else if (newUrl !== currentUrl) {
|
|
143
|
+
return ACTION.EDITED;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
};
|
|
147
|
+
export const setUrlToMedia = (url, inputMethod, editorAnalyticsAPI) => createMediaLinkingCommand({
|
|
148
|
+
type: MediaLinkingActionsTypes.setUrl,
|
|
149
|
+
payload: normalizeUrl(url)
|
|
150
|
+
}, (tr, state) => {
|
|
151
|
+
const action = getAction(url, state);
|
|
152
|
+
if (!action) {
|
|
153
|
+
return tr;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
157
|
+
url: url
|
|
158
|
+
});
|
|
159
|
+
fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? {
|
|
160
|
+
inputMethod
|
|
161
|
+
} : undefined, editorAnalyticsAPI);
|
|
162
|
+
return toggleLinkMarkResult;
|
|
163
|
+
} catch (e) {
|
|
164
|
+
fireAnalyticForMediaLink(tr, ACTION.ERRORED, {
|
|
165
|
+
action: action
|
|
166
|
+
}, editorAnalyticsAPI);
|
|
167
|
+
throw e;
|
|
168
|
+
}
|
|
169
|
+
});
|
package/dist/es2019/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { mediaPlugin } from './plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|