@atlaskit/editor-plugin-show-diff 10.1.9 → 10.1.11

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 (20) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +118 -31
  3. package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +131 -11
  4. package/dist/cjs/pm-plugins/decorations/createGranularBlockReferenceWidget.js +125 -0
  5. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +17 -103
  6. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +79 -1
  7. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +91 -7
  8. package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +112 -10
  9. package/dist/es2019/pm-plugins/decorations/createGranularBlockReferenceWidget.js +120 -0
  10. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +1 -81
  11. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +74 -2
  12. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -32
  13. package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +131 -10
  14. package/dist/esm/pm-plugins/decorations/createGranularBlockReferenceWidget.js +120 -0
  15. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -98
  16. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +79 -2
  17. package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +20 -0
  18. package/dist/types/pm-plugins/decorations/createGranularBlockReferenceWidget.d.ts +36 -0
  19. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
  20. package/package.json +10 -10
@@ -0,0 +1,120 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
3
+ import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
4
+ import { wrapBlockNodeView, injectInnerWrapper } from './utils/wrapBlockNodeView';
5
+
6
+ /**
7
+ * Creates a single block widget that renders a reference text block content
8
+ * beneath a granular diff set, for reference when deleted content is hidden.
9
+ *
10
+ * Since granular diffing only applies to singular isTextBlock=true nodes, this
11
+ * widget always renders exactly one block node and does not need the slice/fragment
12
+ * complexity of createNodeChangedDecorationWidget.
13
+ *
14
+ * Resolves which doc and positions to render based on isInverted:
15
+ * - !isInverted: renders originalDoc at A-side positions (what was there before)
16
+ * - isInverted: renders newDoc at B-side positions (the current/new content)
17
+ *
18
+ * The widget is always inserted at the B-side block boundary in newDoc since
19
+ * ProseMirror decorations are always anchored against the live (new) document.
20
+ */
21
+ export var createGranularBlockReferenceWidget = function createGranularBlockReferenceWidget(_ref) {
22
+ var change = _ref.change,
23
+ originalDoc = _ref.originalDoc,
24
+ newDoc = _ref.newDoc,
25
+ isInverted = _ref.isInverted,
26
+ nodeViewSerializer = _ref.nodeViewSerializer,
27
+ colorScheme = _ref.colorScheme,
28
+ intl = _ref.intl,
29
+ activeIndexPos = _ref.activeIndexPos,
30
+ diffId = _ref.diffId,
31
+ _ref$showIndicators = _ref.showIndicators,
32
+ showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators;
33
+ // Determine which doc and positions to use for rendering the reference block.
34
+ var renderDoc = isInverted ? newDoc : originalDoc;
35
+ var renderTo = isInverted ? change.toB : change.toA;
36
+
37
+ // The insertion point is always in newDoc — ProseMirror decorates against the live document.
38
+ // Walk up from toB to find the enclosing text block boundary for widget placement.
39
+ var insertResolvedPos = newDoc.resolve(change.toB);
40
+ var blockEnd = change.toB;
41
+ for (var depth = insertResolvedPos.depth; depth >= 0; depth--) {
42
+ var node = insertResolvedPos.node(depth);
43
+ if (node.isTextblock) {
44
+ blockEnd = insertResolvedPos.start(depth) + node.nodeSize - 1;
45
+ break;
46
+ }
47
+ }
48
+
49
+ // Find the block node to render from the render doc at the render positions.
50
+ var renderResolvedPos = renderDoc.resolve(renderTo);
51
+ var renderBlockNode = null;
52
+ for (var _depth = renderResolvedPos.depth; _depth >= 0; _depth--) {
53
+ var _node = renderResolvedPos.node(_depth);
54
+ if (_node.isTextblock) {
55
+ renderBlockNode = _node;
56
+ break;
57
+ }
58
+ }
59
+ if (!renderBlockNode) {
60
+ return [];
61
+ }
62
+ var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
63
+
64
+ /**
65
+ * This will always be a block node as it's a textBlock-like node.
66
+ * We use div instead of span so we can add margins.
67
+ */
68
+ var dom = document.createElement('div');
69
+ dom.setAttribute('data-testid', 'show-diff-granular-block-reference');
70
+ dom.style.setProperty('margin-top', "var(--ds-space-200, 16px)");
71
+ var nodeView = nodeViewSerializer.tryCreateNodeView(renderBlockNode);
72
+ if (nodeView) {
73
+ wrapBlockNodeView({
74
+ dom: dom,
75
+ nodeView: nodeView,
76
+ targetNode: renderBlockNode,
77
+ colorScheme: colorScheme,
78
+ intl: intl,
79
+ isActive: !!isActive,
80
+ isInserted: false
81
+ });
82
+ } else {
83
+ var serialized = nodeViewSerializer.serializeNode(renderBlockNode);
84
+ if (serialized && serialized instanceof HTMLElement) {
85
+ injectInnerWrapper({
86
+ node: serialized,
87
+ colorScheme: colorScheme,
88
+ isActive: !!isActive,
89
+ isInserted: false
90
+ });
91
+ dom.append(serialized);
92
+ } else if (serialized) {
93
+ dom.append(serialized);
94
+ }
95
+ }
96
+ if (dom.childNodes.length === 0) {
97
+ return [];
98
+ }
99
+ var decorations = [];
100
+ if (showIndicators) {
101
+ var leftAnchor = createLeftAnchorWidget({
102
+ doc: newDoc,
103
+ from: blockEnd,
104
+ diffId: diffId
105
+ });
106
+ dom.style.setProperty('anchor-name', "--".concat(buildAnchorDecorationKey({
107
+ diffId: diffId
108
+ })));
109
+ if (leftAnchor) {
110
+ decorations.push(leftAnchor);
111
+ }
112
+ }
113
+ decorations.push(Decoration.widget(blockEnd, dom, buildDiffDecorationSpec({
114
+ decorationType: 'widget',
115
+ diffId: diffId,
116
+ // We want it to be as close to the granular diff as possible
117
+ side: -999
118
+ })));
119
+ return decorations;
120
+ };
@@ -1,116 +1,31 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
- import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended } from './colorSchemes/standard';
9
- import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
10
6
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
11
7
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
12
8
  import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
