@atlaskit/editor-plugin-show-diff 6.0.2 → 6.1.1

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 (50) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +37 -16
  3. package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +23 -1
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +23 -1
  5. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +60 -8
  6. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +19 -4
  7. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +24 -4
  8. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +92 -21
  9. package/dist/cjs/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -15
  10. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +87 -45
  11. package/dist/cjs/pm-plugins/main.js +17 -7
  12. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +35 -13
  13. package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +22 -0
  14. package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +22 -0
  15. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +59 -8
  16. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +20 -6
  17. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +25 -6
  18. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +84 -16
  19. package/dist/es2019/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -13
  20. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +58 -19
  21. package/dist/es2019/pm-plugins/main.js +22 -4
  22. package/dist/esm/pm-plugins/calculateDiffDecorations.js +37 -16
  23. package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +22 -0
  24. package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +22 -0
  25. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +62 -10
  26. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +21 -6
  27. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +26 -6
  28. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +93 -23
  29. package/dist/esm/pm-plugins/decorations/utils/getMarkChangeRanges.js +0 -15
  30. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +89 -47
  31. package/dist/esm/pm-plugins/main.js +17 -7
  32. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +2 -0
  33. package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +2 -0
  34. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  35. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
  36. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  37. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +6 -1
  38. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  39. package/dist/types/pm-plugins/main.d.ts +1 -0
  40. package/dist/types/showDiffPluginType.d.ts +1 -0
  41. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +2 -0
  42. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +2 -0
  43. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  44. package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
  45. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  46. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +6 -1
  47. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  48. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  49. package/dist/types-ts4.5/showDiffPluginType.d.ts +1 -0
  50. package/package.json +5 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 6.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 6.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`40c53e0b66a8a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/40c53e0b66a8a) -
14
+ EDITOR-5829: Allow showing inverse of diffs
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 6.0.2
4
21
 
5
22
  ### Patch Changes
@@ -29,18 +29,21 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
29
29
  var doc = _ref.doc,
30
30
  from = _ref.from,
31
31
  to = _ref.to,
32
- colorScheme = _ref.colorScheme;
32
+ colorScheme = _ref.colorScheme,
33
+ _ref$isInserted = _ref.isInserted,
34
+ isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted;
33
35
  var decorations = [];
34
36
  // Iterate over the document nodes within the range
35
37
  doc.nodesBetween(from, to, function (node, pos) {
36
- if (node.isBlock) {
38
+ if (node.isBlock && (!(0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || pos + node.nodeSize <= to)) {
37
39
  var decoration = (0, _createBlockChangedDecoration.createBlockChangedDecoration)({
38
40
  change: {
39
41
  from: pos,
40
42
  to: pos + node.nodeSize,
41
43
  name: node.type.name
42
44
  },
43
- colorScheme: colorScheme
45
+ colorScheme: colorScheme,
46
+ isInserted: isInserted
44
47
  });
45
48
  if (decoration) {
46
49
  decorations.push(decoration);
@@ -89,7 +92,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
89
92
  colorScheme = _ref2.colorScheme,
90
93
  intl = _ref2.intl,
91
94
  activeIndexPos = _ref2.activeIndexPos,
92
- api = _ref2.api;
95
+ api = _ref2.api,
96
+ _ref2$isInverted = _ref2.isInverted,
97
+ isInverted = _ref2$isInverted === void 0 ? false : _ref2$isInverted;
93
98
  var originalDoc = pluginState.originalDoc,
94
99
  steps = pluginState.steps;
95
100
  if (!originalDoc || !pluginState.isDisplayingChanges) {
@@ -143,22 +148,28 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
143
148
  var decorations = [];
144
149
  optimizedChanges.forEach(function (change) {
145
150
  var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
151
+ // Our default operations are insertions, so it should match the opposite of isInverted.
152
+ var isInserted = !isInverted;
146
153
  if (change.inserted.length > 0) {
147
- decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
154
+ decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
148
155
  change: change,
149
156
  colorScheme: colorScheme,
150
157
  isActive: isActive
151
- }));
152
- decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration({
158
+ }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
159
+ isInserted: isInserted
160
+ })));
161
+ decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread({
153
162
  doc: tr.doc,
154
163
  from: change.fromB,
155
164
  to: change.toB,
156
165
  colorScheme: colorScheme
157
- })));
166
+ }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
167
+ isInserted: isInserted
168
+ }))));
158
169
  }
159
170
  if (change.deleted.length > 0) {
160
171
  var _isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
161
- var decoration = (0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)({
172
+ var decoration = (0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread({
162
173
  change: change,
163
174
  doc: originalDoc,
164
175
  nodeViewSerializer: nodeViewSerializer,
@@ -166,7 +177,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
166
177
  newDoc: tr.doc,
167
178
  intl: intl,
168
179
  isActive: _isActive
169
- });
180
+ }, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
181
+ isInserted: !isInserted
182
+ }));
170
183
  if (decoration) {
171
184
  decorations.push.apply(decorations, (0, _toConsumableArray2.default)(decoration));
172
185
  }
@@ -177,7 +190,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
177
190
  decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
178
191
  change: change,
179
192
  colorScheme: colorScheme,
180
- isActive: isActive
193
+ isActive: isActive,
194
+ isInserted: true
181
195
  }));
182
196
  });
183
197
  (0, _getAttrChangeRanges.getAttrChangeRanges)(tr.doc, attrSteps).forEach(function (change) {
@@ -185,7 +199,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
185
199
  doc: tr.doc,
186
200
  from: change.fromB,
187
201
  to: change.toB,
188
- colorScheme: colorScheme
202
+ colorScheme: colorScheme,
203
+ isInserted: true
189
204
  })));
190
205
  });
191
206
  return _view.DecorationSet.empty.add(tr.doc, decorations);
@@ -193,21 +208,27 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
193
208
  var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
194
209
  // Cache results unless relevant inputs change
195
210
  function (_ref3, _ref4) {
196
- var _ref7;
211
+ var _ref8;
197
212
  var _ref5 = (0, _slicedToArray2.default)(_ref3, 1),
198
213
  _ref5$ = _ref5[0],
199
214
  pluginState = _ref5$.pluginState,
200
215
  state = _ref5$.state,
201
216
  colorScheme = _ref5$.colorScheme,
202
217
  intl = _ref5$.intl,
203
- activeIndexPos = _ref5$.activeIndexPos;
218
+ activeIndexPos = _ref5$.activeIndexPos,
219
+ isInverted = _ref5$.isInverted;
204
220
  var _ref6 = (0, _slicedToArray2.default)(_ref4, 1),
205
221
  _ref6$ = _ref6[0],
206
222
  lastPluginState = _ref6$.pluginState,
207
223
  lastState = _ref6$.state,
208
224
  lastColorScheme = _ref6$.colorScheme,
209
225
  lastIntl = _ref6$.intl,
210
- lastActiveIndexPos = _ref6$.activeIndexPos;
226
+ lastActiveIndexPos = _ref6$.activeIndexPos,
227
+ lastIsInverted = _ref6$.isInverted;
211
228
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
212
- return (_ref7 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos)) !== null && _ref7 !== void 0 ? _ref7 : false;
229
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
230
+ var _ref7;
231
+ return (_ref7 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc)) !== null && _ref7 !== void 0 ? _ref7 : false;
232
+ }
233
+ return (_ref8 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos)) !== null && _ref8 !== void 0 ? _ref8 : false;
213
234
  });
@@ -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.deletedBlockOutlineRounded = exports.deletedBlockOutline = void 0;
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;
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)",
@@ -95,4 +95,26 @@ var editingStyleCardBlockNode = exports.editingStyleCardBlockNode = (0, _lazyNod
95
95
  });
96
96
  var standardDecorationMarkerVariable = exports.standardDecorationMarkerVariable = (0, _lazyNodeView.convertToInlineCss)({
97
97
  '--diff-decoration-marker-color': "var(--ds-border-accent-purple, #AF59E1)"
98
+ });
99
+ var addedCellOverlayStyle = exports.addedCellOverlayStyle = (0, _lazyNodeView.convertToInlineCss)({
100
+ position: 'absolute',
101
+ top: 0,
102
+ left: 0,
103
+ width: '100%',
104
+ height: '100%',
105
+ backgroundColor: "rgba(from ".concat("var(--ds-background-accent-purple-subtlest, #F8EEFE)", " r g b / 0.5)"),
106
+ zIndex: 1,
107
+ outline: "1px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
108
+ pointerEvents: 'none'
109
+ });
110
+ var deletedCellOverlayStyle = exports.deletedCellOverlayStyle = (0, _lazyNodeView.convertToInlineCss)({
111
+ position: 'absolute',
112
+ top: 0,
113
+ left: 0,
114
+ width: '100%',
115
+ height: '100%',
116
+ backgroundColor: "rgba(from ".concat("var(--ds-background-accent-gray-subtlest, #F0F1F2)", " r g b / 0.5)"),
117
+ zIndex: 1,
118
+ outline: "1px solid ".concat("var(--ds-border-accent-gray, #7D818A)"),
119
+ pointerEvents: 'none'
98
120
  });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNode = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDecorationMarkerVariable = exports.deletedTraditionalStyleQuoteNode = exports.deletedTraditionalRowStyle = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyle = exports.deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutline = void 0;
6
+ exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNode = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDecorationMarkerVariable = exports.traditionalAddedCellOverlayStyle = exports.deletedTraditionalStyleQuoteNode = exports.deletedTraditionalRowStyle = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyle = exports.deletedTraditionalCellOverlayStyle = exports.deletedTraditionalBlockOutlineRounded = 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)",
@@ -72,4 +72,26 @@ var traditionalStyleCardBlockNode = exports.traditionalStyleCardBlockNode = (0,
72
72
  });
73
73
  var traditionalDecorationMarkerVariable = exports.traditionalDecorationMarkerVariable = (0, _lazyNodeView.convertToInlineCss)({
74
74
  '--diff-decoration-marker-color': "var(--ds-border-accent-green, #22A06B)"
75
+ });
76
+ var traditionalAddedCellOverlayStyle = exports.traditionalAddedCellOverlayStyle = (0, _lazyNodeView.convertToInlineCss)({
77
+ position: 'absolute',
78
+ top: 0,
79
+ left: 0,
80
+ width: '100%',
81
+ height: '100%',
82
+ backgroundColor: "rgba(from ".concat("var(--ds-background-accent-green-subtlest, #DCFFF1)", " r g b / 0.5)"),
83
+ zIndex: 1,
84
+ outline: "1px solid ".concat("var(--ds-border-accent-green, #22A06B)"),
85
+ pointerEvents: 'none'
86
+ });
87
+ var deletedTraditionalCellOverlayStyle = exports.deletedTraditionalCellOverlayStyle = (0, _lazyNodeView.convertToInlineCss)({
88
+ position: 'absolute',
89
+ top: 0,
90
+ left: 0,
91
+ width: '100%',
92
+ height: '100%',
93
+ backgroundColor: "rgba(from ".concat("var(--ds-background-accent-gray-subtlest, #F0F1F2)", " r g b / 0.5)"),
94
+ zIndex: 1,
95
+ outline: "1px solid ".concat("var(--ds-border-disabled, #0515240F)"),
96
+ pointerEvents: 'none'
75
97
  });
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.createBlockChangedDecoration = void 0;
7
7
  var _view = require("@atlaskit/editor-prosemirror/view");
8
8
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _standard = require("./colorSchemes/standard");
10
11
  var _traditional = require("./colorSchemes/traditional");
11
12
  var getNodeClass = function getNodeClass(name) {
@@ -16,7 +17,11 @@ var getNodeClass = function getNodeClass(name) {
16
17
  return undefined;
17
18
  }
18
19
  };
19
- var getBlockNodeStyle = function getBlockNodeStyle(nodeName, colorScheme) {
20
+ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
21
+ var nodeName = _ref.nodeName,
22
+ colorScheme = _ref.colorScheme,
23
+ _ref$isInserted = _ref.isInserted,
24
+ isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted;
20
25
  var isTraditional = colorScheme === 'traditional';
21
26
  if (['mediaSingle', 'mediaGroup', 'table',
22
27
  // Handle table separately to avoid border issues
@@ -27,17 +32,52 @@ var getBlockNodeStyle = function getBlockNodeStyle(nodeName, colorScheme) {
27
32
  return undefined;
28
33
  }
29
34
  if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
35
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
36
+ if (isInserted) {
37
+ return isTraditional ? _traditional.traditionalDecorationMarkerVariable : _standard.standardDecorationMarkerVariable;
38
+ } else {
39
+ return isTraditional ? _traditional.deletedTraditionalContentStyle : _standard.deletedContentStyleNew;
40
+ }
41
+ }
30
42
  return isTraditional ? _traditional.traditionalDecorationMarkerVariable : _standard.standardDecorationMarkerVariable;
31
43
  }
32
44
  if (nodeName === 'blockquote') {
45
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
46
+ if (isInserted) {
47
+ return isTraditional ? _traditional.traditionalStyleQuoteNode : _standard.editingStyleQuoteNode;
48
+ } else {
49
+ return isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNode;
50
+ }
51
+ }
33
52
  return isTraditional ? _traditional.traditionalStyleQuoteNode : _standard.editingStyleQuoteNode;
34
53
  }
35
54
  if (nodeName === 'rule') {
55
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
56
+ if (isInserted) {
57
+ return isTraditional ? _traditional.traditionalStyleRuleNode : _standard.editingStyleRuleNode;
58
+ } else {
59
+ return isTraditional ? _traditional.deletedTraditionalContentStyle : _standard.deletedContentStyleNew;
60
+ }
61
+ }
36
62
  return isTraditional ? _traditional.traditionalStyleRuleNode : _standard.editingStyleRuleNode;
37
63
  }
38
64
  if (nodeName === 'blockCard') {
65
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
66
+ if (isInserted) {
67
+ return isTraditional ? _traditional.traditionalStyleCardBlockNode : _standard.editingStyleCardBlockNode;
68
+ } else {
69
+ return isTraditional ? _traditional.deletedTraditionalContentStyle : _standard.deletedContentStyleNew;
70
+ }
71
+ }
39
72
  return isTraditional ? _traditional.traditionalStyleCardBlockNode : _standard.editingStyleCardBlockNode;
40
73
  }
74
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
75
+ if (isInserted) {
76
+ return isTraditional ? _traditional.traditionalStyleNode : _standard.editingStyleNode;
77
+ } else {
78
+ return isTraditional ? _traditional.deletedTraditionalContentStyle : _standard.deletedContentStyleNew;
79
+ }
80
+ }
41
81
  return isTraditional ? _traditional.traditionalStyleNode : _standard.editingStyleNode;
42
82
  };
43
83
 
@@ -47,12 +87,24 @@ var getBlockNodeStyle = function getBlockNodeStyle(nodeName, colorScheme) {
47
87
  * @param change Changeset "change" containing information about the change content + range
48
88
  * @returns Prosemirror inline decoration
49
89
  */
50
- var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(_ref) {
51
- var change = _ref.change,
52
- colorScheme = _ref.colorScheme;
90
+ var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(_ref2) {
91
+ var change = _ref2.change,
92
+ colorScheme = _ref2.colorScheme,
93
+ _ref2$isInserted = _ref2.isInserted,
94
+ isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted;
95
+ var style = getBlockNodeStyle({
96
+ nodeName: change.name,
97
+ colorScheme: colorScheme
98
+ });
99
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
100
+ style = getBlockNodeStyle({
101
+ nodeName: change.name,
102
+ colorScheme: colorScheme,
103
+ isInserted: isInserted
104
+ });
105
+ }
106
+ var className = getNodeClass(change.name);
53
107
  if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
54
- var style = getBlockNodeStyle(change.name, colorScheme);
55
- var className = getNodeClass(change.name);
56
108
  if (style || className) {
57
109
  return _view.Decoration.node(change.from, change.to, {
58
110
  style: style,
@@ -65,9 +117,9 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
65
117
  return undefined;
66
118
  } else {
67
119
  return _view.Decoration.node(change.from, change.to, {
68
- style: getBlockNodeStyle(change.name, colorScheme),
120
+ style: style,
69
121
  'data-testid': 'show-diff-changed-decoration-node',
70
- class: getNodeClass(change.name)
122
+ class: className
71
123
  }, {
72
124
  key: 'diff-block'
73
125
  });
@@ -10,6 +10,7 @@ var _document = require("@atlaskit/editor-common/utils/document");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
12
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _standard = require("./colorSchemes/standard");
14
15
  var _traditional = require("./colorSchemes/traditional");
15
16
  var _findSafeInsertPos = require("./utils/findSafeInsertPos");
@@ -115,9 +116,15 @@ 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) {
119
+ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted) {
119
120
  var tr = document.createElement('tr');
120
- tr.setAttribute('style', colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle);
121
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
122
+ if (!isInserted) {
123
+ tr.setAttribute('style', colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle);
124
+ }
125
+ } else {
126
+ tr.setAttribute('style', colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle);
127
+ }
121
128
  tr.setAttribute('data-testid', 'show-diff-deleted-row');
122
129
 
123
130
  // Serialize each cell in the row
@@ -125,6 +132,12 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
125
132
  if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
126
133
  var nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
127
134
  if (nodeView) {
135
+ if (isInserted && nodeView instanceof HTMLElement && (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
136
+ var overlay = document.createElement('span');
137
+ var overlayStyle = colorScheme === 'traditional' ? isInserted ? _traditional.traditionalAddedCellOverlayStyle : _traditional.deletedTraditionalCellOverlayStyle : isInserted ? _standard.addedCellOverlayStyle : _standard.deletedCellOverlayStyle;
138
+ overlay.setAttribute('style', overlayStyle);
139
+ nodeView.appendChild(overlay);
140
+ }
128
141
  tr.appendChild(nodeView);
129
142
  } else {
130
143
  // Fallback to fragment serialization
@@ -170,13 +183,15 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
170
183
  originalDoc = _ref.originalDoc,
171
184
  newDoc = _ref.newDoc,
172
185
  nodeViewSerializer = _ref.nodeViewSerializer,
173
- colorScheme = _ref.colorScheme;
186
+ colorScheme = _ref.colorScheme,
187
+ _ref$isInserted = _ref.isInserted,
188
+ isInserted = _ref$isInserted === void 0 ? false : _ref$isInserted;
174
189
  // First, expand the changes to include complete deleted rows
175
190
  var changedRows = expandDiffForChangedRows(changes.filter(function (change) {
176
191
  return change.deleted.length > 0;
177
192
  }), originalDoc, newDoc);
178
193
  return changedRows.map(function (changedRow) {
179
- var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme);
194
+ var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted);
180
195
 
181
196
  // Find safe insertion position for the deleted row
182
197
  var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, changedRow.fromB - 1,
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createInlineChangedDecoration = void 0;
7
7
  var _view = require("@atlaskit/editor-prosemirror/view");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  var _standard = require("./colorSchemes/standard");
9
10
  var _traditional = require("./colorSchemes/traditional");
10
11
  /**
@@ -13,16 +14,35 @@ var _traditional = require("./colorSchemes/traditional");
13
14
  * @param change Changeset "change" containing information about the change content + range
14
15
  * @returns Prosemirror inline decoration
15
16
  */
17
+
16
18
  var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(_ref) {
17
19
  var change = _ref.change,
18
20
  colorScheme = _ref.colorScheme,
19
21
  _ref$isActive = _ref.isActive,
20
- isActive = _ref$isActive === void 0 ? false : _ref$isActive;
22
+ isActive = _ref$isActive === void 0 ? false : _ref$isActive,
23
+ _ref$isInserted = _ref.isInserted,
24
+ isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted;
21
25
  var style;
22
- if (colorScheme === 'traditional') {
23
- style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
26
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
27
+ if (isInserted) {
28
+ if (colorScheme === 'traditional') {
29
+ style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
30
+ } else {
31
+ style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
32
+ }
33
+ } else {
34
+ if (colorScheme === 'traditional') {
35
+ style = _traditional.deletedTraditionalContentStyle;
36
+ } else {
37
+ style = isActive ? _standard.deletedContentStyleActive : _standard.deletedContentStyle;
38
+ }
39
+ }
24
40
  } else {
25
- style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
41
+ if (colorScheme === 'traditional') {
42
+ style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
43
+ } else {
44
+ style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
45
+ }
26
46
  }
27
47
  return _view.Decoration.inline(change.fromB, change.toB, {
28
48
  style: style,
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createNodeChangedDecorationWidget = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
9
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
8
10
  var _view = require("@atlaskit/editor-prosemirror/view");
9
11
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
@@ -15,6 +17,19 @@ var _wrapBlockNodeView = require("./utils/wrapBlockNodeView");
15
17
  var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
16
18
  return colorScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
17
19
  };
20
+ var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
21
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
22
+ if (colorScheme === 'traditional') {
23
+ if (isActive) {
24
+ return _traditional.traditionalInsertStyleActive;
25
+ }
26
+ return _traditional.traditionalInsertStyle;
27
+ }
28
+ if (isActive) {
29
+ return _standard.editingStyleActive;
30
+ }
31
+ return _standard.editingStyle;
32
+ };
18
33
  var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
19
34
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
20
35
  if (colorScheme === 'traditional') {
@@ -34,28 +49,66 @@ var createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapper
34
49
  wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
35
50
  return wrapper;
36
51
  };
52
+
53
+ /**
54
+ * CSS backgrounds don't work when applied to a wrapper around a paragraph, so
55
+ * the wrapper needs to be injected inside the node around the child content
56
+ */
57
+ var injectInnerWrapper = function injectInnerWrapper(_ref) {
58
+ var node = _ref.node,
59
+ colorScheme = _ref.colorScheme,
60
+ isActive = _ref.isActive,
61
+ isInserted = _ref.isInserted;
62
+ var wrapper = document.createElement('span');
63
+ wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
64
+ (0, _toConsumableArray2.default)(node.childNodes).forEach(function (child) {
65
+ var removedChild = node.removeChild(child);
66
+ wrapper.append(removedChild);
67
+ });
68
+ node.appendChild(wrapper);
69
+ return node;
70
+ };
37
71
  var createContentWrapper = function createContentWrapper(colorScheme) {
38
72
  var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
73
+ var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
39
74
  var wrapper = document.createElement('span');
40
75
  var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
41
76
  position: 'relative',
42
77
  width: 'fit-content'
43
78
  });
44
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
45
- var strikethrough = document.createElement('span');
46
- strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
47
- wrapper.append(strikethrough);
79
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
80
+ if (isInserted) {
81
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
82
+ } else {
83
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
84
+ var strikethrough = document.createElement('span');
85
+ strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
86
+ wrapper.append(strikethrough);
87
+ }
88
+ } else {
89
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
90
+ var _strikethrough = document.createElement('span');
91
+ _strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
92
+ wrapper.append(_strikethrough);
93
+ }
48
94
  return wrapper;
49
95
  };
50
- var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
51
- var change = _ref.change,
52
- doc = _ref.doc,
53
- nodeViewSerializer = _ref.nodeViewSerializer,
54
- colorScheme = _ref.colorScheme,
55
- newDoc = _ref.newDoc,
56
- intl = _ref.intl,
57
- _ref$isActive = _ref.isActive,
58
- isActive = _ref$isActive === void 0 ? false : _ref$isActive;
96
+
97
+ /**
98
+ * This function is used to create a decoration widget to show content
99
+ * that is not in the current document.
100
+ */
101
+ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
102
+ var change = _ref2.change,
103
+ doc = _ref2.doc,
104
+ nodeViewSerializer = _ref2.nodeViewSerializer,
105
+ colorScheme = _ref2.colorScheme,
106
+ newDoc = _ref2.newDoc,
107
+ intl = _ref2.intl,
108
+ _ref2$isActive = _ref2.isActive,
109
+ isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
110
+ _ref2$isInserted = _ref2.isInserted,
111
+ isInserted = _ref2$isInserted === void 0 ? false : _ref2$isInserted;
59
112
  var slice = doc.slice(change.fromA, change.toA);
60
113
  if (slice.content.content.length === 0) {
61
114
  return;
@@ -79,7 +132,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
79
132
  originalDoc: doc,
80
133
  newDoc: newDoc,
81
134
  nodeViewSerializer: nodeViewSerializer,
82
- colorScheme: colorScheme
135
+ colorScheme: colorScheme,
136
+ isInserted: isInserted
83
137
  });
84
138
  }
85
139
  var serializer = nodeViewSerializer;
@@ -101,14 +155,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
101
155
  if (childNodeView) {
102
156
  var lineBreak = document.createElement('br');
103
157
  dom.append(lineBreak);
104
- var wrapper = createContentWrapper(colorScheme, isActive);
158
+ var wrapper = createContentWrapper(colorScheme, isActive, isInserted);
105
159
  wrapper.append(childNodeView);
106
160
  dom.append(wrapper);
107
161
  } else {
108
162
  // Fallback to serializing the individual child node
109
163
  var serializedChild = serializer.serializeNode(childNode);
110
164
  if (serializedChild) {
111
- var _wrapper = createContentWrapper(colorScheme, isActive);
165
+ var _wrapper = createContentWrapper(colorScheme, isActive, isInserted);
112
166
  _wrapper.append(serializedChild);
113
167
  dom.append(_wrapper);
114
168
  }
@@ -153,7 +207,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
153
207
  var nodeView = serializer.tryCreateNodeView(node);
154
208
  if (nodeView) {
155
209
  if (node.isInline) {
156
- var wrapper = createContentWrapper(colorScheme, isActive);
210
+ var wrapper = createContentWrapper(colorScheme, isActive, isInserted);
157
211
  wrapper.append(nodeView);
158
212
  dom.append(wrapper);
159
213
  } else {
@@ -163,7 +217,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
163
217
  nodeView: nodeView,
164
218
  targetNode: node,
165
219
  colorScheme: colorScheme,
166
- intl: intl
220
+ intl: intl,
221
+ isInserted: isInserted
167
222
  });
168
223
  }
169
224
  } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
@@ -172,9 +227,25 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
172
227
  } else {
173
228
  var fallbackNode = fallbackSerialization();
174
229
  if (fallbackNode) {
175
- var _wrapper2 = createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive);
176
- _wrapper2.append(fallbackNode);
177
- dom.append(_wrapper2);
230
+ if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
231
+ if (fallbackNode instanceof HTMLElement) {
232
+ var injectedNode = injectInnerWrapper({
233
+ node: fallbackNode,
234
+ colorScheme: colorScheme,
235
+ isActive: isActive,
236
+ isInserted: isInserted
237
+ });
238
+ dom.append(injectedNode);
239
+ } else {
240
+ var _wrapper2 = createContentWrapper(colorScheme, isActive, isInserted);
241
+ _wrapper2.append(fallbackNode);
242
+ dom.append(_wrapper2);
243
+ }
244
+ } else {
245
+ var _wrapper3 = createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive);
246
+ _wrapper3.append(fallbackNode);
247
+ dom.append(_wrapper3);
248
+ }
178
249
  }
179
250
  }
180
251
  });