@atlaskit/editor-core 185.3.0 → 185.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/card/nodeviews/blockCard.js +6 -2
  3. package/dist/cjs/plugins/card/nodeviews/datasource.js +139 -0
  4. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +7 -2
  5. package/dist/cjs/plugins/card/pm-plugins/main.js +4 -0
  6. package/dist/cjs/plugins/date/nodeviews/date.js +2 -1
  7. package/dist/cjs/plugins/expand/nodeviews/index.js +41 -10
  8. package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +2 -1
  9. package/dist/cjs/plugins/media/commands/captions.js +3 -0
  10. package/dist/cjs/plugins/media/commands/helpers.js +3 -3
  11. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +35 -4
  12. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +25 -11
  13. package/dist/cjs/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
  14. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +8 -1
  15. package/dist/cjs/plugins/media/pm-plugins/main.js +5 -1
  16. package/dist/cjs/plugins/media/utils/media-common.js +3 -0
  17. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
  18. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
  19. package/dist/cjs/version-wrapper.js +1 -1
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/plugins/card/nodeviews/blockCard.js +11 -5
  22. package/dist/es2019/plugins/card/nodeviews/datasource.js +100 -0
  23. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +12 -5
  24. package/dist/es2019/plugins/card/pm-plugins/main.js +4 -0
  25. package/dist/es2019/plugins/date/nodeviews/date.js +2 -1
  26. package/dist/es2019/plugins/expand/nodeviews/index.js +41 -10
  27. package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +2 -1
  28. package/dist/es2019/plugins/media/commands/captions.js +3 -0
  29. package/dist/es2019/plugins/media/commands/helpers.js +3 -3
  30. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +39 -4
  31. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +10 -2
  32. package/dist/es2019/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
  33. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +8 -1
  34. package/dist/es2019/plugins/media/pm-plugins/main.js +5 -1
  35. package/dist/es2019/plugins/media/utils/media-common.js +3 -0
  36. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
  37. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
  38. package/dist/es2019/version-wrapper.js +1 -1
  39. package/dist/es2019/version.json +1 -1
  40. package/dist/esm/plugins/card/nodeviews/blockCard.js +6 -2
  41. package/dist/esm/plugins/card/nodeviews/datasource.js +131 -0
  42. package/dist/esm/plugins/card/nodeviews/inlineCard.js +7 -2
  43. package/dist/esm/plugins/card/pm-plugins/main.js +4 -0
  44. package/dist/esm/plugins/date/nodeviews/date.js +2 -1
  45. package/dist/esm/plugins/expand/nodeviews/index.js +41 -10
  46. package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +2 -1
  47. package/dist/esm/plugins/media/commands/captions.js +3 -0
  48. package/dist/esm/plugins/media/commands/helpers.js +3 -3
  49. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +35 -4
  50. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +25 -11
  51. package/dist/esm/plugins/media/nodeviews/mediaNodeView/media.js +5 -1
  52. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +8 -1
  53. package/dist/esm/plugins/media/pm-plugins/main.js +5 -1
  54. package/dist/esm/plugins/media/utils/media-common.js +3 -0
  55. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +7 -1
  56. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +8 -1
  57. package/dist/esm/version-wrapper.js +1 -1
  58. package/dist/esm/version.json +1 -1
  59. package/dist/types/nodeviews/types.d.ts +2 -2
  60. package/dist/types/plugins/card/nodeviews/datasource.d.ts +27 -0
  61. package/dist/types/plugins/expand/nodeviews/index.d.ts +0 -1
  62. package/dist/types/plugins/media/commands/captions.d.ts +1 -1
  63. package/dist/types/plugins/media/nodeviews/mediaGroup.d.ts +1 -1
  64. package/dist/types-ts4.5/nodeviews/types.d.ts +2 -2
  65. package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +27 -0
  66. package/dist/types-ts4.5/plugins/expand/nodeviews/index.d.ts +0 -1
  67. package/dist/types-ts4.5/plugins/media/commands/captions.d.ts +1 -1
  68. package/dist/types-ts4.5/plugins/media/nodeviews/mediaGroup.d.ts +1 -1
  69. package/package.json +8 -7
  70. package/report.api.md +2 -2
  71. package/tmp/api-report-tmp.d.ts +2 -2
