@atlaskit/editor-plugin-show-diff 16.0.16 → 16.1.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 (39) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/afm-products/tsconfig.json +3 -0
  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 +3 -0
  6. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +2 -1
  7. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -0
  8. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +12 -2
  9. package/dist/cjs/pm-plugins/main.js +22 -20
  10. package/dist/cjs/pm-plugins/scrollToDiff.js +20 -0
  11. package/dist/cjs/ui/IndicatorBar/IndicatorBar.js +1 -1
  12. package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  13. package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +7 -3
  14. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +4 -3
  15. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +4 -1
  16. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +3 -2
  17. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -1
  18. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +10 -0
  19. package/dist/es2019/pm-plugins/main.js +21 -19
  20. package/dist/es2019/pm-plugins/scrollToDiff.js +21 -3
  21. package/dist/es2019/ui/IndicatorBar/IndicatorBar.js +1 -1
  22. package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  23. package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +19 -13
  24. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +3 -2
  25. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +4 -1
  26. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +3 -2
  27. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -1
  28. package/dist/esm/pm-plugins/decorations/decorationKeys.js +10 -0
  29. package/dist/esm/pm-plugins/main.js +22 -20
  30. package/dist/esm/pm-plugins/scrollToDiff.js +21 -2
  31. package/dist/esm/ui/IndicatorBar/IndicatorBar.js +1 -1
  32. package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +1 -1
  33. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  34. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +2 -2
  35. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +9 -0
  36. package/dist/types/pm-plugins/main.d.ts +7 -1
  37. package/dist/types/pm-plugins/scrollToDiff.d.ts +5 -1
  38. package/dist/types/showDiffPluginType.d.ts +19 -2
  39. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 16.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8c4837792f18f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c4837792f18f) -
