@atlaskit/editor-common 130.0.0 → 130.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/collab-agent-edit-chrome-ranges/package.json +10 -0
  3. package/dist/cjs/collab/agent-edit-changed-ranges.js +5 -288
  4. package/dist/cjs/collab/agent-edit-chrome-ranges.js +15 -0
  5. package/dist/cjs/collab/agent-edit-range-mapping.js +553 -0
  6. package/dist/cjs/messages/snippets.js +1 -1
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.compiled.css +3 -0
  9. package/dist/cjs/quick-insert/CompactQuickInsertMenuItem.js +17 -2
  10. package/dist/cjs/quick-insert/ElementBrowserQuickInsertMenuItem.compiled.css +3 -1
  11. package/dist/cjs/quick-insert/ElementBrowserQuickInsertMenuItem.js +17 -6
  12. package/dist/cjs/quick-insert/get-matching-quick-insert-components.js +20 -10
  13. package/dist/cjs/quick-insert/messages.js +1 -1
  14. package/dist/cjs/ui/DropList/index.js +1 -1
  15. package/dist/es2019/collab/agent-edit-changed-ranges.js +5 -244
  16. package/dist/es2019/collab/agent-edit-chrome-ranges.js +10 -0
  17. package/dist/es2019/collab/agent-edit-range-mapping.js +463 -0
  18. package/dist/es2019/messages/snippets.js +1 -1
  19. package/dist/es2019/monitoring/error.js +1 -1
  20. package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.compiled.css +3 -0
  21. package/dist/es2019/quick-insert/CompactQuickInsertMenuItem.js +17 -2
  22. package/dist/es2019/quick-insert/ElementBrowserQuickInsertMenuItem.compiled.css +3 -1
  23. package/dist/es2019/quick-insert/ElementBrowserQuickInsertMenuItem.js +17 -6
  24. package/dist/es2019/quick-insert/get-matching-quick-insert-components.js +16 -6
  25. package/dist/es2019/quick-insert/messages.js +1 -1
  26. package/dist/es2019/ui/DropList/index.js +1 -1
  27. package/dist/esm/collab/agent-edit-changed-ranges.js +5 -286
  28. package/dist/esm/collab/agent-edit-chrome-ranges.js +10 -0
  29. package/dist/esm/collab/agent-edit-range-mapping.js +546 -0
  30. package/dist/esm/messages/snippets.js +1 -1
  31. package/dist/esm/monitoring/error.js +1 -1
  32. package/dist/esm/quick-insert/CompactQuickInsertMenuItem.compiled.css +3 -0
  33. package/dist/esm/quick-insert/CompactQuickInsertMenuItem.js +17 -2
  34. package/dist/esm/quick-insert/ElementBrowserQuickInsertMenuItem.compiled.css +3 -1
  35. package/dist/esm/quick-insert/ElementBrowserQuickInsertMenuItem.js +17 -6
  36. package/dist/esm/quick-insert/get-matching-quick-insert-components.js +20 -10
  37. package/dist/esm/quick-insert/messages.js +1 -1
  38. package/dist/esm/ui/DropList/index.js +1 -1
  39. package/dist/types/card/cardOptions.d.ts +5 -0
  40. package/dist/types/collab/agent-edit-changed-ranges.d.ts +4 -1
  41. package/dist/types/collab/agent-edit-chrome-ranges.d.ts +8 -0
  42. package/dist/types/collab/agent-edit-range-mapping.d.ts +7 -0
  43. package/dist/types/quick-insert/CompactQuickInsertMenuItem.d.ts +4 -0
  44. package/package.json +4 -4