@@ -15,6 +15,9 @@ class Task extends ReactNodeView {
15
15
  tr
16
16
  } = this.view.state;
17
17
  const nodePos = this.getPos();
18
+ if (typeof nodePos !== 'number') {
19
+ return false;
20
+ }
18
21
 
19
22
  // SetAttrsStep should be used to prevent task updates from being dropped when mapping task ticks
20
23
  // from a previous version of the document, such as a published page.
@@ -36,7 +39,11 @@ class Task extends ReactNodeView {
36
39
  */
37
40
  _defineProperty(this, "addListAnalyticsData", event => {
38
41
  try {
39
- const resolvedPos = this.view.state.doc.resolve(this.getPos());
42
+ const nodePos = this.getPos();
43
+ if (typeof nodePos !== 'number') {
44
+ return false;
45
+ }
46
+ const resolvedPos = this.view.state.doc.resolve(nodePos);
40
47
  const position = resolvedPos.index();
41
48
  const listSize = resolvedPos.parent.childCount;
42
49
  const listLocalId = resolvedPos.parent.attrs.localId;
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.3.0";
2
+ export const version = "185.4.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.3.0",
3
+ "version": "185.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -41,10 +41,14 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
41
41
  // don't dispatch immediately since we might be in the middle of
42
42
  // rendering a nodeview
43
43
  rafSchedule(function () {
44
- return view.dispatch(registerCard({
44
+ var pos = getPos();
45
+ if (typeof pos !== 'number') {
46
+ return;
47
+ }
48
+ view.dispatch(registerCard({
45
49
  title: title,
46
50
  url: url,
47
- pos: getPos()
51
+ pos: pos
48
52
  })(view.state.tr));
49
53
  })();
50
54
  });
@@ -0,0 +1,131 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ 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; } }
12
+ /** @jsx jsx */
13
+ import React from 'react';
14
+ import PropTypes from 'prop-types';
15
+ import { css, jsx } from '@emotion/react';
16
+ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
17
+ import { DatasourceTableView } from '@atlaskit/link-datasource';
18
+ var containerStyles = css({
19
+ height: '500px',
20
+ overflow: 'auto'
21
+ });
22
+ export var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
23
+ _inherits(DatasourceComponent, _React$PureComponent);
24
+ var _super = _createSuper(DatasourceComponent);
25
+ function DatasourceComponent(props) {
26
+ var _this;
27
+ _classCallCheck(this, DatasourceComponent);
28
+ _this = _super.call(this, props);
29
+ _defineProperty(_assertThisInitialized(_this), "getPosSafely", function () {
30
+ var getPos = _this.props.getPos;
31
+ if (!getPos || typeof getPos === 'boolean') {
32
+ return;
33
+ }
34
+ try {
35
+ return getPos();
36
+ } catch (e) {
37
+ // Can blow up in rare cases, when node has been removed.
38
+ }
39
+ });
40
+ _defineProperty(_assertThisInitialized(_this), "getDatasource", function () {
41
+ return _this.props.node.attrs.datasource;
42
+ });
43
+ _defineProperty(_assertThisInitialized(_this), "getTableView", function (datasource) {
44
+ var views = (datasource || _this.getDatasource()).views;
45
+ return views.find(function (view) {
46
+ return view.type === 'table';
47
+ }) || undefined;
48
+ });
49
+ _defineProperty(_assertThisInitialized(_this), "handleColumnChange", function (columnKeys) {
50
+ var _this$props$view = _this.props.view,
51
+ state = _this$props$view.state,
52
+ dispatch = _this$props$view.dispatch;
53
+ var pos = _this.getPosSafely();
54
+ if (pos === undefined) {
55
+ return;
56
+ }
57
+ var attrs = _this.props.node.attrs;
58
+ var views = [{
59
+ type: 'table',
60
+ properties: {
61
+ columns: columnKeys.map(function (key) {
62
+ return {
63
+ key: key
64
+ };
65
+ })
66
+ }
67
+ }];
68
+ var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, attrs), {}, {
69
+ datasource: _objectSpread(_objectSpread({}, attrs.datasource), {}, {
70
+ views: views
71
+ })
72
+ }));
73
+ tr.setMeta('scrollIntoView', false);
74
+ dispatch(tr);
75
+ });
76
+ return _this;
77
+ }
78
+ _createClass(DatasourceComponent, [{
79
+ key: "render",
80
+ value: function render() {
81
+ var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
82
+ var datasource = this.getDatasource();
83
+ var tableView = this.getTableView();
84
+ if (tableView) {
85
+ var _tableView$properties;
86
+ var visibleColumnKeys = (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(function (_ref) {
87
+ var key = _ref.key;
88
+ return key;
89
+ });
90
+
91
+ // [WS-2307]: we only render card wrapped into a Provider when the value is ready
92
+ if (cardContext && cardContext.value) {
93
+ return jsx(cardContext.Provider, {
94
+ value: cardContext.value
95
+ }, jsx(DatasourceTableView, {
96
+ datasourceId: datasource.id,
97
+ parameters: datasource.parameters,
98
+ visibleColumnKeys: visibleColumnKeys,
99
+ onVisibleColumnKeysChange: this.handleColumnChange
100
+ }));
101
+ }
102
+ }
103
+ return null;
104
+ }
105
+ }]);
106
+ return DatasourceComponent;
107
+ }(React.PureComponent);
108
+ _defineProperty(DatasourceComponent, "contextTypes", {
109
+ contextAdapter: PropTypes.object
110
+ });
111
+ export var Datasource = /*#__PURE__*/function (_ReactNodeView) {
112
+ _inherits(Datasource, _ReactNodeView);
113
+ var _super2 = _createSuper(Datasource);
114
+ function Datasource() {
115
+ _classCallCheck(this, Datasource);
116
+ return _super2.apply(this, arguments);
117
+ }
118
+ _createClass(Datasource, [{
119
+ key: "render",
120
+ value: function render() {
121
+ return jsx("div", {
122
+ css: containerStyles
123
+ }, jsx(DatasourceComponent, {
124
+ node: this.node,
125
+ view: this.view,
126
+ getPos: this.getPos
127
+ }));
128
+ }
129
+ }]);
130
+ return Datasource;
131
+ }(ReactNodeView);
@@ -38,10 +38,15 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
38
38
  // don't dispatch immediately since we might be in the middle of
