@atlaskit/editor-plugin-show-diff 17.1.5 → 17.1.7

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 (40) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +12 -1
  3. package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +165 -32
  4. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +6 -2
  5. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +5 -2
  6. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +54 -15
  7. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +6 -2
  8. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +64 -13
  9. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +8 -3
  10. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
  11. package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +5 -3
  12. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +12 -1
  13. package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +131 -12
  14. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +6 -2
  15. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +5 -2
  16. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +54 -15
  17. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -2
  18. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +66 -16
  19. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +7 -0
  20. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
  21. package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +5 -3
  22. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +12 -1
  23. package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +165 -32
  24. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +6 -2
  25. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +5 -2
  26. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +54 -15
  27. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +6 -2
  28. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +67 -16
  29. package/dist/esm/pm-plugins/decorations/decorationKeys.js +8 -3
  30. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +8 -3
  31. package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +5 -3
  32. package/dist/types/pm-plugins/decorations/createAnchorDecorationWidgets.d.ts +14 -4
  33. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  34. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
  35. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +24 -6
  36. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  37. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
  38. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +3 -1
  39. package/dist/types/showDiffPluginType.d.ts +1 -0
  40. package/package.json +2 -2
@@ -6,10 +6,10 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
6
6
  import { isExtendedEnabled } from '../isExtendedEnabled';
7
7
  import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
8
8
  import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
9
- import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
9
+ import { clampAnchorPosIntoCell, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
10
10
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
11
- import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
12
- import { AnchorTypeKey, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
11
+ import { createContributorTagHost, resolveHoistedCodeBlockAnchor, unmountContributorTag } from './createContributorTagWidget';
12
+ import { AnchorTypeKey, buildContributorTagDecorationSpec, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
13
13
  import { absorbFirstChildMarginReset } from './utils/absorbFirstChildMarginReset';
14
14
  import { createDeletedLineBreakDecoration } from './utils/createDeletedLineBreakWidget';
15
15
  import { createMarginAbsorber } from './utils/createMarginAbsorber';
@@ -34,6 +34,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
34
34
  nodeViewSerializer = _ref.nodeViewSerializer,
35
35
  colorScheme = _ref.colorScheme,
36
36
  isInserted = _ref.isInserted,
37
+ leftAnchorId = _ref.leftAnchorId,
37
38
  diffType = _ref.diffType;
38
39
  // Collect the inner content position of each cell in the new document within
39
40
  // the change range. Whole-cell replacement preserves cell count/order, so the
@@ -90,6 +91,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
90
91
  colorScheme: colorScheme,
91
92
  decorationType: 'widget',
92
93
  diffId: crypto.randomUUID(),
94
+ leftAnchorId: leftAnchorId,
93
95
  isInserted: isInserted,
94
96
  diffType: diffType
95
97
  }, isExtendedEnabled(diffType) && {
@@ -115,6 +117,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
115
117
  activeIndexPos = _ref2.activeIndexPos,
116
118
  _ref2$isInserted = _ref2.isInserted,
117
119
  isInserted = _ref2$isInserted === void 0 ? false : _ref2$isInserted,
120
+ leftAnchorId = _ref2.leftAnchorId,
118
121
  _ref2$showContributor = _ref2.showContributorTags,
119
122
  showContributorTags = _ref2$showContributor === void 0 ? false : _ref2$showContributor,
120
123
  _ref2$showIndicators = _ref2.showIndicators,
@@ -178,6 +181,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
178
181
  nodeViewSerializer: nodeViewSerializer,
179
182
  colorScheme: colorScheme,
180
183
  isInserted: isInserted,
184
+ leftAnchorId: leftAnchorId,
181
185
  diffType: diffType
182
186
  });
183
187
  }
@@ -194,6 +198,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
194
198
  colorScheme: colorScheme,
195
199
  isActive: isActive,
196
200
  isInserted: isInserted,
201
+ leftAnchorId: leftAnchorId,
197
202
  diffType: diffType,
198
203
  intl: intl,
199
204
  // Needed for the row's own indicator anchor; this path returns before the
@@ -407,7 +412,13 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
407
412
  }
408
413
  }
409
414
  });
