@atlaskit/editor-plugin-show-diff 10.2.0 → 10.4.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 (36) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/calculate-diff/package.json +8 -0
  3. package/dist/cjs/entry-points/calculate-diff.js +12 -0
  4. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +14 -3
  5. package/dist/cjs/pm-plugins/calculateDiff/computeDiffChanges.js +112 -0
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +19 -1
  7. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
  8. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -2
  9. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +40 -21
  10. package/dist/cjs/pm-plugins/main.js +11 -7
  11. package/dist/es2019/entry-points/calculate-diff.js +2 -0
  12. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -3
  13. package/dist/es2019/pm-plugins/calculateDiff/computeDiffChanges.js +94 -0
  14. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  15. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +4 -3
  16. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +4 -2
  17. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +35 -25
  18. package/dist/es2019/pm-plugins/main.js +11 -7
  19. package/dist/esm/entry-points/calculate-diff.js +2 -0
  20. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +14 -3
  21. package/dist/esm/pm-plugins/calculateDiff/computeDiffChanges.js +107 -0
  22. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  23. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
  24. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -2
  25. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +41 -22
  26. package/dist/esm/pm-plugins/main.js +11 -7
  27. package/dist/types/entry-points/calculate-diff.d.ts +2 -0
  28. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
  29. package/dist/types/pm-plugins/calculateDiff/computeDiffChanges.d.ts +46 -0
  30. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +9 -0
  31. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  32. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
  33. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  34. package/dist/types/pm-plugins/main.d.ts +1 -0
  35. package/dist/types/showDiffPluginType.d.ts +12 -5
  36. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 10.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0f27159a9087b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0f27159a9087b) -
8
+ Add `hideAddedDiffsUnderline` option to the `showDiff` command to disable the dark-purple
9
+ underline on added/updated diff content while keeping the purple highlight. Only affects the
10
+ extended/`smart` inserted styles, is gated behind the `platform_editor_ai_smart_diff` feature
11
+ gate, and defaults to `false`.
12
+
13
+ ```ts
14
+ editorApi.showDiff.commands.showDiff({
15
+ steps,
16
+ originalDoc,
17
+ hideAddedDiffsUnderline: true,
18
+ });
19
+ ```
20
+
21
+ ## 10.3.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [`21147179a56ea`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21147179a56ea) -
26
+ [CCI-17809] Overhaul Post Stream Review segmenting.
27
+
28
+ `@atlaskit/editor-plugin-show-diff`: add a generic `computeDiffChanges` utility (new
29
+ `@atlaskit/editor-plugin-show-diff/calculate-diff` entry point) that returns the classified
30
+ `Change[]` and reconstructed new document for a given `originalDoc` + `steps`, without rendering
31
+ decorations. It reuses the same classifier the diff overlay renders from (default
32
+ `diffType: 'smart'`), so consumers can derive their own reviewable segments that line up with what
33
+ the overlay would draw. Exposes the `ComputeDiffChangesParams` type.
34
+
35
+ `@atlassian/editor-plugin-ai`: support two segmenting strategies in the Post Stream Review
36
+ step-through, selected by the new `platform_editor_ai_diff_based_segmenting` gate. Gate ON =
37
+ diff-based (`smart`) segmenting (via the show-diff `computeDiffChanges` utility, shaped into
38
+ reviewable segments in the AI plugin); gate OFF (default) = top-level-node segmenting, which no
39
+ longer splits a list into individual list items. Fine segments are now stored in plugin state and
40
+ remapped on every doc change, so per-segment undo/redo and view-changes stay correct after an
41
+ undo. Aggregate ("all changes") mode is unchanged.
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies
46
+
3
47
  ## 10.2.0
4
48
 
5
49
  ### Minor Changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-show-diff/calculate-diff",
3
+ "main": "../dist/cjs/entry-points/calculate-diff.js",
4
+ "module": "../dist/esm/entry-points/calculate-diff.js",
5
+ "module:es2019": "../dist/es2019/entry-points/calculate-diff.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/entry-points/calculate-diff.d.ts"
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "computeDiffChanges", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _computeDiffChanges.computeDiffChanges;
10
+ }
11
+ });
12
+ var _computeDiffChanges = require("../pm-plugins/calculateDiff/computeDiffChanges");
@@ -145,6 +145,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
145
145
  diffType = _ref3$diffType === void 0 ? 'inline' : _ref3$diffType,
