@atlaskit/editor-plugin-show-diff 14.0.4 → 14.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 (56) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +172 -97
  3. package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +20 -9
  4. package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +89 -0
  5. package/dist/cjs/pm-plugins/calculateDiff/simplifySteps.js +81 -4
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +68 -0
  7. package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +26 -2
  8. package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +5 -1
  9. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +7 -2
  10. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +2 -2
  11. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
  12. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -10
  13. package/dist/cjs/pm-plugins/main.js +1 -0
  14. package/dist/cjs/showDiffPlugin.js +36 -14
  15. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +90 -19
  16. package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +17 -9
  17. package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +64 -0
  18. package/dist/es2019/pm-plugins/calculateDiff/simplifySteps.js +64 -1
  19. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +37 -0
  20. package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +19 -2
  21. package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +1 -0
  22. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +6 -3
  23. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
  24. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -3
  25. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +12 -9
  26. package/dist/es2019/pm-plugins/main.js +1 -0
  27. package/dist/es2019/showDiffPlugin.js +23 -1
  28. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +173 -98
  29. package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +20 -9
  30. package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +82 -0
  31. package/dist/esm/pm-plugins/calculateDiff/simplifySteps.js +79 -5
  32. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +61 -0
  33. package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +24 -1
  34. package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +1 -0
  35. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +8 -3
  36. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
  37. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
  38. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -9
  39. package/dist/esm/pm-plugins/main.js +1 -0
  40. package/dist/esm/showDiffPlugin.js +36 -14
  41. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  42. package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +2 -1
  43. package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +7 -0
  44. package/dist/types/pm-plugins/calculateDiff/simplifySteps.d.ts +10 -0
  45. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +12 -0
  46. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +5 -3
  47. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +6 -1
  48. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  49. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
  50. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  51. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
  52. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  53. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +2 -1
  54. package/dist/types/pm-plugins/main.d.ts +3 -1
  55. package/dist/types/showDiffPluginType.d.ts +29 -1
  56. package/package.json +3 -3
@@ -1,10 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ 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; }
6
+ 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; }
4
7
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
5
8
  import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
6
9
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
7
-
10
+ import { getAttributionKey } from '../decorations/colorSchemes/attributions';
8
11
  /**
9
12
  * Attempts to merge two consecutive ReplaceStep operations.
10
13
  * This merges steps where:
@@ -46,21 +49,67 @@ export function simplifySteps(steps, originalDoc) {
46
49
  return acc;
47
50
  }, []);
48
51
  }
52
+ var mergeAttributions = function mergeAttributions(first, second) {
53
+ var _second$wasOffline;
54
+ if (!first) {
55
+ return second;
56
+ }
57
+ if (!second) {
58
+ return first;
59
+ }
60
+ return _objectSpread(_objectSpread(_objectSpread({}, first), second), {}, {
61
+ wasOffline: first.wasOffline === true || second.wasOffline === true ? true : (_second$wasOffline = second.wasOffline) !== null && _second$wasOffline !== void 0 ? _second$wasOffline : first.wasOffline
62
+ });
63
+ };
64
+
65
+ /**
66
+ * Attribution-preserving variant of `simplifySteps`.
67
+ *
68
+ * Steps may only merge when they have the same effective actor identity. Keeping the attribution
69
+ * coupled to the step also ensures filtering a no-op/analytics step cannot shift array indexes.
70
+ */
71
+ export function simplifyStepsWithAttribution(steps, stepAttributions, originalDoc) {
72
+ var stepsToFilter = removeUnusedAttributedSteps(steps.map(function (step, index) {
73
+ return {
74
+ step: step,
75
+ stepAttribution: stepAttributions[index]
76
+ };
77
+ }), originalDoc);
78
+ return stepsToFilter.filter(function (_ref) {
79
+ var step = _ref.step;
80
+ return !(step instanceof AnalyticsStep);
81
+ }).reduce(function (acc, current) {
82
+ var _previous$step$merge, _previous$step$merge2, _previous$step;
83
+ var previous = acc[acc.length - 1];
84
+ var isSameIdentity = previous && getAttributionKey(previous.stepAttribution) === getAttributionKey(current.stepAttribution);
85
+ var merged = isSameIdentity ? (_previous$step$merge = (_previous$step$merge2 = (_previous$step = previous.step).merge) === null || _previous$step$merge2 === void 0 ? void 0 : _previous$step$merge2.call(_previous$step, current.step)) !== null && _previous$step$merge !== void 0 ? _previous$step$merge : mergeReplaceSteps(previous.step, current.step) : null;
86
+ if (merged) {
87
+ acc[acc.length - 1] = {
88
+ step: merged,
89
+ stepAttribution: mergeAttributions(previous.stepAttribution, current.stepAttribution)
90
+ };
91
+ } else {
92
+ acc.push(current);
93
+ }
94
+ return acc;
95
+ }, []);
96
+ }
49
97
 