13
9
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
14
- import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
15
- var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
16
- var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
17
- if (colorScheme === 'traditional' && isActive) {
18
- return deletedTraditionalContentStyleUnboundedActive;
19
- }
20
- return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
21
- };
22
- var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
23
- var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
24
- if (colorScheme === 'traditional') {
25
- if (isActive) {
26
- return traditionalInsertStyleActive;
27
- }
28
- return traditionalInsertStyle;
29
- }
30
- if (isActive) {
31
- return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? editingStyleActiveExtended : editingStyleActive;
32
- }
33
- return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? editingStyleExtended : editingStyle;
34
- };
35
- var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
36
- var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
37
- if (colorScheme === 'traditional') {
38
- return getDeletedTraditionalInlineStyle(isActive);
39
- }
40
- // Merge into existing styles when cleaning up
41
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
42
- if (isActive) {
43
- return deletedContentStyleActive + deletedInlineContentStyleExtended;
44
- }
45
- return deletedContentStyleNew + deletedInlineContentStyleExtended;
46
- }
47
- if (isActive) {
48
- return deletedContentStyleActive;
49
- }
50
- return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
51
- };
52
-
53
- /**
54
- * CSS backgrounds don't work when applied to a wrapper around a paragraph, so
55
- * the wrapper needs to be injected inside the node around the child content
56
- */
57
- var injectInnerWrapper = function injectInnerWrapper(_ref) {
58
- var node = _ref.node,
59
- colorScheme = _ref.colorScheme,
60
- isActive = _ref.isActive,
61
- isInserted = _ref.isInserted;
62
- var wrapper = document.createElement('span');
63
- wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
64
- _toConsumableArray(node.childNodes).forEach(function (child) {
65
- var removedChild = node.removeChild(child);
66
- wrapper.append(removedChild);
67
- });
68
- node.appendChild(wrapper);
69
- return node;
70
- };
71
- var createContentWrapper = function createContentWrapper(colorScheme) {
72
- var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
73
- var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
74
- var wrapper = document.createElement('span');
75
- var baseStyle = convertToInlineCss({
76
- position: 'relative',
77
- width: 'fit-content'
78
- });
79
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
80
- if (isInserted) {
81
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
82
- } else {
83
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
84
- var strikethrough = document.createElement('span');
85
- strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
86
- wrapper.append(strikethrough);
87
- }
88
- } else {
89
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
90
- var _strikethrough = document.createElement('span');
91
- _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
92
- wrapper.append(_strikethrough);
93
- }
94
- return wrapper;
95
- };
10
+ import { wrapBlockNodeView, injectInnerWrapper, createContentWrapper } from './utils/wrapBlockNodeView';
96
11
 
