@atlaskit/editor-plugin-media 2.3.13 → 2.3.15
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 +19 -0
- package/dist/cjs/nodeviews/mediaInline.js +2 -1
- package/dist/cjs/nodeviews/mediaNodeView/index.js +3 -1
- package/dist/cjs/nodeviews/mediaNodeView/media.js +13 -1
- package/dist/cjs/pm-plugins/utils/media-single.js +13 -2
- package/dist/cjs/ui/toolbar/alt-text.js +20 -1
- package/dist/cjs/ui/toolbar/index.js +59 -82
- package/dist/cjs/ui/toolbar/mediaInline.js +75 -71
- package/dist/cjs/ui/toolbar/pixel-resizing.js +28 -3
- package/dist/cjs/ui/toolbar/utils.js +12 -1
- package/dist/es2019/nodeviews/mediaInline.js +2 -1
- package/dist/es2019/nodeviews/mediaNodeView/index.js +3 -1
- package/dist/es2019/nodeviews/mediaNodeView/media.js +13 -1
- package/dist/es2019/pm-plugins/utils/media-single.js +13 -2
- package/dist/es2019/ui/toolbar/alt-text.js +20 -0
- package/dist/es2019/ui/toolbar/index.js +55 -78
- package/dist/es2019/ui/toolbar/mediaInline.js +81 -75
- package/dist/es2019/ui/toolbar/pixel-resizing.js +28 -1
- package/dist/es2019/ui/toolbar/utils.js +11 -0
- package/dist/esm/nodeviews/mediaInline.js +2 -1
- package/dist/esm/nodeviews/mediaNodeView/index.js +3 -1
- package/dist/esm/nodeviews/mediaNodeView/media.js +13 -1
- package/dist/esm/pm-plugins/utils/media-single.js +13 -2
- package/dist/esm/ui/toolbar/alt-text.js +19 -0
- package/dist/esm/ui/toolbar/index.js +55 -78
- package/dist/esm/ui/toolbar/mediaInline.js +75 -71
- package/dist/esm/ui/toolbar/pixel-resizing.js +25 -0
- package/dist/esm/ui/toolbar/utils.js +11 -0
- package/dist/types/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types/ui/toolbar/alt-text.d.ts +4 -2
- package/dist/types/ui/toolbar/pixel-resizing.d.ts +6 -2
- package/dist/types/ui/toolbar/utils.d.ts +2 -0
- package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types-ts4.5/ui/toolbar/alt-text.d.ts +4 -2
- package/dist/types-ts4.5/ui/toolbar/pixel-resizing.d.ts +6 -2
- package/dist/types-ts4.5/ui/toolbar/utils.d.ts +2 -0
- package/package.json +5 -2
|
@@ -6,7 +6,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { alignmentIcons, buildLayoutButtons, IconCard, IconEmbed, IconInline, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
9
|
-
import { altTextMessages } from '@atlaskit/editor-common/media';
|
|
10
9
|
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
11
10
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
12
11
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -14,13 +13,11 @@ import { contains, findParentNodeOfType, hasParentNodeOfType, removeSelectedNode
|
|
|
14
13
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
15
14
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
16
15
|
import GrowDiagonalIcon from '@atlaskit/icon/core/grow-diagonal';
|
|
17
|
-
import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
|
|
18
16
|
import ImageFullscreenIcon from '@atlaskit/icon/core/image-fullscreen';
|
|
19
17
|
import ImageInlineIcon from '@atlaskit/icon/core/image-inline';
|
|
20
18
|
import MaximizeIcon from '@atlaskit/icon/core/maximize';
|
|
21
19
|
import DownloadIcon from '@atlaskit/icon/core/migration/download';
|
|
22
20
|
import SmartLinkCardIcon from '@atlaskit/icon/core/smart-link-card';
|
|
23
|
-
import TextIcon from '@atlaskit/icon/core/text';
|
|
24
21
|
import FilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
|
|
25
22
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
26
23
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
@@ -29,17 +26,15 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
29
26
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
30
27
|
import { MediaSingleNodeSelector } from '../../nodeviews/styles';
|
|
31
28
|
import { getPluginState as getMediaAltTextPluginState } from '../../pm-plugins/alt-text';
|
|
32
|
-
import { openMediaAltTextMenu } from '../../pm-plugins/alt-text/commands';
|
|
33
29
|
import { showLinkingToolbar } from '../../pm-plugins/commands/linking';
|
|
34
30
|
import { getMediaLinkingState } from '../../pm-plugins/linking';
|
|
35
31
|
import { getPluginState as getMediaPixelResizingPluginState } from '../../pm-plugins/pixel-resizing';
|
|
36
|
-
import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
|
|
37
32
|
import { FullWidthDisplay, PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
38
33
|
import { stateKey } from '../../pm-plugins/plugin-key';
|
|
39
34
|
import { currentMediaOrInlineNodeBorderMark } from '../../pm-plugins/utils/current-media-node';
|
|
40
35
|
import { isVideo } from '../../pm-plugins/utils/media-single';
|
|
41
36
|
import ImageBorderItem from '../../ui/ImageBorder';
|
|
42
|
-
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
37
|
+
import { altTextButton, getAltTextToolbar, getAltTextDropdownOption } from './alt-text';
|
|
43
38
|
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark } from './commands';
|
|
44
39
|
import { commentButton } from './comments';
|
|
45
40
|
import { shouldShowImageBorder } from './imageBorder';
|
|
@@ -47,8 +42,8 @@ import { LayoutGroup } from './layout-group';
|
|
|
47
42
|
import { getLinkingDropdownOptions, getLinkingToolbar, getOpenLinkToolbarButtonOption, shouldShowMediaLinkToolbar } from './linking';
|
|
48
43
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
49
44
|
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
50
|
-
import { getPixelResizingToolbar } from './pixel-resizing';
|
|
51
|
-
import { canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getSelectedLayoutIcon, getSelectedMediaSingle, getSelectedNearestMediaContainerNodeAttrs, removeMediaGroupNode } from './utils';
|
|
45
|
+
import { getPixelResizingToolbar, getResizeDropdownOption } from './pixel-resizing';
|
|
46
|
+
import { canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getSelectedLayoutIcon, getSelectedMediaSingle, getSelectedNearestMediaContainerNodeAttrs, removeMediaGroupNode, updateToFullHeightSeparator } from './utils';
|
|
52
47
|
var mediaTypeMessages = {
|
|
53
48
|
image: messages.file_image_is_selected,
|
|
54
49
|
video: messages.file_video_is_selected,
|
|
@@ -216,7 +211,6 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
216
211
|
fullHeight: true
|
|
217
212
|
}, download, {
|
|
218
213
|
type: 'separator',
|
|
219
|
-
fullHeight: true,
|
|
220
214
|
supportsViewMode: true
|
|
221
215
|
}, preview, {
|
|
222
216
|
type: 'separator',
|
|
@@ -241,6 +235,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
241
235
|
var toolbarButtons = [];
|
|
242
236
|
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
243
237
|
hoverDecoration = _ref2.hoverDecoration;
|
|
238
|
+
var isEditorControlsEnabled = editorExperiment('platform_editor_controls', 'variant1');
|
|
244
239
|
if (shouldShowImageBorder(state)) {
|
|
245
240
|
toolbarButtons.push({
|
|
246
241
|
type: 'custom',
|
|
@@ -327,7 +322,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
327
322
|
var hasCaption = contains(selectedNode.node, state.schema.nodes.caption);
|
|
328
323
|
var inlineSwitcherTitle = intl.formatMessage(hasCaption ? mediaAndEmbedToolbarMessages.changeToMediaInlineImageCaptionWarning : mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
329
324
|
var floatingSwitcherTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
330
|
-
if (
|
|
325
|
+
if (!isEditorControlsEnabled) {
|
|
331
326
|
var _pluginInjectionApi$a4;
|
|
332
327
|
toolbarButtons.push({
|
|
333
328
|
type: 'button',
|
|
@@ -463,14 +458,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
463
458
|
}
|
|
464
459
|
return [sizeInput];
|
|
465
460
|
}
|
|
466
|
-
if (
|
|
461
|
+
if (!isEditorControlsEnabled) {
|
|
467
462
|
toolbarButtons.push(sizeInput);
|
|
468
463
|
toolbarButtons.push({
|
|
469
464
|
type: 'separator'
|
|
470
465
|
});
|
|
471
466
|
}
|
|
472
467
|
}
|
|
473
|
-
if (
|
|
468
|
+
if (!isEditorControlsEnabled) {
|
|
474
469
|
if (allowCommentsOnMedia) {
|
|
475
470
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
476
471
|
type: 'separator',
|
|
@@ -568,29 +563,45 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
568
563
|
supportsViewMode: true
|
|
569
564
|
});
|
|
570
565
|
}
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
566
|
+
if (!isEditorControlsEnabled) {
|
|
567
|
+
if (allowAltTextOnImages) {
|
|
568
|
+
var _pluginInjectionApi$a7;
|
|
569
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
570
|
+
type: 'separator'
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
var removeButton = {
|
|
574
|
+
id: 'editor.media.delete',
|
|
575
|
+
type: 'button',
|
|
576
|
+
appearance: 'danger',
|
|
577
|
+
focusEditoronEnter: true,
|
|
578
|
+
icon: DeleteIcon,
|
|
579
|
+
iconFallback: RemoveIcon,
|
|
580
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
581
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
582
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
583
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
584
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
585
|
+
onClick: remove,
|
|
586
|
+
testId: 'media-toolbar-remove-button',
|
|
587
|
+
supportsViewMode: false
|
|
588
|
+
};
|
|
589
|
+
var items = [].concat(_toConsumableArray(toolbarButtons), [{
|
|
590
|
+
type: 'copy-button',
|
|
591
|
+
items: [{
|
|
592
|
+
state: state,
|
|
593
|
+
formatMessage: intl.formatMessage,
|
|
594
|
+
nodeType: mediaSingle
|
|
595
|
+
}],
|
|
596
|
+
supportsViewMode: true
|
|
597
|
+
}]);
|
|
598
|
+
items.push({
|
|
599
|
+
type: 'separator',
|
|
600
|
+
supportsViewMode: false
|
|
575
601
|
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
type: 'button',
|
|
580
|
-
appearance: 'danger',
|
|
581
|
-
focusEditoronEnter: true,
|
|
582
|
-
icon: DeleteIcon,
|
|
583
|
-
iconFallback: RemoveIcon,
|
|
584
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
585
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
586
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
587
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
588
|
-
title: intl.formatMessage(commonMessages.remove),
|
|
589
|
-
onClick: remove,
|
|
590
|
-
testId: 'media-toolbar-remove-button',
|
|
591
|
-
supportsViewMode: false
|
|
592
|
-
};
|
|
593
|
-
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
602
|
+
items.push(removeButton);
|
|
603
|
+
return items;
|
|
604
|
+
} else {
|
|
594
605
|
// Preview Support
|
|
595
606
|
if (allowAdvancedToolBarOptions && allowImagePreview) {
|
|
596
607
|
var _mediaNode$attrs2;
|
|
@@ -616,8 +627,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
616
627
|
supportsViewMode: true
|
|
617
628
|
}, {
|
|
618
629
|
type: 'separator',
|
|
619
|
-
supportsViewMode: true
|
|
620
|
-
fullHeight: true
|
|
630
|
+
supportsViewMode: true
|
|
621
631
|
});
|
|
622
632
|
}
|
|
623
633
|
}
|
|
@@ -626,8 +636,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
626
636
|
if (allowLinking && shouldShowMediaLinkToolbar(state) && mediaLinkingState && mediaLinkingState.editable) {
|
|
627
637
|
toolbarButtons.push(getOpenLinkToolbarButtonOption(intl, mediaLinkingState, pluginInjectionApi), {
|
|
628
638
|
type: 'separator',
|
|
629
|
-
supportsViewMode: true
|
|
630
|
-
fullHeight: true
|
|
639
|
+
supportsViewMode: true
|
|
631
640
|
});
|
|
632
641
|
}
|
|
633
642
|
isViewOnly && toolbarButtons.push({
|
|
@@ -643,26 +652,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
643
652
|
supportsViewMode: true
|
|
644
653
|
});
|
|
645
654
|
if (allowAdvancedToolBarOptions && allowCommentsOnMedia) {
|
|
646
|
-
|
|
655
|
+
updateToFullHeightSeparator(toolbarButtons);
|
|
647
656
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi));
|
|
648
657
|
}
|
|
649
658
|
return toolbarButtons;
|
|
650
659
|
}
|
|
651
|
-
var items = [].concat(_toConsumableArray(toolbarButtons), [{
|
|
652
|
-
type: 'copy-button',
|
|
653
|
-
items: [{
|
|
654
|
-
state: state,
|
|
655
|
-
formatMessage: intl.formatMessage,
|
|
656
|
-
nodeType: mediaSingle
|
|
657
|
-
}],
|
|
658
|
-
supportsViewMode: true
|
|
659
|
-
}]);
|
|
660
|
-
items.push({
|
|
661
|
-
type: 'separator',
|
|
662
|
-
supportsViewMode: false
|
|
663
|
-
});
|
|
664
|
-
items.push(removeButton);
|
|
665
|
-
return items;
|
|
666
660
|
};
|
|
667
661
|
var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
|
|
668
662
|
var mediaType = Object.keys(mediaTypeMessages).find(function (key) {
|
|
@@ -764,34 +758,17 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
764
758
|
}
|
|
765
759
|
if (!mediaPluginState.isResizing && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
766
760
|
var _pluginInjectionApi$a9;
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
type: 'separator',
|
|
773
|
-
fullHeight: true
|
|
761
|
+
updateToFullHeightSeparator(items);
|
|
762
|
+
var customOptions = [].concat(_toConsumableArray(getLinkingDropdownOptions(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly)), _toConsumableArray(getAltTextDropdownOption(state, intl.formatMessage, allowAltTextOnImages, selectedNodeType, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions)), _toConsumableArray(getResizeDropdownOption(options, state, intl.formatMessage, selectedNodeType)));
|
|
763
|
+
if (customOptions.length) {
|
|
764
|
+
customOptions.push({
|
|
765
|
+
type: 'separator'
|
|
774
766
|
});
|
|
775
767
|
}
|
|
776
|
-
var altTextTitle = intl.formatMessage(altTextMessages.addAltText);
|
|
777
768
|
items.push({
|
|
778
769
|
type: 'overflow-dropdown',
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
onClick: openMediaAltTextMenu(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions),
|
|
782
|
-
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
783
|
-
label: ""
|
|
784
|
-
})
|
|
785
|
-
}, {
|
|
786
|
-
title: 'Resize',
|
|
787
|
-
onClick: openPixelEditor(),
|
|
788
|
-
icon: /*#__PURE__*/React.createElement(GrowHorizontalIcon, {
|
|
789
|
-
label: ""
|
|
790
|
-
}),
|
|
791
|
-
testId: 'media-pixel-resizing-dropdown-option'
|
|
792
|
-
}, {
|
|
793
|
-
type: 'separator'
|
|
794
|
-
}, {
|
|
770
|
+
id: 'media',
|
|
771
|
+
options: [].concat(_toConsumableArray(customOptions), [{
|
|
795
772
|
title: 'Copy',
|
|
796
773
|
onClick: function onClick() {
|
|
797
774
|
var _pluginInjectionApi$c4, _pluginInjectionApi$f3;
|
|
@@ -168,7 +168,6 @@ export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloa
|
|
|
168
168
|
fullHeight: true
|
|
169
169
|
}, download, {
|
|
170
170
|
type: 'separator',
|
|
171
|
-
fullHeight: true,
|
|
172
171
|
supportsViewMode: true
|
|
173
172
|
}, preview, {
|
|
174
173
|
type: 'separator',
|
|
@@ -185,6 +184,11 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
185
184
|
var mediaSingleTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
186
185
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
187
186
|
var inlineImageItems = [];
|
|
187
|
+
var isEditorControlsEnabled = editorExperiment('platform_editor_controls', 'variant1');
|
|
188
|
+
var isViewOnly = options.isViewOnly,
|
|
189
|
+
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
190
|
+
allowLinking = options.allowLinking,
|
|
191
|
+
allowImagePreview = options.allowImagePreview;
|
|
188
192
|
if (shouldShowImageBorder(state)) {
|
|
189
193
|
inlineImageItems.push({
|
|
190
194
|
type: 'custom',
|
|
@@ -214,9 +218,20 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
214
218
|
type: 'separator'
|
|
215
219
|
});
|
|
216
220
|
}
|
|
221
|
+
var download = {
|
|
222
|
+
id: 'editor.media.image.download',
|
|
223
|
+
type: 'button',
|
|
224
|
+
icon: DownloadIcon,
|
|
225
|
+
onClick: function onClick() {
|
|
226
|
+
downloadMedia(mediaPluginState, options.isViewOnly);
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
title: intl.formatMessage(messages.download),
|
|
230
|
+
supportsViewMode: true
|
|
231
|
+
};
|
|
217
232
|
|
|
218
233
|
// For Editor Controls: show options to convert from 'Inline' to 'Original size' via dropdown
|
|
219
|
-
if (
|
|
234
|
+
if (!isEditorControlsEnabled) {
|
|
220
235
|
inlineImageItems.push({
|
|
221
236
|
id: 'editor.media.convert.mediainline',
|
|
222
237
|
type: 'button',
|
|
@@ -250,6 +265,48 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
250
265
|
onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
|
|
251
266
|
}, {
|
|
252
267
|
type: 'separator'
|
|
268
|
+
}, {
|
|
269
|
+
type: 'custom',
|
|
270
|
+
fallback: [],
|
|
271
|
+
render: function render(editorView, idx) {
|
|
272
|
+
if (editorView !== null && editorView !== void 0 && editorView.state) {
|
|
273
|
+
var editLink = function editLink() {
|
|
274
|
+
if (editorView) {
|
|
275
|
+
var _state = editorView.state,
|
|
276
|
+
dispatch = editorView.dispatch;
|
|
277
|
+
showLinkingToolbar(_state, dispatch);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var openLink = function openLink() {
|
|
281
|
+
if (editorView) {
|
|
282
|
+
var _pluginInjectionApi$a4;
|
|
283
|
+
var tr = editorView.state.tr,
|
|
284
|
+
dispatch = editorView.dispatch;
|
|
285
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.attachAnalyticsEvent({
|
|
286
|
+
eventType: EVENT_TYPE.TRACK,
|
|
287
|
+
action: ACTION.VISITED,
|
|
288
|
+
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
289
|
+
actionSubjectId: ACTION_SUBJECT_ID.LINK
|
|
290
|
+
})(tr);
|
|
291
|
+
dispatch(tr);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
296
|
+
key: idx,
|
|
297
|
+
editorState: editorView.state,
|
|
298
|
+
intl: intl,
|
|
299
|
+
mediaLinkingState: mediaLinkingState,
|
|
300
|
+
onAddLink: editLink,
|
|
301
|
+
onEditLink: editLink,
|
|
302
|
+
onOpenLink: openLink,
|
|
303
|
+
isInlineNode: true,
|
|
304
|
+
isViewOnly: options.isViewOnly
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
},
|
|
309
|
+
supportsViewMode: true
|
|
253
310
|
});
|
|
254
311
|
} else {
|
|
255
312
|
var _options2 = [{
|
|
@@ -299,62 +356,21 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
299
356
|
type: 'separator',
|
|
300
357
|
fullHeight: true
|
|
301
358
|
});
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
fallback: [],
|
|
309
|
-
render: function render(editorView, idx) {
|
|
310
|
-
if (editorView !== null && editorView !== void 0 && editorView.state) {
|
|
311
|
-
var editLink = function editLink() {
|
|
312
|
-
if (editorView) {
|
|
313
|
-
var _state = editorView.state,
|
|
314
|
-
dispatch = editorView.dispatch;
|
|
315
|
-
showLinkingToolbar(_state, dispatch);
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
var openLink = function openLink() {
|
|
319
|
-
if (editorView) {
|
|
320
|
-
var _pluginInjectionApi$a4;
|
|
321
|
-
var tr = editorView.state.tr,
|
|
322
|
-
dispatch = editorView.dispatch;
|
|
323
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.attachAnalyticsEvent({
|
|
324
|
-
eventType: EVENT_TYPE.TRACK,
|
|
325
|
-
action: ACTION.VISITED,
|
|
326
|
-
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
327
|
-
actionSubjectId: ACTION_SUBJECT_ID.LINK
|
|
328
|
-
})(tr);
|
|
329
|
-
dispatch(tr);
|
|
330
|
-
return true;
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
|
|
334
|
-
key: idx,
|
|
335
|
-
editorState: editorView.state,
|
|
336
|
-
intl: intl,
|
|
337
|
-
mediaLinkingState: mediaLinkingState,
|
|
338
|
-
onAddLink: editLink,
|
|
339
|
-
onEditLink: editLink,
|
|
340
|
-
onOpenLink: openLink,
|
|
341
|
-
isInlineNode: true,
|
|
342
|
-
isViewOnly: options.isViewOnly
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
return null;
|
|
346
|
-
},
|
|
347
|
-
supportsViewMode: true
|
|
348
|
-
});
|
|
359
|
+
if (isViewOnly) {
|
|
360
|
+
inlineImageItems.push(download, {
|
|
361
|
+
type: 'separator',
|
|
362
|
+
supportsViewMode: true
|
|
363
|
+
});
|
|
364
|
+
}
|
|
349
365
|
}
|
|
350
366
|
|
|
351
367
|
//Image Preview
|
|
352
|
-
if (
|
|
368
|
+
if (allowImagePreview) {
|
|
353
369
|
inlineImageItems.push({
|
|
354
370
|
id: 'editor.media.viewer',
|
|
355
371
|
testId: 'file-preview-toolbar-button',
|
|
356
372
|
type: 'button',
|
|
357
|
-
icon: MaximizeIcon,
|
|
373
|
+
icon: isEditorControlsEnabled ? GrowDiagonalIcon : MaximizeIcon,
|
|
358
374
|
iconFallback: FilePreviewIcon,
|
|
359
375
|
title: intl.formatMessage(messages.preview),
|
|
360
376
|
onClick: function onClick() {
|
|
@@ -367,42 +383,30 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
367
383
|
supportsViewMode: true
|
|
368
384
|
}, {
|
|
369
385
|
type: 'separator',
|
|
370
|
-
supportsViewMode: true
|
|
371
|
-
fullHeight: editorExperiment('platform_editor_controls', 'variant1')
|
|
386
|
+
supportsViewMode: true
|
|
372
387
|
});
|
|
373
388
|
}
|
|
374
389
|
|
|
375
390
|
// open link
|
|
376
|
-
if (
|
|
391
|
+
if (allowLinking && shouldShowMediaLinkToolbar(state) && mediaLinkingState && mediaLinkingState.editable && isEditorControlsEnabled) {
|
|
377
392
|
inlineImageItems.push(getOpenLinkToolbarButtonOption(intl, mediaLinkingState, pluginInjectionApi), {
|
|
378
393
|
type: 'separator',
|
|
379
|
-
supportsViewMode: true
|
|
380
|
-
fullHeight: true
|
|
394
|
+
supportsViewMode: true
|
|
381
395
|
});
|
|
382
396
|
}
|
|
383
|
-
if (
|
|
384
|
-
inlineImageItems.push({
|
|
385
|
-
id: 'editor.media.image.download',
|
|
386
|
-
type: 'button',
|
|
387
|
-
icon: DownloadIcon,
|
|
388
|
-
onClick: function onClick() {
|
|
389
|
-
downloadMedia(mediaPluginState, options.isViewOnly);
|
|
390
|
-
return true;
|
|
391
|
-
},
|
|
392
|
-
title: intl.formatMessage(messages.download),
|
|
393
|
-
supportsViewMode: true
|
|
394
|
-
}, {
|
|
397
|
+
if (isViewOnly && !isEditorControlsEnabled) {
|
|
398
|
+
inlineImageItems.push(download, {
|
|
395
399
|
type: 'separator',
|
|
396
400
|
supportsViewMode: true
|
|
397
401
|
});
|
|
398
402
|
}
|
|
399
|
-
if (
|
|
403
|
+
if (allowAltTextOnImages && !isEditorControlsEnabled) {
|
|
400
404
|
var _pluginInjectionApi$a5;
|
|
401
405
|
inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions), {
|
|
402
406
|
type: 'separator'
|
|
403
407
|
});
|
|
404
408
|
}
|
|
405
|
-
if (
|
|
409
|
+
if (isViewOnly || !isEditorControlsEnabled) {
|
|
406
410
|
inlineImageItems.push({
|
|
407
411
|
type: 'copy-button',
|
|
408
412
|
supportsViewMode: true,
|
|
@@ -413,7 +417,7 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
413
417
|
}]
|
|
414
418
|
});
|
|
415
419
|
}
|
|
416
|
-
if (
|
|
420
|
+
if (!isEditorControlsEnabled) {
|
|
417
421
|
inlineImageItems.push({
|
|
418
422
|
type: 'separator'
|
|
419
423
|
});
|
|
@@ -2,6 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
|
|
6
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
|
|
5
10
|
import { PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
6
11
|
import { PIXEL_RESIZING_TOOLBAR_WIDTH } from '../../pm-plugins/pixel-resizing/ui/constants';
|
|
7
12
|
import { getSelectedMediaSingle } from './utils';
|
|
@@ -37,4 +42,24 @@ export var getPixelResizingToolbar = function getPixelResizingToolbar(toolbarBas
|
|
|
37
42
|
}
|
|
38
43
|
}]
|
|
39
44
|
});
|
|
45
|
+
};
|
|
46
|
+
export var getResizeDropdownOption = function getResizeDropdownOption(mediaOptions, state, formatMessage, selectedNodeType) {
|
|
47
|
+
if ((selectedNodeType === null || selectedNodeType === void 0 ? void 0 : selectedNodeType.name) !== 'mediaSingle') {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
var allowResizing = mediaOptions.allowResizing,
|
|
51
|
+
allowResizingInTables = mediaOptions.allowResizingInTables,
|
|
52
|
+
allowAdvancedToolBarOptions = mediaOptions.allowAdvancedToolBarOptions;
|
|
53
|
+
var isWithinTable = hasParentNodeOfType(state.schema.nodes.table)(state.selection);
|
|
54
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && fg('platform_editor_media_extended_resize_experience')) {
|
|
55
|
+
return [{
|
|
56
|
+
title: formatMessage(messages.resizeOption),
|
|
57
|
+
onClick: openPixelEditor(),
|
|
58
|
+
icon: /*#__PURE__*/React.createElement(GrowHorizontalIcon, {
|
|
59
|
+
label: ""
|
|
60
|
+
}),
|
|
61
|
+
testId: 'media-pixel-resizing-dropdown-option'
|
|
62
|
+
}];
|
|
63
|
+
}
|
|
64
|
+
return [];
|
|
40
65
|
};
|
|
@@ -146,4 +146,15 @@ export var canShowSwitchButtons = function canShowSwitchButtons(mediaSingleNode)
|
|
|
146
146
|
return mediaNode && !isVideo(mediaNode.attrs.__fileMimeType);
|
|
147
147
|
}
|
|
148
148
|
return false;
|
|
149
|
+
};
|
|
150
|
+
export var updateToFullHeightSeparator = function updateToFullHeightSeparator(items) {
|
|
151
|
+
var lastItem = items.at(-1);
|
|
152
|
+
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === 'separator') {
|
|
153
|
+
lastItem.fullHeight = true;
|
|
154
|
+
} else if (items.length) {
|
|
155
|
+
items.push({
|
|
156
|
+
type: 'separator',
|
|
157
|
+
fullHeight: true
|
|
158
|
+
});
|
|
159
|
+
}
|
|
149
160
|
};
|
|
@@ -21,6 +21,7 @@ export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
|
|
|
21
21
|
mediaProvider?: Promise<MediaProvider>;
|
|
22
22
|
isLoading?: boolean;
|
|
23
23
|
mediaOptions?: MediaOptions;
|
|
24
|
+
isViewOnly?: boolean;
|
|
24
25
|
}
|
|
25
26
|
interface MediaNodeState {
|
|
26
27
|
viewMediaClientConfig?: MediaClientConfig;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Command, FloatingToolbarButton, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Command, FloatingToolbarButton, FloatingToolbarConfig, FloatingToolbarOverflowDropdownOptions } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
|
-
import
|
|
5
|
+
import { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import type { MediaToolbarBaseConfig } from '../../types';
|
|
7
8
|
export declare const altTextButton: (intl: IntlShape, state: EditorState, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarButton<Command>;
|
|
8
9
|
interface AltTextToolbarOptions {
|
|
@@ -10,4 +11,5 @@ interface AltTextToolbarOptions {
|
|
|
10
11
|
forceFocusSelector?: ForceFocusSelector;
|
|
11
12
|
}
|
|
12
13
|
export declare const getAltTextToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, options?: AltTextToolbarOptions) => FloatingToolbarConfig;
|
|
14
|
+
export declare const getAltTextDropdownOption: (state: EditorState, formatMessage: IntlShape['formatMessage'], allowAltTextOnImages?: boolean, selectedNodeType?: NodeType, editorAnalyticsAPI?: EditorAnalyticsAPI) => FloatingToolbarOverflowDropdownOptions<Command>;
|
|
13
15
|
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { FloatingToolbarConfig, FloatingToolbarOverflowDropdownOptions, Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
import { Props } from '../../pm-plugins/pixel-resizing/ui';
|
|
3
|
-
import { MediaToolbarBaseConfig } from '../../types';
|
|
6
|
+
import { MediaOptions, MediaToolbarBaseConfig } from '../../types';
|
|
4
7
|
export declare const getPixelResizingToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, { pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Omit<Props, 'editorView' | 'selectedMediaSingleNode'>) => FloatingToolbarConfig;
|
|
8
|
+
export declare const getResizeDropdownOption: (mediaOptions: MediaOptions, state: EditorState, formatMessage: IntlShape['formatMessage'], selectedNodeType?: NodeType) => FloatingToolbarOverflowDropdownOptions<Command>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExternalMediaAttributes, MediaADFAttrs, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { LayoutIcon } from '@atlaskit/editor-common/card';
|
|
3
|
+
import { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -19,3 +20,4 @@ export declare const getSelectedLayoutIcon: (layoutIcons: LayoutIcon[], selected
|
|
|
19
20
|
* @param mediaSingleNode node to be checked
|
|
20
21
|
*/
|
|
21
22
|
export declare const canShowSwitchButtons: (mediaSingleNode?: ProseMirrorNode) => boolean | null;
|
|
23
|
+
export declare const updateToFullHeightSeparator: (items: FloatingToolbarItem<Command>[]) => void;
|
|
@@ -21,6 +21,7 @@ export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
|
|
|
21
21
|
mediaProvider?: Promise<MediaProvider>;
|
|
22
22
|
isLoading?: boolean;
|
|
23
23
|
mediaOptions?: MediaOptions;
|
|
24
|
+
isViewOnly?: boolean;
|
|
24
25
|
}
|
|
25
26
|
interface MediaNodeState {
|
|
26
27
|
viewMediaClientConfig?: MediaClientConfig;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Command, FloatingToolbarButton, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Command, FloatingToolbarButton, FloatingToolbarConfig, FloatingToolbarOverflowDropdownOptions } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
|
-
import
|
|
5
|
+
import { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
+
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import type { MediaToolbarBaseConfig } from '../../types';
|
|
7
8
|
export declare const altTextButton: (intl: IntlShape, state: EditorState, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarButton<Command>;
|
|
8
9
|
interface AltTextToolbarOptions {
|
|
@@ -10,4 +11,5 @@ interface AltTextToolbarOptions {
|
|
|
10
11
|
forceFocusSelector?: ForceFocusSelector;
|
|
11
12
|
}
|
|
12
13
|
export declare const getAltTextToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, options?: AltTextToolbarOptions) => FloatingToolbarConfig;
|
|
14
|
+
export declare const getAltTextDropdownOption: (state: EditorState, formatMessage: IntlShape['formatMessage'], allowAltTextOnImages?: boolean, selectedNodeType?: NodeType, editorAnalyticsAPI?: EditorAnalyticsAPI) => FloatingToolbarOverflowDropdownOptions<Command>;
|
|
13
15
|
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { FloatingToolbarConfig, FloatingToolbarOverflowDropdownOptions, Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
import { Props } from '../../pm-plugins/pixel-resizing/ui';
|
|
3
|
-
import { MediaToolbarBaseConfig } from '../../types';
|
|
6
|
+
import { MediaOptions, MediaToolbarBaseConfig } from '../../types';
|
|
4
7
|
export declare const getPixelResizingToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, { pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Omit<Props, 'editorView' | 'selectedMediaSingleNode'>) => FloatingToolbarConfig;
|
|
8
|
+
export declare const getResizeDropdownOption: (mediaOptions: MediaOptions, state: EditorState, formatMessage: IntlShape['formatMessage'], selectedNodeType?: NodeType) => FloatingToolbarOverflowDropdownOptions<Command>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExternalMediaAttributes, MediaADFAttrs, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { LayoutIcon } from '@atlaskit/editor-common/card';
|
|
3
|
+
import { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -19,3 +20,4 @@ export declare const getSelectedLayoutIcon: (layoutIcons: LayoutIcon[], selected
|
|
|
19
20
|
* @param mediaSingleNode node to be checked
|
|
20
21
|
*/
|
|
21
22
|
export declare const canShowSwitchButtons: (mediaSingleNode?: ProseMirrorNode) => boolean | null;
|
|
23
|
+
export declare const updateToFullHeightSeparator: (items: FloatingToolbarItem<Command>[]) => void;
|