@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
@@ -83,7 +83,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
83
83
  let newPluginState = currentPluginState;
84
84
  if (meta) {
85
85
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'REVEAL_COMPLETE') {
86
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1;
86
+ var _newPluginState$color, _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1, _newPluginState10;
87
87
  // REVEAL_COMPLETE repaints with the reveal dropped, so the decorations render their
88
88
  // ordinary resting style. Without it the reveal stays in state indefinitely and the
89
89
  // next unrelated repaint re-emits the hidden, zero-width highlight with no animation
@@ -110,29 +110,29 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
110
110
  state: newState,
111
111
  pluginState: newPluginState,
112
112
  nodeViewSerializer,
113
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
113
+ 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,
114
114
  intl: getIntl(),
115
115
  activeIndexPos: newPluginState.activeIndexPos,
116
116
  api,
117
117
  tagMountContext,
118
- ...(isExtendedEnabled((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
119
- isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
120
- diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
121
- hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
122
- hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
123
- showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
124
- smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
125
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
126
- inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement,
118
+ ...(isExtendedEnabled((_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType) ? {
119
+ isInverted: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.isInverted,
120
+ diffType: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.diffType,
121
+ hideDeletedDiffs: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideDeletedDiffs,
122
+ hideAddedDiffsUnderline: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.hideAddedDiffsUnderline,
123
+ showIndicators: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.showIndicators,
124
+ smartThresholds: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.smartThresholds,
125
+ deletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.deletedDiffPlacement,
126
+ inlineDeletedDiffPlacement: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.inlineDeletedDiffPlacement,
127
127
  // SHOW_DIFF only. The scroll-to-next recalculation further down deliberately
128
128
  // omits this so stepping through changes cannot replay the choreography.
129
- reveal: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.reveal
129
+ reveal: (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.reveal
130
130
  } : {})
131
131
  });
132
132
  // Update the decorations and their ids
133
133
  newPluginState.decorations = decorations;
134
134
  newPluginState.contributorTags = contributorTags;
135
- if (isExtendedEnabled((_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType)) {
135
+ if (isExtendedEnabled((_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType)) {
136
136
  newPluginState.diffDescriptors = diffDescriptors;
137
137
  }
138
138
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -144,6 +144,8 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
144
144
  activeIndex: undefined,
145
145
  contributorTags: [],
146
146
  reveal: undefined,
147
+ // Per-call override — do not let it leak into the next, unrelated `showDiff` call.
148
+ colorScheme: undefined,
147
149
  /**
148
150
  * Reset isInverted & diffType state when hiding diffs
149
151
  * Otherwise this should persist for the diff-showing session
@@ -157,11 +159,11 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
157
159
  } : {})
158
160
  };
159
161
  } 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') {
160
- var _newPluginState10;
162
+ var _newPluginState11;
161
163
  // Update the active index in plugin state and recalculate decorations
162
- const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType);
164
+ const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState11 = newPluginState) === null || _newPluginState11 === void 0 ? void 0 : _newPluginState11.diffType);
163
165
  if (decorations.length > 0) {
164
- var _currentPluginState$a;
166
+ var _currentPluginState$a, _newPluginState$color2, _newPluginState12;
165
167
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
166
168
  // This allows the UI to start with no selection and only highlight on first user interaction.
167
169
  let nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
@@ -194,7 +196,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
194
196
  state: newState,
195
197
  pluginState: newPluginState,
196
198
  nodeViewSerializer,
197
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
199
+ 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,
198
200
  intl: getIntl(),
199
201
  activeIndexPos: newPluginState.activeIndexPos,
200
202
  api,
@@ -264,7 +266,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
264
266
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
265
267
  var _cancelPendingScrollT;
266
268
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 ? void 0 : _cancelPendingScrollT();
267
- cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
269
+ cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType), undefined, api);
268
270
 
269
271
  // Reset the flag so we don't scroll again on subsequent updates
270
272
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -285,7 +287,7 @@ export const createPlugin = (config, getIntl, api, onEditorView) => {
285
287
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
286
288
  api === null || api === void 0 ? void 0 : api.core.actions.execute(toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
287
289
  }
288
- cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex);
290
+ cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex, api);
289
291
 
290
292
  // Stepping only scrolls — no focus moves and no content changes — so without this a
291
293
  // screen-reader user gets silence. Announced through the live region rather than by
@@ -1,5 +1,7 @@
1
- import { isDiffDecoration } from './decorations/decorationKeys';
2
-
1
+ import { tableMarginTop } from '@atlaskit/editor-common/styles';
2
+ import { getStickyHeaderHeight } from '@atlaskit/editor-common/table/get-sticky-header-height';
3
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
+ import { isDiffDecoration, SCROLL_TARGET_MARGIN_CSS_PROPERTY } from './decorations/decorationKeys';
3
5
  /**
4
6
  * Extra space above the scrolled-to element so it does not sit flush under the
5
7
  * viewport edge (helps with sticky table headers, toolbars, etc.).
@@ -10,6 +12,12 @@ import { isDiffDecoration } from './decorations/decorationKeys';
10
12
  * outer scroll or mis-identifies the active scroll container.
11
13
  */
12
14
  const SCROLL_TOP_MARGIN_PX = 100;
15
+ function updateScrollTargetMargin(view, targetPos, api) {
16
+ var _api$limitedMode, _api$limitedMode$shar;
17
+ const isLimitedModeEnabled = Boolean(api === null || api === void 0 ? void 0 : (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : (_api$limitedMode$shar = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode$shar === void 0 ? void 0 : _api$limitedMode$shar.enabled);
18
+ const tableHeaderHeight = isLimitedModeEnabled ? undefined : getStickyHeaderHeight(view, targetPos);
19
+ view.dom.style.setProperty(SCROLL_TARGET_MARGIN_CSS_PROPERTY, `${tableHeaderHeight ? tableHeaderHeight + tableMarginTop : 0}px`);
20
+ }
13
21
 
14
22
  /**
15
23
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
@@ -20,6 +28,13 @@ function scrollToSelection(node) {
20
28
  if (!(element instanceof HTMLElement)) {
21
29
  return;
22
30
  }
31
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
32
+ element.scrollIntoView({
33
+ behavior: 'smooth',
34
+ block: 'start'
35
+ });
36
+ return;
37
+ }
23
38
 
24
39
  // scroll-margin is included in scroll-into-view math; it does not change layout.
25
40
  const previousScrollMarginTop = element.style.scrollMarginTop;
@@ -40,7 +55,7 @@ function scrollToSelection(node) {
40
55
  *
41
56
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
42
57
  */
43
- export const scrollToDecoration = (view, decorations, activeIndex = 0) => {
58
+ export const scrollToDecoration = (view, decorations, activeIndex = 0, api) => {
44
59
  const decoration = decorations[activeIndex];
45
60
  if (!decoration) {
46
61
  return () => {};
@@ -52,6 +67,9 @@ export const scrollToDecoration = (view, decorations, activeIndex = 0) => {
52
67
  const target = isDiffDecoration(decoration) && decoration.spec.scrollTarget || decoration;
53
68
  let rafId = requestAnimationFrame(() => {
54
69
  rafId = null;
70
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
71
+ updateScrollTargetMargin(view, target.from, api);
72
+ }
55
73
  if (isDiffDecoration(target) && target.spec.decorationType === 'widget') {
56
74
  var _target$type;
57
75
  // @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
  import "./IndicatorBar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -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
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React from 'react';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
@@ -214,6 +214,7 @@ export var createLeftAnchorWidget = function createLeftAnchorWidget(_ref) {
214
214
  *
215
215
  */
216
216
  export var createBlockIndicatorAnchorWidgets = function createBlockIndicatorAnchorWidgets(_ref2) {
217
+ var _ref3, _parentTable$pos;
217
218
  var doc = _ref2.doc,
218
219
  from = _ref2.from,
219
220
  to = _ref2.to,
@@ -253,9 +254,14 @@ export var createBlockIndicatorAnchorWidgets = function createBlockIndicatorAnch
253
254
  var parentCellOrRow = findParentNodeClosestToPos($from, function (ancestor) {
254
255
  return ['tableCell', 'tableHeader', 'tableRow'].includes(ancestor.type.name);
255
256
  });
256
-
257
- // Render outside the table when inside one; otherwise keep the original pos.
258
- var widgetPos = parentTable ? parentTable.pos : from;
257
+ var parentLayout = fg('platform_editor_ai_show_diff_patch_1') ? findParentNodeClosestToPos($from, function (ancestor) {
258
+ return ancestor.type.name === 'layoutSection';
259
+ }) : undefined;
260
+ // Layouts flatten direct widget children with display: contents. Such a wrapper has no
261
+ // bounding box or positioning context, so measuring its top produces an offset from the
262
+ // viewport origin and displaces the indicator into content below the editor. Keep the
263
+ // wrapper outside the layout, just as we do for tables, but still measure the target node.
264
+ 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;
259
265
  // Measure the actual cell/row DOM when inside one; otherwise measure the
260
266
  // widget's own position.
261
267
  var measurePos = parentCellOrRow ? parentCellOrRow.pos : from;
@@ -354,11 +360,11 @@ export var createAnchorNameSpan = function createAnchorNameSpan(anchorKey) {
354
360
  span.style.setProperty('anchor-name', "--".concat(anchorKey));
355
361
  return span;
356
362
  };
357
- var createAnchorSpanWidget = function createAnchorSpanWidget(_ref3) {
358
- var pos = _ref3.pos,
359
- diffId = _ref3.diffId,
360
- anchorType = _ref3.anchorType,
361
- side = _ref3.side;
363
+ var createAnchorSpanWidget = function createAnchorSpanWidget(_ref4) {
364
+ var pos = _ref4.pos,
365
+ diffId = _ref4.diffId,
366
+ anchorType = _ref4.anchorType,
367
+ side = _ref4.side;
362
368
  return Decoration.widget(pos, function () {
363
369
  return createAnchorNameSpan(buildAnchorDecorationKey({
364
370
  diffId: diffId,
@@ -375,11 +381,11 @@ var createAnchorSpanWidget = function createAnchorSpanWidget(_ref3) {
375
381
  * Invisible `from`/`to` (and optional `left`) anchor widgets for one inline diff
376
382
  * range, so the `IndicatorBar` can align itself via CSS anchor positioning.
377
383
  */
378
- export var createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref4) {
379
- var doc = _ref4.doc,
380
- from = _ref4.from,
381
- to = _ref4.to,
382
- diffId = _ref4.diffId;
384
+ export var createInlineIndicatorAnchorWidgets = function createInlineIndicatorAnchorWidgets(_ref5) {
385
+ var doc = _ref5.doc,
386
+ from = _ref5.from,
387
+ to = _ref5.to,
388
+ diffId = _ref5.diffId;
383
389
  var leftAnchor = createLeftAnchorWidget({
384
390
  doc: doc,
385
391
  from: from,
@@ -6,12 +6,13 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
6
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
9
10
  import { isExtendedEnabled } from '../isExtendedEnabled';
10
11
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
11
12
  import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
12
13
  import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
13
14
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
14
- import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
15
+ import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopStyle } from './decorationKeys';
15
16
  import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
16
17
  var displayNoneStyle = convertToInlineCss({
17
18
  display: 'none'
@@ -243,7 +244,7 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
243
244
  });
244
245
  var style = tagAnchorName ? [nodeStyle, convertToInlineCss({
245
246
  anchorName: "--".concat(tagAnchorName)
246
- })].filter(Boolean).join(' ') : nodeStyle;
247
+ }), fg('platform_editor_ai_show_diff_patch_1') ? scrollMarginTopStyle : undefined].filter(Boolean).join(' ') : nodeStyle;
247
248
  var className = getNodeClass(change.name);
248
249
  if (style || className) {
249
250
  decorations.push(Decoration.node(change.from, change.to, _objectSpread({
@@ -18,7 +18,7 @@ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/scheme
18
18
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
19
19
  import { resolveCellOverlayStyleLegacy, resolveDeletedRowStyleLegacy } from './createChangedRowDecorationWidgets.styles.legacy';
20
20
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
21
- import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
21
+ import { AnchorTypeKey, buildAnchorDecorationKey, buildDiffDecorationSpec, scrollMarginTopValue } from './decorationKeys';
22
22
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
23
23
  import { applyCellEdgeAttrs, getRowCellEdgeAttrs, getTableTopAndBottomCellEdgeAttrs } from './utils/tableCellEdgeAttrs';
24
24
  /**
@@ -177,6 +177,9 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
177
177
  // is ADDED content, so it must not claim the "deleted" testid — page models match that as
178
178
  // removed content (same reasoning as `createTableCellContentWidgets`).
179
179
  tr.setAttribute('data-testid', isExtendedEnabled(diffType) && isInserted && fg('platform_editor_ai_show_diff_patch_1') ? 'show-diff-changed-row' : 'show-diff-deleted-row');
180
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
181
+ tr.style.setProperty('scroll-margin-top', scrollMarginTopValue);
182
+ }
180
183
 
181
184
  // Serialize each cell in the row
182
185
  var cellIndex = 0;
@@ -5,6 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
8
9
  import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
9
10
  import { isExtendedEnabled } from '../isExtendedEnabled';
10
11
  import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
@@ -13,7 +14,7 @@ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/scheme
13
14
  import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
14
15
  import { createContributorTagWidget, isContributorTagWidgetEnabled } from './createContributorTagWidget';
15
16
  import { getAtomicInlineNodeClassNameLegacy, resolveInlineChangedStyleLegacy } from './createInlineChangedDecoration.styles.legacy';
16
- import { buildDiffDecorationSpec } from './decorationKeys';
17
+ import { buildDiffDecorationSpec, scrollMarginTopStyle } from './decorationKeys';
17
18
  import { REVEAL_ATTR, resolveRevealStyle } from './revealStyles';
18
19
  var displayNoneStyle = convertToInlineCss({
19
20
  display: 'none'
@@ -208,7 +209,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
208
209
  diffId: diffId,
209
210
  mountContext: tagMountContext
210
211
  }) : undefined;
211
- var inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined].filter(Boolean).join('');
212
+ var 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('');
212
213
  var decorations = [Decoration.inline(change.fromB, change.toB, _objectSpread(_objectSpread(_objectSpread({
213
214
  style: inlineStyle
214
215
  }, atomicInlineAttrs && {
@@ -8,7 +8,7 @@ import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
8
8
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
9
9
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
10
10
  import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
11
- import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
11
+ import { buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
12
12
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
13
13
  import { wrapBlockNodeView, injectInnerWrapper, createContentWrapper } from './utils/wrapBlockNodeView';
14
14
  var isHeadingLevel = function isHeadingLevel(level) {
@@ -73,6 +73,9 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
73
73
  // This helper only runs for added content, so use the "changed" testid — not
74
74
  // "deleted", which page models match as removed content.
75
75
  dom.setAttribute('data-testid', 'show-diff-changed-decoration');
76
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
77
+ dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
78
+ }
76
79
 
77
80
  // Skip findSafeInsertPos: it walks forward to a schema-valid cell-insert point
78
81
  // and pushes the widget into the next cell. `targetPos` is the correct spot.
@@ -349,6 +352,9 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
349
352
  }
350
353
  });
351
354
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
355
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
356
+ dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
357
+ }
352
358
 
353
359
  // Needed even when the indicator bar is off, because a contributor tag also anchors against the
354
360
  // widget.
@@ -428,6 +434,9 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
428
434
  defaultSpacer.dataset.testid = 'show-diff-default-margin-spacer';
429
435
  defaultSpacer.style.display = 'block';
430
436
  defaultSpacer.style.marginTop = "var(--ds-space-100, 8px)";
437
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
438
+ defaultSpacer.style.setProperty('scroll-margin-top', scrollMarginTopValue);
439
+ }
431
440
  decorations.push(Decoration.widget(safeInsertPos, defaultSpacer, _objectSpread({}, buildDiffDecorationSpec({
432
441
  colorScheme: colorScheme,
433
442
  decorationType: 'widget',
@@ -12,6 +12,16 @@ export var DecorationFamily = {
12
12
  anchor: 'anchor',
13
13
  contributorTag: 'contributor-tag'
14
14
  };
15
+
16
+ /**
17
+ * Navigation measures the target table header and writes this variable on the
18
+ * editor root immediately before scrolling. Diff decorations inherit it, so
19
+ * native scrolling leaves room for the header without DOM mutation on the
20
+ * ProseMirror-rendered suggestion.
21
+ */
22
+ export var SCROLL_TARGET_MARGIN_CSS_PROPERTY = '--ak-editor-diff-additional-margin';
23
+ export var scrollMarginTopValue = "calc(".concat("var(--ds-space-400, 32px)", " + var(", SCROLL_TARGET_MARGIN_CSS_PROPERTY, ", 0px))");
24
+ export var scrollMarginTopStyle = "scroll-margin-top: ".concat(scrollMarginTopValue, ";");
15
25
  export var AnchorTypeKey = {
16
26
  from: 'from',
17
27
  to: 'to',
@@ -87,7 +87,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
87
87
  var newPluginState = currentPluginState;
88
88
  if (meta) {
89
89
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'REVEAL_COMPLETE') {
90
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1;
90
+ var _newPluginState$color, _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9, _newPluginState0, _newPluginState1, _newPluginState10;
91
91
  // REVEAL_COMPLETE repaints with the reveal dropped, so the decorations render their
92
92
  // ordinary resting style. Without it the reveal stays in state indefinitely and the
93
93
  // next unrelated repaint re-emits the hidden, zero-width highlight with no animation
@@ -107,23 +107,23 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
107
107
  state: newState,
108
108
  pluginState: newPluginState,
109
109
  nodeViewSerializer: nodeViewSerializer,
110
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
110
+ 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,
111
111
  intl: getIntl(),
112
112
  activeIndexPos: newPluginState.activeIndexPos,
113
113
  api: api,
114
114
  tagMountContext: tagMountContext
115
- }, isExtendedEnabled((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
116
- isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
117
- diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
118
- hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
119
- hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
120
- showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
121
- smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
122
- deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
123
- inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement,
115
+ }, isExtendedEnabled((_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType) ? {
116
+ isInverted: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.isInverted,
117
+ diffType: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.diffType,
118
+ hideDeletedDiffs: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideDeletedDiffs,
119
+ hideAddedDiffsUnderline: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.hideAddedDiffsUnderline,
120
+ showIndicators: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.showIndicators,
121
+ smartThresholds: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.smartThresholds,
122
+ deletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.deletedDiffPlacement,
123
+ inlineDeletedDiffPlacement: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.inlineDeletedDiffPlacement,
124
124
  // SHOW_DIFF only. The scroll-to-next recalculation further down deliberately
125
125
  // omits this so stepping through changes cannot replay the choreography.
126
- reveal: (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.reveal
126
+ reveal: (_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.reveal
127
127
  } : {})),
128
128
  contributorTags = _calculateDiffDecorat.contributorTags,
129
129
  decorations = _calculateDiffDecorat.decorations,
@@ -131,7 +131,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
131
131
  // Update the decorations and their ids
132
132
  newPluginState.decorations = decorations;
133
133
  newPluginState.contributorTags = contributorTags;
134
- if (isExtendedEnabled((_newPluginState1 = newPluginState) === null || _newPluginState1 === void 0 ? void 0 : _newPluginState1.diffType)) {
134
+ if (isExtendedEnabled((_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType)) {
135
135
  newPluginState.diffDescriptors = diffDescriptors;
136
136
  }
137
137
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -140,7 +140,9 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
140
140
  isDisplayingChanges: false,
141
141
  activeIndex: undefined,
142
142
  contributorTags: [],
143
- reveal: undefined
143
+ reveal: undefined,
144
+ // Per-call override — do not let it leak into the next, unrelated `showDiff` call.
145
+ colorScheme: undefined
144
146
  }, isExtendedEnabled(currentPluginState.diffType) ? {
145
147
  isInverted: false,
146
148
  diffType: getDefaultDiffType(),
@@ -149,11 +151,11 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
149
151
  diffDescriptors: []
150
152
  } : {});
151
153
  } 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') {
152
- var _newPluginState10;
154
+ var _newPluginState11;
153
155
  // Update the active index in plugin state and recalculate decorations
154
- var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState10 = newPluginState) === null || _newPluginState10 === void 0 ? void 0 : _newPluginState10.diffType);
156
+ var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState11 = newPluginState) === null || _newPluginState11 === void 0 ? void 0 : _newPluginState11.diffType);
155
157
  if (_decorations.length > 0) {
156
- var _currentPluginState$a;
158
+ var _currentPluginState$a, _newPluginState$color2, _newPluginState12;
157
159
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
158
160
  // This allows the UI to start with no selection and only highlight on first user interaction.
159
161
  var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : -1;
@@ -181,7 +183,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
181
183
  state: newState,
182
184
  pluginState: newPluginState,
183
185
  nodeViewSerializer: nodeViewSerializer,
184
- colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
186
+ 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,
185
187
  intl: getIntl(),
186
188
  activeIndexPos: newPluginState.activeIndexPos,
187
189
  api: api,
@@ -251,7 +253,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
251
253
  if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
252
254
  var _cancelPendingScrollT;
253
255
  (_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 || _cancelPendingScrollT();
254
- cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType));
256
+ cancelPendingScrollToDecoration = scrollToDecoration(view, getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType), undefined, api);
255
257
 
256
258
  // Reset the flag so we don't scroll again on subsequent updates
257
259
  view.dispatch(view.state.tr.setMeta(showDiffPluginKey, {
@@ -272,7 +274,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
272
274
  // avoid a circular dependency; expand picks up the meta if loaded (no-op if not).
273
275
  api === null || api === void 0 || api.core.actions.execute(toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
274
276
  }
275
- cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex);
277
+ cancelPendingScrollToDecoration = scrollToDecoration(view, scrollableDecorations, pluginState.activeIndex, api);
276
278
 
277
279
  // Stepping only scrolls — no focus moves and no content changes — so without this a
278
280
  // screen-reader user gets silence. Announced through the live region rather than by
@@ -1,5 +1,7 @@
1
- import { isDiffDecoration } from './decorations/decorationKeys';
2
-
1
+ import { tableMarginTop } from '@atlaskit/editor-common/styles';
2
+ import { getStickyHeaderHeight } from '@atlaskit/editor-common/table/get-sticky-header-height';
3
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
+ import { isDiffDecoration, SCROLL_TARGET_MARGIN_CSS_PROPERTY } from './decorations/decorationKeys';
3
5
  /**
4
6
  * Extra space above the scrolled-to element so it does not sit flush under the
5
7
  * viewport edge (helps with sticky table headers, toolbars, etc.).
@@ -10,6 +12,12 @@ import { isDiffDecoration } from './decorations/decorationKeys';
10
12
  * outer scroll or mis-identifies the active scroll container.
11
13
  */
12
14
  var SCROLL_TOP_MARGIN_PX = 100;
15
+ function updateScrollTargetMargin(view, targetPos, api) {
16
+ var _api$limitedMode;
17
+ 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);
18
+ var tableHeaderHeight = isLimitedModeEnabled ? undefined : getStickyHeaderHeight(view, targetPos);
19
+ view.dom.style.setProperty(SCROLL_TARGET_MARGIN_CSS_PROPERTY, "".concat(tableHeaderHeight ? tableHeaderHeight + tableMarginTop : 0, "px"));
20
+ }
13
21
 
14
22
  /**
15
23
  * Returns the resolved HTMLElement for a given DOM node, walking up to the
@@ -20,6 +28,13 @@ function scrollToSelection(node) {
20
28
  if (!(element instanceof HTMLElement)) {
21
29
  return;
22
30
  }
31
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
32
+ element.scrollIntoView({
33
+ behavior: 'smooth',
34
+ block: 'start'
35
+ });
36
+ return;
37
+ }
23
38
 
24
39
  // scroll-margin is included in scroll-into-view math; it does not change layout.
25
40
  var previousScrollMarginTop = element.style.scrollMarginTop;
@@ -42,6 +57,7 @@ function scrollToSelection(node) {
42
57
  */
43
58
  export var scrollToDecoration = function scrollToDecoration(view, decorations) {
44
59
  var activeIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
60
+ var api = arguments.length > 3 ? arguments[3] : undefined;
45
61
  var decoration = decorations[activeIndex];
46
62
  if (!decoration) {
47
63
  return function () {};
@@ -53,6 +69,9 @@ export var scrollToDecoration = function scrollToDecoration(view, decorations) {
53
69
  var target = isDiffDecoration(decoration) && decoration.spec.scrollTarget || decoration;
54
70
  var rafId = requestAnimationFrame(function () {
55
71
  rafId = null;
72
+ if (fg('platform_editor_ai_show_diff_patch_1')) {
73
+ updateScrollTargetMargin(view, target.from, api);
74
+ }
56
75
  if (isDiffDecoration(target) && target.spec.decorationType === 'widget') {
57
76
  var _target$type;
58
77
  // @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
  import "./IndicatorBar.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -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
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React from 'react';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
@@ -1 +1 @@
1
- export type { DeletedDiffPlacement, DeletedDiffWidget, DiffContributorProfile, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, RevealMode, RevealOptions, ShowDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
1
+ export type { ColorScheme, DeletedDiffPlacement, DeletedDiffWidget, DiffContributorProfile, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, RevealMode, RevealOptions, ShowDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
@@ -1,6 +1,6 @@
1
1
  import type { Change } from 'prosemirror-changeset';
2
2
  import type { DiffContributors, DiffStepAttribution, TagContributor } from '../../../showDiffPluginType';
3
- import { type AdsAccentColor, type ColorScheme, type PublicColorScheme } from './types';
3
+ import { type AdsAccentColor, type ColorScheme } from './types';
4
4
  export type DiffAttributionSpanData = DiffStepAttribution & {
5
5
  stepIndex: number;
6
6
  };
@@ -31,4 +31,4 @@ export declare const createAttributionColorMap: (stepAttributions: Array<DiffSte
31
31
  * back to the latest overlapping attributed step.
32
32
  */
33
33
  export declare const getAttributionKeyForChange: (change: Change, attributedChanges: Change[]) => string | undefined;
34
- export declare const getColorSchemeForChange: (change: Change, attributedChanges: Change[], attributionColors: Map<string, AdsAccentColor>, fallback: PublicColorScheme | undefined) => ColorScheme | undefined;
34
+ export declare const getColorSchemeForChange: (change: Change, attributedChanges: Change[], attributionColors: Map<string, AdsAccentColor>, fallback: ColorScheme | undefined) => ColorScheme | undefined;
@@ -10,6 +10,15 @@ export declare const DecorationFamily: {
10
10
  readonly anchor: 'anchor';
11
11
  readonly contributorTag: 'contributor-tag';
12
12
  };
13
+ /**
14
+ * Navigation measures the target table header and writes this variable on the
15
+ * editor root immediately before scrolling. Diff decorations inherit it, so
16
+ * native scrolling leaves room for the header without DOM mutation on the
17
+ * ProseMirror-rendered suggestion.
18
+ */
19
+ export declare const SCROLL_TARGET_MARGIN_CSS_PROPERTY = "--ak-editor-diff-additional-margin";
20
+ export declare const scrollMarginTopValue: string;
21
+ export declare const scrollMarginTopStyle: string;
13
22
  type DecorationFamilyValue = (typeof DecorationFamily)[keyof typeof DecorationFamily];
14
23
  type BaseDecorationSpec<TFamily extends DecorationFamilyValue> = {
15
24
  decorationFamily: TFamily;
@@ -6,7 +6,7 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
7
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
- import type { ContributorTagModel, DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, RevealOptions, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
9
+ import type { ColorScheme, ContributorTagModel, DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, RevealOptions, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
10
10
  import type { ResolvedDiffContributors } from './decorations/colorSchemes/attributions';
11
11
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
12
12
  export type ShowDiffPluginState = {
@@ -15,6 +15,12 @@ export type ShowDiffPluginState = {
15
15
  from: number;
16
16
  to: number;
17
17
  };
18
+ /**
19
+ * Per-call override, set via SHOW_DIFF meta. Falls back to the plugin's configured
20
+ * `DiffParams.colorScheme` (see `createPlugin`'s `config` argument) when unset, and persists
21
+ * across `SCROLL_TO_NEXT`/`SCROLL_TO_PREVIOUS` repaints of the same diff. Reset on HIDE_DIFF.
22
+ */
23
+ colorScheme?: ColorScheme;
18
24
  /** Set via SHOW_DIFF meta, after `normalizeShowDiffParams` has keyed the public list. */
19
25
  contributors?: ResolvedDiffContributors;
20
26
  /** Resolved per calculation, never set via meta. */
@@ -1,8 +1,12 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
3
+ import type { ShowDiffPlugin } from '../showDiffPluginType';
4
+ type PluginInjectionAPI = ExtractInjectionAPI<ShowDiffPlugin>;
2
5
  /**
3
6
  * Schedules scrolling to the decoration at the given index after the next frame. Defaults to the
4
7
  * first decoration when no index is provided.
5
8
  *
6
9
  * @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
7
10
  */
8
- export declare const scrollToDecoration: (view: EditorView, decorations: Decoration[], activeIndex?: number) => (() => void);
11
+ export declare const scrollToDecoration: (view: EditorView, decorations: Decoration[], activeIndex?: number, api?: PluginInjectionAPI) => (() => void);
12
+ export {};