410
- var contributorTagAnchorName;
415
+
416
+ // A change inside a code block hoists its tag out of the block (EDITOR-9045).
417
+ var hoistedCodeBlockAnchor = canTagWidget ? resolveHoistedCodeBlockAnchor(newDoc, safeInsertPos, diffId) : undefined;
418
+ if (hoistedCodeBlockAnchor) {
419
+ decorations.push(hoistedCodeBlockAnchor.marker);
420
+ }
421
+ var contributorTagAnchorName = hoistedCodeBlockAnchor === null || hoistedCodeBlockAnchor === void 0 ? void 0 : hoistedCodeBlockAnchor.anchorName;
411
422
  if (!isInserted && deletedColumns !== null && deletedColumns !== void 0 && deletedColumns.length) {
412
423
  var table = dom.querySelector('table');
413
424
  var firstRow = table === null || table === void 0 ? void 0 : table.rows[0];
@@ -467,6 +478,13 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
467
478
  dom.style.setProperty('anchor-name', "--".concat(buildAnchorDecorationKey({
468
479
  diffId: diffId
469
480
  })));
481
+ // The tag built below only anchors via `anchor()` if `contributorTagAnchorName` is set; without
482
+ // it the tag falls back to a non-anchored position (EDITOR-9045).
483
+ if (fg('confluence_ncs_step_diffing_version_history')) {
484
+ contributorTagAnchorName !== null && contributorTagAnchorName !== void 0 ? contributorTagAnchorName : contributorTagAnchorName = buildAnchorDecorationKey({
485
+ diffId: diffId
486
+ });
487
+ }
470
488
  }
471
489
 
472
490
  // Taken down in the widget's `destroy` below: `dom` is rebuilt on every recalculation, so the tag
