@atlaskit/editor-plugin-media 2.3.14 → 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 +10 -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/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/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/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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 2.3.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#131280](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131280)
|
|
8
|
+
[`9ff92ea2432f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ff92ea2432f2) -
|
|
9
|
+
[ED-27082] Fix media overflow toolbar to show correct options + update separators between button
|
|
10
|
+
groups
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 2.3.14
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -205,7 +205,8 @@ var MediaInline = exports.MediaInline = function MediaInline(props) {
|
|
|
205
205
|
border: {
|
|
206
206
|
borderSize: borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size,
|
|
207
207
|
borderColor: borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.color
|
|
208
|
-
}
|
|
208
|
+
},
|
|
209
|
+
isViewOnly: props.editorViewMode
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
212
|
return (0, _react2.jsx)(_MediaViewerContainer.MediaViewerContainer, {
|
|
@@ -70,6 +70,7 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
70
70
|
});
|
|
71
71
|
(0, _defineProperty2.default)(_this, "renderMediaNodeWithState", function (contextIdentifierProvider) {
|
|
72
72
|
return function (_ref2) {
|
|
73
|
+
var _this$reactComponentP;
|
|
73
74
|
var editorWidth = _ref2.width,
|
|
74
75
|
mediaProvider = _ref2.mediaProvider;
|
|
75
76
|
var getPos = _this.getPos;
|
|
@@ -110,7 +111,8 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
110
111
|
mediaProvider: mediaProvider,
|
|
111
112
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
112
113
|
mediaOptions: mediaOptions,
|
|
113
|
-
onExternalImageLoaded: _this.onExternalImageLoaded
|
|
114
|
+
onExternalImageLoaded: _this.onExternalImageLoaded,
|
|
115
|
+
isViewOnly: ((_this$reactComponentP = _this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.sharedState.currentState()) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.mode) === 'view'
|
|
114
116
|
});
|
|
115
117
|
};
|
|
116
118
|
});
|
|
@@ -21,6 +21,7 @@ var _analyticsNext = require("@atlaskit/analytics-next");
|
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
22
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
23
23
|
var _mediaCard = require("@atlaskit/media-card");
|
|
24
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
24
25
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
25
26
|
var _styles = require("../styles");
|
|
26
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -63,6 +64,13 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
63
64
|
(0, _defineProperty2.default)(_this, "selectMediaSingleFromCard", function (_ref2) {
|
|
64
65
|
var event = _ref2.event;
|
|
65
66
|
_this.selectMediaSingle(event);
|
|
67
|
+
|
|
68
|
+
// In edit mode (node content wrapper has contenteditable set to true), link redirection is disabled by default
|
|
69
|
+
// We need to call "stopPropagation" here in order to prevent in editor view mode, the browser from navigating to
|
|
70
|
+
// another URL if the media node is wrapped in a link mark.
|
|
71
|
+
if (_this.props.isViewOnly && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
}
|
|
66
74
|
});
|
|
67
75
|
(0, _defineProperty2.default)(_this, "selectMediaSingle", function (event) {
|
|
68
76
|
var propPos = _this.props.getPos();
|
|
@@ -70,9 +78,13 @@ var MediaNode = exports.MediaNode = /*#__PURE__*/function (_Component) {
|
|
|
70
78
|
return;
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
// NOTE: This does not prevent the link navigation in the editor view mode, .preventDefault is needed (see selectMediaSingleFromCard)
|
|
82
|
+
// Hence it should be removed
|
|
73
83
|
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
74
84
|
// another URL if the media node is wrapped in a link mark.
|
|
75
|
-
|
|
85
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
}
|
|
76
88
|
var state = _this.props.view.state;
|
|
77
89
|
if (event.shiftKey) {
|
|
78
90
|
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
@@ -4,15 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getAltTextToolbar = exports.altTextButton = void 0;
|
|
7
|
+
exports.getAltTextToolbar = exports.getAltTextDropdownOption = exports.altTextButton = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
11
|
var _media = require("@atlaskit/editor-common/media");
|
|
12
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
13
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
14
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
var _text = _interopRequireDefault(require("@atlaskit/icon/core/text"));
|
|
14
16
|
var _commands = require("../../pm-plugins/alt-text/commands");
|
|
15
17
|
var _AltTextEdit = _interopRequireDefault(require("../../pm-plugins/alt-text/ui/AltTextEdit"));
|
|
18
|
+
var _isType = require("../../pm-plugins/utils/is-type");
|
|
16
19
|
var _mediaCommon = require("../../pm-plugins/utils/media-common");
|
|
17
20
|
var _commands2 = require("./commands");
|
|
18
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -80,4 +83,20 @@ var getAltTextToolbar = exports.getAltTextToolbar = function getAltTextToolbar(t
|
|
|
80
83
|
className: _styles.MediaSharedClassNames.FLOATING_TOOLBAR_COMPONENT,
|
|
81
84
|
items: [altTextEditComponent(options)]
|
|
82
85
|
});
|
|
86
|
+
};
|
|
87
|
+
var getAltTextDropdownOption = exports.getAltTextDropdownOption = function getAltTextDropdownOption(state, formatMessage, allowAltTextOnImages, selectedNodeType, editorAnalyticsAPI) {
|
|
88
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
89
|
+
mediaSingle = _state$schema$nodes.mediaSingle,
|
|
90
|
+
mediaInline = _state$schema$nodes.mediaInline;
|
|
91
|
+
var mediaType = state.selection instanceof _state.NodeSelection && state.selection.node.attrs.type;
|
|
92
|
+
if (allowAltTextOnImages && (selectedNodeType === mediaSingle || selectedNodeType === mediaInline && (0, _isType.isImage)(mediaType))) {
|
|
93
|
+
return [{
|
|
94
|
+
title: formatMessage(_media.altTextMessages.addAltText),
|
|
95
|
+
onClick: (0, _commands.openMediaAltTextMenu)(editorAnalyticsAPI),
|
|
96
|
+
icon: /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
97
|
+
label: ""
|
|
98
|
+
})
|
|
99
|
+
}];
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
83
102
|
};
|
|
@@ -12,7 +12,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
15
|
-
var _media = require("@atlaskit/editor-common/media");
|
|
16
15
|
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
17
16
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
18
17
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -20,13 +19,11 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
|
20
19
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
21
20
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
22
21
|
var _growDiagonal = _interopRequireDefault(require("@atlaskit/icon/core/grow-diagonal"));
|
|
23
|
-
var _growHorizontal = _interopRequireDefault(require("@atlaskit/icon/core/grow-horizontal"));
|
|
24
22
|
var _imageFullscreen = _interopRequireDefault(require("@atlaskit/icon/core/image-fullscreen"));
|
|
25
23
|
var _imageInline = _interopRequireDefault(require("@atlaskit/icon/core/image-inline"));
|
|
26
24
|
var _maximize = _interopRequireDefault(require("@atlaskit/icon/core/maximize"));
|
|
27
25
|
var _download = _interopRequireDefault(require("@atlaskit/icon/core/migration/download"));
|
|
28
26
|
var _smartLinkCard = _interopRequireDefault(require("@atlaskit/icon/core/smart-link-card"));
|
|
29
|
-
var _text = _interopRequireDefault(require("@atlaskit/icon/core/text"));
|
|
30
27
|
var _filePreview = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/file-preview"));
|
|
31
28
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
32
29
|
var _mediaFilmstrip = require("@atlaskit/media-filmstrip");
|
|
@@ -35,18 +32,16 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
35
32
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
36
33
|
var _styles = require("../../nodeviews/styles");
|
|
37
34
|
var _altText = require("../../pm-plugins/alt-text");
|
|
38
|
-
var _commands = require("../../pm-plugins/alt-text/commands");
|
|
39
35
|
var _linking = require("../../pm-plugins/commands/linking");
|
|
40
36
|
var _linking2 = require("../../pm-plugins/linking");
|
|
41
37
|
var _pixelResizing = require("../../pm-plugins/pixel-resizing");
|
|
42
|
-
var _commands2 = require("../../pm-plugins/pixel-resizing/commands");
|
|
43
38
|
var _ui = require("../../pm-plugins/pixel-resizing/ui");
|
|
44
39
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
45
40
|
var _currentMediaNode = require("../../pm-plugins/utils/current-media-node");
|
|
46
41
|
var _mediaSingle = require("../../pm-plugins/utils/media-single");
|
|
47
42
|
var _ImageBorder = _interopRequireDefault(require("../../ui/ImageBorder"));
|
|
48
43
|
var _altText2 = require("./alt-text");
|
|
49
|
-
var
|
|
44
|
+
var _commands = require("./commands");
|
|
50
45
|
var _comments = require("./comments");
|
|
51
46
|
var _imageBorder = require("./imageBorder");
|
|
52
47
|
var _layoutGroup = require("./layout-group");
|
|
@@ -138,7 +133,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
138
133
|
selected: false,
|
|
139
134
|
focusEditoronEnter: true,
|
|
140
135
|
disabled: false,
|
|
141
|
-
onClick: (0,
|
|
136
|
+
onClick: (0, _commands.changeMediaCardToInline)(editorAnalyticsAPI, forceFocusSelector),
|
|
142
137
|
title: intl.formatMessage(_messages.cardMessages.inlineTitle),
|
|
143
138
|
testId: 'inline-appearance',
|
|
144
139
|
className: 'inline-appearance' // a11y. uses to force focus on item
|
|
@@ -191,7 +186,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
191
186
|
var options = [{
|
|
192
187
|
id: 'editor.media.view.switcher.inline',
|
|
193
188
|
title: intl.formatMessage(_messages.cardMessages.inlineTitle),
|
|
194
|
-
onClick: (0,
|
|
189
|
+
onClick: (0, _commands.changeMediaCardToInline)(editorAnalyticsAPI, forceFocusSelector),
|
|
195
190
|
icon: /*#__PURE__*/_react.default.createElement(_imageInline.default, {
|
|
196
191
|
label: "",
|
|
197
192
|
spacing: "spacious"
|
|
@@ -226,7 +221,6 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
226
221
|
fullHeight: true
|
|
227
222
|
}, download, {
|
|
228
223
|
type: 'separator',
|
|
229
|
-
fullHeight: true,
|
|
230
224
|
supportsViewMode: true
|
|
231
225
|
}, preview, {
|
|
232
226
|
type: 'separator',
|
|
@@ -251,6 +245,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
251
245
|
var toolbarButtons = [];
|
|
252
246
|
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 : {},
|
|
253
247
|
hoverDecoration = _ref2.hoverDecoration;
|
|
248
|
+
var isEditorControlsEnabled = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
|
|
254
249
|
if ((0, _imageBorder.shouldShowImageBorder)(state)) {
|
|
255
250
|
toolbarButtons.push({
|
|
256
251
|
type: 'custom',
|
|
@@ -265,11 +260,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
265
260
|
return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
|
|
266
261
|
toggleBorder: function toggleBorder() {
|
|
267
262
|
var _pluginInjectionApi$a;
|
|
268
|
-
(0,
|
|
263
|
+
(0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(state, dispatch);
|
|
269
264
|
},
|
|
270
265
|
setBorder: function setBorder(attrs) {
|
|
271
266
|
var _pluginInjectionApi$a2;
|
|
272
|
-
(0,
|
|
267
|
+
(0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(attrs)(state, dispatch);
|
|
273
268
|
},
|
|
274
269
|
borderMark: borderMark,
|
|
275
270
|
intl: intl
|
|
@@ -337,7 +332,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
337
332
|
var hasCaption = (0, _utils.contains)(selectedNode.node, state.schema.nodes.caption);
|
|
338
333
|
var inlineSwitcherTitle = intl.formatMessage(hasCaption ? _messages.mediaAndEmbedToolbarMessages.changeToMediaInlineImageCaptionWarning : _messages.mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
339
334
|
var floatingSwitcherTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
340
|
-
if (
|
|
335
|
+
if (!isEditorControlsEnabled) {
|
|
341
336
|
var _pluginInjectionApi$a4;
|
|
342
337
|
toolbarButtons.push({
|
|
343
338
|
type: 'button',
|
|
@@ -352,7 +347,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
352
347
|
LEGACY_fallbackIcon: _card.IconInline
|
|
353
348
|
});
|
|
354
349
|
},
|
|
355
|
-
onClick: (0,
|
|
350
|
+
onClick: (0, _commands.changeMediaSingleToMediaInline)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions),
|
|
356
351
|
testId: 'image-inline-appearance'
|
|
357
352
|
}, {
|
|
358
353
|
type: 'button',
|
|
@@ -381,7 +376,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
381
376
|
var _options2 = [{
|
|
382
377
|
id: 'editor.media.convert.mediainline',
|
|
383
378
|
title: inlineTitle,
|
|
384
|
-
onClick: (0,
|
|
379
|
+
onClick: (0, _commands.changeMediaSingleToMediaInline)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions),
|
|
385
380
|
icon: /*#__PURE__*/_react.default.createElement(_imageInline.default, {
|
|
386
381
|
color: "currentColor",
|
|
387
382
|
spacing: "spacious",
|
|
@@ -473,14 +468,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
473
468
|
}
|
|
474
469
|
return [sizeInput];
|
|
475
470
|
}
|
|
476
|
-
if (
|
|
471
|
+
if (!isEditorControlsEnabled) {
|
|
477
472
|
toolbarButtons.push(sizeInput);
|
|
478
473
|
toolbarButtons.push({
|
|
479
474
|
type: 'separator'
|
|
480
475
|
});
|
|
481
476
|
}
|
|
482
477
|
}
|
|
483
|
-
if (
|
|
478
|
+
if (!isEditorControlsEnabled) {
|
|
484
479
|
if (allowCommentsOnMedia) {
|
|
485
480
|
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
|
|
486
481
|
type: 'separator',
|
|
@@ -578,29 +573,45 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
578
573
|
supportsViewMode: true
|
|
579
574
|
});
|
|
580
575
|
}
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
576
|
+
if (!isEditorControlsEnabled) {
|
|
577
|
+
if (allowAltTextOnImages) {
|
|
578
|
+
var _pluginInjectionApi$a7;
|
|
579
|
+
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
580
|
+
type: 'separator'
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
var removeButton = {
|
|
584
|
+
id: 'editor.media.delete',
|
|
585
|
+
type: 'button',
|
|
586
|
+
appearance: 'danger',
|
|
587
|
+
focusEditoronEnter: true,
|
|
588
|
+
icon: _delete.default,
|
|
589
|
+
iconFallback: _remove.default,
|
|
590
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
591
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
592
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
593
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
594
|
+
title: intl.formatMessage(_messages.default.remove),
|
|
595
|
+
onClick: remove,
|
|
596
|
+
testId: 'media-toolbar-remove-button',
|
|
597
|
+
supportsViewMode: false
|
|
598
|
+
};
|
|
599
|
+
var items = [].concat((0, _toConsumableArray2.default)(toolbarButtons), [{
|
|
600
|
+
type: 'copy-button',
|
|
601
|
+
items: [{
|
|
602
|
+
state: state,
|
|
603
|
+
formatMessage: intl.formatMessage,
|
|
604
|
+
nodeType: mediaSingle
|
|
605
|
+
}],
|
|
606
|
+
supportsViewMode: true
|
|
607
|
+
}]);
|
|
608
|
+
items.push({
|
|
609
|
+
type: 'separator',
|
|
610
|
+
supportsViewMode: false
|
|
585
611
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
type: 'button',
|
|
590
|
-
appearance: 'danger',
|
|
591
|
-
focusEditoronEnter: true,
|
|
592
|
-
icon: _delete.default,
|
|
593
|
-
iconFallback: _remove.default,
|
|
594
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
595
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
596
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
597
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
598
|
-
title: intl.formatMessage(_messages.default.remove),
|
|
599
|
-
onClick: remove,
|
|
600
|
-
testId: 'media-toolbar-remove-button',
|
|
601
|
-
supportsViewMode: false
|
|
602
|
-
};
|
|
603
|
-
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
612
|
+
items.push(removeButton);
|
|
613
|
+
return items;
|
|
614
|
+
} else {
|
|
604
615
|
// Preview Support
|
|
605
616
|
if (allowAdvancedToolBarOptions && allowImagePreview) {
|
|
606
617
|
var _mediaNode$attrs2;
|
|
@@ -626,8 +637,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
626
637
|
supportsViewMode: true
|
|
627
638
|
}, {
|
|
628
639
|
type: 'separator',
|
|
629
|
-
supportsViewMode: true
|
|
630
|
-
fullHeight: true
|
|
640
|
+
supportsViewMode: true
|
|
631
641
|
});
|
|
632
642
|
}
|
|
633
643
|
}
|
|
@@ -636,8 +646,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
636
646
|
if (allowLinking && (0, _linking3.shouldShowMediaLinkToolbar)(state) && mediaLinkingState && mediaLinkingState.editable) {
|
|
637
647
|
toolbarButtons.push((0, _linking3.getOpenLinkToolbarButtonOption)(intl, mediaLinkingState, pluginInjectionApi), {
|
|
638
648
|
type: 'separator',
|
|
639
|
-
supportsViewMode: true
|
|
640
|
-
fullHeight: true
|
|
649
|
+
supportsViewMode: true
|
|
641
650
|
});
|
|
642
651
|
}
|
|
643
652
|
isViewOnly && toolbarButtons.push({
|
|
@@ -653,26 +662,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
653
662
|
supportsViewMode: true
|
|
654
663
|
});
|
|
655
664
|
if (allowAdvancedToolBarOptions && allowCommentsOnMedia) {
|
|
656
|
-
|
|
665
|
+
(0, _utils2.updateToFullHeightSeparator)(toolbarButtons);
|
|
657
666
|
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi));
|
|
658
667
|
}
|
|
659
668
|
return toolbarButtons;
|
|
660
669
|
}
|
|
661
|
-
var items = [].concat((0, _toConsumableArray2.default)(toolbarButtons), [{
|
|
662
|
-
type: 'copy-button',
|
|
663
|
-
items: [{
|
|
664
|
-
state: state,
|
|
665
|
-
formatMessage: intl.formatMessage,
|
|
666
|
-
nodeType: mediaSingle
|
|
667
|
-
}],
|
|
668
|
-
supportsViewMode: true
|
|
669
|
-
}]);
|
|
670
|
-
items.push({
|
|
671
|
-
type: 'separator',
|
|
672
|
-
supportsViewMode: false
|
|
673
|
-
});
|
|
674
|
-
items.push(removeButton);
|
|
675
|
-
return items;
|
|
676
670
|
};
|
|
677
671
|
var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
|
|
678
672
|
var mediaType = Object.keys(mediaTypeMessages).find(function (key) {
|
|
@@ -774,34 +768,17 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
774
768
|
}
|
|
775
769
|
if (!mediaPluginState.isResizing && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
776
770
|
var _pluginInjectionApi$a9;
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
type: 'separator',
|
|
783
|
-
fullHeight: true
|
|
771
|
+
(0, _utils2.updateToFullHeightSeparator)(items);
|
|
772
|
+
var customOptions = [].concat((0, _toConsumableArray2.default)((0, _linking3.getLinkingDropdownOptions)(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly)), (0, _toConsumableArray2.default)((0, _altText2.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)), (0, _toConsumableArray2.default)((0, _pixelResizing2.getResizeDropdownOption)(options, state, intl.formatMessage, selectedNodeType)));
|
|
773
|
+
if (customOptions.length) {
|
|
774
|
+
customOptions.push({
|
|
775
|
+
type: 'separator'
|
|
784
776
|
});
|
|
785
777
|
}
|
|
786
|
-
var altTextTitle = intl.formatMessage(_media.altTextMessages.addAltText);
|
|
787
778
|
items.push({
|
|
788
779
|
type: 'overflow-dropdown',
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
onClick: (0, _commands.openMediaAltTextMenu)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions),
|
|
792
|
-
icon: /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
793
|
-
label: ""
|
|
794
|
-
})
|
|
795
|
-
}, {
|
|
796
|
-
title: 'Resize',
|
|
797
|
-
onClick: (0, _commands2.openPixelEditor)(),
|
|
798
|
-
icon: /*#__PURE__*/_react.default.createElement(_growHorizontal.default, {
|
|
799
|
-
label: ""
|
|
800
|
-
}),
|
|
801
|
-
testId: 'media-pixel-resizing-dropdown-option'
|
|
802
|
-
}, {
|
|
803
|
-
type: 'separator'
|
|
804
|
-
}, {
|
|
780
|
+
id: 'media',
|
|
781
|
+
options: [].concat((0, _toConsumableArray2.default)(customOptions), [{
|
|
805
782
|
title: 'Copy',
|
|
806
783
|
onClick: function onClick() {
|
|
807
784
|
var _pluginInjectionApi$c4, _pluginInjectionApi$f3;
|
|
@@ -178,7 +178,6 @@ var generateMediaInlineFloatingToolbar = exports.generateMediaInlineFloatingTool
|
|
|
178
178
|
fullHeight: true
|
|
179
179
|
}, download, {
|
|
180
180
|
type: 'separator',
|
|
181
|
-
fullHeight: true,
|
|
182
181
|
supportsViewMode: true
|
|
183
182
|
}, preview, {
|
|
184
183
|
type: 'separator',
|
|
@@ -195,6 +194,11 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
195
194
|
var mediaSingleTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
196
195
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
197
196
|
var inlineImageItems = [];
|
|
197
|
+
var isEditorControlsEnabled = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
|
|
198
|
+
var isViewOnly = options.isViewOnly,
|
|
199
|
+
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
200
|
+
allowLinking = options.allowLinking,
|
|
201
|
+
allowImagePreview = options.allowImagePreview;
|
|
198
202
|
if ((0, _imageBorder.shouldShowImageBorder)(state)) {
|
|
199
203
|
inlineImageItems.push({
|
|
200
204
|
type: 'custom',
|
|
@@ -224,9 +228,20 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
224
228
|
type: 'separator'
|
|
225
229
|
});
|
|
226
230
|
}
|
|
231
|
+
var download = {
|
|
232
|
+
id: 'editor.media.image.download',
|
|
233
|
+
type: 'button',
|
|
234
|
+
icon: _download.default,
|
|
235
|
+
onClick: function onClick() {
|
|
236
|
+
(0, _utils.downloadMedia)(mediaPluginState, options.isViewOnly);
|
|
237
|
+
return true;
|
|
238
|
+
},
|
|
239
|
+
title: intl.formatMessage(_mediaUi.messages.download),
|
|
240
|
+
supportsViewMode: true
|
|
241
|
+
};
|
|
227
242
|
|
|
228
243
|
// For Editor Controls: show options to convert from 'Inline' to 'Original size' via dropdown
|
|
229
|
-
if (
|
|
244
|
+
if (!isEditorControlsEnabled) {
|
|
230
245
|
inlineImageItems.push({
|
|
231
246
|
id: 'editor.media.convert.mediainline',
|
|
232
247
|
type: 'button',
|
|
@@ -260,6 +275,48 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
260
275
|
onClick: (0, _commands.changeMediaInlineToMediaSingle)(editorAnalyticsAPI, widthPluginState)
|
|
261
276
|
}, {
|
|
262
277
|
type: 'separator'
|
|
278
|
+
}, {
|
|
279
|
+
type: 'custom',
|
|
280
|
+
fallback: [],
|
|
281
|
+
render: function render(editorView, idx) {
|
|
282
|
+
if (editorView !== null && editorView !== void 0 && editorView.state) {
|
|
283
|
+
var editLink = function editLink() {
|
|
284
|
+
if (editorView) {
|
|
285
|
+
var _state = editorView.state,
|
|
286
|
+
dispatch = editorView.dispatch;
|
|
287
|
+
(0, _linking.showLinkingToolbar)(_state, dispatch);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
var openLink = function openLink() {
|
|
291
|
+
if (editorView) {
|
|
292
|
+
var _pluginInjectionApi$a4;
|
|
293
|
+
var tr = editorView.state.tr,
|
|
294
|
+
dispatch = editorView.dispatch;
|
|
295
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.attachAnalyticsEvent({
|
|
296
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
297
|
+
action: _analytics.ACTION.VISITED,
|
|
298
|
+
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
299
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LINK
|
|
300
|
+
})(tr);
|
|
301
|
+
dispatch(tr);
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
return /*#__PURE__*/_react.default.createElement(_linkingToolbarAppearance.LinkToolbarAppearance, {
|
|
306
|
+
key: idx,
|
|
307
|
+
editorState: editorView.state,
|
|
308
|
+
intl: intl,
|
|
309
|
+
mediaLinkingState: mediaLinkingState,
|
|
310
|
+
onAddLink: editLink,
|
|
311
|
+
onEditLink: editLink,
|
|
312
|
+
onOpenLink: openLink,
|
|
313
|
+
isInlineNode: true,
|
|
314
|
+
isViewOnly: options.isViewOnly
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return null;
|
|
318
|
+
},
|
|
319
|
+
supportsViewMode: true
|
|
263
320
|
});
|
|
264
321
|
} else {
|
|
265
322
|
var _options2 = [{
|
|
@@ -309,62 +366,21 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
309
366
|
type: 'separator',
|
|
310
367
|
fullHeight: true
|
|
311
368
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
fallback: [],
|
|
319
|
-
render: function render(editorView, idx) {
|
|
320
|
-
if (editorView !== null && editorView !== void 0 && editorView.state) {
|
|
321
|
-
var editLink = function editLink() {
|
|
322
|
-
if (editorView) {
|
|
323
|
-
var _state = editorView.state,
|
|
324
|
-
dispatch = editorView.dispatch;
|
|
325
|
-
(0, _linking.showLinkingToolbar)(_state, dispatch);
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
var openLink = function openLink() {
|
|
329
|
-
if (editorView) {
|
|
330
|
-
var _pluginInjectionApi$a4;
|
|
331
|
-
var tr = editorView.state.tr,
|
|
332
|
-
dispatch = editorView.dispatch;
|
|
333
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.attachAnalyticsEvent({
|
|
334
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
335
|
-
action: _analytics.ACTION.VISITED,
|
|
336
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
337
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LINK
|
|
338
|
-
})(tr);
|
|
339
|
-
dispatch(tr);
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
return /*#__PURE__*/_react.default.createElement(_linkingToolbarAppearance.LinkToolbarAppearance, {
|
|
344
|
-
key: idx,
|
|
345
|
-
editorState: editorView.state,
|
|
346
|
-
intl: intl,
|
|
347
|
-
mediaLinkingState: mediaLinkingState,
|
|
348
|
-
onAddLink: editLink,
|
|
349
|
-
onEditLink: editLink,
|
|
350
|
-
onOpenLink: openLink,
|
|
351
|
-
isInlineNode: true,
|
|
352
|
-
isViewOnly: options.isViewOnly
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
return null;
|
|
356
|
-
},
|
|
357
|
-
supportsViewMode: true
|
|
358
|
-
});
|
|
369
|
+
if (isViewOnly) {
|
|
370
|
+
inlineImageItems.push(download, {
|
|
371
|
+
type: 'separator',
|
|
372
|
+
supportsViewMode: true
|
|
373
|
+
});
|
|
374
|
+
}
|
|
359
375
|
}
|
|
360
376
|
|
|
361
377
|
//Image Preview
|
|
362
|
-
if (
|
|
378
|
+
if (allowImagePreview) {
|
|
363
379
|
inlineImageItems.push({
|
|
364
380
|
id: 'editor.media.viewer',
|
|
365
381
|
testId: 'file-preview-toolbar-button',
|
|
366
382
|
type: 'button',
|
|
367
|
-
icon: _maximize.default,
|
|
383
|
+
icon: isEditorControlsEnabled ? _growDiagonal.default : _maximize.default,
|
|
368
384
|
iconFallback: _filePreview.default,
|
|
369
385
|
title: intl.formatMessage(_mediaUi.messages.preview),
|
|
370
386
|
onClick: function onClick() {
|
|
@@ -377,42 +393,30 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
377
393
|
supportsViewMode: true
|
|
378
394
|
}, {
|
|
379
395
|
type: 'separator',
|
|
380
|
-
supportsViewMode: true
|
|
381
|
-
fullHeight: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')
|
|
396
|
+
supportsViewMode: true
|
|
382
397
|
});
|
|
383
398
|
}
|
|
384
399
|
|
|
385
400
|
// open link
|
|
386
|
-
if (
|
|
401
|
+
if (allowLinking && (0, _linking3.shouldShowMediaLinkToolbar)(state) && mediaLinkingState && mediaLinkingState.editable && isEditorControlsEnabled) {
|
|
387
402
|
inlineImageItems.push((0, _linking3.getOpenLinkToolbarButtonOption)(intl, mediaLinkingState, pluginInjectionApi), {
|
|
388
403
|
type: 'separator',
|
|
389
|
-
supportsViewMode: true
|
|
390
|
-
fullHeight: true
|
|
404
|
+
supportsViewMode: true
|
|
391
405
|
});
|
|
392
406
|
}
|
|
393
|
-
if (
|
|
394
|
-
inlineImageItems.push({
|
|
395
|
-
id: 'editor.media.image.download',
|
|
396
|
-
type: 'button',
|
|
397
|
-
icon: _download.default,
|
|
398
|
-
onClick: function onClick() {
|
|
399
|
-
(0, _utils.downloadMedia)(mediaPluginState, options.isViewOnly);
|
|
400
|
-
return true;
|
|
401
|
-
},
|
|
402
|
-
title: intl.formatMessage(_mediaUi.messages.download),
|
|
403
|
-
supportsViewMode: true
|
|
404
|
-
}, {
|
|
407
|
+
if (isViewOnly && !isEditorControlsEnabled) {
|
|
408
|
+
inlineImageItems.push(download, {
|
|
405
409
|
type: 'separator',
|
|
406
410
|
supportsViewMode: true
|
|
407
411
|
});
|
|
408
412
|
}
|
|
409
|
-
if (
|
|
413
|
+
if (allowAltTextOnImages && !isEditorControlsEnabled) {
|
|
410
414
|
var _pluginInjectionApi$a5;
|
|
411
415
|
inlineImageItems.push((0, _altText.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions), {
|
|
412
416
|
type: 'separator'
|
|
413
417
|
});
|
|
414
418
|
}
|
|
415
|
-
if (
|
|
419
|
+
if (isViewOnly || !isEditorControlsEnabled) {
|
|
416
420
|
inlineImageItems.push({
|
|
417
421
|
type: 'copy-button',
|
|
418
422
|
supportsViewMode: true,
|
|
@@ -423,7 +427,7 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
|
|
|
423
427
|
}]
|
|
424
428
|
});
|
|
425
429
|
}
|
|
426
|
-
if (
|
|
430
|
+
if (!isEditorControlsEnabled) {
|
|
427
431
|
inlineImageItems.push({
|
|
428
432
|
type: 'separator'
|
|
429
433
|
});
|