50
98
  /**
51
99
  * Does a first pass to remove steps that don't impact the document
52
100
  */
53
- function removeUnusedSteps(steps, originalDoc) {
101
+ function removeUnusedAttributedSteps(stepsWithAttribution, originalDoc) {
54
102
  var finalSteps = [];
55
103
  var firstPassDoc = originalDoc;
56
- var _iterator = _createForOfIteratorHelper(steps),
104
+ var _iterator = _createForOfIteratorHelper(stepsWithAttribution),
57
105
  _step;
58
106
  try {
59
107
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
60
- var step = _step.value;
108
+ var stepWithAttribution = _step.value;
109
+ var step = stepWithAttribution.step;
61
110
  var result = step.apply(firstPassDoc);
62
111
  if (result.failed === null && result.doc && !areNodesEqualIgnoreAttrs(firstPassDoc, result.doc, ['localId'])) {
63
- finalSteps.push(step);
112
+ finalSteps.push(stepWithAttribution);
64
113
  firstPassDoc = result.doc;
65
114
  }
66
115
  }
@@ -70,4 +119,29 @@ function removeUnusedSteps(steps, originalDoc) {
70
119
  _iterator.f();
71
120
  }
72
121
  return finalSteps;
122
+ }
123
+
124
+ /**
125
+ * Does a first pass to remove steps that don't impact the document
126
+ */
127
+ function removeUnusedSteps(steps, originalDoc) {
128
+ var finalSteps = [];
129
+ var firstPassDoc = originalDoc;
130
+ var _iterator2 = _createForOfIteratorHelper(steps),
131
+ _step2;
132
+ try {
133
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
134
+ var step = _step2.value;
135
+ var result = step.apply(firstPassDoc);
136
+ if (result.failed === null && result.doc && !areNodesEqualIgnoreAttrs(firstPassDoc, result.doc, ['localId'])) {
137
+ finalSteps.push(step);
138
+ firstPassDoc = result.doc;
139
+ }
140
+ }
141
+ } catch (err) {
142
+ _iterator2.e(err);
143
+ } finally {
144
+ _iterator2.f();
145
+ }
146
+ return finalSteps;
73
147
  }