@@ -475,24 +493,56 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
475
493
  if (canTagWidget) {
476
494
  // Lets the contributor tag find the deleted content on hover.
477
495
  dom.setAttribute('data-diff-id', diffId);
478
-
479
- // Hosted at the start of the deleted run rather than on `dom` itself: `dom` is inline, so once
480
- // the deleted content wraps its box is the union of its line fragments.
481
- var tagHost = createContributorTagHost({
482
- anchorName: contributorTagAnchorName,
483
- diffId: diffId,
484
- mountContext: tagMountContext
485
- });
486
- if (tagHost) {
487
- dom.prepend(tagHost.host);
488
- tagMount = tagHost.mount;
496
+ if (hoistedCodeBlockAnchor) {
497
+ // Own widget just before the code block, anchored to the marker above, not `dom` (EDITOR-9045).
498
+ var hoistedTagMount;
499
+ decorations.push(Decoration.widget(clampAnchorPosIntoCell(newDoc, hoistedCodeBlockAnchor.codeBlockStart, 1), function () {
500
+ var _tagHost$host;
501
+ var tagHost = createContributorTagHost({
502
+ anchorName: contributorTagAnchorName,
503
+ diffId: diffId,
504
+ mountContext: tagMountContext
505
+ });
506
+ hoistedTagMount = tagHost === null || tagHost === void 0 ? void 0 : tagHost.mount;
507
+ return (_tagHost$host = tagHost === null || tagHost === void 0 ? void 0 : tagHost.host) !== null && _tagHost$host !== void 0 ? _tagHost$host : document.createElement('span');
508
+ }, _objectSpread(_objectSpread({}, buildContributorTagDecorationSpec(diffId)), {}, {
509
+ side: 1,
510
+ marks: [],
511
+ ignoreSelection: true,
512
+ stopEvent: function stopEvent() {
513
+ return true;
514
+ },
515
+ destroy: function destroy() {
516
+ unmountContributorTag(hoistedTagMount);
517
+ hoistedTagMount = undefined;
518
+ }
519
+ })));
520
+ } else {
521
+ // Hosted at the start of the deleted run rather than on `dom` itself: `dom` is inline, so once
522
+ // the deleted content wraps its box is the union of its line fragments.
523
+ var tagHost = createContributorTagHost({
524
+ anchorName: contributorTagAnchorName,
525
+ diffId: diffId,
526
+ mountContext: tagMountContext
527
+ });
528
+ if (tagHost) {
529
+ dom.prepend(tagHost.host);
530
+ tagMount = tagHost.mount;
531
+ }
489
532
  }
490
533
  }
491
534
  if (showIndicators && isExtendedEnabled(diffType)) {
492
535
  var leftAnchor = createLeftAnchorWidget({
493
536
  doc: newDoc,
494
537
  from: safeInsertPos,
495
- diffId: diffId
538
+ diffId: diffId,
539
+ leftAnchorId: leftAnchorId,
540
+ measureElement: fg('platform_editor_ai_show_diff_patch_2') ? dom : undefined,
541
+ sliceOverride: fg('platform_editor_ai_show_diff_patch_2') ? slice : undefined,
542
+ underlyingRange: fg('platform_editor_ai_show_diff_patch_2') ? {
543
+ from: change.fromB,
544
+ to: change.toB
545
+ } : undefined
496
546
  });
497
547
  if (leftAnchor) {
498
548
  decorations.push(leftAnchor);
@@ -503,6 +553,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
503
553
  colorScheme: colorScheme,
504
554
  decorationType: 'widget',
505
555
  diffId: diffId,
556
+ leftAnchorId: leftAnchorId,
506
557
  isActive: isActive,
507
558
  isInserted: isInserted,
508
559
  diffType: diffType
@@ -75,10 +75,11 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
75
75
  diffId = _ref3.diffId,
76
76
  isActive = _ref3.isActive,
77
77
  isInserted = _ref3.isInserted,
78
+ leftAnchorId = _ref3.leftAnchorId,
78
79
  nodeName = _ref3.nodeName,
79
80
  side = _ref3.side,
80
81
  diffType = _ref3.diffType;
81
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
82
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
82
83
  decorationFamily: DecorationFamily.diff,
83
84
  decorationType: decorationType,
84
85
  diffId: diffId,
@@ -94,6 +95,8 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
94
95
  isActive: isActive
95
96
  } : {}), isInserted !== undefined ? {
96
97
  isInserted: isInserted
98
+ } : {}), leftAnchorId ? {
99
+ leftAnchorId: leftAnchorId
97
100
  } : {}), colorScheme ? {
98
101
  colorScheme: colorScheme
99
102
  } : {}), nodeName ? {
@@ -150,11 +153,13 @@ export var isDiffDecoration = function isDiffDecoration(decoration) {
150
153
  export var extractDiffDescriptors = function extractDiffDescriptors(decorations) {
151
154
  return decorations.find(undefined, undefined, isDiffDecorationSpec).filter(isDiffDecoration).map(function (_ref5) {
152
155
  var spec = _ref5.spec;
153
- return _objectSpread(_objectSpread(_objectSpread({}, spec.colorScheme ? {
156
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, spec.colorScheme ? {
154
157
  colorScheme: spec.colorScheme
155
158
  } : {}), {}, {
156
159
  id: spec.diffId
157
- }, spec.isInserted !== undefined ? {
160
+ }, spec.leftAnchorId ? {
161
+ leftAnchorId: spec.leftAnchorId
162
+ } : {}), spec.isInserted !== undefined ? {
158
163
  isInserted: spec.isInserted
159
164
  } : {}), {}, {
160
165
  type: spec.decorationType
@@ -48,10 +48,15 @@ var getChangedContentStyleNext = function getChangedContentStyleNext(colorScheme
48
48
  if (isExtendedEnabled(diffType) && isInserted) {
49
49
  return buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderline);
50
50
  }
51
- if (isActive) {
52
- return buildDeletedInlineContentStyle(colors, 'active');
51
+ var base = buildDeletedInlineContentStyle(colors, isActive ? 'active' : expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'new' : 'default');
52
+
53
+ // Text-like blocks (heading, lists, blockquote) render their deleted content through this
54
+ // getter rather than `getDeletedContentStyle`, so without this they never receive the
55
+ // glyphTint background + underline that plain deleted text already gets.
56
+ if (fg('confluence_ncs_step_diffing_version_history') && colors.deletedInlineTreatment === 'glyphTint' && isExtendedEnabled(diffType)) {
57
+ return base + buildDeletedInlineContentStyleExtended(colors, isActive);
53
58
  }
54
- return buildDeletedInlineContentStyle(colors, expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'new' : 'default');
59
+ return base;
55
60
  };
56
61
  var getChangedNodeStyleNext = function getChangedNodeStyleNext(nodeName, colorScheme) {
57
62
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -5,6 +5,8 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
5
5
  import { buildAnchorDecorationKey, AnchorTypeKey } from '../../pm-plugins/decorations/decorationKeys';
6
6
  import { IndicatorBar } from './IndicatorBar';
7
7
  var renderIndicatorBar = function renderIndicatorBar(descriptor) {
8
+ var _descriptor$leftAncho;
9
+ var leftAnchorId = (_descriptor$leftAncho = descriptor.leftAnchorId) !== null && _descriptor$leftAncho !== void 0 ? _descriptor$leftAncho : descriptor.id;
8
10
  switch (descriptor.type) {
9
11
  case 'inline':
10
12
  {
@@ -21,7 +23,7 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
21
23
  anchorType: AnchorTypeKey.to
22
24
  }),
23
25
  anchorLeft: buildAnchorDecorationKey({
24
- diffId: descriptor.id,
26
+ diffId: leftAnchorId,
25
27
  anchorType: AnchorTypeKey.left
26
28
  })
27
29
  });
@@ -41,7 +43,7 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
41
43
  anchorTop: blockAnchor,
42
44
  anchorBottom: blockAnchor,
43
45
  anchorLeft: buildAnchorDecorationKey({
44
- diffId: descriptor.id,
46
+ diffId: leftAnchorId,
45
47
  anchorType: AnchorTypeKey.left
46
48
  })
47
49
  });
@@ -59,7 +61,7 @@ var renderIndicatorBar = function renderIndicatorBar(descriptor) {
59
61
  diffId: descriptor.id
60
62
  }),
61
63
  anchorLeft: buildAnchorDecorationKey({
62
- diffId: descriptor.id,
64
+ diffId: leftAnchorId,
63
65
  anchorType: AnchorTypeKey.left
64
66
  }),
65
67
  anchorLeftFallback: buildAnchorDecorationKey({
@@ -1,4 +1,4 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  /**
4
4
  * Create a widget that marks the start of the doc margin.
@@ -16,10 +16,18 @@ export declare const createDocMarginAnchorWidget: () => Decoration;
16
16
  * doc margin so the `IndicatorBar` can align its left edge against it via CSS
17
17
  * anchor positioning. Shared by inline and node (widget) diff decorations.
18
18
  */
19
- export declare const createLeftAnchorWidget: ({ doc, from, diffId, }: {
19
+ export declare const createLeftAnchorWidget: ({ doc, from, to, diffId, leftAnchorId, measureElement, sliceOverride, underlyingRange, }: {
20
20
  diffId: string;
21
21
  doc: PMNode;
22
22
  from: number;
23
+ leftAnchorId?: string;
24
+ measureElement?: HTMLElement;
25
+ sliceOverride?: Slice;
26
+ to?: number;
27
+ underlyingRange?: {
28
+ from: number;
29
+ to: number;
30
+ };
23
31
  }) => Decoration | undefined;
24
32
  /**
25
33
  * Creates invisible anchor widgets for a single block-changed diff so that the
@@ -32,10 +40,11 @@ export declare const createLeftAnchorWidget: ({ doc, from, diffId, }: {
32
40
  * layout, expand) so the bar aligns within the container boundary.
33
41
  *
34
42
  */
35
- export declare const createBlockIndicatorAnchorWidgets: ({ doc, from, to, diffId, }: {
43
+ export declare const createBlockIndicatorAnchorWidgets: ({ doc, from, to, diffId, leftAnchorId, }: {
36
44
  diffId: string;
37
45
  doc: PMNode;
38
46
  from: number;
47
+ leftAnchorId?: string;
39
48
  to: number;
40
49
  }) => Decoration[];
41
50
  /**
@@ -56,9 +65,10 @@ export declare const createAnchorNameSpan: (anchorKey: string) => HTMLSpanElemen
56
65
  * Invisible `from`/`to` (and optional `left`) anchor widgets for one inline diff
57
66
  * range, so the `IndicatorBar` can align itself via CSS anchor positioning.
58
67
  */
59
- export declare const createInlineIndicatorAnchorWidgets: ({ doc, from, to, diffId, }: {
68
+ export declare const createInlineIndicatorAnchorWidgets: ({ doc, from, to, diffId, leftAnchorId, }: {
60
69
  diffId: string;
61
70
  doc: PMNode;
62
71
  from: number;
72
+ leftAnchorId?: string;
63
73
  to: number;
64
74
  }) => Decoration[];
@@ -11,7 +11,7 @@ import { type ContributorTagMountContext } from './createContributorTagWidget';
11
11
  * @param isActive Whether this node is part of the currently active/focused change
12
12
  * @returns Prosemirror node decoration or undefined
13
13
  */
14
- export declare const createBlockChangedDecoration: ({ attributionKey, change, colorScheme, isInserted, isActive, shouldHideDeleted, showContributorTags, showIndicators, doc, diffType, tagMountContext, }: {
14
+ export declare const createBlockChangedDecoration: ({ attributionKey, change, colorScheme, isInserted, isActive, leftAnchorId, shouldHideDeleted, showContributorTags, showIndicators, doc, diffType, tagMountContext, }: {
15
15
  attributionKey?: string;
16
16
  change: {
17
17
  from: number;
@@ -23,6 +23,7 @@ export declare const createBlockChangedDecoration: ({ attributionKey, change, co
23
23
  doc?: PMNode;
24
24
  isActive?: boolean;
25
25
  isInserted?: boolean;
26
+ leftAnchorId?: string;
26
27
  shouldHideDeleted?: boolean;
27
28
  showContributorTags?: boolean;
28
29
  showIndicators?: boolean;
@@ -10,7 +10,7 @@ type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
10
10
  /**
11
11
  * Main function to handle deleted rows - computes diff and creates decorations
12
12
  */
13
- export declare const createChangedRowDecorationWidgets: ({ attributionKey, changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isActive, isInserted, diffType, intl, showIndicators, showContributorTags, tagMountContext, }: {
13
+ export declare const createChangedRowDecorationWidgets: ({ attributionKey, changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isActive, isInserted, leftAnchorId, diffType, intl, showIndicators, showContributorTags, tagMountContext, }: {
14
14
  attributionKey?: string;
15
15
  changes: SimpleChange[];
16
16
  colorScheme?: ColorScheme;
@@ -18,6 +18,7 @@ export declare const createChangedRowDecorationWidgets: ({ attributionKey, chang
18
18
  intl?: IntlShape;
19
19
  isActive?: boolean;
20
20
  isInserted?: boolean;
21
+ leftAnchorId?: string;
21
22
  newDoc: PMNode;
22
23
  nodeViewSerializer: NodeViewSerializer;
23
24
  originalDoc: PMNode;
@@ -48,9 +48,27 @@ export declare const createContributorTagHost: ({ anchorName, diffId, mountConte
48
48
  mount: ContributorTagMount | undefined;
49
49
  } | undefined;
50
50
  /**
51
- * A widget hosting the contributor tag of one diff range, placed on the first visible character the
52
- * range highlights — or, with `anchorAtRangeStart`, at `from` itself. Either way a host that would
53
- * land inside a code block is hoisted out in front of it; see `resolveCodeBlockStart`.
51
+ * Position just before the code block enclosing `pos`, or `undefined` if there is none.
52
+ *
53
+ * Code blocks clip/scroll their own content, so a tag hosted inside one gets clipped away. Hoisting
54
+ * it before the block avoids that (EDITOR-9045, EDITOR-8766).
55
+ */
56
+ export declare const resolveCodeBlockStart: (doc: PMNode, pos: number) => number | undefined;
57
+ /**
58
+ * If `pos` is inside a code block: a marker decoration to anchor the hoisted tag against, plus the
59
+ * position just before the block to host that tag at (EDITOR-9045).
60
+ */
61
+ export declare const resolveHoistedCodeBlockAnchor: (doc: PMNode, pos: number, diffId: string) => {
62
+ anchorName: string;
63
+ codeBlockStart: number;
64
+ marker: Decoration;
65
+ } | undefined;
66
+ /**
67
+ * The contributor tag widget for one diff range, placed on the first visible character the range
68
+ * highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
69
+ * hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
70
+ *
71
+ * Returns one decoration normally, two (marker + tag) when hoisted out of a code block.
54
72
  *
55
73
  * The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
56
74
  * element ProseMirror drew it into — see `mountContributorTag`.
@@ -63,8 +81,8 @@ export declare const createContributorTagWidget: ({ anchorAtRangeStart, anchorNa
63
81
  anchorAtRangeStart?: boolean;
64
82
  /**
65
83
  * The `anchor-name` the block's own decoration carries, so the tag positions against that box
66
- * rather than against its host the block's margin and padding are then the browser's to
67
- * resolve, and the tag sits on the same corner for every node type (EDITOR-8933).
84
+ * rather than against its host (EDITOR-8933). Ignored inside a code block, which anchors to its
85
+ * own marker instead.
68
86
  */
69
87
  anchorName?: string;
70
88
  diffId: string;
@@ -72,4 +90,4 @@ export declare const createContributorTagWidget: ({ anchorAtRangeStart, anchorNa
72
90
  from: number;
73
91
  mountContext?: ContributorTagMountContext;
74
92
  to: number;
75
- }) => Decoration | undefined;
93
+ }) => Decoration[] | undefined;
@@ -14,7 +14,7 @@ export declare const getAtomicInlineChangedAttrs: (inlineNodeName: InlineAttrCha
14
14
  * @param change Changeset "change" containing information about the change content + range
15
15
  * @returns Prosemirror inline decoration
16
16
  */
17
- export declare const createInlineChangedDecoration: ({ attributionKey, change, colorScheme, isActive, isInserted, isAtomicInlineNode, shouldHideDeleted, showContributorTags, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, hasDeletedWidget, isDeletedWidgetBelow, reveal, tagMountContext, }: {
17
+ export declare const createInlineChangedDecoration: ({ attributionKey, change, colorScheme, isActive, isInserted, leftAnchorId, isAtomicInlineNode, shouldHideDeleted, showContributorTags, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, hasDeletedWidget, isDeletedWidgetBelow, reveal, tagMountContext, }: {
18
18
  attributionKey?: string;
19
19
  change: {
20
20
  fromB: number;
@@ -30,6 +30,7 @@ export declare const createInlineChangedDecoration: ({ attributionKey, change, c
30
30
  isAtomicInlineNode?: boolean;
31
31
  isDeletedWidgetBelow?: boolean;
32
32
  isInserted?: boolean;
33
+ leftAnchorId?: string;
33
34
  reveal?: RevealOptions;
34
35
  shouldHideDeleted?: boolean;
35
36
  showContributorTags?: boolean;
@@ -10,7 +10,7 @@ import { type ContributorTagMountContext } from './createContributorTagWidget';
10
10
  * This function is used to create a decoration widget to show content
11
11
  * that is not in the current document.
12
12
  */
13
- export declare const createNodeChangedDecorationWidget: ({ attributionKey, change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showContributorTags, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, reveal, tagMountContext, deletedColumns, }: {
13
+ export declare const createNodeChangedDecorationWidget: ({ attributionKey, change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, leftAnchorId, showContributorTags, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, reveal, tagMountContext, deletedColumns, }: {
14
14
  activeIndexPos?: {
15
15
  from: number;
16
16
  to: number;
@@ -24,6 +24,7 @@ export declare const createNodeChangedDecorationWidget: ({ attributionKey, chang
24
24
  hideAddedDiffsUnderline?: boolean;
25
25
  intl: IntlShape;
26
26
  isInserted?: boolean;
27
+ leftAnchorId?: string;
27
28
  newDoc: PMNode;
28
29
  nodeViewSerializer: NodeViewSerializer;
29
30
  placeBelow?: boolean;
@@ -40,6 +40,7 @@ export type DiffDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.diff
40
40
  * the inserted one.
41
41
  */
42
42
  isInserted?: boolean;
43
+ leftAnchorId?: string;
43
44
  nodeName?: string;
44
45
  /**
45
46
  * The decoration to scroll to, when it is not the one carrying this spec: the member of a merged
@@ -99,7 +100,7 @@ export declare const buildDiffDecorationKey: ({ decorationKeyPrefix, isActive, d
99
100
  diffType?: DiffType;
100
101
  isActive?: boolean;
101
102
  }) => string;
102
- export declare const buildDiffDecorationSpec: ({ attributionKey, colorScheme, decorationType, diffId, isActive, isInserted, nodeName, side, diffType, }: {
103
+ export declare const buildDiffDecorationSpec: ({ attributionKey, colorScheme, decorationType, diffId, isActive, isInserted, leftAnchorId, nodeName, side, diffType, }: {
103
104
  attributionKey?: string;
104
105
  colorScheme?: ColorScheme;
105
106
  decorationType: DiffDescriptor['type'];
@@ -107,6 +108,7 @@ export declare const buildDiffDecorationSpec: ({ attributionKey, colorScheme, de
107
108
  diffType?: DiffType;
108
109
  isActive?: boolean;
109
110
  isInserted?: boolean;
111
+ leftAnchorId?: string;
110
112
  nodeName?: string;
111
113
  side?: number;
112
114
  }) => DiffDecorationSpec;
@@ -120,6 +120,7 @@ export type DiffDescriptor = {
120
120
  colorScheme?: ColorScheme;
121
121
  id: string;
122
122
  isInserted?: boolean;
123
+ leftAnchorId?: string;
123
124
  type: 'inline' | 'block' | 'widget';
124
125
  };
125
126
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "17.1.5",
3
+ "version": "17.1.7",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -71,7 +71,7 @@
71
71
  "react-intl": "^7.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@atlaskit/editor-common": "^123.5.0",
74
+ "@atlaskit/editor-common": "^123.7.0",
75
75
  "react": "^18.2.0 || ^19.2.0",
76
76
  "react-dom": "^18.2.0 || ^19.2.0",
77
77
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"