97
12
  /**
98
13
  * This function is used to create a decoration widget to show content
99
14
  * that is not in the current document.
100
15
  */
101
- export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
16
+ export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
102
17
  var _slice$content, _slice$content2, _slice$content3, _slice$content$firstC;
103
- var change = _ref2.change,
104
- doc = _ref2.doc,
105
- nodeViewSerializer = _ref2.nodeViewSerializer,
106
- colorScheme = _ref2.colorScheme,
107
- newDoc = _ref2.newDoc,
108
- intl = _ref2.intl,
109
- activeIndexPos = _ref2.activeIndexPos,
110
- _ref2$isInserted = _ref2.isInserted,
111
- isInserted = _ref2$isInserted === void 0 ? false : _ref2$isInserted,
112
- _ref2$showIndicators = _ref2.showIndicators,
113
- showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators;
18
+ var change = _ref.change,
19
+ doc = _ref.doc,
20
+ nodeViewSerializer = _ref.nodeViewSerializer,
21
+ colorScheme = _ref.colorScheme,
22
+ newDoc = _ref.newDoc,
23
+ intl = _ref.intl,
24
+ activeIndexPos = _ref.activeIndexPos,
25
+ _ref$isInserted = _ref.isInserted,
26
+ isInserted = _ref$isInserted === void 0 ? false : _ref$isInserted,
27
+ _ref$showIndicators = _ref.showIndicators,
28
+ showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators;
114
29
  var slice = doc.slice(change.fromA, change.toA);
115
30
  var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.childCount) === 1 && (slice === null || slice === void 0 || (_slice$content2 = slice.content) === null || _slice$content2 === void 0 || (_slice$content2 = _slice$content2.firstChild) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.type.name) === 'paragraph' && (slice === null || slice === void 0 || (_slice$content3 = slice.content) === null || _slice$content3 === void 0 || (_slice$content3 = _slice$content3.firstChild) === null || _slice$content3 === void 0 ? void 0 : _slice$content3.content.size) === 0;
116
31
  // Widget decoration used for deletions as the content is not in the document
@@ -1,9 +1,10 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
3
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
3
4
  import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
4
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
- import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
6
- import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
6
+ import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
7
+ import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
7
8
  var lozengeStyle = convertToInlineCss({
8
9
  display: 'inline-flex',
9
10
  boxSizing: 'border-box',
@@ -545,4 +546,80 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
545
546
  });
546
547
  }
547
548
  }
