@atlaskit/editor-plugin-show-diff 10.1.23 → 10.2.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 (65) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
  3. package/dist/cjs/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -2
  4. package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +841 -0
  5. package/dist/cjs/pm-plugins/calculateDiff/smart/helpers.js +135 -0
  6. package/dist/cjs/pm-plugins/calculateDiff/smart/segmentText.js +331 -0
  7. package/dist/cjs/pm-plugins/calculateDiff/smart/thresholds.js +46 -0
  8. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
  9. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
  10. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
  11. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
  12. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +8 -5
  13. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
  14. package/dist/cjs/pm-plugins/getScrollableDecorations.js +6 -6
  15. package/dist/cjs/pm-plugins/isExtendedEnabled.js +20 -0
  16. package/dist/cjs/pm-plugins/main.js +21 -16
  17. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -29
  18. package/dist/es2019/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
  19. package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +689 -0
  20. package/dist/es2019/pm-plugins/calculateDiff/smart/helpers.js +106 -0
  21. package/dist/es2019/pm-plugins/calculateDiff/smart/segmentText.js +283 -0
  22. package/dist/es2019/pm-plugins/calculateDiff/smart/thresholds.js +45 -0
  23. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
  24. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
  25. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
  26. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +31 -16
  27. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +9 -5
  28. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -34
  29. package/dist/es2019/pm-plugins/getScrollableDecorations.js +6 -6
  30. package/dist/es2019/pm-plugins/isExtendedEnabled.js +12 -0
  31. package/dist/es2019/pm-plugins/main.js +21 -16
  32. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
  33. package/dist/esm/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
  34. package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +834 -0
  35. package/dist/esm/pm-plugins/calculateDiff/smart/helpers.js +128 -0
  36. package/dist/esm/pm-plugins/calculateDiff/smart/segmentText.js +325 -0
  37. package/dist/esm/pm-plugins/calculateDiff/smart/thresholds.js +39 -0
  38. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
  39. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
  40. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
  41. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
  42. package/dist/esm/pm-plugins/decorations/decorationKeys.js +9 -5
  43. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
  44. package/dist/esm/pm-plugins/getScrollableDecorations.js +6 -6
  45. package/dist/esm/pm-plugins/isExtendedEnabled.js +14 -0
  46. package/dist/esm/pm-plugins/main.js +21 -16
  47. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  48. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +3 -1
  49. package/dist/types/pm-plugins/calculateDiff/groupChangesByBlock.d.ts +9 -0
  50. package/dist/types/pm-plugins/calculateDiff/smart/classifySmartChanges.d.ts +26 -0
  51. package/dist/types/pm-plugins/calculateDiff/smart/helpers.d.ts +44 -0
  52. package/dist/types/pm-plugins/calculateDiff/smart/segmentText.d.ts +32 -0
  53. package/dist/types/pm-plugins/calculateDiff/smart/thresholds.d.ts +44 -0
  54. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +3 -2
  55. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +3 -2
  56. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +3 -2
  57. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +4 -2
  58. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +5 -3
  59. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +6 -4
  60. package/dist/types/pm-plugins/getScrollableDecorations.d.ts +2 -1
  61. package/dist/types/pm-plugins/isExtendedEnabled.d.ts +11 -0
  62. package/dist/types/pm-plugins/main.d.ts +11 -1
  63. package/dist/types/showDiffPluginType.d.ts +20 -1
  64. package/docs/smart-diff-design.md +240 -0
  65. package/package.json +7 -2
@@ -9,7 +9,7 @@ import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document
9
9
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
11
11
  import { TableMap } from '@atlaskit/editor-tables/table-map';
