@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,206 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
9
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
/** @jsx jsx */
|
|
13
|
+
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { css, jsx } from '@emotion/react';
|
|
16
|
+
import { injectIntl } from 'react-intl-next';
|
|
17
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
18
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
19
|
+
import { escape, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
20
|
+
import { PanelTextInput } from '@atlaskit/editor-common/ui';
|
|
21
|
+
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
22
|
+
import { RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
23
|
+
import { ErrorMessage } from '@atlaskit/editor-common/ui';
|
|
24
|
+
import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
25
|
+
import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
|
|
26
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
27
|
+
import { N100, N30, N80, R400 } from '@atlaskit/theme/colors';
|
|
28
|
+
import { closeMediaAltTextMenu, updateAltText } from '../commands';
|
|
29
|
+
import { messages } from '../messages';
|
|
30
|
+
export var CONTAINER_WIDTH_IN_PX = RECENT_SEARCH_WIDTH_IN_PX;
|
|
31
|
+
export var MAX_ALT_TEXT_LENGTH = 510; // double tweet length
|
|
32
|
+
|
|
33
|
+
var supportText = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n padding: ", " ", ";\n line-height: 20px;\n border-top: 1px solid ", ";\n margin: 0;\n"])), "var(--ds-text-subtlest, ".concat(N100, ")"), relativeFontSizeToBase16(12), "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border, ".concat(N30, ")"));
|
|
34
|
+
var container = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "px;\n display: flex;\n flex-direction: column;\n overflow: auto;\n line-height: 2;\n"])), CONTAINER_WIDTH_IN_PX);
|
|
35
|
+
var inputWrapper = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n line-height: 0;\n padding: 5px 0;\n align-items: center;\n"])));
|
|
36
|
+
var validationWrapper = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n line-height: 0;\n padding: ", " ", "\n ", " 0;\n margin: 0 ", " 0 ", ";\n border-top: 1px solid ", ";\n align-items: start;\n flex-direction: column;\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-300, 24px)", "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border-danger, ".concat(R400, ")"));
|
|
37
|
+
var buttonWrapper = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n padding: ", " ", ";\n"])), "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)");
|
|
38
|
+
var clearText = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon-subtle, ".concat(N80, ")"));
|
|
39
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
40
|
+
export var AltTextEditComponent = /*#__PURE__*/function (_React$Component) {
|
|
41
|
+
_inherits(AltTextEditComponent, _React$Component);
|
|
42
|
+
var _super = _createSuper(AltTextEditComponent);
|
|
43
|
+
function AltTextEditComponent(props) {
|
|
44
|
+
var _this;
|
|
45
|
+
_classCallCheck(this, AltTextEditComponent);
|
|
46
|
+
_this = _super.call(this, props);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
48
|
+
showClearTextButton: Boolean(_this.props.value),
|
|
49
|
+
validationErrors: _this.props.value ? _this.getValidationErrors(_this.props.value) : [],
|
|
50
|
+
lastValue: _this.props.value
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "closeMediaAltTextMenu", function () {
|
|
53
|
+
var view = _this.props.view;
|
|
54
|
+
closeMediaAltTextMenu(view.state, view.dispatch);
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "dispatchCancelEvent", function (event) {
|
|
57
|
+
var _this$props = _this.props,
|
|
58
|
+
view = _this$props.view,
|
|
59
|
+
onEscape = _this$props.onEscape;
|
|
60
|
+
|
|
61
|
+
// We need to pass down the ESCAPE keymap
|
|
62
|
+
// because when we focus on the Toolbar, Prosemirror blur,
|
|
63
|
+
// making all keyboard shortcuts not working
|
|
64
|
+
view.someProp('handleKeyDown', function (fn) {
|
|
65
|
+
return fn(view, event);
|
|
66
|
+
});
|
|
67
|
+
onEscape === null || onEscape === void 0 || onEscape();
|
|
68
|
+
});
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "updateAltText", function (newAltText) {
|
|
70
|
+
var view = _this.props.view;
|
|
71
|
+
var newValue = newAltText.length === 0 ? '' : newAltText;
|
|
72
|
+
updateAltText(newValue)(view.state, view.dispatch);
|
|
73
|
+
});
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "handleOnChange", function (newAltText) {
|
|
75
|
+
var validationErrors = _this.getValidationErrors(newAltText);
|
|
76
|
+
_this.setState({
|
|
77
|
+
showClearTextButton: Boolean(newAltText),
|
|
78
|
+
validationErrors: validationErrors,
|
|
79
|
+
lastValue: newAltText
|
|
80
|
+
}, function () {
|
|
81
|
+
if (!validationErrors || !validationErrors.length) {
|
|
82
|
+
_this.updateAltText(newAltText);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
_defineProperty(_assertThisInitialized(_this), "handleOnBlur", function () {
|
|
87
|
+
// Handling the trimming onBlur() because PanelTextInput doesn't sync
|
|
88
|
+
// defaultValue properly during unmount
|
|
89
|
+
var value = _this.props.value;
|
|
90
|
+
var newValue = (_this.state.lastValue || value || '').trim();
|
|
91
|
+
_this.handleOnChange(newValue);
|
|
92
|
+
});
|
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "handleClearText", function () {
|
|
94
|
+
_this.handleOnChange('');
|
|
95
|
+
});
|
|
96
|
+
var createAnalyticsEvent = props.createAnalyticsEvent;
|
|
97
|
+
_this.fireCustomAnalytics = fireAnalyticsEvent(createAnalyticsEvent);
|
|
98
|
+
return _this;
|
|
99
|
+
}
|
|
100
|
+
_createClass(AltTextEditComponent, [{
|
|
101
|
+
key: "componentDidMount",
|
|
102
|
+
value: function componentDidMount() {
|
|
103
|
+
this.prevValue = this.props.value;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "componentWillUnmount",
|
|
107
|
+
value: function componentWillUnmount() {
|
|
108
|
+
this.fireAnalytics(ACTION.CLOSED);
|
|
109
|
+
if (!this.prevValue && this.props.value) {
|
|
110
|
+
this.fireAnalytics(ACTION.ADDED);
|
|
111
|
+
}
|
|
112
|
+
if (this.prevValue && !this.props.value) {
|
|
113
|
+
this.fireAnalytics(ACTION.CLEARED);
|
|
114
|
+
}
|
|
115
|
+
if (this.prevValue && this.prevValue !== this.props.value) {
|
|
116
|
+
this.fireAnalytics(ACTION.EDITED);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "getValidationErrors",
|
|
121
|
+
value: function getValidationErrors(value) {
|
|
122
|
+
var altTextValidator = this.props.altTextValidator;
|
|
123
|
+
if (value && typeof altTextValidator === 'function') {
|
|
124
|
+
return altTextValidator(value) || [];
|
|
125
|
+
}
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "render",
|
|
130
|
+
value: function render() {
|
|
131
|
+
var formatMessage = this.props.intl.formatMessage;
|
|
132
|
+
var showClearTextButton = this.state.showClearTextButton;
|
|
133
|
+
var backButtonMessage = formatMessage(messages.back);
|
|
134
|
+
var backButtonMessageComponent = jsx(ToolTipContent, {
|
|
135
|
+
description: backButtonMessage,
|
|
136
|
+
keymap: escape,
|
|
137
|
+
shortcutOverride: "Esc"
|
|
138
|
+
});
|
|
139
|
+
var errorsList = (this.state.validationErrors || []).map(function (error, index) {
|
|
140
|
+
return jsx(ErrorMessage, {
|
|
141
|
+
key: index
|
|
142
|
+
}, error);
|
|
143
|
+
});
|
|
144
|
+
return jsx("div", {
|
|
145
|
+
css: container
|
|
146
|
+
}, jsx("section", {
|
|
147
|
+
css: inputWrapper
|
|
148
|
+
}, jsx("div", {
|
|
149
|
+
css: buttonWrapper
|
|
150
|
+
}, jsx(Button, {
|
|
151
|
+
title: formatMessage(messages.back),
|
|
152
|
+
icon: jsx(ChevronLeftLargeIcon, {
|
|
153
|
+
label: formatMessage(messages.back)
|
|
154
|
+
}),
|
|
155
|
+
tooltipContent: backButtonMessageComponent,
|
|
156
|
+
onClick: this.closeMediaAltTextMenu
|
|
157
|
+
})), jsx(PanelTextInput, {
|
|
158
|
+
testId: "alt-text-input",
|
|
159
|
+
ariaLabel: formatMessage(messages.placeholder),
|
|
160
|
+
describedById: "support-text",
|
|
161
|
+
placeholder: formatMessage(messages.placeholder),
|
|
162
|
+
defaultValue: this.state.lastValue,
|
|
163
|
+
onCancel: this.dispatchCancelEvent,
|
|
164
|
+
onChange: this.handleOnChange,
|
|
165
|
+
onBlur: this.handleOnBlur,
|
|
166
|
+
onSubmit: this.closeMediaAltTextMenu,
|
|
167
|
+
maxLength: MAX_ALT_TEXT_LENGTH,
|
|
168
|
+
autoFocus: true
|
|
169
|
+
}), showClearTextButton && jsx("div", {
|
|
170
|
+
css: buttonWrapper
|
|
171
|
+
}, jsx(Button, {
|
|
172
|
+
testId: "alt-text-clear-button",
|
|
173
|
+
title: formatMessage(messages.clear),
|
|
174
|
+
icon: jsx("span", {
|
|
175
|
+
css: clearText
|
|
176
|
+
}, jsx(CrossCircleIcon, {
|
|
177
|
+
label: formatMessage(messages.clear)
|
|
178
|
+
})),
|
|
179
|
+
tooltipContent: formatMessage(messages.clear),
|
|
180
|
+
onClick: this.handleClearText
|
|
181
|
+
}))), !!errorsList.length && jsx("section", {
|
|
182
|
+
css: validationWrapper
|
|
183
|
+
}, errorsList), jsx("p", {
|
|
184
|
+
css: supportText,
|
|
185
|
+
id: "support-text"
|
|
186
|
+
}, formatMessage(messages.supportText)));
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "fireAnalytics",
|
|
190
|
+
value: function fireAnalytics(actionType) {
|
|
191
|
+
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
192
|
+
if (createAnalyticsEvent && this.fireCustomAnalytics) {
|
|
193
|
+
this.fireCustomAnalytics({
|
|
194
|
+
payload: {
|
|
195
|
+
action: actionType,
|
|
196
|
+
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
197
|
+
actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
|
|
198
|
+
eventType: EVENT_TYPE.TRACK
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}]);
|
|
204
|
+
return AltTextEditComponent;
|
|
205
|
+
}(React.Component);
|
|
206
|
+
export default withAnalyticsEvents()(injectIntl(AltTextEditComponent));
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { backspace, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { atTheEndOfDoc } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { isEmptyNode, isSelectionInsideLastNodeInDocument } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { selectNodeBackward } from '@atlaskit/editor-prosemirror/commands';
|
|
5
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
|
+
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check if is an empty selection at the start of the node
|
|
10
|
+
*/
|
|
11
|
+
function isEmptySelectionAtStart(selection) {
|
|
12
|
+
if (!selection.empty) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
var $from = selection.$from;
|
|
16
|
+
return $from.parentOffset <= 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if the current selection is inside a node type
|
|
21
|
+
*/
|
|
22
|
+
function isSelectionInsideOf(selection, nodeType) {
|
|
23
|
+
var $from = selection.$from;
|
|
24
|
+
var parent = $from.parent;
|
|
25
|
+
return parent.type === nodeType;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Return the sibling of the current selection
|
|
30
|
+
*/
|
|
31
|
+
function getSibling(selection, sibling) {
|
|
32
|
+
var $from = selection.$from;
|
|
33
|
+
var index = $from.index($from.depth - 1);
|
|
34
|
+
var grandParent = $from.node($from.depth - 1); // Get GrandParent
|
|
35
|
+
|
|
36
|
+
return grandParent ? grandParent.maybeChild(index + sibling) : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if respective sibling (negative number previous, positive number next)
|
|
41
|
+
* is from the specified node
|
|
42
|
+
*/
|
|
43
|
+
function isSiblingOfType(selection, node, sibling) {
|
|
44
|
+
var maybeSiblingNode = getSibling(selection, sibling);
|
|
45
|
+
return !!maybeSiblingNode && maybeSiblingNode.type === node;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* When there's any empty block before another paragraph with wrap-right
|
|
49
|
+
* mediaSingle. Pressing backspace at the start of the paragraph will select
|
|
50
|
+
* the media but visually it makes more sense to remove the empty paragraph.
|
|
51
|
+
*
|
|
52
|
+
* Structure of the document: doc(block(), mediaSingle(media()), paragraph('{<>}hello!'))
|
|
53
|
+
* But, visually it looks like the following:
|
|
54
|
+
*
|
|
55
|
+
* [empty block] <- Remove this block
|
|
56
|
+
* or [paragraph block] <- Move text inside this paragraph
|
|
57
|
+
* or [any other block] <- Move paragraph node after this node
|
|
58
|
+
* [Cursor] x x x x x x x x +---------------+
|
|
59
|
+
* x x x x x x x x x x | mediaSingle |
|
|
60
|
+
* x x x x x. +---------------+
|
|
61
|
+
*/
|
|
62
|
+
function handleSelectionAfterWrapRight(isEmptyNode) {
|
|
63
|
+
function isEmptyWithoutThrow(node) {
|
|
64
|
+
var isEmpty = false;
|
|
65
|
+
try {
|
|
66
|
+
// We dont have isEmptyNode definition for table for example.
|
|
67
|
+
// In this case it will throw we need to catch it
|
|
68
|
+
isEmpty = isEmptyNode(node);
|
|
69
|
+
} catch (e) {}
|
|
70
|
+
return isEmpty;
|
|
71
|
+
}
|
|
72
|
+
return function (state, dispatch) {
|
|
73
|
+
var $from = state.selection.$from;
|
|
74
|
+
var paragraph = state.schema.nodes.paragraph;
|
|
75
|
+
var previousMediaSingleSibling = -2;
|
|
76
|
+
var maybeSibling = getSibling(state.selection, previousMediaSingleSibling);
|
|
77
|
+
if (!maybeSibling) {
|
|
78
|
+
// the last is the image so should let the default behaviour delete the image
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
var mediaSingle = getSibling(state.selection, -1); // Sibling is a media single already checked in main code
|
|
82
|
+
var mediaSinglePos = $from.pos - mediaSingle.nodeSize;
|
|
83
|
+
|
|
84
|
+
// Should find the position
|
|
85
|
+
// Should move the current paragraph to the last line
|
|
86
|
+
var maybeAnyBlockPos = mediaSinglePos - maybeSibling.nodeSize;
|
|
87
|
+
var tr = state.tr;
|
|
88
|
+
if (isEmptyWithoutThrow(maybeSibling)) {
|
|
89
|
+
// Should remove the empty sibling
|
|
90
|
+
tr = tr.replace(maybeAnyBlockPos - 1, maybeAnyBlockPos + maybeSibling.nodeSize);
|
|
91
|
+
} else {
|
|
92
|
+
// We move the current node, to the new position
|
|
93
|
+
// 1. Remove current node, only if I am not removing the last node.
|
|
94
|
+
if (!isSelectionInsideLastNodeInDocument(state.selection)) {
|
|
95
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
96
|
+
} else {
|
|
97
|
+
// Remove node content, if is the last node, let a empty paragraph
|
|
98
|
+
tr.replace($from.pos, $from.pos + $from.parent.nodeSize - 1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 2. Add it in the new position
|
|
102
|
+
// If the sibling is a paragraph lets copy the text inside the paragraph
|
|
103
|
+
// Like a normal backspace from paragraph to paragraph
|
|
104
|
+
if (maybeSibling.type === paragraph) {
|
|
105
|
+
var insideParagraphPos = maybeAnyBlockPos + maybeSibling.nodeSize - 2;
|
|
106
|
+
safeInsert($from.parent.content, insideParagraphPos)(tr);
|
|
107
|
+
} else {
|
|
108
|
+
// If is any other kind of block just add the paragraph after it
|
|
109
|
+
var endOfBlockPos = maybeAnyBlockPos + maybeSibling.nodeSize - 1;
|
|
110
|
+
safeInsert($from.parent.copy($from.parent.content), endOfBlockPos)(tr);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (dispatch) {
|
|
114
|
+
dispatch(tr);
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var maybeRemoveMediaSingleNode = function maybeRemoveMediaSingleNode(schema) {
|
|
120
|
+
var isEmptyNodeInSchema = isEmptyNode(schema);
|
|
121
|
+
return function (state, dispatch) {
|
|
122
|
+
var selection = state.selection,
|
|
123
|
+
schema = state.schema;
|
|
124
|
+
var $from = selection.$from;
|
|
125
|
+
if (!isEmptySelectionAtStart(state.selection)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (!isSelectionInsideOf(state.selection, schema.nodes.paragraph)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
var previousSibling = -1;
|
|
132
|
+
if (!isSiblingOfType(state.selection, schema.nodes.mediaSingle, previousSibling)) {
|
|
133
|
+
// no media single
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
var mediaSingle = getSibling(state.selection, previousSibling);
|
|
137
|
+
if (mediaSingle.attrs.layout === 'wrap-right') {
|
|
138
|
+
return handleSelectionAfterWrapRight(isEmptyNodeInSchema)(state, dispatch);
|
|
139
|
+
}
|
|
140
|
+
if (dispatch) {
|
|
141
|
+
// Select media single, and remove paragraph if it's empty.
|
|
142
|
+
selectNodeBackward(state, function (tr) {
|
|
143
|
+
if (isEmptyNodeInSchema($from.parent) && !atTheEndOfDoc(state)) {
|
|
144
|
+
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
dispatch(tr);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
export default function keymapPlugin(schema) {
|
|
154
|
+
var list = {};
|
|
155
|
+
var removeMediaSingleCommand = maybeRemoveMediaSingleNode(schema);
|
|
156
|
+
bindKeymapWithCommand(backspace.common, removeMediaSingleCommand, list);
|
|
157
|
+
return keymap(list);
|
|
158
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { bindKeymapWithCommand, enter, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
6
|
+
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
7
|
+
import { stateKey } from '../pm-plugins/plugin-key';
|
|
8
|
+
export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
9
|
+
var list = {};
|
|
10
|
+
var _ref = options || {},
|
|
11
|
+
featureFlags = _ref.featureFlags;
|
|
12
|
+
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
13
|
+
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
14
|
+
if (options !== null && options !== void 0 && options.allowCaptions || getMediaFeatureFlag('captions', featureFlags)) {
|
|
15
|
+
bindKeymapWithCommand(moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
16
|
+
bindKeymapWithCommand(tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
17
|
+
bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(editorSelectionAPI), list);
|
|
18
|
+
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
19
|
+
}
|
|
20
|
+
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
21
|
+
return keymap(list);
|
|
22
|
+
}
|
|
23
|
+
var ignoreLinksInSteps = function ignoreLinksInSteps(state) {
|
|
24
|
+
var mediaPluginState = stateKey.getState(state);
|
|
25
|
+
mediaPluginState.ignoreLinks = true;
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
var splitMediaGroup = function splitMediaGroup(state) {
|
|
29
|
+
var mediaPluginState = stateKey.getState(state);
|
|
30
|
+
return mediaPluginState.splitMediaGroup();
|
|
31
|
+
};
|
|
32
|
+
var insertAndSelectCaption = function insertAndSelectCaption(editorAnalyticsAPI) {
|
|
33
|
+
return function (state, dispatch) {
|
|
34
|
+
var selection = state.selection,
|
|
35
|
+
schema = state.schema;
|
|
36
|
+
if (selection instanceof NodeSelection && selection.node.type === schema.nodes.mediaSingle && schema.nodes.caption) {
|
|
37
|
+
if (dispatch) {
|
|
38
|
+
var from = selection.from,
|
|
39
|
+
node = selection.node;
|
|
40
|
+
if (!insertAndSelectCaptionFromMediaSinglePos(editorAnalyticsAPI)(from, node)(state, dispatch)) {
|
|
41
|
+
selectCaptionFromMediaSinglePos(from, node)(state, dispatch);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var arrowLeftFromMediaSingle = function arrowLeftFromMediaSingle(editorSelectionAPI) {
|
|
50
|
+
return function (state, dispatch) {
|
|
51
|
+
var selection = state.selection;
|
|
52
|
+
if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
53
|
+
var tr = editorSelectionAPI.selectNearNode({
|
|
54
|
+
selectionRelativeToNode: undefined,
|
|
55
|
+
selection: new GapCursorSelection(state.doc.resolve(selection.from), Side.LEFT)
|
|
56
|
+
})(state);
|
|
57
|
+
if (dispatch) {
|
|
58
|
+
dispatch(tr);
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
var arrowRightFromMediaSingle = function arrowRightFromMediaSingle(editorSelectionAPI) {
|
|
66
|
+
return function (state, dispatch) {
|
|
67
|
+
var selection = state.selection;
|
|
68
|
+
if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
69
|
+
var tr = editorSelectionAPI.selectNearNode({
|
|
70
|
+
selectionRelativeToNode: undefined,
|
|
71
|
+
selection: new GapCursorSelection(state.doc.resolve(selection.to), Side.RIGHT)
|
|
72
|
+
})(state);
|
|
73
|
+
if (dispatch) {
|
|
74
|
+
dispatch(tr);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export default keymapPlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var MediaLinkingActionsTypes = /*#__PURE__*/function (MediaLinkingActionsTypes) {
|
|
2
|
+
MediaLinkingActionsTypes["showToolbar"] = "MEDIA_SHOW_TOOLBAR";
|
|
3
|
+
MediaLinkingActionsTypes["hideToolbar"] = "MEDIA_HIDE_TOOLBAR";
|
|
4
|
+
MediaLinkingActionsTypes["setUrl"] = "MEDIA_SET_LINK_TO";
|
|
5
|
+
MediaLinkingActionsTypes["unlink"] = "MEDIA_LINKING_UNLINK";
|
|
6
|
+
return MediaLinkingActionsTypes;
|
|
7
|
+
}({});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
+
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import reducer from './reducer';
|
|
8
|
+
export var mediaLinkingPluginKey = new PluginKey('mediaLinking');
|
|
9
|
+
var initialState = {
|
|
10
|
+
visible: false,
|
|
11
|
+
editable: false,
|
|
12
|
+
mediaPos: null,
|
|
13
|
+
link: ''
|
|
14
|
+
};
|
|
15
|
+
function mapping(tr, pluginState) {
|
|
16
|
+
if (pluginState && pluginState.mediaPos !== null) {
|
|
17
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
18
|
+
mediaPos: tr.mapping.map(pluginState.mediaPos)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return pluginState;
|
|
22
|
+
}
|
|
23
|
+
function onSelectionChanged(tr) {
|
|
24
|
+
var isNodeSelection = tr.selection instanceof NodeSelection;
|
|
25
|
+
if (!isNodeSelection) {
|
|
26
|
+
return initialState;
|
|
27
|
+
}
|
|
28
|
+
var mediaPos = tr.selection.$from.pos + 1;
|
|
29
|
+
var node = tr.doc.nodeAt(mediaPos);
|
|
30
|
+
if (!node || node.type.name !== 'media') {
|
|
31
|
+
return initialState;
|
|
32
|
+
}
|
|
33
|
+
var mark = node.marks.find(function (mark) {
|
|
34
|
+
return mark.type.name === 'link';
|
|
35
|
+
});
|
|
36
|
+
if (mark) {
|
|
37
|
+
return _objectSpread(_objectSpread({}, initialState), {}, {
|
|
38
|
+
mediaPos: mediaPos,
|
|
39
|
+
editable: true,
|
|
40
|
+
link: mark.attrs.href
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return _objectSpread(_objectSpread({}, initialState), {}, {
|
|
44
|
+
mediaPos: mediaPos
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
var mediaLinkingPluginFactory = pluginFactory(mediaLinkingPluginKey, reducer, {
|
|
48
|
+
mapping: mapping,
|
|
49
|
+
onSelectionChanged: onSelectionChanged
|
|
50
|
+
});
|
|
51
|
+
var createMediaLinkingCommand = mediaLinkingPluginFactory.createCommand,
|
|
52
|
+
getMediaLinkingState = mediaLinkingPluginFactory.getPluginState;
|
|
53
|
+
export { createMediaLinkingCommand, getMediaLinkingState };
|
|
54
|
+
export default (function (dispatch) {
|
|
55
|
+
return new SafePlugin({
|
|
56
|
+
key: mediaLinkingPluginKey,
|
|
57
|
+
state: mediaLinkingPluginFactory.createPluginState(dispatch, initialState)
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { addLink, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
+
import { showLinkingToolbarWithMediaTypeCheck } from '../../commands/linking';
|
|
4
|
+
export default function keymapPlugin(schema) {
|
|
5
|
+
var list = {};
|
|
6
|
+
bindKeymapWithCommand(addLink.common, showLinkingToolbarWithMediaTypeCheck, list);
|
|
7
|
+
return keymap(list);
|
|
8
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { MediaLinkingActionsTypes } from './actions';
|
|
5
|
+
export default (function (state, action) {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case MediaLinkingActionsTypes.showToolbar:
|
|
8
|
+
{
|
|
9
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
10
|
+
visible: true
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
case MediaLinkingActionsTypes.setUrl:
|
|
14
|
+
{
|
|
15
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
16
|
+
editable: true,
|
|
17
|
+
link: action.payload
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
case MediaLinkingActionsTypes.hideToolbar:
|
|
21
|
+
{
|
|
22
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
23
|
+
visible: false
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
case MediaLinkingActionsTypes.unlink:
|
|
27
|
+
{
|
|
28
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
29
|
+
link: '',
|
|
30
|
+
visible: false,
|
|
31
|
+
editable: false
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return state;
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|