146
146
  _ref3$hideDeletedDiff = _ref3.hideDeletedDiffs,
147
147
  hideDeletedDiffs = _ref3$hideDeletedDiff === void 0 ? false : _ref3$hideDeletedDiff,
148
+ _ref3$hideAddedDiffsU = _ref3.hideAddedDiffsUnderline,
149
+ hideAddedDiffsUnderlineParam = _ref3$hideAddedDiffsU === void 0 ? false : _ref3$hideAddedDiffsU,
148
150
  _ref3$showIndicators = _ref3.showIndicators,
149
151
  showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators,
150
152
  smartThresholds = _ref3.smartThresholds,
@@ -159,6 +161,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
159
161
  diffDescriptors: []
160
162
  };
161
163
  }
164
+
165
+ // Resolve the option against its gate once here, so every downstream inline/block builder
166
+ // receives the same value. When the gate is off the option is a no-op.
167
+ var hideAddedDiffsUnderline = hideAddedDiffsUnderlineParam && (0, _platformFeatureFlags.fg)('platform_editor_ai_smart_diff');
162
168
  var tr = state.tr;
163
169
  var steppedDoc = originalDoc;
164
170
  var attrSteps = [];
@@ -267,7 +273,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
267
273
  }, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
268
274
  isInserted: isInserted,
269
275
  shouldHideDeleted: shouldHideDeleted,
270
- showIndicators: showIndicators
276
+ showIndicators: showIndicators,
277
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
271
278
  }))));
272
279
  }
273
280
  } catch (err) {
@@ -285,7 +292,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
285
292
  }, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
286
293
  isInserted: isInserted,
287
294
  shouldHideDeleted: shouldHideDeleted,
288
- showIndicators: showIndicators
295
+ showIndicators: showIndicators,
296
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
289
297
  }))));
290
298
  }
291
299
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
@@ -317,6 +325,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
317
325
  }, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
318
326
  isInserted: !isInserted,
319
327
  diffType: diffType,
328
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline,
320
329
  // For `smart` node- and paragraph-level changes, optionally render the
321
330
  // deleted content below the new content (gray + strikethrough) instead
322
331
  // of above it. Controlled by `deletedDiffPlacement` (default `'top'`).