@@ -0,0 +1,553 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.agentEditRangeMapping = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
10
+ 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; } } }; }
11
+ 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; } }
12
+ 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; }
13
+ // localId is identity metadata: regenerating it alone should not create activity.
14
+ var sameAttrs = function sameAttrs(left, right) {
15
+ var keys = Object.keys(left).filter(function (key) {
16
+ return key !== 'localId';
17
+ });
18
+ return keys.length === Object.keys(right).filter(function (key) {
19
+ return key !== 'localId';
20
+ }).length && keys.every(function (key) {
21
+ return (0, _isEqual.default)(left[key], right[key]);
22
+ });
23
+ };
24
+
25
+ // Compare the node's own type, attributes and marks, without comparing its children.
26
+ var sameMarkup = function sameMarkup(left, right) {
27
+ return left.type === right.type && sameAttrs(left.attrs, right.attrs) && left.marks.length === right.marks.length && left.marks.every(function (mark, index) {
28
+ return mark.type === right.marks[index].type && sameAttrs(mark.attrs, right.marks[index].attrs);
29
+ });
30
+ };
31
+ var _sameNode = function sameNode(left, right) {
32
+ if (left === right) {
33
+ return true;
34
+ }
35
+ if (!sameMarkup(left, right) || left.text !== right.text || left.childCount !== right.childCount) {
36
+ return false;
37
+ }
38
+ for (var index = 0; index < left.childCount; index++) {
39
+ if (!_sameNode(left.child(index), right.child(index))) {
40
+ return false;
41
+ }
42
+ }
43
+ return true;
44
+ };
45
+
46
+ // Positions include document structure, not just character offsets. A non-leaf node
47
+ // uses one position for each opening/closing boundary, plus the size of its content.
48
+ // Example: paragraph('Hi') at pos 0 has nodeSize 4, outer range [0, 4),
49
+ // and text content [1, 3). All ranges here use an exclusive end position.
50
+
51
+ // Keep the reason internally so a panel attribute change can survive child edits.
52
+ // Only ordinary { from, to } ranges are returned to the chrome consumer.
53
+
54
+ var getSnapshotIndex = function getSnapshotIndex(doc, indexes) {
55
+ var cached = indexes.get(doc);
56
+ if (cached) {
57
+ return cached;
58
+ }
59
+ var snapshot = {
60
+ byId: new Map(),
61
+ byPosition: new Map(),
62
+ nodes: [],
63
+ textblocks: []
64
+ };
65
+ var parents = [{
66
+ node: doc,
67
+ pos: -1,
68
+ index: 0
69
+ }];
70
+ doc.descendants(function (node, pos, _parent, index) {
71
+ // Track ancestry by position because one immutable node can occupy several slots.
72
+ while (parents.length > 1 && pos >= parents[parents.length - 1].pos + parents[parents.length - 1].node.nodeSize - 1) {
73
+ parents.pop();
74
+ }
75
+ var positioned = {
76
+ node: node,
77
+ pos: pos,
78
+ parent: parents[parents.length - 1],
79
+ index: index
80
+ };
81
+ snapshot.byPosition.set(pos, positioned);
82
+ snapshot.nodes.push(positioned);
83
+ if (node.isTextblock) {
84
+ snapshot.textblocks.push(positioned);
85
+ }
86
+ var id = node.attrs.localId;
87
+ if (typeof id === 'string' && id) {
88
+ snapshot.byId.set(id, snapshot.byId.has(id) ? null : positioned);
89
+ }
90
+ if (!node.isLeaf) {
91
+ parents.push(positioned);
92
+ }
93
+ });
94
+ indexes.set(doc, snapshot);
95
+ return snapshot;
96
+ };
97
+ var indexedNodeAt = function indexedNodeAt(doc, pos, indexes) {
98
+ var snapshot = getSnapshotIndex(doc, indexes);
99
+ var exact = snapshot.byPosition.get(pos);
100
+ if (exact) {
101
+ return exact.node;
102
+ }
103
+ // nodeAt also returns a text node when the position is inside its text.
104
+ var low = 0;
105
+ var high = snapshot.nodes.length;
106
+ while (low < high) {
107
+ var middle = low + high >>> 1;
108
+ if (snapshot.nodes[middle].pos <= pos) {
109
+ low = middle + 1;
110
+ } else {
111
+ high = middle;
112
+ }
113
+ }
114
+ var previous = snapshot.nodes[low - 1];
115
+ return previous !== null && previous !== void 0 && previous.node.isText && pos < previous.pos + previous.node.nodeSize ? previous.node : undefined;
116
+ };
117
+ var _collectChanges = function collectChanges(before, after, map, ranges) {
118
+ var node = after.node,
119
+ pos = after.pos;
120
+ if (before && _sameNode(before.node, node)) {
121
+ return;
122
+ }
123
+ // Text edits belong to their textblock. A node's own markup change instead
124
+ // owns its full content, so we stop here rather than adding child ranges too.
125
+ var markupChanged = !!before && node.isBlock && !sameMarkup(before.node, node);
126
+ if (node.isTextblock || markupChanged) {
127
+ if (node.content.size > 0) {
128
+ ranges.push({
129
+ from: pos,
130
+ to: pos + node.nodeSize,
131
+ markupChanged: markupChanged
132
+ });
133
+ }
134
+ return;
135
+ }
136
+ var byPosition = new Map();
137
+ var byId = new Map();
138
+ var oldChildren = [];
139
+ before === null || before === void 0 || before.node.forEach(function (child, offset) {
140
+ // forEach offsets start inside the parent. Skip its opening boundary (+1)
141
+ // to convert this child offset into an absolute document position.
142
+ var previous = {
143
+ node: child,
144
+ pos: before.pos + 1 + offset
145
+ };
146
+ oldChildren.push(previous);
147
+ // This 1 is a mapping bias, not an added offset: follow the right side
148
+ // of an insertion at the child's start, keeping the original child after it.
149
+ var mapped = map.mapResult(previous.pos, 1);
150
+ if (!mapped.deleted) {
151
+ byPosition.set(mapped.pos, previous);
152
+ }
153
+ var id = child.attrs.localId;
154
+ if (typeof id === 'string' && id) {
155
+ // Duplicate IDs cannot identify a unique old child.
156
+ byId.set(id, byId.has(id) ? null : previous);
157
+ }
158
+ });
159
+ var nextChildren = [];
160
+ node.forEach(function (child, offset) {
161
+ return nextChildren.push({
162
+ node: child,
163
+ pos: pos + 1 + offset
164
+ });
165
+ });
166
+ // Narrow edits usually preserve mapped positions. Whole-container replacements
167
+ // may erase those positions, so stable child IDs provide a second way to match.
168
+ var preferred = nextChildren.map(function (next) {
169
+ var _ref, _byPosition$get;
170
+ return (_ref = (_byPosition$get = byPosition.get(next.pos)) !== null && _byPosition$get !== void 0 ? _byPosition$get : byId.get(next.node.attrs.localId)) !== null && _ref !== void 0 ? _ref : undefined;
171
+ });
172
+ var claims = new Map();
173
+ var _iterator = _createForOfIteratorHelper(preferred),
174
+ _step;
175
+ try {
176
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
177
+ var match = _step.value;
178
+ if (match) {
179
+ var _claims$get;
180
+ claims.set(match, ((_claims$get = claims.get(match)) !== null && _claims$get !== void 0 ? _claims$get : 0) + 1);
181
+ }
182
+ }
183
+ } catch (err) {
184
+ _iterator.e(err);
185
+ } finally {
186
+ _iterator.f();
187
+ }
188
+ nextChildren.forEach(function (next, index) {
189
+ var match = preferred[index];
190
+ // Same-index fallback supports replacements that regenerate IDs but keep
191
+ // the child structure. Different child counts make that correspondence unsafe.
192
+ var aligned = oldChildren.length === node.childCount ? oldChildren[index] : undefined;
193
+ // Reserve every position/ID match before fallback, including later siblings.
194
+ // Reusing one old sibling can otherwise disguise an equal-text insertion.
195
+ var previous = match && claims.get(match) === 1 ? match : aligned && !claims.has(aligned) ? aligned : undefined;
196
+ _collectChanges(previous, next, map, ranges);
197
+ });
198
+ };
199
+ var findPreservedNode = function findPreservedNode(before, doc, previous, markupChanged, indexes) {
200
+ var id = previous.attrs.localId;
201
+ if (typeof id !== 'string' || !id) {
202
+ return;
203
+ }
204
+ // When source uniqueness is required, removing a duplicate must not transfer
205
+ // its activity to the remaining equal-content sibling.
206
+ if (before && !getSnapshotIndex(before, indexes).byId.get(id)) {
207
+ return;
208
+ }
209
+ var match = getSnapshotIndex(doc, indexes).byId.get(id);
210
+ // Attribute/mark activity belongs to the node even when its children are edited.
211
+ // Content-only activity still requires the entire candidate to survive unchanged.
212
+ var isPreserved = markupChanged ? sameMarkup : _sameNode;
213
+ return match && isPreserved(previous, match.node) ? match : undefined;
214
+ };
215
+ var findAlignedTextblock = function findAlignedTextblock(before, after, pos, offsets, indexes) {
216
+ var original = getSnapshotIndex(before, indexes).byPosition.get(pos);
217
+ var path = [];
218
+ while ((_original = original) !== null && _original !== void 0 && _original.parent) {
219
+ var _original;
220
+ path.push(original);
221
+ original = original.parent;
222
+ }
223
+ var parent = after;
224
+ var parentPos = -1;
225
+ var _iterator2 = _createForOfIteratorHelper(path.reverse()),
226
+ _step2;
227
+ try {
228
+ var _loop = function _loop() {
229
+ var _child$parent;
230
+ var child = _step2.value;
231
+ var originalParent = (_child$parent = child.parent) === null || _child$parent === void 0 ? void 0 : _child$parent.node;
232
+ if (!originalParent) {
233
+ return {
234
+ v: void 0
235
+ };
236
+ }
237
+ if (parent.type !== originalParent.type || parent.childCount !== originalParent.childCount) {
238
+ return {
239
+ v: void 0
240
+ };
241
+ }
242
+ var index = child.index;
243
+ if (index >= parent.childCount) {
244
+ return {
245
+ v: void 0
246
+ };
247
+ }
248
+ var childOffsets = offsets.get(parent);
249
+ if (!childOffsets) {
250
+ var computedOffsets = [];
251
+ parent.forEach(function (_child, offset) {
252
+ return computedOffsets.push(offset);
253
+ });
254
+ childOffsets = computedOffsets;
255
+ offsets.set(parent, childOffsets);
256
+ }
257
+ parentPos += 1 + childOffsets[index];
258
+ parent = parent.child(index);
259
+ },
260
+ _ret;
261
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
262
+ _ret = _loop();
263
+ if (_ret) return _ret.v;
264
+ }
265
+ } catch (err) {
266
+ _iterator2.e(err);
267
+ } finally {
268
+ _iterator2.f();
269
+ }
270
+ return parent.isTextblock ? {
271
+ node: parent,
272
+ pos: parentPos
273
+ } : undefined;
274
+ };
275
+ var mapToFinalBlocks = function mapToFinalBlocks(tr, index, range, indexes, options) {
276
+ var _tr$docs;
277
+ var alignedOffsets = options.alignedOffsets,
278
+ requireUniqueSourceIds = options.requireUniqueSourceIds;
279
+ // Carried ranges can cover every block in a document. Repeated nodeAt calls
280
+ // scan preceding siblings, so reuse one positioned index per snapshot instead.
281
+ var nodeAt = function nodeAt(doc, pos) {
282
+ return alignedOffsets ? indexedNodeAt(doc, pos, indexes) : doc.nodeAt(pos);
283
+ };
284
+ var from = range.from,
285
+ to = range.to;
286
+ // Track inner content separately from outer node bounds: +1 skips the opening
287
+ // boundary and -1 excludes the closing boundary (see paragraph example above).
288
+ var contentFrom = from + 1;
289
+ var contentTo = to - 1;
290
+ // docs[i] is the document BEFORE step i, so docs[i + 1] is its result.
291
+ // The last step has no next snapshot; tr.doc is its result instead.
292
+ var node = nodeAt((_tr$docs = tr.docs[index + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc, from);
293
+ if (!node) {
294
+ return [];
295
+ }
296
+ // Later non-AI steps also shift/delete existing activity, even though they
297
+ // cannot create new activity themselves. Process every intermediate document.
298
+ for (var next = index + 1; next < tr.steps.length; next++) {
299
+ var _tr$docs2;
300
+ var map = tr.mapping.maps[next];
301
+ var after = (_tr$docs2 = tr.docs[next + 1]) !== null && _tr$docs2 !== void 0 ? _tr$docs2 : tr.doc;
302
+ // Mapping biases +1 (right) and -1 (left) keep boundary insertions outside
303
+ // the tracked content. These arguments do not add/subtract document positions.
304
+ var start = map.mapResult(contentFrom, 1);
305
+ var end = map.mapResult(contentTo, -1);
306
+ if (start.deleted && end.deleted || end.pos <= start.pos) {
307
+ var _indexes$get, _indexes$get2;
308
+ // A cumulative replacement can preserve the candidate content or owned markup.
309
+ // Check every intermediate doc so deletion then reinsertion never resurrects it.
310
+ var preserved = findPreservedNode(requireUniqueSourceIds ? tr.docs[next] : undefined, after, node, range.markupChanged, indexes);
311
+ var id = node.attrs.localId;
312
+ var sourceMatch = typeof id === 'string' && id ? (_indexes$get = indexes.get(tr.docs[next])) === null || _indexes$get === void 0 ? void 0 : _indexes$get.byId.get(id) : undefined;
313
+ var idMatch = typeof id === 'string' && id ? (_indexes$get2 = indexes.get(after)) === null || _indexes$get2 === void 0 ? void 0 : _indexes$get2.byId.get(id) : undefined;
314
+ if (!preserved && alignedOffsets && sourceMatch !== null && idMatch === undefined) {
315
+ // Inline replacements can keep a block's opening boundary while
316
+ // recreating its content and adding later blocks to the same chunk.
317
+ var mapped = map.mapResult(from, 1);
318
+ var mappedNode = !mapped.deleted ? nodeAt(after, mapped.pos) : undefined;
319
+ if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isTextblock && _sameNode(node, mappedNode)) {
320
+ preserved = {
321
+ node: mappedNode,
322
+ pos: mapped.pos
323
+ };
324
+ } else {
325
+ // Whole-block replacements may recreate unchanged blocks without IDs.
326
+ // Match their slot only while every parent keeps its shape.
327
+ var aligned = findAlignedTextblock(tr.docs[next], after, from, alignedOffsets, indexes);
328
+ if (aligned && _sameNode(node, aligned.node)) {
329
+ preserved = aligned;
330
+ }
331
+ }
332
+ }
333
+ if (!preserved) {
334
+ return [];
335
+ }
336
+ from = preserved.pos;
337
+ to = from + preserved.node.nodeSize;
338
+ contentFrom = from + 1;
339
+ contentTo = to - 1;
340
+ node = preserved.node;
341
+ } else {
342
+ // Apply the same inward biases to the outer node bounds.
343
+ from = map.map(from, 1);
344
+ to = map.map(to, -1);
345
+ contentFrom = start.pos;
346
+ contentTo = end.pos;
347
+ var current = nodeAt(after, from);
348
+ if (current && current.nodeSize === to - from) {
349
+ node = current;
350
+ }
351
+ }
352
+ }
353
+ if (from < 0 || to > tr.doc.content.size || contentTo <= contentFrom) {
354
+ return [];
355
+ }
356
+ var finalNode = nodeAt(tr.doc, from);
357
+ if (finalNode !== null && finalNode !== void 0 && finalNode.isBlock && finalNode.nodeSize === to - from) {
358
+ return [{
359
+ from: from,
360
+ to: to
361
+ }];
362
+ }
363
+ // Joins/splits can leave mapped boundaries inside the final textblock.
364
+ var blocks = [];
365
+ if (alignedOffsets) {
366
+ var textblocks = getSnapshotIndex(tr.doc, indexes).textblocks;
367
+ var low = 0;
368
+ var high = textblocks.length;
369
+ while (low < high) {
370
+ var middle = low + high >>> 1;
371
+ var candidate = textblocks[middle];
372
+ if (candidate.pos + candidate.node.nodeSize <= contentFrom) {
373
+ low = middle + 1;
374
+ } else {
375
+ high = middle;
376
+ }
377
+ }
378
+ for (var _index = low; _index < textblocks.length && textblocks[_index].pos < contentTo; _index++) {
379
+ var _textblocks$_index = textblocks[_index],
380
+ _node = _textblocks$_index.node,
381
+ pos = _textblocks$_index.pos;
382
+ blocks.push({
383
+ from: pos,
384
+ to: pos + _node.nodeSize
385
+ });
386
+ }
387
+ return blocks;
388
+ }
389
+ tr.doc.nodesBetween(contentFrom, contentTo, function (child, pos) {
390
+ if (child.isTextblock) {
391
+ blocks.push({
392
+ from: pos,
393
+ to: pos + child.nodeSize
394
+ });
395
+ return false;
396
+ }
397
+ });
398
+ return blocks;
399
+ };
400
+
401
+ /**
402
+ * Maps existing textblock activity through each applied step into tr.doc coordinates.
403
+ * Replaced content is dropped unless an unchanged block survives with a unique ID
404
+ * or in the same structural slot. Newly changed blocks belong to the producer.
405
+ */
406
+ function mapAgentEditChromeRanges(tr, ranges) {
407
+ var indexes = new WeakMap();
408
+ var alignedOffsets = new WeakMap();
409
+ var options = {
410
+ alignedOffsets: alignedOffsets,
411
+ requireUniqueSourceIds: true
412
+ };
413
+ var validRanges = [];
414
+ var _iterator3 = _createForOfIteratorHelper(ranges),
415
+ _step3;
416
+ try {
417
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
418
+ var _step3$value = _step3.value,
419
+ from = _step3$value.from,
420
+ to = _step3$value.to;
421
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to <= from) {
422
+ continue;
423
+ }
424
+ var start = Math.max(0, Math.min(from, tr.before.content.size));
425
+ var end = Math.max(start, Math.min(to, tr.before.content.size));
426
+ if (start === end) {
427
+ continue;
428
+ }
429
+ validRanges.push({
430
+ from: start,
431
+ to: end
432
+ });
433
+ }
434
+ } catch (err) {
435
+ _iterator3.e(err);
436
+ } finally {
437
+ _iterator3.f();
438
+ }
439
+ if (!validRanges.length) {
440
+ return [];
441
+ }
442
+ validRanges.sort(function (left, right) {
443
+ return left.from - right.from;
444
+ });
445
+ var blocks = [];
446
+ var rangeIndex = 0;
447
+ var _iterator4 = _createForOfIteratorHelper(getSnapshotIndex(tr.before, indexes).textblocks),
448
+ _step4;
449
+ try {
450
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
451
+ var _step4$value = _step4.value,
452
+ node = _step4$value.node,
453
+ pos = _step4$value.pos;
454
+ while (rangeIndex < validRanges.length && validRanges[rangeIndex].to <= pos) {
455
+ rangeIndex++;
456
+ }
457
+ if (rangeIndex === validRanges.length) {
458
+ break;
459
+ }
460
+ if (node.content.size && validRanges[rangeIndex].from < pos + node.nodeSize) {
461
+ blocks.push({
462
+ from: pos,
463
+ to: pos + node.nodeSize,
464
+ markupChanged: false
465
+ });
466
+ }
467
+ }
468
+ // Index -1 starts from docs[0], before the first step, instead of a step result.
469
+ } catch (err) {
470
+ _iterator4.e(err);
471
+ } finally {
472
+ _iterator4.f();
473
+ }
474
+ return blocks.flatMap(function (range) {
475
+ return mapToFinalBlocks(tr, -1, range, indexes, options);
476
+ });
477
+ }
478
+
479
+ /**
480
+ * Returns whole content-block ranges for selected applied steps, in tr.doc coordinates.
481
+ * Callers select actual AI writes (excluding restores, acknowledgments and preparation)
482
+ * and own experiment/lifecycle decisions. This helper does not dispatch or render.
483
+ *
484
+ * Comparing each step's snapshots also handles attribute/mark steps with empty maps.
485
+ * Shared unchanged subtrees are skipped by reference. Only localId changes are ignored;
486
+ * meaningful attributes and marks retain the affected node's full content scope.
487
+ */
488
+ function getAgentEditChangedRanges(tr, includedStepIndexes, requireUniqueSourceIds) {
489
+ // Positions belong to each intermediate document, not just tr.doc. Keep the
490
+ // lazy indexes local to this call so deletion/reinsertion checks stay intact
491
+ // and no cache is retained between transactions or streaming chunks.
492
+ var indexes = new WeakMap();
493
+ var options = {
494
+ requireUniqueSourceIds: requireUniqueSourceIds
495
+ };
496
+ var ranges = [];
497
+ var _iterator5 = _createForOfIteratorHelper(new Set(includedStepIndexes)),
498
+ _step5;
499
+ try {
500
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
501
+ var _tr$docs3;
502
+ var index = _step5.value;
503
+ if (!Number.isInteger(index) || index < 0 || index >= tr.steps.length) {
504
+ continue;
505
+ }
506
+ var changed = [];
507
+ // The root document has no opening boundary. Using -1 makes the recursive
508
+ // parent.pos + 1 + offset formula place its first child at position 0.
509
+ _collectChanges({
510
+ node: tr.docs[index],
511
+ pos: -1
512
+ }, {
513
+ node: (_tr$docs3 = tr.docs[index + 1]) !== null && _tr$docs3 !== void 0 ? _tr$docs3 : tr.doc,
514
+ pos: -1
515
+ }, tr.steps[index].getMap(), changed);
516
+ for (var _i = 0, _changed = changed; _i < _changed.length; _i++) {
517
+ var range = _changed[_i];
518
+ ranges.push.apply(ranges, (0, _toConsumableArray2.default)(mapToFinalBlocks(tr, index, range, indexes, options)));
519
+ }
520
+ }
521
+
522
+ // Return only the surviving final-document ranges, never intermediate step states.
523
+ // Sort outer ranges before their children, then discard duplicates/contained ranges.
524
+ // Separate ranges stay separate; this must not highlight the untouched gaps.
525
+ } catch (err) {
526
+ _iterator5.e(err);
527
+ } finally {
528
+ _iterator5.f();
529
+ }
530
+ var unique = [];
531
+ var _iterator6 = _createForOfIteratorHelper(ranges.sort(function (left, right) {
532
+ return left.from - right.from || right.to - left.to;
533
+ })),
534
+ _step6;
535
+ try {
536
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
537
+ var _range = _step6.value;
538
+ var previous = unique[unique.length - 1];
539
+ if (!previous || _range.to > previous.to) {
540
+ unique.push(_range);
541
+ }
542
+ }
543
+ } catch (err) {
544
+ _iterator6.e(err);
545
+ } finally {
546
+ _iterator6.f();
547
+ }
548
+ return unique;
549
+ }
550
+ var agentEditRangeMapping = exports.agentEditRangeMapping = {
551
+ getChangedRanges: getAgentEditChangedRanges,
552
+ mapChromeRanges: mapAgentEditChromeRanges
553
+ };
@@ -28,7 +28,7 @@ var templateGalleryMessages = exports.templateGalleryMessages = (0, _reactIntl.d
28
28
  },
