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