@@ -0,0 +1,61 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
+ var ATTRIBUTION_COLOR_PALETTE = ['purple', 'blue', 'teal', 'magenta', 'orange', 'green'];
6
+
7
+ /** `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared users. */
8
+ export var getAttributionKey = function getAttributionKey(attribution) {
9
+ var _attribution$userId, _attribution$agentId, _attribution$agentTyp;
10
+ var userId = attribution === null || attribution === void 0 || (_attribution$userId = attribution.userId) === null || _attribution$userId === void 0 ? void 0 : _attribution$userId.trim();
11
+ var agentId = attribution === null || attribution === void 0 || (_attribution$agentId = attribution.agentId) === null || _attribution$agentId === void 0 ? void 0 : _attribution$agentId.trim();
12
+ var agentType = attribution === null || attribution === void 0 || (_attribution$agentTyp = attribution.agentType) === null || _attribution$agentTyp === void 0 ? void 0 : _attribution$agentTyp.trim();
13
+ if (!userId && !agentId && !agentType) {
14
+ return undefined;
15
+ }
16
+ var agentIdentity = agentId || (agentType ? "type:".concat(agentType) : '');
17
+ return "user:".concat(userId !== null && userId !== void 0 ? userId : '', "|agent:").concat(agentIdentity);
18
+ };
19
+ export var areAttributionColorGatesEnabled = function areAttributionColorGatesEnabled() {
20
+ return fg('confluence_ncs_step_diffing_version_history') && isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor');
21
+ };
22
+ export var isAttributionColoringEnabled = function isAttributionColoringEnabled(stepAttributions) {
23
+ return areAttributionColorGatesEnabled() && (stepAttributions === null || stepAttributions === void 0 ? void 0 : stepAttributions.some(function (attribution) {
24
+ return getAttributionKey(attribution) !== undefined;
25
+ })) === true;
26
+ };
27
+ export var createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
28
+ var keys = Array.from(new Set(stepAttributions.map(getAttributionKey).filter(function (key) {
29
+ return key !== undefined;
30
+ }))).sort();
31
+ return new Map(keys.map(function (key, index) {
32
+ return [key, ATTRIBUTION_COLOR_PALETTE[index % ATTRIBUTION_COLOR_PALETTE.length]];
33
+ }));
34
+ };
35
+ var getLatestAttribution = function getLatestAttribution(changes) {
36
+ var data = changes.flatMap(function (change) {
37
+ return [].concat(_toConsumableArray(change.deleted), _toConsumableArray(change.inserted));
38
+ }).map(function (span) {
39
+ return span.data;
40
+ }).filter(function (value) {
41
+ return _typeof(value) === 'object' && value !== null && 'stepIndex' in value && typeof value.stepIndex === 'number';
42
+ });
43
+ return data.reduce(function (latest, attribution) {
44
+ return !latest || attribution.stepIndex > latest.stepIndex ? attribution : latest;
45
+ }, undefined);
46
+ };
47
+ var rangesOverlap = function rangesOverlap(fromA, toA, fromB, toB) {
48
+ return fromA < toB && fromB < toA;
49
+ };
50
+ var changesOverlap = function changesOverlap(change, attributedChange) {
51
+ var insertedOverlap = change.inserted.length > 0 && attributedChange.inserted.length > 0 && rangesOverlap(change.fromB, change.toB, attributedChange.fromB, attributedChange.toB);
52
+ var deletedOverlap = change.deleted.length > 0 && attributedChange.deleted.length > 0 && rangesOverlap(change.fromA, change.toA, attributedChange.fromA, attributedChange.toA);
53
+ return insertedOverlap || deletedOverlap;
54
+ };
55
+ export var getColorSchemeForChange = function getColorSchemeForChange(change, attributedChanges, attributionColors, fallback) {
56
+ var _attributionColors$ge;
57
+ var key = getAttributionKey(getLatestAttribution(attributedChanges.filter(function (attributedChange) {
58
+ return changesOverlap(change, attributedChange);
59
+ })));
60
+ return key ? (_attributionColors$ge = attributionColors.get(key)) !== null && _attributionColors$ge !== void 0 ? _attributionColors$ge : fallback : fallback;
61
+ };
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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; }
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; }
1
4
  /** Green insertions, red deletions. */
