@atlaskit/editor-plugin-mentions 24.0.1 → 24.0.2
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 +11 -0
- package/dist/cjs/nodeviews/mentionAvatarRenderer.js +15 -1
- package/dist/cjs/nodeviews/mentionNodeView.js +42 -5
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/nodeviews/mentionAvatarRenderer.js +15 -1
- package/dist/es2019/nodeviews/mentionNodeView.js +38 -3
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/nodeviews/mentionAvatarRenderer.js +15 -1
- package/dist/esm/nodeviews/mentionNodeView.js +43 -6
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/nodeviews/mentionAvatarRenderer.d.ts +2 -1
- package/dist/types/nodeviews/mentionNodeView.d.ts +1 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 24.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`534c9253b7fab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/534c9253b7fab) -
|
|
8
|
+
Add operational mention avatar failure events and reasons behind
|
|
9
|
+
`platform_editor_mention_avatar_observability`, covering image failures, provider failures,
|
|
10
|
+
missing avatar URLs, and missing providers. Events identify the editor or renderer surface without
|
|
11
|
+
adding mention user data. Successful image loads emit no events.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 24.0.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -14,9 +14,18 @@ var avatarSize = 16;
|
|
|
14
14
|
* No React root or editor portal is created for individual mention nodes.
|
|
15
15
|
*/
|
|
16
16
|
var mentionAvatarRenderer = exports.mentionAvatarRenderer = function mentionAvatarRenderer(_ref) {
|
|
17
|
-
var container = _ref.container
|
|
17
|
+
var container = _ref.container,
|
|
18
|
+
onFailure = _ref.onFailure;
|
|
18
19
|
var image;
|
|
19
20
|
var fallback;
|
|
21
|
+
var failureReported = false;
|
|
22
|
+
var currentUrl;
|
|
23
|
+
var reportFailure = function reportFailure() {
|
|
24
|
+
if (!failureReported) {
|
|
25
|
+
failureReported = true;
|
|
26
|
+
onFailure === null || onFailure === void 0 || onFailure();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
20
29
|
var unbindImageError;
|
|
21
30
|
var removeImage = function removeImage() {
|
|
22
31
|
var _unbindImageError, _image;
|
|
@@ -32,6 +41,7 @@ var mentionAvatarRenderer = exports.mentionAvatarRenderer = function mentionAvat
|
|
|
32
41
|
container.classList.remove(fallbackAvatarClassName);
|
|
33
42
|
};
|
|
34
43
|
var showFallback = function showFallback() {
|
|
44
|
+
reportFailure();
|
|
35
45
|
removeImage();
|
|
36
46
|
removeFallback();
|
|
37
47
|
fallback = container.ownerDocument.createTextNode('@');
|
|
@@ -54,6 +64,10 @@ var mentionAvatarRenderer = exports.mentionAvatarRenderer = function mentionAvat
|
|
|
54
64
|
removeImage();
|
|
55
65
|
return;
|
|
56
66
|
}
|
|
67
|
+
if (!image || currentUrl !== avatarUrl) {
|
|
68
|
+
failureReported = false;
|
|
69
|
+
currentUrl = avatarUrl;
|
|
70
|
+
}
|
|
57
71
|
if (!image) {
|
|
58
72
|
image = container.ownerDocument.createElement('img');
|
|
59
73
|
image.alt = '';
|
|
@@ -165,17 +165,36 @@ var getNewState = function getNewState(isHighlighted, isRestricted, isDisabled)
|
|
|
165
165
|
};
|
|
166
166
|
var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
167
167
|
function MentionNodeView(node, config) {
|
|
168
|
-
var _this
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
var _this = this,
|
|
169
|
+
_this$domElement$quer,
|
|
170
|
+
_api$mention$sharedSt;
|
|
171
171
|
(0, _classCallCheck2.default)(this, MentionNodeView);
|
|
172
172
|
(0, _defineProperty2.default)(this, "hasAvatarSlot", false);
|
|
173
173
|
(0, _defineProperty2.default)(this, "isDestroyed", false);
|
|
174
|
+
(0, _defineProperty2.default)(this, "reportAvatarFailure", function (reason) {
|
|
175
|
+
if (!_this.isDestroyed && (0, _fg.fg)('platform_editor_mention_avatar_observability')) {
|
|
176
|
+
var _this$config$api;
|
|
177
|
+
var payload = {
|
|
178
|
+
action: 'failed',
|
|
179
|
+
actionSubject: 'mentionAvatar',
|
|
180
|
+
eventType: 'operational',
|
|
181
|
+
attributes: {
|
|
182
|
+
componentName: 'mention',
|
|
183
|
+
reason: reason,
|
|
184
|
+
surface: 'editor'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
(_this$config$api = _this.config.api) === null || _this$config$api === void 0 || (_this$config$api = _this$config$api.analytics) === null || _this$config$api === void 0 || _this$config$api.actions.fireAnalyticsEvent(payload, _constants.ELEMENTS_CHANNEL);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
174
190
|
var options = config.options,
|
|
175
191
|
api = config.api,
|
|
176
192
|
portalProviderAPI = config.portalProviderAPI,
|
|
177
193
|
editorView = config.editorView;
|
|
178
|
-
|
|
194
|
+
var hasProvider = Boolean(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
195
|
+
var canReportMissingProvider = !hasProvider && (0, _fg.fg)('platform_editor_mention_avatar_observability');
|
|
196
|
+
var isAvatarEnabled = (hasProvider || canReportMissingProvider) && node.attrs.userType !== 'SPECIAL' && !genericMentionIds.includes(node.attrs.id) && ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_node_avatar') || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_node_graphql_provider'));
|
|
197
|
+
this.hasAvatarSlot = hasProvider && isAvatarEnabled;
|
|
179
198
|
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(node, this.hasAvatarSlot)),
|
|
180
199
|
dom = _DOMSerializer$render.dom,
|
|
181
200
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
@@ -183,6 +202,9 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
183
202
|
this.contentDOM = contentDOM;
|
|
184
203
|
this.config = config;
|
|
185
204
|
this.node = node;
|
|
205
|
+
if (canReportMissingProvider && isAvatarEnabled) {
|
|
206
|
+
this.reportAvatarFailure('missing_provider');
|
|
207
|
+
}
|
|
186
208
|
this.domElement = dom instanceof HTMLElement ? dom : undefined;
|
|
187
209
|
this.mentionPrimitiveElement = this.domElement ? (_this$domElement$quer = this.domElement.querySelector(".".concat(primitiveClassName))) !== null && _this$domElement$quer !== void 0 ? _this$domElement$quer : undefined : undefined;
|
|
188
210
|
this.mentionTextElement = this.mentionPrimitiveElement;
|
|
@@ -192,7 +214,10 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
192
214
|
var avatarContainer = (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.querySelector(".".concat(avatarContainerClassName));
|
|
193
215
|
if (avatarContainer) {
|
|
194
216
|
this.mentionAvatar = (0, _mentionAvatarRenderer.mentionAvatarRenderer)({
|
|
195
|
-
container: avatarContainer
|
|
217
|
+
container: avatarContainer,
|
|
218
|
+
onFailure: function onFailure() {
|
|
219
|
+
return _this.reportAvatarFailure('image_load_failed');
|
|
220
|
+
}
|
|
196
221
|
});
|
|
197
222
|
this.resolveMentionAvatar(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
198
223
|
}
|
|
@@ -504,7 +529,19 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
504
529
|
}
|
|
505
530
|
(_this3$mentionAvatar = _this3.mentionAvatar) === null || _this3$mentionAvatar === void 0 || _this3$mentionAvatar.render(data);
|
|
506
531
|
};
|
|
532
|
+
var failureReported = false;
|
|
507
533
|
mentionNodeDataProvider.getMentionData(mention, function (payload) {
|
|
534
|
+
if (_this3.isDestroyed) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (!failureReported && (payload.error || payload.data && !payload.data.avatarUrl)) {
|
|
538
|
+
failureReported = true;
|
|
539
|
+
if (payload.error) {
|
|
540
|
+
_this3.reportAvatarFailure('provider_failed');
|
|
541
|
+
} else if (payload.data && !payload.data.avatarUrl) {
|
|
542
|
+
_this3.reportAvatarFailure('missing_avatar_url');
|
|
543
|
+
}
|
|
544
|
+
}
|
|
508
545
|
if (payload.data) {
|
|
509
546
|
applyData(payload.data);
|
|
510
547
|
}
|
|
@@ -44,7 +44,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
44
44
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
45
45
|
};
|
|
46
46
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
47
|
-
var PACKAGE_VERSION = "24.0.
|
|
47
|
+
var PACKAGE_VERSION = "24.0.1";
|
|
48
48
|
var setProvider = function setProvider(provider) {
|
|
49
49
|
return function (state, dispatch) {
|
|
50
50
|
if (dispatch) {
|
|
@@ -8,10 +8,19 @@ const avatarSize = 16;
|
|
|
8
8
|
* No React root or editor portal is created for individual mention nodes.
|
|
9
9
|
*/
|
|
10
10
|
export const mentionAvatarRenderer = ({
|
|
11
|
-
container
|
|
11
|
+
container,
|
|
12
|
+
onFailure
|
|
12
13
|
}) => {
|
|
13
14
|
let image;
|
|
14
15
|
let fallback;
|
|
16
|
+
let failureReported = false;
|
|
17
|
+
let currentUrl;
|
|
18
|
+
const reportFailure = () => {
|
|
19
|
+
if (!failureReported) {
|
|
20
|
+
failureReported = true;
|
|
21
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
15
24
|
let unbindImageError;
|
|
16
25
|
const removeImage = () => {
|
|
17
26
|
var _unbindImageError, _image;
|
|
@@ -27,6 +36,7 @@ export const mentionAvatarRenderer = ({
|
|
|
27
36
|
container.classList.remove(fallbackAvatarClassName);
|
|
28
37
|
};
|
|
29
38
|
const showFallback = () => {
|
|
39
|
+
reportFailure();
|
|
30
40
|
removeImage();
|
|
31
41
|
removeFallback();
|
|
32
42
|
fallback = container.ownerDocument.createTextNode('@');
|
|
@@ -50,6 +60,10 @@ export const mentionAvatarRenderer = ({
|
|
|
50
60
|
removeImage();
|
|
51
61
|
return;
|
|
52
62
|
}
|
|
63
|
+
if (!image || currentUrl !== avatarUrl) {
|
|
64
|
+
failureReported = false;
|
|
65
|
+
currentUrl = avatarUrl;
|
|
66
|
+
}
|
|
53
67
|
if (!image) {
|
|
54
68
|
image = container.ownerDocument.createElement('img');
|
|
55
69
|
image.alt = '';
|
|
@@ -7,7 +7,7 @@ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
|
7
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
// oxlint-disable-next-line import/no-duplicates
|
|
9
9
|
|
|
10
|
-
import { UNKNOWN_USER_ID } from '@atlaskit/mention/constants';
|
|
10
|
+
import { ELEMENTS_CHANNEL, UNKNOWN_USER_ID } from '@atlaskit/mention/constants';
|
|
11
11
|
import { isResolvingMentionProvider } from '@atlaskit/mention/is-resolving-mention-provider';
|
|
12
12
|
import { isRestricted } from '@atlaskit/mention/is-restricted';
|
|
13
13
|
import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
@@ -132,13 +132,32 @@ export class MentionNodeView {
|
|
|
132
132
|
var _this$domElement$quer, _api$mention$sharedSt;
|
|
133
133
|
_defineProperty(this, "hasAvatarSlot", false);
|
|
134
134
|
_defineProperty(this, "isDestroyed", false);
|
|
135
|
+
_defineProperty(this, "reportAvatarFailure", reason => {
|
|
136
|
+
if (!this.isDestroyed && fg('platform_editor_mention_avatar_observability')) {
|
|
137
|
+
var _this$config$api, _this$config$api$anal;
|
|
138
|
+
const payload = {
|
|
139
|
+
action: 'failed',
|
|
140
|
+
actionSubject: 'mentionAvatar',
|
|
141
|
+
eventType: 'operational',
|
|
142
|
+
attributes: {
|
|
143
|
+
componentName: 'mention',
|
|
144
|
+
reason,
|
|
145
|
+
surface: 'editor'
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
(_this$config$api = this.config.api) === null || _this$config$api === void 0 ? void 0 : (_this$config$api$anal = _this$config$api.analytics) === null || _this$config$api$anal === void 0 ? void 0 : _this$config$api$anal.actions.fireAnalyticsEvent(payload, ELEMENTS_CHANNEL);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
135
151
|
const {
|
|
136
152
|
options,
|
|
137
153
|
api,
|
|
138
154
|
portalProviderAPI,
|
|
139
155
|
editorView
|
|
140
156
|
} = config;
|
|
141
|
-
|
|
157
|
+
const hasProvider = Boolean(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
158
|
+
const canReportMissingProvider = !hasProvider && fg('platform_editor_mention_avatar_observability');
|
|
159
|
+
const isAvatarEnabled = (hasProvider || canReportMissingProvider) && node.attrs.userType !== 'SPECIAL' && !genericMentionIds.includes(node.attrs.id) && (isExperimentEnabled('platform_editor_mention_node_avatar') || isExperimentEnabled('platform_editor_mention_node_graphql_provider'));
|
|
160
|
+
this.hasAvatarSlot = hasProvider && isAvatarEnabled;
|
|
142
161
|
const {
|
|
143
162
|
dom,
|
|
144
163
|
contentDOM
|
|
@@ -147,6 +166,9 @@ export class MentionNodeView {
|
|
|
147
166
|
this.contentDOM = contentDOM;
|
|
148
167
|
this.config = config;
|
|
149
168
|
this.node = node;
|
|
169
|
+
if (canReportMissingProvider && isAvatarEnabled) {
|
|
170
|
+
this.reportAvatarFailure('missing_provider');
|
|
171
|
+
}
|
|
150
172
|
this.domElement = dom instanceof HTMLElement ? dom : undefined;
|
|
151
173
|
this.mentionPrimitiveElement = this.domElement ? (_this$domElement$quer = this.domElement.querySelector(`.${primitiveClassName}`)) !== null && _this$domElement$quer !== void 0 ? _this$domElement$quer : undefined : undefined;
|
|
152
174
|
this.mentionTextElement = this.mentionPrimitiveElement;
|
|
@@ -156,7 +178,8 @@ export class MentionNodeView {
|
|
|
156
178
|
const avatarContainer = (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.querySelector(`.${avatarContainerClassName}`);
|
|
157
179
|
if (avatarContainer) {
|
|
158
180
|
this.mentionAvatar = mentionAvatarRenderer({
|
|
159
|
-
container: avatarContainer
|
|
181
|
+
container: avatarContainer,
|
|
182
|
+
onFailure: () => this.reportAvatarFailure('image_load_failed')
|
|
160
183
|
});
|
|
161
184
|
this.resolveMentionAvatar(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
162
185
|
}
|
|
@@ -411,7 +434,19 @@ export class MentionNodeView {
|
|
|
411
434
|
}
|
|
412
435
|
(_this$mentionAvatar = this.mentionAvatar) === null || _this$mentionAvatar === void 0 ? void 0 : _this$mentionAvatar.render(data);
|
|
413
436
|
};
|
|
437
|
+
let failureReported = false;
|
|
414
438
|
mentionNodeDataProvider.getMentionData(mention, payload => {
|
|
439
|
+
if (this.isDestroyed) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (!failureReported && (payload.error || payload.data && !payload.data.avatarUrl)) {
|
|
443
|
+
failureReported = true;
|
|
444
|
+
if (payload.error) {
|
|
445
|
+
this.reportAvatarFailure('provider_failed');
|
|
446
|
+
} else if (payload.data && !payload.data.avatarUrl) {
|
|
447
|
+
this.reportAvatarFailure('missing_avatar_url');
|
|
448
|
+
}
|
|
449
|
+
}
|
|
415
450
|
if (payload.data) {
|
|
416
451
|
applyData(payload.data);
|
|
417
452
|
}
|
|
@@ -33,7 +33,7 @@ export const ACTIONS = {
|
|
|
33
33
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
34
34
|
};
|
|
35
35
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
36
|
-
const PACKAGE_VERSION = "24.0.
|
|
36
|
+
const PACKAGE_VERSION = "24.0.1";
|
|
37
37
|
const setProvider = provider => (state, dispatch) => {
|
|
38
38
|
if (dispatch) {
|
|
39
39
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -8,9 +8,18 @@ var avatarSize = 16;
|
|
|
8
8
|
* No React root or editor portal is created for individual mention nodes.
|
|
9
9
|
*/
|
|
10
10
|
export var mentionAvatarRenderer = function mentionAvatarRenderer(_ref) {
|
|
11
|
-
var container = _ref.container
|
|
11
|
+
var container = _ref.container,
|
|
12
|
+
onFailure = _ref.onFailure;
|
|
12
13
|
var image;
|
|
13
14
|
var fallback;
|
|
15
|
+
var failureReported = false;
|
|
16
|
+
var currentUrl;
|
|
17
|
+
var reportFailure = function reportFailure() {
|
|
18
|
+
if (!failureReported) {
|
|
19
|
+
failureReported = true;
|
|
20
|
+
onFailure === null || onFailure === void 0 || onFailure();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
14
23
|
var unbindImageError;
|
|
15
24
|
var removeImage = function removeImage() {
|
|
16
25
|
var _unbindImageError, _image;
|
|
@@ -26,6 +35,7 @@ export var mentionAvatarRenderer = function mentionAvatarRenderer(_ref) {
|
|
|
26
35
|
container.classList.remove(fallbackAvatarClassName);
|
|
27
36
|
};
|
|
28
37
|
var showFallback = function showFallback() {
|
|
38
|
+
reportFailure();
|
|
29
39
|
removeImage();
|
|
30
40
|
removeFallback();
|
|
31
41
|
fallback = container.ownerDocument.createTextNode('@');
|
|
@@ -48,6 +58,10 @@ export var mentionAvatarRenderer = function mentionAvatarRenderer(_ref) {
|
|
|
48
58
|
removeImage();
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
61
|
+
if (!image || currentUrl !== avatarUrl) {
|
|
62
|
+
failureReported = false;
|
|
63
|
+
currentUrl = avatarUrl;
|
|
64
|
+
}
|
|
51
65
|
if (!image) {
|
|
52
66
|
image = container.ownerDocument.createElement('img');
|
|
53
67
|
image.alt = '';
|
|
@@ -13,7 +13,7 @@ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
|
13
13
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
14
14
|
// oxlint-disable-next-line import/no-duplicates
|
|
15
15
|
|
|
16
|
-
import { UNKNOWN_USER_ID } from '@atlaskit/mention/constants';
|
|
16
|
+
import { ELEMENTS_CHANNEL, UNKNOWN_USER_ID } from '@atlaskit/mention/constants';
|
|
17
17
|
import { isResolvingMentionProvider } from '@atlaskit/mention/is-resolving-mention-provider';
|
|
18
18
|
import { isRestricted } from '@atlaskit/mention/is-restricted';
|
|
19
19
|
import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
@@ -160,17 +160,36 @@ var getNewState = function getNewState(isHighlighted, isRestricted, isDisabled)
|
|
|
160
160
|
};
|
|
161
161
|
export var MentionNodeView = /*#__PURE__*/function () {
|
|
162
162
|
function MentionNodeView(node, config) {
|
|
163
|
-
var _this
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
var _this = this,
|
|
164
|
+
_this$domElement$quer,
|
|
165
|
+
_api$mention$sharedSt;
|
|
166
166
|
_classCallCheck(this, MentionNodeView);
|
|
167
167
|
_defineProperty(this, "hasAvatarSlot", false);
|
|
168
168
|
_defineProperty(this, "isDestroyed", false);
|
|
169
|
+
_defineProperty(this, "reportAvatarFailure", function (reason) {
|
|
170
|
+
if (!_this.isDestroyed && fg('platform_editor_mention_avatar_observability')) {
|
|
171
|
+
var _this$config$api;
|
|
172
|
+
var payload = {
|
|
173
|
+
action: 'failed',
|
|
174
|
+
actionSubject: 'mentionAvatar',
|
|
175
|
+
eventType: 'operational',
|
|
176
|
+
attributes: {
|
|
177
|
+
componentName: 'mention',
|
|
178
|
+
reason: reason,
|
|
179
|
+
surface: 'editor'
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
(_this$config$api = _this.config.api) === null || _this$config$api === void 0 || (_this$config$api = _this$config$api.analytics) === null || _this$config$api === void 0 || _this$config$api.actions.fireAnalyticsEvent(payload, ELEMENTS_CHANNEL);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
169
185
|
var options = config.options,
|
|
170
186
|
api = config.api,
|
|
171
187
|
portalProviderAPI = config.portalProviderAPI,
|
|
172
188
|
editorView = config.editorView;
|
|
173
|
-
|
|
189
|
+
var hasProvider = Boolean(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
190
|
+
var canReportMissingProvider = !hasProvider && fg('platform_editor_mention_avatar_observability');
|
|
191
|
+
var isAvatarEnabled = (hasProvider || canReportMissingProvider) && node.attrs.userType !== 'SPECIAL' && !genericMentionIds.includes(node.attrs.id) && (isExperimentEnabled('platform_editor_mention_node_avatar') || isExperimentEnabled('platform_editor_mention_node_graphql_provider'));
|
|
192
|
+
this.hasAvatarSlot = hasProvider && isAvatarEnabled;
|
|
174
193
|
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.hasAvatarSlot)),
|
|
175
194
|
dom = _DOMSerializer$render.dom,
|
|
176
195
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
@@ -178,6 +197,9 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
178
197
|
this.contentDOM = contentDOM;
|
|
179
198
|
this.config = config;
|
|
180
199
|
this.node = node;
|
|
200
|
+
if (canReportMissingProvider && isAvatarEnabled) {
|
|
201
|
+
this.reportAvatarFailure('missing_provider');
|
|
202
|
+
}
|
|
181
203
|
this.domElement = dom instanceof HTMLElement ? dom : undefined;
|
|
182
204
|
this.mentionPrimitiveElement = this.domElement ? (_this$domElement$quer = this.domElement.querySelector(".".concat(primitiveClassName))) !== null && _this$domElement$quer !== void 0 ? _this$domElement$quer : undefined : undefined;
|
|
183
205
|
this.mentionTextElement = this.mentionPrimitiveElement;
|
|
@@ -187,7 +209,10 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
187
209
|
var avatarContainer = (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.querySelector(".".concat(avatarContainerClassName));
|
|
188
210
|
if (avatarContainer) {
|
|
189
211
|
this.mentionAvatar = mentionAvatarRenderer({
|
|
190
|
-
container: avatarContainer
|
|
212
|
+
container: avatarContainer,
|
|
213
|
+
onFailure: function onFailure() {
|
|
214
|
+
return _this.reportAvatarFailure('image_load_failed');
|
|
215
|
+
}
|
|
191
216
|
});
|
|
192
217
|
this.resolveMentionAvatar(options === null || options === void 0 ? void 0 : options.mentionNodeDataProvider);
|
|
193
218
|
}
|
|
@@ -499,7 +524,19 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
499
524
|
}
|
|
500
525
|
(_this3$mentionAvatar = _this3.mentionAvatar) === null || _this3$mentionAvatar === void 0 || _this3$mentionAvatar.render(data);
|
|
501
526
|
};
|
|
527
|
+
var failureReported = false;
|
|
502
528
|
mentionNodeDataProvider.getMentionData(mention, function (payload) {
|
|
529
|
+
if (_this3.isDestroyed) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (!failureReported && (payload.error || payload.data && !payload.data.avatarUrl)) {
|
|
533
|
+
failureReported = true;
|
|
534
|
+
if (payload.error) {
|
|
535
|
+
_this3.reportAvatarFailure('provider_failed');
|
|
536
|
+
} else if (payload.data && !payload.data.avatarUrl) {
|
|
537
|
+
_this3.reportAvatarFailure('missing_avatar_url');
|
|
538
|
+
}
|
|
539
|
+
}
|
|
503
540
|
if (payload.data) {
|
|
504
541
|
applyData(payload.data);
|
|
505
542
|
}
|
|
@@ -36,7 +36,7 @@ export var ACTIONS = {
|
|
|
36
36
|
CLEAR_PENDING_PASTED_AGENT_MENTION: 'CLEAR_PENDING_PASTED_AGENT_MENTION'
|
|
37
37
|
};
|
|
38
38
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
39
|
-
var PACKAGE_VERSION = "24.0.
|
|
39
|
+
var PACKAGE_VERSION = "24.0.1";
|
|
40
40
|
var setProvider = function setProvider(provider) {
|
|
41
41
|
return function (state, dispatch) {
|
|
42
42
|
if (dispatch) {
|
|
@@ -7,6 +7,7 @@ export interface MentionAvatarController {
|
|
|
7
7
|
* Populates the fixed-size avatar slot owned by the vanilla ProseMirror NodeView.
|
|
8
8
|
* No React root or editor portal is created for individual mention nodes.
|
|
9
9
|
*/
|
|
10
|
-
export declare const mentionAvatarRenderer: ({ container, }: {
|
|
10
|
+
export declare const mentionAvatarRenderer: ({ container, onFailure, }: {
|
|
11
11
|
container: HTMLElement;
|
|
12
|
+
onFailure?: () => void;
|
|
12
13
|
}) => MentionAvatarController;
|
|
@@ -60,6 +60,7 @@ export declare class MentionNodeView implements NodeView {
|
|
|
60
60
|
private syncDisabledTooltip;
|
|
61
61
|
private setTextContent;
|
|
62
62
|
private setVisibleText;
|
|
63
|
+
private reportAvatarFailure;
|
|
63
64
|
private resolveMentionAvatar;
|
|
64
65
|
private shouldHighlightMention;
|
|
65
66
|
private updateState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.2",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/section-message": "^10.2.0",
|
|
48
48
|
"@atlaskit/teams-app-config": "^3.1.0",
|
|
49
49
|
"@atlaskit/theme": "^28.2.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^211.0.0",
|
|
51
51
|
"@atlaskit/tokens": "^20.1.0",
|
|
52
52
|
"@atlaskit/tooltip": "^24.3.0",
|
|
53
53
|
"@atlaskit/user-picker": "^14.0.0",
|
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
"wait-for-expect": "^1.2.0"
|
|
77
77
|
},
|
|
78
78
|
"platform-feature-flags": {
|
|
79
|
+
"platform_editor_mention_avatar_observability": {
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"referenceOnly": true
|
|
82
|
+
},
|
|
79
83
|
"editor-disable-feature": {
|
|
80
84
|
"type": "boolean",
|
|
81
85
|
"referenceOnly": true
|