549
+ };
550
+ var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
551
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
552
+ if (colorScheme === 'traditional' && isActive) {
553
+ return deletedTraditionalContentStyleUnboundedActive;
554
+ }
555
+ return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
556
+ };
557
+ var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
558
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
559
+ if (colorScheme === 'traditional') {
560
+ return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
561
+ }
562
+ if (isActive) {
563
+ return editingStyleActiveExtended;
564
+ }
565
+ return editingStyleExtended;
566
+ };
567
+ var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
568
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
569
+ if (colorScheme === 'traditional') {
570
+ return getDeletedTraditionalInlineStyle(isActive);
571
+ }
572
+ if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
573
+ return (isActive ? deletedContentStyleActive : deletedContentStyleNew) + deletedInlineContentStyleExtended;
574
+ }
575
+ return isActive ? deletedContentStyleActive : deletedContentStyleNew;
576
+ };
577
+
578
+ /**
579
+ * Injects a styled inner wrapper span around the children of a block node element.
580
+ * CSS backgrounds don't work when applied to a wrapper around a paragraph, so
581
+ * the wrapper needs to be injected inside the node around the child content.
582
+ */
583
+ export var injectInnerWrapper = function injectInnerWrapper(_ref1) {
584
+ var node = _ref1.node,
585
+ colorScheme = _ref1.colorScheme,
586
+ isActive = _ref1.isActive,
587
+ isInserted = _ref1.isInserted;
588
+ var wrapper = document.createElement('span');
589
+ wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
590
+ _toConsumableArray(node.childNodes).forEach(function (child) {
591
+ var removedChild = node.removeChild(child);
592
+ wrapper.append(removedChild);
593
+ });
594
+ node.appendChild(wrapper);
595
+ return node;
596
+ };
597
+
598
+ /**
599
+ * Creates a styled span wrapper for inline content within a change decoration.
600
+ */
601
+ export var createContentWrapper = function createContentWrapper(colorScheme) {
602
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
603
+ var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
604
+ var wrapper = document.createElement('span');
605
+ var baseStyle = convertToInlineCss({
606
+ position: 'relative',
607
+ width: 'fit-content'
608
+ });
609
+ if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
610
+ if (isInserted) {
611
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
612
+ } else {
613
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
614
+ var strikethrough = document.createElement('span');
615
+ strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
616
+ wrapper.append(strikethrough);
617
+ }
618
+ } else {
619
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
620
+ var _strikethrough = document.createElement('span');
621
+ _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
622
+ wrapper.append(_strikethrough);
623
+ }
624
+ return wrapper;
548
625
  };
@@ -1,4 +1,24 @@
1
1
  import { type Change } from 'prosemirror-changeset';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { Step } from '@atlaskit/editor-prosemirror/transform';
4
+ type StepChanges = {
5
+ changes: Change[];
6
+ isGranular: boolean;
7
+ };
4
8
  export declare const diffBySteps: (originalDoc: PMNode, steps: Step[]) => Change[];
9
+ /**
10
+ * A fork of `diffBySteps` that returns changes grouped per step, rather than as a flat list.
11
+ *
12
+ * Why forked rather than refactoring `diffBySteps`:
13
+ * - `diffBySteps` returns a flat `Change[]` and is consumed by the existing decoration path.
14
+ * Changing its return shape would require threading per-step metadata through all callers,
15
+ * adding complexity to a stable code path.
16
+ * - The per-step grouping is only needed for the `platform_editor_diff_granular_extended` gate,
17
+ * where we need to know how many granular changes a single step produced in order to decide
18
+ * whether to suppress deleted decorations (threshold: > 3 granular changes per step).
19
+ * - Keeping the two functions separate means each has a clear, focused contract and neither
20
+ * accumulates the other's concerns. Shared logic (mapping helpers, `mergeOverlappingByNewDocRange`,
21
+ * `shouldCheckGranularDiff`, etc.) is already extracted and reused by both.
22
+ */
23
+ export declare const getStepChanges: (originalDoc: PMNode, steps: Step[]) => StepChanges[];
24
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import type { IntlShape } from 'react-intl';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
+ import type { ColorScheme } from '../../showDiffPluginType';
6
+ import type { NodeViewSerializer } from '../NodeViewSerializer';
7
+ /**
8
+ * Creates a single block widget that renders a reference text block content
9
+ * beneath a granular diff set, for reference when deleted content is hidden.
10
+ *
11
+ * Since granular diffing only applies to singular isTextBlock=true nodes, this
12
+ * widget always renders exactly one block node and does not need the slice/fragment
13
+ * complexity of createNodeChangedDecorationWidget.
14
+ *
15
+ * Resolves which doc and positions to render based on isInverted:
16
+ * - !isInverted: renders originalDoc at A-side positions (what was there before)
17
+ * - isInverted: renders newDoc at B-side positions (the current/new content)
18
+ *
19
+ * The widget is always inserted at the B-side block boundary in newDoc since
20
+ * ProseMirror decorations are always anchored against the live (new) document.
21
+ */
22
+ export declare const createGranularBlockReferenceWidget: ({ change, originalDoc, newDoc, isInverted, nodeViewSerializer, colorScheme, intl, activeIndexPos, diffId, showIndicators, }: {
23
+ activeIndexPos?: {
24
+ from: number;
25
+ to: number;
26
+ };
27
+ change: Change;
28
+ colorScheme?: ColorScheme;
29
+ diffId: string;
30
+ intl: IntlShape;
31
+ isInverted: boolean;
32
+ newDoc: PMNode;
33
+ nodeViewSerializer: NodeViewSerializer;
34
+ originalDoc: PMNode;
35
+ showIndicators?: boolean;
36
+ }) => Decoration[];
@@ -15,3 +15,18 @@ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorSchem
15
15
  nodeView: Node;