2
5
  export var traditionalScheme = {
3
6
  insertColor: 'green',
@@ -52,9 +55,29 @@ export var standardScheme = {
52
55
  deletedQuoteNodeActiveTone: 'borderAccent',
53
56
  strikesDeletedEmbedCard: false
54
57
  };
58
+ var createAttributionScheme = function createAttributionScheme(color) {
59
+ return _objectSpread(_objectSpread({}, standardScheme), {}, {
60
+ insertColor: color,
61
+ insertActiveColor: color,
62
+ deleteColor: color,
63
+ deleteActiveColor: color,
64
+ deletedCellColor: color
65
+ });
66
+ };
55
67
 
56
- /** Maps the public ColorScheme string to its data object. Adding a scheme = one entry here. */
68
+ /** Maps public schemes and attribution-only accents to their data objects. */
57
69
  export var colorSchemeRegistry = {
70
+ blue: createAttributionScheme('blue'),
71
+ green: createAttributionScheme('green'),
72
+ magenta: createAttributionScheme('magenta'),
73
+ orange: createAttributionScheme('orange'),
74
+ purple: createAttributionScheme('purple'),
75
+ teal: createAttributionScheme('teal'),
58
76
  traditional: traditionalScheme,
59
77
  standard: standardScheme
78
+ };
79
+
80
+ /** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
81
+ export var getLegacyColorScheme = function getLegacyColorScheme(colorScheme) {
82
+ return colorScheme === 'standard' || colorScheme === 'traditional' ? colorScheme : undefined;
60
83
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,14 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ 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
+ 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; }
2
5
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
9
  import { isExtendedEnabled } from '../isExtendedEnabled';
7
10
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
8
- import { colorSchemeRegistry } from './colorSchemes/schemes';
11
+ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
9
12
  import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
10
13
  import { buildDiffDecorationSpec } from './decorationKeys';
11
14
  import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
@@ -98,7 +101,9 @@ var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
98
101
  * same style strings for both shipped schemes; see EDITOR-8281.
99
102
  */
100
103
  var getBlockNodeStyle = function getBlockNodeStyle(props) {
101
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : getBlockNodeStyleLegacy(props);
104
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : getBlockNodeStyleLegacy(_objectSpread(_objectSpread({}, props), {}, {
105
+ colorScheme: getLegacyColorScheme(props.colorScheme)
106
+ }));
102
107
  };
103
108
 
104
109
  /**
@@ -172,7 +177,7 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
172
177
  var isEmptyCellBeingFilled = !isInserted && !!cellNode && isCellEmpty(cellNode);
173
178
  var useAddedStyle = isInserted || isEmptyCellBeingFilled;
174
179
  var cellOverlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? useAddedStyle ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
175
- colorScheme: colorScheme,
180
+ colorScheme: getLegacyColorScheme(colorScheme),
176
181
  isRoundedTable: isRoundedTable,
177
182
  useAddedStyle: useAddedStyle
178
183
  });
@@ -13,7 +13,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
13
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
14
  import { isExtendedEnabled } from '../isExtendedEnabled';
15
15
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildDeletedRowStyle } from './colorSchemes/factory';
16
- import { colorSchemeRegistry } from './colorSchemes/schemes';
16
+ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
17
17
  import { resolveCellOverlayStyleLegacy, resolveDeletedRowStyleLegacy } from './createChangedRowDecorationWidgets.styles.legacy';
18
18
  import { buildDiffDecorationSpec } from './decorationKeys';
19
19
  import { findSafeInsertPos } from './utils/findSafeInsertPos';
@@ -134,7 +134,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
134
134
 
135
135
  // Inserted rows keep their natural styling; the row strikethrough is deletions only.
136
136
  if (!isExtendedEnabled(diffType) || !isInserted) {
137
- tr.setAttribute('style', isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? buildDeletedRowStyle(colors) : resolveDeletedRowStyleLegacy(colorScheme));
137
+ tr.setAttribute('style', isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? buildDeletedRowStyle(colors) : resolveDeletedRowStyleLegacy(getLegacyColorScheme(colorScheme)));
138
138
  }
139
139
  tr.setAttribute('data-testid', 'show-diff-deleted-row');
140
140
 
@@ -150,7 +150,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
150
150
  var overlay = document.createElement('span');
151
151
  var isRoundedTable = expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
152
152
  var overlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? isInserted ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
153
- colorScheme: colorScheme,
153
+ colorScheme: getLegacyColorScheme(colorScheme),
154
154
  isInserted: isInserted,
155
155
  isRoundedTable: isRoundedTable
156
156
  });
@@ -7,7 +7,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
8
  import { isExtendedEnabled } from '../isExtendedEnabled';
9
9
  import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
10
- import { colorSchemeRegistry } from './colorSchemes/schemes';
10
+ import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
11
11
  import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
12
12
  import { getAtomicInlineNodeClassNameLegacy, resolveInlineChangedStyleLegacy } from './createInlineChangedDecoration.styles.legacy';
13
13
  import { buildDiffDecorationSpec } from './decorationKeys';
@@ -70,7 +70,9 @@ var resolveInlineChangedStyleRefactored = function resolveInlineChangedStyleRefa
70
70
  * verbatim pre-refactor per-scheme constants when it is off.
71
71
  */
72
72
  var resolveInlineChangedStyle = function resolveInlineChangedStyle(args) {
73
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : resolveInlineChangedStyleLegacy(args);
73
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : resolveInlineChangedStyleLegacy(_objectSpread(_objectSpread({}, args), {}, {
74
+ colorScheme: getLegacyColorScheme(args.colorScheme)
75
+ }));
74
76
  };
75
77
 
76
78
  /**
@@ -84,7 +86,7 @@ var resolveAtomicInlineAttrs = function resolveAtomicInlineAttrs(inlineNodeName,
84
86
  className: getAtomicInlineNodeClassName(inlineNodeName),
85
87
  styleSuffix: buildAtomicInlineChangedCSSVariables(colors)
86
88
  } : {
87
- className: getAtomicInlineNodeClassNameLegacy(inlineNodeName, colorScheme),
89
+ className: getAtomicInlineNodeClassNameLegacy(inlineNodeName, getLegacyColorScheme(colorScheme)),
88
90
  styleSuffix: ''
89
91
  };
90
92
  };
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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; }
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; }
1
4
  /**
2
5
  * Style resolution for the `wrapBlockNodeView` nodeview decorations.
3
6
  *
@@ -14,7 +17,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
14
17
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
18
  import { isExtendedEnabled } from '../../isExtendedEnabled';
16
19
  import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildAddedCellOverlayStyleNew, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildDeletedInlineContentStyle, buildDeletedInlineContentStyleExtended, buildDeletedLozengeActiveStyle, buildDeletedLozengeStyle, buildDeletedNodeCSSVariables, buildDeletedQuoteNodeWithLozengeStyle, buildDeletedStrikethroughLine, buildDeletedWrappedBlockOutline, buildInsertedBlockNodeStyle, buildInsertedInlineStyle, buildInsertStyleInBlockExtended, buildInsertStyleInBlockExtendedNoUnderline, buildInsertStyleNode } from '../colorSchemes/factory';
17
- import { colorSchemeRegistry, standardScheme } from '../colorSchemes/schemes';
20
+ import { colorSchemeRegistry, getLegacyColorScheme, standardScheme } from '../colorSchemes/schemes';
18
21
  import { getChangedContentStyleLegacy, getChangedNodeStyleLegacy, getDeletedContentStyleLegacy, getDeletedContentStyleUnboundedLegacy, getInsertedContentStyleLegacy, hasRestingDeletedRingLegacy, resolveCellOverlayStyleLegacy, resolveNestedInsertedNodeStyleLegacy, resolveRemovedLozengeStyleLegacy } from './wrapBlockNodeViewStyles.legacy';
19
22
  var DEFAULT_COLOR_SCHEME = 'standard';
20
23
  var getColorScheme = function getColorScheme(colorScheme) {
@@ -135,7 +138,7 @@ export var getChangedContentStyle = function getChangedContentStyle(colorScheme)
135
138
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
136
139
  var diffType = arguments.length > 3 ? arguments[3] : undefined;
137
140
  var hideAddedDiffsUnderline = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
138
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : getChangedContentStyleLegacy(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
141
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : getChangedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, isInserted, diffType, hideAddedDiffsUnderline);
139
142
  };
140
143
 
141
144
  /** Node-specific style for a changed block node, or `undefined` when the node type has none. */
@@ -144,27 +147,27 @@ export var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorSch
144
147
  var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
145
148
  var diffType = arguments.length > 4 ? arguments[4] : undefined;
146
149
  var hideAddedDiffsUnderline = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
147
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : getChangedNodeStyleLegacy(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
150
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : getChangedNodeStyleLegacy(nodeName, getLegacyColorScheme(colorScheme), isInserted, isActive, diffType, hideAddedDiffsUnderline);
148
151
  };
149
152
 
150
153
  /** The positioned line drawn across deleted content spanning an unbounded range. */
151
154
  export var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
152
155
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
153
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : getDeletedContentStyleUnboundedLegacy(colorScheme, isActive);
156
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : getDeletedContentStyleUnboundedLegacy(getLegacyColorScheme(colorScheme), isActive);
154
157
  };
