@atlaskit/editor-plugin-mentions 14.9.2 → 14.9.4

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/nodeviews/disabledTooltipRenderer.js +1 -1
  3. package/dist/cjs/nodeviews/mentionNodeView.js +4 -2
  4. package/dist/cjs/nodeviews/profileCardRenderer.js +28 -2
  5. package/dist/cjs/pm-plugins/main.js +3 -2
  6. package/dist/cjs/ui/InlineInviteRecaptchaContainer.js +1 -1
  7. package/dist/cjs/ui/InviteItem/InviteItemWithEmailDomain.js +1 -1
  8. package/dist/cjs/ui/InviteItem/index.js +1 -1
  9. package/dist/cjs/ui/ProfileCardComponent.compiled.css +0 -1
  10. package/dist/cjs/ui/ProfileCardComponent.js +18 -6
  11. package/dist/es2019/nodeviews/disabledTooltipRenderer.js +1 -1
  12. package/dist/es2019/nodeviews/mentionNodeView.js +4 -2
  13. package/dist/es2019/nodeviews/profileCardRenderer.js +26 -2
  14. package/dist/es2019/pm-plugins/main.js +3 -2
  15. package/dist/es2019/ui/InlineInviteRecaptchaContainer.js +1 -1
  16. package/dist/es2019/ui/InviteItem/InviteItemWithEmailDomain.js +1 -1
  17. package/dist/es2019/ui/InviteItem/index.js +1 -1
  18. package/dist/es2019/ui/ProfileCardComponent.compiled.css +0 -1
  19. package/dist/es2019/ui/ProfileCardComponent.js +15 -6
  20. package/dist/esm/nodeviews/disabledTooltipRenderer.js +1 -1
  21. package/dist/esm/nodeviews/mentionNodeView.js +4 -2
  22. package/dist/esm/nodeviews/profileCardRenderer.js +28 -2
  23. package/dist/esm/pm-plugins/main.js +3 -2
  24. package/dist/esm/ui/InlineInviteRecaptchaContainer.js +1 -1
  25. package/dist/esm/ui/InviteItem/InviteItemWithEmailDomain.js +1 -1
  26. package/dist/esm/ui/InviteItem/index.js +1 -1
  27. package/dist/esm/ui/ProfileCardComponent.compiled.css +0 -1
  28. package/dist/esm/ui/ProfileCardComponent.js +18 -6
  29. package/dist/types/nodeviews/mentionNodeView.d.ts +2 -1
  30. package/dist/types/nodeviews/profileCardRenderer.d.ts +3 -1
  31. package/dist/types/types/index.d.ts +9 -0
  32. package/dist/types/ui/ProfileCardComponent.d.ts +4 -2
  33. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 14.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 14.9.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7bbeb928e7b97`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7bbeb928e7b97) -
14
+ Passes editor context from agent profile card action to rovo chat
15
+ - Updated dependencies
16
+
3
17
  ## 14.9.2
4
18
 
5
19
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -145,7 +145,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
145
145
  (0, _classCallCheck2.default)(this, MentionNodeView);
146
146
  var options = config.options,
147
147
  api = config.api,
148
- portalProviderAPI = config.portalProviderAPI;
148
+ portalProviderAPI = config.portalProviderAPI,
149
+ editorView = config.editorView;
149
150
  var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(node)),
150
151
  dom = _DOMSerializer$render.dom,
151
152
  contentDOM = _DOMSerializer$render.contentDOM;
@@ -169,7 +170,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
169
170
  options: options,
170
171
  portalProviderAPI: portalProviderAPI,
171
172
  node: node,
172
- api: api
173
+ api: api,
174
+ editorView: editorView
173
175
  }),
174
176
  destroyProfileCard = _profileCardRenderer.destroyProfileCard,
175
177
  removeProfileCard = _profileCardRenderer.removeProfileCard,
@@ -10,9 +10,11 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _bindEventListener = require("bind-event-listener");
11
11
  var _v = _interopRequireDefault(require("uuid/v4"));
12
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
13
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _navigation = require("@atlaskit/teams-app-config/navigation");
15
16
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
17
+ var _agentMentionContext = require("../pm-plugins/agent-mention-context");
16
18
  var _ProfileCardComponent = require("../ui/ProfileCardComponent");
17
19
  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; }
18
20
  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) { (0, _defineProperty2.default)(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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
@@ -21,7 +23,8 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
21
23
  options = _ref.options,
22
24
  portalProviderAPI = _ref.portalProviderAPI,
23
25
  node = _ref.node,
24
- api = _ref.api;
26
+ api = _ref.api,
27
+ editorView = _ref.editorView;
25
28
  // Keep a mutable reference to the latest node so the click handler always
26
29
  // reads up-to-date attrs
27
30
  var currentNode = node;
@@ -60,7 +63,9 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
60
63
  });
61
64
  };
62
65
  var renderEditorProfileCard = function renderEditorProfileCard() {
63
- var activeMention = (0, _expVal.expVal)('platform_editor_reduced_profile_cards', 'isEnabled', false) ? function (_dom$querySelector, _currentNode, _currentNode2) {
66
+ var isReducedProfileCards = (0, _expVal.expVal)('platform_editor_reduced_profile_cards', 'isEnabled', false);
67
+ var clickedNode = isReducedProfileCards ? currentNode : node;
68
+ var activeMention = isReducedProfileCards ? function (_dom$querySelector, _currentNode, _currentNode2) {
64
69
  // Read the display name from the DOM element at click time — this is
65
70
  // always up-to-date even when node.attrs.text is absent
66
71
  var primitiveText = dom instanceof HTMLElement ? (_dom$querySelector = dom.querySelector('.editor-mention-primitive')) === null || _dom$querySelector === void 0 || (_dom$querySelector = _dom$querySelector.textContent) === null || _dom$querySelector === void 0 ? void 0 : _dom$querySelector.trim() : undefined;
@@ -72,10 +77,31 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
72
77
  }() : {
73
78
  attrs: node.attrs
74
79
  };
80
+
81
+ // Build agent mention context at click time by finding the parent block of this mention
82
+ // in the live document.
83
+ var agentMentionContext;
84
+ if (options !== null && options !== void 0 && options.onAgentMentionChatClick && editorView && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes')) {
85
+ var _clickedNode$attrs;
86
+ var localId = (_clickedNode$attrs = clickedNode.attrs) === null || _clickedNode$attrs === void 0 ? void 0 : _clickedNode$attrs.localId;
87
+ if (localId) {
88
+ var found = (0, _utils.findChildrenByAttr)(editorView.state.doc, function (attrs) {
89
+ return (attrs === null || attrs === void 0 ? void 0 : attrs.localId) === localId;
90
+ })[0];
91
+ if (found) {
92
+ var parentBlock = editorView.state.doc.resolve(found.pos).parent;
93
+ agentMentionContext = (0, _agentMentionContext.getAgentMentionParentContext)(parentBlock, localId);
94
+ }
95
+ }
96
+ }
75
97
  renderProfileCardPopup(function (referenceElement) {
76
98
  return /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
77
99
  activeMention: activeMention,
78
100
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
101
+ onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (agentId) {
102
+ var _options$onAgentMenti;
103
+ return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
104
+ } : undefined,
79
105
  dom: referenceElement,
80
106
  closeComponent: removeProfileCard
81
107
  });
@@ -66,7 +66,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
66
66
  var AGENT_MENTION_INACTIVITY_MS = 3000;
67
67
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
68
68
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
69
- var PACKAGE_VERSION = "14.9.1";
69
+ var PACKAGE_VERSION = "14.9.3";
70
70
  var setProvider = function setProvider(provider) {
71
71
  return function (state, dispatch) {
72
72
  if (dispatch) {
@@ -810,10 +810,11 @@ function createMentionPlugin(_ref2) {
810
810
  },
811
811
  props: {
812
812
  nodeViews: {
813
- mention: function mention(node) {
813
+ mention: function mention(node, view) {
814
814
  return new _mentionNodeView.MentionNodeView(node, {
815
815
  options: options,
816
816
  api: api,
817
+ editorView: view,
817
818
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
818
819
  });
819
820
  }
@@ -1,4 +1,4 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,2 +1 @@
1
-
2
1
  ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
@@ -1,4 +1,4 @@
1
- /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -17,6 +17,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
17
17
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
18
18
  var _bindEventListener = require("bind-event-listener");
19
19
  var _reactLoadable = _interopRequireDefault(require("react-loadable"));
20
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _user = require("@atlaskit/profilecard/user");
21
22
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
23
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
@@ -152,7 +153,8 @@ function ProfileCardComponent(_ref5) {
152
153
  var profilecardProvider = _ref5.profilecardProvider,
153
154
  activeMention = _ref5.activeMention,
154
155
  dom = _ref5.dom,
155
- closeComponent = _ref5.closeComponent;
156
+ closeComponent = _ref5.closeComponent,
157
+ onAgentMentionChatClick = _ref5.onAgentMentionChatClick;
156
158
  var _useState11 = (0, _react.useState)(undefined),
157
159
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
158
160
  provider = _useState12[0],
@@ -193,7 +195,14 @@ function ProfileCardComponent(_ref5) {
193
195
  }, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
194
196
  accountId: id,
195
197
  provider: provider,
196
- text: (0, _expVal.expVal)('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined
198
+ text: (0, _expVal.expVal)('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined,
199
+ onChatClick: onAgentMentionChatClick && (0, _platformFeatureFlags.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
200
+ return (
201
+ // agentMentionContext is already captured in the onAgentMentionChatClick
202
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
203
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id)
204
+ );
205
+ } : undefined
197
206
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
198
207
  accessLevel: accessLevel,
199
208
  id: id,
@@ -249,16 +258,19 @@ var UserProfileCardContent = function UserProfileCardContent(_ref8) {
249
258
  var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
250
259
  var accountId = _ref9.accountId,
251
260
  provider = _ref9.provider,
252
- text = _ref9.text;
261
+ text = _ref9.text,
262
+ onChatClick = _ref9.onChatClick;
253
263
  var agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
254
264
  return (0, _expVal.expVal)('platform_editor_reduced_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
255
265
  accountId: accountId,
256
266
  cloudId: provider.cloudId,
257
267
  resourceClient: provider.resourceClient,
258
- agentName: agentName
268
+ agentName: agentName,
269
+ onChatClick: onChatClick
259
270
  }) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
260
271
  accountId: accountId,
261
272
  cloudId: provider.cloudId,
262
- resourceClient: provider.resourceClient
273
+ resourceClient: provider.resourceClient,
274
+ onChatClick: onChatClick
263
275
  });
264
276
  };
@@ -1,4 +1,4 @@
1
- /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import "./disabledTooltipRenderer.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useEffect, useState } from 'react';
@@ -104,7 +104,8 @@ export class MentionNodeView {
104
104
  const {
105
105
  options,
106
106
  api,
107
- portalProviderAPI
107
+ portalProviderAPI,
108
+ editorView
108
109
  } = config;
109
110
  const {
110
111
  dom,
@@ -136,7 +137,8 @@ export class MentionNodeView {
136
137
  options,
137
138
  portalProviderAPI,
138
139
  node,
139
- api
140
+ api,
141
+ editorView
140
142
  });
141
143
  // Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
142
144
  if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
@@ -3,16 +3,19 @@ import { bind } from 'bind-event-listener';
3
3
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
4
  import uuid from 'uuid/v4';
5
5
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { findChildrenByAttr } from '@atlaskit/editor-prosemirror/utils';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
8
9
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
10
+ import { getAgentMentionParentContext } from '../pm-plugins/agent-mention-context';
9
11
  import { isAgentMentionType, ProfileCardComponent } from '../ui/ProfileCardComponent';
10
12
  export const profileCardRenderer = ({
11
13
  dom,
12
14
  options,
13
15
  portalProviderAPI,
14
16
  node,
15
- api
17
+ api,
18
+ editorView
16
19
  }) => {
17
20
  // Keep a mutable reference to the latest node so the click handler always
18
21
  // reads up-to-date attrs
@@ -51,7 +54,9 @@ export const profileCardRenderer = ({
51
54
  });
52
55
  };
53
56
  const renderEditorProfileCard = () => {
54
- const activeMention = expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? ((_dom$querySelector, _dom$querySelector$te, _currentNode, _currentNode2, _currentNode2$attrs) => {
57
+ const isReducedProfileCards = expVal('platform_editor_reduced_profile_cards', 'isEnabled', false);
58
+ const clickedNode = isReducedProfileCards ? currentNode : node;
59
+ const activeMention = isReducedProfileCards ? ((_dom$querySelector, _dom$querySelector$te, _currentNode, _currentNode2, _currentNode2$attrs) => {
55
60
  // Read the display name from the DOM element at click time — this is
56
61
  // always up-to-date even when node.attrs.text is absent
57
62
  const primitiveText = dom instanceof HTMLElement ? (_dom$querySelector = dom.querySelector('.editor-mention-primitive')) === null || _dom$querySelector === void 0 ? void 0 : (_dom$querySelector$te = _dom$querySelector.textContent) === null || _dom$querySelector$te === void 0 ? void 0 : _dom$querySelector$te.trim() : undefined;
@@ -64,9 +69,28 @@ export const profileCardRenderer = ({
64
69
  })() : {
65
70
  attrs: node.attrs
66
71
  };
72
+
73
+ // Build agent mention context at click time by finding the parent block of this mention
74
+ // in the live document.
75
+ let agentMentionContext;
76
+ if (options !== null && options !== void 0 && options.onAgentMentionChatClick && editorView && fg('platform_editor_agent_mentions_drop_one_fixes')) {
77
+ var _clickedNode$attrs;
78
+ const localId = (_clickedNode$attrs = clickedNode.attrs) === null || _clickedNode$attrs === void 0 ? void 0 : _clickedNode$attrs.localId;
79
+ if (localId) {
80
+ const found = findChildrenByAttr(editorView.state.doc, attrs => (attrs === null || attrs === void 0 ? void 0 : attrs.localId) === localId)[0];
81
+ if (found) {
82
+ const parentBlock = editorView.state.doc.resolve(found.pos).parent;
83
+ agentMentionContext = getAgentMentionParentContext(parentBlock, localId);
84
+ }
85
+ }
86
+ }
67
87
  renderProfileCardPopup(referenceElement => /*#__PURE__*/React.createElement(ProfileCardComponent, {
68
88
  activeMention: activeMention,
69
89
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
90
+ onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? agentId => {
91
+ var _options$onAgentMenti;
92
+ return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
93
+ } : undefined,
70
94
  dom: referenceElement,
71
95
  closeComponent: removeProfileCard
72
96
  }));
@@ -50,7 +50,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
50
50
  const AGENT_MENTION_INACTIVITY_MS = 3000;
51
51
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
52
52
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
53
- const PACKAGE_VERSION = "14.9.1";
53
+ const PACKAGE_VERSION = "14.9.3";
54
54
  const setProvider = provider => (state, dispatch) => {
55
55
  if (dispatch) {
56
56
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -774,10 +774,11 @@ export function createMentionPlugin({
774
774
  },
775
775
  props: {
776
776
  nodeViews: {
777
- mention: node => {
777
+ mention: (node, view) => {
778
778
  return new MentionNodeView(node, {
779
779
  options,
780
780
  api,
781
+ editorView: view,
781
782
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
782
783
  });
783
784
  }
@@ -1,4 +1,4 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React, { useCallback, useEffect, useState } from 'react';
4
4
  import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
@@ -1,4 +1,4 @@
1
- /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./InviteItemWithEmailDomain.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./index.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,2 +1 @@
1
-
2
1
  ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
@@ -1,10 +1,11 @@
1
- /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import "./ProfileCardComponent.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import { useEffect, useMemo, useState } from 'react';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import Loadable from 'react-loadable';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { ProfileCardLazy } from '@atlaskit/profilecard/user';
9
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
@@ -82,7 +83,8 @@ export function ProfileCardComponent({
82
83
  profilecardProvider,
83
84
  activeMention,
84
85
  dom,
85
- closeComponent
86
+ closeComponent,
87
+ onAgentMentionChatClick
86
88
  }) {
87
89
  var _ref;
88
90
  const [provider, setProvider] = useState(undefined);
@@ -123,7 +125,11 @@ export function ProfileCardComponent({
123
125
  }, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
124
126
  accountId: id,
125
127
  provider: provider,
126
- text: expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined
128
+ text: expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined,
129
+ onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? (event, agentStudioId) =>
130
+ // agentMentionContext is already captured in the onAgentMentionChatClick
131
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
132
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id) : undefined
127
133
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
128
134
  accessLevel: accessLevel,
129
135
  id: id,
@@ -179,17 +185,20 @@ const UserProfileCardContent = ({
179
185
  const AgentProfileCardContent = ({
180
186
  accountId,
181
187
  provider,
182
- text
188
+ text,
189
+ onChatClick
183
190
  }) => {
184
191
  const agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
185
192
  return expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
186
193
  accountId: accountId,
187
194
  cloudId: provider.cloudId,
188
195
  resourceClient: provider.resourceClient,
189
- agentName: agentName
196
+ agentName: agentName,
197
+ onChatClick: onChatClick
190
198
  }) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
191
199
  accountId: accountId,
192
200
  cloudId: provider.cloudId,
193
- resourceClient: provider.resourceClient
201
+ resourceClient: provider.resourceClient,
202
+ onChatClick: onChatClick
194
203
  });
195
204
  };
@@ -1,4 +1,4 @@
1
- /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* disabledTooltipRenderer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import "./disabledTooltipRenderer.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -138,7 +138,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
138
138
  _classCallCheck(this, MentionNodeView);
139
139
  var options = config.options,
140
140
  api = config.api,
141
- portalProviderAPI = config.portalProviderAPI;
141
+ portalProviderAPI = config.portalProviderAPI,
142
+ editorView = config.editorView;
142
143
  var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node)),
143
144
  dom = _DOMSerializer$render.dom,
144
145
  contentDOM = _DOMSerializer$render.contentDOM;
@@ -162,7 +163,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
162
163
  options: options,
163
164
  portalProviderAPI: portalProviderAPI,
164
165
  node: node,
165
- api: api
166
+ api: api,
167
+ editorView: editorView
166
168
  }),
167
169
  destroyProfileCard = _profileCardRenderer.destroyProfileCard,
168
170
  removeProfileCard = _profileCardRenderer.removeProfileCard,
@@ -6,16 +6,19 @@ import { bind } from 'bind-event-listener';
6
6
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
7
7
  import uuid from 'uuid/v4';
8
8
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
+ import { findChildrenByAttr } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { navigateToTeamsApp } from '@atlaskit/teams-app-config/navigation';
11
12
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
13
+ import { getAgentMentionParentContext } from '../pm-plugins/agent-mention-context';
12
14
  import { isAgentMentionType, ProfileCardComponent } from '../ui/ProfileCardComponent';
13
15
  export var profileCardRenderer = function profileCardRenderer(_ref) {
14
16
  var dom = _ref.dom,
15
17
  options = _ref.options,
16
18
  portalProviderAPI = _ref.portalProviderAPI,
17
19
  node = _ref.node,
18
- api = _ref.api;
20
+ api = _ref.api,
21
+ editorView = _ref.editorView;
19
22
  // Keep a mutable reference to the latest node so the click handler always
20
23
  // reads up-to-date attrs
21
24
  var currentNode = node;
@@ -54,7 +57,9 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
54
57
  });
55
58
  };
56
59
  var renderEditorProfileCard = function renderEditorProfileCard() {
57
- var activeMention = expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? function (_dom$querySelector, _currentNode, _currentNode2) {
60
+ var isReducedProfileCards = expVal('platform_editor_reduced_profile_cards', 'isEnabled', false);
61
+ var clickedNode = isReducedProfileCards ? currentNode : node;
62
+ var activeMention = isReducedProfileCards ? function (_dom$querySelector, _currentNode, _currentNode2) {
58
63
  // Read the display name from the DOM element at click time — this is
59
64
  // always up-to-date even when node.attrs.text is absent
60
65
  var primitiveText = dom instanceof HTMLElement ? (_dom$querySelector = dom.querySelector('.editor-mention-primitive')) === null || _dom$querySelector === void 0 || (_dom$querySelector = _dom$querySelector.textContent) === null || _dom$querySelector === void 0 ? void 0 : _dom$querySelector.trim() : undefined;
@@ -66,10 +71,31 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
66
71
  }() : {
67
72
  attrs: node.attrs
68
73
  };
74
+
75
+ // Build agent mention context at click time by finding the parent block of this mention
76
+ // in the live document.
77
+ var agentMentionContext;
78
+ if (options !== null && options !== void 0 && options.onAgentMentionChatClick && editorView && fg('platform_editor_agent_mentions_drop_one_fixes')) {
79
+ var _clickedNode$attrs;
80
+ var localId = (_clickedNode$attrs = clickedNode.attrs) === null || _clickedNode$attrs === void 0 ? void 0 : _clickedNode$attrs.localId;
81
+ if (localId) {
82
+ var found = findChildrenByAttr(editorView.state.doc, function (attrs) {
83
+ return (attrs === null || attrs === void 0 ? void 0 : attrs.localId) === localId;
84
+ })[0];
85
+ if (found) {
86
+ var parentBlock = editorView.state.doc.resolve(found.pos).parent;
87
+ agentMentionContext = getAgentMentionParentContext(parentBlock, localId);
88
+ }
89
+ }
90
+ }
69
91
  renderProfileCardPopup(function (referenceElement) {
70
92
  return /*#__PURE__*/React.createElement(ProfileCardComponent, {
71
93
  activeMention: activeMention,
72
94
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
95
+ onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? function (agentId) {
96
+ var _options$onAgentMenti;
97
+ return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
98
+ } : undefined,
73
99
  dom: referenceElement,
74
100
  closeComponent: removeProfileCard
75
101
  });
@@ -57,7 +57,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
57
57
  var AGENT_MENTION_INACTIVITY_MS = 3000;
58
58
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
59
59
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
60
- var PACKAGE_VERSION = "14.9.1";
60
+ var PACKAGE_VERSION = "14.9.3";
61
61
  var setProvider = function setProvider(provider) {
62
62
  return function (state, dispatch) {
63
63
  if (dispatch) {
@@ -801,10 +801,11 @@ export function createMentionPlugin(_ref2) {
801
801
  },
802
802
  props: {
803
803
  nodeViews: {
804
- mention: function mention(node) {
804
+ mention: function mention(node, view) {
805
805
  return new MentionNodeView(node, {
806
806
  options: options,
807
807
  api: api,
808
+ editorView: view,
808
809
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
809
810
  });
810
811
  }
@@ -1,4 +1,4 @@
1
- /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback, useEffect, useState } from 'react';
@@ -1,4 +1,4 @@
1
- /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* InviteItemWithEmailDomain.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./InviteItemWithEmailDomain.compiled.css";
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./index.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,2 +1 @@
1
-
2
1
  ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
@@ -1,4 +1,4 @@
1
- /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.39.1 */
1
+ /* ProfileCardComponent.tsx generated by @compiled/babel-plugin v0.40.0 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./ProfileCardComponent.compiled.css";
@@ -8,6 +8,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { useEffect, useMemo, useState } from 'react';
9
9
  import { bind } from 'bind-event-listener';
10
10
  import Loadable from 'react-loadable';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { ProfileCardLazy } from '@atlaskit/profilecard/user';
12
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
@@ -141,7 +142,8 @@ export function ProfileCardComponent(_ref5) {
141
142
  var profilecardProvider = _ref5.profilecardProvider,
142
143
  activeMention = _ref5.activeMention,
143
144
  dom = _ref5.dom,
144
- closeComponent = _ref5.closeComponent;
145
+ closeComponent = _ref5.closeComponent,
146
+ onAgentMentionChatClick = _ref5.onAgentMentionChatClick;
145
147
  var _useState11 = useState(undefined),
146
148
  _useState12 = _slicedToArray(_useState11, 2),
147
149
  provider = _useState12[0],
@@ -182,7 +184,14 @@ export function ProfileCardComponent(_ref5) {
182
184
  }, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
183
185
  accountId: id,
184
186
  provider: provider,
185
- text: expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined
187
+ text: expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? text : undefined,
188
+ onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
189
+ return (
190
+ // agentMentionContext is already captured in the onAgentMentionChatClick
191
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
192
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id)
193
+ );
194
+ } : undefined
186
195
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
187
196
  accessLevel: accessLevel,
188
197
  id: id,
@@ -238,16 +247,19 @@ var UserProfileCardContent = function UserProfileCardContent(_ref8) {
238
247
  var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
239
248
  var accountId = _ref9.accountId,
240
249
  provider = _ref9.provider,
241
- text = _ref9.text;
250
+ text = _ref9.text,
251
+ onChatClick = _ref9.onChatClick;
242
252
  var agentName = (text !== null && text !== void 0 ? text : '').replace(LEADING_AT_SIGN_RE, '');
243
253
  return expVal('platform_editor_reduced_profile_cards', 'isEnabled', false) ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
244
254
  accountId: accountId,
245
255
  cloudId: provider.cloudId,
246
256
  resourceClient: provider.resourceClient,
247
- agentName: agentName
257
+ agentName: agentName,
258
+ onChatClick: onChatClick
248
259
  }) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
249
260
  accountId: accountId,
250
261
  cloudId: provider.cloudId,
251
- resourceClient: provider.resourceClient
262
+ resourceClient: provider.resourceClient,
263
+ onChatClick: onChatClick
252
264
  });
253
265
  };
@@ -1,11 +1,12 @@
1
1
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import type { NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { MentionsPlugin } from '../mentionsPluginType';
6
6
  import type { MentionPluginOptions } from '../types';
7
7
  interface MentionNodeViewProps {
8
8
  api: ExtractInjectionAPI<MentionsPlugin> | undefined;
9
+ editorView?: EditorView;
9
10
  options?: MentionPluginOptions;
10
11
  portalProviderAPI: PortalProviderAPI;
11
12
  }
@@ -1,11 +1,13 @@
1
1
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { MentionsPlugin } from '../mentionsPluginType';
5
6
  import type { MentionPluginOptions } from '../types';
6
- export declare const profileCardRenderer: ({ dom, options, portalProviderAPI, node, api, }: {
7
+ export declare const profileCardRenderer: ({ dom, options, portalProviderAPI, node, api, editorView, }: {
7
8
  api: ExtractInjectionAPI<MentionsPlugin> | undefined;
8
9
  dom: Node;
10
+ editorView?: EditorView;
9
11
  node: PMNode;
10
12
  options?: MentionPluginOptions;
11
13
  portalProviderAPI: PortalProviderAPI;
@@ -49,6 +49,15 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
49
49
  getIsRovoPanelOpen?: () => boolean;
50
50
  handleMentionsChanged?: MentionsChangedHandler;
51
51
  mentionProvider?: Providers['mentionProvider'];
52
+ /**
53
+ * Optional callback injected by Rovo-aware consumers (e.g. Confluence) to
54
+ * handle the "Chat with Agent" action on the agent profile card. When provided,
55
+ * clicking "Chat" on the card calls this function instead of the card's default
56
+ * handler, so the caller can pass editor context to Rovo chat. The `agentId` argument is the UUID.
57
+ *
58
+ * Gated behind `platform_editor_agent_mentions`.
59
+ */
60
+ onAgentMentionChatClick?: (agentId: string, agentMentionContext?: DocNode) => void;
52
61
  sanitizePrivateContent?: boolean;
53
62
  /**
54
63
  * Shows the experimental Labs label beside the agent mentions section when the agent mentions experiment is enabled.
@@ -1,4 +1,5 @@
1
- import type { MentionAttributes } from '@atlaskit/adf-schema';
1
+ import type { MentionAttributes } from '@atlaskit/adf-schema/mention';
2
+ import type { DocNode } from '@atlaskit/adf-schema/schema';
2
3
  import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
3
4
  import type { ProfileCardClientData, TeamCentralReportingLinesData } from '@atlaskit/profilecard/types';
4
5
  interface ProfileCardStateProps {
@@ -17,12 +18,13 @@ export declare const useProfileCardState: ({ id, provider, }: ProfileCardStatePr
17
18
  /**
18
19
  * Renders the profile card popup for an editor mention node.
19
20
  */
20
- export declare function ProfileCardComponent({ profilecardProvider, activeMention, dom, closeComponent, }: {
21
+ export declare function ProfileCardComponent({ profilecardProvider, activeMention, dom, closeComponent, onAgentMentionChatClick, }: {
21
22
  activeMention: {
22
23
  attrs: MentionAttributes;
23
24
  };
24
25
  closeComponent: () => void;
25
26
  dom: HTMLElement;
27
+ onAgentMentionChatClick?: (agentId: string, agentMentionContext?: DocNode) => void;
26
28
  profilecardProvider?: Promise<ProfilecardProvider> | undefined;
27
29
  }): JSX.Element;
28
30
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "14.9.2",
3
+ "version": "14.9.4",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-plugin-selection": "^12.0.0",
30
30
  "@atlaskit/editor-plugin-type-ahead": "^13.0.0",
31
31
  "@atlaskit/editor-prosemirror": "^8.0.0",
32
- "@atlaskit/icon": "^37.0.0",
32
+ "@atlaskit/icon": "^37.1.0",
33
33
  "@atlaskit/insm": "^1.0.0",
34
34
  "@atlaskit/link": "^4.3.0",
35
35
  "@atlaskit/lozenge": "^14.1.0",
@@ -38,15 +38,15 @@
38
38
  "@atlaskit/popper": "^8.3.0",
39
39
  "@atlaskit/portal": "^6.1.0",
40
40
  "@atlaskit/primitives": "^22.0.0",
41
- "@atlaskit/profilecard": "^26.11.0",
41
+ "@atlaskit/profilecard": "^26.12.0",
42
42
  "@atlaskit/teams-app-config": "^2.1.0",
43
43
  "@atlaskit/theme": "^26.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^128.0.0",
45
- "@atlaskit/tokens": "^16.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^130.0.0",
45
+ "@atlaskit/tokens": "^16.1.0",
46
46
  "@atlaskit/tooltip": "^23.1.0",
47
47
  "@atlaskit/user-picker": "^13.4.0",
48
48
  "@babel/runtime": "^7.0.0",
49
- "@compiled/react": "^0.20.0",
49
+ "@compiled/react": "^0.22.2",
50
50
  "bind-event-listener": "^3.0.0",
51
51
  "focus-trap": "^2.4.5",
52
52
  "react-loadable": "^5.1.0",