@@ -461,6 +470,7 @@ function (_ref5, _ref6) {
461
470
  isInverted = _ref7$.isInverted,
462
471
  diffType = _ref7$.diffType,
463
472
  hideDeletedDiffs = _ref7$.hideDeletedDiffs,
473
+ hideAddedDiffsUnderline = _ref7$.hideAddedDiffsUnderline,
464
474
  showIndicators = _ref7$.showIndicators,
465
475
  smartThresholds = _ref7$.smartThresholds,
466
476
  deletedDiffPlacement = _ref7$.deletedDiffPlacement;
@@ -474,13 +484,14 @@ function (_ref5, _ref6) {
474
484
  lastIsInverted = _ref8$.isInverted,
475
485
  lastDiffType = _ref8$.diffType,
476
486
  lastHideDeletedDiffs = _ref8$.hideDeletedDiffs,
487
+ lastHideAddedDiffsUnderline = _ref8$.hideAddedDiffsUnderline,
477
488
  lastShowIndicators = _ref8$.showIndicators,
478
489
  lastSmartThresholds = _ref8$.smartThresholds,
479
490
  lastDeletedDiffPlacement = _ref8$.deletedDiffPlacement;
480
491
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
481
492
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
482
493
  var _ref9;
483
- return (_ref9 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
494
+ return (_ref9 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement) !== null && _ref9 !== void 0 ? _ref9 : false;
484
495
  }
485
496
  return (_ref0 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref0 !== void 0 ? _ref0 : false;
486
497
  });
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.computeDiffChanges = void 0;
7
+ var _prosemirrorChangeset = require("prosemirror-changeset");
8
+ var _diffBySteps = require("./diffBySteps");
9
+ var _groupChangesByBlock = require("./groupChangesByBlock");
10
+ var _optimizeChanges = require("./optimizeChanges");
11
+ var _simplifySteps = require("./simplifySteps");
12
+ var _classifySmartChanges = require("./smart/classifySmartChanges");
13
+ 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; } } }; }
14
+ 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; } }
15
+ 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; } /**
16
+ * Generic, editor-state-free diff-change computation.
17
+ *
18
+ * Turns an `originalDoc` + forward `steps` into the classified `Change[]` for the
19
+ * requested `diffType`, plus the reconstructed new document — the same classifier
20
+ * the diff overlay uses (`calculateDiffDecorations` → `getChanges`), exposed as a
21
+ * reusable utility (e.g. to derive reviewable segments without rendering
22
+ * decorations). It runs the requested `diffType` DIRECTLY and does NOT apply the
23
+ * overlay's `platform_editor_ai_smart_diff` gate, so a `smart` result here can
24
+ * differ from what the overlay draws when that gate is off (the overlay falls back
25
+ * to inline); callers that need overlay parity must account for that gate.
26
+ *
27
+ * Pure: no `EditorState`, no transactions, no React. The new document is
28
+ * reconstructed by applying the (simplified) steps to `originalDoc`.
29
+ */
30
+ /**
31
+ * Apply the (simplified) steps to `originalDoc` to reconstruct the new doc, and
32
+ * compute the classified `Change[]` for the requested `diffType`. Mirrors the
33
+ * body of `calculateDiffDecorations` → `getChanges` so callers stay in lock-step
34
+ * with the rendered diff. Returns an empty change list (and `originalDoc` as the
35
+ * new doc) when there are no steps.
36
+ */
37
+ var computeDiffChanges = exports.computeDiffChanges = function computeDiffChanges(_ref) {
38
+ var originalDoc = _ref.originalDoc,
39
+ steps = _ref.steps,
40
+ _ref$diffType = _ref.diffType,
41
+ diffType = _ref$diffType === void 0 ? 'smart' : _ref$diffType,
42
+ _ref$locale = _ref.locale,
43
+ locale = _ref$locale === void 0 ? 'en' : _ref$locale,
44
+ smartThresholds = _ref.smartThresholds;
45
+ if (!steps || steps.length === 0) {
46
+ return {
47
+ changes: [],
48
+ newDoc: originalDoc
49
+ };
50
+ }
51
+ var simplifiedSteps = (0, _simplifySteps.simplifySteps)(steps, originalDoc);
52
+ var steppedDoc = originalDoc;
53
+ var stepMaps = [];
54
+ try {
55
+ var _iterator = _createForOfIteratorHelper(simplifiedSteps),
56
+ _step;
57
+ try {
58
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
+ var step = _step.value;
60
+ var result = step.apply(steppedDoc);
61
+ if (result.failed === null && result.doc) {
62
+ stepMaps.push(step.getMap());
63
+ steppedDoc = result.doc;
64
+ }
65
+ }
66
+ } catch (err) {
67
+ _iterator.e(err);
68
+ } finally {
69
+ _iterator.f();
70
+ }
71
+ } catch (_unused) {
72
+ // A step's positions fell outside the current doc — `ReplaceStep.apply`
73
+ // throws a RangeError (rather than returning a failed result) when a
74
+ // position exceeds the doc size. This can happen for pathological or
75
+ // inconsistent step sequences. Bail with no changes rather than letting the
76
+ // error propagate to the caller (which, for the PSR, would crash the
77
+ // toolbar); the consumer then falls back to its non-diff segmenting path.
78
+ return {
79
+ changes: [],
80
+ newDoc: originalDoc
81
+ };
82
+ }
83
+ var changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc).addSteps(steppedDoc, stepMaps, steppedDoc);
84
+ if (diffType === 'smart') {
85
+ return {
86
+ changes: (0, _classifySmartChanges.classifySmartChanges)({
87
+ changes: (0, _prosemirrorChangeset.simplifyChanges)(changeset.changes, steppedDoc),
88
+ originalDoc: originalDoc,
89
+ newDoc: steppedDoc,
90
+ locale: locale,
91
+ thresholds: smartThresholds
92
+ }),
93
+ newDoc: steppedDoc
94
+ };
95
+ }
96
+ if (diffType === 'block') {
97
+ return {
98
+ changes: (0, _groupChangesByBlock.groupChangesByBlock)(changeset.changes, originalDoc, steppedDoc),
99
+ newDoc: steppedDoc
100
+ };
101
+ }
102
+ if (diffType === 'step') {
103
+ return {
104
+ changes: (0, _diffBySteps.diffBySteps)(originalDoc, simplifiedSteps),
105
+ newDoc: steppedDoc
106
+ };
107
+ }
108
+ return {
109
+ changes: (0, _optimizeChanges.optimizeChanges)((0, _prosemirrorChangeset.simplifyChanges)(changeset.changes, steppedDoc)),
110
+ newDoc: steppedDoc
111
+ };
112
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.standardDecorationMarkerVariable = exports.editingStyleRuleNode = exports.editingStyleQuoteNode = exports.editingStyleNode = exports.editingStyleExtended = exports.editingStyleCardBlockNode = exports.editingStyleActiveExtended = exports.editingStyleActive = exports.editingStyle = exports.editingContentStyleInBlockExtended = exports.editingContentStyleInBlock = exports.deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedInlineContentStyleExtended = exports.deletedDecorationMarkerVariable = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = exports.deletedCellOverlayStyle = exports.deletedBlockOutlineRoundedActive = exports.deletedBlockOutlineRounded = exports.deletedBlockOutlineActive = exports.deletedBlockOutline = exports.addedCellOverlayStyle = void 0;
6
+ exports.standardDecorationMarkerVariable = exports.editingStyleRuleNode = exports.editingStyleQuoteNode = exports.editingStyleNode = exports.editingStyleExtendedNoUnderline = exports.editingStyleExtended = exports.editingStyleCardBlockNode = exports.editingStyleActiveExtendedNoUnderline = exports.editingStyleActiveExtended = exports.editingStyleActive = exports.editingStyle = exports.editingContentStyleInBlockExtendedNoUnderline = exports.editingContentStyleInBlockExtended = exports.editingContentStyleInBlock = exports.deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedInlineContentStyleExtended = exports.deletedDecorationMarkerVariable = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = exports.deletedCellOverlayStyle = exports.deletedBlockOutlineRoundedActive = exports.deletedBlockOutlineRounded = exports.deletedBlockOutlineActive = exports.deletedBlockOutline = exports.addedCellOverlayStyle = void 0;
7
7
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
8
8
  // delete on platform_editor_diff_plugin_extended cleanup
