@atlaskit/editor-plugin-mentions 18.2.5 → 18.2.7

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,32 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 18.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 18.2.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [`3ae04490ac0f4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ae04490ac0f4) -
14
+ Render the disabled mention chip tooltip without React. Behind the
15
+ `platform_editor_use_vanilla_components` experiment, with no visual change.
16
+ - Disabled mention chips no longer mount a React tooltip, its portal, and the DOM-to-React event
17
+ bridge that fed it.
18
+ - Tooltips release their positioning instance when they close, rather than keeping one alive per
19
+ hovered chip.
20
+ - Tooltips remove their own element and attributes when destroyed, so mention and emoji chips no
21
+ longer leave orphaned popovers behind.
22
+ - Re-hovering a tooltip while it is closing keeps it open, matching `@atlaskit/tooltip`.
23
+ Previously the pending hide still landed and the tooltip disappeared under the pointer.
24
+ - Tooltips close when they hide, instead of waiting on a transition that nothing declares.
25
+ Required by the change above: releasing the positioning instance while the popover was still
26
+ open left it behind as an invisible hit target over the content.
27
+
28
+ - Updated dependencies
29
+
3
30
  ## 18.2.5
4
31
 
5
32
  ### Patch Changes
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.mentionNodeSpec = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _adfSchema = require("@atlaskit/adf-schema");
9
+ var _mention = require("@atlaskit/adf-schema/mention");
10
10
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
11
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
12
12
  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; }
@@ -21,9 +21,9 @@ var isSSR = Boolean(process.env.REACT_SSR);
21
21
  */
22
22
  var mentionNodeSpec = exports.mentionNodeSpec = function mentionNodeSpec() {
23
23
  if (isSSR) {
24
- return _adfSchema.mention;
24
+ return _mention.mention;
25
25
  }
26
- return _objectSpread(_objectSpread({}, _adfSchema.mention), {}, {
26
+ return _objectSpread(_objectSpread({}, _mention.mention), {}, {
27
27
  toDOM: function toDOM(node) {
28
28
  // packages/elements/mention/src/components/Mention/index.tsx
29
29
  var mentionAttrs = {
@@ -11,6 +11,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
  var _browser = require("@atlaskit/editor-common/browser");
14
+ var _coreUtils = require("@atlaskit/editor-common/core-utils");
15
+ var _vanillaTooltip = require("@atlaskit/editor-common/vanilla-tooltip");
14
16
  var _whitespace = require("@atlaskit/editor-common/whitespace");
15
17
  var _model = require("@atlaskit/editor-prosemirror/model");
16
18
  var _constants = require("@atlaskit/mention/constants");
@@ -29,6 +31,12 @@ var primitiveClassName = 'editor-mention-primitive';
29
31
  var primitiveWithAvatarClassName = 'editor-mention-primitive-with-avatar';
30
32
  var avatarContainerClassName = 'editor-mention-avatar';
31
33
  var mentionTextClassName = 'editor-mention-text';
34
+ /**
35
+ * Classes applied to the disabled-reason tooltip. `ak-editor-vanilla-tooltip-default` opts into
36
+ * the shared `VanillaTooltip` look, defined as `vanillaTooltipDefaultStyles` in both
37
+ * EditorContentContainer stylesheets — keep them in sync when renaming.
38
+ */
39
+ var disabledTooltipClassNames = 'ak-editor-vanilla-tooltip-default mention-disabled-tooltip';
32
40
  var genericMentionIds = ['HipChat', 'all', 'here'];
33
41
  var unknownMentionText = "@".concat(_constants.UNKNOWN_USER_ID);
34
42
  // eslint-disable-next-line require-unicode-regexp
@@ -291,6 +299,32 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
291
299
  _this2.updateState(_this2.subscribedProvider);
292
300
  });
293
301
  }
302
+
303
+ /**
304
+ * Bind to `this.domElement`, the node-view wrapper. `VanillaTooltip` appends the popover to
305
+ * its trigger and listens for hover/focus there. This wrapper is also where `role`,
306
+ * `tabindex`, and aria are set, so `aria-describedby` belongs on it — not on the inner
307
+ * `.editor-mention-primitive` that the React tooltip still wraps.
308
+ */
309
+ }, {
310
+ key: "syncVanillaDisabledTooltip",
311
+ value: function syncVanillaDisabledTooltip(tooltipText) {
312
+ var _this$vanillaDisabled;
313
+ var trigger = this.domElement;
314
+ if (!trigger || tooltipText === this.vanillaDisabledTooltipText) {
315
+ return;
316
+ }
317
+
318
+ // A changed reason rebuilds rather than re-texting, so nothing out here has to reach into
319
+ // the element `VanillaTooltip` owns. `destroy()` takes that element with it.
320
+ (_this$vanillaDisabled = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled === void 0 || _this$vanillaDisabled.destroy();
321
+ this.vanillaDisabledTooltip = undefined;
322
+ this.vanillaDisabledTooltipText = tooltipText;
323
+ if ((0, _coreUtils.isSSR)() || !tooltipText) {
324
+ return;
325
+ }
326
+ this.vanillaDisabledTooltip = new _vanillaTooltip.VanillaTooltip(trigger, tooltipText, undefined, disabledTooltipClassNames);
327
+ }
294
328
  }, {
295
329
  key: "syncDisabledTooltip",
296
330
  value: function syncDisabledTooltip(disabledState) {
@@ -298,6 +332,10 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
298
332
  // branch on a truthy string instead of re-asserting non-null fields
299
333
  // off of `disabledState`.
300
334
  var tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
335
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_use_vanilla_components')) {
336
+ this.syncVanillaDisabledTooltip(tooltipText);
337
+ return;
338
+ }
301
339
  var chip = this.mentionPrimitiveElement;
302
340
  var portalProviderAPI = this.config.portalProviderAPI;
303
341
  if (!chip || !portalProviderAPI) {
@@ -473,6 +511,12 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
473
511
  this.mentionAvatar = undefined;
474
512
  (_this$disabledTooltip = this.disabledTooltip) === null || _this$disabledTooltip === void 0 || _this$disabledTooltip.destroy();
475
513
  this.disabledTooltip = undefined;
514
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_use_vanilla_components')) {
515
+ var _this$vanillaDisabled2;
516
+ (_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
517
+ this.vanillaDisabledTooltip = undefined;
518
+ this.vanillaDisabledTooltipText = undefined;
519
+ }
476
520
  (_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 || _this$unsubscribeFrom2.call(this);
477
521
  this.unsubscribeFromDisabledStateChanges = undefined;
478
522
  this.subscribedProvider = undefined;
@@ -74,7 +74,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
74
74
  var AGENT_MENTION_INACTIVITY_MS = 3000;
75
75
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
76
76
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
77
- var PACKAGE_VERSION = "18.2.4";
77
+ var PACKAGE_VERSION = "18.2.6";
78
78
  var setProvider = function setProvider(provider) {
79
79
  return function (state, dispatch) {
80
80
  if (dispatch) {
@@ -607,7 +607,9 @@ function createMentionPlugin(_ref2) {
607
607
  from = _step$value[0],
608
608
  to = _step$value[1];
609
609
  var clampedTo = Math.min(to, newState.doc.content.size);
610
- if (from >= clampedTo) continue;
610
+ if (from >= clampedTo) {
611
+ continue;
612
+ }
611
613
  newState.doc.nodesBetween(from, clampedTo, function (node, pos) {
612
614
  if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
613
615
  return true;
@@ -649,7 +651,9 @@ function createMentionPlugin(_ref2) {
649
651
  _from = _step2$value[0],
650
652
  _to = _step2$value[1];
651
653
  var clampedOldTo = Math.min(_to, oldState.doc.content.size);
652
- if (_from >= clampedOldTo) continue;
654
+ if (_from >= clampedOldTo) {
655
+ continue;
656
+ }
653
657
  oldState.doc.nodesBetween(_from, clampedOldTo, function (node) {
654
658
  if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
655
659
  return true;
@@ -16,7 +16,7 @@ var _reactIntl = require("react-intl");
16
16
  var _messages = require("@atlaskit/editor-common/messages");
17
17
  var _email = _interopRequireDefault(require("@atlaskit/icon/core/email"));
18
18
  var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
19
- var _userPicker = require("@atlaskit/user-picker");
19
+ var _emailValidation = require("@atlaskit/user-picker/components/email-validation");
20
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
21
  var mentionItemStyle = null;
22
22
  var mentionItemSelectedStyle = null;
@@ -88,7 +88,7 @@ var getInviteOption = function getInviteOption(inputValue, suggestedEmailDomain)
88
88
  if (inputValue.includes(' ') && inputValue.includes('@')) {
89
89
  return truncateInviteOption(inputValue);
90
90
  }
91
- var isEmail = inputValue && [VALID_OPTION, POTENTIAL_OPTION].includes((0, _userPicker.isValidEmail)(inputValue));
91
+ var isEmail = inputValue && [VALID_OPTION, POTENTIAL_OPTION].includes((0, _emailValidation.isValidEmail)(inputValue));
92
92
  if (isEmail || !suggestedEmailDomain) {
93
93
  return truncateInviteOption(inputValue);
94
94
  }
@@ -18,7 +18,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
18
18
  var _bindEventListener = require("bind-event-listener");
19
19
  var _reactLoadable = _interopRequireDefault(require("react-loadable"));
20
20
  var _fg = require("@atlaskit/platform-feature-flags/fg");
21
- var _user = require("@atlaskit/profilecard/user");
21
+ var _lazyProfileCard = require("@atlaskit/profilecard/lazy-profile-card");
22
22
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
23
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
24
24
  var _PopperWrapper = require("./PopperWrapper");
@@ -246,7 +246,7 @@ var UserProfileCardContent = function UserProfileCardContent(_ref8) {
246
246
  hasError = _useProfileCardState.hasError;
247
247
  return /*#__PURE__*/React.createElement(LoadingWrapper, {
248
248
  isLoading: isLoading
249
- }, /*#__PURE__*/React.createElement(_user.ProfileCardLazy, {
249
+ }, /*#__PURE__*/React.createElement(_lazyProfileCard.ProfileCardLazy, {
250
250
  avatarUrl: data === null || data === void 0 ? void 0 : data.avatarUrl,
251
251
  accountType: data === null || data === void 0 ? void 0 : data.accountType,
252
252
  status: data === null || data === void 0 ? void 0 : data.status,
@@ -1,4 +1,4 @@
1
- import { mention } from '@atlaskit/adf-schema';
1
+ import { mention } from '@atlaskit/adf-schema/mention';
2
2
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
3
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
4
4
  const isSSR = Boolean(process.env.REACT_SSR);
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
3
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
4
+ import { VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
3
5
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
4
6
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
7
  // oxlint-disable-next-line import/no-duplicates
@@ -18,6 +20,12 @@ const primitiveClassName = 'editor-mention-primitive';
18
20
  const primitiveWithAvatarClassName = 'editor-mention-primitive-with-avatar';
19
21
  const avatarContainerClassName = 'editor-mention-avatar';
20
22
  const mentionTextClassName = 'editor-mention-text';
23
+ /**
24
+ * Classes applied to the disabled-reason tooltip. `ak-editor-vanilla-tooltip-default` opts into
25
+ * the shared `VanillaTooltip` look, defined as `vanillaTooltipDefaultStyles` in both
26
+ * EditorContentContainer stylesheets — keep them in sync when renaming.
27
+ */
28
+ const disabledTooltipClassNames = 'ak-editor-vanilla-tooltip-default mention-disabled-tooltip';
21
29
  const genericMentionIds = ['HipChat', 'all', 'here'];
22
30
  const unknownMentionText = `@${UNKNOWN_USER_ID}`;
23
31
  // eslint-disable-next-line require-unicode-regexp
@@ -251,11 +259,39 @@ export class MentionNodeView {
251
259
  this.updateState(this.subscribedProvider);
252
260
  });
253
261
  }
262
+
263
+ /**
264
+ * Bind to `this.domElement`, the node-view wrapper. `VanillaTooltip` appends the popover to
265
+ * its trigger and listens for hover/focus there. This wrapper is also where `role`,
266
+ * `tabindex`, and aria are set, so `aria-describedby` belongs on it — not on the inner
267
+ * `.editor-mention-primitive` that the React tooltip still wraps.
268
+ */
269
+ syncVanillaDisabledTooltip(tooltipText) {
270
+ var _this$vanillaDisabled;
271
+ const trigger = this.domElement;
272
+ if (!trigger || tooltipText === this.vanillaDisabledTooltipText) {
273
+ return;
274
+ }
275
+
276
+ // A changed reason rebuilds rather than re-texting, so nothing out here has to reach into
277
+ // the element `VanillaTooltip` owns. `destroy()` takes that element with it.
278
+ (_this$vanillaDisabled = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled === void 0 ? void 0 : _this$vanillaDisabled.destroy();
279
+ this.vanillaDisabledTooltip = undefined;
280
+ this.vanillaDisabledTooltipText = tooltipText;
281
+ if (isSSR() || !tooltipText) {
282
+ return;
283
+ }
284
+ this.vanillaDisabledTooltip = new VanillaTooltip(trigger, tooltipText, undefined, disabledTooltipClassNames);
285
+ }
254
286
  syncDisabledTooltip(disabledState) {
255
287
  // Capture the tooltip text into a local so the rest of the method can
256
288
  // branch on a truthy string instead of re-asserting non-null fields
257
289
  // off of `disabledState`.
258
290
  const tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
291
+ if (isExperimentEnabled('platform_editor_use_vanilla_components')) {
292
+ this.syncVanillaDisabledTooltip(tooltipText);
293
+ return;
294
+ }
259
295
  const chip = this.mentionPrimitiveElement;
260
296
  const {
261
297
  portalProviderAPI
@@ -401,6 +437,12 @@ export class MentionNodeView {
401
437
  this.mentionAvatar = undefined;
402
438
  (_this$disabledTooltip = this.disabledTooltip) === null || _this$disabledTooltip === void 0 ? void 0 : _this$disabledTooltip.destroy();
403
439
  this.disabledTooltip = undefined;
440
+ if (isExperimentEnabled('platform_editor_use_vanilla_components')) {
441
+ var _this$vanillaDisabled2;
442
+ (_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 ? void 0 : _this$vanillaDisabled2.destroy();
443
+ this.vanillaDisabledTooltip = undefined;
444
+ this.vanillaDisabledTooltipText = undefined;
445
+ }
404
446
  (_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 ? void 0 : _this$unsubscribeFrom2.call(this);
405
447
  this.unsubscribeFromDisabledStateChanges = undefined;
406
448
  this.subscribedProvider = undefined;
@@ -58,7 +58,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
58
58
  const AGENT_MENTION_INACTIVITY_MS = 3000;
59
59
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
60
60
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
61
- const PACKAGE_VERSION = "18.2.4";
61
+ const PACKAGE_VERSION = "18.2.6";
62
62
  const setProvider = provider => (state, dispatch) => {
63
63
  if (dispatch) {
64
64
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -584,7 +584,9 @@ export function createMentionPlugin({
584
584
  if (stepsTouchMentions) {
585
585
  for (const [from, to] of newDocRanges) {
586
586
  const clampedTo = Math.min(to, newState.doc.content.size);
587
- if (from >= clampedTo) continue;
587
+ if (from >= clampedTo) {
588
+ continue;
589
+ }
588
590
  newState.doc.nodesBetween(from, clampedTo, (node, pos) => {
589
591
  if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType)) {
590
592
  return true;
@@ -611,7 +613,9 @@ export function createMentionPlugin({
611
613
  }
612
614
  for (const [from, to] of oldDocRanges) {
613
615
  const clampedOldTo = Math.min(to, oldState.doc.content.size);
614
- if (from >= clampedOldTo) continue;
616
+ if (from >= clampedOldTo) {
617
+ continue;
618
+ }
615
619
  oldState.doc.nodesBetween(from, clampedOldTo, node => {
616
620
  if (node.type !== mentionSchema || !isAgentUserType(node.attrs.userType)) {
617
621
  return true;
@@ -7,7 +7,7 @@ import { FormattedMessage, injectIntl } from 'react-intl';
7
7
  import { mentionMessages as messages } from '@atlaskit/editor-common/messages';
8
8
  import EmailIcon from '@atlaskit/icon/core/email';
9
9
  import StatusErrorIcon from '@atlaskit/icon/core/status-error';
10
- import { isValidEmail } from '@atlaskit/user-picker';
10
+ import { isValidEmail } from '@atlaskit/user-picker/components/email-validation';
11
11
  const mentionItemStyle = null;
12
12
  const mentionItemSelectedStyle = null;
13
13
  const displayNameStyles = {
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useState } from 'react';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import Loadable from 'react-loadable';
8
8
  import { fg } from '@atlaskit/platform-feature-flags/fg';
9
- import { ProfileCardLazy } from '@atlaskit/profilecard/user';
9
+ import { ProfileCardLazy } from '@atlaskit/profilecard/lazy-profile-card';
10
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
11
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
12
12
  import { Popup } from './PopperWrapper';
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
- import { mention } from '@atlaskit/adf-schema';
4
+ import { mention } from '@atlaskit/adf-schema/mention';
5
5
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
6
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
7
7
  var isSSR = Boolean(process.env.REACT_SSR);
@@ -6,6 +6,8 @@ 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
8
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
9
+ import { isSSR } from '@atlaskit/editor-common/core-utils';
10
+ import { VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
9
11
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
10
12
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
11
13
  // oxlint-disable-next-line import/no-duplicates
@@ -24,6 +26,12 @@ var primitiveClassName = 'editor-mention-primitive';
24
26
  var primitiveWithAvatarClassName = 'editor-mention-primitive-with-avatar';
25
27
  var avatarContainerClassName = 'editor-mention-avatar';
26
28
  var mentionTextClassName = 'editor-mention-text';
29
+ /**
30
+ * Classes applied to the disabled-reason tooltip. `ak-editor-vanilla-tooltip-default` opts into
31
+ * the shared `VanillaTooltip` look, defined as `vanillaTooltipDefaultStyles` in both
32
+ * EditorContentContainer stylesheets — keep them in sync when renaming.
33
+ */
34
+ var disabledTooltipClassNames = 'ak-editor-vanilla-tooltip-default mention-disabled-tooltip';
27
35
  var genericMentionIds = ['HipChat', 'all', 'here'];
28
36
  var unknownMentionText = "@".concat(UNKNOWN_USER_ID);
29
37
  // eslint-disable-next-line require-unicode-regexp
@@ -286,6 +294,32 @@ export var MentionNodeView = /*#__PURE__*/function () {
286
294
  _this2.updateState(_this2.subscribedProvider);
287
295
  });
288
296
  }
297
+
298
+ /**
299
+ * Bind to `this.domElement`, the node-view wrapper. `VanillaTooltip` appends the popover to
300
+ * its trigger and listens for hover/focus there. This wrapper is also where `role`,
301
+ * `tabindex`, and aria are set, so `aria-describedby` belongs on it — not on the inner
302
+ * `.editor-mention-primitive` that the React tooltip still wraps.
303
+ */
304
+ }, {
305
+ key: "syncVanillaDisabledTooltip",
306
+ value: function syncVanillaDisabledTooltip(tooltipText) {
307
+ var _this$vanillaDisabled;
308
+ var trigger = this.domElement;
309
+ if (!trigger || tooltipText === this.vanillaDisabledTooltipText) {
310
+ return;
311
+ }
312
+
313
+ // A changed reason rebuilds rather than re-texting, so nothing out here has to reach into
314
+ // the element `VanillaTooltip` owns. `destroy()` takes that element with it.
315
+ (_this$vanillaDisabled = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled === void 0 || _this$vanillaDisabled.destroy();
316
+ this.vanillaDisabledTooltip = undefined;
317
+ this.vanillaDisabledTooltipText = tooltipText;
318
+ if (isSSR() || !tooltipText) {
319
+ return;
320
+ }
321
+ this.vanillaDisabledTooltip = new VanillaTooltip(trigger, tooltipText, undefined, disabledTooltipClassNames);
322
+ }
289
323
  }, {
290
324
  key: "syncDisabledTooltip",
291
325
  value: function syncDisabledTooltip(disabledState) {
@@ -293,6 +327,10 @@ export var MentionNodeView = /*#__PURE__*/function () {
293
327
  // branch on a truthy string instead of re-asserting non-null fields
294
328
  // off of `disabledState`.
295
329
  var tooltipText = disabledState !== null && disabledState !== void 0 && disabledState.disabled ? disabledState.tooltip : undefined;
330
+ if (isExperimentEnabled('platform_editor_use_vanilla_components')) {
331
+ this.syncVanillaDisabledTooltip(tooltipText);
332
+ return;
333
+ }
296
334
  var chip = this.mentionPrimitiveElement;
297
335
  var portalProviderAPI = this.config.portalProviderAPI;
298
336
  if (!chip || !portalProviderAPI) {
@@ -468,6 +506,12 @@ export var MentionNodeView = /*#__PURE__*/function () {
468
506
  this.mentionAvatar = undefined;
469
507
  (_this$disabledTooltip = this.disabledTooltip) === null || _this$disabledTooltip === void 0 || _this$disabledTooltip.destroy();
470
508
  this.disabledTooltip = undefined;
509
+ if (isExperimentEnabled('platform_editor_use_vanilla_components')) {
510
+ var _this$vanillaDisabled2;
511
+ (_this$vanillaDisabled2 = this.vanillaDisabledTooltip) === null || _this$vanillaDisabled2 === void 0 || _this$vanillaDisabled2.destroy();
512
+ this.vanillaDisabledTooltip = undefined;
513
+ this.vanillaDisabledTooltipText = undefined;
514
+ }
471
515
  (_this$unsubscribeFrom2 = this.unsubscribeFromDisabledStateChanges) === null || _this$unsubscribeFrom2 === void 0 || _this$unsubscribeFrom2.call(this);
472
516
  this.unsubscribeFromDisabledStateChanges = undefined;
473
517
  this.subscribedProvider = undefined;
@@ -65,7 +65,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
65
65
  var AGENT_MENTION_INACTIVITY_MS = 3000;
66
66
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
67
67
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
68
- var PACKAGE_VERSION = "18.2.4";
68
+ var PACKAGE_VERSION = "18.2.6";
69
69
  var setProvider = function setProvider(provider) {
70
70
  return function (state, dispatch) {
71
71
  if (dispatch) {
@@ -598,7 +598,9 @@ export function createMentionPlugin(_ref2) {
598
598
  from = _step$value[0],
599
599
  to = _step$value[1];
600
600
  var clampedTo = Math.min(to, newState.doc.content.size);
601
- if (from >= clampedTo) continue;
601
+ if (from >= clampedTo) {
602
+ continue;
603
+ }
602
604
  newState.doc.nodesBetween(from, clampedTo, function (node, pos) {
603
605
  if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
604
606
  return true;
@@ -640,7 +642,9 @@ export function createMentionPlugin(_ref2) {
640
642
  _from = _step2$value[0],
641
643
  _to = _step2$value[1];
642
644
  var clampedOldTo = Math.min(_to, oldState.doc.content.size);
643
- if (_from >= clampedOldTo) continue;
645
+ if (_from >= clampedOldTo) {
646
+ continue;
647
+ }
644
648
  oldState.doc.nodesBetween(_from, clampedOldTo, function (node) {
645
649
  if (node.type !== _mentionSchema || !isAgentUserType(node.attrs.userType)) {
646
650
  return true;
@@ -8,7 +8,7 @@ import { FormattedMessage, injectIntl } from 'react-intl';
8
8
  import { mentionMessages as messages } from '@atlaskit/editor-common/messages';
9
9
  import EmailIcon from '@atlaskit/icon/core/email';
10
10
  import StatusErrorIcon from '@atlaskit/icon/core/status-error';
11
- import { isValidEmail } from '@atlaskit/user-picker';
11
+ import { isValidEmail } from '@atlaskit/user-picker/components/email-validation';
12
12
  var mentionItemStyle = null;
13
13
  var mentionItemSelectedStyle = null;
14
14
  var displayNameStyles = {
@@ -9,7 +9,7 @@ import { useEffect, useMemo, useState } from 'react';
9
9
  import { bind } from 'bind-event-listener';
10
10
  import Loadable from 'react-loadable';
11
11
  import { fg } from '@atlaskit/platform-feature-flags/fg';
12
- import { ProfileCardLazy } from '@atlaskit/profilecard/user';
12
+ import { ProfileCardLazy } from '@atlaskit/profilecard/lazy-profile-card';
13
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
14
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
15
15
  import { Popup } from './PopperWrapper';
@@ -26,6 +26,8 @@ export declare class MentionNodeView implements NodeView {
26
26
  private hasAvatarSlot;
27
27
  private isDestroyed;
28
28
  private disabledTooltip;
29
+ private vanillaDisabledTooltip;
30
+ private vanillaDisabledTooltipText;
29
31
  private unsubscribeFromDisabledStateChanges;
30
32
  private subscribedProvider;
31
33
  constructor(node: PMNode, config: MentionNodeViewProps);
@@ -44,6 +46,13 @@ export declare class MentionNodeView implements NodeView {
44
46
  * `onChange` handler when the editor swaps providers.
45
47
  */
46
48
  private subscribeToProviderDisabledStateChanges;
49
+ /**
50
+ * Bind to `this.domElement`, the node-view wrapper. `VanillaTooltip` appends the popover to
51
+ * its trigger and listens for hover/focus there. This wrapper is also where `role`,
52
+ * `tabindex`, and aria are set, so `aria-describedby` belongs on it — not on the inner
53
+ * `.editor-mention-primitive` that the React tooltip still wraps.
54
+ */
55
+ private syncVanillaDisabledTooltip;
47
56
  private syncDisabledTooltip;
48
57
  private setTextContent;
49
58
  private setVisibleText;
@@ -1,4 +1,4 @@
1
- import type { DocNode } from '@atlaskit/adf-schema';
1
+ import type { DocNode } from '@atlaskit/adf-schema/doc';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  /**
4
4
  * Returns the direct parent content of an inserted agent mention as prompt ADF.
@@ -1,4 +1,4 @@
1
- import type { DocNode } from '@atlaskit/adf-schema';
1
+ import type { DocNode } from '@atlaskit/adf-schema/doc';
2
2
  import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
3
3
  import type { MentionNodeDataProvider } from '@atlaskit/editor-common/mention';
4
4
  import type { Providers, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
@@ -1,5 +1,5 @@
1
1
  import type { MentionAttributes } from '@atlaskit/adf-schema/mention';
2
- import type { DocNode } from '@atlaskit/adf-schema/schema';
2
+ import type { DocNode } from '@atlaskit/adf-schema/doc';
3
3
  import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { Placement } from '@atlaskit/popper/main';
5
5
  import type { ProfileCardClientData, TeamCentralReportingLinesData } from '@atlaskit/profilecard/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "18.2.5",
3
+ "version": "18.2.7",
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.0.0",
49
49
  "@atlaskit/theme": "^28.2.0",
50
- "@atlaskit/tmp-editor-statsig": "^172.0.0",
50
+ "@atlaskit/tmp-editor-statsig": "^173.0.0",
51
51
  "@atlaskit/tokens": "^16.11.0",
52
52
  "@atlaskit/tooltip": "^24.3.0",
53
53
  "@atlaskit/user-picker": "^13.12.0",