@atlaskit/editor-core 185.0.2 → 185.1.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,24 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 185.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`63ef771aab9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/63ef771aab9) - [ux] Fix layout button. breakoutNode equals check should include position.
8
+
9
+ ## 185.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`d9fe34b3f2b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d9fe34b3f2b) - [ux] The ResizerNext component now supports a new property handleAlignmentMethod which defaults to "sticky". This means the resizer handles wil stick to the top/bottom bounds of the browser viewport if the component extends beyond and the user scrolls down. An alternative "center" value can be set which means the handles will just center to their content and not stick.
14
+
15
+ ### Patch Changes
16
+
17
+ - [`bb442ced942`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bb442ced942) - Remove newCardExperience feature flag
18
+ - [`daee7ddddc2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/daee7ddddc2) - [MEX-2405] Fixed the flickering error (inline) card issue
19
+ - [`d7888f058a9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7888f058a9) - converted to using new AnalyticsAPI in mentions plugin and wrote test for it
20
+ - Updated dependencies
21
+
3
22
  ## 185.0.2
4
23
 
5
24
  ### Patch Changes
@@ -106,7 +106,7 @@ var BreakoutView = /*#__PURE__*/function () {
106
106
  }();
107
107
  function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
108
108
  if (newBreakoutNode && currentBreakoutNode) {
109
- return !newBreakoutNode.eq(currentBreakoutNode);
109
+ return newBreakoutNode !== currentBreakoutNode;
110
110
  }
111
111
  return newBreakoutNode || currentBreakoutNode ? true : false;
112
112
  }
@@ -121,10 +121,9 @@ function createPlugin(pluginInjectionApi, _ref2) {
121
121
  },
122
122
  apply: function apply(tr, pluginState) {
123
123
  var breakoutNode = (0, _findBreakoutNode.findSupportedNodeForBreakout)(tr.selection);
124
- var node = breakoutNode ? breakoutNode.node : null;
125
- if (shouldPluginStateUpdate(node, pluginState.breakoutNode)) {
124
+ if (shouldPluginStateUpdate(breakoutNode, pluginState.breakoutNode)) {
126
125
  var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
127
- breakoutNode: node
126
+ breakoutNode: breakoutNode
128
127
  });
129
128
  dispatch(_pluginKey.pluginKey, nextPluginState);
130
129
  return nextPluginState;
@@ -147,7 +146,7 @@ function createPlugin(pluginInjectionApi, _ref2) {
147
146
  });
148
147
  }
149
148
  var LayoutButtonWrapper = function LayoutButtonWrapper(_ref3) {
150
- var _breakoutState$breako;
149
+ var _breakoutState$breako, _breakoutState$breako2;
151
150
  var api = _ref3.api,
152
151
  editorView = _ref3.editorView,
153
152
  boundariesElement = _ref3.boundariesElement,
@@ -161,7 +160,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref3) {
161
160
  mountPoint: mountPoint,
162
161
  boundariesElement: boundariesElement,
163
162
  scrollableElement: scrollableElement,
164
- node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : breakoutState.breakoutNode) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
163
+ node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : (_breakoutState$breako2 = breakoutState.breakoutNode) === null || _breakoutState$breako2 === void 0 ? void 0 : _breakoutState$breako2.node) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
165
164
  });
166
165
  };