9
9
  var editingStyle = exports.editingStyle = (0, _lazyNodeView.convertToInlineCss)({
@@ -44,6 +44,24 @@ var editingStyleActiveExtended = exports.editingStyleActiveExtended = (0, _lazyN
44
44
  borderBottom: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
45
45
  padding: "1px 0 2px"
46
46
  });
47
+
48
+ /**
49
+ * Underline-free variants of the extended inserted-content styles. Used when the `showDiff`
50
+ * command is called with `hideAddedDiffsUnderline: true` to remove ONLY the dark-purple
51
+ * `borderBottom` underline from added/updated content while keeping the purple background
52
+ * highlight and padding. See the `editing*Extended` constants above for the full versions.
53
+ */
54
+ var editingStyleExtendedNoUnderline = exports.editingStyleExtendedNoUnderline = (0, _lazyNodeView.convertToInlineCss)({
55
+ background: "var(--ds-background-accent-purple-subtlest, #F8EEFE)",
56
+ padding: "1px 0 2px"
57
+ });
58
+ var editingStyleActiveExtendedNoUnderline = exports.editingStyleActiveExtendedNoUnderline = (0, _lazyNodeView.convertToInlineCss)({
59
+ background: "var(--ds-background-accent-purple-subtler-pressed, #D8A0F7)",
60
+ padding: "1px 0 2px"
61
+ });
62
+ var editingContentStyleInBlockExtendedNoUnderline = exports.editingContentStyleInBlockExtendedNoUnderline = (0, _lazyNodeView.convertToInlineCss)({
63
+ padding: "1px 0 2px"
64
+ });
47
65
  var deletedContentStyle = exports.deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
48
66
  color: "var(--ds-text-accent-gray, #505258)",
49
67
  textDecoration: 'line-through',
@@ -35,7 +35,9 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
35
35
  _ref$showIndicators = _ref.showIndicators,
36
36
  showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
37
37
  doc = _ref.doc,
38
- diffType = _ref.diffType;
38
+ diffType = _ref.diffType,
39
+ _ref$hideAddedDiffsUn = _ref.hideAddedDiffsUnderline,
40
+ hideAddedDiffsUnderline = _ref$hideAddedDiffsUn === void 0 ? false : _ref$hideAddedDiffsUn;
39
41
  var diffId = crypto.randomUUID();
40
42
  if (shouldHideDeleted) {
41
43
  return [_view.Decoration.inline(change.fromB, change.toB, {
@@ -52,7 +54,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
52
54
  if (colorScheme === 'traditional') {
53
55
  style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
54
56
  } else {
55
- style = isActive ? _standard.editingStyleActiveExtended : _standard.editingStyleExtended;
57
+ style = isActive ? hideAddedDiffsUnderline ? _standard.editingStyleActiveExtendedNoUnderline : _standard.editingStyleActiveExtended : hideAddedDiffsUnderline ? _standard.editingStyleExtendedNoUnderline : _standard.editingStyleExtended;
56
58
  }
57
59
  } else {
58
60
  if (colorScheme === 'traditional') {
@@ -34,7 +34,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
34
34
  showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
35
35
  _ref$placeBelow = _ref.placeBelow,
36
36
  placeBelow = _ref$placeBelow === void 0 ? false : _ref$placeBelow,
37
- diffType = _ref.diffType;
37
+ diffType = _ref.diffType,
38
+ _ref$hideAddedDiffsUn = _ref.hideAddedDiffsUnderline,
39
+ hideAddedDiffsUnderline = _ref$hideAddedDiffsUn === void 0 ? false : _ref$hideAddedDiffsUn;
38
40
  var slice = doc.slice(change.fromA, change.toA);
39
41
  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;
40
42
  // Widget decoration used for deletions as the content is not in the document
@@ -183,7 +185,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
183
185
  intl: intl,
184
186
  isActive: isActive,
185
187
  isInserted: isInserted,
186
- diffType: diffType
188
+ diffType: diffType,
189
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
187
190
  });
188
191
  }
189
192
  } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
@@ -65,11 +65,12 @@ var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
65
65
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
66
66
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
67
67
  var diffType = arguments.length > 3 ? arguments[3] : undefined;
68
+ var hideAddedDiffsUnderline = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
68
69
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted) {
69
70
  if (colorScheme === 'traditional') {
70
71
  return isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
71
72
  }
72
- return isActive ? _standard.editingStyleActiveExtended : _standard.editingStyleExtended;
73
+ return isActive ? hideAddedDiffsUnderline ? _standard.editingStyleActiveExtendedNoUnderline : _standard.editingStyleActiveExtended : hideAddedDiffsUnderline ? _standard.editingStyleExtendedNoUnderline : _standard.editingStyleExtended;
73
74
  }
74
75
  if (colorScheme === 'traditional') {
75
76
  return (0, _traditional.getDeletedTraditionalInlineStyle)(isActive);
@@ -83,10 +84,11 @@ var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
83
84
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
84
85
  var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
85
86
  var diffType = arguments.length > 4 ? arguments[4] : undefined;
87
+ var hideAddedDiffsUnderline = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
86
88
  var isTraditional = colorScheme === 'traditional';
87
89
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted) {
88
90
  if (isMultiContainerBlockNode(nodeName)) {
89
- return _standard.editingContentStyleInBlockExtended;
91
+ return hideAddedDiffsUnderline ? _standard.editingContentStyleInBlockExtendedNoUnderline : _standard.editingContentStyleInBlockExtended;
90
92
  }
91
93
  if (isTextLikeBlockNode(nodeName)) {
92
94
  return undefined;
@@ -234,11 +236,13 @@ var applyStylesToElement = function applyStylesToElement(_ref3) {
234
236
  colorScheme = _ref3.colorScheme,
235
237
  isActive = _ref3.isActive,
236
238
  isInserted = _ref3.isInserted,
237
- diffType = _ref3.diffType;
239
+ diffType = _ref3.diffType,
240
+ _ref3$hideAddedDiffsU = _ref3.hideAddedDiffsUnderline,
241
+ hideAddedDiffsUnderline = _ref3$hideAddedDiffsU === void 0 ? false : _ref3$hideAddedDiffsU;
238
242
  var currentStyle = element.getAttribute('style') || '';
239
- var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
243
+ var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
240
244
  var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
241
- var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
245
+ var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
242
246
  element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
243
247
  };
244
248
  var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4) {
@@ -247,10 +251,12 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4
247
251
  colorScheme = _ref4.colorScheme,
248
252
  isActive = _ref4.isActive,
249
253
  isInserted = _ref4.isInserted,
250
- diffType = _ref4.diffType;
254
+ diffType = _ref4.diffType,
255
+ _ref4$hideAddedDiffsU = _ref4.hideAddedDiffsUnderline,
256
+ hideAddedDiffsUnderline = _ref4$hideAddedDiffsU === void 0 ? false : _ref4$hideAddedDiffsU;
251
257
  var currentStyle = element.getAttribute('style') || '';
252
258
  var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
253
- var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
259
+ var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
254
260
  if (targetNode.type.name === 'decisionList') {
255
261
  element.querySelectorAll('li').forEach(function (listItem) {
256
262
  var currentListItemStyle = listItem.getAttribute('style') || '';
@@ -275,13 +281,15 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref5)
275
281
  colorScheme = _ref5.colorScheme,
276
282
  isActive = _ref5.isActive,
277
283
  isInserted = _ref5.isInserted,
278
- diffType = _ref5.diffType;
284
+ diffType = _ref5.diffType,
285
+ _ref5$hideAddedDiffsU = _ref5.hideAddedDiffsUnderline,
286
+ hideAddedDiffsUnderline = _ref5$hideAddedDiffsU === void 0 ? false : _ref5$hideAddedDiffsU;
279
287
  var currentStyle = element.getAttribute('style') || '';
280
- var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType) || '';
288
+ var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
281
289
  if (nodeSpecificStyle) {
282
290
  element.setAttribute('style', "".concat(currentStyle).concat(nodeSpecificStyle));
283
291
  }
284
- var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
292
+ var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
285
293
  var walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
286
294
  var textNodesToWrap = [];
287
295
  var currentNode = walker.nextNode();
@@ -308,16 +316,18 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
308
316
  colorScheme = _ref6.colorScheme,
309
317
  isActive = _ref6.isActive,
310
318
  isInserted = _ref6.isInserted,
311
- diffType = _ref6.diffType;
319
+ diffType = _ref6.diffType,
320
+ _ref6$hideAddedDiffsU = _ref6.hideAddedDiffsUnderline,
321
+ hideAddedDiffsUnderline = _ref6$hideAddedDiffsU === void 0 ? false : _ref6$hideAddedDiffsU;
312
322
  var contentWrapper = document.createElement('div');
313
323
  var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
314
- var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType);
324
+ var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
315
325
 
316
326
  // When the extended experiment is enabled and the content is inserted,
317
327
  // block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
318
328
  // should not also get the inline content style (borderBottom underline) on their container.
319
329
  var shouldSkipContentStyle = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted && nodeStyle !== undefined;
320
- var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
330
+ var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
321
331
  contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
322
332
  contentWrapper.append(nodeView);
323
333
  return contentWrapper;
@@ -432,7 +442,9 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
432
442
  isActive = _ref9$isActive === void 0 ? false : _ref9$isActive,
433
443
  _ref9$isInserted = _ref9.isInserted,
434
444
  isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted,
435
- diffType = _ref9.diffType;
445
+ diffType = _ref9.diffType,
446
+ _ref9$hideAddedDiffsU = _ref9.hideAddedDiffsUnderline,
447
+ hideAddedDiffsUnderline = _ref9$hideAddedDiffsU === void 0 ? false : _ref9$hideAddedDiffsU;
436
448
  var blockWrapper = createBlockNodeWrapper();
437
449
  var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
438
450
  if (shouldShowRemovedLozenge(targetNodeName) && (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted)) {
@@ -465,7 +477,8 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
465
477
  colorScheme: colorScheme,
466
478
  isActive: isActive,
467
479
  isInserted: isInserted,
468
- diffType: diffType
480
+ diffType: diffType,
481
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
469
482
  });
470
483
  blockWrapper.append(contentWrapper);
471
484
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
@@ -499,7 +512,9 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
499
512
  isActive = _ref0$isActive === void 0 ? false : _ref0$isActive,
500
513
  _ref0$isInserted = _ref0.isInserted,
501
514
  isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted,
502
- diffType = _ref0.diffType;
515
+ diffType = _ref0.diffType,
516
+ _ref0$hideAddedDiffsU = _ref0.hideAddedDiffsUnderline,
517
+ hideAddedDiffsUnderline = _ref0$hideAddedDiffsU === void 0 ? false : _ref0$hideAddedDiffsU;
503
518
  if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
504
519
  if (nodeView instanceof HTMLElement) {
505
520
  if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
@@ -509,7 +524,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
509
524
  colorScheme: colorScheme,
510
525
  isActive: isActive,
511
526
  isInserted: isInserted,
512
- diffType: diffType
527
+ diffType: diffType,
528
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
513
529
  });
514
530
  dom.append(nodeView);
515
531
  return;
@@ -521,7 +537,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
521
537
  colorScheme: colorScheme,
522
538
  isActive: isActive,
523
539
  isInserted: isInserted,
524
- diffType: diffType
540
+ diffType: diffType,
541
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
525
542
  });
