@atlaskit/editor-plugin-mentions 12.3.0 → 12.3.2
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 +14 -0
- package/dist/cjs/pm-plugins/main.js +170 -2
- package/dist/es2019/pm-plugins/main.js +146 -2
- package/dist/esm/pm-plugins/main.js +170 -2
- package/dist/types/types/index.d.ts +20 -1
- package/dist/types-ts4.5/types/index.d.ts +20 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 12.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fcf5961a91bce`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fcf5961a91bce) -
|
|
8
|
+
EDITOR-7322 - mentions plugin agent detection and tracking
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 12.3.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 12.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.ACTIONS = void 0;
|
|
8
8
|
exports.createMentionPlugin = createMentionPlugin;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
@@ -13,17 +14,25 @@ var _insm = require("@atlaskit/insm");
|
|
|
13
14
|
var _resource = require("@atlaskit/mention/resource");
|
|
14
15
|
var _types = require("@atlaskit/mention/types");
|
|
15
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
18
|
var _mentionNodeView = require("../nodeviews/mentionNodeView");
|
|
17
19
|
var _types2 = require("../types");
|
|
18
20
|
var _key = require("./key");
|
|
19
21
|
var _utils = require("./utils");
|
|
22
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
23
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
20
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
26
|
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; }
|
|
22
27
|
var ACTIONS = exports.ACTIONS = {
|
|
23
28
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
24
29
|
};
|
|
30
|
+
|
|
31
|
+
// 'AGENT' is not in the ADF schema UserType enum but is used at runtime.
|
|
32
|
+
var AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
33
|
+
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
25
34
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
26
|
-
var PACKAGE_VERSION = "12.
|
|
35
|
+
var PACKAGE_VERSION = "12.3.1";
|
|
27
36
|
var setProvider = function setProvider(provider) {
|
|
28
37
|
return function (state, dispatch) {
|
|
29
38
|
if (dispatch) {
|
|
@@ -90,7 +99,11 @@ function createMentionPlugin(_ref) {
|
|
|
90
99
|
hasNewPluginState = true;
|
|
91
100
|
break;
|
|
92
101
|
}
|
|
93
|
-
|
|
102
|
+
|
|
103
|
+
// When the agent mentions experiment is off, dispatch immediately (original behaviour).
|
|
104
|
+
// When it's on, defer dispatch to after the agent tracking block below so that
|
|
105
|
+
// agent-mention state changes are included in the notification.
|
|
106
|
+
if (hasNewPluginState && !(0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
|
|
94
107
|
pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
|
|
95
108
|
}
|
|
96
109
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
@@ -152,6 +165,161 @@ function createMentionPlugin(_ref) {
|
|
|
152
165
|
}
|
|
153
166
|
(_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
|
|
154
167
|
}
|
|
168
|
+
var isAIStreaming = Boolean(tr.getMeta(AI_STREAMING_TRANSFORMATION_META_KEY));
|
|
169
|
+
if (tr.docChanged && !tr.getMeta('replaceDocument') && !isAIStreaming && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
|
|
170
|
+
var _mentionSchema = newState.schema.nodes.mention;
|
|
171
|
+
var newDocRanges = [];
|
|
172
|
+
var oldDocRanges = [];
|
|
173
|
+
var stepsTouchMentions = false;
|
|
174
|
+
tr.steps.forEach(function (step) {
|
|
175
|
+
var found = false;
|
|
176
|
+
// Only merge a step's ranges if it actually touched an agent mention,
|
|
177
|
+
// so unrelated steps (e.g. mark-only changes) don't inflate the scan area.
|
|
178
|
+
var stepNewRanges = [];
|
|
179
|
+
var stepOldRanges = [];
|
|
180
|
+
step.getMap().forEach(function (oldFrom, oldTo, newFrom, newTo) {
|
|
181
|
+
stepOldRanges.push([oldFrom, oldTo]);
|
|
182
|
+
stepNewRanges.push([newFrom, newTo]);
|
|
183
|
+
if (!found) {
|
|
184
|
+
// Clamp positions: delete-only steps can produce newTo > doc.content.size.
|
|
185
|
+
var clampedNewFrom = Math.min(newFrom, newState.doc.content.size);
|
|
186
|
+
var clampedNewTo = Math.min(newTo, newState.doc.content.size);
|
|
187
|
+
if (clampedNewFrom < clampedNewTo) {
|
|
188
|
+
newState.doc.nodesBetween(clampedNewFrom, clampedNewTo, function (node) {
|
|
189
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
190
|
+
found = true;
|
|
191
|
+
}
|
|
192
|
+
return !found;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (!found) {
|
|
196
|
+
var clampedOldFrom = Math.min(oldFrom, oldState.doc.content.size);
|
|
197
|
+
var clampedOldTo = Math.min(oldTo, oldState.doc.content.size);
|
|
198
|
+
if (clampedOldFrom < clampedOldTo) {
|
|
199
|
+
oldState.doc.nodesBetween(clampedOldFrom, clampedOldTo, function (node) {
|
|
200
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
201
|
+
found = true;
|
|
202
|
+
}
|
|
203
|
+
return !found;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
if (found) {
|
|
210
|
+
stepsTouchMentions = true;
|
|
211
|
+
newDocRanges.push.apply(newDocRanges, stepNewRanges);
|
|
212
|
+
oldDocRanges.push.apply(oldDocRanges, stepOldRanges);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
if (stepsTouchMentions || newPluginState.lastInsertedAgentMentionId) {
|
|
216
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
217
|
+
var agentMentionId = null;
|
|
218
|
+
var agentMentionContext = null;
|
|
219
|
+
var agentMentionParentNodeType = null;
|
|
220
|
+
var newCount = 0;
|
|
221
|
+
var oldAgentMentionId = null;
|
|
222
|
+
var oldCount = 0;
|
|
223
|
+
if (stepsTouchMentions) {
|
|
224
|
+
var _iterator = _createForOfIteratorHelper(newDocRanges),
|
|
225
|
+
_step;
|
|
226
|
+
try {
|
|
227
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
228
|
+
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
229
|
+
from = _step$value[0],
|
|
230
|
+
to = _step$value[1];
|
|
231
|
+
var clampedTo = Math.min(to, newState.doc.content.size);
|
|
232
|
+
if (from >= clampedTo) continue;
|
|
233
|
+
newState.doc.nodesBetween(from, clampedTo, function (node, _pos, parent) {
|
|
234
|
+
if (node.type !== _mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
newCount++;
|
|
238
|
+
if (agentMentionId === null && node.attrs.id) {
|
|
239
|
+
var _parent$type$name;
|
|
240
|
+
agentMentionId = node.attrs.id;
|
|
241
|
+
agentMentionParentNodeType = (_parent$type$name = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name !== void 0 ? _parent$type$name : null;
|
|
242
|
+
agentMentionContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
_iterator.e(err);
|
|
249
|
+
} finally {
|
|
250
|
+
_iterator.f();
|
|
251
|
+
}
|
|
252
|
+
var _iterator2 = _createForOfIteratorHelper(oldDocRanges),
|
|
253
|
+
_step2;
|
|
254
|
+
try {
|
|
255
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
256
|
+
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
257
|
+
_from = _step2$value[0],
|
|
258
|
+
_to = _step2$value[1];
|
|
259
|
+
var clampedOldTo = Math.min(_to, oldState.doc.content.size);
|
|
260
|
+
if (_from >= clampedOldTo) continue;
|
|
261
|
+
oldState.doc.nodesBetween(_from, clampedOldTo, function (node) {
|
|
262
|
+
if (node.type !== _mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
oldCount++;
|
|
266
|
+
if (oldAgentMentionId === null && node.attrs.id) {
|
|
267
|
+
oldAgentMentionId = node.attrs.id;
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
} catch (err) {
|
|
273
|
+
_iterator2.e(err);
|
|
274
|
+
} finally {
|
|
275
|
+
_iterator2.f();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// When a deletion collapses the new-doc range to a zero-width point, or when
|
|
280
|
+
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
281
|
+
// above finds nothing. Check whether any agent mention survived in the document.
|
|
282
|
+
var resolvedFromSurvivor = false;
|
|
283
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
284
|
+
var prevId = newPluginState.lastInsertedAgentMentionId;
|
|
285
|
+
var survivorId = null;
|
|
286
|
+
var survivorContext = null;
|
|
287
|
+
var survivorParentNodeType = null;
|
|
288
|
+
newState.doc.descendants(function (node, _pos, parent) {
|
|
289
|
+
if (survivorId === prevId) return false;
|
|
290
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
291
|
+
var _parent$type$name2;
|
|
292
|
+
// Prefer the previously tracked ID; otherwise keep the first found.
|
|
293
|
+
survivorId = node.attrs.id;
|
|
294
|
+
survivorParentNodeType = (_parent$type$name2 = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name2 !== void 0 ? _parent$type$name2 : null;
|
|
295
|
+
survivorContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
296
|
+
}
|
|
297
|
+
return survivorId !== prevId;
|
|
298
|
+
});
|
|
299
|
+
if (survivorId !== null) {
|
|
300
|
+
agentMentionId = survivorId;
|
|
301
|
+
agentMentionContext = survivorContext;
|
|
302
|
+
agentMentionParentNodeType = survivorParentNodeType;
|
|
303
|
+
resolvedFromSurvivor = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
var isNewInsertion = agentMentionId !== null && !resolvedFromSurvivor && (oldAgentMentionId !== agentMentionId || newCount > oldCount);
|
|
307
|
+
var newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
308
|
+
if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || newInsertionCount !== undefined) {
|
|
309
|
+
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
310
|
+
lastInsertedAgentMentionId: agentMentionId,
|
|
311
|
+
lastInsertedAgentMentionContext: agentMentionContext,
|
|
312
|
+
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
313
|
+
}, newInsertionCount !== undefined ? {
|
|
314
|
+
lastAgentMentionInsertionCount: newInsertionCount
|
|
315
|
+
} : {});
|
|
316
|
+
hasNewPluginState = true;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (hasNewPluginState && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
|
|
321
|
+
pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
|
|
322
|
+
}
|
|
155
323
|
return newPluginState;
|
|
156
324
|
}
|
|
157
325
|
},
|
|
@@ -4,6 +4,7 @@ import { insm } from '@atlaskit/insm';
|
|
|
4
4
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
|
|
5
5
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
8
9
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
9
10
|
import { mentionPluginKey } from './key';
|
|
@@ -11,8 +12,12 @@ import { canMentionBeCreatedInRange } from './utils';
|
|
|
11
12
|
export const ACTIONS = {
|
|
12
13
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
13
14
|
};
|
|
15
|
+
|
|
16
|
+
// 'AGENT' is not in the ADF schema UserType enum but is used at runtime.
|
|
17
|
+
const AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
18
|
+
const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
14
19
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
15
|
-
const PACKAGE_VERSION = "12.
|
|
20
|
+
const PACKAGE_VERSION = "12.3.1";
|
|
16
21
|
const setProvider = provider => (state, dispatch) => {
|
|
17
22
|
if (dispatch) {
|
|
18
23
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -82,7 +87,11 @@ export function createMentionPlugin({
|
|
|
82
87
|
hasNewPluginState = true;
|
|
83
88
|
break;
|
|
84
89
|
}
|
|
85
|
-
|
|
90
|
+
|
|
91
|
+
// When the agent mentions experiment is off, dispatch immediately (original behaviour).
|
|
92
|
+
// When it's on, defer dispatch to after the agent tracking block below so that
|
|
93
|
+
// agent-mention state changes are included in the notification.
|
|
94
|
+
if (hasNewPluginState && !editorExperiment('platform_editor_agent_mentions', true)) {
|
|
86
95
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
87
96
|
}
|
|
88
97
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
@@ -142,6 +151,141 @@ export function createMentionPlugin({
|
|
|
142
151
|
}
|
|
143
152
|
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('mentionDeletionDetection');
|
|
144
153
|
}
|
|
154
|
+
const isAIStreaming = Boolean(tr.getMeta(AI_STREAMING_TRANSFORMATION_META_KEY));
|
|
155
|
+
if (tr.docChanged && !tr.getMeta('replaceDocument') && !isAIStreaming && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
156
|
+
const mentionSchema = newState.schema.nodes.mention;
|
|
157
|
+
const newDocRanges = [];
|
|
158
|
+
const oldDocRanges = [];
|
|
159
|
+
let stepsTouchMentions = false;
|
|
160
|
+
tr.steps.forEach(step => {
|
|
161
|
+
let found = false;
|
|
162
|
+
// Only merge a step's ranges if it actually touched an agent mention,
|
|
163
|
+
// so unrelated steps (e.g. mark-only changes) don't inflate the scan area.
|
|
164
|
+
const stepNewRanges = [];
|
|
165
|
+
const stepOldRanges = [];
|
|
166
|
+
step.getMap().forEach((oldFrom, oldTo, newFrom, newTo) => {
|
|
167
|
+
stepOldRanges.push([oldFrom, oldTo]);
|
|
168
|
+
stepNewRanges.push([newFrom, newTo]);
|
|
169
|
+
if (!found) {
|
|
170
|
+
// Clamp positions: delete-only steps can produce newTo > doc.content.size.
|
|
171
|
+
const clampedNewFrom = Math.min(newFrom, newState.doc.content.size);
|
|
172
|
+
const clampedNewTo = Math.min(newTo, newState.doc.content.size);
|
|
173
|
+
if (clampedNewFrom < clampedNewTo) {
|
|
174
|
+
newState.doc.nodesBetween(clampedNewFrom, clampedNewTo, node => {
|
|
175
|
+
if (node.type === mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
176
|
+
found = true;
|
|
177
|
+
}
|
|
178
|
+
return !found;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (!found) {
|
|
182
|
+
const clampedOldFrom = Math.min(oldFrom, oldState.doc.content.size);
|
|
183
|
+
const clampedOldTo = Math.min(oldTo, oldState.doc.content.size);
|
|
184
|
+
if (clampedOldFrom < clampedOldTo) {
|
|
185
|
+
oldState.doc.nodesBetween(clampedOldFrom, clampedOldTo, node => {
|
|
186
|
+
if (node.type === mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
187
|
+
found = true;
|
|
188
|
+
}
|
|
189
|
+
return !found;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (found) {
|
|
196
|
+
stepsTouchMentions = true;
|
|
197
|
+
newDocRanges.push(...stepNewRanges);
|
|
198
|
+
oldDocRanges.push(...stepOldRanges);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (stepsTouchMentions || newPluginState.lastInsertedAgentMentionId) {
|
|
202
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
203
|
+
let agentMentionId = null;
|
|
204
|
+
let agentMentionContext = null;
|
|
205
|
+
let agentMentionParentNodeType = null;
|
|
206
|
+
let newCount = 0;
|
|
207
|
+
let oldAgentMentionId = null;
|
|
208
|
+
let oldCount = 0;
|
|
209
|
+
if (stepsTouchMentions) {
|
|
210
|
+
for (const [from, to] of newDocRanges) {
|
|
211
|
+
const clampedTo = Math.min(to, newState.doc.content.size);
|
|
212
|
+
if (from >= clampedTo) continue;
|
|
213
|
+
newState.doc.nodesBetween(from, clampedTo, (node, _pos, parent) => {
|
|
214
|
+
if (node.type !== mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
newCount++;
|
|
218
|
+
if (agentMentionId === null && node.attrs.id) {
|
|
219
|
+
var _parent$type$name;
|
|
220
|
+
agentMentionId = node.attrs.id;
|
|
221
|
+
agentMentionParentNodeType = (_parent$type$name = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name !== void 0 ? _parent$type$name : null;
|
|
222
|
+
agentMentionContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
for (const [from, to] of oldDocRanges) {
|
|
228
|
+
const clampedOldTo = Math.min(to, oldState.doc.content.size);
|
|
229
|
+
if (from >= clampedOldTo) continue;
|
|
230
|
+
oldState.doc.nodesBetween(from, clampedOldTo, node => {
|
|
231
|
+
if (node.type !== mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
oldCount++;
|
|
235
|
+
if (oldAgentMentionId === null && node.attrs.id) {
|
|
236
|
+
oldAgentMentionId = node.attrs.id;
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// When a deletion collapses the new-doc range to a zero-width point, or when
|
|
244
|
+
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
245
|
+
// above finds nothing. Check whether any agent mention survived in the document.
|
|
246
|
+
let resolvedFromSurvivor = false;
|
|
247
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
248
|
+
const prevId = newPluginState.lastInsertedAgentMentionId;
|
|
249
|
+
let survivorId = null;
|
|
250
|
+
let survivorContext = null;
|
|
251
|
+
let survivorParentNodeType = null;
|
|
252
|
+
newState.doc.descendants((node, _pos, parent) => {
|
|
253
|
+
if (survivorId === prevId) return false;
|
|
254
|
+
if (node.type === mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
255
|
+
var _parent$type$name2;
|
|
256
|
+
// Prefer the previously tracked ID; otherwise keep the first found.
|
|
257
|
+
survivorId = node.attrs.id;
|
|
258
|
+
survivorParentNodeType = (_parent$type$name2 = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name2 !== void 0 ? _parent$type$name2 : null;
|
|
259
|
+
survivorContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
260
|
+
}
|
|
261
|
+
return survivorId !== prevId;
|
|
262
|
+
});
|
|
263
|
+
if (survivorId !== null) {
|
|
264
|
+
agentMentionId = survivorId;
|
|
265
|
+
agentMentionContext = survivorContext;
|
|
266
|
+
agentMentionParentNodeType = survivorParentNodeType;
|
|
267
|
+
resolvedFromSurvivor = true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const isNewInsertion = agentMentionId !== null && !resolvedFromSurvivor && (oldAgentMentionId !== agentMentionId || newCount > oldCount);
|
|
271
|
+
const newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
272
|
+
if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || newInsertionCount !== undefined) {
|
|
273
|
+
newPluginState = {
|
|
274
|
+
...newPluginState,
|
|
275
|
+
lastInsertedAgentMentionId: agentMentionId,
|
|
276
|
+
lastInsertedAgentMentionContext: agentMentionContext,
|
|
277
|
+
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType,
|
|
278
|
+
...(newInsertionCount !== undefined ? {
|
|
279
|
+
lastAgentMentionInsertionCount: newInsertionCount
|
|
280
|
+
} : {})
|
|
281
|
+
};
|
|
282
|
+
hasNewPluginState = true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (hasNewPluginState && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
287
|
+
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
288
|
+
}
|
|
145
289
|
return newPluginState;
|
|
146
290
|
}
|
|
147
291
|
},
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
8
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
@@ -7,6 +11,7 @@ import { insm } from '@atlaskit/insm';
|
|
|
7
11
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
|
|
8
12
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
9
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
15
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
11
16
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
12
17
|
import { mentionPluginKey } from './key';
|
|
@@ -14,8 +19,12 @@ import { canMentionBeCreatedInRange } from './utils';
|
|
|
14
19
|
export var ACTIONS = {
|
|
15
20
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
16
21
|
};
|
|
22
|
+
|
|
23
|
+
// 'AGENT' is not in the ADF schema UserType enum but is used at runtime.
|
|
24
|
+
var AGENT_USER_TYPES = new Set(['APP', 'AGENT']);
|
|
25
|
+
var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
17
26
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
18
|
-
var PACKAGE_VERSION = "12.
|
|
27
|
+
var PACKAGE_VERSION = "12.3.1";
|
|
19
28
|
var setProvider = function setProvider(provider) {
|
|
20
29
|
return function (state, dispatch) {
|
|
21
30
|
if (dispatch) {
|
|
@@ -82,7 +91,11 @@ export function createMentionPlugin(_ref) {
|
|
|
82
91
|
hasNewPluginState = true;
|
|
83
92
|
break;
|
|
84
93
|
}
|
|
85
|
-
|
|
94
|
+
|
|
95
|
+
// When the agent mentions experiment is off, dispatch immediately (original behaviour).
|
|
96
|
+
// When it's on, defer dispatch to after the agent tracking block below so that
|
|
97
|
+
// agent-mention state changes are included in the notification.
|
|
98
|
+
if (hasNewPluginState && !editorExperiment('platform_editor_agent_mentions', true)) {
|
|
86
99
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
87
100
|
}
|
|
88
101
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
@@ -144,6 +157,161 @@ export function createMentionPlugin(_ref) {
|
|
|
144
157
|
}
|
|
145
158
|
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
|
|
146
159
|
}
|
|
160
|
+
var isAIStreaming = Boolean(tr.getMeta(AI_STREAMING_TRANSFORMATION_META_KEY));
|
|
161
|
+
if (tr.docChanged && !tr.getMeta('replaceDocument') && !isAIStreaming && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
162
|
+
var _mentionSchema = newState.schema.nodes.mention;
|
|
163
|
+
var newDocRanges = [];
|
|
164
|
+
var oldDocRanges = [];
|
|
165
|
+
var stepsTouchMentions = false;
|
|
166
|
+
tr.steps.forEach(function (step) {
|
|
167
|
+
var found = false;
|
|
168
|
+
// Only merge a step's ranges if it actually touched an agent mention,
|
|
169
|
+
// so unrelated steps (e.g. mark-only changes) don't inflate the scan area.
|
|
170
|
+
var stepNewRanges = [];
|
|
171
|
+
var stepOldRanges = [];
|
|
172
|
+
step.getMap().forEach(function (oldFrom, oldTo, newFrom, newTo) {
|
|
173
|
+
stepOldRanges.push([oldFrom, oldTo]);
|
|
174
|
+
stepNewRanges.push([newFrom, newTo]);
|
|
175
|
+
if (!found) {
|
|
176
|
+
// Clamp positions: delete-only steps can produce newTo > doc.content.size.
|
|
177
|
+
var clampedNewFrom = Math.min(newFrom, newState.doc.content.size);
|
|
178
|
+
var clampedNewTo = Math.min(newTo, newState.doc.content.size);
|
|
179
|
+
if (clampedNewFrom < clampedNewTo) {
|
|
180
|
+
newState.doc.nodesBetween(clampedNewFrom, clampedNewTo, function (node) {
|
|
181
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
182
|
+
found = true;
|
|
183
|
+
}
|
|
184
|
+
return !found;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (!found) {
|
|
188
|
+
var clampedOldFrom = Math.min(oldFrom, oldState.doc.content.size);
|
|
189
|
+
var clampedOldTo = Math.min(oldTo, oldState.doc.content.size);
|
|
190
|
+
if (clampedOldFrom < clampedOldTo) {
|
|
191
|
+
oldState.doc.nodesBetween(clampedOldFrom, clampedOldTo, function (node) {
|
|
192
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
193
|
+
found = true;
|
|
194
|
+
}
|
|
195
|
+
return !found;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (found) {
|
|
202
|
+
stepsTouchMentions = true;
|
|
203
|
+
newDocRanges.push.apply(newDocRanges, stepNewRanges);
|
|
204
|
+
oldDocRanges.push.apply(oldDocRanges, stepOldRanges);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
if (stepsTouchMentions || newPluginState.lastInsertedAgentMentionId) {
|
|
208
|
+
var _newPluginState$lastA, _newPluginState$lastI, _newPluginState$lastI2, _newPluginState$lastI3;
|
|
209
|
+
var agentMentionId = null;
|
|
210
|
+
var agentMentionContext = null;
|
|
211
|
+
var agentMentionParentNodeType = null;
|
|
212
|
+
var newCount = 0;
|
|
213
|
+
var oldAgentMentionId = null;
|
|
214
|
+
var oldCount = 0;
|
|
215
|
+
if (stepsTouchMentions) {
|
|
216
|
+
var _iterator = _createForOfIteratorHelper(newDocRanges),
|
|
217
|
+
_step;
|
|
218
|
+
try {
|
|
219
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
220
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
221
|
+
from = _step$value[0],
|
|
222
|
+
to = _step$value[1];
|
|
223
|
+
var clampedTo = Math.min(to, newState.doc.content.size);
|
|
224
|
+
if (from >= clampedTo) continue;
|
|
225
|
+
newState.doc.nodesBetween(from, clampedTo, function (node, _pos, parent) {
|
|
226
|
+
if (node.type !== _mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
newCount++;
|
|
230
|
+
if (agentMentionId === null && node.attrs.id) {
|
|
231
|
+
var _parent$type$name;
|
|
232
|
+
agentMentionId = node.attrs.id;
|
|
233
|
+
agentMentionParentNodeType = (_parent$type$name = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name !== void 0 ? _parent$type$name : null;
|
|
234
|
+
agentMentionContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
} catch (err) {
|
|
240
|
+
_iterator.e(err);
|
|
241
|
+
} finally {
|
|
242
|
+
_iterator.f();
|
|
243
|
+
}
|
|
244
|
+
var _iterator2 = _createForOfIteratorHelper(oldDocRanges),
|
|
245
|
+
_step2;
|
|
246
|
+
try {
|
|
247
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
248
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
249
|
+
_from = _step2$value[0],
|
|
250
|
+
_to = _step2$value[1];
|
|
251
|
+
var clampedOldTo = Math.min(_to, oldState.doc.content.size);
|
|
252
|
+
if (_from >= clampedOldTo) continue;
|
|
253
|
+
oldState.doc.nodesBetween(_from, clampedOldTo, function (node) {
|
|
254
|
+
if (node.type !== _mentionSchema || !AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
oldCount++;
|
|
258
|
+
if (oldAgentMentionId === null && node.attrs.id) {
|
|
259
|
+
oldAgentMentionId = node.attrs.id;
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} catch (err) {
|
|
265
|
+
_iterator2.e(err);
|
|
266
|
+
} finally {
|
|
267
|
+
_iterator2.f();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// When a deletion collapses the new-doc range to a zero-width point, or when
|
|
272
|
+
// the doc changed but no step covered the tracked mention, the new-doc scan
|
|
273
|
+
// above finds nothing. Check whether any agent mention survived in the document.
|
|
274
|
+
var resolvedFromSurvivor = false;
|
|
275
|
+
if (agentMentionId === null && newPluginState.lastInsertedAgentMentionId) {
|
|
276
|
+
var prevId = newPluginState.lastInsertedAgentMentionId;
|
|
277
|
+
var survivorId = null;
|
|
278
|
+
var survivorContext = null;
|
|
279
|
+
var survivorParentNodeType = null;
|
|
280
|
+
newState.doc.descendants(function (node, _pos, parent) {
|
|
281
|
+
if (survivorId === prevId) return false;
|
|
282
|
+
if (node.type === _mentionSchema && AGENT_USER_TYPES.has(node.attrs.userType)) {
|
|
283
|
+
var _parent$type$name2;
|
|
284
|
+
// Prefer the previously tracked ID; otherwise keep the first found.
|
|
285
|
+
survivorId = node.attrs.id;
|
|
286
|
+
survivorParentNodeType = (_parent$type$name2 = parent === null || parent === void 0 ? void 0 : parent.type.name) !== null && _parent$type$name2 !== void 0 ? _parent$type$name2 : null;
|
|
287
|
+
survivorContext = (parent === null || parent === void 0 ? void 0 : parent.textContent.trim()) || null;
|
|
288
|
+
}
|
|
289
|
+
return survivorId !== prevId;
|
|
290
|
+
});
|
|
291
|
+
if (survivorId !== null) {
|
|
292
|
+
agentMentionId = survivorId;
|
|
293
|
+
agentMentionContext = survivorContext;
|
|
294
|
+
agentMentionParentNodeType = survivorParentNodeType;
|
|
295
|
+
resolvedFromSurvivor = true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
var isNewInsertion = agentMentionId !== null && !resolvedFromSurvivor && (oldAgentMentionId !== agentMentionId || newCount > oldCount);
|
|
299
|
+
var newInsertionCount = isNewInsertion ? ((_newPluginState$lastA = newPluginState.lastAgentMentionInsertionCount) !== null && _newPluginState$lastA !== void 0 ? _newPluginState$lastA : 0) + 1 : undefined;
|
|
300
|
+
if (agentMentionId !== ((_newPluginState$lastI = newPluginState.lastInsertedAgentMentionId) !== null && _newPluginState$lastI !== void 0 ? _newPluginState$lastI : null) || agentMentionContext !== ((_newPluginState$lastI2 = newPluginState.lastInsertedAgentMentionContext) !== null && _newPluginState$lastI2 !== void 0 ? _newPluginState$lastI2 : null) || agentMentionParentNodeType !== ((_newPluginState$lastI3 = newPluginState.lastInsertedAgentMentionParentNodeType) !== null && _newPluginState$lastI3 !== void 0 ? _newPluginState$lastI3 : null) || newInsertionCount !== undefined) {
|
|
301
|
+
newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
302
|
+
lastInsertedAgentMentionId: agentMentionId,
|
|
303
|
+
lastInsertedAgentMentionContext: agentMentionContext,
|
|
304
|
+
lastInsertedAgentMentionParentNodeType: agentMentionParentNodeType
|
|
305
|
+
}, newInsertionCount !== undefined ? {
|
|
306
|
+
lastAgentMentionInsertionCount: newInsertionCount
|
|
307
|
+
} : {});
|
|
308
|
+
hasNewPluginState = true;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (hasNewPluginState && editorExperiment('platform_editor_agent_mentions', true)) {
|
|
313
|
+
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
314
|
+
}
|
|
147
315
|
return newPluginState;
|
|
148
316
|
}
|
|
149
317
|
},
|
|
@@ -17,7 +17,6 @@ export interface MentionPluginConfig {
|
|
|
17
17
|
export type MentionsChangedHandler = (changes: {
|
|
18
18
|
id: string;
|
|
19
19
|
localId: string;
|
|
20
|
-
shouldSuppressMentionNotification?: boolean;
|
|
21
20
|
taskLocalId?: string;
|
|
22
21
|
type: 'added' | 'deleted';
|
|
23
22
|
}[]) => void;
|
|
@@ -43,6 +42,26 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
|
43
42
|
export type MentionPluginOptions = MentionsPluginOptions;
|
|
44
43
|
export type MentionPluginState = {
|
|
45
44
|
canInsertMention?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Increments on each new agent mention insertion (including re-mentions of the same agent).
|
|
47
|
+
* Used to trigger re-renders when the same agent is mentioned again.
|
|
48
|
+
*/
|
|
49
|
+
lastAgentMentionInsertionCount?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Plain-text content of the block node containing the agent mention.
|
|
52
|
+
* Used as a prompt context for Rovo chat.
|
|
53
|
+
*/
|
|
54
|
+
lastInsertedAgentMentionContext?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* The ID of the most recently inserted agent (APP | AGENT userType) mention.
|
|
57
|
+
* Null when no agent mention is present in the document.
|
|
58
|
+
*/
|
|
59
|
+
lastInsertedAgentMentionId?: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* ProseMirror node type of the direct parent of the agent mention
|
|
62
|
+
* (e.g. 'taskItem', 'paragraph'). Determines auto-send vs. draft behaviour.
|
|
63
|
+
*/
|
|
64
|
+
lastInsertedAgentMentionParentNodeType?: string | null;
|
|
46
65
|
mentionProvider?: MentionProvider;
|
|
47
66
|
mentions?: Array<MentionDescription>;
|
|
48
67
|
};
|
|
@@ -17,7 +17,6 @@ export interface MentionPluginConfig {
|
|
|
17
17
|
export type MentionsChangedHandler = (changes: {
|
|
18
18
|
id: string;
|
|
19
19
|
localId: string;
|
|
20
|
-
shouldSuppressMentionNotification?: boolean;
|
|
21
20
|
taskLocalId?: string;
|
|
22
21
|
type: 'added' | 'deleted';
|
|
23
22
|
}[]) => void;
|
|
@@ -43,6 +42,26 @@ export interface MentionsPluginOptions extends MentionPluginConfig {
|
|
|
43
42
|
export type MentionPluginOptions = MentionsPluginOptions;
|
|
44
43
|
export type MentionPluginState = {
|
|
45
44
|
canInsertMention?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Increments on each new agent mention insertion (including re-mentions of the same agent).
|
|
47
|
+
* Used to trigger re-renders when the same agent is mentioned again.
|
|
48
|
+
*/
|
|
49
|
+
lastAgentMentionInsertionCount?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Plain-text content of the block node containing the agent mention.
|
|
52
|
+
* Used as a prompt context for Rovo chat.
|
|
53
|
+
*/
|
|
54
|
+
lastInsertedAgentMentionContext?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* The ID of the most recently inserted agent (APP | AGENT userType) mention.
|
|
57
|
+
* Null when no agent mention is present in the document.
|
|
58
|
+
*/
|
|
59
|
+
lastInsertedAgentMentionId?: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* ProseMirror node type of the direct parent of the agent mention
|
|
62
|
+
* (e.g. 'taskItem', 'paragraph'). Determines auto-send vs. draft behaviour.
|
|
63
|
+
*/
|
|
64
|
+
lastInsertedAgentMentionParentNodeType?: string | null;
|
|
46
65
|
mentionProvider?: MentionProvider;
|
|
47
66
|
mentions?: Array<MentionDescription>;
|
|
48
67
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.2",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/profilecard": "^25.7.0",
|
|
49
49
|
"@atlaskit/teams-app-config": "^1.12.0",
|
|
50
50
|
"@atlaskit/theme": "^25.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^87.0.0",
|
|
52
52
|
"@atlaskit/tokens": "^13.1.0",
|
|
53
53
|
"@atlaskit/user-picker": "^12.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"uuid": "^3.1.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^114.
|
|
62
|
+
"@atlaskit/editor-common": "^114.55.0",
|
|
63
63
|
"react": "^18.2.0",
|
|
64
64
|
"react-dom": "^18.2.0",
|
|
65
65
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|