167
166
  var breakoutPlugin = function breakoutPlugin(options, api) {
@@ -64,7 +64,7 @@ function getBreakoutNodeElement(pluginState, selection, editorView) {
64
64
  if (selection instanceof _prosemirrorState.NodeSelection && (0, _isSupportedNode.isSupportedNodeForBreakout)(selection.node)) {
65
65
  return (0, _prosemirrorUtils.findDomRefAtPos)(selection.from, editorView.domAtPos.bind(editorView));
66
66
  }
67
- return (0, _prosemirrorUtils.findParentDomRefOfType)(pluginState.breakoutNode.type, editorView.domAtPos.bind(editorView))(selection);
67
+ return (0, _prosemirrorUtils.findParentDomRefOfType)(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
68
68
  }
69
69
  var LayoutButton = /*#__PURE__*/function (_React$Component) {
70
70
  (0, _inherits2.default)(LayoutButton, _React$Component);
@@ -49,60 +49,59 @@ var createMediaNodeUpdater = function createMediaNodeUpdater(props) {
49
49
  */
50
50
  exports.createMediaNodeUpdater = createMediaNodeUpdater;
51
51
  var updateMediaNodeAttributes = /*#__PURE__*/function () {
52
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(props) {
53
- var mediaNodeUpdater, addPendingTask, node, contextId, hasDifferentContextId, copyNode;
52
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(props, mediaNodeUpdater) {
53
+ var addPendingTask, node, contextId, hasDifferentContextId, copyNode;
54
54
  return _regenerator.default.wrap(function _callee$(_context) {
55
55
  while (1) switch (_context.prev = _context.next) {
56
56
  case 0:
57
- mediaNodeUpdater = createMediaNodeUpdater(props);
58
57
  addPendingTask = props.mediaPluginState.addPendingTask;
59
58
  node = props.node;
60
59
  if (node) {
61
- _context.next = 5;
60
+ _context.next = 4;
62
61
  break;
63
62
  }
64
63
  return _context.abrupt("return");
65
- case 5:
64
+ case 4:
66
65
  contextId = mediaNodeUpdater.getNodeContextId();
67
66
  if (contextId) {
68
- _context.next = 9;
67
+ _context.next = 8;
69
68
  break;
70
69
  }
71
- _context.next = 9;
70
+ _context.next = 8;
72
71
  return mediaNodeUpdater.updateContextId();
73
- case 9:
74
- _context.next = 11;
72
+ case 8:
73
+ _context.next = 10;
75
74
  return mediaNodeUpdater.hasDifferentContextId();
76
- case 11:
75
+ case 10:
77
76
  hasDifferentContextId = _context.sent;
78
77
  if (!hasDifferentContextId) {
79
- _context.next = 23;
78
+ _context.next = 22;
80
79
  break;
81
80
  }
82
- _context.prev = 13;
81
+ _context.prev = 12;
83
82
  copyNode = mediaNodeUpdater.copyNode({
84
83
  traceId: node.attrs.__mediaTraceId
85
84
  });
86
85
  addPendingTask(copyNode);
87
- _context.next = 18;
86
+ _context.next = 17;
88
87
  return copyNode;
89
- case 18:
90
- _context.next = 23;
88
+ case 17:
89
+ _context.next = 22;
91
90
  break;
92
- case 20:
93
- _context.prev = 20;
94
- _context.t0 = _context["catch"](13);
91
+ case 19:
92
+ _context.prev = 19;
93
+ _context.t0 = _context["catch"](12);
95
94
  return _context.abrupt("return");
96
- case 23:
97
- _context.next = 25;
95
+ case 22:
96
+ _context.next = 24;
98
97
  return mediaNodeUpdater.updateMediaSingleFileAttrs();
99
- case 25:
98
+ case 24:
100
99
  case "end":
101
100
  return _context.stop();
102
101
  }
103
- }, _callee, null, [[13, 20]]);
102
+ }, _callee, null, [[12, 19]]);
104
103
  }));
105
- return function updateMediaNodeAttributes(_x) {
104
+ return function updateMediaNodeAttributes(_x, _x2) {
106
105
  return _ref.apply(this, arguments);
107
106
  };
108
107
  }();
@@ -121,9 +120,15 @@ var MediaInline = function MediaInline(props) {
121
120
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
122
121
  viewMediaClientConfig = _useState2[0],
123
122
  setViewMediaClientConfig = _useState2[1];
123
+ var _useState3 = (0, _react.useState)(true),
124
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
125
+ isContextIdUnsync = _useState4[0],
126
+ setIsContextIdUnsync = _useState4[1];
124
127
  (0, _react.useEffect)(function () {
128
+ var mediaNodeUpdater = createMediaNodeUpdater(props);
129
+ mediaNodeUpdater.hasDifferentContextId().then(setIsContextIdUnsync);
125
130
  handleNewNode(props);
126
- updateMediaNodeAttributes(props);
131
+ updateMediaNodeAttributes(props, mediaNodeUpdater);
127
132
  updateViewMediaClientConfig(props);
128
133
  return function () {
129
134
  var mediaPluginState = props.mediaPluginState;
@@ -150,7 +155,7 @@ var MediaInline = function MediaInline(props) {
150
155
  }
151
156
  }, _callee2);
152
157
  }));
153
- return function updateViewMediaClientConfig(_x2) {
158
+ return function updateViewMediaClientConfig(_x3) {
154
159
  return _ref2.apply(this, arguments);
155
160
  };
156
161
  }();
@@ -164,10 +169,13 @@ var MediaInline = function MediaInline(props) {
164
169
  };
165
170
 
166
171
  /*
167
- * Only show the loading view if the media provider is not ready
168
- * prevents calling the media API before the provider is ready
172
+ * Show the loading view if
173
+ * 1. The media provider is not ready
174
+ * 2. Context Id is not synced
175
+ * to prevent calling the media API (in mounting of `MediaInlineCard`)
176
+ * before the prerequisites meet
169
177
  */
170
- if (!viewMediaClientConfig) {
178
+ if (!viewMediaClientConfig || isContextIdUnsync) {
171
179
  return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
172
180
  message: "",
173
181
  isSelected: false
@@ -18,14 +18,14 @@ var _adfSchema = require("@atlaskit/adf-schema");
18
18
  var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
19
19
  var _utils = require("../type-ahead/utils");
20
20
  var _ToolbarMention = _interopRequireDefault(require("./ui/ToolbarMention"));
21
- var _analytics = require("../analytics");
21
+ var _analytics = require("@atlaskit/editor-common/analytics");
22
22
  var _assets = require("../quick-insert/assets");
23
23
  var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
24
24
  var _openTypeaheadAtCursor = require("../type-ahead/transforms/open-typeahead-at-cursor");
25
25
  var _typeAhead = require("./type-ahead");
26
26
  var _key = require("./pm-plugins/key");
27
27
  var _main = require("./pm-plugins/main");
28
- var mentionsPlugin = function mentionsPlugin(options) {
28
+ var mentionsPlugin = function mentionsPlugin(options, api) {
29
29
  var sessionId = (0, _uuid.default)();
30
30
  var fireEvent = function fireEvent(payload) {
31
31
  if (!(options !== null && options !== void 0 && options.createAnalyticsEvent)) {
@@ -91,12 +91,13 @@ var mentionsPlugin = function mentionsPlugin(options) {
91
91
  return /*#__PURE__*/_react.default.createElement(_assets.IconMention, null);
92
92
  },
93
93
  action: function action(insert, state) {
94
+ var _api$dependencies$ana;
94
95
  var tr = insert(undefined);
95
96
  (0, _openTypeaheadAtCursor.openTypeAheadAtCursor)({
96
97
  triggerHandler: typeAhead,
97
98
  inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
98
99
  })(tr);
99
- return (0, _analytics.addAnalytics)(state, tr, {
100
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
100
101
  action: _analytics.ACTION.INVOKED,
101
102
  actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
102
103
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_MENTION,
@@ -104,7 +105,8 @@ var mentionsPlugin = function mentionsPlugin(options) {
104
105
  inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
105
106
  },
106
107
  eventType: _analytics.EVENT_TYPE.UI
107
- });
108
+ })(tr);
109
+ return tr;
108
110
  }
109
111
  }];
110
112
  },
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.0.2";
9
+ var version = "185.1.1";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.0.2",
3
+ "version": "185.1.1",
4
4
  "sideEffects": false
5
5
  }
@@ -94,7 +94,7 @@ class BreakoutView {
94
94
  }
95
95
  function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
96
96
  if (newBreakoutNode && currentBreakoutNode) {
97
- return !newBreakoutNode.eq(currentBreakoutNode);
97
+ return newBreakoutNode !== currentBreakoutNode;
98
98
  }
99
99
  return newBreakoutNode || currentBreakoutNode ? true : false;
100
100
  }