526
543
  dom.append(nodeView);
527
544
  return;
@@ -544,7 +561,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
544
561
  intl: intl,
545
562
  isActive: isActive,
546
563
  isInserted: isInserted,
547
- diffType: diffType
564
+ diffType: diffType,
565
+ hideAddedDiffsUnderline: hideAddedDiffsUnderline
548
566
  });
549
567
  return;
550
568
  } else {
@@ -582,13 +600,14 @@ var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(c
582
600
  };
583
601
  var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
584
602
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
603
+ var hideAddedDiffsUnderline = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
585
604
  if (colorScheme === 'traditional') {
586
605
  return isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
587
606
  }
588
607
  if (isActive) {
589
- return _standard.editingStyleActiveExtended;
608
+ return hideAddedDiffsUnderline ? _standard.editingStyleActiveExtendedNoUnderline : _standard.editingStyleActiveExtended;
590
609
  }
591
- return _standard.editingStyleExtended;
610
+ return hideAddedDiffsUnderline ? _standard.editingStyleExtendedNoUnderline : _standard.editingStyleExtended;
592
611
  };
593
612
  var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
594
613
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -42,6 +42,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
42
42
  isInverted: false,
43
43
  diffType: 'inline',
44
44
  hideDeletedDiffs: false,
45
+ hideAddedDiffsUnderline: false,
45
46
  showIndicators: false,