8
+ Add a per-call colorScheme override to the showDiff command, so callers can paint a diff in a
9
+ specific colour scheme without changing the plugin's configured default.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 16.0.17
16
+
17
+ ### Patch Changes
18
+
19
+ - [`bac902441a512`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bac902441a512) -
20
+ Keep layout column diff indicators aligned with their content instead of appearing beside the
21
+ comments footer, behind `platform_editor_ai_show_diff_patch_1`.
22
+ - [`20d41af8d6f4c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20d41af8d6f4c) -
23
+ EDITOR-9000 Fixes scroll to suggestion when it is in table with sticky header
24
+ - Updated dependencies
25
+
3
26
  ## 16.0.16
4
27
 
5
28
  ### Patch Changes
@@ -32,6 +32,9 @@
32
32
  {
33
33
  "path": "../../editor-plugin-analytics/afm-products/tsconfig.json"
34
34
  },
35
+ {
36
+ "path": "../../editor-plugin-limited-mode/afm-products/tsconfig.json"
37
+ },
35
38
  {
36
39
  "path": "../../editor-plugin-user-intent/afm-products/tsconfig.json"
37
40
  },
@@ -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({
@@ -184,6 +184,9 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
184
184
  // is ADDED content, so it must not claim the "deleted" testid — page models match that as
185
185
  // removed content (same reasoning as `createTableCellContentWidgets`).
186
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
+ }
187
190
 
188
191
  // Serialize each cell in the row
189
192
  var cellIndex = 0;
@@ -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.
@@ -356,6 +359,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
356
359
  }
357
360
  });
358
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
+ }
359
365
 
360
366
  // Needed even when the indicator bar is off, because a contributor tag also anchors against the
361
367
  // widget.
@@ -435,6 +441,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
435
441
  defaultSpacer.dataset.testid = 'show-diff-default-margin-spacer';
436
442
  defaultSpacer.style.display = 'block';
437
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
+ }
438
447
  decorations.push(_view.Decoration.widget(safeInsertPos, defaultSpacer, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
439
448
  colorScheme: colorScheme,
440
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',
@@ -94,7 +94,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
94
94
  var newPluginState = currentPluginState;
95
95
  if (meta) {
96
96
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'REVEAL_COMPLETE') {
97
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1;
97
+ var _newPluginState$color, _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1, _newPluginState10;
98
98
  // REVEAL_COMPLETE repaints with the reveal dropped, so the decorations render their
99
99
  // ordinary resting style. Without it the reveal stays in state indefinitely and the
100
100
  // next unrelated repaint re-emits the hidden, zero-width highlight with no animation
@@ -114,23 +114,23 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
114
114
  state: newState,
115
115
  pluginState: newPluginState,
116
116
  nodeViewSerializer: nodeViewSerializer,
117
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
117
+ colorScheme: (_newPluginState$color = (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.colorScheme) !== null && _newPluginState$color !== void 0 ? _newPluginState$color : config === null || config === void 0 ? void 0 : config.colorScheme,
118
118
  intl: getIntl(),
119
119
  activeIndexPos: newPluginState.activeIndexPos,
120
120
  api: api,
121
121
  tagMountContext: tagMountContext
122
- }, (0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
123
- isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
124
- diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
125
- hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
126
- hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
127
- showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
128
- smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
129
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
130
- inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement,
122
+ }, (0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType) ? {
123
+ isInverted: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.isInverted,
124
+ diffType: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.diffType,
125
+ hideDeletedDiffs: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideDeletedDiffs,
126
+ hideAddedDiffsUnderline: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.hideAddedDiffsUnderline,
127
+ showIndicators: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.showIndicators,
128
+ smartThresholds: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.smartThresholds,
129
+ deletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.deletedDiffPlacement,
130
+ inlineDeletedDiffPlacement: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.inlineDeletedDiffPlacement,
131
131
  // SHOW_DIFF only. The scroll-to-next recalculation further down deliberately
132
132
  // omits this so stepping through changes cannot replay the choreography.
133
- reveal: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.reveal
133
+ reveal: (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.reveal
134
134
  } : {})),
135
135
  contributorTags = _calculateDiffDecorat.contributorTags,
136
136
  decorations = _calculateDiffDecorat.decorations,
@@ -138,7 +138,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
138
138
  // Update the decorations and their ids
139
139
  newPluginState.decorations = decorations;
140
140
  newPluginState.contributorTags = contributorTags;
141
- if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType)) {
141
+ if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType)) {
142
142
  newPluginState.diffDescriptors = diffDescriptors;
143
143
  }
144
144
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -147,7 +147,9 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
147
147
  isDisplayingChanges: false,
148
148
  activeIndex: undefined,
149
149
  contributorTags: [],
150
- reveal: undefined
150
+ reveal: undefined,
151
+ // Per-call override — do not let it leak into the next, unrelated `showDiff` call.
152
+ colorScheme: undefined
151
153
  }, (0, _isExtendedEnabled.isExtendedEnabled)(currentPluginState.diffType) ? {
152
154
  isInverted: false,
153
155
  diffType: (0, _isExtendedEnabled.getDefaultDiffType)(),
@@ -156,11 +158,11 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
156
158
  diffDescriptors: []
157
159
  } : {});
158
160
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
159
- var _newPluginState10;
161
+ var _newPluginState11;
160
162
  // Update the active index in plugin state and recalculate decorations
161
- var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType);
163
+ var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState11 = newPluginState) === null || _newPluginState11 === void 0 ? void 0 : _newPluginState11.diffType);
162
164
  if (_decorations.length > 0) {
163
- var _currentPluginState$a;
165
+ var _currentPluginState$a, _newPluginState$color2, _newPluginState12;
164
166
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
165
167
  // This allows the UI to start with no selection and only highlight on first user interaction.
166
168
  var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
@@ -188,7 +190,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
188
190
  state: newState,
189
191
  pluginState: newPluginState,
190
192
  nodeViewSerializer: nodeViewSerializer,
191
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
193
+ colorScheme: (_newPluginState$color2 = (_newPluginState12 = newPluginState) === null || _newPluginState12 === void 0 ? void 0 : _newPluginState12.colorScheme) !== null && _newPluginState$color2 !== void 0 ? _newPluginState$color2 : config === null || config === void 0 ? void 0 : config.colorScheme,
192
194
  intl: getIntl(),
193
195
  activeIndexPos: newPluginState.activeIndexPos,
194
196
  api: api,
@@ -258,7 +260,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
258
260
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && (0, _isExtendedEnabled.isExtendedEnabled)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
259
261
  var _cancelPendingScrollT;
260
262
  (_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));
263
+ 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
264
 
263
265
  // Reset the flag so we don't scroll again on subsequent updates
264
266
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -279,7 +281,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
279
281
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
280
282
  api === null || api === void 0 || api.core.actions.execute((0, _expand.toggleExpandRange)(activeDecoration.from, activeDecoration.to, true));
281
283
  }
282
- cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, scrollableDecorations, pluginState.activeIndex);
284
+ cancelPendingScrollToDecoration = (0, _scrollToDiff.scrollToDecoration)(view, scrollableDecorations, pluginState.activeIndex, api);
283
285
 
284
286
  // Stepping only scrolls — no focus moves and no content changes — so without this a
285
287
  // 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
@@ -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");
@@ -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.
@@ -11,7 +11,7 @@ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/scheme
11
11
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
12
12
  import { resolveCellOverlayStyleLegacy, resolveDeletedRowStyleLegacy } from './createChangedRowDecorationWidgets.styles.legacy';
13
13
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
14
- import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
14
+ import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec, scrollMarginTopValue } from './decorationKeys';
15
15
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
16
16
  import { applyCellEdgeAttrs, getRowCellEdgeAttrs, getTableTopAndBottomCellEdgeAttrs } from './utils/tableCellEdgeAttrs';
17
17
  /**
@@ -160,6 +160,9 @@ const createChangedRowDOM = (rowNode, cellEdgeAttrs, nodeViewSerializer, colorSc
160
160
  // is ADDED content, so it must not claim the "deleted" testid — page models match that as
161
161
  // removed content (same reasoning as `createTableCellContentWidgets`).
162
162
  tr.setAttribute('data-testid', isExtendedEnabled(diffType) && isInserted && fg('platform_editor_ai_show_diff_patch_1') ? 'show-diff-changed-row' : 'show-diff-deleted-row');
163
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
164
+ tr.style.setProperty('scroll-margin-top', scrollMarginTopValue);
165
+ }
163
166
 
164
167
  // Serialize each cell in the row
165
168
  let cellIndex = 0;
@@ -1,6 +1,7 @@
1
1
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
5
  import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
5
6
  import { isExtendedEnabled } from '../isExtendedEnabled';
6
7
  import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
@@ -9,7 +10,7 @@ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/scheme
9
10
  import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
10
11
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
11
12
  import { getAtomicInlineNodeClassNameLegacy, resolveInlineChangedStyleLegacy } from './createInlineChangedDecoration.styles.legacy';
12
- import { buildDiffDecorationSpec } from './decorationKeys';
13
+ import { buildDiffDecorationSpec, scrollMarginTopStyle } from './decorationKeys';
13
14
  import { REVEAL_ATTR, resolveRevealStyle } from './revealStyles';
14
15
  const displayNoneStyle = convertToInlineCss({
15
16
  display: 'none'
@@ -190,7 +191,7 @@ export const createInlineChangedDecoration = ({
190
191
  diffId,
191
192
  mountContext: tagMountContext
192
193
  }) : undefined;
193
- const inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined].filter(Boolean).join('');
194
+ const inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined, fg('platform_editor_ai_show_diff_patch_1') ? scrollMarginTopStyle : undefined].filter(Boolean).join('');
194
195
  const decorations = [Decoration.inline(change.fromB, change.toB, {
195
196
  style: inlineStyle,
196
197
  ...(atomicInlineAttrs && {
@@ -5,7 +5,7 @@ import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
5
5
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
6
6
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
7
7
  import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
8
- import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
8
+ import { buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
9
9
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
10
10
  import { wrapBlockNodeView, injectInnerWrapper, createContentWrapper } from './utils/wrapBlockNodeView';
11
11
  const isHeadingLevel = level => typeof level === 'number' && level >= 1 && level <= 6;
@@ -69,6 +69,9 @@ const createTableCellContentWidgets = ({
69
69
  // This helper only runs for added content, so use the "changed" testid — not
70
70
  // "deleted", which page models match as removed content.
71
71
  dom.setAttribute('data-testid', 'show-diff-changed-decoration');
72
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
73
+ dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
74
+ }
72
75
 
73
76
  // Skip findSafeInsertPos: it walks forward to a schema-valid cell-insert point
74
77
  // and pushes the widget into the next cell. `targetPos` is the correct spot.
@@ -334,6 +337,9 @@ export const createNodeChangedDecorationWidget = ({
334
337
  }
335
338
  });
336
339
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
340
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
341
+ dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
342
+ }
337
343
 
338
344
  // Needed even when the indicator bar is off, because a contributor tag also anchors against the
339
345
  // widget.
@@ -420,6 +426,9 @@ export const createNodeChangedDecorationWidget = ({
420
426
  defaultSpacer.dataset.testid = 'show-diff-default-margin-spacer';
421
427
  defaultSpacer.style.display = 'block';
422
428
  defaultSpacer.style.marginTop = "var(--ds-space-100, 8px)";
429
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
430
+ defaultSpacer.style.setProperty('scroll-margin-top', scrollMarginTopValue);
431
+ }
423
432
  decorations.push(Decoration.widget(safeInsertPos, defaultSpacer, {
424
433
  ...buildDiffDecorationSpec({
425
434
  colorScheme,
@@ -8,6 +8,16 @@ export const DecorationFamily = {
8
8
  anchor: 'anchor',
9
9
  contributorTag: 'contributor-tag'
10
10
  };
11
+
12
+ /**
13
+ * Navigation measures the target table header and writes this variable on the
14
+ * editor root immediately before scrolling. Diff decorations inherit it, so
15
+ * native scrolling leaves room for the header without DOM mutation on the
16
+ * ProseMirror-rendered suggestion.
17
+ */
18
+ export const SCROLL_TARGET_MARGIN_CSS_PROPERTY = '--ak-editor-diff-additional-margin';
19
+ export const scrollMarginTopValue = `calc(${"var(--ds-space-400, 32px)"} + var(${SCROLL_TARGET_MARGIN_CSS_PROPERTY}, 0px))`;
20
+ export const scrollMarginTopStyle = `scroll-margin-top: ${scrollMarginTopValue};`;
11
21
  export const AnchorTypeKey = {
12
22
  from: 'from',
13
23
  to: 'to',