39
39
  // rendering a nodeview
40
40
  rafSchedule(function () {
41
- return view.dispatch(registerCard({
41
+ // prosemirror-bump-fix
42
+ var pos = getPos();
43
+ if (typeof pos !== 'number') {
44
+ return;
45
+ }
46
+ view.dispatch(registerCard({
42
47
  title: title,
43
48
  url: url,
44
- pos: getPos()
49
+ pos: pos
45
50
  })(view.state.tr));
46
51
  })();
47
52
  });
@@ -10,6 +10,7 @@ import reducer from './reducers';
10
10
  import { handleProvider, resolveWithProvider } from './util/resolve';
11
11
  import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
12
12
  import { createAnalyticsQueue, eventsFromTransaction } from './analytics';
13
+ import { Datasource } from '../nodeviews/datasource';
13
14
  export { pluginKey } from './plugin-key';
14
15
  export var createPlugin = function createPlugin(options, pluginInjectionApi) {
15
16
  return function (pmPluginFactoryParams) {
@@ -117,6 +118,9 @@ export var createPlugin = function createPlugin(options, pluginInjectionApi) {
117
118
  showServerActions: showServerActions
118
119
  };
119
120
  var hasIntlContext = true;
121
+ if (node.attrs.datasource) {
122
+ return new Datasource(node, view, getPos, portalProviderAPI, eventDispatcher, undefined, undefined, true, undefined, hasIntlContext).init();
123
+ }
120
124
  return new BlockCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
121
125
  },
122
126
  embedCard: function embedCard(node, view, getPos) {
@@ -12,10 +12,11 @@ export function DateNodeView(props) {
12
12
  selection = _props$view$state.selection,
13
13
  getPos = props.getPos;
14
14
  var intl = useIntl();
15
+ var pos = typeof getPos === 'function' ? getPos() : undefined;
15
16
 
16
17
  // We fall back to selection.$from even though it does not cover all use cases
17
18
  // eg. upon Editor init, selection is at the start, not at the Date node
18
- var $nodePos = typeof getPos === 'function' ? doc.resolve(getPos()) : selection.$from;
19
+ var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
19
20
  var parent = $nodePos.parent;
20
21
  var withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
21
22
  var color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
@@ -84,6 +84,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
84
84
  return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
85
85
  });
86
86
  _defineProperty(this, "handleClick", function (event) {
87
+ var pos = _this.getPos();
88
+ if (typeof pos !== 'number') {
89
+ return;
90
+ }
87
91
  var target = event.target;
88
92
  var _this$view2 = _this.view,
89
93
  state = _this$view2.state,
@@ -99,7 +103,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
99
103
  if (_this.view.dom instanceof HTMLElement) {
100
104
  _this.view.dom.blur();
101
105
  }
102
- toggleExpandExpanded(_this.getPos(), _this.node.type)(state, dispatch);
106
+ toggleExpandExpanded(pos, _this.node.type)(state, dispatch);
103
107
  return;
104
108
  }
105
109
  if (target === _this.input) {
@@ -109,13 +113,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
109
113
  }
110
114
  });
111
115
  _defineProperty(this, "handleInput", function (event) {
116
+ var pos = _this.getPos();
117
+ if (typeof pos !== 'number') {
118
+ return;
119
+ }
112
120
  var target = event.target;
113
121
  if (target === _this.input) {
114
122
  event.stopPropagation();
115
123
  var _this$view3 = _this.view,
116
124
  state = _this$view3.state,
117
125
  dispatch = _this$view3.dispatch;
118
- updateExpandTitle(target.value, _this.getPos(), _this.node.type)(state, dispatch);
126
+ updateExpandTitle(target.value, pos, _this.node.type)(state, dispatch);
119
127
  }
120
128
  });
121
129
  _defineProperty(this, "handleFocus", function (event) {
@@ -148,6 +156,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
148
156
  if (!_this.input) {
149
157
  return;
150
158
  }
159
+ var pos = _this.getPos();
160
+ if (typeof pos !== 'number') {
161
+ return;
162
+ }
151
163
  var _this$input = _this.input,
152
164
  selectionStart = _this$input.selectionStart,
153
165
  selectionEnd = _this$input.selectionEnd;
@@ -157,15 +169,19 @@ export var ExpandNodeView = /*#__PURE__*/function () {
157
169
  var state = _this.view.state;
158
170
  var expandNode = _this.node;
159
171
  if (expandNode && isEmptyNode(state.schema)(expandNode)) {
160
- deleteExpandAtPos(_this.getPos(), expandNode)(state, _this.view.dispatch);
172
+ deleteExpandAtPos(pos, expandNode)(state, _this.view.dispatch);
161
173
  }
162
174
  });
163
175
  _defineProperty(this, "toggleExpand", function () {
176
+ var pos = _this.getPos();
177
+ if (typeof pos !== 'number') {
178
+ return;
179
+ }
164
180
  if (_this.isAllowInteractiveExpandEnabled()) {
165
181
  var _this$view4 = _this.view,
166
182
  state = _this$view4.state,
167
183
  dispatch = _this$view4.dispatch;
168
- toggleExpandExpanded(_this.getPos(), _this.node.type)(state, dispatch);
184
+ toggleExpandExpanded(pos, _this.node.type)(state, dispatch);
169
185
  }
170
186
  });
171
187
  _defineProperty(this, "moveToOutsideOfTitle", function (event) {
@@ -203,6 +219,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
203
219
  if (!_this.input) {
204
220
  return;
205
221
  }
222
+ var pos = _this.getPos();
223
+ if (typeof pos !== 'number') {
224
+ return;
225
+ }
206
226
  var _this$input2 = _this.input,
207
227
  value = _this$input2.value,
208
228
  selectionStart = _this$input2.selectionStart,
@@ -213,13 +233,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
213
233
  dispatch = _this$view6.dispatch;
214
234
  event.preventDefault();
215
235
  _this.view.focus();
216
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + _this.getPos()), Side.RIGHT)));
236
+ dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.node.nodeSize + pos), Side.RIGHT)));
217
237
  }
