@atlaskit/editor-plugin-show-diff 16.0.14 → 16.0.17

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 (47) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -1
  3. package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +19 -13
  4. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +2 -1
  5. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +94 -28
  6. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +2 -1
  7. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +14 -1
  8. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +12 -2
  9. package/dist/cjs/pm-plugins/main.js +2 -2
  10. package/dist/cjs/pm-plugins/scrollToDiff.js +20 -0
  11. package/dist/cjs/ui/ContributorTag/buildContributorTagDom.js +5 -4
  12. package/dist/cjs/ui/IndicatorBar/IndicatorBar.js +1 -1
  13. package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  14. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -1
  15. package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +7 -3
  16. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +4 -3
  17. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +73 -13
  18. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +3 -2
  19. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +15 -2
  20. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +10 -0
  21. package/dist/es2019/pm-plugins/main.js +2 -2
  22. package/dist/es2019/pm-plugins/scrollToDiff.js +21 -3
  23. package/dist/es2019/ui/ContributorTag/buildContributorTagDom.js +5 -4
  24. package/dist/es2019/ui/IndicatorBar/IndicatorBar.js +1 -1
  25. package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  26. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -1
  27. package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +19 -13
  28. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +3 -2
  29. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +95 -29
  30. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +3 -2
  31. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +15 -2
  32. package/dist/esm/pm-plugins/decorations/decorationKeys.js +10 -0
  33. package/dist/esm/pm-plugins/main.js +2 -2
  34. package/dist/esm/pm-plugins/scrollToDiff.js +21 -2
  35. package/dist/esm/ui/ContributorTag/buildContributorTagDom.js +5 -4
  36. package/dist/esm/ui/IndicatorBar/IndicatorBar.js +1 -1
  37. package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  38. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +6 -1
  39. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +9 -0
  40. package/dist/types/pm-plugins/scrollToDiff.d.ts +5 -1
  41. package/dist/types/showDiffPluginType.d.ts +2 -0
  42. package/dist/types/ui/ContributorTag/buildContributorTagDom.d.ts +4 -4
  43. package/package.json +4 -3
  44. package/dist/cjs/pm-plugins/areDocsEqualByBlockStructureAndText.js +0 -55
  45. package/dist/es2019/pm-plugins/areDocsEqualByBlockStructureAndText.js +0 -50
  46. package/dist/esm/pm-plugins/areDocsEqualByBlockStructureAndText.js +0 -50
  47. package/dist/types/pm-plugins/areDocsEqualByBlockStructureAndText.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 16.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bac902441a512`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bac902441a512) -
8
+ Keep layout column diff indicators aligned with their content instead of appearing beside the
9
+ comments footer, behind `platform_editor_ai_show_diff_patch_1`.
10
+ - [`20d41af8d6f4c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20d41af8d6f4c) -
11
+ EDITOR-9000 Fixes scroll to suggestion when it is in table with sticky header
12
+ - Updated dependencies
13
+
14
+ ## 16.0.16
15
+
16
+ ### Patch Changes
17
+
18
+ - [`b56b3a7dbfb5a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b56b3a7dbfb5a) -
19
+ [ux] Show contributor tags at the top-left of removed table rows and above table interaction
20
+ overlays and sticky header rows. Behind `confluence_ncs_step_diffing_version_history`.
21
+ - Updated dependencies
22
+
23
+ ## 16.0.15
24
+
25
+ ### Patch Changes
26
+
27
+ - [`442abbe2a88e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/442abbe2a88e0) -
28
+ Normalize documents before relaxed show-diff comparisons when Confluence version-history diffing
29
+ is enabled.
30
+ - Updated dependencies
31
+
3
32
  ## 16.0.14
4
33
 
5
34
  ### Patch Changes
@@ -11,13 +11,13 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
12
12
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
13
13
  var _prosemirrorChangeset = require("prosemirror-changeset");
14
+ var _areDocsEqualByBlockStructureAndText = require("@atlaskit/editor-common/utils/areDocsEqualByBlockStructureAndText");
14
15
  var _document = require("@atlaskit/editor-common/utils/document");
15
16
  var _transform = require("@atlaskit/editor-prosemirror/transform");
16
17
  var _view = require("@atlaskit/editor-prosemirror/view");
17
18
  var _unsafeExpValNoExposure = require("@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure");
18
19
  var _fg = require("@atlaskit/platform-feature-flags/fg");
19
20
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
20
- var _areDocsEqualByBlockStructureAndText = require("../areDocsEqualByBlockStructureAndText");
21
21
  var _createAnchorDecorationWidgets = require("../decorations/createAnchorDecorationWidgets");
