@atlaskit/editor-plugin-mentions 24.0.10 → 24.1.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,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 24.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`051cd10867eae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/051cd10867eae) -
|
|
8
|
+
Expose uploadStatus and mentionProviderStatus to distinguish pending providers from unavailable
|
|
9
|
+
capabilities. Under platform_editor_ssr_toolbar_optimistic, keep mention and media toolbar buttons
|
|
10
|
+
enabled while providers are pending, avoiding class changes on successful initialization while
|
|
11
|
+
preserving existing insertion restrictions.
|
|
12
|
+
|
|
13
|
+
When a view-only synchronous SSR media provider accompanies a pending full provider, keep uploads
|
|
14
|
+
pending until the full provider resolves instead of treating the SSR config as a permission
|
|
15
|
+
denial.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 24.0.10
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -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.
|
|
48
|
+
var PACKAGE_VERSION = "24.0.10";
|
|
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
|
}
|
|
@@ -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.
|
|
37
|
+
const PACKAGE_VERSION = "24.0.10";
|
|
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
|
}
|
|
@@ -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.
|
|
40
|
+
var PACKAGE_VERSION = "24.0.10";
|
|
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
|
}
|
|
@@ -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
|
|
3
|
+
"version": "24.1.0",
|
|
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.
|
|
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",
|