155
158
 
156
159
  /** Inline style for inserted content. */
157
160
  export var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
158
161
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
159
162
  var hideAddedDiffsUnderline = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
160
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : getInsertedContentStyleLegacy(colorScheme, isActive, hideAddedDiffsUnderline);
163
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : getInsertedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, hideAddedDiffsUnderline);
161
164
  };
162
165
 
163
166
  /** Inline style for deleted content. */
164
167
  export var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
165
168
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
166
169
  var diffType = arguments.length > 2 ? arguments[2] : undefined;
167
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : getDeletedContentStyleLegacy(colorScheme, isActive, diffType);
170
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : getDeletedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, diffType);
168
171
  };
169
172
 
170
173
  /**
@@ -172,12 +175,14 @@ export var getDeletedContentStyle = function getDeletedContentStyle(colorScheme)
172
175
  * `querySelectorAll('td, th')` loop in `wrapBlockNodeView.ts` resolves it once.
173
176
  */
174
177
  export var resolveCellOverlayStyle = function resolveCellOverlayStyle(args) {
175
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : resolveCellOverlayStyleLegacy(args);
178
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : resolveCellOverlayStyleLegacy(_objectSpread(_objectSpread({}, args), {}, {
179
+ colorScheme: getLegacyColorScheme(args.colorScheme)
180
+ }));
176
181
  };