218
238
  });
219
239
  _defineProperty(this, "setLeftGapCursor", function (event) {
220
240
  if (!_this.input) {
221
241
  return;
222
242
  }
243
+ var pos = _this.getPos();
244
+ if (typeof pos !== 'number') {
245
+ return;
246
+ }
223
247
  var _this$input3 = _this.input,
224
248
  selectionStart = _this$input3.selectionStart,
225
249
  selectionEnd = _this$input3.selectionEnd;
@@ -229,13 +253,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
229
253
  state = _this$view7.state,
230
254
  dispatch = _this$view7.dispatch;
231
255
  _this.view.focus();
232
- dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(_this.getPos()), Side.LEFT)));
256
+ dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)));
233
257
  }
234
258
  });
235
259
  _defineProperty(this, "handleArrowRightFromTitle", function (event) {
236
260
  if (!_this.input) {
237
261
  return;
238
262
  }
263
+ var pos = _this.getPos();
264
+ if (typeof pos !== 'number') {
265
+ return;
266
+ }
239
267
  var _this$input4 = _this.input,
240
268
  value = _this$input4.value,
241
269
  selectionStart = _this$input4.selectionStart,
@@ -246,13 +274,17 @@ export var ExpandNodeView = /*#__PURE__*/function () {
246
274
  state = _this$view8.state,
247
275
  dispatch = _this$view8.dispatch;
248
276
  _this.view.focus();
249
- setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, _this.getPos()))(state, dispatch);
277
+ setSelectionRelativeToNode(RelativeSelectionPos.End, NodeSelection.create(state.doc, pos))(state, dispatch);
250
278
  }
