@atlaskit/editor-plugin-media 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#77601](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77601) [`ee98d2aa7c8a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee98d2aa7c8a) - [ED-22199] Update media card wrapper so that it applies comments styles according to comment status
8
+
9
+ ## 1.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#76770](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76770) [`7eb1d4032d40`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7eb1d4032d40) - [ux] Select upladed image. In case there are mulitple image files being pasted or drag&dropped, select last image.
14
+
3
15
  ## 1.3.0
4
16
 
5
17
  ### Minor Changes
@@ -45,6 +45,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
45
45
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
46
46
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
47
47
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
48
+ var figureWrapperStyles = (0, _react2.css)({
49
+ margin: 0
50
+ });
48
51
  // eslint-disable-next-line @repo/internal/react/no-class-components
49
52
  var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
50
53
  (0, _inherits2.default)(MediaSingleNode, _Component);
@@ -421,7 +424,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
421
424
  var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
422
425
  var MediaChildren = (0, _react2.jsx)("figure", {
423
426
  ref: this.mediaSingleWrapperRef,
424
- css: [_styles.figureWrapper],
427
+ css: figureWrapperStyles,
425
428
  className: _styles.MediaSingleNodeSelector,
426
429
  onClick: this.onMediaSingleClicked
427
430
  }, (0, _react2.jsx)("div", {
@@ -4,36 +4,54 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.figureWrapper = exports.MediaSingleNodeSelector = exports.MediaInlineNodeSelector = exports.MediaCardWrapper = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
7
+ exports.MediaSingleNodeSelector = exports.MediaInlineNodeSelector = exports.MediaCardWrapper = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _react2 = require("@emotion/react");
11
11
  var _ui = require("@atlaskit/editor-common/ui");
12
- var _templateObject, _templateObject2, _templateObject3;
13
- /** @jsx jsx */
12
+ var _colors = require("@atlaskit/theme/colors");
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
14
15
  var MediaInlineNodeSelector = exports.MediaInlineNodeSelector = 'media-inline-node';
15
16
  var MediaSingleNodeSelector = exports.MediaSingleNodeSelector = 'media-single-node';
16
- var figureWrapper = exports.figureWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: 0;\n"])));
17
- var absoluteDiv = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 100%;\n height: 100%;\n"])));
18
- var forcedDimensions = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n position: relative;\n"])));
17
+ var absoluteDivStyles = (0, _react2.css)({
18
+ position: 'absolute',
19
+ width: '100%',
20
+ height: '100%'
21
+ });
22
+ var forcedDimensionsStyles = (0, _react2.css)({
23
+ width: '100%',
24
+ position: 'relative'
25
+ });
26
+ var boxShadowColorByStatus = {
27
+ draft: "var(--ds-background-accent-yellow-subtle, ".concat(_colors.Y300, ")"),
28
+ focus: "var(--ds-background-accent-yellow-subtle, ".concat(_colors.Y300, ")"),
29
+ blur: "var(--ds-background-accent-yellow-subtler, ".concat(_colors.Y200, ")")
30
+ };
31
+ var commentStatusStyleMap = function commentStatusStyleMap(status) {
32
+ return "3px 3px 0px 0px ".concat(boxShadowColorByStatus[status]);
33
+ };
19
34
  var MediaCardWrapper = exports.MediaCardWrapper = function MediaCardWrapper(_ref) {
20
35
  var dimensions = _ref.dimensions,
21
36
  children = _ref.children,
22
37
  selected = _ref.selected,
23
38
  _ref$borderWidth = _ref.borderWidth,
24
39
  borderWidth = _ref$borderWidth === void 0 ? 0 : _ref$borderWidth,
25
- onContextMenu = _ref.onContextMenu;
40
+ onContextMenu = _ref.onContextMenu,
41
+ commentStatus = _ref.commentStatus;
26
42
  var calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
27
43
  return (0, _react2.jsx)("div", {
28
44
  "data-testid": "media-card-wrapper",
29
- style: {
45
+ style: _objectSpread({
30
46
  borderColor: "var(--custom-palette-color)",
31
47
  borderWidth: "".concat(calculatedBorderWidth, "px"),
32
48
  borderStyle: 'solid',
33
49
  borderRadius: "".concat(calculatedBorderWidth * 2, "px")
34
- }
50
+ }, commentStatus && {
51
+ boxShadow: "".concat(commentStatusStyleMap(commentStatus))
52
+ })
35
53
  }, (0, _react2.jsx)("div", {
36
- css: forcedDimensions,
54
+ css: forcedDimensionsStyles,
37
55
  style: {
38
56
  paddingBottom: "".concat(dimensions.height / dimensions.width * 100, "%")
39
57
  },
@@ -41,6 +59,6 @@ var MediaCardWrapper = exports.MediaCardWrapper = function MediaCardWrapper(_ref
41
59
  }, borderWidth > 0 && (0, _react2.jsx)(_ui.MediaBorderGapFiller, {
42
60
  borderColor: "var(--custom-palette-color)"
43
61
  }), (0, _react2.jsx)("div", {
44
- css: absoluteDiv
62
+ css: absoluteDivStyles
45
63
  }, children)));
46
64
  };
@@ -32,6 +32,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
32
32
  var _view2 = require("@atlaskit/editor-prosemirror/view");
33
33
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
34
34
  var _mediaCommon = require("@atlaskit/media-common");
35
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
35
36
  var _helpers = _interopRequireWildcard(require("../commands/helpers"));
36
37
  var helpers = _helpers;
37
38
  var _pickerFacade = _interopRequireDefault(require("../picker-facade"));
@@ -86,6 +87,8 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
86
87
  (0, _defineProperty2.default)(this, "isResizing", false);
87
88
  (0, _defineProperty2.default)(this, "resizingWidth", 0);
88
89
  (0, _defineProperty2.default)(this, "allowInlineImages", false);
90
+ // this is only a temporary variable, which gets cleared after the last inserted node has been selected
91
+ (0, _defineProperty2.default)(this, "lastAddedMediaSingleFileIds", []);
89
92
  (0, _defineProperty2.default)(this, "destroyed", false);
90
93
  (0, _defineProperty2.default)(this, "removeOnCloseListener", function () {});
91
94
  (0, _defineProperty2.default)(this, "onPopupToggleCallback", function () {});
@@ -198,6 +201,13 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
198
201
  }
199
202
  return type === mediaSingle;
200
203
  });
204
+ // callback to flag that a node has been inserted
205
+ (0, _defineProperty2.default)(this, "onNodeInserted", function (id, selectionPosition) {
206
+ _this.lastAddedMediaSingleFileIds.unshift({
207
+ id: id,
208
+ selectionPosition: selectionPosition
209
+ });
210
+ });
201
211
  /**
202
212
  * we insert a new file by inserting a initial state for that file.
203
213
  *
@@ -228,7 +238,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
228
238
  case 'block':
229
239
  // read width state right before inserting to get up-to-date and define values
230
240
  var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
231
- (0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI);
241
+ (0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted);
232
242
  break;
233
243
  case 'group':
234
244
  (0, _mediaFiles.insertMediaGroupNode)(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
@@ -263,6 +273,9 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
263
273
  if (!view.hasFocus()) {
264
274
  view.focus();
265
275
  }
276
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.autoselect-inserted-image_oumto')) {
277
+ _this.selectLastAddedMediaNode();
278
+ }
266
279
  });
267
280
  (0, _defineProperty2.default)(this, "addPendingTask", function (task) {
268
281
  _this.taskManager.addPendingTask(task);
@@ -546,6 +559,36 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
546
559
  var _this$pluginInjection3;
547
560
  return (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.contextIdentifier) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.sharedState.currentState()) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.contextIdentifierProvider;
548
561
  }
562
+ }, {
563
+ key: "selectLastAddedMediaNode",
564
+ value: function selectLastAddedMediaNode() {
565
+ var _this2 = this;
566
+ // if lastAddedMediaSingleFileIds is empty exit because there are no added media single nodes to be selected
567
+ if (this.lastAddedMediaSingleFileIds.length !== 0) {
568
+ this.waitForPendingTasks().then(function () {
569
+ var lastTrackedAddedNode = _this2.lastAddedMediaSingleFileIds[0];
570
+ // execute selection only if selection did not change after the node has been inserted
571
+ if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === _this2.view.state.selection.from) {
572
+ var lastAddedNode = _this2.mediaNodes.find(function (node) {
573
+ return node.node.attrs.id === lastTrackedAddedNode.id;
574
+ });
575
+ var lastAddedNodePos = lastAddedNode === null || lastAddedNode === void 0 ? void 0 : lastAddedNode.getPos();
576
+ if (lastAddedNodePos) {
577
+ var _this2$view = _this2.view,
578
+ dispatch = _this2$view.dispatch,
579
+ state = _this2$view.state;
580
+ var tr = state.tr;
581
+ tr.setSelection(_state2.NodeSelection.create(tr.doc, lastAddedNodePos));
582
+ if (dispatch) {
583
+ dispatch(tr);
584
+ }
585
+ }
586
+ }
587
+ // reset temp constant after uploads finished
588
+ _this2.lastAddedMediaSingleFileIds = [];
589
+ });
590
+ }
591
+ }
549
592
  }, {
550
593
  key: "setView",
551
594
  value: function setView(view) {
@@ -567,7 +610,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
567
610
  key: "initPickers",
568
611
  value: function () {
569
612
  var _initPickers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(uploadParams, Picker) {
570
- var _this2 = this;
613
+ var _this3 = this;
571
614
  var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker;
572
615
  return _regenerator.default.wrap(function _callee2$(_context2) {
573
616
  while (1) switch (_context2.prev = _context2.next) {
@@ -601,7 +644,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
601
644
  _context2.t0.push.call(_context2.t0, _context2.t1);
602
645
  case 13:
603
646
  pickers.forEach(function (picker) {
604
- picker.onNewMedia(_this2.insertFile);
647
+ picker.onNewMedia(_this3.insertFile);
605
648
  });
606
649
  case 14:
607
650
  // set new upload params for the pickers
@@ -627,13 +670,13 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
627
670
  }, {
628
671
  key: "updateAndDispatch",
629
672
  value: function updateAndDispatch(props) {
630
- var _this3 = this;
673
+ var _this4 = this;
631
674
  // update plugin state
632
675
  Object.keys(props).forEach(function (_key) {
633
676
  var key = _key;
634
677
  var value = props[key];
635
678
  if (value !== undefined) {
636
- _this3[key] = value;
679
+ _this4[key] = value;
637
680
  }
638
681
  });
639
682
  if (this.dispatch) {
@@ -113,7 +113,7 @@ var getFileExtension = function getFileExtension(fileName) {
113
113
  }
114
114
  return undefined;
115
115
  };
116
- var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI) {
116
+ var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted) {
117
117
  var _state$selection$$fro;
118
118
  if (collection === undefined) {
119
119
  return false;
@@ -155,6 +155,9 @@ var insertMediaSingleNode = exports.insertMediaSingleNode = function insertMedia
155
155
  }
156
156
  dispatch(tr);
157
157
  }
158
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.autoselect-inserted-image_oumto') && onNodeInserted) {
159
+ onNodeInserted(mediaState.id, view.state.selection.to);
160
+ }
158
161
  return true;
159
162
  };
160
163
  var changeFromMediaInlineToMediaSingleNode = exports.changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI) {
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  /** @jsx jsx */
4
4
 
5
5
  import React, { Component } from 'react';
6
- import { jsx } from '@emotion/react';
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';
9
9
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
@@ -23,7 +23,10 @@ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaS
23
23
  import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
24
24
  import { hasPrivateAttrsChanged } from './helpers';
25
25
  import { MediaNodeUpdater } from './mediaNodeUpdater';
26
- import { figureWrapper, MediaSingleNodeSelector } from './styles';
26
+ import { MediaSingleNodeSelector } from './styles';
27
+ const figureWrapperStyles = css({
28
+ margin: 0
29
+ });
27
30
  // eslint-disable-next-line @repo/internal/react/no-class-components
28
31
  export default class MediaSingleNode extends Component {
29
32
  constructor(...args) {
@@ -334,7 +337,7 @@ export default class MediaSingleNode extends Component {
334
337
  const shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
335
338
  const MediaChildren = jsx("figure", {
336
339
  ref: this.mediaSingleWrapperRef,
337
- css: [figureWrapper],
340
+ css: figureWrapperStyles,
338
341
  className: MediaSingleNodeSelector,
339
342
  onClick: this.onMediaSingleClicked
340
343
  }, jsx("div", {
@@ -2,26 +2,31 @@
2
2
  import React from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
5
+ import { Y200, Y300 } from '@atlaskit/theme/colors';
5
6
  export const MediaInlineNodeSelector = 'media-inline-node';
6
7
  export const MediaSingleNodeSelector = 'media-single-node';
7
- export const figureWrapper = css`
8
- margin: 0;
9
- `;
10
- const absoluteDiv = css`
11
- position: absolute;
12
- width: 100%;
13
- height: 100%;
14
- `;
15
- const forcedDimensions = css`
16
- width: 100%;
17
- position: relative;
18
- `;
8
+ const absoluteDivStyles = css({
9
+ position: 'absolute',
10
+ width: '100%',
11
+ height: '100%'
12
+ });
13
+ const forcedDimensionsStyles = css({
14
+ width: '100%',
15
+ position: 'relative'
16
+ });
17
+ const boxShadowColorByStatus = {
18
+ draft: `var(--ds-background-accent-yellow-subtle, ${Y300})`,
19
+ focus: `var(--ds-background-accent-yellow-subtle, ${Y300})`,
20
+ blur: `var(--ds-background-accent-yellow-subtler, ${Y200})`
21
+ };
22
+ const commentStatusStyleMap = status => `3px 3px 0px 0px ${boxShadowColorByStatus[status]}`;
19
23
  export const MediaCardWrapper = ({
20
24
  dimensions,
21
25
  children,
22
26
  selected,
23
27
  borderWidth = 0,
24
- onContextMenu
28
+ onContextMenu,
29
+ commentStatus
25
30
  }) => {
26
31
  const calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
27
32
  return jsx("div", {
@@ -30,10 +35,13 @@ export const MediaCardWrapper = ({
30
35
  borderColor: `var(--custom-palette-color)`,
31
36
  borderWidth: `${calculatedBorderWidth}px`,
32
37
  borderStyle: 'solid',
33
- borderRadius: `${calculatedBorderWidth * 2}px`
38
+ borderRadius: `${calculatedBorderWidth * 2}px`,
39
+ ...(commentStatus && {
40
+ boxShadow: `${commentStatusStyleMap(commentStatus)}`
41
+ })
34
42
  }
35
43
  }, jsx("div", {
36
- css: forcedDimensions,
44
+ css: forcedDimensionsStyles,
37
45
  style: {
38
46
  paddingBottom: `${dimensions.height / dimensions.width * 100}%`
39
47
  },
@@ -41,6 +49,6 @@ export const MediaCardWrapper = ({
41
49
  }, borderWidth > 0 && jsx(MediaBorderGapFiller, {
42
50
  borderColor: `var(--custom-palette-color)`
43
51
  }), jsx("div", {
44
- css: absoluteDiv
52
+ css: absoluteDivStyles
45
53
  }, children)));
46
54
  };
@@ -14,6 +14,7 @@ import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSe
14
14
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
15
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
16
16
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
17
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
18
  import * as helpers from '../commands/helpers';
18
19
  import { updateMediaNodeAttrs } from '../commands/helpers';
19
20
  import PickerFacade from '../picker-facade';
@@ -59,6 +60,8 @@ export class MediaPluginStateImplementation {
59
60
  _defineProperty(this, "isResizing", false);
60
61
  _defineProperty(this, "resizingWidth", 0);
61
62
  _defineProperty(this, "allowInlineImages", false);
63
+ // this is only a temporary variable, which gets cleared after the last inserted node has been selected
64
+ _defineProperty(this, "lastAddedMediaSingleFileIds", []);
62
65
  _defineProperty(this, "destroyed", false);
63
66
  _defineProperty(this, "removeOnCloseListener", () => {});
64
67
  _defineProperty(this, "onPopupToggleCallback", () => {});
@@ -143,6 +146,13 @@ export class MediaPluginStateImplementation {
143
146
  }
144
147
  return type === mediaSingle;
145
148
  });
149
+ // callback to flag that a node has been inserted
150
+ _defineProperty(this, "onNodeInserted", (id, selectionPosition) => {
151
+ this.lastAddedMediaSingleFileIds.unshift({
152
+ id,
153
+ selectionPosition
154
+ });
155
+ });
146
156
  /**
147
157
  * we insert a new file by inserting a initial state for that file.
148
158
  *
@@ -176,7 +186,7 @@ export class MediaPluginStateImplementation {
176
186
  case 'block':
177
187
  // read width state right before inserting to get up-to-date and define values
178
188
  const widthPluginState = (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 ? void 0 : (_this$pluginInjection4 = _this$pluginInjection3.width) === null || _this$pluginInjection4 === void 0 ? void 0 : _this$pluginInjection4.sharedState.currentState();
179
- insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI);
189
+ insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, this.onNodeInserted);
180
190
  break;
181
191
  case 'group':
182
192
  insertMediaGroupNode(editorAnalyticsAPI)(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
@@ -211,6 +221,9 @@ export class MediaPluginStateImplementation {
211
221
  if (!view.hasFocus()) {
212
222
  view.focus();
213
223
  }
224
+ if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto')) {
225
+ this.selectLastAddedMediaNode();
226
+ }
214
227
  });
215
228
  _defineProperty(this, "addPendingTask", task => {
216
229
  this.taskManager.addPendingTask(task);
@@ -483,6 +496,34 @@ export class MediaPluginStateImplementation {
483
496
  var _this$pluginInjection5, _this$pluginInjection6, _this$pluginInjection7;
484
497
  return (_this$pluginInjection5 = this.pluginInjectionApi) === null || _this$pluginInjection5 === void 0 ? void 0 : (_this$pluginInjection6 = _this$pluginInjection5.contextIdentifier) === null || _this$pluginInjection6 === void 0 ? void 0 : (_this$pluginInjection7 = _this$pluginInjection6.sharedState.currentState()) === null || _this$pluginInjection7 === void 0 ? void 0 : _this$pluginInjection7.contextIdentifierProvider;
485
498
  }
499
+ selectLastAddedMediaNode() {
500
+ // if lastAddedMediaSingleFileIds is empty exit because there are no added media single nodes to be selected
501
+ if (this.lastAddedMediaSingleFileIds.length !== 0) {
502
+ this.waitForPendingTasks().then(() => {
503
+ const lastTrackedAddedNode = this.lastAddedMediaSingleFileIds[0];
504
+ // execute selection only if selection did not change after the node has been inserted
505
+ if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === this.view.state.selection.from) {
506
+ const lastAddedNode = this.mediaNodes.find(node => {
507
+ return node.node.attrs.id === lastTrackedAddedNode.id;
508
+ });
509
+ const lastAddedNodePos = lastAddedNode === null || lastAddedNode === void 0 ? void 0 : lastAddedNode.getPos();
510
+ if (lastAddedNodePos) {
511
+ const {
512
+ dispatch,
513
+ state
514
+ } = this.view;
515
+ const tr = state.tr;
516
+ tr.setSelection(NodeSelection.create(tr.doc, lastAddedNodePos));
517
+ if (dispatch) {
518
+ dispatch(tr);
519
+ }
520
+ }
521
+ }
522
+ // reset temp constant after uploads finished
523
+ this.lastAddedMediaSingleFileIds = [];
524
+ });
525
+ }
526
+ }
486
527
  setView(view) {
487
528
  this.view = view;
488
529
  }
@@ -102,7 +102,7 @@ const getFileExtension = fileName => {
102
102
  }
103
103
  return undefined;
104
104
  };
105
- export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI) => {
105
+ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted) => {
106
106
  var _state$selection$$fro;
107
107
  if (collection === undefined) {
108
108
  return false;
@@ -146,6 +146,9 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
146
146
  }
147
147
  dispatch(tr);
148
148
  }
149
+ if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto') && onNodeInserted) {
150
+ onNodeInserted(mediaState.id, view.state.selection.to);
151
+ }
149
152
  return true;
150
153
  };
151
154
  export const changeFromMediaInlineToMediaSingleNode = (view, fromNode, widthPluginState, editorAnalyticsAPI) => {
@@ -16,7 +16,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
16
16
  /** @jsx jsx */
17
17
 
18
18
  import React, { Component } from 'react';
19
- import { jsx } from '@emotion/react';
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';
22
22
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
@@ -36,7 +36,10 @@ import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaS
36
36
  import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
37
37
  import { hasPrivateAttrsChanged } from './helpers';
38
38
  import { MediaNodeUpdater } from './mediaNodeUpdater';
39
- import { figureWrapper, MediaSingleNodeSelector } from './styles';
39
+ import { MediaSingleNodeSelector } from './styles';
40
+ var figureWrapperStyles = css({
41
+ margin: 0
42
+ });
40
43
  // eslint-disable-next-line @repo/internal/react/no-class-components
41
44
  var MediaSingleNode = /*#__PURE__*/function (_Component) {
42
45
  _inherits(MediaSingleNode, _Component);
@@ -413,7 +416,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
413
416
  var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
414
417
  var MediaChildren = jsx("figure", {
415
418
  ref: this.mediaSingleWrapperRef,
416
- css: [figureWrapper],
419
+ css: figureWrapperStyles,
417
420
  className: MediaSingleNodeSelector,
418
421
  onClick: this.onMediaSingleClicked
419
422
  }, jsx("div", {
@@ -1,32 +1,51 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3;
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
4
  /** @jsx jsx */
4
5
  import React from 'react';
5
6
  import { css, jsx } from '@emotion/react';
6
7
  import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
8
+ import { Y200, Y300 } from '@atlaskit/theme/colors';
7
9
  export var MediaInlineNodeSelector = 'media-inline-node';
8
10
  export var MediaSingleNodeSelector = 'media-single-node';
9
- export var figureWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0;\n"])));
10
- var absoluteDiv = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n width: 100%;\n height: 100%;\n"])));
11
- var forcedDimensions = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n position: relative;\n"])));
11
+ var absoluteDivStyles = css({
12
+ position: 'absolute',
13
+ width: '100%',
14
+ height: '100%'
15
+ });
16
+ var forcedDimensionsStyles = css({
17
+ width: '100%',
18
+ position: 'relative'
19
+ });
20
+ var boxShadowColorByStatus = {
21
+ draft: "var(--ds-background-accent-yellow-subtle, ".concat(Y300, ")"),
22
+ focus: "var(--ds-background-accent-yellow-subtle, ".concat(Y300, ")"),
23
+ blur: "var(--ds-background-accent-yellow-subtler, ".concat(Y200, ")")
24
+ };
25
+ var commentStatusStyleMap = function commentStatusStyleMap(status) {
26
+ return "3px 3px 0px 0px ".concat(boxShadowColorByStatus[status]);
27
+ };
12
28
  export var MediaCardWrapper = function MediaCardWrapper(_ref) {
13
29
  var dimensions = _ref.dimensions,
14
30
  children = _ref.children,
15
31
  selected = _ref.selected,
16
32
  _ref$borderWidth = _ref.borderWidth,
17
33
  borderWidth = _ref$borderWidth === void 0 ? 0 : _ref$borderWidth,
18
- onContextMenu = _ref.onContextMenu;
34
+ onContextMenu = _ref.onContextMenu,
35
+ commentStatus = _ref.commentStatus;
19
36
  var calculatedBorderWidth = selected && borderWidth > 0 ? borderWidth + 1 : borderWidth;
20
37
  return jsx("div", {
21
38
  "data-testid": "media-card-wrapper",
22
- style: {
39
+ style: _objectSpread({
23
40
  borderColor: "var(--custom-palette-color)",
24
41
  borderWidth: "".concat(calculatedBorderWidth, "px"),
25
42
  borderStyle: 'solid',
26
43
  borderRadius: "".concat(calculatedBorderWidth * 2, "px")
27
- }
44
+ }, commentStatus && {
45
+ boxShadow: "".concat(commentStatusStyleMap(commentStatus))
46
+ })
28
47
  }, jsx("div", {
29
- css: forcedDimensions,
48
+ css: forcedDimensionsStyles,
30
49
  style: {
31
50
  paddingBottom: "".concat(dimensions.height / dimensions.width * 100, "%")
32
51
  },
@@ -34,6 +53,6 @@ export var MediaCardWrapper = function MediaCardWrapper(_ref) {
34
53
  }, borderWidth > 0 && jsx(MediaBorderGapFiller, {
35
54
  borderColor: "var(--custom-palette-color)"
36
55
  }), jsx("div", {
37
- css: absoluteDiv
56
+ css: absoluteDivStyles
38
57
  }, children)));
39
58
  };
@@ -23,6 +23,7 @@ import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSe
23
23
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
24
24
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
25
25
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
26
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
26
27
  import * as helpers from '../commands/helpers';
27
28
  import { updateMediaNodeAttrs } from '../commands/helpers';
28
29
  import PickerFacade from '../picker-facade';
@@ -71,6 +72,8 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
71
72
  _defineProperty(this, "isResizing", false);
72
73
  _defineProperty(this, "resizingWidth", 0);
73
74
  _defineProperty(this, "allowInlineImages", false);
75
+ // this is only a temporary variable, which gets cleared after the last inserted node has been selected
76
+ _defineProperty(this, "lastAddedMediaSingleFileIds", []);
74
77
  _defineProperty(this, "destroyed", false);
75
78
  _defineProperty(this, "removeOnCloseListener", function () {});
76
79
  _defineProperty(this, "onPopupToggleCallback", function () {});
@@ -183,6 +186,13 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
183
186
  }
184
187
  return type === mediaSingle;
185
188
  });
189
+ // callback to flag that a node has been inserted
190
+ _defineProperty(this, "onNodeInserted", function (id, selectionPosition) {
191
+ _this.lastAddedMediaSingleFileIds.unshift({
192
+ id: id,
193
+ selectionPosition: selectionPosition
194
+ });
195
+ });
186
196
  /**
187
197
  * we insert a new file by inserting a initial state for that file.
188
198
  *
@@ -213,7 +223,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
213
223
  case 'block':
214
224
  // read width state right before inserting to get up-to-date and define values
215
225
  var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
216
- insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI);
226
+ insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted);
217
227
  break;
218
228
  case 'group':
219
229
  insertMediaGroupNode(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
@@ -248,6 +258,9 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
248
258
  if (!view.hasFocus()) {
249
259
  view.focus();
250
260
  }
261
+ if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto')) {
262
+ _this.selectLastAddedMediaNode();
263
+ }
251
264
  });
252
265
  _defineProperty(this, "addPendingTask", function (task) {
253
266
  _this.taskManager.addPendingTask(task);
@@ -531,6 +544,36 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
531
544
  var _this$pluginInjection3;
532
545
  return (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.contextIdentifier) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.sharedState.currentState()) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.contextIdentifierProvider;
533
546
  }
547
+ }, {
548
+ key: "selectLastAddedMediaNode",
549
+ value: function selectLastAddedMediaNode() {
550
+ var _this2 = this;
551
+ // if lastAddedMediaSingleFileIds is empty exit because there are no added media single nodes to be selected
552
+ if (this.lastAddedMediaSingleFileIds.length !== 0) {
553
+ this.waitForPendingTasks().then(function () {
554
+ var lastTrackedAddedNode = _this2.lastAddedMediaSingleFileIds[0];
555
+ // execute selection only if selection did not change after the node has been inserted
556
+ if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === _this2.view.state.selection.from) {
557
+ var lastAddedNode = _this2.mediaNodes.find(function (node) {
558
+ return node.node.attrs.id === lastTrackedAddedNode.id;
559
+ });
560
+ var lastAddedNodePos = lastAddedNode === null || lastAddedNode === void 0 ? void 0 : lastAddedNode.getPos();
561
+ if (lastAddedNodePos) {
562
+ var _this2$view = _this2.view,
563
+ dispatch = _this2$view.dispatch,
564
+ state = _this2$view.state;
565
+ var tr = state.tr;
566
+ tr.setSelection(NodeSelection.create(tr.doc, lastAddedNodePos));
567
+ if (dispatch) {
568
+ dispatch(tr);
569
+ }
570
+ }
571
+ }
572
+ // reset temp constant after uploads finished
573
+ _this2.lastAddedMediaSingleFileIds = [];
574
+ });
575
+ }
576
+ }
534
577
  }, {
535
578
  key: "setView",
536
579
  value: function setView(view) {
@@ -552,7 +595,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
552
595
  key: "initPickers",
553
596
  value: function () {
554
597
  var _initPickers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(uploadParams, Picker) {
555
- var _this2 = this;
598
+ var _this3 = this;
556
599
  var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker;
557
600
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
558
601
  while (1) switch (_context2.prev = _context2.next) {
@@ -586,7 +629,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
586
629
  _context2.t0.push.call(_context2.t0, _context2.t1);
587
630
  case 13:
588
631
  pickers.forEach(function (picker) {
589
- picker.onNewMedia(_this2.insertFile);
632
+ picker.onNewMedia(_this3.insertFile);
590
633
  });
591
634
  case 14:
592
635
  // set new upload params for the pickers
@@ -612,13 +655,13 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
612
655
  }, {
613
656
  key: "updateAndDispatch",
614
657
  value: function updateAndDispatch(props) {
615
- var _this3 = this;
658
+ var _this4 = this;
616
659
  // update plugin state
617
660
  Object.keys(props).forEach(function (_key) {
618
661
  var key = _key;
619
662
  var value = props[key];
620
663
  if (value !== undefined) {
621
- _this3[key] = value;
664
+ _this4[key] = value;
622
665
  }
623
666
  });
624
667
  if (this.dispatch) {
@@ -104,7 +104,7 @@ var getFileExtension = function getFileExtension(fileName) {
104
104
  }
105
105
  return undefined;
106
106
  };
107
- export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI) {
107
+ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted) {
108
108
  var _state$selection$$fro;
109
109
  if (collection === undefined) {
110
110
  return false;
@@ -146,6 +146,9 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
146
146
  }
147
147
  dispatch(tr);
148
148
  }
149
+ if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto') && onNodeInserted) {
150
+ onNodeInserted(mediaState.id, view.state.selection.to);
151
+ }
149
152
  return true;
150
153
  };
151
154
  export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI) {
@@ -2,15 +2,16 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { NumericalCardDimensions } from '@atlaskit/media-card';
5
+ import type { CommentStatus } from '../types';
5
6
  export declare const MediaInlineNodeSelector = "media-inline-node";
6
7
  export declare const MediaSingleNodeSelector = "media-single-node";
7
- export declare const figureWrapper: import("@emotion/react").SerializedStyles;
8
8
  type MediaCardWrapperProps = {
9
9
  dimensions: NumericalCardDimensions;
10
10
  children: React.ReactNode;
11
11
  selected?: boolean;
12
12
  borderWidth?: number;
13
13
  onContextMenu?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
14
+ commentStatus?: CommentStatus;
14
15
  };
15
- export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, }: MediaCardWrapperProps) => jsx.JSX.Element;
16
+ export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, commentStatus, }: MediaCardWrapperProps) => jsx.JSX.Element;
16
17
  export {};
@@ -37,6 +37,10 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
37
37
  resizingWidth: number;
38
38
  currentMaxWidth?: number;
39
39
  allowInlineImages: boolean;
40
+ lastAddedMediaSingleFileIds: {
41
+ id: string;
42
+ selectionPosition: number;
43
+ }[];
40
44
  private view;
41
45
  private destroyed;
42
46
  private errorReporter;
@@ -64,12 +68,14 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
64
68
  private isMediaSchemaNode;
65
69
  private getDomElement;
66
70
  get contextIdentifierProvider(): import("@atlaskit/editor-common/provider-factory").ContextIdentifierProvider | undefined;
71
+ onNodeInserted: (id: string, selectionPosition: number) => void;
67
72
  /**
68
73
  * we insert a new file by inserting a initial state for that file.
69
74
  *
70
75
  * called when we insert a new file via the picker (connected via pickerfacade)
71
76
  */
72
77
  insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string) => void;
78
+ private selectLastAddedMediaNode;
73
79
  addPendingTask: (task: Promise<any>) => void;
74
80
  splitMediaGroup: () => boolean;
75
81
  onPopupPickerClose: () => void;
@@ -35,6 +35,10 @@ export interface MediaPluginState {
35
35
  resizingWidth: number;
36
36
  currentMaxWidth?: number;
37
37
  allowInlineImages?: boolean;
38
+ lastAddedMediaSingleFileIds: {
39
+ id: string;
40
+ selectionPosition: number;
41
+ }[];
38
42
  dispatch?: Dispatch;
39
43
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
40
44
  getMediaOptions: () => MediaPluginOptions;
@@ -12,6 +12,7 @@ interface PlaceholderTextOptions {
12
12
  allowInserting?: boolean;
13
13
  }
14
14
  export type MediaStateStatus = 'unknown' | 'ready' | 'cancelled' | 'preview' | 'error' | 'mobile-upload-end';
15
+ export type CommentStatus = 'draft' | 'focus' | 'blur';
15
16
  export type MediaSingleWithType = 'pixel' | 'percentage';
16
17
  export interface MediaOptions {
17
18
  provider?: Providers['mediaProvider'];
@@ -14,7 +14,7 @@ export interface MediaSingleState extends MediaState {
14
14
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
15
15
  export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia) => boolean;
16
16
  export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => boolean;
17
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
17
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined) => boolean;
18
18
  export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
19
19
  export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
20
20
  export declare function isCaptionNode(editorView: EditorView): boolean;
@@ -2,15 +2,16 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { NumericalCardDimensions } from '@atlaskit/media-card';
5
+ import type { CommentStatus } from '../types';
5
6
  export declare const MediaInlineNodeSelector = "media-inline-node";
6
7
  export declare const MediaSingleNodeSelector = "media-single-node";
7
- export declare const figureWrapper: import("@emotion/react").SerializedStyles;
8
8
  type MediaCardWrapperProps = {
9
9
  dimensions: NumericalCardDimensions;
10
10
  children: React.ReactNode;
11
11
  selected?: boolean;
12
12
  borderWidth?: number;
13
13
  onContextMenu?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
14
+ commentStatus?: CommentStatus;
14
15
  };
15
- export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, }: MediaCardWrapperProps) => jsx.JSX.Element;
16
+ export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, commentStatus, }: MediaCardWrapperProps) => jsx.JSX.Element;
16
17
  export {};
@@ -37,6 +37,10 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
37
37
  resizingWidth: number;
38
38
  currentMaxWidth?: number;
39
39
  allowInlineImages: boolean;
40
+ lastAddedMediaSingleFileIds: {
41
+ id: string;
42
+ selectionPosition: number;
43
+ }[];
40
44
  private view;
41
45
  private destroyed;
42
46
  private errorReporter;
@@ -64,12 +68,14 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
64
68
  private isMediaSchemaNode;
65
69
  private getDomElement;
66
70
  get contextIdentifierProvider(): import("@atlaskit/editor-common/provider-factory").ContextIdentifierProvider | undefined;
71
+ onNodeInserted: (id: string, selectionPosition: number) => void;
67
72
  /**
68
73
  * we insert a new file by inserting a initial state for that file.
69
74
  *
70
75
  * called when we insert a new file via the picker (connected via pickerfacade)
71
76
  */
72
77
  insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string) => void;
78
+ private selectLastAddedMediaNode;
73
79
  addPendingTask: (task: Promise<any>) => void;
74
80
  splitMediaGroup: () => boolean;
75
81
  onPopupPickerClose: () => void;
@@ -35,6 +35,10 @@ export interface MediaPluginState {
35
35
  resizingWidth: number;
36
36
  currentMaxWidth?: number;
37
37
  allowInlineImages?: boolean;
38
+ lastAddedMediaSingleFileIds: {
39
+ id: string;
40
+ selectionPosition: number;
41
+ }[];
38
42
  dispatch?: Dispatch;
39
43
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
40
44
  getMediaOptions: () => MediaPluginOptions;
@@ -12,6 +12,7 @@ interface PlaceholderTextOptions {
12
12
  allowInserting?: boolean;
13
13
  }
14
14
  export type MediaStateStatus = 'unknown' | 'ready' | 'cancelled' | 'preview' | 'error' | 'mobile-upload-end';
15
+ export type CommentStatus = 'draft' | 'focus' | 'blur';
15
16
  export type MediaSingleWithType = 'pixel' | 'percentage';
16
17
  export interface MediaOptions {
17
18
  provider?: Providers['mediaProvider'];
@@ -14,7 +14,7 @@ export interface MediaSingleState extends MediaState {
14
14
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
15
15
  export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia) => boolean;
16
16
  export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => boolean;
17
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
17
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined) => boolean;
18
18
  export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
19
19
  export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
20
20
  export declare function isCaptionNode(editorView: EditorView): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
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.2.0",
39
39
  "@atlaskit/button": "^17.6.0",
40
- "@atlaskit/editor-common": "^78.8.0",
40
+ "@atlaskit/editor-common": "^78.9.0",
41
41
  "@atlaskit/editor-palette": "1.5.2",
42
42
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
43
43
  "@atlaskit/editor-plugin-decorations": "^1.0.0",
@@ -143,6 +143,9 @@
143
143
  },
144
144
  "platform.editor.media.fix-copy-paste-excel_62g4s": {
145
145
  "type": "boolean"
146
+ },
147
+ "platform.editor.media.autoselect-inserted-image_oumto": {
148
+ "type": "boolean"
146
149
  }
147
150
  },
148
151
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",