12
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
+ import { isExtendedEnabled } from '../isExtendedEnabled';
13
13
  import { addedCellOverlayStyle, deletedRowStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
14
14
  import { deletedTraditionalRowStyle, deletedTraditionalCellOverlayStyle, traditionalAddedCellOverlayStyle } from './colorSchemes/traditional';
15
15
  import { buildDiffDecorationSpec } from './decorationKeys';
@@ -20,7 +20,8 @@ import { findSafeInsertPos } from './utils/findSafeInsertPos';
20
20
  var extractChangedRows = function extractChangedRows(_ref) {
21
21
  var change = _ref.change,
22
22
  originalDoc = _ref.originalDoc,
23
- newDoc = _ref.newDoc;
23
+ newDoc = _ref.newDoc,
24
+ diffType = _ref.diffType;
24
25
  var changedRows = [];
25
26
 
26
27
  // Find the table in the original document
@@ -60,7 +61,7 @@ var extractChangedRows = function extractChangedRows(_ref) {
60
61
 
61
62
  // Check if this row overlaps with the deletion range
62
63
  var rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
63
- if (rowOverlapsChange && rowNode.type.name === 'tableRow' && (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || !isEmptyRow(rowNode))) {
64
+ if (rowOverlapsChange && rowNode.type.name === 'tableRow' && (isExtendedEnabled(diffType) || !isEmptyRow(rowNode))) {
64
65
  var startOfRow = newTableMap.mapByRow.slice().reverse().find(function (row) {
65
66
  return row[0] + tableNew.pos < change.fromB && change.fromB < row[row.length - 1] + tableNew.pos;
66
67
  });
@@ -115,9 +116,9 @@ var isEmptyRow = function isEmptyRow(rowNode) {
115
116
  /**
116
117
  * Creates a DOM representation of a deleted table row
117
118
  */
118
- var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted) {
119
+ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted, diffType) {
119
120
  var tr = document.createElement('tr');
120
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
121
+ if (isExtendedEnabled(diffType)) {
121
122
  if (!isInserted) {
122
123
  tr.setAttribute('style', colorScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
123
124
  }
@@ -131,7 +132,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
131
132
  if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
132
133
  var nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
133
134
  if (nodeView) {
134
- if (nodeView instanceof HTMLElement && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
135
+ if (nodeView instanceof HTMLElement && isExtendedEnabled(diffType)) {
135
136
  var overlay = document.createElement('span');
136
137
  var overlayStyle = colorScheme === 'traditional' ? isInserted ? traditionalAddedCellOverlayStyle : deletedTraditionalCellOverlayStyle : isInserted ? addedCellOverlayStyle : deletedCellOverlayStyle;
137
138
  overlay.setAttribute('style', overlayStyle);
@@ -156,7 +157,8 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
156
157
  var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
157
158
  var changes = _ref2.changes,
158
159
  originalDoc = _ref2.originalDoc,
159
- newDoc = _ref2.newDoc;
160
+ newDoc = _ref2.newDoc,
161
+ diffType = _ref2.diffType;
160
162
  var rowInfo = [];
161
163
  var _iterator = _createForOfIteratorHelper(changes),
162
164
  _step;
@@ -167,7 +169,8 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
167
169
  var changedRows = extractChangedRows({
168
170
  change: change,
169
171
  originalDoc: originalDoc,
170
- newDoc: newDoc
172
+ newDoc: newDoc,
173
+ diffType: diffType
171
174
  });
172
175
  if (changedRows.length > 0) {
173
176
  rowInfo.push.apply(rowInfo, _toConsumableArray(changedRows));
@@ -191,17 +194,19 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
191
194
  nodeViewSerializer = _ref3.nodeViewSerializer,
192
195
  colorScheme = _ref3.colorScheme,
193
196
  _ref3$isInserted = _ref3.isInserted,
194
- isInserted = _ref3$isInserted === void 0 ? false : _ref3$isInserted;
197
+ isInserted = _ref3$isInserted === void 0 ? false : _ref3$isInserted,
198
+ diffType = _ref3.diffType;
195
199
  // First, expand the changes to include complete deleted rows
196
200
  var changedRows = expandDiffForChangedRows({
197
201
  changes: changes.filter(function (change) {
198
202
  return change.deleted.length > 0;
199
203
  }),
200
204
  originalDoc: originalDoc,
201
- newDoc: newDoc
205
+ newDoc: newDoc,
206
+ diffType: diffType
202
207
  });
203
208
  return changedRows.map(function (changedRow) {
204
- var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted);
209
+ var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted, diffType);
205
210
 
206
211
  // Find safe insertion position for the deleted row
207
212
  var safeInsertPos = findSafeInsertPos(newDoc, changedRow.fromB - 1,
@@ -211,7 +216,8 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
211
216
  return Decoration.widget(safeInsertPos, rowDOM, _objectSpread({}, buildDiffDecorationSpec({
212
217
  decorationType: 'widget',
213
218
  diffId: diffId,
214
- isActive: false
219
+ isActive: false,
220
+ diffType: diffType
215
221
  })));
216
222
  });
217
223
  };
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+ import { isExtendedEnabled } from '../isExtendedEnabled';
5
5
  import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedInlineContentStyleExtended } from './colorSchemes/standard';
6
6
  import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
7
7
  import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
@@ -27,7 +27,8 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
27
27
  shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete,
28
28
  _ref$showIndicators = _ref.showIndicators,
29
29
  showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
30
- doc = _ref.doc;
30
+ doc = _ref.doc,
31
+ diffType = _ref.diffType;
31
32
  var diffId = crypto.randomUUID();
32
33
  if (shouldHideDeleted) {
33
34
  return [Decoration.inline(change.fromB, change.toB, {
@@ -39,7 +40,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
39
40
  }))];
40
41
  }
41
42
  var style;
42
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
43
+ if (isExtendedEnabled(diffType)) {
43
44
  if (isInserted) {
44
45
  if (colorScheme === 'traditional') {
45
46
  style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
@@ -54,7 +55,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
54
55
  /**
55
56
  * Merge into existing styles when cleaning up
56
57
  */
57
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
58
+ if (isExtendedEnabled(diffType)) {
58
59
  style += deletedInlineContentStyleExtended;
59
60
  }
60
61
  }
@@ -74,7 +75,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
74
75
  diffId: diffId,
75
76
  isActive: isActive
76
77
  }))];
77
- if (showIndicators && doc && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
78
+ if (showIndicators && doc && isExtendedEnabled(diffType)) {
78
79
  decorations.push.apply(decorations, _toConsumableArray(createInlineIndicatorAnchorWidgets({
79
80
  doc: doc,
80
81
  from: change.fromB,
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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; }
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { isExtendedEnabled } from '../isExtendedEnabled';
6
6
  import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
7
7
  import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
8
8
  import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
@@ -25,12 +25,18 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
25
25
  _ref$isInserted = _ref.isInserted,
26
26
  isInserted = _ref$isInserted === void 0 ? false : _ref$isInserted,
27
27
  _ref$showIndicators = _ref.showIndicators,
28
- showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators;
28
+ showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
29
+ _ref$placeBelow = _ref.placeBelow,
30
+ placeBelow = _ref$placeBelow === void 0 ? false : _ref$placeBelow,
31
+ diffType = _ref.diffType;
29
32
  var slice = doc.slice(change.fromA, change.toA);
30
33
  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;
31
34
  // Widget decoration used for deletions as the content is not in the document
32
35
  // and we want to display the deleted content with a style.
33
- var safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
36
+ // For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
37
+ // node renders beneath its replacement; otherwise anchor at the start (change.fromB).
38
+ var anchorPos = placeBelow ? change.toB : change.fromB;
39
+ var safeInsertPos = findSafeInsertPos(newDoc, anchorPos, slice);
34
40
  var isActive = activeIndexPos && safeInsertPos === activeIndexPos.from && safeInsertPos === activeIndexPos.to;
35
41
  if (slice.content.content.length === 0 || shouldSkipDeletedEmptyParagraphDecoration) {
36
42
  return [];
@@ -55,7 +61,8 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
55
61
  newDoc: newDoc,
56
62
  nodeViewSerializer: nodeViewSerializer,
57
63
  colorScheme: colorScheme,
58
- isInserted: isInserted
64
+ isInserted: isInserted,
65
+ diffType: diffType
59
66
  });
60
67
  }
61
68
  var serializer = nodeViewSerializer;
@@ -68,7 +75,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
68
75
  // Observe DOM mutations and override the transform on .rich-media-item elements
69
76
  // after React mounts to prevent the image from shifting outside its parent container.
70
77
  var constrainMediaObserver;
71
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
78
+ if (isExtendedEnabled(diffType)) {
72
79
  constrainMediaObserver = new MutationObserver(function () {
73
80
  var richMediaItems = dom.querySelectorAll('.rich-media-item');
74
81
  richMediaItems.forEach(function (el) {
@@ -105,14 +112,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
105
112
  if (childNodeView) {
106
113
  var lineBreak = document.createElement('br');
107
114
  dom.append(lineBreak);
108
- var wrapper = createContentWrapper(colorScheme, isActive, isInserted);
115
+ var wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
109
116
  wrapper.append(childNodeView);
110
117
  dom.append(wrapper);
111
118
  } else {
112
119
  // Fallback to serializing the individual child node
113
120
  var serializedChild = serializer.serializeNode(childNode);
114
121
  if (serializedChild) {
115
- var _wrapper = createContentWrapper(colorScheme, isActive, isInserted);
122
+ var _wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
116
123
  _wrapper.append(serializedChild);
117
124
  dom.append(_wrapper);
118
125
  }
@@ -157,7 +164,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
157
164
  var nodeView = serializer.tryCreateNodeView(node);
158
165
  if (nodeView) {
159
166
  if (node.isInline) {
160
- var wrapper = createContentWrapper(colorScheme, isActive, isInserted);
167
+ var wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
161
168
  wrapper.append(nodeView);
162
169
  dom.append(wrapper);
163
170
  } else {
@@ -169,7 +176,8 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
169
176
  colorScheme: colorScheme,
170
177
  intl: intl,
171
178
  isActive: isActive,
172
- isInserted: isInserted
179
+ isInserted: isInserted,
180
+ diffType: diffType
173
181
  });
174
182
  }
175
183
  } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
@@ -183,11 +191,12 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
183
191
  node: fallbackNode,
184
192
  colorScheme: colorScheme,
185
193
  isActive: isActive,
186
- isInserted: isInserted
194
+ isInserted: isInserted,
195
+ diffType: diffType
187
196
  });
188
197
  dom.append(injectedNode);
189
198
  } else {
190
- var _wrapper2 = createContentWrapper(colorScheme, isActive, isInserted);
199
+ var _wrapper2 = createContentWrapper(colorScheme, isActive, isInserted, diffType);
191
200
  _wrapper2.append(fallbackNode);
192
201
  dom.append(_wrapper2);
193
202
  }
@@ -195,7 +204,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
195
204
  }
196
205
  });
197
206
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
198
- if (showIndicators && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
207
+ if (showIndicators && isExtendedEnabled(diffType)) {
199
208
  var leftAnchor = createLeftAnchorWidget({
200
209
  doc: newDoc,
201
210
  from: safeInsertPos,
@@ -211,9 +220,12 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
211
220
  decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread(_objectSpread({}, buildDiffDecorationSpec(_objectSpread({
212
221
  decorationType: 'widget',
213
222
  diffId: diffId,
214
- isActive: isActive
215
- }, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
216
- side: -1
223
+ isActive: isActive,
224
+ diffType: diffType
225
+ }, isExtendedEnabled(diffType) && {
226
+ // placeBelow anchors at the end of the new content, so render on the
227
+ // trailing side (1); otherwise render before the new content (-1).
228
+ side: placeBelow ? 1 : -1
217
229
  }))), {}, {
218
230
  destroy: function destroy() {
219
231
  var _constrainMediaObserv2;
@@ -236,14 +248,15 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
236
248
  var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
237
249
  var resolvedPos = newDoc.resolve(change.fromB);
238
250
  var isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
239
- if (isFirstDocChild && isSingleBlock && isPureDeletion && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
251
+ if (isFirstDocChild && isSingleBlock && isPureDeletion && isExtendedEnabled(diffType)) {
240
252
  var emptyWidgetSpan = document.createElement('span');
241
253
  emptyWidgetSpan.style.display = 'block';
242
254
  // Use a design token for the margin to keep spacing consistent with the design system
243
255
  emptyWidgetSpan.style.marginTop = "var(--ds-space-100, 8px)";
244
256
  var widget = Decoration.widget(safeInsertPos, emptyWidgetSpan, _objectSpread({}, buildDiffDecorationSpec({
245
257
  decorationType: 'widget',
246
- diffId: crypto.randomUUID()
258
+ diffId: crypto.randomUUID(),
259
+ diffType: diffType
247
260
  })));
248
261
  decorations.push(widget);
249
262
  }
@@ -2,7 +2,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
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
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; }
5
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { isExtendedEnabled } from '../isExtendedEnabled';
6
+
6
7
  /**
7
8
  * Decoration families produced by the show-diff plugin.
8
9
  * Each family owns its own key space and spec shape.
@@ -42,8 +43,9 @@ export var buildAnchorDecorationKey = function buildAnchorDecorationKey(_ref) {
42
43
  export var buildDiffDecorationKey = function buildDiffDecorationKey(_ref2) {
43
44
  var decorationKeyPrefix = _ref2.decorationKeyPrefix,
44
45
  isActive = _ref2.isActive,
45
- diffId = _ref2.diffId;
46
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
46
+ diffId = _ref2.diffId,
47
+ diffType = _ref2.diffType;
48
+ if (isExtendedEnabled(diffType)) {
47
49
  return "".concat(decorationKeyPrefix, "-").concat(diffId, "-").concat(isActive ? 'active' : 'inactive');
48
50
  }
49
51
  return isActive !== undefined ? "".concat(decorationKeyPrefix, "-").concat(isActive ? 'active' : 'inactive') : decorationKeyPrefix;
@@ -53,7 +55,8 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
53
55
  diffId = _ref3.diffId,
54
56
  isActive = _ref3.isActive,
55
57
  nodeName = _ref3.nodeName,
56
- side = _ref3.side;
58
+ side = _ref3.side,
59
+ diffType = _ref3.diffType;
57
60
  return _objectSpread(_objectSpread({
58
61
  decorationFamily: DecorationFamily.diff,
59
62
  decorationType: decorationType,
@@ -61,7 +64,8 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
61
64
  key: buildDiffDecorationKey({
62
65
  decorationKeyPrefix: DiffDecorationKey[decorationType],
63
66
  diffId: diffId,
64
- isActive: isActive
67
+ isActive: isActive,
68
+ diffType: diffType
65
69
  })
66
70
  }, nodeName ? {
67
71
  nodeName: nodeName
@@ -3,6 +3,7 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
3
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
4
4
  import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
+ import { isExtendedEnabled } from '../../isExtendedEnabled';
6
7
  import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
7
8
  import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
8
9
  var lozengeStyle = convertToInlineCss({
@@ -56,7 +57,8 @@ var lozengeStyleActiveTraditional = convertToInlineCss({
56
57
  var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
57
58
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
58
59
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
59
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
60
+ var diffType = arguments.length > 3 ? arguments[3] : undefined;
61
+ if (isExtendedEnabled(diffType) && isInserted) {
60
62
  if (colorScheme === 'traditional') {
61
63
  return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
62
64
  }
@@ -73,8 +75,9 @@ var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
73
75
  var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
74
76
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
75
77
  var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
78
+ var diffType = arguments.length > 4 ? arguments[4] : undefined;
76
79
  var isTraditional = colorScheme === 'traditional';
77
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
80
+ if (isExtendedEnabled(diffType) && isInserted) {
78
81
  if (isMultiContainerBlockNode(nodeName)) {
79
82
  return editingContentStyleInBlockExtended;
80
83
  }
@@ -223,11 +226,12 @@ var applyStylesToElement = function applyStylesToElement(_ref3) {
223
226
  targetNode = _ref3.targetNode,
224
227
  colorScheme = _ref3.colorScheme,
225
228
  isActive = _ref3.isActive,
226
- isInserted = _ref3.isInserted;
229
+ isInserted = _ref3.isInserted,
230
+ diffType = _ref3.diffType;
227
231
  var currentStyle = element.getAttribute('style') || '';
228
- var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
232
+ var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
229
233
  var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
230
- var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
234
+ var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
231
235
  element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
232
236
  };
233
237
  var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4) {
@@ -235,10 +239,11 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4
235
239
  targetNode = _ref4.targetNode,
236
240
  colorScheme = _ref4.colorScheme,
237
241
  isActive = _ref4.isActive,
238
- isInserted = _ref4.isInserted;
242
+ isInserted = _ref4.isInserted,
243
+ diffType = _ref4.diffType;
239
244
  var currentStyle = element.getAttribute('style') || '';
240
245
  var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
241
- var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
246
+ var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
242
247
  if (targetNode.type.name === 'decisionList') {
243
248
  element.querySelectorAll('li').forEach(function (listItem) {
244
249
  var currentListItemStyle = listItem.getAttribute('style') || '';
@@ -262,9 +267,14 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref5)
262
267
  targetNode = _ref5.targetNode,
263
268
  colorScheme = _ref5.colorScheme,
264
269
  isActive = _ref5.isActive,
265
- isInserted = _ref5.isInserted;
266
- getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
267
- var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
270
+ isInserted = _ref5.isInserted,
271
+ diffType = _ref5.diffType;
272
+ var currentStyle = element.getAttribute('style') || '';
273
+ var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType) || '';
274
+ if (nodeSpecificStyle) {
275
+ element.setAttribute('style', "".concat(currentStyle).concat(nodeSpecificStyle));
276
+ }
277
+ var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
268
278
  var walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
269
279
  var textNodesToWrap = [];
270
280
  var currentNode = walker.nextNode();
@@ -290,16 +300,17 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
290
300
  targetNode = _ref6.targetNode,
291
301
  colorScheme = _ref6.colorScheme,
292
302
  isActive = _ref6.isActive,
293
- isInserted = _ref6.isInserted;
303
+ isInserted = _ref6.isInserted,
304
+ diffType = _ref6.diffType;
294
305
  var contentWrapper = document.createElement('div');
295
306
  var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
296
- var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
307
+ var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType);
297
308
 
298
309
  // When the extended experiment is enabled and the content is inserted,
299
310
  // block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
300
311
  // should not also get the inline content style (borderBottom underline) on their container.
301
- var shouldSkipContentStyle = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted && nodeStyle !== undefined;
302
- var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
312
+ var shouldSkipContentStyle = isExtendedEnabled(diffType) && isInserted && nodeStyle !== undefined;
313
+ var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
303
314
  contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
304
315
  contentWrapper.append(nodeView);
305
316
  return contentWrapper;
@@ -413,10 +424,11 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
413
424
  _ref9$isActive = _ref9.isActive,
414
425
  isActive = _ref9$isActive === void 0 ? false : _ref9$isActive,
415
426
  _ref9$isInserted = _ref9.isInserted,
416
- isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted;
427
+ isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted,
428
+ diffType = _ref9.diffType;
417
429
  var blockWrapper = createBlockNodeWrapper();
418
430
  var targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
419
- if (shouldShowRemovedLozenge(targetNodeName) && (!expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || !isInserted)) {
431
+ if (shouldShowRemovedLozenge(targetNodeName) && (!isExtendedEnabled(diffType) || !isInserted)) {
420
432
  var lozenge = createRemovedLozenge(intl, isActive, colorScheme);
421
433
  if (handleEmbedCardWithLozenge({
422
434
  dom: dom,
@@ -445,7 +457,8 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
445
457
  targetNode: targetNode,
446
458
  colorScheme: colorScheme,
447
459
  isActive: isActive,
448
- isInserted: isInserted
460
+ isInserted: isInserted,
461
+ diffType: diffType
449
462
  });
450
463
  blockWrapper.append(contentWrapper);
451
464
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
@@ -478,8 +491,9 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
478
491
  _ref0$isActive = _ref0.isActive,
479
492
  isActive = _ref0$isActive === void 0 ? false : _ref0$isActive,
480
493
  _ref0$isInserted = _ref0.isInserted,
481
- isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted;
482
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
494
+ isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted,
495
+ diffType = _ref0.diffType;
496
+ if (isExtendedEnabled(diffType)) {
483
497
  if (nodeView instanceof HTMLElement) {
484
498
  if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
485
499
  applyMultiContainerLikeStyles({
@@ -487,7 +501,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
487
501
  targetNode: targetNode,
488
502
  colorScheme: colorScheme,
489
503
  isActive: isActive,
490
- isInserted: isInserted
504
+ isInserted: isInserted,
505
+ diffType: diffType
491
506
  });
492
507
  dom.append(nodeView);
493
508
  return;
@@ -498,7 +513,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
498
513
  targetNode: targetNode,
499
514
  colorScheme: colorScheme,
500
515
  isActive: isActive,
501
- isInserted: isInserted
516
+ isInserted: isInserted,
517
+ diffType: diffType
502
518
  });
503
519
  dom.append(nodeView);
504
520
  return;
@@ -520,7 +536,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
520
536
  colorScheme: colorScheme,
521
537
  intl: intl,
522
538
  isActive: isActive,
523
- isInserted: isInserted
539
+ isInserted: isInserted,
540
+ diffType: diffType
524
541
  });
525
542
  return;
526
543
  } else {
@@ -531,7 +548,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
531
548
  targetNode: targetNode,
532
549
  colorScheme: colorScheme,
533
550
  isActive: isActive,
534
- isInserted: isInserted
551
+ isInserted: isInserted,
552
+ diffType: diffType
535
553
  });
536
554
  dom.append(nodeView);
537
555
  } else {
@@ -542,7 +560,8 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref0) {
542
560
  colorScheme: colorScheme,
543
561
  intl: intl,
544
562
  isActive: isActive,
545
- isInserted: isInserted
563
+ isInserted: isInserted,
564
+ diffType: diffType
546
565
  });
547
566
  }
548
567
  }
@@ -566,10 +585,11 @@ var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
566
585
  };
567
586
  var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
568
587
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
588
+ var diffType = arguments.length > 2 ? arguments[2] : undefined;
569
589
  if (colorScheme === 'traditional') {
570
590
  return getDeletedTraditionalInlineStyle(isActive);
571
591
  }
572
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
592
+ if (isExtendedEnabled(diffType)) {
573
593
  return (isActive ? deletedContentStyleActive : deletedContentStyleNew) + deletedInlineContentStyleExtended;
574
594
  }
575
595
  return isActive ? deletedContentStyleActive : deletedContentStyleNew;
@@ -584,9 +604,10 @@ export var injectInnerWrapper = function injectInnerWrapper(_ref1) {
584
604
  var node = _ref1.node,
585
605
  colorScheme = _ref1.colorScheme,
586
606
  isActive = _ref1.isActive,
587
- isInserted = _ref1.isInserted;
607
+ isInserted = _ref1.isInserted,
608
+ diffType = _ref1.diffType;
588
609
  var wrapper = document.createElement('span');
589
- wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
610
+ wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive, diffType));
590
611
  _toConsumableArray(node.childNodes).forEach(function (child) {
591
612
  var removedChild = node.removeChild(child);
592
613
  wrapper.append(removedChild);
@@ -601,22 +622,23 @@ export var injectInnerWrapper = function injectInnerWrapper(_ref1) {
601
622
  export var createContentWrapper = function createContentWrapper(colorScheme) {
602
623
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
603
624
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
625
+ var diffType = arguments.length > 3 ? arguments[3] : undefined;
604
626
  var wrapper = document.createElement('span');
605
627
  var baseStyle = convertToInlineCss({
606
628
  position: 'relative',
607
629
  width: 'fit-content'
608
630
  });
609
- if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
631
+ if (isExtendedEnabled(diffType)) {
610
632
  if (isInserted) {
611
633
  wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
612
634
  } else {
613
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
635
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive, diffType)));
614
636
  var strikethrough = document.createElement('span');
615
637
  strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
616
638
  wrapper.append(strikethrough);
617
639
  }
618
640
  } else {
619
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
641
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive, diffType)));
620
642
  var _strikethrough = document.createElement('span');
621
643
  _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
622
644
  wrapper.append(_strikethrough);
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _typeof from "@babel/runtime/helpers/typeof";
3
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
3
  import { DiffDecorationKey, isDiffDecoration, isDiffDecorationSpec } from './decorations/decorationKeys';
4
+ import { isExtendedEnabled } from './isExtendedEnabled';
5
5
 
6
6
  /**
7
7
  * True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
@@ -62,24 +62,24 @@ function specHasDiffKeyPrefix(spec, keyPrefix) {
62
62
  * @param doc - Current document; when set, diff-inline ranges are validated against this doc
63
63
  * @returns Array of scrollable decorations, sorted and deduplicated
64
64
  */
65
- export var getScrollableDecorations = function getScrollableDecorations(set, doc) {
65
+ export var getScrollableDecorations = function getScrollableDecorations(set, doc, diffType) {
66
66
  if (!set) {
67
67
  return [];
68
68
  }
69
69
  var isBlockDecoration = function isBlockDecoration(decoration) {
70
70
  var _decoration$spec$key$, _decoration$spec;
71
- return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'block' : (_decoration$spec$key$ = (_decoration$spec = decoration.spec) === null || _decoration$spec === void 0 || (_decoration$spec = _decoration$spec.key) === null || _decoration$spec === void 0 ? void 0 : _decoration$spec.startsWith(DiffDecorationKey.block)) !== null && _decoration$spec$key$ !== void 0 ? _decoration$spec$key$ : false;
71
+ return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'block' : (_decoration$spec$key$ = (_decoration$spec = decoration.spec) === null || _decoration$spec === void 0 || (_decoration$spec = _decoration$spec.key) === null || _decoration$spec === void 0 ? void 0 : _decoration$spec.startsWith(DiffDecorationKey.block)) !== null && _decoration$spec$key$ !== void 0 ? _decoration$spec$key$ : false;
72
72
  };
73
73
  var isInlineDecoration = function isInlineDecoration(decoration) {
74
74
  var _decoration$spec$key$2, _decoration$spec2;
75
- return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'inline' : (_decoration$spec$key$2 = (_decoration$spec2 = decoration.spec) === null || _decoration$spec2 === void 0 || (_decoration$spec2 = _decoration$spec2.key) === null || _decoration$spec2 === void 0 ? void 0 : _decoration$spec2.startsWith(DiffDecorationKey.inline)) !== null && _decoration$spec$key$2 !== void 0 ? _decoration$spec$key$2 : false;
75
+ return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'inline' : (_decoration$spec$key$2 = (_decoration$spec2 = decoration.spec) === null || _decoration$spec2 === void 0 || (_decoration$spec2 = _decoration$spec2.key) === null || _decoration$spec2 === void 0 ? void 0 : _decoration$spec2.startsWith(DiffDecorationKey.inline)) !== null && _decoration$spec$key$2 !== void 0 ? _decoration$spec$key$2 : false;
76
76
  };
77
77
  var isWidgetDecoration = function isWidgetDecoration(decoration) {
78
78
  var _decoration$spec$key$3, _decoration$spec3;
79
- return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'widget' : (_decoration$spec$key$3 = (_decoration$spec3 = decoration.spec) === null || _decoration$spec3 === void 0 || (_decoration$spec3 = _decoration$spec3.key) === null || _decoration$spec3 === void 0 ? void 0 : _decoration$spec3.startsWith(DiffDecorationKey.widget)) !== null && _decoration$spec$key$3 !== void 0 ? _decoration$spec$key$3 : false;
79
+ return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'widget' : (_decoration$spec$key$3 = (_decoration$spec3 = decoration.spec) === null || _decoration$spec3 === void 0 || (_decoration$spec3 = _decoration$spec3.key) === null || _decoration$spec3 === void 0 ? void 0 : _decoration$spec3.startsWith(DiffDecorationKey.widget)) !== null && _decoration$spec$key$3 !== void 0 ? _decoration$spec$key$3 : false;
80
80
  };
81
81
  var seenBlockKeys = new Set();
82
- var allDecorations = expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? set.find(undefined, undefined, isDiffDecorationSpec) : set.find(undefined, undefined, function (spec) {
82
+ var allDecorations = isExtendedEnabled(diffType) ? set.find(undefined, undefined, isDiffDecorationSpec) : set.find(undefined, undefined, function (spec) {
83
83
  return specHasDiffKeyPrefix(spec, DiffDecorationKey.inline) || specHasDiffKeyPrefix(spec, DiffDecorationKey.widget) || specHasDiffKeyPrefix(spec, DiffDecorationKey.block);
84
84
  });
85
85
 
@@ -0,0 +1,14 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+ /**
4
+ * The "extended" diff pipeline is normally gated by `platform_editor_diff_plugin_extended`.
5
+ * The `smart` diff type REQUIRES the extended pipeline, so whenever `smart` is active (and its
6
+ * own gate `platform_editor_ai_smart_diff` is on) the extended pipeline is force-enabled,
7
+ * independent of the extended gate. For all other diff types the extended gate alone decides.
8
+ *
9
+ * Pass the active `diffType` so callers deep in the decoration layer render the extended shape
10
+ * when `smart` is active even if `platform_editor_diff_plugin_extended` is off.
11
+ */
12
+ export var isExtendedEnabled = function isExtendedEnabled(diffType) {
13
+ return expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || diffType === 'smart' && fg('platform_editor_ai_smart_diff');
14
+ };