16
16
  targetNode: PMNode;
17
17
  }) => void;
18
+ /**
19
+ * Injects a styled inner wrapper span around the children of a block node element.
20
+ * CSS backgrounds don't work when applied to a wrapper around a paragraph, so
21
+ * the wrapper needs to be injected inside the node around the child content.
22
+ */
23
+ export declare const injectInnerWrapper: ({ node, colorScheme, isActive, isInserted, }: {
24
+ colorScheme?: ColorScheme;
25
+ isActive?: boolean;
26
+ isInserted?: boolean;
27
+ node: HTMLElement;
28
+ }) => HTMLElement;
29
+ /**
30
+ * Creates a styled span wrapper for inline content within a change decoration.
31
+ */
32
+ export declare const createContentWrapper: (colorScheme?: ColorScheme, isActive?: boolean, isInserted?: boolean) => HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "10.1.9",
3
+ "version": "10.1.11",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,8 +28,8 @@
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/editor-tables": "^3.0.0",
30
30
  "@atlaskit/platform-feature-flags": "^2.0.0",
31
- "@atlaskit/tmp-editor-statsig": "^114.0.0",
32
- "@atlaskit/tokens": "^15.0.0",
31
+ "@atlaskit/tmp-editor-statsig": "^114.5.0",
32
+ "@atlaskit/tokens": "^15.2.0",
33
33
  "@babel/runtime": "^7.0.0",
34
34
  "@compiled/react": "^0.20.0",
35
35
  "lodash": "^4.17.21",
@@ -38,14 +38,14 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@atlaskit/adf-utils": "^20.0.0",
41
- "@atlaskit/button": "^24.1.0",
41
+ "@atlaskit/button": "^24.3.0",
42
42
  "@atlaskit/css": "^1.0.0",
43
- "@atlaskit/editor-core": "^221.4.0",
43
+ "@atlaskit/editor-core": "^221.5.0",
44
44
  "@atlaskit/editor-json-transformer": "^9.0.0",
45
- "@atlaskit/form": "^16.0.0",
46
- "@atlaskit/primitives": "^20.0.0",
47
- "@atlaskit/section-message": "^9.1.0",
48
- "@atlaskit/textarea": "^9.0.0",
45
+ "@atlaskit/form": "^16.1.0",
46
+ "@atlaskit/primitives": "^20.2.0",
47
+ "@atlaskit/section-message": "^9.2.0",
48
+ "@atlaskit/textarea": "^9.1.0",
49
49
  "@atlassian/confluence-presets": "workspace:^",
50
50
  "@atlassian/content-reconciliation": "^0.1.3506",
51
51
  "@atlassian/structured-docs-types": "workspace:^",
@@ -53,7 +53,7 @@
53
53
  "react-intl": "^7.0.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^116.14.0",
56
+ "@atlaskit/editor-common": "^116.17.0",
57
57
  "react": "^18.2.0"
58
58
  },
59
59
  "techstack": {