@@ -110,11 +110,10 @@ function createPlugin(pluginInjectionApi, {
110
110
  },
111
111
  apply(tr, pluginState) {
112
112
  const breakoutNode = findSupportedNodeForBreakout(tr.selection);
113
- const node = breakoutNode ? breakoutNode.node : null;
114
- if (shouldPluginStateUpdate(node, pluginState.breakoutNode)) {
113
+ if (shouldPluginStateUpdate(breakoutNode, pluginState.breakoutNode)) {
115
114
  const nextPluginState = {
116
115
  ...pluginState,
117
- breakoutNode: node
116
+ breakoutNode
118
117
  };
119
118
  dispatch(pluginKey, nextPluginState);
120
119
  return nextPluginState;
@@ -143,7 +142,7 @@ const LayoutButtonWrapper = ({
143
142
  scrollableElement,
144
143
  mountPoint
145
144
  }) => {
146
- var _breakoutState$breako;
145
+ var _breakoutState$breako, _breakoutState$breako2;
147
146
  // Re-render with `width` (but don't use state) due to https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/24272
148
147
  const {
149
148
  breakoutState
@@ -153,7 +152,7 @@ const LayoutButtonWrapper = ({
153
152
  mountPoint: mountPoint,
154
153
  boundariesElement: boundariesElement,
155
154
  scrollableElement: scrollableElement,
156
- node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : breakoutState.breakoutNode) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
155
+ node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : (_breakoutState$breako2 = breakoutState.breakoutNode) === null || _breakoutState$breako2 === void 0 ? void 0 : _breakoutState$breako2.node) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
157
156
  });
158
157
  };
159
158
  const breakoutPlugin = (options, api) => ({
@@ -56,7 +56,7 @@ function getBreakoutNodeElement(pluginState, selection, editorView) {
56
56
  if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
57
57
  return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
58
58
  }
59
- return findParentDomRefOfType(pluginState.breakoutNode.type, editorView.domAtPos.bind(editorView))(selection);
59
+ return findParentDomRefOfType(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
60
60
  }
61
61
  class LayoutButton extends React.Component {
62
62
  constructor(...args) {
@@ -24,8 +24,7 @@ export const createMediaNodeUpdater = props => {
24
24
  * using the contextid
25
25
  *
26
26
  */
27
- export const updateMediaNodeAttributes = async props => {
28
- const mediaNodeUpdater = createMediaNodeUpdater(props);
27
+ export const updateMediaNodeAttributes = async (props, mediaNodeUpdater) => {
29
28
  const {
30
29
  addPendingTask
31
30
  } = props.mediaPluginState;
@@ -39,6 +38,7 @@ export const updateMediaNodeAttributes = async props => {
39
38
  }
40
39
  const hasDifferentContextId = await mediaNodeUpdater.hasDifferentContextId();
41
40
  if (hasDifferentContextId) {
41
+ // Copy paste flow (different pages)
42
42
  try {
43
43
  const copyNode = mediaNodeUpdater.copyNode({
44
44
  traceId: node.attrs.__mediaTraceId
@@ -61,9 +61,12 @@ export const handleNewNode = props => {
61
61
  };
62
62
  export const MediaInline = props => {
63
63
  const [viewMediaClientConfig, setViewMediaClientConfig] = useState();
64
+ const [isContextIdUnsync, setIsContextIdUnsync] = useState(true);
64
65
  useEffect(() => {
66
+ const mediaNodeUpdater = createMediaNodeUpdater(props);
67
+ mediaNodeUpdater.hasDifferentContextId().then(setIsContextIdUnsync);
65
68
  handleNewNode(props);
66
- updateMediaNodeAttributes(props);
69
+ updateMediaNodeAttributes(props, mediaNodeUpdater);
67
70
  updateViewMediaClientConfig(props);
68
71
  return () => {
69
72
  const {
@@ -90,10 +93,13 @@ export const MediaInline = props => {
90
93
  };
91
94
 
92
95
  /*
93
- * Only show the loading view if the media provider is not ready
94
- * prevents calling the media API before the provider is ready
96
+ * Show the loading view if
97
+ * 1. The media provider is not ready
98
+ * 2. Context Id is not synced
99
+ * to prevent calling the media API (in mounting of `MediaInlineCard`)
100
+ * before the prerequisites meet
95
101
  */
96
- if (!viewMediaClientConfig) {
102
+ if (!viewMediaClientConfig || isContextIdUnsync) {
97
103
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
98
104
  message: "",
99
105
  isSelected: false
@@ -5,7 +5,7 @@ import { mention } from '@atlaskit/adf-schema';
5
5
  import WithPluginState from '../../ui/WithPluginState';
6
6
  import { isTypeAheadAllowed } from '../type-ahead/utils';
7
7
  import ToolbarMention from './ui/ToolbarMention';
8
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
8
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
9
  import { IconMention } from '../quick-insert/assets';
10
10
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
11
11
  import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
@@ -13,7 +13,7 @@ import { createTypeAheadConfig } from './type-ahead';
13
13
  import { mentionPluginKey } from './pm-plugins/key';
14
14
  import { createMentionPlugin } from './pm-plugins/main';
15
15
  export { mentionPluginKey };
16
- const mentionsPlugin = options => {
16
+ const mentionsPlugin = (options, api) => {
17
17
  let sessionId = uuid();
18
18
  const fireEvent = payload => {
19
19
  if (!(options !== null && options !== void 0 && options.createAnalyticsEvent)) {
@@ -76,12 +76,13 @@ const mentionsPlugin = options => {
76
76
  keyshortcut: '@',
77
77
  icon: () => /*#__PURE__*/React.createElement(IconMention, null),
78
78
  action(insert, state) {
79
+ var _api$dependencies$ana;
79
80
  const tr = insert(undefined);
80
81
  openTypeAheadAtCursor({
81
82
  triggerHandler: typeAhead,
82
83
  inputMethod: INPUT_METHOD.QUICK_INSERT
83
84
  })(tr);
84
- return addAnalytics(state, tr, {
85
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
85
86
  action: ACTION.INVOKED,
86
87
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
87
88
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_MENTION,
@@ -89,7 +90,8 @@ const mentionsPlugin = options => {
89
90
  inputMethod: INPUT_METHOD.QUICK_INSERT
90
91
  },
91
92
  eventType: EVENT_TYPE.UI
92
- });
93
+ })(tr);
94
+ return tr;
93
95
  }
94
96
  }],
95
97
  typeAhead
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.0.2";
2
+ export const version = "185.1.1";
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.0.2",
3
+ "version": "185.1.1",
4
4
  "sideEffects": false
5
5
  }
@@ -99,7 +99,7 @@ var BreakoutView = /*#__PURE__*/function () {
99
99
  }();
100
100
  function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
101
101
  if (newBreakoutNode && currentBreakoutNode) {
102
- return !newBreakoutNode.eq(currentBreakoutNode);
102
+ return newBreakoutNode !== currentBreakoutNode;
103
103
  }
104
104
  return newBreakoutNode || currentBreakoutNode ? true : false;
105
105
  }
@@ -114,10 +114,9 @@ function createPlugin(pluginInjectionApi, _ref2) {
114
114
  },
115
115
  apply: function apply(tr, pluginState) {
116
116
  var breakoutNode = findSupportedNodeForBreakout(tr.selection);
117
- var node = breakoutNode ? breakoutNode.node : null;
118
- if (shouldPluginStateUpdate(node, pluginState.breakoutNode)) {
117
+ if (shouldPluginStateUpdate(breakoutNode, pluginState.breakoutNode)) {
119
118
  var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
120
- breakoutNode: node
119
+ breakoutNode: breakoutNode
121
120
  });
122
121
  dispatch(pluginKey, nextPluginState);
123
122
  return nextPluginState;
@@ -140,7 +139,7 @@ function createPlugin(pluginInjectionApi, _ref2) {
140
139
  });
141
140
  }
142
141
  var LayoutButtonWrapper = function LayoutButtonWrapper(_ref3) {
143
- var _breakoutState$breako;
142
+ var _breakoutState$breako, _breakoutState$breako2;
144
143
  var api = _ref3.api,
145
144
  editorView = _ref3.editorView,
146
145
  boundariesElement = _ref3.boundariesElement,
@@ -154,7 +153,7 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref3) {
154
153
  mountPoint: mountPoint,
155
154
  boundariesElement: boundariesElement,
156
155
  scrollableElement: scrollableElement,
157
- node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : breakoutState.breakoutNode) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
156
+ node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : (_breakoutState$breako2 = breakoutState.breakoutNode) === null || _breakoutState$breako2 === void 0 ? void 0 : _breakoutState$breako2.node) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
158
157
  });
159
158
  };
160
159
  var breakoutPlugin = function breakoutPlugin(options, api) {
@@ -57,7 +57,7 @@ function getBreakoutNodeElement(pluginState, selection, editorView) {
57
57
  if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
58
58
  return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
59
59
  }
60
- return findParentDomRefOfType(pluginState.breakoutNode.type, editorView.domAtPos.bind(editorView))(selection);
60
+ return findParentDomRefOfType(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
61
61
  }
62
62
  var LayoutButton = /*#__PURE__*/function (_React$Component) {
63
63
  _inherits(LayoutButton, _React$Component);
@@ -38,60 +38,59 @@ export var createMediaNodeUpdater = function createMediaNodeUpdater(props) {
38
38
  *
39
39
  */
40
40
  export var updateMediaNodeAttributes = /*#__PURE__*/function () {
41
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(props) {
42
- var mediaNodeUpdater, addPendingTask, node, contextId, hasDifferentContextId, copyNode;
41
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(props, mediaNodeUpdater) {
42
+ var addPendingTask, node, contextId, hasDifferentContextId, copyNode;
43
43
  return _regeneratorRuntime.wrap(function _callee$(_context) {
44
44
  while (1) switch (_context.prev = _context.next) {
45
45
  case 0:
46
- mediaNodeUpdater = createMediaNodeUpdater(props);
47
46
  addPendingTask = props.mediaPluginState.addPendingTask;
48
47
  node = props.node;
49
48
  if (node) {
50
- _context.next = 5;
49
+ _context.next = 4;
51
50
  break;
52
51
  }
53
52
  return _context.abrupt("return");
54
- case 5:
53
+ case 4:
55
54
  contextId = mediaNodeUpdater.getNodeContextId();
56
55
  if (contextId) {
57
- _context.next = 9;
56
+ _context.next = 8;
58
57
  break;
59
58
  }
60
- _context.next = 9;
59
+ _context.next = 8;
61
60
  return mediaNodeUpdater.updateContextId();
62
- case 9:
63
- _context.next = 11;
61
+ case 8:
62
+ _context.next = 10;
64
63
  return mediaNodeUpdater.hasDifferentContextId();
65
- case 11:
64
+ case 10:
66
65
  hasDifferentContextId = _context.sent;
67
66
  if (!hasDifferentContextId) {
68
- _context.next = 23;
67
+ _context.next = 22;
69
68
  break;
70
69
  }
71
- _context.prev = 13;
70
+ _context.prev = 12;
72
71
  copyNode = mediaNodeUpdater.copyNode({
73
72
  traceId: node.attrs.__mediaTraceId
74
73
  });
75
74
  addPendingTask(copyNode);
76
- _context.next = 18;
75
+ _context.next = 17;
77
76
  return copyNode;
78
- case 18:
79
- _context.next = 23;
77
+ case 17:
78
+ _context.next = 22;
80
79
  break;
81
- case 20:
82
- _context.prev = 20;
83
- _context.t0 = _context["catch"](13);
80
+ case 19:
81
+ _context.prev = 19;
82
+ _context.t0 = _context["catch"](12);
84
83
  return _context.abrupt("return");
85
- case 23:
86
- _context.next = 25;
84
+ case 22:
85
+ _context.next = 24;
87
86
  return mediaNodeUpdater.updateMediaSingleFileAttrs();
88
- case 25:
87
+ case 24:
89
88
  case "end":
90
89
  return _context.stop();
91
90
  }
92
- }, _callee, null, [[13, 20]]);
91
+ }, _callee, null, [[12, 19]]);
93
92
  }));
94
- return function updateMediaNodeAttributes(_x) {
93
+ return function updateMediaNodeAttributes(_x, _x2) {
95
94
  return _ref.apply(this, arguments);
96
95
  };
97
96
  }();
@@ -108,9 +107,15 @@ export var MediaInline = function MediaInline(props) {
108
107
  _useState2 = _slicedToArray(_useState, 2),
109
108
  viewMediaClientConfig = _useState2[0],
110
109
  setViewMediaClientConfig = _useState2[1];
110
+ var _useState3 = useState(true),
111
+ _useState4 = _slicedToArray(_useState3, 2),
112
+ isContextIdUnsync = _useState4[0],
113
+ setIsContextIdUnsync = _useState4[1];
111
114
  useEffect(function () {
115
+ var mediaNodeUpdater = createMediaNodeUpdater(props);
116
+ mediaNodeUpdater.hasDifferentContextId().then(setIsContextIdUnsync);
112
117
  handleNewNode(props);
113
- updateMediaNodeAttributes(props);
118
+ updateMediaNodeAttributes(props, mediaNodeUpdater);
114
119
  updateViewMediaClientConfig(props);
115
120
  return function () {
116
121
  var mediaPluginState = props.mediaPluginState;
@@ -137,7 +142,7 @@ export var MediaInline = function MediaInline(props) {
137
142
  }
138
143
  }, _callee2);
139
144
  }));
140
- return function updateViewMediaClientConfig(_x2) {
145
+ return function updateViewMediaClientConfig(_x3) {
141
146
  return _ref2.apply(this, arguments);
142
147
  };
143
148
  }();
@@ -151,10 +156,13 @@ export var MediaInline = function MediaInline(props) {
151
156
  };
152
157
 
153
158
  /*
154
- * Only show the loading view if the media provider is not ready
155
- * prevents calling the media API before the provider is ready
159
+ * Show the loading view if
160
+ * 1. The media provider is not ready
161
+ * 2. Context Id is not synced
162
+ * to prevent calling the media API (in mounting of `MediaInlineCard`)
163
+ * before the prerequisites meet
156
164
  */
157
- if (!viewMediaClientConfig) {
165
+ if (!viewMediaClientConfig || isContextIdUnsync) {
158
166
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
159
167
  message: "",
160
168
  isSelected: false
@@ -5,7 +5,7 @@ import { mention } from '@atlaskit/adf-schema';
5
5
  import WithPluginState from '../../ui/WithPluginState';
6
6
  import { isTypeAheadAllowed } from '../type-ahead/utils';
7
7
  import ToolbarMention from './ui/ToolbarMention';
8
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
8
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
9
  import { IconMention } from '../quick-insert/assets';
10
10
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
11
11
  import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
@@ -13,7 +13,7 @@ import { createTypeAheadConfig } from './type-ahead';
13
13
  import { mentionPluginKey } from './pm-plugins/key';
14
14
  import { createMentionPlugin } from './pm-plugins/main';
15
15
  export { mentionPluginKey };
16
- var mentionsPlugin = function mentionsPlugin(options) {
16
+ var mentionsPlugin = function mentionsPlugin(options, api) {
17
17
  var sessionId = uuid();
18
18
  var fireEvent = function fireEvent(payload) {
19
19
  if (!(options !== null && options !== void 0 && options.createAnalyticsEvent)) {
@@ -79,12 +79,13 @@ var mentionsPlugin = function mentionsPlugin(options) {
79
79
  return /*#__PURE__*/React.createElement(IconMention, null);
80
80
  },
81
81
  action: function action(insert, state) {
82
+ var _api$dependencies$ana;
82
83
  var tr = insert(undefined);
83
84
  openTypeAheadAtCursor({
84
85
  triggerHandler: typeAhead,
85
86
  inputMethod: INPUT_METHOD.QUICK_INSERT
86
87
  })(tr);
87
- return addAnalytics(state, tr, {
88
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
88
89
  action: ACTION.INVOKED,
89
90
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
90
91
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_MENTION,
@@ -92,7 +93,8 @@ var mentionsPlugin = function mentionsPlugin(options) {
92
93
  inputMethod: INPUT_METHOD.QUICK_INSERT
93
94
  },
94
95
  eventType: EVENT_TYPE.UI
95
- });
96
+ })(tr);
97
+ return tr;
96
98
  }
97
99
  }];
98
100
  },
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "185.0.2";
2
+ export var version = "185.1.1";
3
3
  export var nextMajorVersion = function 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.0.2",
3
+ "version": "185.1.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { Node as PMNode } from 'prosemirror-model';
1
+ import { ContentNodeWithPos } from 'prosemirror-utils';
2
2
  export interface BreakoutPluginState {
3
- breakoutNode: PMNode;
3
+ breakoutNode: ContentNodeWithPos;
4
4
  }
@@ -28,7 +28,7 @@ export declare const createMediaNodeUpdater: (props: MediaInlineProps) => MediaN
28
28
  * using the contextid
29
29
  *
30
30
  */
31
- export declare const updateMediaNodeAttributes: (props: MediaInlineProps) => Promise<void>;
31
+ export declare const updateMediaNodeAttributes: (props: MediaInlineProps, mediaNodeUpdater: MediaNodeUpdater) => Promise<void>;
32
32
  export declare const handleNewNode: (props: MediaInlineProps) => void;
33
33
  export declare const MediaInline: React.FC<MediaInlineProps>;
34
34
  export interface MediaInlineNodeViewProps {
@@ -1,8 +1,10 @@
1
- import { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import { MentionPluginOptions } from './types';
3
3
  import { mentionPluginKey } from './pm-plugins/key';
4
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
5
  export { mentionPluginKey };
5
6
  declare const mentionsPlugin: NextEditorPlugin<'mention', {
6
7
  pluginConfiguration: MentionPluginOptions | undefined;
8
+ dependencies: [OptionalPlugin<typeof analyticsPlugin>];
7
9
  }>;
8
10
  export default mentionsPlugin;
@@ -1,4 +1,4 @@
1
- import { Node as PMNode } from 'prosemirror-model';
1
+ import { ContentNodeWithPos } from 'prosemirror-utils';
2
2
  export interface BreakoutPluginState {
3
- breakoutNode: PMNode;
3
+ breakoutNode: ContentNodeWithPos;
4
4
  }
@@ -28,7 +28,7 @@ export declare const createMediaNodeUpdater: (props: MediaInlineProps) => MediaN
28
28
  * using the contextid
29
29
  *
30
30
  */
31
- export declare const updateMediaNodeAttributes: (props: MediaInlineProps) => Promise<void>;
31
+ export declare const updateMediaNodeAttributes: (props: MediaInlineProps, mediaNodeUpdater: MediaNodeUpdater) => Promise<void>;
32
32
  export declare const handleNewNode: (props: MediaInlineProps) => void;
33
33
  export declare const MediaInline: React.FC<MediaInlineProps>;
34
34
  export interface MediaInlineNodeViewProps {
@@ -1,8 +1,12 @@
1
- import { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import { MentionPluginOptions } from './types';
3
3
  import { mentionPluginKey } from './pm-plugins/key';
4
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
5
  export { mentionPluginKey };
5
6
  declare const mentionsPlugin: NextEditorPlugin<'mention', {
6
7
  pluginConfiguration: MentionPluginOptions | undefined;
8
+ dependencies: [
9
+ OptionalPlugin<typeof analyticsPlugin>
10
+ ];
7
11
  }>;
8
12
  export default mentionsPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.0.2",
3
+ "version": "185.1.1",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/activity-provider": "^2.4.0",
37
- "@atlaskit/adf-schema": "^25.7.0",
38
- "@atlaskit/adf-utils": "^18.2.0",
37
+ "@atlaskit/adf-schema": "^25.8.0",
38
+ "@atlaskit/adf-utils": "^18.3.0",
39
39
  "@atlaskit/analytics-gas-types": "^5.1.0",
40
40
  "@atlaskit/analytics-listeners": "^8.7.0",
41
41
  "@atlaskit/analytics-namespaced-context": "^6.7.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/code": "^14.6.0",
50
50
  "@atlaskit/date": "^0.10.0",
51
51
  "@atlaskit/datetime-picker": "^12.7.0",
52
- "@atlaskit/editor-common": "^74.3.0",
52
+ "@atlaskit/editor-common": "^74.4.0",
53
53
  "@atlaskit/editor-json-transformer": "^8.9.0",
54
54
  "@atlaskit/editor-markdown-transformer": "^5.2.0",
55
55
  "@atlaskit/editor-palette": "1.4.2",
@@ -72,8 +72,8 @@
72
72
  "@atlaskit/locale": "^2.5.0",
73
73
  "@atlaskit/logo": "^13.14.0",
74
74
  "@atlaskit/media-card": "^76.0.0",
75
- "@atlaskit/media-client": "^22.0.0",
76
- "@atlaskit/media-common": "^5.0.0",
75
+ "@atlaskit/media-client": "^23.0.0",
76
+ "@atlaskit/media-common": "^6.0.0",
77
77
  "@atlaskit/media-filmstrip": "^47.0.0",
78
78
  "@atlaskit/media-picker": "^66.0.0",
79
79
  "@atlaskit/media-ui": "^23.0.0",
@@ -147,9 +147,9 @@
147
147
  "devDependencies": {
148
148
  "@af/integration-testing": "*",
149
149
  "@atlaskit/atlassian-navigation": "^2.6.0",
150
- "@atlaskit/breadcrumbs": "11.10.3",
150
+ "@atlaskit/breadcrumbs": "11.10.4",
151
151
  "@atlaskit/code": "^14.6.0",
152
- "@atlaskit/collab-provider": "9.0.1",
152
+ "@atlaskit/collab-provider": "9.1.0",
153
153
  "@atlaskit/docs": "*",
154
154
  "@atlaskit/drawer": "^7.5.0",
155
155
  "@atlaskit/dropdown-menu": "^11.9.0",
@@ -183,8 +183,8 @@
183
183
  "@atlaskit/visual-regression": "*",
184
184
  "@atlaskit/webdriver-runner": "*",
185
185
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
186
- "@atlassian/link-picker-atlassian-plugin": "^32.1.0",
187
- "@atlassian/link-picker-plugins": "^22.1.0",
186
+ "@atlassian/link-picker-atlassian-plugin": "^33.0.0",
187
+ "@atlassian/link-picker-plugins": "^22.2.0",
188
188
  "@atlassian/search-provider": "2.4.4",
189
189
  "@atlassian/ufo": "^0.2.0",
190
190
  "@emotion/jest": "^11.8.0",