22
22
  var _createBlockChangedDecoration = require("../decorations/createBlockChangedDecoration");
23
23
  var _createInlineChangedDecoration = require("../decorations/createInlineChangedDecoration");
@@ -220,6 +220,7 @@ var createLeftAnchorWidget = exports.createLeftAnchorWidget = function createLef
220
220
  *
221
221
  */
222
222
  var createBlockIndicatorAnchorWidgets = exports.createBlockIndicatorAnchorWidgets = function createBlockIndicatorAnchorWidgets(_ref2) {
223
+ var _ref3, _parentTable$pos;
223
224
  var doc = _ref2.doc,
224
225
  from = _ref2.from,
225
226
  to = _ref2.to,
@@ -259,9 +260,14 @@ var createBlockIndicatorAnchorWidgets = exports.createBlockIndicatorAnchorWidget
259
260
  var parentCellOrRow = (0, _utils.findParentNodeClosestToPos)($from, function (ancestor) {
260
261
  return ['tableCell', 'tableHeader', 'tableRow'].includes(ancestor.type.name);
261
262
  });
262
-
263
- // Render outside the table when inside one; otherwise keep the original pos.
264
- var widgetPos = parentTable ? parentTable.pos : from;
263
+ var parentLayout = (0, _fg.fg)('platform_editor_ai_show_diff_patch_1') ? (0, _utils.findParentNodeClosestToPos)($from, function (ancestor) {
264
+ return ancestor.type.name === 'layoutSection';
265
+ }) : undefined;
266
+ // Layouts flatten direct widget children with display: contents. Such a wrapper has no
267
+ // bounding box or positioning context, so measuring its top produces an offset from the
268
+ // viewport origin and displaces the indicator into content below the editor. Keep the
269
+ // wrapper outside the layout, just as we do for tables, but still measure the target node.
270
+ var widgetPos = (_ref3 = (_parentTable$pos = parentTable === null || parentTable === void 0 ? void 0 : parentTable.pos) !== null && _parentTable$pos !== void 0 ? _parentTable$pos : parentLayout === null || parentLayout === void 0 ? void 0 : parentLayout.pos) !== null && _ref3 !== void 0 ? _ref3 : from;
265
271
  // Measure the actual cell/row DOM when inside one; otherwise measure the
266
272
  // widget's own position.
267
273
  var measurePos = parentCellOrRow ? parentCellOrRow.pos : from;
@@ -360,11 +366,11 @@ var createAnchorNameSpan = exports.createAnchorNameSpan = function createAnchorN
360
366
  span.style.setProperty('anchor-name', "--".concat(anchorKey));
361
367
  return span;
362
368
  };