177
182
 
178
183
  /** Inner style for the "Removed" lozenge on a deleted block node. */
179
184
  export var resolveRemovedLozengeStyle = function resolveRemovedLozengeStyle(colorScheme, isActive) {
180
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : resolveRemovedLozengeStyleLegacy(colorScheme, isActive);
185
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : resolveRemovedLozengeStyleLegacy(getLegacyColorScheme(colorScheme), isActive);
181
186
  };
182
187
 
183
188
  /**
@@ -194,7 +199,7 @@ export var resolveNestedInsertedNodeStyle = function resolveNestedInsertedNodeSt
194
199
  * is what the `show-diff-deleted-outline-new` class styles in editor-core's smartCardStyles.
195
200
  */
196
201
  export var hasRestingDeletedRing = function hasRestingDeletedRing(colorScheme) {
197
- return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : hasRestingDeletedRingLegacy(colorScheme);
202
+ return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : hasRestingDeletedRingLegacy(getLegacyColorScheme(colorScheme));
198
203
  };
199
204
 
200
205
  /**
@@ -30,6 +30,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
30
30
  var defaultDiffType = getDefaultDiffType();
31
31
  return _objectSpread({
32
32
  steps: [],
33
+ stepAttributions: [],
33
34
  originalDoc: undefined,
34
35
  decorations: DecorationSet.empty,
35
36
  isDisplayingChanges: false
@@ -1,4 +1,6 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ var _excluded = ["stepsWithAttribution"];
2
4
  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; }
3
5
  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; }
4
6
  import React from 'react';
@@ -7,9 +9,28 @@ import { getDeletedWidgets as _getDeletedWidgets } from './pm-plugins/getDeleted
7
9
  import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
8
10
  import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
9
11
  import { IndicatorBarContentComponent } from './ui/IndicatorBar/IndicatorBarContentComponent';
10
- export var showDiffPlugin = function showDiffPlugin(_ref) {
11
- var api = _ref.api,
12
- config = _ref.config;
12
+ var normalizeShowDiffParams = function normalizeShowDiffParams(params) {
13
+ if (!params || !('stepsWithAttribution' in params)) {
14
+ return params ? _objectSpread(_objectSpread({}, params), {}, {
15
+ stepAttributions: []
16
+ }) : params;
17
+ }
18
+ var stepsWithAttribution = params.stepsWithAttribution,
19
+ rest = _objectWithoutProperties(params, _excluded);
20
+ return _objectSpread(_objectSpread({}, rest), {}, {
21
+ steps: stepsWithAttribution.map(function (_ref) {
22
+ var step = _ref.step;
23
+ return step;
24
+ }),
25
+ stepAttributions: stepsWithAttribution.map(function (_ref2) {
26
+ var stepAttribution = _ref2.stepAttribution;
27
+ return stepAttribution;
28
+ })
29
+ });
30
+ };
31
+ export var showDiffPlugin = function showDiffPlugin(_ref3) {
32
+ var api = _ref3.api,
33
+ config = _ref3.config;
13
34
  // Captured from the plugin's view lifecycle (see `createPlugin`) so read-only actions can access
14
35
  // the current state without exposing the plugin key to consumers.
15
36
  var editorView;
@@ -25,21 +46,21 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
25
46
  },
26
47
  commands: {
27
48
  showDiff: function showDiff(params) {
28
- return function (_ref2) {
29
- var tr = _ref2.tr;
49
+ return function (_ref4) {
50
+ var tr = _ref4.tr;
30
51
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
31
52
  var _api$userIntent;
32
53
  api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
33
54
  tr: tr
34
55
  });
35
56
  }
36
- return tr.setMeta(showDiffPluginKey, _objectSpread(_objectSpread({}, params), {}, {
57
+ return tr.setMeta(showDiffPluginKey, _objectSpread(_objectSpread({}, normalizeShowDiffParams(params)), {}, {
37
58
  action: 'SHOW_DIFF'
38
59
  }));
39
60
  };
40
61
  },
41
- hideDiff: function hideDiff(_ref3) {
42
- var tr = _ref3.tr;
62
+ hideDiff: function hideDiff(_ref5) {
63
+ var tr = _ref5.tr;
43
64
  if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
44
65
  var _api$userIntent2;
45
66
  api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
@@ -48,17 +69,18 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
48
69
  }
49
70
  return tr.setMeta(showDiffPluginKey, {
50
71
  steps: [],
72
+ stepAttributions: [],
51
73
  action: 'HIDE_DIFF'
52
74
  });
53
75
  },
54
- scrollToNext: function scrollToNext(_ref4) {
55
- var tr = _ref4.tr;
76
+ scrollToNext: function scrollToNext(_ref6) {
77
+ var tr = _ref6.tr;
56
78
  return tr.setMeta(showDiffPluginKey, {
57
79
  action: 'SCROLL_TO_NEXT'
58
80
  });
59
81
  },
60
- scrollToPrevious: function scrollToPrevious(_ref5) {
61
- var tr = _ref5.tr;
82
+ scrollToPrevious: function scrollToPrevious(_ref7) {
83
+ var tr = _ref7.tr;
62
84
  return tr.setMeta(showDiffPluginKey, {
63
85
  action: 'SCROLL_TO_PREVIOUS'
64
86
  });
@@ -67,8 +89,8 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
67
89
  pmPlugins: function pmPlugins() {
68
90
  return [{
69
91
  name: 'showDiffPlugin',
70
- plugin: function plugin(_ref6) {
71
- var getIntl = _ref6.getIntl;
92
+ plugin: function plugin(_ref8) {
93
+ var getIntl = _ref8.getIntl;
72
94
  return createPlugin(config, getIntl, api, setEditorView);
73
95
  }
74
96
  }];
@@ -1 +1 @@
1
- export type { DeletedDiffPlacement, DeletedDiffWidget, DiffParams, DiffType, PMDiffParams, ShowDiffPlugin, SmartDiffThresholds, } from '../showDiffPluginType';
1
+ export type { DeletedDiffPlacement, DeletedDiffWidget, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
@@ -1,4 +1,5 @@
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-override';
4
- export declare const diffBySteps: (originalDoc: PMNode, steps: Step[]) => Change[];
4
+ import type { DiffStepAttribution } from '../../showDiffPluginType';
5
+ export declare const diffBySteps: (originalDoc: PMNode, steps: Step[], stepAttributions?: Array<DiffStepAttribution | undefined>) => Change[];
@@ -0,0 +1,7 @@
1
+ import { type Change } from 'prosemirror-changeset';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ /**
4
+ * Simplifies and optimizes consecutive changes without crossing an attribution boundary.
5
+ * A change which already contains more than one identity is deliberately kept isolated.
6
+ */
7
+ export declare const simplifyChangesWithAttribution: (changes: readonly Change[], doc: PMNode) => Change[];
@@ -1,3 +1,13 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
3
+ import type { DiffStepAttribution, StepWithAttribution } from '../../showDiffPluginType';
4
+ type ProseMirrorStepWithAttribution = StepWithAttribution<ProseMirrorStep>;
3
5
  export declare function simplifySteps(steps: ProseMirrorStep[], originalDoc: PMNode): ProseMirrorStep[];