29
29
  templateGalleryTitle: {
30
30
  id: 'editor-plugin-snippets.snippetsPlugin.templateGalleryTitle',
31
- defaultMessage: 'Block Template Gallery',
31
+ defaultMessage: 'Block template gallery',
32
32
  description: 'Title for the block template gallery quick insert item'
33
33
  }
34
34
  });
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
27
27
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
28
28
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
29
29
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
30
- var packageVersion = "129.1.2";
30
+ var packageVersion = "130.2.0";
31
31
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
32
32
  // Remove URL as it has UGC
33
33
  // Ignored via go/ees007
@@ -13,6 +13,7 @@
13
13
  ._1e0c1txw{display:flex}
14
14
  ._1o9zidpf{flex-shrink:0}
15
15
  ._1o9zkb7n{flex-shrink:1}
16
+ ._1pgcjdj5 [style*="--ds-icon-subtle"]{color:inherit!important}
16
17
  ._1reo15vq{overflow-x:hidden}
17
18
  ._1tke1tcg{min-height:24px}
18
19
  ._1ul91tcg{min-width:24px}
@@ -22,4 +23,6 @@
22
23
  ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
23
24
  ._bfhki8nm{background-color:var(--ds-background-neutral,#0515240f)}
24
25
  ._i0dlidpf{flex-basis:0}
26
+ ._rpzpjdj5 [style*="--ds-icon-accent-gray"]{color:inherit!important}
27
+ ._syaz1q3r{color:var(--ds-icon,#292a2e)}
25
28
  ._syazazsu{color:var(--ds-text-subtle,#505258)}
@@ -24,6 +24,17 @@ var styles = {
24
24
  iconLarge: "_2rko1mok _1reo15vq _18m915vq _1h6d1l7x _1dqonqa1 _189ee4h9 _4cvr1h6o _bfhk1bhr _1e0c1txw _4t3izwfg _1bah1h6o _1bsbzwfg",
25
25
  shortcut: "_2rko12b0 _11c8wadc _1rjcv77o _18zr1b66 _bfhki8nm _syazazsu"
26
26
  };
27
+ var iconColorStyles = null;
28
+
29
+ // Some icons pin a neutral colour inline (for example the Forge and Spotlight icons use
30
+ // color.icon.subtle or color.icon.accent.gray), which would ignore the colour set by the menu item.
31
+ // Reset only those so every icon follows the menu item (color.icon, or the disabled colour).
32
+ // Do NOT widen this to all icon colours: some icons are intentionally coloured (for example skill
33
+ // and brand icons that use other --ds-icon-accent-* tokens) and must keep their own colour.
34
+ /* eslint-disable @atlaskit/design-system/no-unsafe-design-token-usage, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-important-styles -- Icons pin their colour with an inline style, which only an !important rule on a descendant selector can override. */
35
+ var pinnedIconColorResetStyles = null;
36
+ /* eslint-enable @atlaskit/design-system/no-unsafe-design-token-usage, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-important-styles */
37
+
27
38
  var itemStyles = (0, _primitives.xcss)({
28
39
  alignItems: 'center',
29
40
  backgroundColor: 'elevation.surface.overlay',
@@ -137,11 +148,15 @@ var CompactQuickInsertMenuItem = exports.CompactQuickInsertMenuItem = function C
137
148
  xcss: isDisabled ? disabledItemStyles : isSelected ? selectedItemStyles : itemStyles
138
149
  }, wrappedIcon && /*#__PURE__*/_react.default.createElement(_compiled.Box, {
139
150
  xcss: styles.iconContainer
140
- }, wrappedIcon), /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
151
+ }, /*#__PURE__*/_react.default.createElement("span", {
152
+ className: (0, _runtime.ax)(["_rpzpjdj5 _1pgcjdj5", !isDisabled && "_syaz1q3r"])
153
+ }, wrappedIcon)), /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
141
154
  alignBlock: "center",
142
155
  spread: "space-between",
143
156
  xcss: styles.content
144
- }, titleContent !== null && titleContent !== void 0 ? titleContent : /*#__PURE__*/_react.default.createElement(_compiled.Text, null, title), shortcut && /*#__PURE__*/_react.default.createElement(_compiled.Box, {
157
+ }, titleContent !== null && titleContent !== void 0 ? titleContent : /*#__PURE__*/_react.default.createElement(_compiled.Text, {
158
+ color: isDisabled ? 'color.text.disabled' : 'color.text'
159
+ }, title), shortcut && /*#__PURE__*/_react.default.createElement(_compiled.Box, {
145
160
  as: "span",
146
161
  xcss: styles.shortcut
147
162
  }, shortcut))), shouldRenderPreview && referenceElement && /*#__PURE__*/_react.default.createElement(_QuickInsertHoverPreview.QuickInsertHoverPreview, {
@@ -1 +1,3 @@
1
- ._syazdgkc{color:var(--ds-icon-subtle,#505258)}
1
+ ._1pgcjdj5 [style*="--ds-icon-subtle"]{color:inherit!important}
2
+ ._rpzpjdj5 [style*="--ds-icon-accent-gray"]{color:inherit!important}
3
+ ._syaz1q3r{color:var(--ds-icon,#292a2e)}
@@ -100,6 +100,16 @@ var iconLargeStyles = (0, _primitives.xcss)({
100
100
  width: '40px'
101
101
  });
102
102
  var iconColorStyles = null;
103
+
104
+ // Some icons pin a neutral colour inline (for example the Forge and Spotlight icons use
105
+ // color.icon.subtle or color.icon.accent.gray), which would ignore the colour set by the menu item.
106
+ // Reset only those so every icon follows the menu item (color.icon, or the disabled colour).
107
+ // Do NOT widen this to all icon colours: some icons are intentionally coloured (for example skill
108
+ // and brand icons that use other --ds-icon-accent-* tokens) and must keep their own colour.
109
+ /* eslint-disable @atlaskit/design-system/no-unsafe-design-token-usage, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-important-styles -- Icons pin their colour with an inline style, which only an !important rule on a descendant selector can override. */
110
+ var pinnedIconColorResetStyles = null;
111
+ /* eslint-enable @atlaskit/design-system/no-unsafe-design-token-usage, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-important-styles */
112
+
103
113
  var shortcutStyles = (0, _primitives.xcss)({
104
114
  backgroundColor: 'color.background.neutral',
105
115
  borderRadius: 'radius.small',
@@ -132,6 +142,11 @@ var ElementBrowserQuickInsertMenuItem = exports.ElementBrowserQuickInsertMenuIte
132
142
  var itemStyles = (0, _react.useMemo)(function () {
133
143
  return [isDisabled ? borderlessDisabledItemStyles : isSelected ? borderlessSelectedItemStyles : borderlessItemStyles, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') && !isDisabled && !isSelected && hoveredItemStyles];
134
144
  }, [isDisabled, isSelected]);
145
+
146
+ // Disabled items keep the dimmed colour inherited from the item.
147
+ var icon = iconBefore ? /*#__PURE__*/_react.default.createElement("span", {
148
+ className: (0, _runtime.ax)(["_rpzpjdj5 _1pgcjdj5", !isDisabled && "_syaz1q3r"])
149
+ }, iconBefore) : iconBefore;
135
150
  return /*#__PURE__*/_react.default.createElement(_primitives.Pressable, {
136
151
  "aria-label": ariaLabel,
137
152
  "aria-selected": isSelected,
@@ -145,11 +160,7 @@ var ElementBrowserQuickInsertMenuItem = exports.ElementBrowserQuickInsertMenuIte
145
160
  xcss: itemStyles
146
161
  }, iconBefore && shouldWrapIcon ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
147
162
  xcss: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command') ? iconLargeStyles : iconStyles
148
- }, /*#__PURE__*/_react.default.createElement("span", {
149
- className: (0, _runtime.ax)(["_syazdgkc"])
150
- }, iconBefore)) : iconBefore ? /*#__PURE__*/_react.default.createElement("span", {
151
- className: (0, _runtime.ax)(["_syazdgkc"])
152
- }, iconBefore) : null, /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
163
+ }, icon) : icon, /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
153
164
  space: "space.050",
154
165
  grow: "fill"
155
166
  }, /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
@@ -157,7 +168,7 @@ var ElementBrowserQuickInsertMenuItem = exports.ElementBrowserQuickInsertMenuIte
157
168
  spread: "space-between",
158
169
  space: "space.100"
159
170
  }, titleContent !== null && titleContent !== void 0 ? titleContent : /*#__PURE__*/_react.default.createElement(_primitives.Text, {
160
- color: "color.text",
171
+ color: isDisabled ? 'color.text.disabled' : 'color.text',
161
172
  maxLines: 1,
162
173
  size: "medium",
163
174
  weight: "medium"