@atlaskit/editor-plugin-media 1.16.5 → 1.17.0
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 +545 -238
- package/dist/cjs/nodeviews/mediaSingle.js +14 -10
- package/dist/cjs/plugin.js +3 -1
- package/dist/cjs/toolbar/comments.js +2 -1
- package/dist/cjs/toolbar/index.js +47 -15
- package/dist/cjs/toolbar/linking-toolbar-appearance.js +5 -4
- package/dist/cjs/toolbar/mediaInline.js +1 -1
- package/dist/cjs/toolbar/utils.js +3 -3
- package/dist/cjs/ui/CommentBadge/index.js +5 -2
- package/dist/es2019/nodeviews/mediaSingle.js +17 -11
- package/dist/es2019/plugin.js +19 -15
- package/dist/es2019/toolbar/comments.js +2 -1
- package/dist/es2019/toolbar/index.js +47 -15
- package/dist/es2019/toolbar/linking-toolbar-appearance.js +5 -4
- package/dist/es2019/toolbar/mediaInline.js +1 -1
- package/dist/es2019/toolbar/utils.js +2 -2
- package/dist/es2019/ui/CommentBadge/index.js +5 -2
- package/dist/esm/nodeviews/mediaSingle.js +15 -11
- package/dist/esm/plugin.js +3 -1
- package/dist/esm/toolbar/comments.js +2 -1
- package/dist/esm/toolbar/index.js +47 -15
- package/dist/esm/toolbar/linking-toolbar-appearance.js +5 -4
- package/dist/esm/toolbar/mediaInline.js +1 -1
- package/dist/esm/toolbar/utils.js +3 -3
- package/dist/esm/ui/CommentBadge/index.js +5 -2
- package/dist/types/toolbar/linking-toolbar-appearance.d.ts +2 -1
- package/dist/types/toolbar/linking.d.ts +1 -2
- package/dist/types/toolbar/utils.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/CommentBadge/index.d.ts +2 -0
- package/dist/types-ts4.5/toolbar/linking-toolbar-appearance.d.ts +2 -1
- package/dist/types-ts4.5/toolbar/linking.d.ts +1 -2
- package/dist/types-ts4.5/toolbar/utils.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/CommentBadge/index.d.ts +2 -0
- package/package.json +6 -3
|
@@ -34,7 +34,6 @@ var _captions = require("../commands/captions");
|
|
|
34
34
|
var _main = require("../pm-plugins/main");
|
|
35
35
|
var _CaptionPlaceholder = _interopRequireDefault(require("../ui/CaptionPlaceholder"));
|
|
36
36
|
var _CommentBadge = require("../ui/CommentBadge");
|
|
37
|
-
var _MediaViewerContainer = require("../ui/MediaViewer/MediaViewerContainer");
|
|
38
37
|
var _ResizableMediaSingle = _interopRequireDefault(require("../ui/ResizableMediaSingle"));
|
|
39
38
|
var _ResizableMediaSingleNext = _interopRequireDefault(require("../ui/ResizableMediaSingle/ResizableMediaSingleNext"));
|
|
40
39
|
var _mediaCommon = require("../utils/media-common");
|
|
@@ -329,7 +328,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
329
328
|
}, {
|
|
330
329
|
key: "render",
|
|
331
330
|
value: function render() {
|
|
332
|
-
var _mediaOptions$getEdit, _pluginInjectionApi$m, _node$firstChild;
|
|
331
|
+
var _mediaOptions$getEdit, _pluginInjectionApi$m, _node$firstChild, _mediaOptions$getEdit2;
|
|
333
332
|
var _this$props2 = this.props,
|
|
334
333
|
selected = _this$props2.selected,
|
|
335
334
|
getPos = _this$props2.getPos,
|
|
@@ -343,7 +342,6 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
343
342
|
lineLength = _this$props2.lineLength,
|
|
344
343
|
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
|
|
345
344
|
editorViewMode = _this$props2.editorViewMode,
|
|
346
|
-
mediaPluginState = _this$props2.mediaPluginState,
|
|
347
345
|
editorDisabled = _this$props2.editorDisabled,
|
|
348
346
|
annotationPluginState = _this$props2.annotationPluginState;
|
|
349
347
|
var _ref4 = (mediaOptions === null || mediaOptions === void 0 || (_mediaOptions$getEdit = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit === void 0 ? void 0 : _mediaOptions$getEdit.call(mediaOptions)) || {},
|
|
@@ -430,6 +428,16 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
430
428
|
canResize = canResize && !disabledNode;
|
|
431
429
|
}
|
|
432
430
|
}
|
|
431
|
+
var isBadgePosOffsetRight = function isBadgePosOffsetRight() {
|
|
432
|
+
var pos = getPos();
|
|
433
|
+
if (pos !== undefined) {
|
|
434
|
+
var _$pos = view.state.doc.resolve(pos);
|
|
435
|
+
var _table = view.state.schema.nodes.table;
|
|
436
|
+
var foundTableNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(_$pos, [_table]);
|
|
437
|
+
return foundTableNode ? '2px' : '14px';
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
var badgeOffsetRight = isBadgePosOffsetRight();
|
|
433
441
|
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
|
|
434
442
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
435
443
|
shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
|
|
@@ -441,9 +449,11 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
441
449
|
className: _styles.MediaSingleNodeSelector,
|
|
442
450
|
onClick: this.onMediaSingleClicked
|
|
443
451
|
}, commentsOnMedia && (0, _react2.jsx)(_CommentBadge.CommentBadge, {
|
|
452
|
+
commentsOnMediaBugFixEnabled: mediaOptions === null || mediaOptions === void 0 || (_mediaOptions$getEdit2 = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit2 === void 0 || (_mediaOptions$getEdit2 = _mediaOptions$getEdit2.call(mediaOptions)) === null || _mediaOptions$getEdit2 === void 0 ? void 0 : _mediaOptions$getEdit2.commentsOnMediaBugFix,
|
|
444
453
|
view: view,
|
|
445
454
|
api: pluginInjectionApi,
|
|
446
455
|
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
456
|
+
badgeOffsetRight: badgeOffsetRight,
|
|
447
457
|
getPos: getPos,
|
|
448
458
|
isDrafting: isCurrentNodeDrafting
|
|
449
459
|
}), (0, _react2.jsx)("div", {
|
|
@@ -452,13 +462,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
452
462
|
ref: this.captionPlaceHolderRef,
|
|
453
463
|
onClick: this.clickPlaceholder
|
|
454
464
|
}));
|
|
455
|
-
return (0, _react2.jsx)(
|
|
456
|
-
mediaPluginState: mediaPluginState,
|
|
457
|
-
isEditorViewMode: editorViewMode,
|
|
458
|
-
mediaNode: node,
|
|
459
|
-
isSelected: isSelected,
|
|
460
|
-
isInline: false
|
|
461
|
-
}, canResize ? (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? (0, _react2.jsx)(_ResizableMediaSingleNext.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
465
|
+
return (0, _react2.jsx)(_react.Fragment, null, canResize ? (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? (0, _react2.jsx)(_ResizableMediaSingleNext.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
462
466
|
showLegacyNotification: widthType !== 'pixel'
|
|
463
467
|
}), MediaChildren) : (0, _react2.jsx)(_ResizableMediaSingle.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
464
468
|
lineLength: contentWidthForLegacyExperience,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -269,6 +269,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
269
269
|
}];
|
|
270
270
|
},
|
|
271
271
|
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
272
|
+
var _api$editorViewMode;
|
|
272
273
|
return (0, _toolbar.floatingToolbar)(state, intl, {
|
|
273
274
|
providerFactory: providerFactory,
|
|
274
275
|
allowMediaInline: options && (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', options.featureFlags),
|
|
@@ -282,7 +283,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
282
283
|
altTextValidator: options && options.altTextValidator,
|
|
283
284
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
284
285
|
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
285
|
-
getEditorFeatureFlags: options && options.getEditorFeatureFlags
|
|
286
|
+
getEditorFeatureFlags: options && options.getEditorFeatureFlags,
|
|
287
|
+
isViewOnly: (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view'
|
|
286
288
|
}, api);
|
|
287
289
|
}
|
|
288
290
|
}
|
|
@@ -45,6 +45,7 @@ var commentButton = exports.commentButton = function commentButton(intl, state,
|
|
|
45
45
|
onClick: onClickHandler,
|
|
46
46
|
tooltipContent: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
47
47
|
description: title
|
|
48
|
-
})
|
|
48
|
+
}),
|
|
49
|
+
supportsViewMode: true
|
|
49
50
|
};
|
|
50
51
|
};
|
|
@@ -77,10 +77,14 @@ var generateFilePreviewItem = exports.generateFilePreviewItem = function generat
|
|
|
77
77
|
mediaPluginState: mediaPluginState,
|
|
78
78
|
intl: intl
|
|
79
79
|
});
|
|
80
|
-
}
|
|
80
|
+
},
|
|
81
|
+
supportsViewMode: true
|
|
81
82
|
};
|
|
82
83
|
};
|
|
83
|
-
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) {
|
|
84
|
+
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
|
|
85
|
+
if (isViewOnly) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
84
88
|
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
85
89
|
var items = [{
|
|
86
90
|
type: 'separator'
|
|
@@ -182,7 +186,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
182
186
|
allowMediaInline = options.allowMediaInline,
|
|
183
187
|
allowMediaInlineImages = options.allowMediaInlineImages,
|
|
184
188
|
allowImagePreview = options.allowImagePreview,
|
|
185
|
-
getEditorFeatureFlags = options.getEditorFeatureFlags
|
|
189
|
+
getEditorFeatureFlags = options.getEditorFeatureFlags,
|
|
190
|
+
isViewOnly = options.isViewOnly;
|
|
186
191
|
var editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
|
|
187
192
|
var toolbarButtons = [];
|
|
188
193
|
var _ref = (_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 : {},
|
|
@@ -406,9 +411,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
406
411
|
type: 'separator'
|
|
407
412
|
});
|
|
408
413
|
}
|
|
409
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia)
|
|
414
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia && (!isViewOnly || isViewOnly && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.comments-in-media-toolbar-button')) //This is required until this fix is merged: https://product-fabric.atlassian.net/browse/ED-23180
|
|
415
|
+
) {
|
|
410
416
|
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
|
|
411
|
-
type: 'separator'
|
|
417
|
+
type: 'separator',
|
|
418
|
+
supportsViewMode: true
|
|
412
419
|
});
|
|
413
420
|
}
|
|
414
421
|
if (allowLinking && (0, _linking3.shouldShowMediaLinkToolbar)(state)) {
|
|
@@ -446,11 +453,13 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
446
453
|
mediaLinkingState: mediaLinkingState,
|
|
447
454
|
onAddLink: editLink,
|
|
448
455
|
onEditLink: editLink,
|
|
449
|
-
onOpenLink: openLink
|
|
456
|
+
onOpenLink: openLink,
|
|
457
|
+
isViewOnly: isViewOnly
|
|
450
458
|
});
|
|
451
459
|
}
|
|
452
460
|
return null;
|
|
453
|
-
}
|
|
461
|
+
},
|
|
462
|
+
supportsViewMode: true
|
|
454
463
|
});
|
|
455
464
|
}
|
|
456
465
|
// Preview Support
|
|
@@ -460,11 +469,28 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
460
469
|
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
461
470
|
if (!(0, _mediaSingle2.isVideo)(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
462
471
|
toolbarButtons.push(generateFilePreviewItem(pluginState, intl), {
|
|
463
|
-
type: 'separator'
|
|
472
|
+
type: 'separator',
|
|
473
|
+
supportsViewMode: true
|
|
464
474
|
});
|
|
465
475
|
}
|
|
466
476
|
}
|
|
467
477
|
}
|
|
478
|
+
if (isViewOnly) {
|
|
479
|
+
toolbarButtons.push({
|
|
480
|
+
id: 'editor.media.image.download',
|
|
481
|
+
type: 'button',
|
|
482
|
+
icon: _download.default,
|
|
483
|
+
onClick: function onClick() {
|
|
484
|
+
(0, _utils2.downloadMedia)(pluginState, isViewOnly);
|
|
485
|
+
return true;
|
|
486
|
+
},
|
|
487
|
+
title: intl.formatMessage(_mediaUi.messages.download),
|
|
488
|
+
supportsViewMode: true
|
|
489
|
+
}, {
|
|
490
|
+
type: 'separator',
|
|
491
|
+
supportsViewMode: true
|
|
492
|
+
});
|
|
493
|
+
}
|
|
468
494
|
if (allowAltTextOnImages) {
|
|
469
495
|
var _pluginInjectionApi$a7;
|
|
470
496
|
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), {
|
|
@@ -483,7 +509,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
483
509
|
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
484
510
|
title: intl.formatMessage(_messages.default.remove),
|
|
485
511
|
onClick: remove,
|
|
486
|
-
testId: 'media-toolbar-remove-button'
|
|
512
|
+
testId: 'media-toolbar-remove-button',
|
|
513
|
+
supportsViewMode: false
|
|
487
514
|
};
|
|
488
515
|
var items = [].concat((0, _toConsumableArray2.default)(toolbarButtons), [{
|
|
489
516
|
type: 'copy-button',
|
|
@@ -491,10 +518,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
491
518
|
state: state,
|
|
492
519
|
formatMessage: intl.formatMessage,
|
|
493
520
|
nodeType: mediaSingle
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
521
|
+
}],
|
|
522
|
+
supportsViewMode: true
|
|
523
|
+
}]);
|
|
524
|
+
items.push({
|
|
525
|
+
type: 'separator',
|
|
526
|
+
supportsViewMode: false
|
|
527
|
+
});
|
|
528
|
+
items.push(removeButton);
|
|
498
529
|
return items;
|
|
499
530
|
};
|
|
500
531
|
var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
|
|
@@ -517,7 +548,8 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
517
548
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
518
549
|
providerFactory = options.providerFactory,
|
|
519
550
|
allowMediaInline = options.allowMediaInline,
|
|
520
|
-
allowResizing = options.allowResizing
|
|
551
|
+
allowResizing = options.allowResizing,
|
|
552
|
+
isViewOnly = options.isViewOnly;
|
|
521
553
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
522
554
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
523
555
|
var _ref3 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
@@ -563,7 +595,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
563
595
|
var selector = (0, _mediaFilmstrip.mediaFilmstripItemDOMSelector)(mediaOffset);
|
|
564
596
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
565
597
|
};
|
|
566
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector);
|
|
598
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector, isViewOnly);
|
|
567
599
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
568
600
|
baseToolbar.getDomRef = function () {
|
|
569
601
|
var _mediaPluginState$ele2;
|
|
@@ -33,7 +33,8 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = function LinkToolbar
|
|
|
33
33
|
onAddLink = _ref.onAddLink,
|
|
34
34
|
onEditLink = _ref.onEditLink,
|
|
35
35
|
onOpenLink = _ref.onOpenLink,
|
|
36
|
-
isInlineNode = _ref.isInlineNode
|
|
36
|
+
isInlineNode = _ref.isInlineNode,
|
|
37
|
+
isViewOnly = _ref.isViewOnly;
|
|
37
38
|
var _useState = (0, _react.useState)(true),
|
|
38
39
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
39
40
|
showLinkingControls = _useState2[0],
|
|
@@ -61,7 +62,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = function LinkToolbar
|
|
|
61
62
|
var isValidUrl = (0, _adfSchema.isSafeUrl)(mediaLinkingState.link);
|
|
62
63
|
var title = intl.formatMessage(_messages.linkToolbarMessages.editLink);
|
|
63
64
|
var linkTitle = intl.formatMessage(isValidUrl ? _messages.linkMessages.openLink : _messages.linkToolbarMessages.unableToOpenLink);
|
|
64
|
-
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)("div", {
|
|
65
|
+
return (0, _react2.jsx)(_react.Fragment, null, !isViewOnly && (0, _react2.jsx)("div", {
|
|
65
66
|
css: wrapperStyles
|
|
66
67
|
}, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
67
68
|
onClick: onEditLink,
|
|
@@ -84,7 +85,7 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = function LinkToolbar
|
|
|
84
85
|
}), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
|
|
85
86
|
} else {
|
|
86
87
|
var _title = intl.formatMessage(_messages.linkToolbarMessages.addLink);
|
|
87
|
-
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
88
|
+
return !isViewOnly ? (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
|
|
88
89
|
testId: "add-link-button",
|
|
89
90
|
onClick: onAddLink,
|
|
90
91
|
title: _title,
|
|
@@ -95,6 +96,6 @@ var LinkToolbarAppearance = exports.LinkToolbarAppearance = function LinkToolbar
|
|
|
95
96
|
icon: (0, _react2.jsx)(_link.default, {
|
|
96
97
|
label: _title
|
|
97
98
|
})
|
|
98
|
-
}), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null));
|
|
99
|
+
}), (0, _react2.jsx)(_ui.FloatingToolbarSeparator, null)) : null;
|
|
99
100
|
}
|
|
100
101
|
};
|
|
@@ -249,7 +249,7 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
|
|
|
249
249
|
});
|
|
250
250
|
|
|
251
251
|
//Image Preview
|
|
252
|
-
if (options.allowImagePreview) {
|
|
252
|
+
if (!options.isViewOnly && options.allowImagePreview) {
|
|
253
253
|
inlineImageItems.push((0, _index.generateFilePreviewItem)(mediaPluginState, intl), {
|
|
254
254
|
type: 'separator'
|
|
255
255
|
});
|
|
@@ -39,13 +39,13 @@ var getSelectedNearestMediaContainerNodeAttrs = exports.getSelectedNearestMediaC
|
|
|
39
39
|
return null;
|
|
40
40
|
};
|
|
41
41
|
var downloadMedia = exports.downloadMedia = /*#__PURE__*/function () {
|
|
42
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaPluginState) {
|
|
42
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaPluginState, isViewMode) {
|
|
43
43
|
var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName;
|
|
44
44
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
45
45
|
while (1) switch (_context.prev = _context.next) {
|
|
46
46
|
case 0:
|
|
47
47
|
_context.prev = 0;
|
|
48
|
-
selectedNodeAttrs = getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
48
|
+
selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
|
|
49
49
|
if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig)) {
|
|
50
50
|
_context.next = 10;
|
|
51
51
|
break;
|
|
@@ -72,7 +72,7 @@ var downloadMedia = exports.downloadMedia = /*#__PURE__*/function () {
|
|
|
72
72
|
}
|
|
73
73
|
}, _callee, null, [[0, 13]]);
|
|
74
74
|
}));
|
|
75
|
-
return function downloadMedia(_x) {
|
|
75
|
+
return function downloadMedia(_x, _x2) {
|
|
76
76
|
return _ref.apply(this, arguments);
|
|
77
77
|
};
|
|
78
78
|
}();
|
|
@@ -19,7 +19,9 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
19
19
|
view = _ref.view,
|
|
20
20
|
getPos = _ref.getPos,
|
|
21
21
|
intl = _ref.intl,
|
|
22
|
-
isDrafting = _ref.isDrafting
|
|
22
|
+
isDrafting = _ref.isDrafting,
|
|
23
|
+
badgeOffsetRight = _ref.badgeOffsetRight,
|
|
24
|
+
commentsOnMediaBugFixEnabled = _ref.commentsOnMediaBugFixEnabled;
|
|
23
25
|
var _useState = (0, _react.useState)(false),
|
|
24
26
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
25
27
|
entered = _useState2[0],
|
|
@@ -56,12 +58,13 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref) {
|
|
|
56
58
|
}
|
|
57
59
|
var mediaElement = view.domAtPos(pos + 1).node;
|
|
58
60
|
return /*#__PURE__*/_react.default.createElement(_mediaSingle.CommentBadge, {
|
|
61
|
+
commentsOnMediaBugFixEnabled: commentsOnMediaBugFixEnabled,
|
|
62
|
+
badgeOffsetRight: badgeOffsetRight,
|
|
59
63
|
width: mediaNode.attrs.width,
|
|
60
64
|
height: mediaNode.attrs.height,
|
|
61
65
|
onClick: onClick,
|
|
62
66
|
mediaElement: mediaElement,
|
|
63
67
|
intl: intl,
|
|
64
|
-
isEditor: true,
|
|
65
68
|
status: entered ? 'entered' : status,
|
|
66
69
|
onMouseEnter: function onMouseEnter() {
|
|
67
70
|
return setEntered(true);
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
|
|
5
|
-
import React, { Component } from 'react';
|
|
5
|
+
import React, { Component, Fragment } from 'react';
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
|
|
@@ -19,7 +19,6 @@ import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
|
19
19
|
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
20
20
|
import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
21
21
|
import { CommentBadge } from '../ui/CommentBadge';
|
|
22
|
-
import { MediaViewerContainer } from '../ui/MediaViewer/MediaViewerContainer';
|
|
23
22
|
import ResizableMediaSingle from '../ui/ResizableMediaSingle';
|
|
24
23
|
import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
|
|
25
24
|
import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
|
|
@@ -230,7 +229,7 @@ export default class MediaSingleNode extends Component {
|
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
231
|
render() {
|
|
233
|
-
var _mediaOptions$getEdit, _pluginInjectionApi$m, _pluginInjectionApi$m2, _node$firstChild;
|
|
232
|
+
var _mediaOptions$getEdit, _pluginInjectionApi$m, _pluginInjectionApi$m2, _node$firstChild, _mediaOptions$getEdit2, _mediaOptions$getEdit3;
|
|
234
233
|
const {
|
|
235
234
|
selected,
|
|
236
235
|
getPos,
|
|
@@ -246,7 +245,6 @@ export default class MediaSingleNode extends Component {
|
|
|
246
245
|
lineLength,
|
|
247
246
|
dispatchAnalyticsEvent,
|
|
248
247
|
editorViewMode,
|
|
249
|
-
mediaPluginState,
|
|
250
248
|
editorDisabled,
|
|
251
249
|
annotationPluginState
|
|
252
250
|
} = this.props;
|
|
@@ -343,6 +341,18 @@ export default class MediaSingleNode extends Component {
|
|
|
343
341
|
canResize = canResize && !disabledNode;
|
|
344
342
|
}
|
|
345
343
|
}
|
|
344
|
+
const isBadgePosOffsetRight = () => {
|
|
345
|
+
const pos = getPos();
|
|
346
|
+
if (pos !== undefined) {
|
|
347
|
+
const $pos = view.state.doc.resolve(pos);
|
|
348
|
+
const {
|
|
349
|
+
table
|
|
350
|
+
} = view.state.schema.nodes;
|
|
351
|
+
const foundTableNode = findParentNodeOfTypeClosestToPos($pos, [table]);
|
|
352
|
+
return foundTableNode ? '2px' : '14px';
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const badgeOffsetRight = isBadgePosOffsetRight();
|
|
346
356
|
let shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
347
357
|
if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
348
358
|
shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
|
|
@@ -354,9 +364,11 @@ export default class MediaSingleNode extends Component {
|
|
|
354
364
|
className: MediaSingleNodeSelector,
|
|
355
365
|
onClick: this.onMediaSingleClicked
|
|
356
366
|
}, commentsOnMedia && jsx(CommentBadge, {
|
|
367
|
+
commentsOnMediaBugFixEnabled: mediaOptions === null || mediaOptions === void 0 ? void 0 : (_mediaOptions$getEdit2 = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit2 === void 0 ? void 0 : (_mediaOptions$getEdit3 = _mediaOptions$getEdit2.call(mediaOptions)) === null || _mediaOptions$getEdit3 === void 0 ? void 0 : _mediaOptions$getEdit3.commentsOnMediaBugFix,
|
|
357
368
|
view: view,
|
|
358
369
|
api: pluginInjectionApi,
|
|
359
370
|
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
371
|
+
badgeOffsetRight: badgeOffsetRight,
|
|
360
372
|
getPos: getPos,
|
|
361
373
|
isDrafting: isCurrentNodeDrafting
|
|
362
374
|
}), jsx("div", {
|
|
@@ -365,13 +377,7 @@ export default class MediaSingleNode extends Component {
|
|
|
365
377
|
ref: this.captionPlaceHolderRef,
|
|
366
378
|
onClick: this.clickPlaceholder
|
|
367
379
|
}));
|
|
368
|
-
return jsx(
|
|
369
|
-
mediaPluginState: mediaPluginState,
|
|
370
|
-
isEditorViewMode: editorViewMode,
|
|
371
|
-
mediaNode: node,
|
|
372
|
-
isSelected: isSelected,
|
|
373
|
-
isInline: false
|
|
374
|
-
}, canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
|
|
380
|
+
return jsx(Fragment, null, canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
|
|
375
381
|
showLegacyNotification: widthType !== 'pixel'
|
|
376
382
|
}), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
|
|
377
383
|
lineLength: contentWidthForLegacyExperience,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -262,21 +262,25 @@ export const mediaPlugin = ({
|
|
|
262
262
|
return tr;
|
|
263
263
|
}
|
|
264
264
|
}],
|
|
265
|
-
floatingToolbar: (state, intl, providerFactory) =>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
265
|
+
floatingToolbar: (state, intl, providerFactory) => {
|
|
266
|
+
var _api$editorViewMode, _api$editorViewMode$s;
|
|
267
|
+
return floatingToolbar(state, intl, {
|
|
268
|
+
providerFactory,
|
|
269
|
+
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
270
|
+
allowResizing: options && options.allowResizing,
|
|
271
|
+
allowResizingInTables: options && options.allowResizingInTables,
|
|
272
|
+
allowCommentsOnMedia: options && options.allowCommentsOnMedia,
|
|
273
|
+
allowLinking: options && options.allowLinking,
|
|
274
|
+
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
275
|
+
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
276
|
+
allowImagePreview: options && options.allowImagePreview,
|
|
277
|
+
altTextValidator: options && options.altTextValidator,
|
|
278
|
+
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
279
|
+
allowMediaInlineImages: options && options.allowMediaInlineImages,
|
|
280
|
+
getEditorFeatureFlags: options && options.getEditorFeatureFlags,
|
|
281
|
+
isViewOnly: (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view'
|
|
282
|
+
}, api);
|
|
283
|
+
}
|
|
280
284
|
}
|
|
281
285
|
};
|
|
282
286
|
};
|
|
@@ -63,10 +63,14 @@ export const generateFilePreviewItem = (mediaPluginState, intl) => {
|
|
|
63
63
|
mediaPluginState: mediaPluginState,
|
|
64
64
|
intl: intl
|
|
65
65
|
});
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
supportsViewMode: true
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
|
-
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) => {
|
|
70
|
+
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector, isViewOnly) => {
|
|
71
|
+
if (isViewOnly) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
70
74
|
const {
|
|
71
75
|
mediaGroup
|
|
72
76
|
} = state.schema.nodes;
|
|
@@ -171,7 +175,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
171
175
|
allowMediaInline,
|
|
172
176
|
allowMediaInlineImages,
|
|
173
177
|
allowImagePreview,
|
|
174
|
-
getEditorFeatureFlags
|
|
178
|
+
getEditorFeatureFlags,
|
|
179
|
+
isViewOnly
|
|
175
180
|
} = options;
|
|
176
181
|
const editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
|
|
177
182
|
let toolbarButtons = [];
|
|
@@ -403,9 +408,11 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
403
408
|
type: 'separator'
|
|
404
409
|
});
|
|
405
410
|
}
|
|
406
|
-
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia)
|
|
411
|
+
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia && (!isViewOnly || isViewOnly && getBooleanFF('platform.editor.live-view.comments-in-media-toolbar-button')) //This is required until this fix is merged: https://product-fabric.atlassian.net/browse/ED-23180
|
|
412
|
+
) {
|
|
407
413
|
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
408
|
-
type: 'separator'
|
|
414
|
+
type: 'separator',
|
|
415
|
+
supportsViewMode: true
|
|
409
416
|
});
|
|
410
417
|
}
|
|
411
418
|
if (allowLinking && shouldShowMediaLinkToolbar(state)) {
|
|
@@ -449,11 +456,13 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
449
456
|
mediaLinkingState: mediaLinkingState,
|
|
450
457
|
onAddLink: editLink,
|
|
451
458
|
onEditLink: editLink,
|
|
452
|
-
onOpenLink: openLink
|
|
459
|
+
onOpenLink: openLink,
|
|
460
|
+
isViewOnly: isViewOnly
|
|
453
461
|
});
|
|
454
462
|
}
|
|
455
463
|
return null;
|
|
456
|
-
}
|
|
464
|
+
},
|
|
465
|
+
supportsViewMode: true
|
|
457
466
|
});
|
|
458
467
|
}
|
|
459
468
|
// Preview Support
|
|
@@ -463,11 +472,28 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
463
472
|
const mediaNode = selectedMediaSingleNode === null || selectedMediaSingleNode === void 0 ? void 0 : selectedMediaSingleNode.node.content.firstChild;
|
|
464
473
|
if (!isVideo(mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
465
474
|
toolbarButtons.push(generateFilePreviewItem(pluginState, intl), {
|
|
466
|
-
type: 'separator'
|
|
475
|
+
type: 'separator',
|
|
476
|
+
supportsViewMode: true
|
|
467
477
|
});
|
|
468
478
|
}
|
|
469
479
|
}
|
|
470
480
|
}
|
|
481
|
+
if (isViewOnly) {
|
|
482
|
+
toolbarButtons.push({
|
|
483
|
+
id: 'editor.media.image.download',
|
|
484
|
+
type: 'button',
|
|
485
|
+
icon: DownloadIcon,
|
|
486
|
+
onClick: () => {
|
|
487
|
+
downloadMedia(pluginState, isViewOnly);
|
|
488
|
+
return true;
|
|
489
|
+
},
|
|
490
|
+
title: intl.formatMessage(messages.download),
|
|
491
|
+
supportsViewMode: true
|
|
492
|
+
}, {
|
|
493
|
+
type: 'separator',
|
|
494
|
+
supportsViewMode: true
|
|
495
|
+
});
|
|
496
|
+
}
|
|
471
497
|
if (allowAltTextOnImages) {
|
|
472
498
|
var _pluginInjectionApi$a7;
|
|
473
499
|
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
@@ -486,7 +512,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
486
512
|
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
487
513
|
title: intl.formatMessage(commonMessages.remove),
|
|
488
514
|
onClick: remove,
|
|
489
|
-
testId: 'media-toolbar-remove-button'
|
|
515
|
+
testId: 'media-toolbar-remove-button',
|
|
516
|
+
supportsViewMode: false
|
|
490
517
|
};
|
|
491
518
|
const items = [...toolbarButtons, {
|
|
492
519
|
type: 'copy-button',
|
|
@@ -494,10 +521,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
494
521
|
state,
|
|
495
522
|
formatMessage: intl.formatMessage,
|
|
496
523
|
nodeType: mediaSingle
|
|
497
|
-
},
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
524
|
+
}],
|
|
525
|
+
supportsViewMode: true
|
|
526
|
+
}];
|
|
527
|
+
items.push({
|
|
528
|
+
type: 'separator',
|
|
529
|
+
supportsViewMode: false
|
|
530
|
+
});
|
|
531
|
+
items.push(removeButton);
|
|
501
532
|
return items;
|
|
502
533
|
};
|
|
503
534
|
const getMediaTypeMessage = selectedNodeTypeSingle => {
|
|
@@ -518,7 +549,8 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
518
549
|
allowAltTextOnImages,
|
|
519
550
|
providerFactory,
|
|
520
551
|
allowMediaInline,
|
|
521
|
-
allowResizing
|
|
552
|
+
allowResizing,
|
|
553
|
+
isViewOnly
|
|
522
554
|
} = options;
|
|
523
555
|
const mediaPluginState = stateKey.getState(state);
|
|
524
556
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
@@ -564,7 +596,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
564
596
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
565
597
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
566
598
|
};
|
|
567
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.actions) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.forceFocusSelector);
|
|
599
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.actions) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.forceFocusSelector, isViewOnly);
|
|
568
600
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
569
601
|
baseToolbar.getDomRef = () => {
|
|
570
602
|
var _mediaPluginState$ele2;
|
|
@@ -21,7 +21,8 @@ export const LinkToolbarAppearance = ({
|
|
|
21
21
|
onAddLink,
|
|
22
22
|
onEditLink,
|
|
23
23
|
onOpenLink,
|
|
24
|
-
isInlineNode
|
|
24
|
+
isInlineNode,
|
|
25
|
+
isViewOnly
|
|
25
26
|
}) => {
|
|
26
27
|
const [showLinkingControls, setShowLinkingControls] = useState(true);
|
|
27
28
|
useEffect(() => {
|
|
@@ -47,7 +48,7 @@ export const LinkToolbarAppearance = ({
|
|
|
47
48
|
const isValidUrl = isSafeUrl(mediaLinkingState.link);
|
|
48
49
|
const title = intl.formatMessage(linkToolbarMessages.editLink);
|
|
49
50
|
const linkTitle = intl.formatMessage(isValidUrl ? linkMessages.openLink : linkToolbarMessages.unableToOpenLink);
|
|
50
|
-
return jsx(Fragment, null, jsx("div", {
|
|
51
|
+
return jsx(Fragment, null, !isViewOnly && jsx("div", {
|
|
51
52
|
css: wrapperStyles
|
|
52
53
|
}, jsx(ToolbarButton, {
|
|
53
54
|
onClick: onEditLink,
|
|
@@ -70,7 +71,7 @@ export const LinkToolbarAppearance = ({
|
|
|
70
71
|
}), jsx(Separator, null));
|
|
71
72
|
} else {
|
|
72
73
|
const title = intl.formatMessage(linkToolbarMessages.addLink);
|
|
73
|
-
return jsx(Fragment, null, jsx(ToolbarButton, {
|
|
74
|
+
return !isViewOnly ? jsx(Fragment, null, jsx(ToolbarButton, {
|
|
74
75
|
testId: "add-link-button",
|
|
75
76
|
onClick: onAddLink,
|
|
76
77
|
title: title,
|
|
@@ -81,6 +82,6 @@ export const LinkToolbarAppearance = ({
|
|
|
81
82
|
icon: jsx(LinkIcon, {
|
|
82
83
|
label: title
|
|
83
84
|
})
|
|
84
|
-
}), jsx(Separator, null));
|
|
85
|
+
}), jsx(Separator, null)) : null;
|
|
85
86
|
}
|
|
86
87
|
};
|
|
@@ -243,7 +243,7 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
|
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
//Image Preview
|
|
246
|
-
if (options.allowImagePreview) {
|
|
246
|
+
if (!options.isViewOnly && options.allowImagePreview) {
|
|
247
247
|
inlineImageItems.push(generateFilePreviewItem(mediaPluginState, intl), {
|
|
248
248
|
type: 'separator'
|
|
249
249
|
});
|