@atlaskit/editor-plugin-mentions 18.2.4 → 18.2.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3ae04490ac0f4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ae04490ac0f4) -
8
+ Render the disabled mention chip tooltip without React. Behind the
9
+ `platform_editor_use_vanilla_components` experiment, with no visual change.
10
+ - Disabled mention chips no longer mount a React tooltip, its portal, and the DOM-to-React event
11
+ bridge that fed it.
12
+ - Tooltips release their positioning instance when they close, rather than keeping one alive per
13
+ hovered chip.
14
+ - Tooltips remove their own element and attributes when destroyed, so mention and emoji chips no
15
+ longer leave orphaned popovers behind.
16
+ - Re-hovering a tooltip while it is closing keeps it open, matching `@atlaskit/tooltip`.
17
+ Previously the pending hide still landed and the tooltip disappeared under the pointer.
18
+ - Tooltips close when they hide, instead of waiting on a transition that nothing declares.
19
+ Required by the change above: releasing the positioning instance while the popover was still
20
+ open left it behind as an invisible hit target over the content.
21
+
22
+ - Updated dependencies
23
+
24
+ ## 18.2.5
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies
29
+
3
30
  ## 18.2.4
4
31
 
5
32
  ### Patch Changes
@@ -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.3";
77
+ var PACKAGE_VERSION = "18.2.5";
78
78
  var setProvider = function setProvider(provider) {
79
79
  return function (state, dispatch) {
80
80
  if (dispatch) {
@@ -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.3";
61
+ const PACKAGE_VERSION = "18.2.5";
62
62
  const setProvider = provider => (state, dispatch) => {
63
63
  if (dispatch) {
64
64
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -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.3";
68
+ var PACKAGE_VERSION = "18.2.5";
69
69
  var setProvider = function setProvider(provider) {
70
70
  return function (state, dispatch) {
71
71
  if (dispatch) {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "18.2.4",
3
+ "version": "18.2.6",
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": "^171.0.0",
50
+ "@atlaskit/tmp-editor-statsig": "^172.0.0",
51
51
  "@atlaskit/tokens": "^16.11.0",
52
52
  "@atlaskit/tooltip": "^24.3.0",
53
53
  "@atlaskit/user-picker": "^13.12.0",
@@ -59,7 +59,7 @@
59
59
  "uuid": "^3.1.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@atlaskit/editor-common": "^120.10.0",
62
+ "@atlaskit/editor-common": "^120.11.0",
63
63
  "react": "^18.2.0 || ^19.2.0",
64
64
  "react-dom": "^18.2.0 || ^19.2.0",
65
65
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"