251
279
  });
252
280
  _defineProperty(this, "handleArrowLeftFromTitle", function (event) {
253
281
  if (!_this.input) {
254
282
  return;
255
283
  }
284
+ var pos = _this.getPos();
285
+ if (typeof pos !== 'number') {
286
+ return;
287
+ }
256
288
  var _this$input5 = _this.input,
257
289
  selectionStart = _this$input5.selectionStart,
258
290
  selectionEnd = _this$input5.selectionEnd;
@@ -266,9 +298,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
266
298
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
267
299
  // This is a special case where we want to bypass node selection and jump straight to gap cursor
268
300
  if (getSelectionPluginState(state).selectionRelativeToNode === undefined) {
269
- setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(_this.getPos()), Side.LEFT))(state, dispatch);
301
+ setSelectionRelativeToNode(undefined, new GapCursorSelection(state.doc.resolve(pos), Side.LEFT))(state, dispatch);
270
302
  } else {
271
- setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, _this.getPos()))(state, dispatch);
303
+ setSelectionRelativeToNode(RelativeSelectionPos.Start, NodeSelection.create(state.doc, pos))(state, dispatch);
272
304
  }
273
305
  }
274
306
  });
@@ -277,7 +309,6 @@ export var ExpandNodeView = /*#__PURE__*/function () {
277
309
  dom = _DOMSerializer$render.dom,
278
310
  contentDOM = _DOMSerializer$render.contentDOM;
279
311
  this.getPos = getPos;
280
- this.pos = getPos();
281
312
  this.view = view;
282
313
  this.node = node;
283
314
  this.dom = dom;
@@ -30,7 +30,8 @@ function ExtensionWithPluginState(props) {
30
30
  var isMobile = editorAppearance === 'mobile';
31
31
  var hasChildren = !!children;
32
32
  var removeBorder = hideFrame && !isMobile && !hasBody || false;
33
- var isTopLevelNode = props.getPos && !isNaN(props.getPos()) && props.view.state.doc.resolve(props.getPos()).depth === 0;
33
+ var pos = typeof props.getPos === 'function' ? props.getPos() : undefined;
34
+ var isTopLevelNode = typeof pos !== 'undefined' && !isNaN(pos) && props.view.state.doc.resolve(pos).depth === 0;
34
35
  var shouldBreakout =
35
36
  // Extension should breakout when the layout is set to 'full-width' or 'wide'.
36
37
  ['full-width', 'wide'].includes(node.attrs.layout) &&
@@ -19,6 +19,9 @@ export var selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSing
19
19
  };
20
20
  export var insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(mediaSingleNodePos, mediaSingleNode) {
21
21
  return function (state, dispatch) {
22
+ if (typeof mediaSingleNodePos !== 'number') {
23
+ return false;
24
+ }
22
25
  var tr = state.tr;
23
26
 
24
27
  // node should have one child, media
@@ -41,7 +41,7 @@ export var updateAllMediaSingleNodesAttrs = function updateAllMediaSingleNodesAt
41
41
  var validMediaNodePositions = mediaNodes.reduce(function (acc, _ref) {
42
42
  var getPos = _ref.getPos;
43
43
  var pos = getPos();
44
- if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
44
+ if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
45
45
  return acc;
46
46
  }
47
47
  acc.push(pos);
@@ -64,7 +64,7 @@ export var updateAllMediaSingleNodesAttrs = function updateAllMediaSingleNodesAt
64
64
  export var updateCurrentMediaNodeAttrs = function updateCurrentMediaNodeAttrs(attrs, mediaNode) {
65
65
  return function (state, dispatch) {
66
66
  var pos = mediaNode.getPos();
67
- if (isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
67
+ if (typeof pos !== 'number' || isNaN(pos) || typeof pos === 'number' && !isMediaNode(pos, state)) {
68
68
  return false;
69
69
  }
70
70
  var tr = state.tr;
@@ -85,7 +85,7 @@ export var updateMediaSingleNodeAttrs = function updateMediaSingleNodeAttrs(id,
85
85
  }
86
86
  var tr = state.tr;
87
87
  var pos = mediaNodeWithPos.getPos();
88
- if (!isMediaNode(pos, state)) {
88
+ if (typeof pos !== 'number' || !isMediaNode(pos, state)) {
89
89
  return false;
90
90
  }
91
91
  tr.step(new SetAttrsStep(pos, attrs)).setMeta('addToHistory', false);
@@ -25,7 +25,11 @@ import { injectIntl } from 'react-intl-next';
25
25
  import { messages } from './messages';
26
26
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
27
27
  var isMediaGroupSelectedFromProps = function isMediaGroupSelectedFromProps(props) {
28
- return isNodeSelectedOrInRange(props.anchorPos, props.headPos, props.getPos(), props.node.nodeSize);
28
+ var pos = props.getPos();
29
+ if (typeof pos !== 'number') {
30
+ return false;
31
+ }
32
+ return isNodeSelectedOrInRange(props.anchorPos, props.headPos, pos, props.node.nodeSize);
29
33
  };
30
34
  var hasSelectionChanged = function hasSelectionChanged(oldProps, newProps) {
31
35
  if (isMediaGroupSelectedFromProps(oldProps) !== isMediaGroupSelectedFromProps(newProps)) {
@@ -66,7 +70,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
66
70
  _this.mediaNodes = [];
67
71
  node.forEach(function (item, childOffset) {
68
72
  var getPos = function getPos() {
69
- return props.getPos() + childOffset + 1;
73
+ var pos = props.getPos();
74
+ if (typeof pos !== 'number') {
75
+ // That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
76
+ // Because the original code would return NaN on runtime
77
+ // We are just make it explict now.
78
+ // We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
79
+ // TODO: ED-13910 prosemirror-bump leftovers
80
+ return NaN;
81
+ }
82
+ return pos + childOffset + 1;
70
83
  };
71
84
  _this.mediaNodes.push(item);
72
85
  if (updatedAttrs) {
@@ -108,7 +121,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
108
121
  var items = _this.mediaNodes.map(function (item, idx) {
109
122
  // We declared this to get a fresh position every time
110
123
  var getNodePos = function getNodePos() {
111
- return getPos() + idx + 1;
124
+ var pos = getPos();
125
+ if (typeof pos !== 'number') {
126
+ // That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
127
+ // Because the original code would return NaN on runtime
128
+ // We are just make it explict now.
129
+ // We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
130
+ // TODO: ED-13910 prosemirror-bump leftovers
131
+ return NaN;
132
+ }
133
+ return pos + idx + 1;
112
134
  };
113
135
 
114
136
  // Media Inline creates a floating toolbar with the same options, excludes these options if enabled
@@ -175,7 +197,16 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
175
197
  isMediaSingle: false
176
198
  });
177
199
  getPos = function getPos() {
178
- return _this2.props.getPos() + 1;
200
+ var pos = _this2.props.getPos();
201
+ if (typeof pos !== 'number') {
202
+ // That may seems weird, but the previous type wasn't match with the real ProseMirror code. And a lot of Media API was built expecting a number
203
+ // Because the original code would return NaN on runtime
204
+ // We are just make it explict now.
205
+ // We may run a deep investagation on Media code to figure out a better fix. But, for now, we want to keep the current behavior.
206
+ // TODO: ED-13910 prosemirror-bump leftovers
207
+ return NaN;
208
+ }
209
+ return pos + 1;
179
210
  };
180
211
  contextId = mediaNodeUpdater.getNodeContextId();
181
212
  if (contextId) {
@@ -216,7 +216,7 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
216
216
  })));
217
217
  _defineProperty(this, "uploadExternalMedia", /*#__PURE__*/function () {
218
218
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(getPos) {
219
- var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions;
219
+ var node, mediaProvider, uploadMediaClientConfig, mediaClient, collection, uploader, uploadableFileUpfrontIds, dimensions, pos;
220
220
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
221
221
  while (1) switch (_context7.prev = _context7.next) {
222
222
  case 0:
@@ -226,7 +226,7 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
226
226
  case 3:
227
227
  mediaProvider = _context7.sent;
228
228
  if (!(node && mediaProvider)) {
229
- _context7.next = 21;
229
+ _context7.next = 24;
230
230
  break;
231
231
  }
232
232
  uploadMediaClientConfig = mediaProvider.uploadMediaClientConfig;
@@ -244,17 +244,24 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
244
244
  case 13:
245
245
  uploader = _context7.sent;
246
246
  uploadableFileUpfrontIds = uploader.uploadableFileUpfrontIds, dimensions = uploader.dimensions;
247
- replaceExternalMedia(getPos() + 1, {
247
+ pos = getPos();
248
+ if (!(typeof pos !== 'number')) {
249
+ _context7.next = 18;
250
+ break;
251
+ }
252
+ return _context7.abrupt("return");
253
+ case 18:
254
+ replaceExternalMedia(pos + 1, {
248
255
  id: uploadableFileUpfrontIds.id,
249
256
  collection: collection,
250
257
  height: dimensions.height,
251
258
  width: dimensions.width,
252
259
  occurrenceKey: uploadableFileUpfrontIds.occurrenceKey
253
260
  })(_this.props.view.state, _this.props.view.dispatch);
254
- _context7.next = 21;
261
+ _context7.next = 24;
255
262
  break;
256
- case 18:
257
- _context7.prev = 18;
263
+ case 21:
264
+ _context7.prev = 21;
258
265
  _context7.t0 = _context7["catch"](10);
259
266
  //keep it as external media
260
267
  if (_this.props.dispatchAnalyticsEvent) {
@@ -264,11 +271,11 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
264
271
  eventType: EVENT_TYPE.OPERATIONAL
265
272
  });
266
273
  }
267
- case 21:
274
+ case 24:
268
275
  case "end":
269
276
  return _context7.stop();
270
277
  }
271
- }, _callee7, null, [[10, 18]]);
278
+ }, _callee7, null, [[10, 21]]);
272
279
  }));
273
280
  return function (_x3) {
274
281
  return _ref8.apply(this, arguments);
@@ -360,7 +367,7 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
360
367
  })));
361
368
  _defineProperty(this, "copyNodeFromBlobUrl", /*#__PURE__*/function () {
362
369
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(getPos) {
363
- var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile;
370
+ var attrs, url, mediaAttrs, mediaProvider, currentCollectionName, contextId, id, collection, height, width, mimeType, name, size, uploadMediaClientConfig, mediaClient, auth, source, destination, mediaFile, pos;
364
371
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
365
372
  while (1) switch (_context10.prev = _context10.next) {
366
373
  case 0:
@@ -419,7 +426,14 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
419
426
  return mediaClient.file.copyFile(source, destination);
420
427
  case 25:
421
428
  mediaFile = _context10.sent;
422
- replaceExternalMedia(getPos() + 1, {
429
+ pos = getPos();
430
+ if (!(typeof pos !== 'number')) {
431
+ _context10.next = 29;
432
+ break;
433
+ }
434
+ return _context10.abrupt("return");
435
+ case 29:
436
+ replaceExternalMedia(pos + 1, {
423
437
  id: mediaFile.id,
424
438
  collection: currentCollectionName,
425
439
  height: height,
@@ -428,7 +442,7 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
428
442
  __fileMimeType: mimeType,
429
443
  __fileSize: size
430
444
  })(_this.props.view.state, _this.props.view.dispatch);
431
- case 27:
445
+ case 30:
432
446
  case "end":
433
447
  return _context10.stop();
434
448
  }
@@ -55,10 +55,14 @@ export var MediaNode = /*#__PURE__*/function (_Component) {
55
55
  _this.selectMediaSingle(event);
56
56
  });
57
57
  _defineProperty(_assertThisInitialized(_this), "selectMediaSingle", function (event) {
58
+ var propPos = _this.props.getPos();
59
+ if (typeof propPos !== 'number') {
60
+ return;
61
+ }
62
+
58
63
  // We need to call "stopPropagation" here in order to prevent the browser from navigating to
59
64
  // another URL if the media node is wrapped in a link mark.
60
65
  event.stopPropagation();
61
- var propPos = _this.props.getPos();
62
66
  var state = _this.props.view.state;
63
67
  if (event.shiftKey) {
64
68
  // don't select text if there is current selection in a table (as this would override selected cells)
@@ -169,10 +169,14 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
169
169
  }());
170
170
  _defineProperty(_assertThisInitialized(_this), "selectMediaSingle", function (_ref3) {
171
171
  var event = _ref3.event;
172
+ var propPos = _this.props.getPos();
173
+ if (typeof propPos !== 'number') {
174
+ return;
175
+ }
176
+
172
177
  // We need to call "stopPropagation" here in order to prevent the browser from navigating to
173
178
  // another URL if the media node is wrapped in a link mark.
174
179
  event.stopPropagation();
175
- var propPos = _this.props.getPos();
176
180
  var state = _this.props.view.state;
177
181
  if (event.shiftKey) {
178
182
  // don't select text if there is current selection in a table (as this would override selected cells)
@@ -244,6 +248,9 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
244
248
  insertAndSelectCaptionFromMediaSinglePos(getPos(), node)(view.state, view.dispatch);
245
249
  });
246
250
  _defineProperty(_assertThisInitialized(_this), "getLineLength", function (view, pos) {
251
+ if (typeof pos !== 'number') {
252
+ return null;
253
+ }
247
254
  if (isRichMediaInsideOfBlockNode(view, pos)) {
248
255
  var $pos = view.state.doc.resolve(pos);
249
256
  var domNode = view.nodeDOM($pos.pos);