363
- var createAnchorSpanWidget = function createAnchorSpanWidget(_ref3) {
364
- var pos = _ref3.pos,
365
- diffId = _ref3.diffId,
366
- anchorType = _ref3.anchorType,
367
- side = _ref3.side;
369
+ var createAnchorSpanWidget = function createAnchorSpanWidget(_ref4) {
370
+ var pos = _ref4.pos,
371
+ diffId = _ref4.diffId,
372
+ anchorType = _ref4.anchorType,
373
+ side = _ref4.side;
368
374
  return _view.Decoration.widget(pos, function () {
369
375
  return createAnchorNameSpan((0, _decorationKeys.buildAnchorDecorationKey)({
370
376
  diffId: diffId,
@@ -381,11 +387,11 @@ var createAnchorSpanWidget = function createAnchorSpanWidget(_ref3) {
381
387
  * Invisible `from`/`to` (and optional `left`) anchor widgets for one inline diff
382
388
  * range, so the `IndicatorBar` can align itself via CSS anchor positioning.
383
389
  */
384
- var createInlineIndicatorAnchorWidgets = exports.createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref4) {
385
- var doc = _ref4.doc,
386
- from = _ref4.from,
387
- to = _ref4.to,
388
- diffId = _ref4.diffId;
390
+ var createInlineIndicatorAnchorWidgets = exports.createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref5) {
391
+ var doc = _ref5.doc,
392
+ from = _ref5.from,
393
+ to = _ref5.to,
394
+ diffId = _ref5.diffId;
389
395
  var leftAnchor = createLeftAnchorWidget({
390
396
  doc: doc,
391
397
  from: from,
@@ -11,6 +11,7 @@ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
12
12
  var _view = require("@atlaskit/editor-prosemirror/view");
13
13
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
14
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
14
15
  var _isExtendedEnabled = require("../isExtendedEnabled");
15
16
  var _factory = require("./colorSchemes/factory");
16
17
  var _schemes = require("./colorSchemes/schemes");
@@ -250,7 +251,7 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
250
251
  });
251
252
  var style = tagAnchorName ? [nodeStyle, (0, _lazyNodeView.convertToInlineCss)({
252
253
  anchorName: "--".concat(tagAnchorName)
253
- })].filter(Boolean).join(' ') : nodeStyle;
254
+ }), (0, _fg.fg)('platform_editor_ai_show_diff_patch_1') ? _decorationKeys.scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
254
255
  var className = getNodeClass(change.name);
255
256
  if (style || className) {
256
257
  decorations.push(_view.Decoration.node(change.from, change.to, _objectSpread({
@@ -19,6 +19,7 @@ var _factory = require("./colorSchemes/factory");
19
19
  var _schemes = require("./colorSchemes/schemes");
20
20
  var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
21
21
  var _createChangedRowDecorationWidgetsStyles = require("./createChangedRowDecorationWidgets.styles.legacy");
22
+ var _createContributorTagWidget = require("./createContributorTagWidget");
22
23
  var _decorationKeys = require("./decorationKeys");
23
24
  var _findSafeInsertPos = require("./utils/findSafeInsertPos");
24
25
  var _tableCellEdgeAttrs = require("./utils/tableCellEdgeAttrs");
@@ -105,20 +106,40 @@ var extractChangedRows = function extractChangedRows(_ref) {
105
106
  }
106
107
  });
107
108
 
108
- // Filter changes that never truly got deleted
109
+ // Filter changes that never truly got deleted. Compare the number of equivalent rows rather
110
+ // than only checking whether one still exists: deleting two of three identical empty rows should
111
+ // retain two changed rows even though the third remains in the new table.
112
+ var equivalentRowDeletionCounts = [];
109
113
  return changedRows.filter(function (changedRow) {
110
114
  // A replacement leaves every sibling row in place, so asking "does this row still exist
111
115
  // ANYWHERE in the new table?" can drop a genuinely rewritten row that happens to match a
112
- // sibling. Compare it against the row at the same index instead. Deletions must keep the
113
- // whole-table `some()`: their indices shift, so an index comparison would let every
114
- // surviving row through and draw a widget for each one.
116
+ // sibling. Compare it against the row at the same index instead.
115
117
  if (handleRowReplacement) {
116
118
  var counterpart = tableNew.node.maybeChild(changedRow.rowIndex);
117
119
  return !counterpart || !(0, _document.areNodesEqualIgnoreAttrs)(counterpart, changedRow.rowNode);
118
120
  }
119
- return !tableNew.node.children.some(function (newRow) {
120
- return (0, _document.areNodesEqualIgnoreAttrs)(newRow, changedRow.rowNode);
121
+ var deletionCount = equivalentRowDeletionCounts.find(function (_ref2) {
122
+ var rowNode = _ref2.rowNode;
123
+ return (0, _document.areNodesEqualIgnoreAttrs)(rowNode, changedRow.rowNode);
121
124
  });
125
+ if (!deletionCount) {
126
+ var oldRowCount = tableOld.node.children.filter(function (oldRow) {
127
+ return (0, _document.areNodesEqualIgnoreAttrs)(oldRow, changedRow.rowNode);
128
+ }).length;
129
+ var newRowCount = tableNew.node.children.filter(function (newRow) {
130
+ return (0, _document.areNodesEqualIgnoreAttrs)(newRow, changedRow.rowNode);
131
+ }).length;
132
+ deletionCount = {
133
+ remaining: Math.max(0, oldRowCount - newRowCount),
134
+ rowNode: changedRow.rowNode
135
+ };
136
+ equivalentRowDeletionCounts.push(deletionCount);
137
+ }
138
+ if (deletionCount.remaining === 0) {
139
+ return false;
140
+ }
141
+ deletionCount.remaining--;
142
+ return true;
122
143
  });
123
144
  };
124
145
 
@@ -163,6 +184,9 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
163
184
  // is ADDED content, so it must not claim the "deleted" testid — page models match that as
164
185
  // removed content (same reasoning as `createTableCellContentWidgets`).
165
186
  tr.setAttribute('data-testid', (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted && (0, _fg.fg)('platform_editor_ai_show_diff_patch_1') ? 'show-diff-changed-row' : 'show-diff-deleted-row');
187
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
188
+ tr.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
189
+ }
166
190
 
167
191
  // Serialize each cell in the row
168
192
  var cellIndex = 0;
@@ -201,11 +225,11 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
201
225
  /**
202
226
  * Expands a diff to include whole changed rows when table rows are affected
203
227
  */
204
- var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
205
- var changes = _ref2.changes,
206
- originalDoc = _ref2.originalDoc,
207
- newDoc = _ref2.newDoc,
208
- diffType = _ref2.diffType;
228
+ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref3) {
229
+ var changes = _ref3.changes,
230
+ originalDoc = _ref3.originalDoc,
231
+ newDoc = _ref3.newDoc,
232
+ diffType = _ref3.diffType;
209
233
  var rowInfo = [];
210
234
  var _iterator = _createForOfIteratorHelper(changes),
211
235
  _step;
@@ -234,17 +258,22 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
234
258
  /**
235
259
  * Main function to handle deleted rows - computes diff and creates decorations
236
260
  */
237
- var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(_ref3) {
238
- var changes = _ref3.changes,
239
- originalDoc = _ref3.originalDoc,
240
- newDoc = _ref3.newDoc,
241
- nodeViewSerializer = _ref3.nodeViewSerializer,
242
- colorScheme = _ref3.colorScheme,
243
- _ref3$isInserted = _ref3.isInserted,
244
- isInserted = _ref3$isInserted === void 0 ? false : _ref3$isInserted,
245
- diffType = _ref3.diffType,
246
- _ref3$showIndicators = _ref3.showIndicators,
247
- showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators;
261
+ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(_ref4) {
262
+ var attributionKey = _ref4.attributionKey,
263
+ changes = _ref4.changes,
264
+ originalDoc = _ref4.originalDoc,
265
+ newDoc = _ref4.newDoc,
266
+ nodeViewSerializer = _ref4.nodeViewSerializer,
267
+ colorScheme = _ref4.colorScheme,
268
+ isActive = _ref4.isActive,
269
+ _ref4$isInserted = _ref4.isInserted,
270
+ isInserted = _ref4$isInserted === void 0 ? false : _ref4$isInserted,
271
+ diffType = _ref4.diffType,
272
+ _ref4$showIndicators = _ref4.showIndicators,
273
+ showIndicators = _ref4$showIndicators === void 0 ? false : _ref4$showIndicators,
274
+ _ref4$showContributor = _ref4.showContributorTags,
275
+ showContributorTags = _ref4$showContributor === void 0 ? false : _ref4$showContributor,
276
+ tagMountContext = _ref4.tagMountContext;
248
277
  // First, expand the changes to include complete deleted rows
249
278
  var changedRows = expandDiffForChangedRows({
250
279
  changes: changes.filter(function (change) {
@@ -261,8 +290,12 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
261
290
  var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, changedRow.fromB - 1,
262
291
  // -1 to find the first safe position from the table
263
292
  originalDoc.slice(changedRow.fromA, changedRow.toA));
264
- var diffId = crypto.randomUUID();
293
+
294
+ // Stable while contributor tags are enabled so a decoration recalculation preserves the tag's
295
+ // identity and controller state.
296
+ var diffId = showContributorTags ? "widget-row-".concat(changedRow.fromA, "-").concat(changedRow.toA) : crypto.randomUUID();
265
297
  var decorations = [];
298
+ var rowAnchorNames = [];
266
299
 
267
300
  // `IndicatorBarContentComponent` renders a bar for every widget descriptor and anchors its
268
301
  // top and bottom to `anchor-<diffId>`. Without an element carrying that anchor name the bar
@@ -270,9 +303,9 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
270
303
  // bar covers only the row being changed. `createNodeChangedDecorationWidget` sets the same
271
304
  // property on its own widget DOM for non-table content; this path returns before reaching it.
272
305
  if (showIndicators && (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && (0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
273
- rowDOM.style.setProperty('anchor-name', "--".concat((0, _decorationKeys.buildAnchorDecorationKey)({
306
+ rowAnchorNames.push((0, _decorationKeys.buildAnchorDecorationKey)({
274
307
  diffId: diffId
275
- })));
308
+ }));
276
309
 
277
310
  // A table's content can extend past the doc margin, so the bar also needs a left anchor
278
311
  // measured against the table itself or it is clipped once the table is resized.
@@ -285,14 +318,47 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
285
318
  decorations.push(leftAnchor);
286
319
  }
287
320
  }
288
- decorations.push(_view.Decoration.widget(safeInsertPos, rowDOM, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
321
+ var tagAnchorName = showContributorTags && (0, _createContributorTagWidget.isContributorTagWidgetEnabled)() ? (0, _decorationKeys.buildAnchorDecorationKey)({
322
+ diffId: diffId,
323
+ anchorType: _decorationKeys.AnchorTypeKey.tag
324
+ }) : undefined;
325
+ var tagWidget = tagAnchorName ? (0, _createContributorTagWidget.createContributorTagWidget)({
326
+ anchorAtRangeStart: true,
327
+ anchorName: tagAnchorName,
328
+ diffId: diffId,
329
+ doc: newDoc,
330
+ from: safeInsertPos,
331
+ mountContext: tagMountContext,
332
+ to: safeInsertPos
333
+ }) : undefined;
334
+ if (tagAnchorName) {
335
+ // The tag host is a separate, table-safe widget. CSS anchor positioning aligns it to this
336
+ // synthetic row without placing non-cell DOM inside the `<tr>` or inheriting its deletion
337
+ // opacity and strikethrough.
338
+ rowAnchorNames.push(tagAnchorName);
339
+ }
340
+ if (rowAnchorNames.length > 0) {
341
+ rowDOM.style.setProperty('anchor-name', rowAnchorNames.map(function (anchorName) {
342
+ return "--".concat(anchorName);
343
+ }).join(', '));
344
+ }
345
+ if (tagWidget) {
346
+ // Lets the contributor tag reveal when any part of the deleted row is hovered.
347
+ rowDOM.setAttribute('data-diff-id', diffId);
348
+ }
349
+ var rowWidget = _view.Decoration.widget(safeInsertPos, rowDOM, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
350
+ attributionKey: tagWidget ? attributionKey : undefined,
289
351
  colorScheme: colorScheme,
290
352
  decorationType: 'widget',
291
353
  diffId: diffId,
292
- isActive: false,
354
+ isActive: isActive,
293
355
  isInserted: isInserted,
294
356
  diffType: diffType
295
- }))));
357
+ })));
358
+ decorations.push(rowWidget);
359
+ if (tagWidget) {
360
+ decorations.push(tagWidget);
361
+ }
296
362
  return decorations;
297
363
  });
298
364
  };
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
12
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
13
14
  var _buildContributorTagDom = require("../../ui/ContributorTag/buildContributorTagDom");
14
15
  var _isExtendedEnabled = require("../isExtendedEnabled");
15
16
  var _isEmptyParagraphSlice = require("../utils/isEmptyParagraphSlice");
@@ -215,7 +216,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
215
216
  diffId: diffId,
216
217
  mountContext: tagMountContext
217
218
  }) : undefined;
218
- var inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined].filter(Boolean).join('');
219
+ var inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined, (0, _fg.fg)('platform_editor_ai_show_diff_patch_1') ? _decorationKeys.scrollMarginTopStyle : undefined].filter(Boolean).join('');
219
220
  var decorations = [_view.Decoration.inline(change.fromB, change.toB, _objectSpread(_objectSpread(_objectSpread({
220
221
  style: inlineStyle
221
222
  }, atomicInlineAttrs && {
@@ -80,6 +80,9 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
80
80
  // This helper only runs for added content, so use the "changed" testid — not
81
81
  // "deleted", which page models match as removed content.
82
82
  dom.setAttribute('data-testid', 'show-diff-changed-decoration');
83
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
84
+ dom.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
85
+ }
83
86
 
84
87
  // Skip findSafeInsertPos: it walks forward to a schema-valid cell-insert point
85
88
  // and pushes the widget into the next cell. `targetPos` is the correct spot.
@@ -166,16 +169,20 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
166
169
  }
167
170
  if (isTableRowContent) {
168
171
  return (0, _createChangedRowDecorationWidgets.createChangedRowDecorationWidgets)({
172
+ attributionKey: attributionKey,
169
173
  changes: [change],
170
174
  originalDoc: doc,
171
175
  newDoc: newDoc,
172
176
  nodeViewSerializer: nodeViewSerializer,
173
177
  colorScheme: colorScheme,
178
+ isActive: isActive,
174
179
  isInserted: isInserted,
175
180
  diffType: diffType,
176
181
  // Needed for the row's own indicator anchor; this path returns before the
177
182
  // `anchor-name` assignment further down.
178
- showIndicators: showIndicators
183
+ showIndicators: showIndicators,
184
+ showContributorTags: showContributorTags,
185
+ tagMountContext: tagMountContext
179
186
  });
180
187
  }
181
188
  var serializer = nodeViewSerializer;
@@ -352,6 +359,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
352
359
  }
353
360
  });
354
361
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
362
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
363
+ dom.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
364
+ }
355
365
 
356
366
  // Needed even when the indicator bar is off, because a contributor tag also anchors against the
357
367
  // widget.
@@ -431,6 +441,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
431
441
  defaultSpacer.dataset.testid = 'show-diff-default-margin-spacer';
432
442
  defaultSpacer.style.display = 'block';
433
443
  defaultSpacer.style.marginTop = "var(--ds-space-100, 8px)";
444
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
445
+ defaultSpacer.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
446
+ }
434
447
  decorations.push(_view.Decoration.widget(safeInsertPos, defaultSpacer, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
435
448
  colorScheme: colorScheme,
436
449
  decorationType: 'widget',
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.buildAnchorDecorationKey = exports.DiffDecorationKey = exports.DecorationFamily = exports.AnchorTypeKey = exports.AnchorDocMarginKey = void 0;
7
+ exports.buildAnchorDecorationKey = exports.SCROLL_TARGET_MARGIN_CSS_PROPERTY = exports.DiffDecorationKey = exports.DecorationFamily = exports.AnchorTypeKey = exports.AnchorDocMarginKey = void 0;
8
8
  exports.buildAnchorDecorationSpec = buildAnchorDecorationSpec;
9
- exports.isDiffDecorationSpec = exports.isDiffDecoration = exports.isAnchorDecorationSpec = exports.extractDiffDescriptors = exports.buildDiffDecorationSpec = exports.buildDiffDecorationKey = exports.buildContributorTagDecorationSpec = void 0;
9
+ exports.scrollMarginTopValue = exports.scrollMarginTopStyle = exports.isDiffDecorationSpec = exports.isDiffDecoration = exports.isAnchorDecorationSpec = exports.extractDiffDescriptors = exports.buildDiffDecorationSpec = exports.buildDiffDecorationKey = exports.buildContributorTagDecorationSpec = void 0;
10
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _isExtendedEnabled = require("../isExtendedEnabled");
@@ -21,6 +21,16 @@ var DecorationFamily = exports.DecorationFamily = {
21
21
  anchor: 'anchor',
22
22
  contributorTag: 'contributor-tag'
23
23
  };
24
+
25
+ /**
26
+ * Navigation measures the target table header and writes this variable on the
27
+ * editor root immediately before scrolling. Diff decorations inherit it, so
28
+ * native scrolling leaves room for the header without DOM mutation on the
29
+ * ProseMirror-rendered suggestion.
30
+ */
31
+ var SCROLL_TARGET_MARGIN_CSS_PROPERTY = exports.SCROLL_TARGET_MARGIN_CSS_PROPERTY = '--ak-editor-diff-additional-margin';
32
+ var scrollMarginTopValue = exports.scrollMarginTopValue = "calc(".concat("var(--ds-space-400, 32px)", " + var(", SCROLL_TARGET_MARGIN_CSS_PROPERTY, ", 0px))");
33
+ var scrollMarginTopStyle = exports.scrollMarginTopStyle = "scroll-margin-top: ".concat(scrollMarginTopValue, ";");
24
34
  var AnchorTypeKey = exports.AnchorTypeKey = {
25
35
  from: 'from',
26
36
  to: 'to',
@@ -258,7 +258,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
258
258
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && (0, _isExtendedEnabled.isExtendedEnabled)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
259
259
  var _cancelPendingScrollT;
260
260
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 || _cancelPendingScrollT();
261
- cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, (0, _getScrollableDecorations.getScrollableDecorations)(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
261
+ cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, (0, _getScrollableDecorations.getScrollableDecorations)(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType), undefined, api);
262
262
 
263
263
  // Reset the flag so we don't scroll again on subsequent updates
264
264
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -279,7 +279,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
279
279
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
280
280
  api === null || api === void 0 || api.core.actions.execute((0, _expand.toggleExpandRange)(activeDecoration.from, activeDecoration.to, true));
281
281
  }
282
- cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, scrollableDecorations, pluginState.activeIndex);
282
+ cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, scrollableDecorations, pluginState.activeIndex, api);
283
283
 
284
284
  // Stepping only scrolls — no focus moves and no content changes — so without this a
285
285
  // screen-reader user gets silence. Announced through the live region rather than by
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.scrollToDecoration = void 0;
7
+ var _styles = require("@atlaskit/editor-common/styles");
8
+ var _getStickyHeaderHeight = require("@atlaskit/editor-common/table/get-sticky-header-height");
9
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
7
10
  var _decorationKeys = require("./decorations/decorationKeys");
8
11
  /**
9
12
  * Extra space above the scrolled-to element so it does not sit flush under the
@@ -15,6 +18,12 @@ var _decorationKeys = require("./decorations/decorationKeys");
15
18
  * outer scroll or mis-identifies the active scroll container.
16
19
  */
17
20
  var SCROLL_TOP_MARGIN_PX = 100;
21
+ function updateScrollTargetMargin(view, targetPos, api) {
22
+ var _api$limitedMode;
23
+ var isLimitedModeEnabled = Boolean(api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.enabled);
24
+ var tableHeaderHeight = isLimitedModeEnabled ? undefined : (0, _getStickyHeaderHeight.getStickyHeaderHeight)(view, targetPos);
25
+ view.dom.style.setProperty(_decorationKeys.SCROLL_TARGET_MARGIN_CSS_PROPERTY, "".concat(tableHeaderHeight ? tableHeaderHeight + _styles.tableMarginTop : 0, "px"));
26
+ }
18
27
 
19
28
  /**
20
29
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
@@ -25,6 +34,13 @@ function scrollToSelection(node) {
25
34
  if (!(element instanceof HTMLElement)) {
26
35
  return;
27
36
  }
37
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
38
+ element.scrollIntoView({
39
+ behavior: 'smooth',
40
+ block: 'start'
41
+ });
42
+ return;
43
+ }
28
44
 
29
45
  // scroll-margin is included in scroll-into-view math; it does not change layout.
30
46
  var previousScrollMarginTop = element.style.scrollMarginTop;
@@ -47,6 +63,7 @@ function scrollToSelection(node) {
47
63
  */
48
64
  var scrollToDecoration = exports.scrollToDecoration = function scrollToDecoration(view, decorations) {
49
65
  var activeIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
66
+ var api = arguments.length > 3 ? arguments[3] : undefined;
50
67
  var decoration = decorations[activeIndex];
51
68
  if (!decoration) {
52
69
  return function () {};
@@ -58,6 +75,9 @@ var scrollToDecoration = exports.scrollToDecoration = function scrollToDecoratio
58
75
  var target = (0, _decorationKeys.isDiffDecoration)(decoration) && decoration.spec.scrollTarget || decoration;
59
76
  var rafId = requestAnimationFrame(function () {
60
77
  rafId = null;
78
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
79
+ updateScrollTargetMargin(view, target.from, api);
80
+ }
61
81
  if ((0, _decorationKeys.isDiffDecoration)(target) && target.spec.decorationType === 'widget') {
62
82
  var _target$type;
63
83
  // @ts-expect-error - decoration.type is not typed public API
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.buildContributorTagDom = exports.TAG_EXIT_FALLBACK_MS = exports.MAX_TAG_WIDTH = exports.CONTRIBUTOR_TAG_Z_INDEX = exports.CONTRIBUTOR_TAG_TOOLTIP_STYLES = exports.CONTRIBUTOR_TAG_TESTID = exports.CONTRIBUTOR_TAG_REVEALED_ATTRIBUTE = exports.CONTRIBUTOR_TAG_NAME_TESTID = exports.CONTRIBUTOR_TAG_CLASS = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
+ var _constants = require("@atlaskit/editor-shared-styles/constants");
10
11
  var CONTRIBUTOR_TAG_TESTID = exports.CONTRIBUTOR_TAG_TESTID = 'diff-contributor-tag';
11
12
  var CONTRIBUTOR_TAG_NAME_TESTID = exports.CONTRIBUTOR_TAG_NAME_TESTID = 'diff-contributor-tag-name';
12
13
 
@@ -20,15 +21,15 @@ var MAX_TAG_WIDTH = exports.MAX_TAG_WIDTH = '200px';
20
21
  /**
21
22
  * The tag sits on the line above the change, so it has to paint over that line to be readable —
22
23
  * including any diff highlight already on it, which would otherwise slice straight through the tag.
23
- * Hence one level above `akEditorUnitZIndex`, where the highlights sit; exported because the
24
- * change's own highlight is stacked one level below it — see `stackBelowContributorTagStyle` in
25
- * `createInlineChangedDecoration`.
24
+ * It also has to paint above table interaction overlays and sticky-capable header rows, which use
25
+ * `akEditorSmallZIndex`. The change's own highlight is stacked one level below it — see
26
+ * `stackBelowContributorTagStyle` in `createInlineChangedDecoration`.
26
27
  *
27
28
  * Painting above its own highlight is only safe because the tag can never reach it: `bottom: 100%`
28
29
  * puts the root's bottom edge exactly on the highlight's top edge, and the root's `overflow: clip`
29
30
  * keeps every pixel the tag paints inside it.
30
31
  */
31
- var CONTRIBUTOR_TAG_Z_INDEX = exports.CONTRIBUTOR_TAG_Z_INDEX = 2;
32
+ var CONTRIBUTOR_TAG_Z_INDEX = exports.CONTRIBUTOR_TAG_Z_INDEX = _constants.akEditorSmallZIndex + 1;
32
33
 
33
34
  /**
34
35
  * The plugin's whole side of the tag's motion: the fade and the hidden state are
@@ -1,4 +1,4 @@
1
- /* IndicatorBar.tsx generated by @compiled/babel-plugin v3.0.1 */
1
+ /* IndicatorBar.tsx generated by @compiled/babel-plugin v3.0.2 */
2
2
  "use strict";
3
3
 
4
4
  var _typeof = require("@babel/runtime/helpers/typeof");
@@ -1,4 +1,4 @@
1
- /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v3.0.1 */
1
+ /* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v3.0.2 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,13 +1,13 @@
1
1
  import isEqual from 'lodash/isEqual';
2
2
  import memoizeOne from 'memoize-one';
3
3
  import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
4
+ import { areDocsEqualByBlockStructureAndText } from '@atlaskit/editor-common/utils/areDocsEqualByBlockStructureAndText';
4
5
  import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
5
6
  import { Mapping } from '@atlaskit/editor-prosemirror/transform';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
8
9
  import { fg } from '@atlaskit/platform-feature-flags/fg';
9
10
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
- import { areDocsEqualByBlockStructureAndText } from '../areDocsEqualByBlockStructureAndText';
11
11
  import { createDocMarginAnchorWidget } from '../decorations/createAnchorDecorationWidgets';
12
12
  import { createBlockChangedDecoration } from '../decorations/createBlockChangedDecoration';
13
13
  import { createInlineChangedDecoration } from '../decorations/createInlineChangedDecoration';
@@ -220,6 +220,7 @@ export const createBlockIndicatorAnchorWidgets = ({
220
220
  to,
221
221
  diffId
222
222
  }) => {
223
+ var _ref, _parentTable$pos;
223
224
  const leftAnchor = createLeftAnchorWidget({
224
225
  doc,
225
226
  from,
@@ -251,9 +252,12 @@ export const createBlockIndicatorAnchorWidgets = ({
251
252
  const $from = doc.resolve(from);
252
253
  const parentTable = findParentNodeClosestToPos($from, ancestor => ancestor.type.name === 'table');
253
254
  const parentCellOrRow = findParentNodeClosestToPos($from, ancestor => ['tableCell', 'tableHeader', 'tableRow'].includes(ancestor.type.name));
254
-
255
- // Render outside the table when inside one; otherwise keep the original pos.
256
- const widgetPos = parentTable ? parentTable.pos : from;
255
+ const parentLayout = fg('platform_editor_ai_show_diff_patch_1') ? findParentNodeClosestToPos($from, ancestor => ancestor.type.name === 'layoutSection') : undefined;
256
+ // Layouts flatten direct widget children with display: contents. Such a wrapper has no
257
+ // bounding box or positioning context, so measuring its top produces an offset from the
258
+ // viewport origin and displaces the indicator into content below the editor. Keep the
259
+ // wrapper outside the layout, just as we do for tables, but still measure the target node.
260
+ const widgetPos = (_ref = (_parentTable$pos = parentTable === null || parentTable === void 0 ? void 0 : parentTable.pos) !== null && _parentTable$pos !== void 0 ? _parentTable$pos : parentLayout === null || parentLayout === void 0 ? void 0 : parentLayout.pos) !== null && _ref !== void 0 ? _ref : from;
257
261
  // Measure the actual cell/row DOM when inside one; otherwise measure the
258
262
  // widget's own position.
259
263
  const measurePos = parentCellOrRow ? parentCellOrRow.pos : from;
@@ -2,12 +2,13 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
4
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
6
  import { isExtendedEnabled } from '../isExtendedEnabled';
6
7
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
7
8
  import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
8
9
  import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
9
10
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
10
- import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
11
+ import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopStyle } from './decorationKeys';
11
12
  import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
12
13
  const displayNoneStyle = convertToInlineCss({
13
14
  display: 'none'
@@ -230,11 +231,11 @@ export const createBlockChangedDecoration = ({
230
231
  });
231
232
  const style = tagAnchorName ? [nodeStyle, convertToInlineCss({
232
233
  anchorName: `--${tagAnchorName}`
233
- })].filter(Boolean).join(' ') : nodeStyle;
234
+ }), fg('platform_editor_ai_show_diff_patch_1') ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
234
235
  const className = getNodeClass(change.name);
235
236
  if (style || className) {
236
237
  decorations.push(Decoration.node(change.from, change.to, {
237
- style: style,
238
+ style,
238
239
  'data-testid': 'show-diff-changed-decoration-node',
239
240
  class: className,
240
241
  // Lets the contributor tag find the block it captions on hover.