6
+ /**
7
+ * Attribution-preserving variant of `simplifySteps`.
8
+ *
9
+ * Steps may only merge when they have the same effective actor identity. Keeping the attribution
10
+ * coupled to the step also ensures filtering a no-op/analytics step cannot shift array indexes.
11
+ */
12
+ export declare function simplifyStepsWithAttribution(steps: ProseMirrorStep[], stepAttributions: Array<DiffStepAttribution | undefined>, originalDoc: PMNode): ProseMirrorStepWithAttribution[];
13
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { Change } from 'prosemirror-changeset';
2
+ import type { ColorScheme as PublicColorScheme, DiffStepAttribution } from '../../../showDiffPluginType';
3
+ import type { ColorScheme, DiffAccentColor } from './types';
4
+ export type DiffAttributionSpanData = DiffStepAttribution & {
5
+ stepIndex: number;
6
+ };
7
+ /** `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared users. */
8
+ export declare const getAttributionKey: (attribution: DiffStepAttribution | undefined) => string | undefined;
9
+ export declare const areAttributionColorGatesEnabled: () => boolean;
10
+ export declare const isAttributionColoringEnabled: (stepAttributions: Array<DiffStepAttribution | undefined> | undefined) => boolean;
11
+ export declare const createAttributionColorMap: (stepAttributions: Array<DiffStepAttribution | undefined>) => Map<string, DiffAccentColor>;
12
+ export declare const getColorSchemeForChange: (change: Change, attributedChanges: Change[], attributionColors: Map<string, DiffAccentColor>, fallback: PublicColorScheme | undefined) => ColorScheme | undefined;
@@ -1,8 +1,10 @@
1
- import type { ColorScheme } from '../../../showDiffPluginType';
2
- import type { DiffColorScheme } from './types';
1
+ import type { ColorScheme as PublicColorScheme } from '../../../showDiffPluginType';
2
+ import type { ColorScheme, DiffColorScheme } from './types';
3
3
  /** Green insertions, red deletions. */
