@atlaskit/editor-plugin-media 1.16.6 → 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#92514](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92514)
8
+ [`8f64cde1a25a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8f64cde1a25a) -
9
+ [ux] Add floating toolbar to MediaSingle nodes for Live View editor
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 1.16.6
4
16
 
5
17
  ### Patch Changes
@@ -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");
@@ -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)) || {},
@@ -464,13 +462,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
464
462
  ref: this.captionPlaceHolderRef,
465
463
  onClick: this.clickPlaceholder
466
464
  }));
467
- return (0, _react2.jsx)(_MediaViewerContainer.MediaViewerContainer, {
468
- mediaPluginState: mediaPluginState,
469
- isEditorViewMode: editorViewMode,
470
- mediaNode: node,
471
- isSelected: isSelected,
472
- isInline: false
473
- }, 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, {
474
466
  showLegacyNotification: widthType !== 'pixel'
475
467
  }), MediaChildren) : (0, _react2.jsx)(_ResizableMediaSingle.default, (0, _extends2.default)({}, resizableMediaSingleProps, {
476
468
  lineLength: contentWidthForLegacyExperience,
@@ -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
- type: 'separator'
496
- }]
497
- }, removeButton]);
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
  }();
@@ -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';
@@ -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;
@@ -379,13 +377,7 @@ export default class MediaSingleNode extends Component {
379
377
  ref: this.captionPlaceHolderRef,
380
378
  onClick: this.clickPlaceholder
381
379
  }));
382
- return jsx(MediaViewerContainer, {
383
- mediaPluginState: mediaPluginState,
384
- isEditorViewMode: editorViewMode,
385
- mediaNode: node,
386
- isSelected: isSelected,
387
- isInline: false
388
- }, 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, {
389
381
  showLegacyNotification: widthType !== 'pixel'
390
382
  }), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
391
383
  lineLength: contentWidthForLegacyExperience,
@@ -262,21 +262,25 @@ export const mediaPlugin = ({
262
262
  return tr;
263
263
  }
264
264
  }],
265
- floatingToolbar: (state, intl, providerFactory) => floatingToolbar(state, intl, {
266
- providerFactory,
267
- allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
268
- allowResizing: options && options.allowResizing,
269
- allowResizingInTables: options && options.allowResizingInTables,
270
- allowCommentsOnMedia: options && options.allowCommentsOnMedia,
271
- allowLinking: options && options.allowLinking,
272
- allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
273
- allowAltTextOnImages: options && options.allowAltTextOnImages,
274
- allowImagePreview: options && options.allowImagePreview,
275
- altTextValidator: options && options.altTextValidator,
276
- fullWidthEnabled: options && options.fullWidthEnabled,
277
- allowMediaInlineImages: options && options.allowMediaInlineImages,
278
- getEditorFeatureFlags: options && options.getEditorFeatureFlags
279
- }, api)
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
  };
@@ -37,6 +37,7 @@ export const commentButton = (intl, state, api) => {
37
37
  onClick: onClickHandler,
38
38
  tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
39
39
  description: title
40
- })
40
+ }),
41
+ supportsViewMode: true
41
42
  };
42
43
  };
@@ -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
- type: 'separator'
499
- }]
500
- }, removeButton];
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
  });
@@ -29,9 +29,9 @@ export const getSelectedNearestMediaContainerNodeAttrs = mediaPluginState => {
29
29
  }
30
30
  return null;
31
31
  };
32
- export const downloadMedia = async mediaPluginState => {
32
+ export const downloadMedia = async (mediaPluginState, isViewMode) => {
33
33
  try {
34
- const selectedNodeAttrs = getSelectedMediaContainerNodeAttrs(mediaPluginState);
34
+ const selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
35
35
  if (selectedNodeAttrs && mediaPluginState.mediaClientConfig) {
36
36
  const {
37
37
  id,
@@ -15,7 +15,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
15
15
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
16
  /** @jsx jsx */
17
17
 
18
- import React, { Component } from 'react';
18
+ import React, { Component, Fragment } from 'react';
19
19
  import { css, jsx } from '@emotion/react';
20
20
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
21
21
  import { calcMediaSinglePixelWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, MEDIA_SINGLE_GUTTER_SIZE } from '@atlaskit/editor-common/media-single';
@@ -32,7 +32,6 @@ import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
32
32
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
33
33
  import CaptionPlaceholder from '../ui/CaptionPlaceholder';
34
34
  import { CommentBadge } from '../ui/CommentBadge';
35
- import { MediaViewerContainer } from '../ui/MediaViewer/MediaViewerContainer';
36
35
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
37
36
  import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
38
37
  import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
@@ -335,7 +334,6 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
335
334
  lineLength = _this$props2.lineLength,
336
335
  dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
337
336
  editorViewMode = _this$props2.editorViewMode,
338
- mediaPluginState = _this$props2.mediaPluginState,
339
337
  editorDisabled = _this$props2.editorDisabled,
340
338
  annotationPluginState = _this$props2.annotationPluginState;
341
339
  var _ref4 = (mediaOptions === null || mediaOptions === void 0 || (_mediaOptions$getEdit = mediaOptions.getEditorFeatureFlags) === null || _mediaOptions$getEdit === void 0 ? void 0 : _mediaOptions$getEdit.call(mediaOptions)) || {},
@@ -456,13 +454,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
456
454
  ref: this.captionPlaceHolderRef,
457
455
  onClick: this.clickPlaceholder
458
456
  }));
459
- return jsx(MediaViewerContainer, {
460
- mediaPluginState: mediaPluginState,
461
- isEditorViewMode: editorViewMode,
462
- mediaNode: node,
463
- isSelected: isSelected,
464
- isInline: false
465
- }, canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
457
+ return jsx(Fragment, null, canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
466
458
  showLegacyNotification: widthType !== 'pixel'
467
459
  }), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
468
460
  lineLength: contentWidthForLegacyExperience,
@@ -258,6 +258,7 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
258
258
  }];
259
259
  },
260
260
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
261
+ var _api$editorViewMode;
261
262
  return _floatingToolbar(state, intl, {
262
263
  providerFactory: providerFactory,
263
264
  allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
@@ -271,7 +272,8 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
271
272
  altTextValidator: options && options.altTextValidator,
272
273
  fullWidthEnabled: options && options.fullWidthEnabled,
273
274
  allowMediaInlineImages: options && options.allowMediaInlineImages,
274
- getEditorFeatureFlags: options && options.getEditorFeatureFlags
275
+ getEditorFeatureFlags: options && options.getEditorFeatureFlags,
276
+ 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'
275
277
  }, api);
276
278
  }
277
279
  }
@@ -38,6 +38,7 @@ export var commentButton = function commentButton(intl, state, api) {
38
38
  onClick: onClickHandler,
39
39
  tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
40
40
  description: title
41
- })
41
+ }),
42
+ supportsViewMode: true
42
43
  };
43
44
  };
@@ -67,10 +67,14 @@ export var generateFilePreviewItem = function generateFilePreviewItem(mediaPlugi
67
67
  mediaPluginState: mediaPluginState,
68
68
  intl: intl
69
69
  });
70
- }
70
+ },
71
+ supportsViewMode: true
71
72
  };
72
73
  };
73
- var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector) {
74
+ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
75
+ if (isViewOnly) {
76
+ return [];
77
+ }
74
78
  var mediaGroup = state.schema.nodes.mediaGroup;
75
79
  var items = [{
76
80
  type: 'separator'
@@ -172,7 +176,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
172
176
  allowMediaInline = options.allowMediaInline,
173
177
  allowMediaInlineImages = options.allowMediaInlineImages,
174
178
  allowImagePreview = options.allowImagePreview,
175
- getEditorFeatureFlags = options.getEditorFeatureFlags;
179
+ getEditorFeatureFlags = options.getEditorFeatureFlags,
180
+ isViewOnly = options.isViewOnly;
176
181
  var editorFeatureFlags = getEditorFeatureFlags ? getEditorFeatureFlags() : undefined;
177
182
  var toolbarButtons = [];
178
183
  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 : {},
@@ -396,9 +401,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
396
401
  type: 'separator'
397
402
  });
398
403
  }
399
- if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia && allowCommentsOnMedia) {
404
+ 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
405
+ ) {
400
406
  toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
401
- type: 'separator'
407
+ type: 'separator',
408
+ supportsViewMode: true
402
409
  });
403
410
  }
404
411
  if (allowLinking && shouldShowMediaLinkToolbar(state)) {
@@ -436,11 +443,13 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
436
443
  mediaLinkingState: mediaLinkingState,
437
444
  onAddLink: editLink,
438
445
  onEditLink: editLink,
439
- onOpenLink: openLink
446
+ onOpenLink: openLink,
447
+ isViewOnly: isViewOnly
440
448
  });
441
449
  }
442
450
  return null;
443
- }
451
+ },
452
+ supportsViewMode: true
444
453
  });
445
454
  }
446
455
  // Preview Support
@@ -450,11 +459,28 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
450
459
  var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
451
460
  if (!isVideo(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
452
461
  toolbarButtons.push(generateFilePreviewItem(pluginState, intl), {
453
- type: 'separator'
462
+ type: 'separator',
463
+ supportsViewMode: true
454
464
  });
455
465
  }
456
466
  }
457
467
  }
468
+ if (isViewOnly) {
469
+ toolbarButtons.push({
470
+ id: 'editor.media.image.download',
471
+ type: 'button',
472
+ icon: DownloadIcon,
473
+ onClick: function onClick() {
474
+ downloadMedia(pluginState, isViewOnly);
475
+ return true;
476
+ },
477
+ title: intl.formatMessage(messages.download),
478
+ supportsViewMode: true
479
+ }, {
480
+ type: 'separator',
481
+ supportsViewMode: true
482
+ });
483
+ }
458
484
  if (allowAltTextOnImages) {
459
485
  var _pluginInjectionApi$a7;
460
486
  toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
@@ -473,7 +499,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
473
499
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
474
500
  title: intl.formatMessage(commonMessages.remove),
475
501
  onClick: remove,
476
- testId: 'media-toolbar-remove-button'
502
+ testId: 'media-toolbar-remove-button',
503
+ supportsViewMode: false
477
504
  };
478
505
  var items = [].concat(_toConsumableArray(toolbarButtons), [{
479
506
  type: 'copy-button',
@@ -481,10 +508,14 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
481
508
  state: state,
482
509
  formatMessage: intl.formatMessage,
483
510
  nodeType: mediaSingle
484
- }, {
485
- type: 'separator'
486
- }]
487
- }, removeButton]);
511
+ }],
512
+ supportsViewMode: true
513
+ }]);
514
+ items.push({
515
+ type: 'separator',
516
+ supportsViewMode: false
517
+ });
518
+ items.push(removeButton);
488
519
  return items;
489
520
  };
490
521
  var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
@@ -507,7 +538,8 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
507
538
  allowAltTextOnImages = options.allowAltTextOnImages,
508
539
  providerFactory = options.providerFactory,
509
540
  allowMediaInline = options.allowMediaInline,
510
- allowResizing = options.allowResizing;
541
+ allowResizing = options.allowResizing,
542
+ isViewOnly = options.isViewOnly;
511
543
  var mediaPluginState = stateKey.getState(state);
512
544
  var mediaLinkingState = getMediaLinkingState(state);
513
545
  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 : {},
@@ -553,7 +585,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
553
585
  var selector = mediaFilmstripItemDOMSelector(mediaOffset);
554
586
  return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
555
587
  };
556
- 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);
588
+ 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);
557
589
  } else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
558
590
  baseToolbar.getDomRef = function () {
559
591
  var _mediaPluginState$ele2;
@@ -22,7 +22,8 @@ export var LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
22
22
  onAddLink = _ref.onAddLink,
23
23
  onEditLink = _ref.onEditLink,
24
24
  onOpenLink = _ref.onOpenLink,
25
- isInlineNode = _ref.isInlineNode;
25
+ isInlineNode = _ref.isInlineNode,
26
+ isViewOnly = _ref.isViewOnly;
26
27
  var _useState = useState(true),
27
28
  _useState2 = _slicedToArray(_useState, 2),
28
29
  showLinkingControls = _useState2[0],
@@ -50,7 +51,7 @@ export var LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
50
51
  var isValidUrl = isSafeUrl(mediaLinkingState.link);
51
52
  var title = intl.formatMessage(linkToolbarMessages.editLink);
52
53
  var linkTitle = intl.formatMessage(isValidUrl ? linkMessages.openLink : linkToolbarMessages.unableToOpenLink);
53
- return jsx(Fragment, null, jsx("div", {
54
+ return jsx(Fragment, null, !isViewOnly && jsx("div", {
54
55
  css: wrapperStyles
55
56
  }, jsx(ToolbarButton, {
56
57
  onClick: onEditLink,
@@ -73,7 +74,7 @@ export var LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
73
74
  }), jsx(Separator, null));
74
75
  } else {
75
76
  var _title = intl.formatMessage(linkToolbarMessages.addLink);
76
- return jsx(Fragment, null, jsx(ToolbarButton, {
77
+ return !isViewOnly ? jsx(Fragment, null, jsx(ToolbarButton, {
77
78
  testId: "add-link-button",
78
79
  onClick: onAddLink,
79
80
  title: _title,
@@ -84,6 +85,6 @@ export var LinkToolbarAppearance = function LinkToolbarAppearance(_ref) {
84
85
  icon: jsx(LinkIcon, {
85
86
  label: _title
86
87
  })
87
- }), jsx(Separator, null));
88
+ }), jsx(Separator, null)) : null;
88
89
  }
89
90
  };
@@ -239,7 +239,7 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
239
239
  });
240
240
 
241
241
  //Image Preview
242
- if (options.allowImagePreview) {
242
+ if (!options.isViewOnly && options.allowImagePreview) {
243
243
  inlineImageItems.push(generateFilePreviewItem(mediaPluginState, intl), {
244
244
  type: 'separator'
245
245
  });
@@ -32,13 +32,13 @@ export var getSelectedNearestMediaContainerNodeAttrs = function getSelectedNeare
32
32
  return null;
33
33
  };
34
34
  export var downloadMedia = /*#__PURE__*/function () {
35
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaPluginState) {
35
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaPluginState, isViewMode) {
36
36
  var selectedNodeAttrs, id, _selectedNodeAttrs$co, collection, mediaClient, fileState, fileName;
37
37
  return _regeneratorRuntime.wrap(function _callee$(_context) {
38
38
  while (1) switch (_context.prev = _context.next) {
39
39
  case 0:
40
40
  _context.prev = 0;
41
- selectedNodeAttrs = getSelectedMediaContainerNodeAttrs(mediaPluginState);
41
+ selectedNodeAttrs = isViewMode ? getSelectedNearestMediaContainerNodeAttrs(mediaPluginState) : getSelectedMediaContainerNodeAttrs(mediaPluginState);
42
42
  if (!(selectedNodeAttrs && mediaPluginState.mediaClientConfig)) {
43
43
  _context.next = 10;
44
44
  break;
@@ -65,7 +65,7 @@ export var downloadMedia = /*#__PURE__*/function () {
65
65
  }
66
66
  }, _callee, null, [[0, 13]]);
67
67
  }));
68
- return function downloadMedia(_x) {
68
+ return function downloadMedia(_x, _x2) {
69
69
  return _ref.apply(this, arguments);
70
70
  };
71
71
  }();
@@ -12,5 +12,6 @@ export interface LinkingToolbarProps {
12
12
  onEditLink: React.MouseEventHandler;
13
13
  onOpenLink: React.MouseEventHandler;
14
14
  isInlineNode?: boolean;
15
+ isViewOnly?: boolean;
15
16
  }
16
- export declare const LinkToolbarAppearance: ({ editorState, mediaLinkingState, intl, onAddLink, onEditLink, onOpenLink, isInlineNode, }: LinkingToolbarProps) => jsx.JSX.Element | null;
17
+ export declare const LinkToolbarAppearance: ({ editorState, mediaLinkingState, intl, onAddLink, onEditLink, onOpenLink, isInlineNode, isViewOnly, }: LinkingToolbarProps) => jsx.JSX.Element | null;
@@ -1,7 +1,6 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
- import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
4
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
5
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
5
  import type { MediaNextEditorPluginType } from '../next-plugin-type';
7
6
  import type { MediaLinkingState } from '../pm-plugins/linking';
@@ -6,7 +6,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { MediaPluginState } from '../pm-plugins/types';
7
7
  export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
8
8
  export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
9
- export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
9
+ export declare const downloadMedia: (mediaPluginState: MediaPluginState, isViewMode?: boolean) => Promise<boolean>;
10
10
  export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
11
11
  export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
12
12
  export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(editorView: EditorView, pos: number, mediaWidth: number) => number>;
@@ -114,6 +114,7 @@ export type MediaFloatingToolbarOptions = {
114
114
  getEditorFeatureFlags?: GetEditorFeatureFlags;
115
115
  fullWidthEnabled?: boolean;
116
116
  allowCommentsOnMedia?: boolean;
117
+ isViewOnly?: boolean;
117
118
  };
118
119
  export type MediaDecorationSpec = {
119
120
  type: 'media';
@@ -12,5 +12,6 @@ export interface LinkingToolbarProps {
12
12
  onEditLink: React.MouseEventHandler;
13
13
  onOpenLink: React.MouseEventHandler;
14
14
  isInlineNode?: boolean;
15
+ isViewOnly?: boolean;
15
16
  }
16
- export declare const LinkToolbarAppearance: ({ editorState, mediaLinkingState, intl, onAddLink, onEditLink, onOpenLink, isInlineNode, }: LinkingToolbarProps) => jsx.JSX.Element | null;
17
+ export declare const LinkToolbarAppearance: ({ editorState, mediaLinkingState, intl, onAddLink, onEditLink, onOpenLink, isInlineNode, isViewOnly, }: LinkingToolbarProps) => jsx.JSX.Element | null;
@@ -1,7 +1,6 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
- import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
4
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
5
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
5
  import type { MediaNextEditorPluginType } from '../next-plugin-type';
7
6
  import type { MediaLinkingState } from '../pm-plugins/linking';
@@ -6,7 +6,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { MediaPluginState } from '../pm-plugins/types';
7
7
  export declare const getSelectedMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
8
8
  export declare const getSelectedNearestMediaContainerNodeAttrs: (mediaPluginState: MediaPluginState) => MediaBaseAttributes | null;
9
- export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Promise<boolean>;
9
+ export declare const downloadMedia: (mediaPluginState: MediaPluginState, isViewMode?: boolean) => Promise<boolean>;
10
10
  export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
11
11
  export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
12
12
  export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(editorView: EditorView, pos: number, mediaWidth: number) => number>;
@@ -114,6 +114,7 @@ export type MediaFloatingToolbarOptions = {
114
114
  getEditorFeatureFlags?: GetEditorFeatureFlags;
115
115
  fullWidthEnabled?: boolean;
116
116
  allowCommentsOnMedia?: boolean;
117
+ isViewOnly?: boolean;
117
118
  };
118
119
  export type MediaDecorationSpec = {
119
120
  type: 'media';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.16.6",
3
+ "version": "1.17.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/analytics-namespaced-context": "^6.9.0",
38
38
  "@atlaskit/analytics-next": "^9.3.0",
39
39
  "@atlaskit/button": "^17.14.0",
40
- "@atlaskit/editor-common": "^78.36.0",
40
+ "@atlaskit/editor-common": "^78.37.0",
41
41
  "@atlaskit/editor-palette": "1.6.0",
42
42
  "@atlaskit/editor-plugin-analytics": "^1.1.0",
43
43
  "@atlaskit/editor-plugin-annotation": "1.6.2",
@@ -154,6 +154,9 @@
154
154
  "platform.editor.media.preview-in-full-page": {
155
155
  "type": "boolean"
156
156
  },
157
+ "platform.editor.live-view.comments-in-media-toolbar-button": {
158
+ "type": "boolean"
159
+ },
157
160
  "platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
158
161
  "type": "boolean"
159
162
  }