@atlaskit/editor-plugin-mentions 14.5.7 → 14.5.9
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 +19 -0
- package/compass.yml +3 -0
- package/dist/cjs/nodeviews/mentionNodeView.js +7 -1
- package/dist/cjs/nodeviews/profileCardRenderer.js +28 -9
- package/dist/cjs/pm-plugins/main.js +49 -4
- package/dist/cjs/ui/ProfileCardComponent.js +25 -15
- package/dist/cjs/ui/type-ahead/index.js +1 -1
- package/dist/es2019/nodeviews/mentionNodeView.js +7 -1
- package/dist/es2019/nodeviews/profileCardRenderer.js +26 -7
- package/dist/es2019/pm-plugins/main.js +45 -4
- package/dist/es2019/ui/ProfileCardComponent.js +21 -9
- package/dist/es2019/ui/type-ahead/index.js +1 -1
- package/dist/esm/nodeviews/mentionNodeView.js +7 -1
- package/dist/esm/nodeviews/profileCardRenderer.js +28 -7
- package/dist/esm/pm-plugins/main.js +49 -4
- package/dist/esm/ui/ProfileCardComponent.js +25 -15
- package/dist/esm/ui/type-ahead/index.js +1 -1
- package/dist/types/nodeviews/mentionNodeView.d.ts +1 -0
- package/dist/types/nodeviews/profileCardRenderer.d.ts +1 -0
- package/dist/types/ui/ProfileCardComponent.d.ts +4 -2
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 14.5.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`25b1301af566b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25b1301af566b) -
|
|
8
|
+
[ux] Make Labs lozenge text capitalised
|
|
9
|
+
- [`d2f1039e54388`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2f1039e54388) -
|
|
10
|
+
Defer typed agent mention nudges while focus remains in the active document but outside the
|
|
11
|
+
editor, such as when typeahead, date, or status picker UI is open.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 14.5.8
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`14023b8bbf880`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/14023b8bbf880) -
|
|
19
|
+
[ux] Shows reduced profile card when user lacks permission to read/access agent mention on page
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 14.5.7
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/compass.yml
CHANGED
|
@@ -24,6 +24,9 @@ customFields:
|
|
|
24
24
|
- name: Department
|
|
25
25
|
type: text
|
|
26
26
|
value: Eng - Editor AI
|
|
27
|
+
- name: Trusted Reviewer Teams
|
|
28
|
+
type: text
|
|
29
|
+
value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
|
|
27
30
|
- name: Technical Owner
|
|
28
31
|
type: user
|
|
29
32
|
value: ari:cloud:identity::user/612646c53fe26c00694fbe6a # Chris Kimber
|
|
@@ -143,7 +143,8 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
143
143
|
api: api
|
|
144
144
|
}),
|
|
145
145
|
destroyProfileCard = _profileCardRenderer.destroyProfileCard,
|
|
146
|
-
removeProfileCard = _profileCardRenderer.removeProfileCard
|
|
146
|
+
removeProfileCard = _profileCardRenderer.removeProfileCard,
|
|
147
|
+
updateNode = _profileCardRenderer.updateNode;
|
|
147
148
|
// Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
|
|
148
149
|
if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
|
|
149
150
|
if (node.attrs.text) {
|
|
@@ -156,6 +157,7 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
156
157
|
}
|
|
157
158
|
this.destroyProfileCard = destroyProfileCard;
|
|
158
159
|
this.removeProfileCard = removeProfileCard;
|
|
160
|
+
this.updateProfileCardNode = updateNode;
|
|
159
161
|
}
|
|
160
162
|
return (0, _createClass2.default)(MentionNodeView, [{
|
|
161
163
|
key: "setClassList",
|
|
@@ -333,10 +335,14 @@ var MentionNodeView = exports.MentionNodeView = /*#__PURE__*/function () {
|
|
|
333
335
|
}, {
|
|
334
336
|
key: "update",
|
|
335
337
|
value: function update(node) {
|
|
338
|
+
var _this$updateProfileCa;
|
|
336
339
|
if (!this.nodeIsEqual(node)) {
|
|
337
340
|
return false;
|
|
338
341
|
}
|
|
339
342
|
this.node = node;
|
|
343
|
+
// Keep the profile card renderer's node reference in sync so that the
|
|
344
|
+
// click handler always reads up-to-date attrs.
|
|
345
|
+
(_this$updateProfileCa = this.updateProfileCardNode) === null || _this$updateProfileCa === void 0 || _this$updateProfileCa.call(this, node);
|
|
340
346
|
return true;
|
|
341
347
|
}
|
|
342
348
|
}, {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.profileCardRenderer = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _bindEventListener = require("bind-event-listener");
|
|
10
11
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
@@ -13,14 +14,17 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
13
14
|
var _navigation = require("@atlaskit/teams-app-config/navigation");
|
|
14
15
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
15
16
|
var _ProfileCardComponent = require("../ui/ProfileCardComponent");
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
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
|
+
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
|
|
18
19
|
var profileCardRenderer = exports.profileCardRenderer = function profileCardRenderer(_ref) {
|
|
19
20
|
var dom = _ref.dom,
|
|
20
21
|
options = _ref.options,
|
|
21
22
|
portalProviderAPI = _ref.portalProviderAPI,
|
|
22
23
|
node = _ref.node,
|
|
23
24
|
api = _ref.api;
|
|
25
|
+
// Keep a mutable reference to the latest node so the click handler always
|
|
26
|
+
// reads up-to-date attrs
|
|
27
|
+
var currentNode = node;
|
|
24
28
|
var renderingProfileCard = false;
|
|
25
29
|
var navigatingToProfile = false;
|
|
26
30
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -49,16 +53,28 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
|
|
|
49
53
|
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
50
54
|
var nextSharedState = _ref2.nextSharedState;
|
|
51
55
|
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
52
|
-
if (selection instanceof _state.NodeSelection ? selection.node === node : false) {
|
|
56
|
+
if (selection instanceof _state.NodeSelection ? (0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? selection.node.sameMarkup(currentNode) : selection.node === node : false) {
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
59
|
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
62
|
var renderEditorProfileCard = function renderEditorProfileCard() {
|
|
63
|
+
var activeMention = (0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? function (_dom$querySelector, _currentNode, _currentNode2) {
|
|
64
|
+
// Read the display name from the DOM element at click time — this is
|
|
65
|
+
// always up-to-date even when node.attrs.text is absent
|
|
66
|
+
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;
|
|
67
|
+
return {
|
|
68
|
+
attrs: _objectSpread(_objectSpread({}, (_currentNode = currentNode) === null || _currentNode === void 0 ? void 0 : _currentNode.attrs), {}, {
|
|
69
|
+
text: ((_currentNode2 = currentNode) === null || _currentNode2 === void 0 || (_currentNode2 = _currentNode2.attrs) === null || _currentNode2 === void 0 ? void 0 : _currentNode2.text) || primitiveText || undefined
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
}() : {
|
|
73
|
+
attrs: node.attrs
|
|
74
|
+
};
|
|
59
75
|
renderProfileCardPopup(function (referenceElement) {
|
|
60
76
|
return /*#__PURE__*/_react.default.createElement(_ProfileCardComponent.ProfileCardComponent, {
|
|
61
|
-
activeMention:
|
|
77
|
+
activeMention: activeMention,
|
|
62
78
|
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
63
79
|
dom: referenceElement,
|
|
64
80
|
closeComponent: removeProfileCard
|
|
@@ -112,19 +128,19 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
|
|
|
112
128
|
type: 'click',
|
|
113
129
|
listener: function listener() {
|
|
114
130
|
if ((0, _platformFeatureFlags.fg)('people-teams_migrate-user-profile-card')) {
|
|
115
|
-
var _node$attrs, _options$profilecardP;
|
|
116
|
-
var userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
131
|
+
var _currentNode$attrs, _node$attrs, _options$profilecardP;
|
|
132
|
+
var userId = (0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs = currentNode.attrs) === null || _currentNode$attrs === void 0 ? void 0 : _currentNode$attrs.id : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
117
133
|
if (!userId) {
|
|
118
134
|
return;
|
|
119
135
|
}
|
|
120
136
|
navigatingToProfile = false;
|
|
121
137
|
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
122
|
-
var _node$attrs2;
|
|
138
|
+
var _currentNode$attrs2, _node$attrs2;
|
|
123
139
|
if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
124
140
|
renderDefaultProfileCard(userId, provider);
|
|
125
141
|
return;
|
|
126
142
|
}
|
|
127
|
-
if ((0, _ProfileCardComponent.isAgentMentionType)((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
143
|
+
if ((0, _ProfileCardComponent.isAgentMentionType)((0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs2 = currentNode.attrs) === null || _currentNode$attrs2 === void 0 ? void 0 : _currentNode$attrs2.userType : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
128
144
|
renderEditorProfileCard();
|
|
129
145
|
} else {
|
|
130
146
|
renderDefaultProfileCard(userId, provider);
|
|
@@ -142,6 +158,9 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
|
|
|
142
158
|
listenerCleanup();
|
|
143
159
|
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
144
160
|
},
|
|
145
|
-
removeProfileCard: removeProfileCard
|
|
161
|
+
removeProfileCard: removeProfileCard,
|
|
162
|
+
updateNode: function updateNode(nextNode) {
|
|
163
|
+
currentNode = nextNode;
|
|
164
|
+
}
|
|
146
165
|
};
|
|
147
166
|
};
|
|
@@ -49,8 +49,9 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
|
49
49
|
};
|
|
50
50
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
51
51
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
52
|
+
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
52
53
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
53
|
-
var PACKAGE_VERSION = "14.5.
|
|
54
|
+
var PACKAGE_VERSION = "14.5.8";
|
|
54
55
|
var setProvider = function setProvider(provider) {
|
|
55
56
|
return function (state, dispatch) {
|
|
56
57
|
if (dispatch) {
|
|
@@ -624,14 +625,47 @@ function createMentionPlugin(_ref2) {
|
|
|
624
625
|
var isAgentMentionsEnabled = (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true);
|
|
625
626
|
var pendingTypedAgentMentionTimer;
|
|
626
627
|
var pendingTypedAgentMentionTimerKey = null;
|
|
628
|
+
var pendingTypedAgentMentionFocusDeferCount = 0;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Clears the currently scheduled pending typed-agent-mention timer.
|
|
632
|
+
*
|
|
633
|
+
* By default this also resets the focus defer count because a new pending mention,
|
|
634
|
+
* local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
|
|
635
|
+
* retries pass `preserveFocusDeferCount` so repeated defers for the same pending
|
|
636
|
+
* mention are counted toward the bounded retry cap.
|
|
637
|
+
*/
|
|
627
638
|
var clearPendingTypedAgentMentionTimer = function clearPendingTypedAgentMentionTimer() {
|
|
639
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
640
|
+
_ref4$preserveFocusDe = _ref4.preserveFocusDeferCount,
|
|
641
|
+
preserveFocusDeferCount = _ref4$preserveFocusDe === void 0 ? false : _ref4$preserveFocusDe;
|
|
628
642
|
if (pendingTypedAgentMentionTimer) {
|
|
629
643
|
clearTimeout(pendingTypedAgentMentionTimer);
|
|
630
644
|
pendingTypedAgentMentionTimer = undefined;
|
|
631
645
|
}
|
|
632
646
|
pendingTypedAgentMentionTimerKey = null;
|
|
647
|
+
if (!preserveFocusDeferCount) {
|
|
648
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Typed agent mentions intentionally wait before invoking the agent so content the
|
|
654
|
+
* user adds next can become context. That context can be authored through
|
|
655
|
+
* editor-adjacent UI, such as mention typeahead, date picker, or status picker,
|
|
656
|
+
* where focus leaves the ProseMirror editor but remains in the active document.
|
|
657
|
+
* Treat that as continued authoring activity by restarting the inactivity window.
|
|
658
|
+
* This only defers the inactivity timer path: existing selection-change handling can
|
|
659
|
+
* still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
|
|
660
|
+
* publish anyway so pathological focus states cannot keep the mention pending indefinitely.
|
|
661
|
+
*/
|
|
662
|
+
var shouldDeferPendingTypedAgentMention = function shouldDeferPendingTypedAgentMention() {
|
|
663
|
+
return typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
|
|
633
664
|
};
|
|
634
|
-
var
|
|
665
|
+
var _schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
|
|
666
|
+
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
667
|
+
_ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
|
|
668
|
+
preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
|
|
635
669
|
if (!isAgentMentionsEnabled) {
|
|
636
670
|
clearPendingTypedAgentMentionTimer();
|
|
637
671
|
return;
|
|
@@ -645,7 +679,9 @@ function createMentionPlugin(_ref2) {
|
|
|
645
679
|
if (timerKey === pendingTypedAgentMentionTimerKey) {
|
|
646
680
|
return;
|
|
647
681
|
}
|
|
648
|
-
clearPendingTypedAgentMentionTimer(
|
|
682
|
+
clearPendingTypedAgentMentionTimer({
|
|
683
|
+
preserveFocusDeferCount: preserveFocusDeferCount
|
|
684
|
+
});
|
|
649
685
|
pendingTypedAgentMentionTimerKey = timerKey;
|
|
650
686
|
pendingTypedAgentMentionTimer = setTimeout(function () {
|
|
651
687
|
var _mentionPluginKey$get;
|
|
@@ -653,6 +689,15 @@ function createMentionPlugin(_ref2) {
|
|
|
653
689
|
if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
|
|
654
690
|
return;
|
|
655
691
|
}
|
|
692
|
+
if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
|
|
693
|
+
pendingTypedAgentMentionFocusDeferCount++;
|
|
694
|
+
pendingTypedAgentMentionTimerKey = null;
|
|
695
|
+
_schedulePendingTypedAgentMentionTimer(_key.mentionPluginKey.getState(editorView.state), {
|
|
696
|
+
preserveFocusDeferCount: true
|
|
697
|
+
});
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
656
701
|
editorView.dispatch(editorView.state.tr.setMeta(_key.mentionPluginKey, {
|
|
657
702
|
action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
|
|
658
703
|
params: {
|
|
@@ -712,7 +757,7 @@ function createMentionPlugin(_ref2) {
|
|
|
712
757
|
if (mentionPluginState === _key.mentionPluginKey.getState(prevState)) {
|
|
713
758
|
return;
|
|
714
759
|
}
|
|
715
|
-
|
|
760
|
+
_schedulePendingTypedAgentMentionTimer(mentionPluginState);
|
|
716
761
|
},
|
|
717
762
|
destroy: function destroy() {
|
|
718
763
|
clearPendingTypedAgentMentionTimer();
|
|
@@ -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");
|
|
@@ -190,7 +191,8 @@ function ProfileCardComponent(_ref5) {
|
|
|
190
191
|
referenceElement: dom
|
|
191
192
|
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
192
193
|
accountId: id,
|
|
193
|
-
provider: provider
|
|
194
|
+
provider: provider,
|
|
195
|
+
text: (0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? text : undefined
|
|
194
196
|
}) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
195
197
|
accessLevel: accessLevel,
|
|
196
198
|
id: id,
|
|
@@ -198,20 +200,11 @@ function ProfileCardComponent(_ref5) {
|
|
|
198
200
|
text: text
|
|
199
201
|
}));
|
|
200
202
|
}
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
cloudId: provider.cloudId,
|
|
207
|
-
resourceClient: provider.resourceClient
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
var UserProfileCardContent = function UserProfileCardContent(_ref9) {
|
|
211
|
-
var accessLevel = _ref9.accessLevel,
|
|
212
|
-
id = _ref9.id,
|
|
213
|
-
provider = _ref9.provider,
|
|
214
|
-
text = _ref9.text;
|
|
203
|
+
var UserProfileCardContent = function UserProfileCardContent(_ref8) {
|
|
204
|
+
var accessLevel = _ref8.accessLevel,
|
|
205
|
+
id = _ref8.id,
|
|
206
|
+
provider = _ref8.provider,
|
|
207
|
+
text = _ref8.text;
|
|
215
208
|
var actions = (0, _react.useMemo)(function () {
|
|
216
209
|
return provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
|
|
217
210
|
}, [accessLevel, id, provider, text]);
|
|
@@ -251,4 +244,21 @@ var UserProfileCardContent = function UserProfileCardContent(_ref9) {
|
|
|
251
244
|
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
252
245
|
isRenderedInPortal: (0, _expValEquals.expValEquals)('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
|
|
253
246
|
}));
|
|
247
|
+
};
|
|
248
|
+
var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
|
|
249
|
+
var accountId = _ref9.accountId,
|
|
250
|
+
provider = _ref9.provider,
|
|
251
|
+
text = _ref9.text;
|
|
252
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
253
|
+
var agentName = (text !== null && text !== void 0 ? text : '').replace(/^@/, '');
|
|
254
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_reduced_agent_profile_card') ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
255
|
+
accountId: accountId,
|
|
256
|
+
cloudId: provider.cloudId,
|
|
257
|
+
resourceClient: provider.resourceClient,
|
|
258
|
+
agentName: agentName
|
|
259
|
+
}) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
260
|
+
accountId: accountId,
|
|
261
|
+
cloudId: provider.cloudId,
|
|
262
|
+
resourceClient: provider.resourceClient
|
|
263
|
+
});
|
|
254
264
|
};
|
|
@@ -399,7 +399,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
399
399
|
} : {}), (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
400
400
|
lozenge: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
401
401
|
appearance: "new"
|
|
402
|
-
}, intl.formatMessage(_messages.mentionMessages.
|
|
402
|
+
}, intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
403
403
|
} : {})];
|
|
404
404
|
},
|
|
405
405
|
onOpen: function onOpen() {
|
|
@@ -106,7 +106,8 @@ export class MentionNodeView {
|
|
|
106
106
|
});
|
|
107
107
|
const {
|
|
108
108
|
destroyProfileCard,
|
|
109
|
-
removeProfileCard
|
|
109
|
+
removeProfileCard,
|
|
110
|
+
updateNode
|
|
110
111
|
} = profileCardRenderer({
|
|
111
112
|
dom,
|
|
112
113
|
options,
|
|
@@ -126,6 +127,7 @@ export class MentionNodeView {
|
|
|
126
127
|
}
|
|
127
128
|
this.destroyProfileCard = destroyProfileCard;
|
|
128
129
|
this.removeProfileCard = removeProfileCard;
|
|
130
|
+
this.updateProfileCardNode = updateNode;
|
|
129
131
|
}
|
|
130
132
|
setClassList(state, disabledTooltip) {
|
|
131
133
|
var _this$mentionPrimitiv, _this$mentionPrimitiv2, _this$mentionPrimitiv3;
|
|
@@ -271,10 +273,14 @@ export class MentionNodeView {
|
|
|
271
273
|
return this.node.sameMarkup(nextNode);
|
|
272
274
|
}
|
|
273
275
|
update(node) {
|
|
276
|
+
var _this$updateProfileCa;
|
|
274
277
|
if (!this.nodeIsEqual(node)) {
|
|
275
278
|
return false;
|
|
276
279
|
}
|
|
277
280
|
this.node = node;
|
|
281
|
+
// Keep the profile card renderer's node reference in sync so that the
|
|
282
|
+
// click handler always reads up-to-date attrs.
|
|
283
|
+
(_this$updateProfileCa = this.updateProfileCardNode) === null || _this$updateProfileCa === void 0 ? void 0 : _this$updateProfileCa.call(this, node);
|
|
278
284
|
return true;
|
|
279
285
|
}
|
|
280
286
|
destroy() {
|
|
@@ -14,6 +14,9 @@ export const profileCardRenderer = ({
|
|
|
14
14
|
node,
|
|
15
15
|
api
|
|
16
16
|
}) => {
|
|
17
|
+
// Keep a mutable reference to the latest node so the click handler always
|
|
18
|
+
// reads up-to-date attrs
|
|
19
|
+
let currentNode = node;
|
|
17
20
|
let renderingProfileCard = false;
|
|
18
21
|
let navigatingToProfile = false;
|
|
19
22
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -41,15 +44,28 @@ export const profileCardRenderer = ({
|
|
|
41
44
|
nextSharedState
|
|
42
45
|
}) => {
|
|
43
46
|
const selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
44
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
47
|
+
if (selection instanceof NodeSelection ? fg('platform_editor_reduced_agent_profile_card') ? selection.node.sameMarkup(currentNode) : selection.node === node : false) {
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
removeProfileCard === null || removeProfileCard === void 0 ? void 0 : removeProfileCard();
|
|
48
51
|
});
|
|
49
52
|
};
|
|
50
53
|
const renderEditorProfileCard = () => {
|
|
54
|
+
const activeMention = fg('platform_editor_reduced_agent_profile_card') ? ((_dom$querySelector, _dom$querySelector$te, _currentNode, _currentNode2, _currentNode2$attrs) => {
|
|
55
|
+
// Read the display name from the DOM element at click time — this is
|
|
56
|
+
// always up-to-date even when node.attrs.text is absent
|
|
57
|
+
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;
|
|
58
|
+
return {
|
|
59
|
+
attrs: {
|
|
60
|
+
...((_currentNode = currentNode) === null || _currentNode === void 0 ? void 0 : _currentNode.attrs),
|
|
61
|
+
text: ((_currentNode2 = currentNode) === null || _currentNode2 === void 0 ? void 0 : (_currentNode2$attrs = _currentNode2.attrs) === null || _currentNode2$attrs === void 0 ? void 0 : _currentNode2$attrs.text) || primitiveText || undefined
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
})() : {
|
|
65
|
+
attrs: node.attrs
|
|
66
|
+
};
|
|
51
67
|
renderProfileCardPopup(referenceElement => /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
52
|
-
activeMention:
|
|
68
|
+
activeMention: activeMention,
|
|
53
69
|
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
54
70
|
dom: referenceElement,
|
|
55
71
|
closeComponent: removeProfileCard
|
|
@@ -102,19 +118,19 @@ export const profileCardRenderer = ({
|
|
|
102
118
|
type: 'click',
|
|
103
119
|
listener: () => {
|
|
104
120
|
if (fg('people-teams_migrate-user-profile-card')) {
|
|
105
|
-
var _node$attrs, _options$profilecardP;
|
|
106
|
-
const userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
121
|
+
var _currentNode$attrs, _node$attrs, _options$profilecardP;
|
|
122
|
+
const userId = fg('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs = currentNode.attrs) === null || _currentNode$attrs === void 0 ? void 0 : _currentNode$attrs.id : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
107
123
|
if (!userId) {
|
|
108
124
|
return;
|
|
109
125
|
}
|
|
110
126
|
navigatingToProfile = false;
|
|
111
127
|
options === null || options === void 0 ? void 0 : (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 ? void 0 : _options$profilecardP.then(provider => {
|
|
112
|
-
var _node$attrs2;
|
|
128
|
+
var _currentNode$attrs2, _node$attrs2;
|
|
113
129
|
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
114
130
|
renderDefaultProfileCard(userId, provider);
|
|
115
131
|
return;
|
|
116
132
|
}
|
|
117
|
-
if (isAgentMentionType((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
133
|
+
if (isAgentMentionType(fg('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs2 = currentNode.attrs) === null || _currentNode$attrs2 === void 0 ? void 0 : _currentNode$attrs2.userType : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
118
134
|
renderEditorProfileCard();
|
|
119
135
|
} else {
|
|
120
136
|
renderDefaultProfileCard(userId, provider);
|
|
@@ -132,6 +148,9 @@ export const profileCardRenderer = ({
|
|
|
132
148
|
listenerCleanup();
|
|
133
149
|
removeProfileCard === null || removeProfileCard === void 0 ? void 0 : removeProfileCard();
|
|
134
150
|
},
|
|
135
|
-
removeProfileCard
|
|
151
|
+
removeProfileCard,
|
|
152
|
+
updateNode: nextNode => {
|
|
153
|
+
currentNode = nextNode;
|
|
154
|
+
}
|
|
136
155
|
};
|
|
137
156
|
};
|
|
@@ -34,8 +34,9 @@ const getAgentMentionName = (text, fallbackName) => {
|
|
|
34
34
|
};
|
|
35
35
|
const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
36
36
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
37
|
+
const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
37
38
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
38
|
-
const PACKAGE_VERSION = "14.5.
|
|
39
|
+
const PACKAGE_VERSION = "14.5.8";
|
|
39
40
|
const setProvider = provider => (state, dispatch) => {
|
|
40
41
|
if (dispatch) {
|
|
41
42
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -583,14 +584,43 @@ export function createMentionPlugin({
|
|
|
583
584
|
const isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
|
|
584
585
|
let pendingTypedAgentMentionTimer;
|
|
585
586
|
let pendingTypedAgentMentionTimerKey = null;
|
|
586
|
-
|
|
587
|
+
let pendingTypedAgentMentionFocusDeferCount = 0;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Clears the currently scheduled pending typed-agent-mention timer.
|
|
591
|
+
*
|
|
592
|
+
* By default this also resets the focus defer count because a new pending mention,
|
|
593
|
+
* local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
|
|
594
|
+
* retries pass `preserveFocusDeferCount` so repeated defers for the same pending
|
|
595
|
+
* mention are counted toward the bounded retry cap.
|
|
596
|
+
*/
|
|
597
|
+
const clearPendingTypedAgentMentionTimer = ({
|
|
598
|
+
preserveFocusDeferCount = false
|
|
599
|
+
} = {}) => {
|
|
587
600
|
if (pendingTypedAgentMentionTimer) {
|
|
588
601
|
clearTimeout(pendingTypedAgentMentionTimer);
|
|
589
602
|
pendingTypedAgentMentionTimer = undefined;
|
|
590
603
|
}
|
|
591
604
|
pendingTypedAgentMentionTimerKey = null;
|
|
605
|
+
if (!preserveFocusDeferCount) {
|
|
606
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
607
|
+
}
|
|
592
608
|
};
|
|
593
|
-
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Typed agent mentions intentionally wait before invoking the agent so content the
|
|
612
|
+
* user adds next can become context. That context can be authored through
|
|
613
|
+
* editor-adjacent UI, such as mention typeahead, date picker, or status picker,
|
|
614
|
+
* where focus leaves the ProseMirror editor but remains in the active document.
|
|
615
|
+
* Treat that as continued authoring activity by restarting the inactivity window.
|
|
616
|
+
* This only defers the inactivity timer path: existing selection-change handling can
|
|
617
|
+
* still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
|
|
618
|
+
* publish anyway so pathological focus states cannot keep the mention pending indefinitely.
|
|
619
|
+
*/
|
|
620
|
+
const shouldDeferPendingTypedAgentMention = () => typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
|
|
621
|
+
const schedulePendingTypedAgentMentionTimer = (mentionPluginState, {
|
|
622
|
+
preserveFocusDeferCount = false
|
|
623
|
+
} = {}) => {
|
|
594
624
|
if (!isAgentMentionsEnabled) {
|
|
595
625
|
clearPendingTypedAgentMentionTimer();
|
|
596
626
|
return;
|
|
@@ -604,7 +634,9 @@ export function createMentionPlugin({
|
|
|
604
634
|
if (timerKey === pendingTypedAgentMentionTimerKey) {
|
|
605
635
|
return;
|
|
606
636
|
}
|
|
607
|
-
clearPendingTypedAgentMentionTimer(
|
|
637
|
+
clearPendingTypedAgentMentionTimer({
|
|
638
|
+
preserveFocusDeferCount
|
|
639
|
+
});
|
|
608
640
|
pendingTypedAgentMentionTimerKey = timerKey;
|
|
609
641
|
pendingTypedAgentMentionTimer = setTimeout(() => {
|
|
610
642
|
var _mentionPluginKey$get;
|
|
@@ -612,6 +644,15 @@ export function createMentionPlugin({
|
|
|
612
644
|
if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
|
|
613
645
|
return;
|
|
614
646
|
}
|
|
647
|
+
if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
|
|
648
|
+
pendingTypedAgentMentionFocusDeferCount++;
|
|
649
|
+
pendingTypedAgentMentionTimerKey = null;
|
|
650
|
+
schedulePendingTypedAgentMentionTimer(mentionPluginKey.getState(editorView.state), {
|
|
651
|
+
preserveFocusDeferCount: true
|
|
652
|
+
});
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
615
656
|
editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
|
|
616
657
|
action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
|
|
617
658
|
params: {
|
|
@@ -5,6 +5,7 @@ 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';
|
|
@@ -119,7 +120,8 @@ export function ProfileCardComponent({
|
|
|
119
120
|
referenceElement: dom
|
|
120
121
|
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
121
122
|
accountId: id,
|
|
122
|
-
provider: provider
|
|
123
|
+
provider: provider,
|
|
124
|
+
text: fg('platform_editor_reduced_agent_profile_card') ? text : undefined
|
|
123
125
|
}) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
124
126
|
accessLevel: accessLevel,
|
|
125
127
|
id: id,
|
|
@@ -127,14 +129,6 @@ export function ProfileCardComponent({
|
|
|
127
129
|
text: text
|
|
128
130
|
}));
|
|
129
131
|
}
|
|
130
|
-
const AgentProfileCardContent = ({
|
|
131
|
-
accountId,
|
|
132
|
-
provider
|
|
133
|
-
}) => /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
134
|
-
accountId: accountId,
|
|
135
|
-
cloudId: provider.cloudId,
|
|
136
|
-
resourceClient: provider.resourceClient
|
|
137
|
-
});
|
|
138
132
|
const UserProfileCardContent = ({
|
|
139
133
|
accessLevel,
|
|
140
134
|
id,
|
|
@@ -179,4 +173,22 @@ const UserProfileCardContent = ({
|
|
|
179
173
|
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
180
174
|
isRenderedInPortal: expValEquals('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
|
|
181
175
|
}));
|
|
176
|
+
};
|
|
177
|
+
const AgentProfileCardContent = ({
|
|
178
|
+
accountId,
|
|
179
|
+
provider,
|
|
180
|
+
text
|
|
181
|
+
}) => {
|
|
182
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
183
|
+
const agentName = (text !== null && text !== void 0 ? text : '').replace(/^@/, '');
|
|
184
|
+
return fg('platform_editor_reduced_agent_profile_card') ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
185
|
+
accountId: accountId,
|
|
186
|
+
cloudId: provider.cloudId,
|
|
187
|
+
resourceClient: provider.resourceClient,
|
|
188
|
+
agentName: agentName
|
|
189
|
+
}) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
190
|
+
accountId: accountId,
|
|
191
|
+
cloudId: provider.cloudId,
|
|
192
|
+
resourceClient: provider.resourceClient
|
|
193
|
+
});
|
|
182
194
|
};
|
|
@@ -373,7 +373,7 @@ export const createTypeAheadConfig = ({
|
|
|
373
373
|
...(expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
374
374
|
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
375
375
|
appearance: "new"
|
|
376
|
-
}, intl.formatMessage(mentionMessages.
|
|
376
|
+
}, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
377
377
|
} : {})
|
|
378
378
|
}];
|
|
379
379
|
},
|
|
@@ -136,7 +136,8 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
136
136
|
api: api
|
|
137
137
|
}),
|
|
138
138
|
destroyProfileCard = _profileCardRenderer.destroyProfileCard,
|
|
139
|
-
removeProfileCard = _profileCardRenderer.removeProfileCard
|
|
139
|
+
removeProfileCard = _profileCardRenderer.removeProfileCard,
|
|
140
|
+
updateNode = _profileCardRenderer.updateNode;
|
|
140
141
|
// Accessibility attributes - based on `packages/people-and-teams/profilecard/src/components/User/ProfileCardTrigger.tsx`
|
|
141
142
|
if (this.domElement && options !== null && options !== void 0 && options.profilecardProvider) {
|
|
142
143
|
if (node.attrs.text) {
|
|
@@ -149,6 +150,7 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
149
150
|
}
|
|
150
151
|
this.destroyProfileCard = destroyProfileCard;
|
|
151
152
|
this.removeProfileCard = removeProfileCard;
|
|
153
|
+
this.updateProfileCardNode = updateNode;
|
|
152
154
|
}
|
|
153
155
|
return _createClass(MentionNodeView, [{
|
|
154
156
|
key: "setClassList",
|
|
@@ -326,10 +328,14 @@ export var MentionNodeView = /*#__PURE__*/function () {
|
|
|
326
328
|
}, {
|
|
327
329
|
key: "update",
|
|
328
330
|
value: function update(node) {
|
|
331
|
+
var _this$updateProfileCa;
|
|
329
332
|
if (!this.nodeIsEqual(node)) {
|
|
330
333
|
return false;
|
|
331
334
|
}
|
|
332
335
|
this.node = node;
|
|
336
|
+
// Keep the profile card renderer's node reference in sync so that the
|
|
337
|
+
// click handler always reads up-to-date attrs.
|
|
338
|
+
(_this$updateProfileCa = this.updateProfileCardNode) === null || _this$updateProfileCa === void 0 || _this$updateProfileCa.call(this, node);
|
|
333
339
|
return true;
|
|
334
340
|
}
|
|
335
341
|
}, {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { bind } from 'bind-event-listener';
|
|
3
6
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -13,6 +16,9 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
|
13
16
|
portalProviderAPI = _ref.portalProviderAPI,
|
|
14
17
|
node = _ref.node,
|
|
15
18
|
api = _ref.api;
|
|
19
|
+
// Keep a mutable reference to the latest node so the click handler always
|
|
20
|
+
// reads up-to-date attrs
|
|
21
|
+
var currentNode = node;
|
|
16
22
|
var renderingProfileCard = false;
|
|
17
23
|
var navigatingToProfile = false;
|
|
18
24
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -41,16 +47,28 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
|
41
47
|
cleanupSelection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.sharedState.onChange(function (_ref2) {
|
|
42
48
|
var nextSharedState = _ref2.nextSharedState;
|
|
43
49
|
var selection = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.selection;
|
|
44
|
-
if (selection instanceof NodeSelection ? selection.node === node : false) {
|
|
50
|
+
if (selection instanceof NodeSelection ? fg('platform_editor_reduced_agent_profile_card') ? selection.node.sameMarkup(currentNode) : selection.node === node : false) {
|
|
45
51
|
return;
|
|
46
52
|
}
|
|
47
53
|
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
48
54
|
});
|
|
49
55
|
};
|
|
50
56
|
var renderEditorProfileCard = function renderEditorProfileCard() {
|
|
57
|
+
var activeMention = fg('platform_editor_reduced_agent_profile_card') ? function (_dom$querySelector, _currentNode, _currentNode2) {
|
|
58
|
+
// Read the display name from the DOM element at click time — this is
|
|
59
|
+
// always up-to-date even when node.attrs.text is absent
|
|
60
|
+
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;
|
|
61
|
+
return {
|
|
62
|
+
attrs: _objectSpread(_objectSpread({}, (_currentNode = currentNode) === null || _currentNode === void 0 ? void 0 : _currentNode.attrs), {}, {
|
|
63
|
+
text: ((_currentNode2 = currentNode) === null || _currentNode2 === void 0 || (_currentNode2 = _currentNode2.attrs) === null || _currentNode2 === void 0 ? void 0 : _currentNode2.text) || primitiveText || undefined
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
}() : {
|
|
67
|
+
attrs: node.attrs
|
|
68
|
+
};
|
|
51
69
|
renderProfileCardPopup(function (referenceElement) {
|
|
52
70
|
return /*#__PURE__*/React.createElement(ProfileCardComponent, {
|
|
53
|
-
activeMention:
|
|
71
|
+
activeMention: activeMention,
|
|
54
72
|
profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
|
|
55
73
|
dom: referenceElement,
|
|
56
74
|
closeComponent: removeProfileCard
|
|
@@ -104,19 +122,19 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
|
104
122
|
type: 'click',
|
|
105
123
|
listener: function listener() {
|
|
106
124
|
if (fg('people-teams_migrate-user-profile-card')) {
|
|
107
|
-
var _node$attrs, _options$profilecardP;
|
|
108
|
-
var userId = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
125
|
+
var _currentNode$attrs, _node$attrs, _options$profilecardP;
|
|
126
|
+
var userId = fg('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs = currentNode.attrs) === null || _currentNode$attrs === void 0 ? void 0 : _currentNode$attrs.id : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id;
|
|
109
127
|
if (!userId) {
|
|
110
128
|
return;
|
|
111
129
|
}
|
|
112
130
|
navigatingToProfile = false;
|
|
113
131
|
options === null || options === void 0 || (_options$profilecardP = options.profilecardProvider) === null || _options$profilecardP === void 0 || _options$profilecardP.then(function (provider) {
|
|
114
|
-
var _node$attrs2;
|
|
132
|
+
var _currentNode$attrs2, _node$attrs2;
|
|
115
133
|
if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
|
|
116
134
|
renderDefaultProfileCard(userId, provider);
|
|
117
135
|
return;
|
|
118
136
|
}
|
|
119
|
-
if (isAgentMentionType((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
137
|
+
if (isAgentMentionType(fg('platform_editor_reduced_agent_profile_card') ? (_currentNode$attrs2 = currentNode.attrs) === null || _currentNode$attrs2 === void 0 ? void 0 : _currentNode$attrs2.userType : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.userType)) {
|
|
120
138
|
renderEditorProfileCard();
|
|
121
139
|
} else {
|
|
122
140
|
renderDefaultProfileCard(userId, provider);
|
|
@@ -134,6 +152,9 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
|
|
|
134
152
|
listenerCleanup();
|
|
135
153
|
removeProfileCard === null || removeProfileCard === void 0 || removeProfileCard();
|
|
136
154
|
},
|
|
137
|
-
removeProfileCard: removeProfileCard
|
|
155
|
+
removeProfileCard: removeProfileCard,
|
|
156
|
+
updateNode: function updateNode(nextNode) {
|
|
157
|
+
currentNode = nextNode;
|
|
158
|
+
}
|
|
138
159
|
};
|
|
139
160
|
};
|
|
@@ -41,8 +41,9 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
|
|
|
41
41
|
};
|
|
42
42
|
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
43
43
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
44
|
+
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
44
45
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
45
|
-
var PACKAGE_VERSION = "14.5.
|
|
46
|
+
var PACKAGE_VERSION = "14.5.8";
|
|
46
47
|
var setProvider = function setProvider(provider) {
|
|
47
48
|
return function (state, dispatch) {
|
|
48
49
|
if (dispatch) {
|
|
@@ -616,14 +617,47 @@ export function createMentionPlugin(_ref2) {
|
|
|
616
617
|
var isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
|
|
617
618
|
var pendingTypedAgentMentionTimer;
|
|
618
619
|
var pendingTypedAgentMentionTimerKey = null;
|
|
620
|
+
var pendingTypedAgentMentionFocusDeferCount = 0;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Clears the currently scheduled pending typed-agent-mention timer.
|
|
624
|
+
*
|
|
625
|
+
* By default this also resets the focus defer count because a new pending mention,
|
|
626
|
+
* local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
|
|
627
|
+
* retries pass `preserveFocusDeferCount` so repeated defers for the same pending
|
|
628
|
+
* mention are counted toward the bounded retry cap.
|
|
629
|
+
*/
|
|
619
630
|
var clearPendingTypedAgentMentionTimer = function clearPendingTypedAgentMentionTimer() {
|
|
631
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
632
|
+
_ref4$preserveFocusDe = _ref4.preserveFocusDeferCount,
|
|
633
|
+
preserveFocusDeferCount = _ref4$preserveFocusDe === void 0 ? false : _ref4$preserveFocusDe;
|
|
620
634
|
if (pendingTypedAgentMentionTimer) {
|
|
621
635
|
clearTimeout(pendingTypedAgentMentionTimer);
|
|
622
636
|
pendingTypedAgentMentionTimer = undefined;
|
|
623
637
|
}
|
|
624
638
|
pendingTypedAgentMentionTimerKey = null;
|
|
639
|
+
if (!preserveFocusDeferCount) {
|
|
640
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Typed agent mentions intentionally wait before invoking the agent so content the
|
|
646
|
+
* user adds next can become context. That context can be authored through
|
|
647
|
+
* editor-adjacent UI, such as mention typeahead, date picker, or status picker,
|
|
648
|
+
* where focus leaves the ProseMirror editor but remains in the active document.
|
|
649
|
+
* Treat that as continued authoring activity by restarting the inactivity window.
|
|
650
|
+
* This only defers the inactivity timer path: existing selection-change handling can
|
|
651
|
+
* still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
|
|
652
|
+
* publish anyway so pathological focus states cannot keep the mention pending indefinitely.
|
|
653
|
+
*/
|
|
654
|
+
var shouldDeferPendingTypedAgentMention = function shouldDeferPendingTypedAgentMention() {
|
|
655
|
+
return typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
|
|
625
656
|
};
|
|
626
|
-
var
|
|
657
|
+
var _schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
|
|
658
|
+
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
659
|
+
_ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
|
|
660
|
+
preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
|
|
627
661
|
if (!isAgentMentionsEnabled) {
|
|
628
662
|
clearPendingTypedAgentMentionTimer();
|
|
629
663
|
return;
|
|
@@ -637,7 +671,9 @@ export function createMentionPlugin(_ref2) {
|
|
|
637
671
|
if (timerKey === pendingTypedAgentMentionTimerKey) {
|
|
638
672
|
return;
|
|
639
673
|
}
|
|
640
|
-
clearPendingTypedAgentMentionTimer(
|
|
674
|
+
clearPendingTypedAgentMentionTimer({
|
|
675
|
+
preserveFocusDeferCount: preserveFocusDeferCount
|
|
676
|
+
});
|
|
641
677
|
pendingTypedAgentMentionTimerKey = timerKey;
|
|
642
678
|
pendingTypedAgentMentionTimer = setTimeout(function () {
|
|
643
679
|
var _mentionPluginKey$get;
|
|
@@ -645,6 +681,15 @@ export function createMentionPlugin(_ref2) {
|
|
|
645
681
|
if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
|
|
646
682
|
return;
|
|
647
683
|
}
|
|
684
|
+
if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
|
|
685
|
+
pendingTypedAgentMentionFocusDeferCount++;
|
|
686
|
+
pendingTypedAgentMentionTimerKey = null;
|
|
687
|
+
_schedulePendingTypedAgentMentionTimer(mentionPluginKey.getState(editorView.state), {
|
|
688
|
+
preserveFocusDeferCount: true
|
|
689
|
+
});
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
pendingTypedAgentMentionFocusDeferCount = 0;
|
|
648
693
|
editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
|
|
649
694
|
action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
|
|
650
695
|
params: {
|
|
@@ -704,7 +749,7 @@ export function createMentionPlugin(_ref2) {
|
|
|
704
749
|
if (mentionPluginState === mentionPluginKey.getState(prevState)) {
|
|
705
750
|
return;
|
|
706
751
|
}
|
|
707
|
-
|
|
752
|
+
_schedulePendingTypedAgentMentionTimer(mentionPluginState);
|
|
708
753
|
},
|
|
709
754
|
destroy: function destroy() {
|
|
710
755
|
clearPendingTypedAgentMentionTimer();
|
|
@@ -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';
|
|
@@ -178,7 +179,8 @@ export function ProfileCardComponent(_ref5) {
|
|
|
178
179
|
referenceElement: dom
|
|
179
180
|
}, isAgentMention && provider && id ? /*#__PURE__*/React.createElement(AgentProfileCardContent, {
|
|
180
181
|
accountId: id,
|
|
181
|
-
provider: provider
|
|
182
|
+
provider: provider,
|
|
183
|
+
text: fg('platform_editor_reduced_agent_profile_card') ? text : undefined
|
|
182
184
|
}) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
|
|
183
185
|
accessLevel: accessLevel,
|
|
184
186
|
id: id,
|
|
@@ -186,20 +188,11 @@ export function ProfileCardComponent(_ref5) {
|
|
|
186
188
|
text: text
|
|
187
189
|
}));
|
|
188
190
|
}
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
cloudId: provider.cloudId,
|
|
195
|
-
resourceClient: provider.resourceClient
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
var UserProfileCardContent = function UserProfileCardContent(_ref9) {
|
|
199
|
-
var accessLevel = _ref9.accessLevel,
|
|
200
|
-
id = _ref9.id,
|
|
201
|
-
provider = _ref9.provider,
|
|
202
|
-
text = _ref9.text;
|
|
191
|
+
var UserProfileCardContent = function UserProfileCardContent(_ref8) {
|
|
192
|
+
var accessLevel = _ref8.accessLevel,
|
|
193
|
+
id = _ref8.id,
|
|
194
|
+
provider = _ref8.provider,
|
|
195
|
+
text = _ref8.text;
|
|
203
196
|
var actions = useMemo(function () {
|
|
204
197
|
return provider === null || provider === void 0 ? void 0 : provider.getActions(id, text !== null && text !== void 0 ? text : '', accessLevel);
|
|
205
198
|
}, [accessLevel, id, provider, text]);
|
|
@@ -239,4 +232,21 @@ var UserProfileCardContent = function UserProfileCardContent(_ref9) {
|
|
|
239
232
|
teamCentralBaseUrl: teamCentralBaseUrl,
|
|
240
233
|
isRenderedInPortal: expValEquals('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
|
|
241
234
|
}));
|
|
235
|
+
};
|
|
236
|
+
var AgentProfileCardContent = function AgentProfileCardContent(_ref9) {
|
|
237
|
+
var accountId = _ref9.accountId,
|
|
238
|
+
provider = _ref9.provider,
|
|
239
|
+
text = _ref9.text;
|
|
240
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
241
|
+
var agentName = (text !== null && text !== void 0 ? text : '').replace(/^@/, '');
|
|
242
|
+
return fg('platform_editor_reduced_agent_profile_card') ? /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
243
|
+
accountId: accountId,
|
|
244
|
+
cloudId: provider.cloudId,
|
|
245
|
+
resourceClient: provider.resourceClient,
|
|
246
|
+
agentName: agentName
|
|
247
|
+
}) : /*#__PURE__*/React.createElement(AgentProfileCardResourcedLazy, {
|
|
248
|
+
accountId: accountId,
|
|
249
|
+
cloudId: provider.cloudId,
|
|
250
|
+
resourceClient: provider.resourceClient
|
|
251
|
+
});
|
|
242
252
|
};
|
|
@@ -390,7 +390,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
390
390
|
} : {}), expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
|
|
391
391
|
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
392
392
|
appearance: "new"
|
|
393
|
-
}, intl.formatMessage(mentionMessages.
|
|
393
|
+
}, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
|
|
394
394
|
} : {})];
|
|
395
395
|
},
|
|
396
396
|
onOpen: function onOpen() {
|
|
@@ -18,6 +18,7 @@ export declare class MentionNodeView implements NodeView {
|
|
|
18
18
|
private cleanup;
|
|
19
19
|
private destroyProfileCard;
|
|
20
20
|
private removeProfileCard;
|
|
21
|
+
private updateProfileCardNode;
|
|
21
22
|
private mentionPrimitiveElement;
|
|
22
23
|
private disabledTooltip;
|
|
23
24
|
private unsubscribeFromDisabledStateChanges;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MentionAttributes } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { ProfileCardClientData, TeamCentralReportingLinesData } from '@atlaskit/profilecard/types';
|
|
4
4
|
interface ProfileCardStateProps {
|
|
5
5
|
id: string | undefined;
|
|
@@ -18,7 +18,9 @@ export declare const useProfileCardState: ({ id, provider, }: ProfileCardStatePr
|
|
|
18
18
|
* Renders the profile card popup for an editor mention node.
|
|
19
19
|
*/
|
|
20
20
|
export declare function ProfileCardComponent({ profilecardProvider, activeMention, dom, closeComponent, }: {
|
|
21
|
-
activeMention:
|
|
21
|
+
activeMention: {
|
|
22
|
+
attrs: MentionAttributes;
|
|
23
|
+
};
|
|
22
24
|
closeComponent: () => void;
|
|
23
25
|
dom: HTMLElement;
|
|
24
26
|
profilecardProvider?: Promise<ProfilecardProvider> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.9",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/profilecard": "^26.5.0",
|
|
42
42
|
"@atlaskit/teams-app-config": "^2.1.0",
|
|
43
43
|
"@atlaskit/theme": "^26.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^119.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^119.2.0",
|
|
45
45
|
"@atlaskit/tokens": "^15.3.0",
|
|
46
46
|
"@atlaskit/tooltip": "^23.1.0",
|
|
47
47
|
"@atlaskit/user-picker": "^13.4.0",
|
|
@@ -123,6 +123,9 @@
|
|
|
123
123
|
},
|
|
124
124
|
"rovo_chat_agent_selection": {
|
|
125
125
|
"type": "boolean"
|
|
126
|
+
},
|
|
127
|
+
"platform_editor_reduced_agent_profile_card": {
|
|
128
|
+
"type": "boolean"
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
}
|