@atlaskit/editor-plugin-mentions 21.1.2 → 21.1.3
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 +9 -0
- package/dist/cjs/nodeviews/mentionNodeView.js +128 -9
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/es2019/nodeviews/mentionNodeView.js +76 -1
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/esm/nodeviews/mentionNodeView.js +128 -9
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/types/nodeviews/mentionNodeView.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 21.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`90cc9e3c7fc0c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/90cc9e3c7fc0c) -
|
|
8
|
+
Support gated dark-background styling for the configured Rovo Chat agent mention in editors and
|
|
9
|
+
the renderer.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 21.1.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -10,6 +10,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _bindEventListener = require("bind-event-listener");
|
|
13
14
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
14
15
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
15
16
|
var _vanillaTooltip = require("@atlaskit/editor-common/vanilla-tooltip");
|
|
@@ -198,10 +199,16 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
198
199
|
}
|
|
199
200
|
var _ref2 = (_api$mention$sharedSt = api === null || api === void 0 ? void 0 : api.mention.sharedState.currentState()) !== null && _api$mention$sharedSt !== void 0 ? _api$mention$sharedSt : {},
|
|
200
201
|
mentionProvider = _ref2.mentionProvider;
|
|
202
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_rovo')) {
|
|
203
|
+
void this.resolveRovoChatIdentity(mentionProvider);
|
|
204
|
+
}
|
|
201
205
|
this.updateState(mentionProvider);
|
|
202
206
|
this.subscribeToProviderDisabledStateChanges(mentionProvider);
|
|
203
207
|
this.cleanup = api === null || api === void 0 ? void 0 : api.mention.sharedState.onChange(function (_ref3) {
|
|
204
208
|
var nextSharedState = _ref3.nextSharedState;
|
|
209
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_rovo')) {
|
|
210
|
+
void _this.resolveRovoChatIdentity(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
211
|
+
}
|
|
205
212
|
_this.updateState(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
206
213
|
_this.subscribeToProviderDisabledStateChanges(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
207
214
|
});
|
|
@@ -256,6 +263,116 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
256
263
|
}
|
|
257
264
|
}
|
|
258
265
|
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "resolveRovoChatIdentity",
|
|
268
|
+
value: function () {
|
|
269
|
+
var _resolveRovoChatIdentity = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(mentionProvider) {
|
|
270
|
+
var identityAccountId;
|
|
271
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
272
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
273
|
+
case 0:
|
|
274
|
+
if (!(this.rovoChatIdentityProvider === mentionProvider)) {
|
|
275
|
+
_context2.next = 1;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
return _context2.abrupt("return");
|
|
279
|
+
case 1:
|
|
280
|
+
this.rovoChatIdentityProvider = mentionProvider;
|
|
281
|
+
if (!(!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_rovo') || !(mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.getRovoChatAgentIdentityAccountId))) {
|
|
282
|
+
_context2.next = 2;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
this.setRovoChatStyles(false);
|
|
286
|
+
return _context2.abrupt("return");
|
|
287
|
+
case 2:
|
|
288
|
+
_context2.next = 3;
|
|
289
|
+
return mentionProvider.getRovoChatAgentIdentityAccountId();
|
|
290
|
+
case 3:
|
|
291
|
+
identityAccountId = _context2.sent;
|
|
292
|
+
if (!(this.rovoChatIdentityProvider !== mentionProvider)) {
|
|
293
|
+
_context2.next = 4;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
return _context2.abrupt("return");
|
|
297
|
+
case 4:
|
|
298
|
+
if (!(identityAccountId === undefined || identityAccountId !== this.node.attrs.id)) {
|
|
299
|
+
_context2.next = 5;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
this.setRovoChatStyles(false);
|
|
303
|
+
return _context2.abrupt("return");
|
|
304
|
+
case 5:
|
|
305
|
+
this.setRovoChatStyles(true);
|
|
306
|
+
case 6:
|
|
307
|
+
case "end":
|
|
308
|
+
return _context2.stop();
|
|
309
|
+
}
|
|
310
|
+
}, _callee2, this);
|
|
311
|
+
}));
|
|
312
|
+
function resolveRovoChatIdentity(_x4) {
|
|
313
|
+
return _resolveRovoChatIdentity.apply(this, arguments);
|
|
314
|
+
}
|
|
315
|
+
return resolveRovoChatIdentity;
|
|
316
|
+
}()
|
|
317
|
+
}, {
|
|
318
|
+
key: "setRovoChatStyles",
|
|
319
|
+
value: function setRovoChatStyles(isRovoChat) {
|
|
320
|
+
var _this$cleanupRovoChat, _this$mentionTextElem2;
|
|
321
|
+
(_this$cleanupRovoChat = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat === void 0 || _this$cleanupRovoChat.call(this);
|
|
322
|
+
this.cleanupRovoChatStyles = undefined;
|
|
323
|
+
var primitive = this.mentionPrimitiveElement;
|
|
324
|
+
if (!primitive) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
primitive.classList.toggle('mention-rovo-chat', isRovoChat);
|
|
328
|
+
if (!isRovoChat) {
|
|
329
|
+
var _this$mentionTextElem;
|
|
330
|
+
primitive.style.removeProperty('background-color');
|
|
331
|
+
primitive.style.removeProperty('color');
|
|
332
|
+
(_this$mentionTextElem = this.mentionTextElement) === null || _this$mentionTextElem === void 0 || _this$mentionTextElem.style.removeProperty('color');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
var baseBackground = "var(--ds-background-neutral-bold, #292A2E)";
|
|
336
|
+
var hoveredBackground = "var(--ds-background-neutral-bold-hovered, #3B3D42)";
|
|
337
|
+
var pressedBackground = "var(--ds-background-neutral-bold-pressed, #505258)";
|
|
338
|
+
var inverseText = "var(--ds-text-inverse, #FFFFFF)";
|
|
339
|
+
var setBackground = function setBackground(background) {
|
|
340
|
+
primitive.style.setProperty('background-color', background);
|
|
341
|
+
};
|
|
342
|
+
setBackground(baseBackground);
|
|
343
|
+
primitive.style.setProperty('color', inverseText);
|
|
344
|
+
(_this$mentionTextElem2 = this.mentionTextElement) === null || _this$mentionTextElem2 === void 0 || _this$mentionTextElem2.style.setProperty('color', inverseText);
|
|
345
|
+
var onMouseEnter = function onMouseEnter() {
|
|
346
|
+
return setBackground(hoveredBackground);
|
|
347
|
+
};
|
|
348
|
+
var onMouseLeave = function onMouseLeave() {
|
|
349
|
+
return setBackground(baseBackground);
|
|
350
|
+
};
|
|
351
|
+
var onMouseDown = function onMouseDown() {
|
|
352
|
+
return setBackground(pressedBackground);
|
|
353
|
+
};
|
|
354
|
+
var onMouseUp = function onMouseUp() {
|
|
355
|
+
return setBackground(hoveredBackground);
|
|
356
|
+
};
|
|
357
|
+
var unbinders = [(0, _bindEventListener.bind)(primitive, {
|
|
358
|
+
type: 'mouseenter',
|
|
359
|
+
listener: onMouseEnter
|
|
360
|
+
}), (0, _bindEventListener.bind)(primitive, {
|
|
361
|
+
type: 'mouseleave',
|
|
362
|
+
listener: onMouseLeave
|
|
363
|
+
}), (0, _bindEventListener.bind)(primitive, {
|
|
364
|
+
type: 'mousedown',
|
|
365
|
+
listener: onMouseDown
|
|
366
|
+
}), (0, _bindEventListener.bind)(primitive, {
|
|
367
|
+
type: 'mouseup',
|
|
368
|
+
listener: onMouseUp
|
|
369
|
+
})];
|
|
370
|
+
this.cleanupRovoChatStyles = function () {
|
|
371
|
+
unbinders.forEach(function (unbind) {
|
|
372
|
+
return unbind();
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
}
|
|
259
376
|
}, {
|
|
260
377
|
key: "getDisabledState",
|
|
261
378
|
value: function getDisabledState(mentionProvider) {
|
|
@@ -412,11 +529,11 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
412
529
|
}, {
|
|
413
530
|
key: "updateState",
|
|
414
531
|
value: function () {
|
|
415
|
-
var _updateState = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
532
|
+
var _updateState = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(mentionProvider) {
|
|
416
533
|
var _this$config$options2;
|
|
417
534
|
var isAgentMentionsEnabled, isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name, text;
|
|
418
|
-
return _regenerator.default.wrap(function (
|
|
419
|
-
while (1) switch (
|
|
535
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
536
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
420
537
|
case 0:
|
|
421
538
|
isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
|
|
422
539
|
isHighlighted = this.shouldHighlightMention(mentionProvider);
|
|
@@ -432,10 +549,10 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
432
549
|
// the tooltip text stays in sync if the disabled reason changes while
|
|
433
550
|
// the chip is already disabled.
|
|
434
551
|
this.syncDisabledTooltip(disabledState);
|
|
435
|
-
|
|
552
|
+
_context3.next = 1;
|
|
436
553
|
return handleProviderName(mentionProvider, this.node, isAgentMentionsEnabled);
|
|
437
554
|
case 1:
|
|
438
|
-
name =
|
|
555
|
+
name = _context3.sent;
|
|
439
556
|
this.setTextContent(name, isAgentMentionsEnabled);
|
|
440
557
|
// Only overwrite the disabled-state aria-label with the name-based one
|
|
441
558
|
// when the chip is NOT disabled; otherwise the disabled reason set in
|
|
@@ -448,11 +565,11 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
448
565
|
}
|
|
449
566
|
case 2:
|
|
450
567
|
case "end":
|
|
451
|
-
return
|
|
568
|
+
return _context3.stop();
|
|
452
569
|
}
|
|
453
|
-
},
|
|
570
|
+
}, _callee3, this);
|
|
454
571
|
}));
|
|
455
|
-
function updateState(
|
|
572
|
+
function updateState(_x5) {
|
|
456
573
|
return _updateState.apply(this, arguments);
|
|
457
574
|
}
|
|
458
575
|
return updateState;
|
|
@@ -486,7 +603,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
486
603
|
}, {
|
|
487
604
|
key: "destroy",
|
|
488
605
|
value: function destroy() {
|
|
489
|
-
var _this$cleanup, _this$destroyProfileC, _this$mentionAvatar, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
606
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
490
607
|
this.isDestroyed = true;
|
|
491
608
|
// Surface the destruction to the provider before tearing down so the
|
|
492
609
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -502,6 +619,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
502
619
|
// the NodeView from cleaning up its own resources below.
|
|
503
620
|
}
|
|
504
621
|
(_this$cleanup = this.cleanup) === null || _this$cleanup === void 0 || _this$cleanup.call(this);
|
|
622
|
+
(_this$cleanupRovoChat2 = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat2 === void 0 || _this$cleanupRovoChat2.call(this);
|
|
623
|
+
this.cleanupRovoChatStyles = undefined;
|
|
505
624
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 || _this$destroyProfileC.call(this);
|
|
506
625
|
(_this$mentionAvatar = this.mentionAvatar) === null || _this$mentionAvatar === void 0 || _this$mentionAvatar.destroy();
|
|
507
626
|
this.mentionAvatar = undefined;
|
|
@@ -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 = "21.1.
|
|
47
|
+
var PACKAGE_VERSION = "21.1.2";
|
|
48
48
|
var setProvider = function setProvider(provider) {
|
|
49
49
|
return function (state, dispatch) {
|
|
50
50
|
if (dispatch) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { bind } from 'bind-event-listener';
|
|
2
3
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
3
4
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
4
5
|
import { VANILLA_TOOLTIP_DEFAULT_CLASS, VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
@@ -163,11 +164,17 @@ export class MentionNodeView {
|
|
|
163
164
|
const {
|
|
164
165
|
mentionProvider
|
|
165
166
|
} = (_api$mention$sharedSt = api === null || api === void 0 ? void 0 : api.mention.sharedState.currentState()) !== null && _api$mention$sharedSt !== void 0 ? _api$mention$sharedSt : {};
|
|
167
|
+
if (isExperimentEnabled('platform_editor_mention_rovo')) {
|
|
168
|
+
void this.resolveRovoChatIdentity(mentionProvider);
|
|
169
|
+
}
|
|
166
170
|
this.updateState(mentionProvider);
|
|
167
171
|
this.subscribeToProviderDisabledStateChanges(mentionProvider);
|
|
168
172
|
this.cleanup = api === null || api === void 0 ? void 0 : api.mention.sharedState.onChange(({
|
|
169
173
|
nextSharedState
|
|
170
174
|
}) => {
|
|
175
|
+
if (isExperimentEnabled('platform_editor_mention_rovo')) {
|
|
176
|
+
void this.resolveRovoChatIdentity(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
177
|
+
}
|
|
171
178
|
this.updateState(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
172
179
|
this.subscribeToProviderDisabledStateChanges(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
173
180
|
});
|
|
@@ -221,6 +228,72 @@ export class MentionNodeView {
|
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
230
|
}
|
|
231
|
+
async resolveRovoChatIdentity(mentionProvider) {
|
|
232
|
+
if (this.rovoChatIdentityProvider === mentionProvider) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.rovoChatIdentityProvider = mentionProvider;
|
|
236
|
+
if (!isExperimentEnabled('platform_editor_mention_rovo') || !(mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.getRovoChatAgentIdentityAccountId)) {
|
|
237
|
+
this.setRovoChatStyles(false);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const identityAccountId = await mentionProvider.getRovoChatAgentIdentityAccountId();
|
|
241
|
+
if (this.rovoChatIdentityProvider !== mentionProvider) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (identityAccountId === undefined || identityAccountId !== this.node.attrs.id) {
|
|
245
|
+
this.setRovoChatStyles(false);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.setRovoChatStyles(true);
|
|
249
|
+
}
|
|
250
|
+
setRovoChatStyles(isRovoChat) {
|
|
251
|
+
var _this$cleanupRovoChat, _this$mentionTextElem2;
|
|
252
|
+
(_this$cleanupRovoChat = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat === void 0 ? void 0 : _this$cleanupRovoChat.call(this);
|
|
253
|
+
this.cleanupRovoChatStyles = undefined;
|
|
254
|
+
const primitive = this.mentionPrimitiveElement;
|
|
255
|
+
if (!primitive) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
primitive.classList.toggle('mention-rovo-chat', isRovoChat);
|
|
259
|
+
if (!isRovoChat) {
|
|
260
|
+
var _this$mentionTextElem;
|
|
261
|
+
primitive.style.removeProperty('background-color');
|
|
262
|
+
primitive.style.removeProperty('color');
|
|
263
|
+
(_this$mentionTextElem = this.mentionTextElement) === null || _this$mentionTextElem === void 0 ? void 0 : _this$mentionTextElem.style.removeProperty('color');
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const baseBackground = "var(--ds-background-neutral-bold, #292A2E)";
|
|
267
|
+
const hoveredBackground = "var(--ds-background-neutral-bold-hovered, #3B3D42)";
|
|
268
|
+
const pressedBackground = "var(--ds-background-neutral-bold-pressed, #505258)";
|
|
269
|
+
const inverseText = "var(--ds-text-inverse, #FFFFFF)";
|
|
270
|
+
const setBackground = background => {
|
|
271
|
+
primitive.style.setProperty('background-color', background);
|
|
272
|
+
};
|
|
273
|
+
setBackground(baseBackground);
|
|
274
|
+
primitive.style.setProperty('color', inverseText);
|
|
275
|
+
(_this$mentionTextElem2 = this.mentionTextElement) === null || _this$mentionTextElem2 === void 0 ? void 0 : _this$mentionTextElem2.style.setProperty('color', inverseText);
|
|
276
|
+
const onMouseEnter = () => setBackground(hoveredBackground);
|
|
277
|
+
const onMouseLeave = () => setBackground(baseBackground);
|
|
278
|
+
const onMouseDown = () => setBackground(pressedBackground);
|
|
279
|
+
const onMouseUp = () => setBackground(hoveredBackground);
|
|
280
|
+
const unbinders = [bind(primitive, {
|
|
281
|
+
type: 'mouseenter',
|
|
282
|
+
listener: onMouseEnter
|
|
283
|
+
}), bind(primitive, {
|
|
284
|
+
type: 'mouseleave',
|
|
285
|
+
listener: onMouseLeave
|
|
286
|
+
}), bind(primitive, {
|
|
287
|
+
type: 'mousedown',
|
|
288
|
+
listener: onMouseDown
|
|
289
|
+
}), bind(primitive, {
|
|
290
|
+
type: 'mouseup',
|
|
291
|
+
listener: onMouseUp
|
|
292
|
+
})];
|
|
293
|
+
this.cleanupRovoChatStyles = () => {
|
|
294
|
+
unbinders.forEach(unbind => unbind());
|
|
295
|
+
};
|
|
296
|
+
}
|
|
224
297
|
getDisabledState(mentionProvider) {
|
|
225
298
|
var _mentionProvider$getM;
|
|
226
299
|
const input = {
|
|
@@ -412,7 +485,7 @@ export class MentionNodeView {
|
|
|
412
485
|
return true;
|
|
413
486
|
}
|
|
414
487
|
destroy() {
|
|
415
|
-
var _this$cleanup, _this$destroyProfileC, _this$mentionAvatar2, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
488
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar2, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
416
489
|
this.isDestroyed = true;
|
|
417
490
|
// Surface the destruction to the provider before tearing down so the
|
|
418
491
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -428,6 +501,8 @@ export class MentionNodeView {
|
|
|
428
501
|
// the NodeView from cleaning up its own resources below.
|
|
429
502
|
}
|
|
430
503
|
(_this$cleanup = this.cleanup) === null || _this$cleanup === void 0 ? void 0 : _this$cleanup.call(this);
|
|
504
|
+
(_this$cleanupRovoChat2 = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat2 === void 0 ? void 0 : _this$cleanupRovoChat2.call(this);
|
|
505
|
+
this.cleanupRovoChatStyles = undefined;
|
|
431
506
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 ? void 0 : _this$destroyProfileC.call(this);
|
|
432
507
|
(_this$mentionAvatar2 = this.mentionAvatar) === null || _this$mentionAvatar2 === void 0 ? void 0 : _this$mentionAvatar2.destroy();
|
|
433
508
|
this.mentionAvatar = undefined;
|
|
@@ -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 = "21.1.
|
|
36
|
+
const PACKAGE_VERSION = "21.1.2";
|
|
37
37
|
const setProvider = provider => (state, dispatch) => {
|
|
38
38
|
if (dispatch) {
|
|
39
39
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -5,6 +5,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
import { bind } from 'bind-event-listener';
|
|
8
9
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
9
10
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
10
11
|
import { VANILLA_TOOLTIP_DEFAULT_CLASS, VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
@@ -193,10 +194,16 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
193
194
|
}
|
|
194
195
|
var _ref2 = (_api$mention$sharedSt = api === null || api === void 0 ? void 0 : api.mention.sharedState.currentState()) !== null && _api$mention$sharedSt !== void 0 ? _api$mention$sharedSt : {},
|
|
195
196
|
mentionProvider = _ref2.mentionProvider;
|
|
197
|
+
if (isExperimentEnabled('platform_editor_mention_rovo')) {
|
|
198
|
+
void this.resolveRovoChatIdentity(mentionProvider);
|
|
199
|
+
}
|
|
196
200
|
this.updateState(mentionProvider);
|
|
197
201
|
this.subscribeToProviderDisabledStateChanges(mentionProvider);
|
|
198
202
|
this.cleanup = api === null || api === void 0 ? void 0 : api.mention.sharedState.onChange(function (_ref3) {
|
|
199
203
|
var nextSharedState = _ref3.nextSharedState;
|
|
204
|
+
if (isExperimentEnabled('platform_editor_mention_rovo')) {
|
|
205
|
+
void _this.resolveRovoChatIdentity(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
206
|
+
}
|
|
200
207
|
_this.updateState(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
201
208
|
_this.subscribeToProviderDisabledStateChanges(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mentionProvider);
|
|
202
209
|
});
|
|
@@ -251,6 +258,116 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "resolveRovoChatIdentity",
|
|
263
|
+
value: function () {
|
|
264
|
+
var _resolveRovoChatIdentity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mentionProvider) {
|
|
265
|
+
var identityAccountId;
|
|
266
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
267
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
if (!(this.rovoChatIdentityProvider === mentionProvider)) {
|
|
270
|
+
_context2.next = 1;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
return _context2.abrupt("return");
|
|
274
|
+
case 1:
|
|
275
|
+
this.rovoChatIdentityProvider = mentionProvider;
|
|
276
|
+
if (!(!isExperimentEnabled('platform_editor_mention_rovo') || !(mentionProvider !== null && mentionProvider !== void 0 && mentionProvider.getRovoChatAgentIdentityAccountId))) {
|
|
277
|
+
_context2.next = 2;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
this.setRovoChatStyles(false);
|
|
281
|
+
return _context2.abrupt("return");
|
|
282
|
+
case 2:
|
|
283
|
+
_context2.next = 3;
|
|
284
|
+
return mentionProvider.getRovoChatAgentIdentityAccountId();
|
|
285
|
+
case 3:
|
|
286
|
+
identityAccountId = _context2.sent;
|
|
287
|
+
if (!(this.rovoChatIdentityProvider !== mentionProvider)) {
|
|
288
|
+
_context2.next = 4;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
return _context2.abrupt("return");
|
|
292
|
+
case 4:
|
|
293
|
+
if (!(identityAccountId === undefined || identityAccountId !== this.node.attrs.id)) {
|
|
294
|
+
_context2.next = 5;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
this.setRovoChatStyles(false);
|
|
298
|
+
return _context2.abrupt("return");
|
|
299
|
+
case 5:
|
|
300
|
+
this.setRovoChatStyles(true);
|
|
301
|
+
case 6:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context2.stop();
|
|
304
|
+
}
|
|
305
|
+
}, _callee2, this);
|
|
306
|
+
}));
|
|
307
|
+
function resolveRovoChatIdentity(_x4) {
|
|
308
|
+
return _resolveRovoChatIdentity.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
return resolveRovoChatIdentity;
|
|
311
|
+
}()
|
|
312
|
+
}, {
|
|
313
|
+
key: "setRovoChatStyles",
|
|
314
|
+
value: function setRovoChatStyles(isRovoChat) {
|
|
315
|
+
var _this$cleanupRovoChat, _this$mentionTextElem2;
|
|
316
|
+
(_this$cleanupRovoChat = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat === void 0 || _this$cleanupRovoChat.call(this);
|
|
317
|
+
this.cleanupRovoChatStyles = undefined;
|
|
318
|
+
var primitive = this.mentionPrimitiveElement;
|
|
319
|
+
if (!primitive) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
primitive.classList.toggle('mention-rovo-chat', isRovoChat);
|
|
323
|
+
if (!isRovoChat) {
|
|
324
|
+
var _this$mentionTextElem;
|
|
325
|
+
primitive.style.removeProperty('background-color');
|
|
326
|
+
primitive.style.removeProperty('color');
|
|
327
|
+
(_this$mentionTextElem = this.mentionTextElement) === null || _this$mentionTextElem === void 0 || _this$mentionTextElem.style.removeProperty('color');
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
var baseBackground = "var(--ds-background-neutral-bold, #292A2E)";
|
|
331
|
+
var hoveredBackground = "var(--ds-background-neutral-bold-hovered, #3B3D42)";
|
|
332
|
+
var pressedBackground = "var(--ds-background-neutral-bold-pressed, #505258)";
|
|
333
|
+
var inverseText = "var(--ds-text-inverse, #FFFFFF)";
|
|
334
|
+
var setBackground = function setBackground(background) {
|
|
335
|
+
primitive.style.setProperty('background-color', background);
|
|
336
|
+
};
|
|
337
|
+
setBackground(baseBackground);
|
|
338
|
+
primitive.style.setProperty('color', inverseText);
|
|
339
|
+
(_this$mentionTextElem2 = this.mentionTextElement) === null || _this$mentionTextElem2 === void 0 || _this$mentionTextElem2.style.setProperty('color', inverseText);
|
|
340
|
+
var onMouseEnter = function onMouseEnter() {
|
|
341
|
+
return setBackground(hoveredBackground);
|
|
342
|
+
};
|
|
343
|
+
var onMouseLeave = function onMouseLeave() {
|
|
344
|
+
return setBackground(baseBackground);
|
|
345
|
+
};
|
|
346
|
+
var onMouseDown = function onMouseDown() {
|
|
347
|
+
return setBackground(pressedBackground);
|
|
348
|
+
};
|
|
349
|
+
var onMouseUp = function onMouseUp() {
|
|
350
|
+
return setBackground(hoveredBackground);
|
|
351
|
+
};
|
|
352
|
+
var unbinders = [bind(primitive, {
|
|
353
|
+
type: 'mouseenter',
|
|
354
|
+
listener: onMouseEnter
|
|
355
|
+
}), bind(primitive, {
|
|
356
|
+
type: 'mouseleave',
|
|
357
|
+
listener: onMouseLeave
|
|
358
|
+
}), bind(primitive, {
|
|
359
|
+
type: 'mousedown',
|
|
360
|
+
listener: onMouseDown
|
|
361
|
+
}), bind(primitive, {
|
|
362
|
+
type: 'mouseup',
|
|
363
|
+
listener: onMouseUp
|
|
364
|
+
})];
|
|
365
|
+
this.cleanupRovoChatStyles = function () {
|
|
366
|
+
unbinders.forEach(function (unbind) {
|
|
367
|
+
return unbind();
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
}
|
|
254
371
|
}, {
|
|
255
372
|
key: "getDisabledState",
|
|
256
373
|
value: function getDisabledState(mentionProvider) {
|
|
@@ -407,11 +524,11 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
407
524
|
}, {
|
|
408
525
|
key: "updateState",
|
|
409
526
|
value: function () {
|
|
410
|
-
var _updateState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
527
|
+
var _updateState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(mentionProvider) {
|
|
411
528
|
var _this$config$options2;
|
|
412
529
|
var isAgentMentionsEnabled, isHighlighted, disabledState, isDisabled, newState, disabledTooltip, name, text;
|
|
413
|
-
return _regeneratorRuntime.wrap(function (
|
|
414
|
-
while (1) switch (
|
|
530
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
531
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
415
532
|
case 0:
|
|
416
533
|
isAgentMentionsEnabled = isAgentMentionsExperimentEnabled();
|
|
417
534
|
isHighlighted = this.shouldHighlightMention(mentionProvider);
|
|
@@ -427,10 +544,10 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
427
544
|
// the tooltip text stays in sync if the disabled reason changes while
|
|
428
545
|
// the chip is already disabled.
|
|
429
546
|
this.syncDisabledTooltip(disabledState);
|
|
430
|
-
|
|
547
|
+
_context3.next = 1;
|
|
431
548
|
return handleProviderName(mentionProvider, this.node, isAgentMentionsEnabled);
|
|
432
549
|
case 1:
|
|
433
|
-
name =
|
|
550
|
+
name = _context3.sent;
|
|
434
551
|
this.setTextContent(name, isAgentMentionsEnabled);
|
|
435
552
|
// Only overwrite the disabled-state aria-label with the name-based one
|
|
436
553
|
// when the chip is NOT disabled; otherwise the disabled reason set in
|
|
@@ -443,11 +560,11 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
443
560
|
}
|
|
444
561
|
case 2:
|
|
445
562
|
case "end":
|
|
446
|
-
return
|
|
563
|
+
return _context3.stop();
|
|
447
564
|
}
|
|
448
|
-
},
|
|
565
|
+
}, _callee3, this);
|
|
449
566
|
}));
|
|
450
|
-
function updateState(
|
|
567
|
+
function updateState(_x5) {
|
|
451
568
|
return _updateState.apply(this, arguments);
|
|
452
569
|
}
|
|
453
570
|
return updateState;
|
|
@@ -481,7 +598,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
481
598
|
}, {
|
|
482
599
|
key: "destroy",
|
|
483
600
|
value: function destroy() {
|
|
484
|
-
var _this$cleanup, _this$destroyProfileC, _this$mentionAvatar, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
601
|
+
var _this$cleanup, _this$cleanupRovoChat2, _this$destroyProfileC, _this$mentionAvatar, _this$disabledTooltip, _this$unsubscribeFrom2;
|
|
485
602
|
this.isDestroyed = true;
|
|
486
603
|
// Surface the destruction to the provider before tearing down so the
|
|
487
604
|
// chat layer can react (e.g. drop the agent id from `selectedAgentIds`).
|
|
@@ -497,6 +614,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
497
614
|
// the NodeView from cleaning up its own resources below.
|
|
498
615
|
}
|
|
499
616
|
(_this$cleanup = this.cleanup) === null || _this$cleanup === void 0 || _this$cleanup.call(this);
|
|
617
|
+
(_this$cleanupRovoChat2 = this.cleanupRovoChatStyles) === null || _this$cleanupRovoChat2 === void 0 || _this$cleanupRovoChat2.call(this);
|
|
618
|
+
this.cleanupRovoChatStyles = undefined;
|
|
500
619
|
(_this$destroyProfileC = this.destroyProfileCard) === null || _this$destroyProfileC === void 0 || _this$destroyProfileC.call(this);
|
|
501
620
|
(_this$mentionAvatar = this.mentionAvatar) === null || _this$mentionAvatar === void 0 || _this$mentionAvatar.destroy();
|
|
502
621
|
this.mentionAvatar = undefined;
|
|
@@ -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 = "21.1.
|
|
39
|
+
var PACKAGE_VERSION = "21.1.2";
|
|
40
40
|
var setProvider = function setProvider(provider) {
|
|
41
41
|
return function (state, dispatch) {
|
|
42
42
|
if (dispatch) {
|
|
@@ -23,6 +23,8 @@ export declare class MentionNodeView implements NodeView {
|
|
|
23
23
|
private mentionPrimitiveElement;
|
|
24
24
|
private mentionTextElement;
|
|
25
25
|
private mentionAvatar;
|
|
26
|
+
private cleanupRovoChatStyles;
|
|
27
|
+
private rovoChatIdentityProvider;
|
|
26
28
|
private hasAvatarSlot;
|
|
27
29
|
private isDestroyed;
|
|
28
30
|
private disabledTooltip;
|
|
@@ -32,6 +34,8 @@ export declare class MentionNodeView implements NodeView {
|
|
|
32
34
|
private subscribedProvider;
|
|
33
35
|
constructor(node: PMNode, config: MentionNodeViewProps);
|
|
34
36
|
private setClassList;
|
|
37
|
+
private resolveRovoChatIdentity;
|
|
38
|
+
private setRovoChatStyles;
|
|
35
39
|
private getDisabledState;
|
|
36
40
|
/**
|
|
37
41
|
* Subscribes this NodeView to disabled-state-change notifications on the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "21.1.
|
|
3
|
+
"version": "21.1.3",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"uuid": "^11.1.1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@atlaskit/editor-common": "^123.
|
|
63
|
+
"@atlaskit/editor-common": "^123.6.0",
|
|
64
64
|
"react": "^18.2.0 || ^19.2.0",
|
|
65
65
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
66
66
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|