46
47
  diffDescriptors: []
47
48
  } : {});
@@ -51,7 +52,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
51
52
  var newPluginState = currentPluginState;
52
53
  if (meta) {
53
54
  if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
54
- var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8;
55
+ var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8, _newPluginState9;
55
56
  // Update the plugin state with the new metadata
56
57
  newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
57
58
  isDisplayingChanges: true,
@@ -70,15 +71,16 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
70
71
  isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
71
72
  diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
72
73
  hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
73
- showIndicators: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.showIndicators,
74
- smartThresholds: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.smartThresholds,
75
- deletedDiffPlacement: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.deletedDiffPlacement
74
+ hideAddedDiffsUnderline: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.hideAddedDiffsUnderline,
75
+ showIndicators: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.showIndicators,
76
+ smartThresholds: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.smartThresholds,
77
+ deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement
76
78
  } : {})),
77
79
  decorations = _calculateDiffDecorat.decorations,
78
80
  diffDescriptors = _calculateDiffDecorat.diffDescriptors;
79
81
  // Update the decorations and their ids
80
82
  newPluginState.decorations = decorations;
81
- if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.diffType)) {
83
+ if ((0, _isExtendedEnabled.isExtendedEnabled)((_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType)) {
82
84
  newPluginState.diffDescriptors = diffDescriptors;
83
85
  }
84
86
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
@@ -90,12 +92,13 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
90
92
  isInverted: false,
91
93
  diffType: 'inline',
92
94
  hideDeletedDiffs: false,
95
+ hideAddedDiffsUnderline: false,
93
96
  diffDescriptors: []
94
97
  } : {});
95
98
  } else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
96
- var _newPluginState9;
99
+ var _newPluginState0;
97
100
  // Update the active index in plugin state and recalculate decorations
98
- var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType);
101
+ var _decorations = (0, _getScrollableDecorations.getScrollableDecorations)(currentPluginState.decorations, newState.doc, (_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType);
99
102
  if (_decorations.length > 0) {
100
103
  var _currentPluginState$a;
101
104
  // Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
@@ -133,6 +136,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
133
136
  isInverted: newPluginState.isInverted,
134
137
  diffType: newPluginState.diffType,
135
138
  hideDeletedDiffs: newPluginState.hideDeletedDiffs,
139
+ hideAddedDiffsUnderline: newPluginState.hideAddedDiffsUnderline,
136
140
  showIndicators: newPluginState.showIndicators,
137
141
  smartThresholds: newPluginState.smartThresholds,
138
142
  deletedDiffPlacement: newPluginState.deletedDiffPlacement
@@ -0,0 +1,2 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ export { computeDiffChanges } from '../pm-plugins/calculateDiff/computeDiffChanges';