@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,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { hideLinkingToolbar, setUrlToMedia, unlink } from '../commands/linking';
|
|
4
|
+
import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
5
|
+
import MediaLinkingToolbar from '../ui/MediaLinkingToolbar';
|
|
6
|
+
const FORCE_FOCUS_SELECTOR = '[data-testid="add-link-button"],[data-testid="edit-link-button"]';
|
|
7
|
+
export function shouldShowMediaLinkToolbar(editorState) {
|
|
8
|
+
const mediaLinkingState = getMediaLinkingState(editorState);
|
|
9
|
+
if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const {
|
|
13
|
+
nodes: {
|
|
14
|
+
media
|
|
15
|
+
},
|
|
16
|
+
marks: {
|
|
17
|
+
link
|
|
18
|
+
}
|
|
19
|
+
} = editorState.schema;
|
|
20
|
+
const node = editorState.doc.nodeAt(mediaLinkingState.mediaPos);
|
|
21
|
+
if (!node || node.type !== media) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
parent
|
|
26
|
+
} = editorState.doc.resolve(mediaLinkingState.mediaPos);
|
|
27
|
+
return parent && parent.type.allowsMarkType(link);
|
|
28
|
+
}
|
|
29
|
+
export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, intl, pluginInjectionApi, providerFactory) => {
|
|
30
|
+
const {
|
|
31
|
+
link,
|
|
32
|
+
visible,
|
|
33
|
+
editable: editing,
|
|
34
|
+
mediaPos
|
|
35
|
+
} = mediaLinkingState;
|
|
36
|
+
if (visible && mediaPos !== null) {
|
|
37
|
+
const node = state.doc.nodeAt(mediaPos);
|
|
38
|
+
if (node) {
|
|
39
|
+
return {
|
|
40
|
+
...toolbarBaseConfig,
|
|
41
|
+
height: RECENT_SEARCH_HEIGHT_IN_PX,
|
|
42
|
+
width: RECENT_SEARCH_WIDTH_IN_PX,
|
|
43
|
+
forcePlacement: true,
|
|
44
|
+
items: [{
|
|
45
|
+
type: 'custom',
|
|
46
|
+
fallback: [],
|
|
47
|
+
disableArrowNavigation: true,
|
|
48
|
+
render: (view, idx) => {
|
|
49
|
+
if (!view || !providerFactory) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return /*#__PURE__*/React.createElement(MediaLinkingToolbar, {
|
|
53
|
+
key: idx,
|
|
54
|
+
displayUrl: link,
|
|
55
|
+
providerFactory: providerFactory,
|
|
56
|
+
intl: intl,
|
|
57
|
+
editing: editing,
|
|
58
|
+
onUnlink: () => {
|
|
59
|
+
var _pluginInjectionApi$a;
|
|
60
|
+
return unlink(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(view.state, view.dispatch, view);
|
|
61
|
+
},
|
|
62
|
+
onBack: (href, meta) => {
|
|
63
|
+
if (href.trim() && meta.inputMethod) {
|
|
64
|
+
var _pluginInjectionApi$a2;
|
|
65
|
+
setUrlToMedia(href, meta.inputMethod, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(view.state, view.dispatch, view);
|
|
66
|
+
}
|
|
67
|
+
hideLinkingToolbar(view.state, view.dispatch, view);
|
|
68
|
+
},
|
|
69
|
+
onCancel: () => {
|
|
70
|
+
var _pluginInjectionApi$f;
|
|
71
|
+
hideLinkingToolbar(view.state, view.dispatch, view, true);
|
|
72
|
+
/** Focus should move to the 'Add link' button when the toolbar closes
|
|
73
|
+
* and not close the floating toolbar.
|
|
74
|
+
*/
|
|
75
|
+
const {
|
|
76
|
+
state: {
|
|
77
|
+
tr
|
|
78
|
+
},
|
|
79
|
+
dispatch
|
|
80
|
+
} = view;
|
|
81
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
|
|
82
|
+
dispatch(tr);
|
|
83
|
+
},
|
|
84
|
+
onSubmit: (href, meta) => {
|
|
85
|
+
var _pluginInjectionApi$a3;
|
|
86
|
+
setUrlToMedia(href, meta.inputMethod, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(view.state, view.dispatch, view);
|
|
87
|
+
hideLinkingToolbar(view.state, view.dispatch, view);
|
|
88
|
+
},
|
|
89
|
+
onBlur: () => {
|
|
90
|
+
hideLinkingToolbar(view.state, view.dispatch, view);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { wrappedLayouts } from '@atlaskit/editor-common/media-single';
|
|
2
|
+
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { getMediaClient } from '@atlaskit/media-client';
|
|
5
|
+
export const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
|
|
6
|
+
const selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
7
|
+
if (selectedNode && selectedNode.attrs) {
|
|
8
|
+
return selectedNode.attrs;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
export const downloadMedia = async mediaPluginState => {
|
|
13
|
+
try {
|
|
14
|
+
const selectedNodeAttrs = getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
15
|
+
if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
collection = ''
|
|
19
|
+
} = selectedNodeAttrs;
|
|
20
|
+
const mediaClient = getMediaClient(mediaPluginState.mediaClientConfig);
|
|
21
|
+
const fileState = await mediaClient.file.getCurrentState(id, {
|
|
22
|
+
collectionName: collection
|
|
23
|
+
});
|
|
24
|
+
const fileName = fileState.status === 'error' ? undefined : fileState.name;
|
|
25
|
+
mediaClient.file.downloadBinary(id, fileName, collection);
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const removeMediaGroupNode = state => {
|
|
33
|
+
const {
|
|
34
|
+
mediaGroup
|
|
35
|
+
} = state.schema.nodes;
|
|
36
|
+
const mediaGroupParent = findParentNodeOfType(mediaGroup)(state.selection);
|
|
37
|
+
let tr = state.tr;
|
|
38
|
+
// If it is the last media group in filmstrip, remove the entire filmstrip
|
|
39
|
+
if (mediaGroupParent && mediaGroupParent.node.childCount === 1) {
|
|
40
|
+
tr = removeParentNodeOfType(mediaGroup)(tr);
|
|
41
|
+
} else {
|
|
42
|
+
tr = removeSelectedNode(tr);
|
|
43
|
+
}
|
|
44
|
+
return tr;
|
|
45
|
+
};
|
|
46
|
+
export const getSelectedMediaSingle = state => {
|
|
47
|
+
const {
|
|
48
|
+
mediaSingle
|
|
49
|
+
} = state.schema.nodes;
|
|
50
|
+
return findSelectedNodeOfType(mediaSingle)(state.selection) || findParentNodeOfType(mediaSingle)(state.selection);
|
|
51
|
+
};
|
|
52
|
+
export const getPixelWidthOfElement = (editorView, pos, mediaWidth) => {
|
|
53
|
+
const domNode = editorView.nodeDOM(pos);
|
|
54
|
+
if (domNode instanceof HTMLElement) {
|
|
55
|
+
return domNode.offsetWidth;
|
|
56
|
+
}
|
|
57
|
+
return mediaWidth;
|
|
58
|
+
};
|
|
59
|
+
export const calcNewLayout = (width, layout, contentWidth, fullWidthMode = false) => {
|
|
60
|
+
const isWrappedLayout = wrappedLayouts.indexOf(layout) > -1;
|
|
61
|
+
if (width >= akEditorFullWidthLayoutWidth) {
|
|
62
|
+
// If width is greater than or equal to full editor width
|
|
63
|
+
return 'full-width';
|
|
64
|
+
}
|
|
65
|
+
if (fullWidthMode) {
|
|
66
|
+
// If under editor full width mode
|
|
67
|
+
return isWrappedLayout ? layout : 'center';
|
|
68
|
+
}
|
|
69
|
+
if (width > contentWidth) {
|
|
70
|
+
// If width is greater than content length and not nested
|
|
71
|
+
return 'wide';
|
|
72
|
+
}
|
|
73
|
+
return isWrappedLayout && width !== contentWidth ? layout : 'center';
|
|
74
|
+
};
|
|
75
|
+
let maxToolbarFitWidth = 0;
|
|
76
|
+
export const getMaxToolbarWidth = () => {
|
|
77
|
+
const toolbar = document.querySelector(`div[aria-label="Media floating controls"]`);
|
|
78
|
+
const toolbarWidth = toolbar === null || toolbar === void 0 ? void 0 : toolbar.getBoundingClientRect().width;
|
|
79
|
+
if (!toolbar) {
|
|
80
|
+
maxToolbarFitWidth = 0;
|
|
81
|
+
}
|
|
82
|
+
if (toolbarWidth && toolbarWidth > maxToolbarFitWidth) {
|
|
83
|
+
maxToolbarFitWidth = toolbarWidth;
|
|
84
|
+
}
|
|
85
|
+
return maxToolbarFitWidth;
|
|
86
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
|
|
6
|
+
import { N200 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { messages } from './messages';
|
|
8
|
+
const placeholder = css`
|
|
9
|
+
color: ${`var(--ds-text-subtlest, ${N200})`};
|
|
10
|
+
width: 100%;
|
|
11
|
+
text-align: center;
|
|
12
|
+
margin-top: ${"var(--ds-space-100, 8px)"} !important;
|
|
13
|
+
display: block;
|
|
14
|
+
`;
|
|
15
|
+
export default /*#__PURE__*/React.forwardRef(({
|
|
16
|
+
onClick
|
|
17
|
+
}, ref) => {
|
|
18
|
+
return jsx("span", {
|
|
19
|
+
ref: ref,
|
|
20
|
+
css: placeholder,
|
|
21
|
+
onClick: onClick,
|
|
22
|
+
"data-id": CAPTION_PLACEHOLDER_ID,
|
|
23
|
+
"data-testid": "caption-placeholder"
|
|
24
|
+
}, jsx(FormattedMessage, messages.placeholder));
|
|
25
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
placeholder: {
|
|
4
|
+
id: 'fabric.editor.captionPlaceholder',
|
|
5
|
+
defaultMessage: 'Add a caption',
|
|
6
|
+
description: 'Placeholder description for an empty (new) caption in the editor'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { BorderIcon } from '@atlaskit/editor-common/icons';
|
|
5
|
+
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
7
|
+
import { borderColorPalette, borderPaletteTooltipMessages, ColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
8
|
+
import { ArrowKeyNavigationType, DropdownMenu, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
9
|
+
import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
|
|
10
|
+
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
11
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
12
|
+
import { messages } from './messages';
|
|
13
|
+
import { buttonStyle, buttonWrapperStyle, contextualMenuArrow, contextualMenuColorIcon, contextualSubMenu, itemSpacing, line, menuItemDimensions, toolbarButtonWrapper } from './styles';
|
|
14
|
+
const ImageBorder = ({
|
|
15
|
+
intl: {
|
|
16
|
+
formatMessage
|
|
17
|
+
},
|
|
18
|
+
toggleBorder,
|
|
19
|
+
borderMark,
|
|
20
|
+
setBorder
|
|
21
|
+
}) => {
|
|
22
|
+
const popupTarget = useRef(null);
|
|
23
|
+
const enabled = !!borderMark;
|
|
24
|
+
const color = borderMark === null || borderMark === void 0 ? void 0 : borderMark.color;
|
|
25
|
+
const size = borderMark === null || borderMark === void 0 ? void 0 : borderMark.size;
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
const [isColorSubmenuOpen, setIsColorSubmenuOpen] = useState(false);
|
|
28
|
+
const [isSizeSubmenuOpen, setIsSizeSubmenuOpen] = useState(false);
|
|
29
|
+
const handleSubMenuRef = ref => {
|
|
30
|
+
if (!ref) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const rect = ref.getBoundingClientRect();
|
|
34
|
+
if (rect.left + rect.width > window.innerWidth) {
|
|
35
|
+
ref.style.left = `-${rect.width}px`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const borderSizeOptions = [{
|
|
39
|
+
name: formatMessage(messages.borderSizeSubtle),
|
|
40
|
+
value: 1
|
|
41
|
+
}, {
|
|
42
|
+
name: formatMessage(messages.borderSizeMedium),
|
|
43
|
+
value: 2
|
|
44
|
+
}, {
|
|
45
|
+
name: formatMessage(messages.borderSizeBold),
|
|
46
|
+
value: 3
|
|
47
|
+
}];
|
|
48
|
+
const items = [{
|
|
49
|
+
content: formatMessage(messages.borderColor),
|
|
50
|
+
value: {
|
|
51
|
+
name: 'color'
|
|
52
|
+
},
|
|
53
|
+
elemAfter: jsx("div", {
|
|
54
|
+
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
55
|
+
}, jsx("div", {
|
|
56
|
+
css: contextualMenuColorIcon(color && hexToEditorBorderPaletteColor(color))
|
|
57
|
+
}), isColorSubmenuOpen && jsx("div", {
|
|
58
|
+
css: contextualSubMenu(0),
|
|
59
|
+
ref: handleSubMenuRef
|
|
60
|
+
}, jsx(ColorPalette, {
|
|
61
|
+
onClick: color => {
|
|
62
|
+
setBorder({
|
|
63
|
+
color
|
|
64
|
+
});
|
|
65
|
+
setIsOpen(!isOpen);
|
|
66
|
+
},
|
|
67
|
+
selectedColor: color !== null && color !== void 0 ? color : null,
|
|
68
|
+
paletteOptions: {
|
|
69
|
+
palette: borderColorPalette,
|
|
70
|
+
paletteColorTooltipMessages: borderPaletteTooltipMessages,
|
|
71
|
+
hexToPaletteColor: hexToEditorBorderPaletteColor
|
|
72
|
+
}
|
|
73
|
+
})))
|
|
74
|
+
}, {
|
|
75
|
+
content: formatMessage(messages.borderSize),
|
|
76
|
+
value: {
|
|
77
|
+
name: 'size'
|
|
78
|
+
},
|
|
79
|
+
elemAfter: jsx("div", {
|
|
80
|
+
className: DropdownMenuSharedCssClassName.SUBMENU
|
|
81
|
+
}, jsx("div", {
|
|
82
|
+
css: contextualMenuArrow
|
|
83
|
+
}), isSizeSubmenuOpen && jsx("div", {
|
|
84
|
+
css: contextualSubMenu(1),
|
|
85
|
+
ref: handleSubMenuRef
|
|
86
|
+
}, borderSizeOptions.map(({
|
|
87
|
+
name,
|
|
88
|
+
value
|
|
89
|
+
}, idx) => jsx(Tooltip, {
|
|
90
|
+
key: idx,
|
|
91
|
+
content: name
|
|
92
|
+
}, jsx("span", {
|
|
93
|
+
css: buttonWrapperStyle
|
|
94
|
+
}, jsx("button", {
|
|
95
|
+
css: buttonStyle(value === size),
|
|
96
|
+
"aria-label": name,
|
|
97
|
+
role: "radio",
|
|
98
|
+
"aria-checked": value === size,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setBorder({
|
|
101
|
+
size: value
|
|
102
|
+
});
|
|
103
|
+
setIsOpen(false);
|
|
104
|
+
},
|
|
105
|
+
onMouseDown: e => {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
}
|
|
108
|
+
}, jsx("div", {
|
|
109
|
+
css: line(value, value === size),
|
|
110
|
+
role: "presentation"
|
|
111
|
+
})))))))
|
|
112
|
+
}];
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* We want to change direction of our dropdowns a bit early,
|
|
116
|
+
* not exactly when it hits the boundary.
|
|
117
|
+
*/
|
|
118
|
+
const fitTolerance = 10;
|
|
119
|
+
const fitWidth = menuItemDimensions.width;
|
|
120
|
+
const fitHeight = items.length * (menuItemDimensions.height + itemSpacing);
|
|
121
|
+
return jsx("div", null, jsx("div", {
|
|
122
|
+
css: toolbarButtonWrapper({
|
|
123
|
+
enabled,
|
|
124
|
+
isOpen
|
|
125
|
+
})
|
|
126
|
+
}, jsx(ToolbarButton, {
|
|
127
|
+
className: "image-border-toolbar-btn",
|
|
128
|
+
selected: enabled,
|
|
129
|
+
onClick: toggleBorder,
|
|
130
|
+
spacing: "compact",
|
|
131
|
+
"aria-label": enabled ? formatMessage(messages.removeBorder) : formatMessage(messages.addBorder),
|
|
132
|
+
iconBefore: jsx(BorderIcon, {
|
|
133
|
+
label: ""
|
|
134
|
+
}),
|
|
135
|
+
title: enabled ? formatMessage(messages.removeBorder) : formatMessage(messages.addBorder)
|
|
136
|
+
}), jsx("div", {
|
|
137
|
+
ref: popupTarget
|
|
138
|
+
}, jsx(ToolbarButton, {
|
|
139
|
+
className: "image-border-toolbar-dropdown",
|
|
140
|
+
selected: enabled || isOpen,
|
|
141
|
+
"aria-label": formatMessage(messages.borderOptions),
|
|
142
|
+
title: formatMessage(messages.borderOptions),
|
|
143
|
+
spacing: "compact",
|
|
144
|
+
iconBefore: jsx(ExpandIcon, {
|
|
145
|
+
label: ""
|
|
146
|
+
}),
|
|
147
|
+
onClick: () => {
|
|
148
|
+
setIsOpen(!isOpen);
|
|
149
|
+
}
|
|
150
|
+
}))), jsx(Popup, {
|
|
151
|
+
target: popupTarget.current ? popupTarget.current : undefined,
|
|
152
|
+
fitWidth: fitWidth + fitTolerance,
|
|
153
|
+
fitHeight: fitHeight + fitTolerance,
|
|
154
|
+
forcePlacement: true,
|
|
155
|
+
stick: true
|
|
156
|
+
}, jsx("div", {
|
|
157
|
+
onMouseLeave: () => {
|
|
158
|
+
setIsColorSubmenuOpen(false);
|
|
159
|
+
setIsSizeSubmenuOpen(false);
|
|
160
|
+
}
|
|
161
|
+
}, jsx(DropdownMenu
|
|
162
|
+
//This needs be removed when the a11y is completely handled
|
|
163
|
+
//Disabling key navigation now as it works only partially
|
|
164
|
+
//Same with packages/editor/editor-plugin-table/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx
|
|
165
|
+
, {
|
|
166
|
+
arrowKeyNavigationProviderOptions: {
|
|
167
|
+
type: ArrowKeyNavigationType.MENU,
|
|
168
|
+
disableArrowKeyNavigation: true
|
|
169
|
+
},
|
|
170
|
+
items: [{
|
|
171
|
+
items
|
|
172
|
+
}],
|
|
173
|
+
isOpen: isOpen,
|
|
174
|
+
onOpenChange: () => {
|
|
175
|
+
setIsOpen(false);
|
|
176
|
+
setIsColorSubmenuOpen(false);
|
|
177
|
+
setIsSizeSubmenuOpen(false);
|
|
178
|
+
},
|
|
179
|
+
onItemActivated: ({
|
|
180
|
+
item
|
|
181
|
+
}) => {
|
|
182
|
+
if (item.value.name === 'color') {
|
|
183
|
+
setIsColorSubmenuOpen(!isColorSubmenuOpen);
|
|
184
|
+
}
|
|
185
|
+
if (item.value.name === 'size') {
|
|
186
|
+
setIsSizeSubmenuOpen(!isSizeSubmenuOpen);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
onMouseEnter: ({
|
|
190
|
+
item
|
|
191
|
+
}) => {
|
|
192
|
+
if (item.value.name === 'color') {
|
|
193
|
+
setIsColorSubmenuOpen(true);
|
|
194
|
+
}
|
|
195
|
+
if (item.value.name === 'size') {
|
|
196
|
+
setIsSizeSubmenuOpen(true);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onMouseLeave: ({
|
|
200
|
+
item
|
|
201
|
+
}) => {
|
|
202
|
+
if (item.value.name === 'color') {
|
|
203
|
+
setIsColorSubmenuOpen(false);
|
|
204
|
+
}
|
|
205
|
+
if (item.value.name === 'size') {
|
|
206
|
+
setIsSizeSubmenuOpen(false);
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
fitWidth: fitWidth + fitTolerance,
|
|
210
|
+
fitHeight: fitHeight + fitTolerance
|
|
211
|
+
}))));
|
|
212
|
+
};
|
|
213
|
+
export default ImageBorder;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
borderColor: {
|
|
4
|
+
id: 'fabric.editor.imageBorderColor',
|
|
5
|
+
defaultMessage: 'Color',
|
|
6
|
+
description: 'Change the border color of an image.'
|
|
7
|
+
},
|
|
8
|
+
borderSize: {
|
|
9
|
+
id: 'fabric.editor.imageBorderSize',
|
|
10
|
+
defaultMessage: 'Size',
|
|
11
|
+
description: 'Change the border size of an image.'
|
|
12
|
+
},
|
|
13
|
+
addBorder: {
|
|
14
|
+
id: 'fabric.editor.addImageBorder',
|
|
15
|
+
defaultMessage: 'Add border',
|
|
16
|
+
description: 'Add a border to an image.'
|
|
17
|
+
},
|
|
18
|
+
removeBorder: {
|
|
19
|
+
id: 'fabric.editor.removeImageBorder',
|
|
20
|
+
defaultMessage: 'Remove border',
|
|
21
|
+
description: 'Remove the border of an image.'
|
|
22
|
+
},
|
|
23
|
+
borderOptions: {
|
|
24
|
+
id: 'fabric.editor.imageBorderOptions',
|
|
25
|
+
defaultMessage: 'Border options',
|
|
26
|
+
description: 'Display options available for customizing the border of an image.'
|
|
27
|
+
},
|
|
28
|
+
borderSizeSubtle: {
|
|
29
|
+
id: 'fabric.editor.imageBorderSubtle',
|
|
30
|
+
defaultMessage: 'Subtle',
|
|
31
|
+
description: 'Name of a border size.'
|
|
32
|
+
},
|
|
33
|
+
borderSizeMedium: {
|
|
34
|
+
id: 'fabric.editor.imageBorderMedium',
|
|
35
|
+
defaultMessage: 'Medium',
|
|
36
|
+
description: 'Name of a border size.'
|
|
37
|
+
},
|
|
38
|
+
borderSizeBold: {
|
|
39
|
+
id: 'fabric.editor.imageBorderBold',
|
|
40
|
+
defaultMessage: 'Bold',
|
|
41
|
+
description: 'Name of a border size.'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
3
|
+
import * as colors from '@atlaskit/theme/colors';
|
|
4
|
+
import { N0, N20A, N50, N60A, N800, N90 } from '@atlaskit/theme/colors';
|
|
5
|
+
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
6
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
7
|
+
// menuItemDimensions and itemSpacing are copied from
|
|
8
|
+
// packages/editor/editor-core/src/plugins/floating-toolbar/ui/DropdownMenu.tsx
|
|
9
|
+
export const menuItemDimensions = {
|
|
10
|
+
width: 175,
|
|
11
|
+
height: 32
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// TODO: Migrate away from gridSize
|
|
15
|
+
// Recommendation: Replace directly with 4 due to itemSpacing being used in calculations
|
|
16
|
+
export const itemSpacing = gridSize() / 2;
|
|
17
|
+
export const contextualMenuArrow = css`
|
|
18
|
+
display: flex;
|
|
19
|
+
&::after {
|
|
20
|
+
content: '›';
|
|
21
|
+
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
22
|
+
line-height: 20px;
|
|
23
|
+
color: ${`var(--ds-icon, ${N90})`};
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
export const contextualMenuColorIcon = color => css`
|
|
27
|
+
${contextualMenuArrow}
|
|
28
|
+
&::before {
|
|
29
|
+
content: '';
|
|
30
|
+
display: block;
|
|
31
|
+
border: 1px solid ${DEFAULT_BORDER_COLOR};
|
|
32
|
+
border-radius: ${"var(--ds-border-radius-100, 3px)"};
|
|
33
|
+
width: 20px;
|
|
34
|
+
height: 20px;
|
|
35
|
+
${color && `background: ${color}`}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
export const contextualSubMenu = index => css`
|
|
39
|
+
border-radius: ${"var(--ds-border-radius-100, 3px)"};
|
|
40
|
+
background: ${"var(--ds-surface-overlay, white)"};
|
|
41
|
+
box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
|
|
42
|
+
display: flex;
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: ${index * (menuItemDimensions.height + itemSpacing * 2)}px;
|
|
45
|
+
left: ${menuItemDimensions.width}px;
|
|
46
|
+
padding: ${"var(--ds-space-100, 8px)"};
|
|
47
|
+
|
|
48
|
+
> div {
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
export const buttonStyle = selected => css`
|
|
53
|
+
height: 26px;
|
|
54
|
+
width: 26px;
|
|
55
|
+
padding: 0;
|
|
56
|
+
border-radius: 4px;
|
|
57
|
+
background-color: ${selected ? `var(--ds-text, ${N800})` : `var(--ds-background-neutral, ${N20A})`};
|
|
58
|
+
border: 1px solid ${DEFAULT_BORDER_COLOR};
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
display: block;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
64
|
+
export const buttonWrapperStyle = css`
|
|
65
|
+
border: 1px solid transparent;
|
|
66
|
+
margin: 1px;
|
|
67
|
+
font-size: 0;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
padding: 1px;
|
|
71
|
+
border-radius: 6px;
|
|
72
|
+
&:focus-within,
|
|
73
|
+
&:focus,
|
|
74
|
+
&:hover {
|
|
75
|
+
border-color: ${N50} !important;
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
export const line = (size, selected) => css`
|
|
79
|
+
position: relative;
|
|
80
|
+
&:before {
|
|
81
|
+
content: '';
|
|
82
|
+
display: block;
|
|
83
|
+
position: absolute;
|
|
84
|
+
top: 50%;
|
|
85
|
+
left: 50%;
|
|
86
|
+
width: 12px;
|
|
87
|
+
height: ${size}px;
|
|
88
|
+
background-color: ${selected ? `var(--ds-icon-inverse, ${N0})` : "var(--ds-icon, #44546F)"};
|
|
89
|
+
border-radius: 90px;
|
|
90
|
+
transform: translate(-50%, -50%) rotate(135deg);
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
const getHoverStyles = selector => `&:hover ${selector} {
|
|
94
|
+
background: ${`var(--ds-background-neutral-subtle-hovered, ${colors.N20A})`};
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
background: ${`var(--ds-background-neutral-hovered, ${colors.N30A})`};
|
|
98
|
+
}
|
|
99
|
+
}`;
|
|
100
|
+
export const toolbarButtonWrapper = ({
|
|
101
|
+
enabled,
|
|
102
|
+
isOpen
|
|
103
|
+
}) => css`
|
|
104
|
+
display: flex;
|
|
105
|
+
.image-border-toolbar-btn {
|
|
106
|
+
border-top-right-radius: 0;
|
|
107
|
+
border-bottom-right-radius: 0;
|
|
108
|
+
padding: 0;
|
|
109
|
+
& > span {
|
|
110
|
+
margin: 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
.image-border-toolbar-dropdown {
|
|
114
|
+
padding: 0;
|
|
115
|
+
& > span {
|
|
116
|
+
margin: 0;
|
|
117
|
+
}
|
|
118
|
+
width: 16px !important;
|
|
119
|
+
border-top-left-radius: 0 !important;
|
|
120
|
+
border-bottom-left-radius: 0 !important;
|
|
121
|
+
margin-left: 1px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
${!enabled && getHoverStyles('.image-border-toolbar-btn')}
|
|
125
|
+
${!isOpen && !enabled && getHoverStyles('.image-border-toolbar-dropdown')}
|
|
126
|
+
`;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { hexToRgba } from '@atlaskit/adf-schema';
|
|
5
|
+
import DocumentFilledIcon from '@atlaskit/icon/glyph/document-filled';
|
|
6
|
+
import { B200, B300, B400 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { borderRadius } from '@atlaskit/theme/constants';
|
|
8
|
+
import { FILE_WIDTH, MEDIA_HEIGHT } from '../../nodeviews/mediaNodeView/media';
|
|
9
|
+
import { dropPlaceholderMessages } from './drop-placeholder-messages';
|
|
10
|
+
const iconWrapper = css`
|
|
11
|
+
color: ${`var(--ds-icon-accent-blue, ${hexToRgba(B400, 0.4) || B400})`};
|
|
12
|
+
background: ${`var(--ds-background-accent-blue-subtle, ${hexToRgba(B300, 0.6) || B300})`};
|
|
13
|
+
border-radius: ${borderRadius()}px;
|
|
14
|
+
margin: 5px 3px 25px;
|
|
15
|
+
width: ${FILE_WIDTH}px;
|
|
16
|
+
min-height: ${MEDIA_HEIGHT}px;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
`;
|
|
21
|
+
const dropLine = css`
|
|
22
|
+
background: ${`var(--ds-border-focused, ${B200})`};
|
|
23
|
+
border-radius: ${borderRadius()}px;
|
|
24
|
+
margin: ${"var(--ds-space-025, 2px)"} 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 2px;
|
|
27
|
+
`;
|
|
28
|
+
const IconWrapperComponent = props => {
|
|
29
|
+
const {
|
|
30
|
+
intl
|
|
31
|
+
} = props;
|
|
32
|
+
const {
|
|
33
|
+
dropPlaceholderLabel
|
|
34
|
+
} = dropPlaceholderMessages;
|
|
35
|
+
return jsx("div", {
|
|
36
|
+
css: iconWrapper
|
|
37
|
+
}, jsx(DocumentFilledIcon, {
|
|
38
|
+
label: intl.formatMessage(dropPlaceholderLabel),
|
|
39
|
+
size: "medium"
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
const IntlIconWrapper = injectIntl(IconWrapperComponent);
|
|
43
|
+
export default (({
|
|
44
|
+
type = 'group'
|
|
45
|
+
}) => type === 'single' ? jsx("div", {
|
|
46
|
+
css: dropLine
|
|
47
|
+
}) : jsx(IntlIconWrapper, null));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const dropPlaceholderMessages = defineMessages({
|
|
3
|
+
dropPlaceholderLabel: {
|
|
4
|
+
id: 'fabric.editor.dropPlaceholderLabel',
|
|
5
|
+
defaultMessage: 'Document',
|
|
6
|
+
description: 'document label for an media icon'
|
|
7
|
+
}
|
|
8
|
+
});
|