4
4
  export declare const traditionalScheme: DiffColorScheme;
5
5
  /** Purple insertions, gray deletions (red on active). */
6
6
  export declare const standardScheme: DiffColorScheme;
7
- /** Maps the public ColorScheme string to its data object. Adding a scheme = one entry here. */
7
+ /** Maps public schemes and attribution-only accents to their data objects. */
8
8
  export declare const colorSchemeRegistry: Record<ColorScheme, DiffColorScheme>;
9
+ /** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
10
+ export declare const getLegacyColorScheme: (colorScheme: ColorScheme | undefined) => PublicColorScheme | undefined;
@@ -1,8 +1,13 @@
1
+ import type { ColorScheme as PublicColorScheme } from '../../../showDiffPluginType';
2
+ /** Attribution-only accents selected by the plugin, never by consumers. */
3
+ export type DiffAccentColor = 'blue' | 'green' | 'magenta' | 'orange' | 'purple' | 'teal';
4
+ /** A public scheme or an attribution accent resolved internally for one change. */
5
+ export type ColorScheme = PublicColorScheme | DiffAccentColor;
1
6
  /**
2
7
  * ADS accent colours for which every token path used by `factory.ts` exists. Closed set, so
3
8
  * interpolating a colour name into a token path is compile-time safe.
4
9
  */
5
- export type AdsAccentColor = 'green' | 'teal' | 'blue' | 'purple' | 'red' | 'orange' | 'yellow' | 'magenta' | 'gray';
10
+ export type AdsAccentColor = DiffAccentColor | 'red' | 'yellow' | 'gray';
6
11
  /**
7
12
  * A show-diff colour scheme. Colour fields are accent names that `factory.ts` expands into token
8
13
  * paths; the rest encode structural differences no colour can express. Ring widths, padding,
@@ -1,6 +1,7 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
- import type { ColorScheme, DiffType } from '../../showDiffPluginType';
3
+ import type { DiffType } from '../../showDiffPluginType';
4
+ import type { ColorScheme } from './colorSchemes/types';
4
5
  /**
5
6
  * Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
6
7
  *
@@ -1,8 +1,9 @@
1
1
  import type { Change } from 'prosemirror-changeset';
2
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
- import type { ColorScheme, DiffType } from '../../showDiffPluginType';
4
+ import type { DiffType } from '../../showDiffPluginType';
5
5
  import type { NodeViewSerializer } from '../NodeViewSerializer';
6
+ import type { ColorScheme } from './colorSchemes/types';
6
7
  type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
7
8
  /**
8
9
  * Main function to handle deleted rows - computes diff and creates decorations
@@ -1,6 +1,7 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
- import type { ColorScheme, DiffType } from '../../showDiffPluginType';
3
+ import type { DiffType } from '../../showDiffPluginType';
4
+ import type { ColorScheme } from './colorSchemes/types';
4
5
  import type { InlineAttrChangeNodeName } from './utils/getAttrChangeRanges';
5
6
  /**
6
7
  * Inline decoration used for insertions as the content already exists in the document