@atlaskit/editor-plugin-show-diff 6.2.5 → 6.2.6

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 (43) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +19 -1
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +18 -2
  5. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -10
  6. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +83 -14
  7. package/dist/cjs/pm-plugins/getScrollableDecorations.js +132 -0
  8. package/dist/cjs/pm-plugins/main.js +12 -25
  9. package/dist/cjs/pm-plugins/scrollToActiveDecoration.js +50 -9
  10. package/dist/cjs/showDiffPlugin.js +2 -1
  11. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  12. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  13. package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +17 -1
  14. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -9
  15. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +80 -18
  16. package/dist/es2019/pm-plugins/getScrollableDecorations.js +117 -0
  17. package/dist/es2019/pm-plugins/main.js +11 -22
  18. package/dist/es2019/pm-plugins/scrollToActiveDecoration.js +50 -10
  19. package/dist/es2019/showDiffPlugin.js +3 -2
  20. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +1 -2
  21. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +18 -0
  22. package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +17 -1
  23. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -10
  24. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +85 -16
  25. package/dist/esm/pm-plugins/getScrollableDecorations.js +124 -0
  26. package/dist/esm/pm-plugins/main.js +11 -24
  27. package/dist/esm/pm-plugins/scrollToActiveDecoration.js +50 -9
  28. package/dist/esm/showDiffPlugin.js +3 -2
  29. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +4 -0
  30. package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +3 -0
  31. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -2
  32. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  33. package/dist/types/pm-plugins/getScrollableDecorations.d.ts +27 -0
  34. package/dist/types/pm-plugins/main.d.ts +0 -2
  35. package/dist/types/pm-plugins/scrollToActiveDecoration.d.ts +4 -2
  36. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +4 -0
  37. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +3 -0
  38. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -2
  39. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  40. package/dist/types-ts4.5/pm-plugins/getScrollableDecorations.d.ts +27 -0
  41. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -2
  42. package/dist/types-ts4.5/pm-plugins/scrollToActiveDecoration.d.ts +4 -2
  43. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 6.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`164eae4f672d5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/164eae4f672d5) -
8
+ Fix a number of issues with the diff flipper
9
+ - Updated dependencies
10
+
3
11
  ## 6.2.5
4
12
 
5
13
  ### Patch Changes
@@ -173,7 +173,6 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
173
173
  }))));
174
174
  }
175
175
  if (change.deleted.length > 0) {
176
- var _isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.fromB === activeIndexPos.to;
177
176
  var decoration = (0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread({
178
177
  change: change,
179
178
  doc: originalDoc,
@@ -181,7 +180,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
181
180
  colorScheme: colorScheme,
182
181
  newDoc: tr.doc,
183
182
  intl: intl,
184
- isActive: _isActive
183
+ activeIndexPos: activeIndexPos
185
184
  }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
186
185
  isInserted: !isInserted
187
186
  }));
@@ -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.editingStyleCardBlockNode = exports.editingStyleActive = exports.editingStyle = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNewActive = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = exports.deletedCellOverlayStyle = exports.deletedBlockOutlineRounded = exports.deletedBlockOutline = exports.addedCellOverlayStyle = void 0;
6
+ exports.standardDecorationMarkerVariable = exports.editingStyleRuleNode = exports.editingStyleQuoteNode = exports.editingStyleNode = exports.editingStyleCardBlockNode = exports.editingStyleActive = exports.editingStyle = exports.deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNewActive = 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
  var editingStyle = exports.editingStyle = (0, _lazyNodeView.convertToInlineCss)({
9
9
  background: "var(--ds-background-accent-purple-subtlest, #F8EEFE)",
@@ -65,14 +65,32 @@ var deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNodeWithLozenge
65
65
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
66
66
  borderRadius: "var(--ds-radius-small, 4px)"
67
67
  });
68
+
69
+ /** Stronger outline when this deleted block decoration is the active scroll target */
70
+ var deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozengeActive = (0, _lazyNodeView.convertToInlineCss)({
71
+ marginTop: "var(--ds-space-150, 12px)",
72
+ paddingTop: "var(--ds-space-025, 2px)",
73
+ paddingBottom: "var(--ds-space-025, 2px)",
74
+ paddingLeft: "var(--ds-space-025, 2px)",
75
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
76
+ borderRadius: "var(--ds-radius-small, 4px)"
77
+ });
68
78
  var deletedBlockOutline = exports.deletedBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
69
79
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
70
80
  borderRadius: "var(--ds-radius-small, 4px)"
71
81
  });
82
+ var deletedBlockOutlineActive = exports.deletedBlockOutlineActive = (0, _lazyNodeView.convertToInlineCss)({
83
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
84
+ borderRadius: "var(--ds-radius-small, 4px)"
85
+ });
72
86
  var deletedBlockOutlineRounded = exports.deletedBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
73
87
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
74
88
  borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
75
89
  });
90
+ var deletedBlockOutlineRoundedActive = exports.deletedBlockOutlineRoundedActive = (0, _lazyNodeView.convertToInlineCss)({
91
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
92
+ borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
93
+ });
76
94
  var deletedRowStyle = exports.deletedRowStyle = (0, _lazyNodeView.convertToInlineCss)({
77
95
  color: "var(--ds-text-accent-gray, #505258)",
78
96
  textDecoration: 'line-through',
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.traditionalStyleRuleNodeActive = exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNodeActive = exports.traditionalStyleQuoteNode = exports.traditionalStyleNodeActive = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNodeActive = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDecorationMarkerVariableActive = exports.traditionalDecorationMarkerVariable = exports.traditionalAddedCellOverlayStyle = exports.deletedTraditionalStyleQuoteNode = exports.deletedTraditionalRowStyle = exports.deletedTraditionalContentStyleUnboundedActive = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyleActive = exports.deletedTraditionalContentStyle = exports.deletedTraditionalCellOverlayStyle = exports.deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutline = void 0;
6
+ exports.traditionalStyleRuleNodeActive = exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNodeActive = exports.traditionalStyleQuoteNode = exports.traditionalStyleNodeActive = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNodeActive = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDecorationMarkerVariableActive = exports.traditionalDecorationMarkerVariable = exports.traditionalAddedCellOverlayStyle = exports.deletedTraditionalStyleQuoteNodeActive = exports.deletedTraditionalStyleQuoteNode = exports.deletedTraditionalRowStyle = exports.deletedTraditionalContentStyleUnboundedActive = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyleActive = exports.deletedTraditionalContentStyle = exports.deletedTraditionalCellOverlayStyle = exports.deletedTraditionalBlockOutlineRoundedActive = exports.deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutlineActive = exports.deletedTraditionalBlockOutline = void 0;
7
7
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
8
8
  var traditionalInsertStyle = exports.traditionalInsertStyle = (0, _lazyNodeView.convertToInlineCss)({
9
9
  background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
@@ -50,7 +50,7 @@ var deletedTraditionalContentStyleUnboundedActive = exports.deletedTraditionalCo
50
50
  top: '50%',
51
51
  width: '100%',
52
52
  display: 'inline-block',
53
- borderTop: "1px solid ".concat("var(--ds-text-accent-red-bolder, #5D1F1A)"),
53
+ borderTop: "2px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
54
54
  pointerEvents: 'none',
55
55
  zIndex: 1
56
56
  });
@@ -62,14 +62,30 @@ var deletedTraditionalStyleQuoteNode = exports.deletedTraditionalStyleQuoteNode
62
62
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
63
63
  borderRadius: "var(--ds-radius-small, 4px)"
64
64
  });
65
+ var deletedTraditionalStyleQuoteNodeActive = exports.deletedTraditionalStyleQuoteNodeActive = (0, _lazyNodeView.convertToInlineCss)({
66
+ marginTop: "var(--ds-space-150, 12px)",
67
+ paddingTop: "var(--ds-space-025, 2px)",
68
+ paddingBottom: "var(--ds-space-025, 2px)",
69
+ paddingLeft: "var(--ds-space-025, 2px)",
70
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
71
+ borderRadius: "var(--ds-radius-small, 4px)"
72
+ });
65
73
  var deletedTraditionalBlockOutline = exports.deletedTraditionalBlockOutline = (0, _lazyNodeView.convertToInlineCss)({
66
74
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
67
75
  borderRadius: "var(--ds-radius-small, 4px)"
68
76
  });
77
+ var deletedTraditionalBlockOutlineActive = exports.deletedTraditionalBlockOutlineActive = (0, _lazyNodeView.convertToInlineCss)({
78
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
79
+ borderRadius: "var(--ds-radius-small, 4px)"
80
+ });
69
81
  var deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutlineRounded = (0, _lazyNodeView.convertToInlineCss)({
70
82
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
71
83
  borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
72
84
  });
85
+ var deletedTraditionalBlockOutlineRoundedActive = exports.deletedTraditionalBlockOutlineRoundedActive = (0, _lazyNodeView.convertToInlineCss)({
86
+ boxShadow: "0 0 0 2px ".concat("var(--ds-border-accent-red, #E2483D)"),
87
+ borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
88
+ });
73
89
  var deletedTraditionalRowStyle = exports.deletedTraditionalRowStyle = (0, _lazyNodeView.convertToInlineCss)({
74
90
  textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
75
91
  textDecoration: 'line-through',
@@ -8,6 +8,7 @@ exports.createNodeChangedDecorationWidget = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
13
  var _standard = require("./colorSchemes/standard");
13
14
  var _traditional = require("./colorSchemes/traditional");
@@ -86,13 +87,13 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
86
87
  } else {
87
88
  wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
88
89
  var strikethrough = document.createElement('span');
89
- strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
90
+ strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
90
91
  wrapper.append(strikethrough);
91
92
  }
92
93
  } else {
93
94
  wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
94
95
  var _strikethrough = document.createElement('span');
95
- _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
96
+ _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
96
97
  wrapper.append(_strikethrough);
97
98
  }
98
99
  return wrapper;
@@ -103,18 +104,23 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
103
104
  * that is not in the current document.
104
105
  */
105
106
  var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
107
+ var _slice$content, _slice$content2, _slice$content3;
106
108
  var change = _ref2.change,
107
109
  doc = _ref2.doc,
108
110
  nodeViewSerializer = _ref2.nodeViewSerializer,
109
111
  colorScheme = _ref2.colorScheme,
110
112
  newDoc = _ref2.newDoc,
111
113
  intl = _ref2.intl,
112
- _ref2$isActive = _ref2.isActive,
113
- isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
114
+ activeIndexPos = _ref2.activeIndexPos,
114
115
  _ref2$isInserted = _ref2.isInserted,
115
116
  isInserted = _ref2$isInserted === void 0 ? false : _ref2$isInserted;
116
117
  var slice = doc.slice(change.fromA, change.toA);
117
- if (slice.content.content.length === 0) {
118
+ 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 && (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation');
119
+ // Widget decoration used for deletions as the content is not in the document
120
+ // and we want to display the deleted content with a style.
121
+ var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
122
+ var isActive = activeIndexPos && safeInsertPos === activeIndexPos.from && safeInsertPos === activeIndexPos.to;
123
+ if (slice.content.content.length === 0 || shouldSkipDeletedEmptyParagraphDecoration) {
118
124
  return;
119
125
  }
120
126
  var isTableCellContent = slice.content.content.some(function () {
@@ -222,6 +228,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
222
228
  targetNode: node,
223
229
  colorScheme: colorScheme,
224
230
  intl: intl,
231
+ isActive: isActive,
225
232
  isInserted: isInserted
226
233
  });
227
234
  }
@@ -231,7 +238,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
231
238
  } else {
232
239
  var fallbackNode = fallbackSerialization();
233
240
  if (fallbackNode) {
234
- if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
241
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
235
242
  if (fallbackNode instanceof HTMLElement) {
236
243
  var injectedNode = injectInnerWrapper({
237
244
  node: fallbackNode,
@@ -254,10 +261,6 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
254
261
  }
255
262
  });
256
263
  dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
257
-
258
- // Widget decoration used for deletions as the content is not in the document
259
- // and we want to display the deleted content with a style.
260
- var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
261
264
  var decorations = [];
262
265
  decorations.push(_view.Decoration.widget(safeInsertPos, dom, {
263
266
  key: "diff-widget-".concat(isActive ? 'active' : 'inactive')
@@ -25,6 +25,38 @@ var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
25
25
  whiteSpace: 'nowrap',
26
26
  color: "var(--ds-text-warning-inverse, #292A2E)"
27
27
  });
28
+ var lozengeStyleActiveStandard = (0, _lazyNodeView.convertToInlineCss)({
29
+ display: 'inline-flex',
30
+ boxSizing: 'border-box',
31
+ position: 'static',
32
+ blockSize: 'min-content',
33
+ borderRadius: "var(--ds-radius-small, 4px)",
34
+ overflow: 'hidden',
35
+ paddingInlineStart: "var(--ds-space-050, 4px)",
36
+ paddingInlineEnd: "var(--ds-space-050, 4px)",
37
+ backgroundColor: "var(--ds-background-accent-red-subtler-pressed, #FD9891)",
38
+ font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
39
+ fontWeight: "var(--ds-font-weight-bold, 653)",
40
+ textOverflow: 'ellipsis',
41
+ whiteSpace: 'nowrap',
42
+ color: "var(--ds-text-warning-inverse, #292A2E)"
43
+ });
44
+ var lozengeStyleActiveTraditional = (0, _lazyNodeView.convertToInlineCss)({
45
+ display: 'inline-flex',
46
+ boxSizing: 'border-box',
47
+ position: 'static',
48
+ blockSize: 'min-content',
49
+ borderRadius: "var(--ds-radius-small, 4px)",
50
+ overflow: 'hidden',
51
+ paddingInlineStart: "var(--ds-space-050, 4px)",
52
+ paddingInlineEnd: "var(--ds-space-050, 4px)",
53
+ backgroundColor: "var(--ds-background-accent-red-subtler-pressed, #FD9891)",
54
+ font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
55
+ fontWeight: "var(--ds-font-weight-bold, 653)",
56
+ textOverflow: 'ellipsis',
57
+ whiteSpace: 'nowrap',
58
+ color: "var(--ds-text-warning-inverse, #292A2E)"
59
+ });
28
60
  var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
29
61
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
30
62
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -35,7 +67,7 @@ var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
35
67
  return isActive ? _standard.editingStyleActive : _standard.editingStyle;
36
68
  }
37
69
  if (colorScheme === 'traditional') {
38
- return _traditional.deletedTraditionalContentStyle;
70
+ return isActive ? _traditional.deletedTraditionalContentStyleActive : _traditional.deletedTraditionalContentStyle;
39
71
  }
40
72
  if (isActive) {
41
73
  return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNewActive : _standard.deletedContentStyleActive;
@@ -44,6 +76,7 @@ var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
44
76
  };
45
77
  var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
46
78
  var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
79
+ var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
47
80
  var isTraditional = colorScheme === 'traditional';
48
81
  if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && isInserted) {
49
82
  if (shouldApplyStylesDirectly(nodeName)) {
@@ -56,13 +89,22 @@ var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
56
89
  }
57
90
  switch (nodeName) {
58
91
  case 'blockquote':
59
- return isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNodeWithLozenge;
92
+ if (isTraditional) {
93
+ return isActive ? _traditional.deletedTraditionalStyleQuoteNodeActive : _traditional.deletedTraditionalStyleQuoteNode;
94
+ }
95
+ return isActive ? _standard.deletedStyleQuoteNodeWithLozengeActive : _standard.deletedStyleQuoteNodeWithLozenge;
60
96
  case 'expand':
61
97
  case 'decisionList':
62
- return isTraditional ? _traditional.deletedTraditionalBlockOutline : _standard.deletedBlockOutline;
98
+ if (isTraditional) {
99
+ return isActive ? _traditional.deletedTraditionalBlockOutlineActive : _traditional.deletedTraditionalBlockOutline;
100
+ }
101
+ return isActive ? _standard.deletedBlockOutlineActive : _standard.deletedBlockOutline;
63
102
  case 'panel':
64
103
  case 'codeBlock':
65
- return isTraditional ? _traditional.deletedTraditionalBlockOutlineRounded : _standard.deletedBlockOutlineRounded;
104
+ if (isTraditional) {
105
+ return isActive ? _traditional.deletedTraditionalBlockOutlineRoundedActive : _traditional.deletedTraditionalBlockOutlineRounded;
106
+ }
107
+ return isActive ? _standard.deletedBlockOutlineRoundedActive : _standard.deletedBlockOutlineRounded;
66
108
  default:
67
109
  return undefined;
68
110
  }
@@ -115,6 +157,8 @@ var applyCellOverlayStyles = function applyCellOverlayStyles(_ref) {
115
157
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
116
158
  */
117
159
  var createRemovedLozenge = function createRemovedLozenge(intl) {
160
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
161
+ var colorScheme = arguments.length > 2 ? arguments[2] : undefined;
118
162
  var container = document.createElement('span');
119
163
  var containerStyle = (0, _lazyNodeView.convertToInlineCss)({
120
164
  position: 'absolute',
@@ -129,7 +173,8 @@ var createRemovedLozenge = function createRemovedLozenge(intl) {
129
173
 
130
174
  // Create vanilla HTML lozenge element with Atlaskit Lozenge styling (visual refresh)
131
175
  var lozengeElement = document.createElement('span');
132
- lozengeElement.setAttribute('style', lozengeStyle);
176
+ var lozengeInnerStyle = isActive && colorScheme === 'traditional' ? lozengeStyleActiveTraditional : isActive ? lozengeStyleActiveStandard : lozengeStyle;
177
+ lozengeElement.setAttribute('style', lozengeInnerStyle);
133
178
  lozengeElement.textContent = intl.formatMessage(_messages.trackChangesMessages.removed).toUpperCase();
134
179
  container.appendChild(lozengeElement);
135
180
  return container;
@@ -156,10 +201,11 @@ var applyStylesToElement = function applyStylesToElement(_ref2) {
156
201
  var element = _ref2.element,
157
202
  targetNode = _ref2.targetNode,
158
203
  colorScheme = _ref2.colorScheme,
204
+ isActive = _ref2.isActive,
159
205
  isInserted = _ref2.isInserted;
160
206
  var currentStyle = element.getAttribute('style') || '';
161
- var contentStyle = getChangedContentStyle(colorScheme, false, isInserted);
162
- var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted) || '';
207
+ var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
208
+ var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive) || '';
163
209
  element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
164
210
  };
165
211
 
@@ -170,10 +216,11 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref3
170
216
  var nodeView = _ref3.nodeView,
171
217
  targetNode = _ref3.targetNode,
172
218
  colorScheme = _ref3.colorScheme,
219
+ isActive = _ref3.isActive,
173
220
  isInserted = _ref3.isInserted;
174
221
  var contentWrapper = document.createElement('div');
175
- var nodeStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted);
176
- contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, false, isInserted)).concat(nodeStyle || ''));
222
+ var nodeStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive);
223
+ contentWrapper.setAttribute('style', "".concat(getChangedContentStyle(colorScheme, isActive, isInserted)).concat(nodeStyle || ''));
177
224
  contentWrapper.append(nodeView);
178
225
  return contentWrapper;
179
226
  };
@@ -189,7 +236,9 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref4) {
189
236
  nodeView = _ref4.nodeView,
190
237
  targetNode = _ref4.targetNode,
191
238
  lozenge = _ref4.lozenge,
192
- colorScheme = _ref4.colorScheme;
239
+ colorScheme = _ref4.colorScheme,
240
+ _ref4$isActive = _ref4.isActive,
241
+ isActive = _ref4$isActive === void 0 ? false : _ref4$isActive;
193
242
  if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
194
243
  return false;
195
244
  }
@@ -212,6 +261,9 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref4) {
212
261
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
213
262
  var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
214
263
  nodeView.classList.add(showDiffDeletedNodeClass);
264
+ if (isActive) {
265
+ nodeView.classList.add('show-diff-deleted-active');
266
+ }
215
267
  }
216
268
  dom.append(nodeView);
217
269
  return true;
@@ -226,7 +278,9 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref5)
226
278
  nodeView = _ref5.nodeView,
227
279
  targetNode = _ref5.targetNode,
228
280
  lozenge = _ref5.lozenge,
229
- colorScheme = _ref5.colorScheme;
281
+ colorScheme = _ref5.colorScheme,
282
+ _ref5$isActive = _ref5.isActive,
283
+ isActive = _ref5$isActive === void 0 ? false : _ref5$isActive;
230
284
  if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
231
285
  return false;
232
286
  }
@@ -247,6 +301,9 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref5)
247
301
  if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
248
302
  var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
249
303
  nodeView.classList.add(showDiffDeletedNodeClass);
304
+ if (isActive) {
305
+ nodeView.classList.add('show-diff-deleted-active');
306
+ }
250
307
  }
251
308
  dom.append(nodeView);
252
309
  return true;
@@ -261,17 +318,20 @@ var wrapBlockNode = function wrapBlockNode(_ref6) {
261
318
  targetNode = _ref6.targetNode,
262
319
  colorScheme = _ref6.colorScheme,
263
320
  intl = _ref6.intl,
321
+ _ref6$isActive = _ref6.isActive,
322
+ isActive = _ref6$isActive === void 0 ? false : _ref6$isActive,
264
323
  _ref6$isInserted = _ref6.isInserted,
265
324
  isInserted = _ref6$isInserted === void 0 ? false : _ref6$isInserted;
266
325
  var blockWrapper = createBlockNodeWrapper();
267
326
  if (shouldShowRemovedLozenge(targetNode.type.name) && (!(0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || !isInserted)) {
268
- var lozenge = createRemovedLozenge(intl);
327
+ var lozenge = createRemovedLozenge(intl, isActive, colorScheme);
269
328
  if (handleEmbedCardWithLozenge({
270
329
  dom: dom,
271
330
  nodeView: nodeView,
272
331
  targetNode: targetNode,
273
332
  lozenge: lozenge,
274
- colorScheme: colorScheme
333
+ colorScheme: colorScheme,
334
+ isActive: isActive
275
335
  })) {
276
336
  return;
277
337
  }
@@ -280,7 +340,8 @@ var wrapBlockNode = function wrapBlockNode(_ref6) {
280
340
  nodeView: nodeView,
281
341
  targetNode: targetNode,
282
342
  lozenge: lozenge,
283
- colorScheme: colorScheme
343
+ colorScheme: colorScheme,
344
+ isActive: isActive
284
345
  })) {
285
346
  return;
286
347
  }
@@ -290,12 +351,16 @@ var wrapBlockNode = function wrapBlockNode(_ref6) {
290
351
  nodeView: nodeView,
291
352
  targetNode: targetNode,
292
353
  colorScheme: colorScheme,
354
+ isActive: isActive,
293
355
  isInserted: isInserted
294
356
  });
295
357
  blockWrapper.append(contentWrapper);
296
358
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
297
359
  var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
298
360
  nodeView.classList.add(showDiffDeletedNodeClass);
361
+ if (isActive) {
362
+ nodeView.classList.add('show-diff-deleted-active');
363
+ }
299
364
  }
300
365
  dom.append(blockWrapper);
301
366
  };
@@ -311,6 +376,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
311
376
  targetNode = _ref7.targetNode,
312
377
  colorScheme = _ref7.colorScheme,
313
378
  intl = _ref7.intl,
379
+ _ref7$isActive = _ref7.isActive,
380
+ isActive = _ref7$isActive === void 0 ? false : _ref7$isActive,
314
381
  _ref7$isInserted = _ref7.isInserted,
315
382
  isInserted = _ref7$isInserted === void 0 ? false : _ref7$isInserted;
316
383
  if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
@@ -319,6 +386,7 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
319
386
  element: nodeView,
320
387
  targetNode: targetNode,
321
388
  colorScheme: colorScheme,
389
+ isActive: isActive,
322
390
  isInserted: isInserted
323
391
  });
324
392
  dom.append(nodeView);
@@ -337,6 +405,7 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
337
405
  targetNode: targetNode,
338
406
  colorScheme: colorScheme,
339
407
  intl: intl,
408
+ isActive: isActive,
340
409
  isInserted: isInserted
341
410
  });
342
411
  }
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getScrollableDecorations = void 0;
8
+ exports.isInlineDiffDecorationRenderableInDoc = isInlineDiffDecorationRenderableInDoc;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ /**
11
+ * True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
12
+ * Block-only subtrees (e.g. empty paragraphs, block cards with no inline children) return false.
13
+ */
14
+ function fragmentContainsInlineContent(fragment) {
15
+ for (var i = 0; i < fragment.childCount; i++) {
16
+ var node = fragment.child(i);
17
+ if (node.isInline) {
18
+ return true;
19
+ }
20
+ if (node.content.size > 0 && fragmentContainsInlineContent(node.content)) {
21
+ return true;
22
+ }
23
+ }
24
+ return false;
25
+ }
26
+
27
+ /**
28
+ * Returns true when an inline decoration's [from, to) range can actually show in the document:
29
+ * positions are valid, and the slice contains at least one inline node ProseMirror would paint
30
+ * (not only empty block wrappers or block-only structure).
31
+ */
32
+ function isInlineDiffDecorationRenderableInDoc(doc, from, to) {
33
+ try {
34
+ var slice = doc.slice(from, to);
35
+ return fragmentContainsInlineContent(slice.content);
36
+ } catch (_unused) {
37
+ return false;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Checks if range1 is fully contained within range2
43
+ */
44
+ function isRangeFullyInside(range1Start, range1End, range2Start, range2End) {
45
+ return range2Start <= range1Start && range1End <= range2End;
46
+ }
47
+
48
+ /**
49
+ * Gets scrollable decorations from a DecorationSet, filtering out overlapping decorations
50
+ * and applying various rules for diff visualization.
51
+ *
52
+ * Rules:
53
+ * 1. Only includes diff-inline, diff-widget-* and diff-block decorations
54
+ * 2. Excludes listItem diff-block decorations (never scrollable)
55
+ * 3. Deduplicates diff-block decorations with same from, to and nodeName
56
+ * 4. When `doc` is passed: excludes diff-inline decorations whose range has no inline content
57
+ * (invalid positions, or block-only slices with no text/atoms — e.g. empty blocks)
58
+ * 5. Excludes diff-inline decorations that are fully contained within a diff-block
59
+ * 6. Excludes diff-block decorations that are fully contained within a diff-inline
60
+ * 7. Results are sorted by from position, then by to position
61
+ *
62
+ * @param set - The DecorationSet to extract scrollable decorations from
63
+ * @param doc - Current document; when set, diff-inline ranges are validated against this doc
64
+ * @returns Array of scrollable decorations, sorted and deduplicated
65
+ */
66
+ var getScrollableDecorations = exports.getScrollableDecorations = function getScrollableDecorations(set, doc) {
67
+ if (!set) {
68
+ return [];
69
+ }
70
+ var seenBlockKeys = new Set();
71
+ var allDecorations = set.find(undefined, undefined, function (spec) {
72
+ var _spec$key;
73
+ return spec.key === 'diff-inline' || ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith('diff-widget')) || spec.key === 'diff-block';
74
+ });
75
+
76
+ // First pass: filter out listItem blocks and deduplicates blocks
77
+ var filtered = allDecorations.filter(function (dec) {
78
+ var _dec$spec, _dec$spec$nodeName, _dec$spec3;
79
+ if (((_dec$spec = dec.spec) === null || _dec$spec === void 0 ? void 0 : _dec$spec.key) === 'diff-block') {
80
+ var _dec$spec2;
81
+ // Skip listItem blocks as they are not scrollable
82
+ if (((_dec$spec2 = dec.spec) === null || _dec$spec2 === void 0 ? void 0 : _dec$spec2.nodeName) === 'listItem') return false;
83
+ }
84
+ var key = "".concat(dec.from, "-").concat(dec.to, "-").concat((_dec$spec$nodeName = (_dec$spec3 = dec.spec) === null || _dec$spec3 === void 0 ? void 0 : _dec$spec3.nodeName) !== null && _dec$spec$nodeName !== void 0 ? _dec$spec$nodeName : '');
85
+ // Skip blocks that have already been seen
86
+ if (seenBlockKeys.has(key)) return false;
87
+ seenBlockKeys.add(key);
88
+ return true;
89
+ });
90
+
91
+ // Separate decorations by type for easier processing
92
+ var blocks = filtered.filter(function (d) {
93
+ var _d$spec;
94
+ return ((_d$spec = d.spec) === null || _d$spec === void 0 ? void 0 : _d$spec.key) === 'diff-block';
95
+ });
96
+ var rawInlines = filtered.filter(function (d) {
97
+ var _d$spec2;
98
+ return ((_d$spec2 = d.spec) === null || _d$spec2 === void 0 ? void 0 : _d$spec2.key) === 'diff-inline';
99
+ });
100
+ var inlines = doc !== undefined ? rawInlines.filter(function (d) {
101
+ return isInlineDiffDecorationRenderableInDoc(doc, d.from, d.to);
102
+ }) : rawInlines;
103
+ var widgets = filtered.filter(function (d) {
104
+ var _d$spec3;
105
+ return (_d$spec3 = d.spec) === null || _d$spec3 === void 0 || (_d$spec3 = _d$spec3.key) === null || _d$spec3 === void 0 ? void 0 : _d$spec3.startsWith('diff-widget');
106
+ });
107
+
108
+ // Second pass: exclude overlapping decorations
109
+ // Rules:
110
+ // - If an inline is fully inside a block, exclude the block (inline takes priority)
111
+ // - If a block is fully inside an inline, exclude the block (inline takes priority)
112
+ var nonOverlappingBlocks = blocks.filter(function (block) {
113
+ // Exclude block if:
114
+ // 1. It's fully contained within any inline, OR
115
+ // 2. It fully contains any inline
116
+ return !inlines.some(function (inline) {
117
+ return isRangeFullyInside(block.from, block.to, inline.from, inline.to) ||
118
+ // block inside inline
119
+ isRangeFullyInside(inline.from, inline.to, block.from, block.to);
120
+ } // inline inside block
121
+ );
122
+ });
123
+
124
+ // Combine all non-overlapping decorations
125
+ var result = [].concat((0, _toConsumableArray2.default)(nonOverlappingBlocks), (0, _toConsumableArray2.default)(inlines), (0, _toConsumableArray2.default)(widgets));
126
+
127
+ // Sort by from position, then by to position
128
+ result.sort(function (a, b) {
129
+ return a.from === b.from ? a.to - b.to : a.from - b.from;
130
+ });
131
+ return result;
132
+ };