@atlaskit/editor-plugin-mentions 24.0.10 → 24.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,31 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 24.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a726b246b3166`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a726b246b3166) -
8
+ Clean up feature gate `platform_editor_agent_card_close_on_chat`
9
+ - Updated dependencies
10
+
11
+ ## 24.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`051cd10867eae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/051cd10867eae) -
16
+ Expose uploadStatus and mentionProviderStatus to distinguish pending providers from unavailable
17
+ capabilities. Under platform_editor_ssr_toolbar_optimistic, keep mention and media toolbar buttons
18
+ enabled while providers are pending, avoiding class changes on successful initialization while
19
+ preserving existing insertion restrictions.
20
+
21
+ When a view-only synchronous SSR media provider accompanies a pending full provider, keep uploads
22
+ pending until the full provider resolves instead of treating the SSR config as a permission
23
+ denial.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+
3
29
  ## 24.0.10
4
30
 
5
31
  ### Patch Changes
@@ -107,7 +107,7 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
107
107
  // The mention stays node-selected after the chat opens; collapse the
108
108
  // selection to a cursor just after it so it is no longer left selected.
109
109
  // Selection-only change, so it does not move focus (EDITOR-8257).
110
- if (editorView && (0, _fg.fg)('platform_editor_agent_card_close_on_chat')) {
110
+ if (editorView) {
111
111
  var state = editorView.state;
112
112
  editorView.dispatch(state.tr.setSelection(_state.TextSelection.create(state.doc, state.selection.to)));
113
113
  }
@@ -12,6 +12,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
12
  var _insm = require("@atlaskit/insm");
13
13
  var _analytics2 = require("@atlaskit/mention/analytics");
14
14
  var _types = require("@atlaskit/mention/types");
15
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
15
16
  var _fg = require("@atlaskit/platform-feature-flags/fg");
16
17
  var _isMentionTypeAheadEnabled = require("../isMentionTypeAheadEnabled");
17
18
  var _mentionNodeView = require("../nodeviews/mentionNodeView");
@@ -44,7 +45,7 @@ var ACTIONS = exports.ACTIONS = {
44
45
  CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
45
46
  };
46
47
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
47
- var PACKAGE_VERSION = "24.0.9";
48
+ var PACKAGE_VERSION = "24.1.0";
48
49
  var setProvider = function setProvider(provider) {
49
50
  return function (state, dispatch) {
50
51
  if (dispatch) {
@@ -86,7 +87,8 @@ function createMentionPlugin(_ref) {
86
87
  state: {
87
88
  init: function init(_, state) {
88
89
  return {
89
- canInsertMention: isMentionInsertionEnabled(state)
90
+ canInsertMention: isMentionInsertionEnabled(state),
91
+ mentionProviderStatus: 'pending'
90
92
  };
91
93
  },
92
94
  apply: function apply(tr, pluginState, oldState, newState) {
@@ -108,7 +110,8 @@ function createMentionPlugin(_ref) {
108
110
  switch (action) {
109
111
  case ACTIONS.SET_PROVIDER:
110
112
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
111
- mentionProvider: params.provider
113
+ mentionProvider: params.provider,
114
+ mentionProviderStatus: params.provider ? 'available' : 'unavailable'
112
115
  });
113
116
  hasPublicPluginStateChanged = true;
114
117
  break;
@@ -191,9 +194,13 @@ function createMentionPlugin(_ref) {
191
194
  }
192
195
  },
193
196
  view: function view(editorView) {
197
+ var destroyed = false;
198
+ var optimistic = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ssr_toolbar_optimistic');
199
+ var currentProviderPromise;
194
200
  var providerHandler = function providerHandler(name, providerPromise) {
195
201
  switch (name) {
196
202
  case 'mentionProvider':
203
+ currentProviderPromise = providerPromise;
197
204
  if (!providerPromise) {
198
205
  fireEvent({
199
206
  action: _analytics.ACTION.ERRORED,
@@ -207,6 +214,9 @@ function createMentionPlugin(_ref) {
207
214
  return setProvider(undefined)(editorView.state, editorView.dispatch);
208
215
  }
209
216
  providerPromise.then(function (provider) {
217
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
218
+ return;
219
+ }
210
220
  if (mentionProvider) {
211
221
  mentionProvider.unsubscribe('mentionPlugin');
212
222
  }
@@ -214,6 +224,9 @@ function createMentionPlugin(_ref) {
214
224
  setProvider(provider)(editorView.state, editorView.dispatch);
215
225
  provider.subscribe('mentionPlugin', undefined, undefined, undefined, undefined, sendAnalytics);
216
226
  }).catch(function () {
227
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
228
+ return;
229
+ }
217
230
  fireEvent({
218
231
  action: _analytics.ACTION.ERRORED,
219
232
  actionSubject: _analytics.ACTION_SUBJECT.MENTION,
@@ -234,9 +247,19 @@ function createMentionPlugin(_ref) {
234
247
  providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
235
248
  } else {
236
249
  pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
250
+ if (optimistic) {
251
+ // Subscribe does not notify us when no provider exists. Wait until the view
252
+ // has finished mounting before publishing the unavailable state.
253
+ Promise.resolve().then(function () {
254
+ if (!destroyed && !pmPluginFactoryParams.providerFactory.hasProvider('mentionProvider')) {
255
+ setProvider(undefined)(editorView.state, editorView.dispatch);
256
+ }
257
+ });
258
+ }
237
259
  }
238
260
  return {
239
261
  destroy: function destroy() {
262
+ destroyed = true;
240
263
  if (pmPluginFactoryParams.providerFactory) {
241
264
  pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
242
265
  }
@@ -233,9 +233,7 @@ function ProfileCardComponent(_ref6) {
233
233
  // closure built by profileCardRenderer at chip-click time via doc.descendants()
234
234
  onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
235
235
  // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
236
- if ((0, _fg.fg)('platform_editor_agent_card_close_on_chat')) {
237
- closeComponent();
238
- }
236
+ closeComponent();
239
237
  } : undefined
240
238
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
241
239
  accessLevel: accessLevel,
@@ -96,7 +96,7 @@ export const profileCardRenderer = ({
96
96
  // The mention stays node-selected after the chat opens; collapse the
97
97
  // selection to a cursor just after it so it is no longer left selected.
98
98
  // Selection-only change, so it does not move focus (EDITOR-8257).
99
- if (editorView && fg('platform_editor_agent_card_close_on_chat')) {
99
+ if (editorView) {
100
100
  const {
101
101
  state
102
102
  } = editorView;
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { insm } from '@atlaskit/insm';
4
4
  import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/analytics';
5
5
  import { ComponentNames } from '@atlaskit/mention/types';
6
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
6
7
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
8
  import { isMentionTypeAheadEnabled } from '../isMentionTypeAheadEnabled';
8
9
  import { MentionNodeView } from '../nodeviews/mentionNodeView';
@@ -33,7 +34,7 @@ export const ACTIONS = {
33
34
  CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
34
35
  };
35
36
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
36
- const PACKAGE_VERSION = "24.0.9";
37
+ const PACKAGE_VERSION = "24.1.0";
37
38
  const setProvider = provider => (state, dispatch) => {
38
39
  if (dispatch) {
39
40
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -73,7 +74,8 @@ export function createMentionPlugin({
73
74
  state: {
74
75
  init(_, state) {
75
76
  return {
76
- canInsertMention: isMentionInsertionEnabled(state)
77
+ canInsertMention: isMentionInsertionEnabled(state),
78
+ mentionProviderStatus: 'pending'
77
79
  };
78
80
  },
79
81
  apply(tr, pluginState, oldState, newState) {
@@ -98,7 +100,8 @@ export function createMentionPlugin({
98
100
  case ACTIONS.SET_PROVIDER:
99
101
  newPluginState = {
100
102
  ...newPluginState,
101
- mentionProvider: params.provider
103
+ mentionProvider: params.provider,
104
+ mentionProviderStatus: params.provider ? 'available' : 'unavailable'
102
105
  };
103
106
  hasPublicPluginStateChanged = true;
104
107
  break;
@@ -179,9 +182,13 @@ export function createMentionPlugin({
179
182
  }
180
183
  },
181
184
  view(editorView) {
185
+ let destroyed = false;
186
+ const optimistic = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
187
+ let currentProviderPromise;
182
188
  const providerHandler = (name, providerPromise) => {
183
189
  switch (name) {
184
190
  case 'mentionProvider':
191
+ currentProviderPromise = providerPromise;
185
192
  if (!providerPromise) {
186
193
  fireEvent({
187
194
  action: ACTION.ERRORED,
@@ -195,6 +202,9 @@ export function createMentionPlugin({
195
202
  return setProvider(undefined)(editorView.state, editorView.dispatch);
196
203
  }
197
204
  providerPromise.then(provider => {
205
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
206
+ return;
207
+ }
198
208
  if (mentionProvider) {
199
209
  mentionProvider.unsubscribe('mentionPlugin');
200
210
  }
@@ -202,6 +212,9 @@ export function createMentionPlugin({
202
212
  setProvider(provider)(editorView.state, editorView.dispatch);
203
213
  provider.subscribe('mentionPlugin', undefined, undefined, undefined, undefined, sendAnalytics);
204
214
  }).catch(() => {
215
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
216
+ return;
217
+ }
205
218
  fireEvent({
206
219
  action: ACTION.ERRORED,
207
220
  actionSubject: ACTION_SUBJECT.MENTION,
@@ -222,9 +235,19 @@ export function createMentionPlugin({
222
235
  providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
223
236
  } else {
224
237
  pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
238
+ if (optimistic) {
239
+ // Subscribe does not notify us when no provider exists. Wait until the view
240
+ // has finished mounting before publishing the unavailable state.
241
+ Promise.resolve().then(() => {
242
+ if (!destroyed && !pmPluginFactoryParams.providerFactory.hasProvider('mentionProvider')) {
243
+ setProvider(undefined)(editorView.state, editorView.dispatch);
244
+ }
245
+ });
246
+ }
225
247
  }
226
248
  return {
227
249
  destroy() {
250
+ destroyed = true;
228
251
  if (pmPluginFactoryParams.providerFactory) {
229
252
  pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
230
253
  }
@@ -157,9 +157,7 @@ export function ProfileCardComponent({
157
157
  // closure built by profileCardRenderer at chip-click time via doc.descendants()
158
158
  onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
159
159
  // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
160
- if (fg('platform_editor_agent_card_close_on_chat')) {
161
- closeComponent();
162
- }
160
+ closeComponent();
163
161
  } : undefined
164
162
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
165
163
  accessLevel: accessLevel,
@@ -101,7 +101,7 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
101
101
  // The mention stays node-selected after the chat opens; collapse the
102
102
  // selection to a cursor just after it so it is no longer left selected.
103
103
  // Selection-only change, so it does not move focus (EDITOR-8257).
104
- if (editorView && fg('platform_editor_agent_card_close_on_chat')) {
104
+ if (editorView) {
105
105
  var state = editorView.state;
106
106
  editorView.dispatch(state.tr.setSelection(TextSelection.create(state.doc, state.selection.to)));
107
107
  }
@@ -6,6 +6,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { insm } from '@atlaskit/insm';
7
7
  import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/analytics';
8
8
  import { ComponentNames } from '@atlaskit/mention/types';
9
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
10
  import { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { isMentionTypeAheadEnabled } from '../isMentionTypeAheadEnabled';
11
12
  import { MentionNodeView } from '../nodeviews/mentionNodeView';
@@ -36,7 +37,7 @@ export var ACTIONS = {
36
37
  CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
37
38
  };
38
39
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
39
- var PACKAGE_VERSION = "24.0.9";
40
+ var PACKAGE_VERSION = "24.1.0";
40
41
  var setProvider = function setProvider(provider) {
41
42
  return function (state, dispatch) {
42
43
  if (dispatch) {
@@ -78,7 +79,8 @@ export function createMentionPlugin(_ref) {
78
79
  state: {
79
80
  init: function init(_, state) {
80
81
  return {
81
- canInsertMention: isMentionInsertionEnabled(state)
82
+ canInsertMention: isMentionInsertionEnabled(state),
83
+ mentionProviderStatus: 'pending'
82
84
  };
83
85
  },
84
86
  apply: function apply(tr, pluginState, oldState, newState) {
@@ -100,7 +102,8 @@ export function createMentionPlugin(_ref) {
100
102
  switch (action) {
101
103
  case ACTIONS.SET_PROVIDER:
102
104
  newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
103
- mentionProvider: params.provider
105
+ mentionProvider: params.provider,
106
+ mentionProviderStatus: params.provider ? 'available' : 'unavailable'
104
107
  });
105
108
  hasPublicPluginStateChanged = true;
106
109
  break;
@@ -183,9 +186,13 @@ export function createMentionPlugin(_ref) {
183
186
  }
184
187
  },
185
188
  view: function view(editorView) {
189
+ var destroyed = false;
190
+ var optimistic = isExperimentEnabled('platform_editor_ssr_toolbar_optimistic');
191
+ var currentProviderPromise;
186
192
  var providerHandler = function providerHandler(name, providerPromise) {
187
193
  switch (name) {
188
194
  case 'mentionProvider':
195
+ currentProviderPromise = providerPromise;
189
196
  if (!providerPromise) {
190
197
  fireEvent({
191
198
  action: ACTION.ERRORED,
@@ -199,6 +206,9 @@ export function createMentionPlugin(_ref) {
199
206
  return setProvider(undefined)(editorView.state, editorView.dispatch);
200
207
  }
201
208
  providerPromise.then(function (provider) {
209
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
210
+ return;
211
+ }
202
212
  if (mentionProvider) {
203
213
  mentionProvider.unsubscribe('mentionPlugin');
204
214
  }
@@ -206,6 +216,9 @@ export function createMentionPlugin(_ref) {
206
216
  setProvider(provider)(editorView.state, editorView.dispatch);
207
217
  provider.subscribe('mentionPlugin', undefined, undefined, undefined, undefined, sendAnalytics);
208
218
  }).catch(function () {
219
+ if (optimistic && (destroyed || currentProviderPromise !== providerPromise)) {
220
+ return;
221
+ }
209
222
  fireEvent({
210
223
  action: ACTION.ERRORED,
211
224
  actionSubject: ACTION_SUBJECT.MENTION,
@@ -226,9 +239,19 @@ export function createMentionPlugin(_ref) {
226
239
  providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
227
240
  } else {
228
241
  pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
242
+ if (optimistic) {
243
+ // Subscribe does not notify us when no provider exists. Wait until the view
244
+ // has finished mounting before publishing the unavailable state.
245
+ Promise.resolve().then(function () {
246
+ if (!destroyed && !pmPluginFactoryParams.providerFactory.hasProvider('mentionProvider')) {
247
+ setProvider(undefined)(editorView.state, editorView.dispatch);
248
+ }
249
+ });
250
+ }
229
251
  }
230
252
  return {
231
253
  destroy: function destroy() {
254
+ destroyed = true;
232
255
  if (pmPluginFactoryParams.providerFactory) {
233
256
  pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
234
257
  }
@@ -221,9 +221,7 @@ export function ProfileCardComponent(_ref6) {
221
221
  // closure built by profileCardRenderer at chip-click time via doc.descendants()
222
222
  onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
223
223
  // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
224
- if (fg('platform_editor_agent_card_close_on_chat')) {
225
- closeComponent();
226
- }
224
+ closeComponent();
227
225
  } : undefined
228
226
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
229
227
  accessLevel: accessLevel,
@@ -140,6 +140,8 @@ export type MentionPluginState = {
140
140
  */
141
141
  lastInsertedAgentMentionPrompt?: string | null;
142
142
  mentionProvider?: MentionProvider;
143
+ /** Initial provider resolution, separate from whether the selection allows mentions. */
144
+ mentionProviderStatus?: 'pending' | 'available' | 'unavailable';
143
145
  mentions?: Array<MentionDescription>;
144
146
  /**
145
147
  * @internal Tracks a pasted agent mention pending name resolution (cache miss).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "24.0.10",
3
+ "version": "24.1.1",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "@atlaskit/platform-feature-experiments": "^0.3.0",
41
41
  "@atlaskit/platform-feature-flags": "^2.2.0",
42
42
  "@atlaskit/popper": "^9.4.0",
43
- "@atlaskit/popup": "^8.0.0",
43
+ "@atlaskit/popup": "^8.1.0",
44
44
  "@atlaskit/portal": "^7.0.0",
45
45
  "@atlaskit/primitives": "^22.5.0",
46
46
  "@atlaskit/profilecard": "^27.1.0",
@@ -102,9 +102,6 @@
102
102
  "platform_editor_agent_mentions_drop_one_fixes": {
103
103
  "type": "boolean"
104
104
  },
105
- "platform_editor_agent_card_close_on_chat": {
106
- "type": "boolean"
107
- },
108
105
  "platform_editor_mention_typeahead_profilecard": {
109
106
  "type": "boolean"
110
107
  },