@atlaskit/editor-plugin-media 1.3.0 → 1.4.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,11 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  ### Minor Changes
@@ -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) {
@@ -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) => {
@@ -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) {
@@ -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;
@@ -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;
@@ -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;
@@ -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.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.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",