@atlaskit/editor-plugin-show-diff 5.0.4 → 5.0.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 (70) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/pm-plugins/calculateDiffDecorations.js +66 -39
  3. package/dist/cjs/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +32 -30
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +75 -0
  5. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +75 -0
  6. package/dist/cjs/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +34 -61
  7. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +33 -0
  8. package/dist/cjs/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
  9. package/dist/cjs/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  10. package/dist/cjs/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +90 -70
  11. package/dist/es2019/pm-plugins/calculateDiffDecorations.js +41 -13
  12. package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +31 -29
  13. package/dist/es2019/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +28 -29
  14. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +70 -0
  15. package/dist/es2019/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +30 -57
  16. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
  17. package/dist/es2019/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
  18. package/dist/es2019/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  19. package/dist/es2019/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +89 -64
  20. package/dist/esm/pm-plugins/calculateDiffDecorations.js +62 -35
  21. package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/standard.js +31 -29
  22. package/dist/esm/pm-plugins/{colorSchemes → decorations/colorSchemes}/traditional.js +28 -29
  23. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +69 -0
  24. package/dist/esm/pm-plugins/{deletedRowsHandler.js → decorations/createChangedRowDecorationWidgets.js} +32 -59
  25. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +28 -0
  26. package/dist/esm/pm-plugins/{decorations.js → decorations/createNodeChangedDecorationWidget.js} +27 -71
  27. package/dist/esm/pm-plugins/{attributeDecorations.js → decorations/utils/getAttrChangeRanges.js} +1 -1
  28. package/dist/esm/pm-plugins/{deletedBlocksHandler.js → decorations/utils/wrapBlockNodeView.js} +84 -64
  29. package/dist/types/pm-plugins/NodeViewSerializer.d.ts +1 -1
  30. package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -1
  31. package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +17 -0
  32. package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +13 -0
  33. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
  34. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
  35. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
  36. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
  37. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
  38. package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +1 -1
  39. package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -1
  40. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +17 -0
  41. package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +13 -0
  42. package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +16 -0
  43. package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +17 -0
  44. package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +16 -0
  45. package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +15 -0
  46. package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +15 -0
  47. package/package.json +3 -3
  48. package/dist/cjs/pm-plugins/colorSchemes/traditional.js +0 -76
  49. package/dist/types/pm-plugins/colorSchemes/standard.d.ts +0 -8
  50. package/dist/types/pm-plugins/colorSchemes/traditional.d.ts +0 -5
  51. package/dist/types/pm-plugins/decorations.d.ts +0 -39
  52. package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +0 -59
  53. package/dist/types/pm-plugins/deletedRowsHandler.d.ts +0 -30
  54. package/dist/types-ts4.5/pm-plugins/colorSchemes/standard.d.ts +0 -8
  55. package/dist/types-ts4.5/pm-plugins/colorSchemes/traditional.d.ts +0 -5
  56. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -39
  57. package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +0 -59
  58. package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +0 -30
  59. /package/dist/cjs/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  60. /package/dist/cjs/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  61. /package/dist/es2019/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  62. /package/dist/es2019/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  63. /package/dist/esm/pm-plugins/{findSafeInsertPos.js → decorations/utils/findSafeInsertPos.js} +0 -0
  64. /package/dist/esm/pm-plugins/{markDecorations.js → decorations/utils/getMarkChangeRanges.js} +0 -0
  65. /package/dist/types/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
  66. /package/dist/types/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
  67. /package/dist/types/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
  68. /package/dist/types-ts4.5/pm-plugins/{findSafeInsertPos.d.ts → decorations/utils/findSafeInsertPos.d.ts} +0 -0
  69. /package/dist/types-ts4.5/pm-plugins/{attributeDecorations.d.ts → decorations/utils/getAttrChangeRanges.d.ts} +0 -0
  70. /package/dist/types-ts4.5/pm-plugins/{markDecorations.d.ts → decorations/utils/getMarkChangeRanges.d.ts} +0 -0
@@ -1,42 +1,9 @@
1
1
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { trackChangesMessages } from '@atlaskit/editor-common/messages';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
- import { getDeletedContentStyle } from './decorations';
5
- export const deletedStyleQuoteNode = convertToInlineCss({
6
- borderLeft: `2px solid ${"var(--ds-border-accent-gray, #7D818A)"}`
7
- });
8
- export const deletedStyleQuoteNodeWithLozenge = convertToInlineCss({
9
- marginTop: "var(--ds-space-150, 12px)",
10
- paddingTop: "var(--ds-space-025, 2px)",
11
- paddingBottom: "var(--ds-space-025, 2px)",
12
- paddingLeft: "var(--ds-space-025, 2px)",
13
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
14
- borderRadius: "var(--ds-radius-small, 4px)"
15
- });
16
- export const deletedTraditionalStyleQuoteNode = convertToInlineCss({
17
- marginTop: "var(--ds-space-150, 12px)",
18
- paddingTop: "var(--ds-space-025, 2px)",
19
- paddingBottom: "var(--ds-space-025, 2px)",
20
- paddingLeft: "var(--ds-space-025, 2px)",
21
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-red, #E2483D)"}`,
22
- borderRadius: "var(--ds-radius-small, 4px)"
23
- });
24
- export const deletedBlockOutline = convertToInlineCss({
25
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
26
- borderRadius: "var(--ds-radius-small, 4px)"
27
- });
28
- export const deletedTraditionalBlockOutline = convertToInlineCss({
29
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-red, #E2483D)"}`,
30
- borderRadius: "var(--ds-radius-small, 4px)"
31
- });
32
- export const deletedBlockOutlineRounded = convertToInlineCss({
33
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
34
- borderRadius: `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`
35
- });
36
- export const deletedTraditionalBlockOutlineRounded = convertToInlineCss({
37
- boxShadow: `0 0 0 1px ${"var(--ds-border-accent-red, #E2483D)"}`,
38
- borderRadius: `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`
39
- });
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive } from '../colorSchemes/standard';
6
+ import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded, deletedTraditionalContentStyle } from '../colorSchemes/traditional';
40
7
  const lozengeStyle = convertToInlineCss({
41
8
  display: 'inline-flex',
42
9
  boxSizing: 'border-box',
@@ -53,7 +20,16 @@ const lozengeStyle = convertToInlineCss({
53
20
  whiteSpace: 'nowrap',
54
21
  color: "var(--ds-text-warning-inverse, #292A2E)"
55
22
  });
56
- export const getDeletedStyleNode = (nodeName, colorScheme) => {
23
+ const getDeletedContentStyle = (colorScheme, isActive = false) => {
24
+ if (colorScheme === 'traditional') {
25
+ return deletedTraditionalContentStyle;
26
+ }
27
+ if (isActive) {
28
+ return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
29
+ }
30
+ return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
31
+ };
32
+ const getDeletedStyleNode = (nodeName, colorScheme) => {
57
33
  const isTraditional = colorScheme === 'traditional';
58
34
  switch (nodeName) {
59
35
  case 'blockquote':
@@ -68,7 +44,7 @@ export const getDeletedStyleNode = (nodeName, colorScheme) => {
68
44
  return undefined;
69
45
  }
70
46
  };
71
- export const shouldShowRemovedLozenge = nodeName => {
47
+ const shouldShowRemovedLozenge = nodeName => {
72
48
  switch (nodeName) {
73
49
  case 'expand':
74
50
  case 'codeBlock':
@@ -83,7 +59,7 @@ export const shouldShowRemovedLozenge = nodeName => {
83
59
  return false;
84
60
  }
85
61
  };
86
- export const shouldAddShowDiffDeletedNodeClass = nodeName => {
62
+ const shouldAddShowDiffDeletedNodeClass = nodeName => {
87
63
  switch (nodeName) {
88
64
  case 'mediaSingle':
89
65
  case 'embedCard':
@@ -99,14 +75,14 @@ export const shouldAddShowDiffDeletedNodeClass = nodeName => {
99
75
  * Checks if a node should apply deleted styles directly without wrapper
100
76
  * to preserve natural block-level margins
101
77
  */
102
- export const shouldApplyDeletedStylesDirectly = nodeName => {
78
+ const shouldApplyStylesDirectly = nodeName => {
103
79
  return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
104
80
  };
105
81
 
106
82
  /**
107
83
  * Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
108
84
  */
109
- export const createRemovedLozenge = (intl, nodeName) => {
85
+ const createRemovedLozenge = (intl, nodeName) => {
110
86
  const container = document.createElement('span');
111
87
  let borderTopRightRadius;
112
88
  if (['expand', 'decisionList'].includes(nodeName || '')) {
@@ -140,7 +116,7 @@ export const createRemovedLozenge = (intl, nodeName) => {
140
116
  /**
141
117
  * Wraps a block node in a container with relative positioning to support absolute positioned lozenge
142
118
  */
143
- export const createBlockNodeWrapper = () => {
119
+ const createBlockNodeWrapper = () => {
144
120
  const wrapper = document.createElement('div');
145
121
  const baseStyle = convertToInlineCss({
146
122
  position: 'relative',
@@ -152,18 +128,13 @@ export const createBlockNodeWrapper = () => {
152
128
  };
153
129
 
154
130
  /**
155
- * Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
131
+ * Applies styles directly to an HTML element by merging with existing styles
156
132
  */
157
- export const createDeletedStyleWrapperWithoutOpacity = (colorScheme, isActive) => {
158
- const wrapper = document.createElement('span');
159
- wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
160
- return wrapper;
161
- };
162
-
163
- /**
164
- * Applies deleted styles directly to an HTML element by merging with existing styles
165
- */
166
- export const applyDeletedStylesToElement = (element, targetNode, colorScheme) => {
133
+ const applyStylesToElement = ({
134
+ element,
135
+ targetNode,
136
+ colorScheme
137
+ }) => {
167
138
  const currentStyle = element.getAttribute('style') || '';
168
139
  const deletedContentStyle = getDeletedContentStyle(colorScheme);
169
140
  const nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
@@ -173,7 +144,11 @@ export const applyDeletedStylesToElement = (element, targetNode, colorScheme) =>
173
144
  /**
174
145
  * Creates a content wrapper with deleted styles for a block node
175
146
  */
176
- export const createBlockNodeContentWrapper = (nodeView, targetNode, colorScheme) => {
147
+ const createBlockNodeContentWrapper = ({
148
+ nodeView,
149
+ targetNode,
150
+ colorScheme
151
+ }) => {
177
152
  const contentWrapper = document.createElement('div');
178
153
  const nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
179
154
  contentWrapper.setAttribute('style', `${getDeletedContentStyle(colorScheme)}${nodeStyle || ''}`);
@@ -187,7 +162,13 @@ export const createBlockNodeContentWrapper = (nodeView, targetNode, colorScheme)
187
162
  * to wait for the rich-media-item to appear before attaching the lozenge.
188
163
  * @returns true if embedCard was handled
189
164
  */
190
- export const handleEmbedCardWithLozenge = (dom, nodeView, targetNode, lozenge, colorScheme) => {
165
+ const handleEmbedCardWithLozenge = ({
166
+ dom,
167
+ nodeView,
168
+ targetNode,
169
+ lozenge,
170
+ colorScheme
171
+ }) => {
191
172
  if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
192
173
  return false;
193
174
  }
@@ -219,7 +200,13 @@ export const handleEmbedCardWithLozenge = (dom, nodeView, targetNode, lozenge, c
219
200
  * Handles special mediaSingle node rendering with lozenge on child media element
220
201
  * @returns true if mediaSingle was handled, false otherwise
221
202
  */
222
- export const handleMediaSingleWithLozenge = (dom, nodeView, targetNode, lozenge, colorScheme) => {
203
+ const handleMediaSingleWithLozenge = ({
204
+ dom,
205
+ nodeView,
206
+ targetNode,
207
+ lozenge,
208
+ colorScheme
209
+ }) => {
223
210
  if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
224
211
  return false;
225
212
  }
@@ -248,19 +235,41 @@ export const handleMediaSingleWithLozenge = (dom, nodeView, targetNode, lozenge,
248
235
  /**
249
236
  * Appends a block node with wrapper, lozenge, and appropriate styling
250
237
  */
251
- export const appendBlockNodeWithWrapper = (dom, nodeView, targetNode, colorScheme, intl) => {
238
+ const wrapBlockNode = ({
239
+ dom,
240
+ nodeView,
241
+ targetNode,
242
+ colorScheme,
243
+ intl
244
+ }) => {
252
245
  const blockWrapper = createBlockNodeWrapper();
253
246
  if (shouldShowRemovedLozenge(targetNode.type.name)) {
254
247
  const lozenge = createRemovedLozenge(intl);
255
- if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
248
+ if (handleEmbedCardWithLozenge({
249
+ dom,
250
+ nodeView,
251
+ targetNode,
252
+ lozenge,
253
+ colorScheme
254
+ }) && fg('platform_editor_ai_aifc_patch_ga_blockers')) {
256
255
  return;
257
256
  }
258
- if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme)) {
257
+ if (handleMediaSingleWithLozenge({
258
+ dom,
259
+ nodeView,
260
+ targetNode,
261
+ lozenge,
262
+ colorScheme
263
+ })) {
259
264
  return;
260
265
  }
261
266
  blockWrapper.append(lozenge);
262
267
  }
263
- const contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colorScheme);
268
+ const contentWrapper = createBlockNodeContentWrapper({
269
+ nodeView,
270
+ targetNode,
271
+ colorScheme
272
+ });
264
273
  blockWrapper.append(contentWrapper);
265
274
  if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
266
275
  const showDiffDeletedNodeClass = colorScheme === 'traditional' && fg('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
@@ -274,13 +283,29 @@ export const appendBlockNodeWithWrapper = (dom, nodeView, targetNode, colorSchem
274
283
  * For heading nodes, applies styles directly to preserve natural margins.
275
284
  * For other block nodes, uses wrapper approach with optional lozenge.
276
285
  */
277
- export const handleBlockNodeView = (dom, nodeView, targetNode, colorScheme, intl) => {
278
- if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
286
+ export const wrapBlockNodeView = ({
287
+ dom,
288
+ nodeView,
289
+ targetNode,
290
+ colorScheme,
291
+ intl
292
+ }) => {
293
+ if (shouldApplyStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
279
294
  // Apply deleted styles directly to preserve natural block-level margins
280
- applyDeletedStylesToElement(nodeView, targetNode, colorScheme);
295
+ applyStylesToElement({
296
+ element: nodeView,
297
+ targetNode,
298
+ colorScheme
299
+ });
281
300
  dom.append(nodeView);
282
301
  } else {
283
302
  // Use wrapper approach for other block nodes
284
- appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl);
303
+ wrapBlockNode({
304
+ dom,
305
+ nodeView,
306
+ targetNode,
307
+ colorScheme,
308
+ intl
309
+ });
285
310
  }
286
311
  };
@@ -12,20 +12,29 @@ import memoizeOne from 'memoize-one';
12
12
  import { ChangeSet, simplifyChanges } from 'prosemirror-changeset';
13
13
  import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
14
14
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
15
- import { getAttrChangeRanges, stepIsValidAttrChange } from './attributeDecorations';
16
- import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
17
- import { getMarkChangeRanges } from './markDecorations';
15
+ import { createBlockChangedDecoration } from './decorations/createBlockChangedDecoration';
16
+ import { createInlineChangedDecoration } from './decorations/createInlineChangedDecoration';
17
+ import { createNodeChangedDecorationWidget } from './decorations/createNodeChangedDecorationWidget';
18
+ import { getAttrChangeRanges, stepIsValidAttrChange } from './decorations/utils/getAttrChangeRanges';
19
+ import { getMarkChangeRanges } from './decorations/utils/getMarkChangeRanges';
18
20
  import { simplifySteps } from './simplifyChanges';
19
- var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to, colorScheme) {
21
+ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref) {
22
+ var doc = _ref.doc,
23
+ from = _ref.from,
24
+ to = _ref.to,
25
+ colorScheme = _ref.colorScheme;
20
26
  var decorations = [];
21
27
  // Iterate over the document nodes within the range
22
28
  doc.nodesBetween(from, to, function (node, pos) {
23
29
  if (node.isBlock) {
24
30
  var decoration = createBlockChangedDecoration({
25
- from: pos,
26
- to: pos + node.nodeSize,
27
- name: node.type.name
28
- }, colorScheme);
31
+ change: {
32
+ from: pos,
33
+ to: pos + node.nodeSize,
34
+ name: node.type.name
35
+ },
36
+ colorScheme: colorScheme
37
+ });
29
38
  if (decoration) {
30
39
  decorations.push(decoration);
31
40
  }
@@ -66,13 +75,13 @@ function optimizeChanges(changes) {
66
75
  optimized.push(current);
67
76
  return optimized;
68
77
  }
69
- var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref) {
70
- var state = _ref.state,
71
- pluginState = _ref.pluginState,
72
- nodeViewSerializer = _ref.nodeViewSerializer,
73
- colorScheme = _ref.colorScheme,
74
- intl = _ref.intl,
75
- activeIndexPos = _ref.activeIndexPos;
78
+ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2) {
79
+ var state = _ref2.state,
80
+ pluginState = _ref2.pluginState,
81
+ nodeViewSerializer = _ref2.nodeViewSerializer,
82
+ colorScheme = _ref2.colorScheme,
83
+ intl = _ref2.intl,
84
+ activeIndexPos = _ref2.activeIndexPos;
76
85
  var originalDoc = pluginState.originalDoc,
77
86
  steps = pluginState.steps;
78
87
  if (!originalDoc || !pluginState.isDisplayingChanges) {
@@ -115,12 +124,21 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
115
124
  optimizedChanges.forEach(function (change) {
116
125
  var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
117
126
  if (change.inserted.length > 0) {
118
- decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
119
- decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
127
+ decorations.push(createInlineChangedDecoration({
128
+ change: change,
129
+ colorScheme: colorScheme,
130
+ isActive: isActive
131
+ }));
132
+ decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration({
133
+ doc: tr.doc,
134
+ from: change.fromB,
135
+ to: change.toB,
136
+ colorScheme: colorScheme
137
+ })));
120
138
  }
121
139
  if (change.deleted.length > 0) {
122
140
  var _isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
123
- var decoration = createDeletedContentDecoration({
141
+ var decoration = createNodeChangedDecorationWidget({
124
142
  change: change,
125
143
  doc: originalDoc,
126
144
  nodeViewSerializer: nodeViewSerializer,
@@ -136,31 +154,40 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
136
154
  });
137
155
  getMarkChangeRanges(steps).forEach(function (change) {
138
156
  var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
139
- decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
157
+ decorations.push(createInlineChangedDecoration({
158
+ change: change,
159
+ colorScheme: colorScheme,
160
+ isActive: isActive
161
+ }));
140
162
  });
141
163
  getAttrChangeRanges(tr.doc, attrSteps).forEach(function (change) {
142
- decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
164
+ decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration({
165
+ doc: tr.doc,
166
+ from: change.fromB,
167
+ to: change.toB,
168
+ colorScheme: colorScheme
169
+ })));
143
170
  });
144
171
  return DecorationSet.empty.add(tr.doc, decorations);
145
172
  };
146
173
  export var calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
147
174
  // Cache results unless relevant inputs change
148
- function (_ref2, _ref3) {
149
- var _ref6;
150
- var _ref4 = _slicedToArray(_ref2, 1),
151
- _ref4$ = _ref4[0],
152
- pluginState = _ref4$.pluginState,
153
- state = _ref4$.state,
154
- colorScheme = _ref4$.colorScheme,
155
- intl = _ref4$.intl,
156
- activeIndexPos = _ref4$.activeIndexPos;
175
+ function (_ref3, _ref4) {
176
+ var _ref7;
157
177
  var _ref5 = _slicedToArray(_ref3, 1),
158
178
  _ref5$ = _ref5[0],
159
- lastPluginState = _ref5$.pluginState,
160
- lastState = _ref5$.state,
161
- lastColorScheme = _ref5$.colorScheme,
162
- lastIntl = _ref5$.intl,
163
- lastActiveIndexPos = _ref5$.activeIndexPos;
179
+ pluginState = _ref5$.pluginState,
180
+ state = _ref5$.state,
181
+ colorScheme = _ref5$.colorScheme,
182
+ intl = _ref5$.intl,
183
+ activeIndexPos = _ref5$.activeIndexPos;
184
+ var _ref6 = _slicedToArray(_ref4, 1),
185
+ _ref6$ = _ref6[0],
186
+ lastPluginState = _ref6$.pluginState,
187
+ lastState = _ref6$.state,
188
+ lastColorScheme = _ref6$.colorScheme,
189
+ lastIntl = _ref6$.intl,
190
+ lastActiveIndexPos = _ref6$.activeIndexPos;
164
191
  var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
165
- return (_ref6 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref6 !== void 0 ? _ref6 : false;
192
+ return (_ref7 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref7 !== void 0 ? _ref7 : false;
166
193
  });
@@ -48,43 +48,45 @@ export var deletedContentStyleUnbounded = convertToInlineCss({
48
48
  pointerEvents: 'none',
49
49
  zIndex: 1
50
50
  });
51
- var editingStyleQuoteNode = convertToInlineCss({
51
+ export var deletedStyleQuoteNode = convertToInlineCss({
52
+ borderLeft: "2px solid ".concat("var(--ds-border-accent-gray, #7D818A)")
53
+ });
54
+ export var deletedStyleQuoteNodeWithLozenge = convertToInlineCss({
55
+ marginTop: "var(--ds-space-150, 12px)",
56
+ paddingTop: "var(--ds-space-025, 2px)",
57
+ paddingBottom: "var(--ds-space-025, 2px)",
58
+ paddingLeft: "var(--ds-space-025, 2px)",
59
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
60
+ borderRadius: "var(--ds-radius-small, 4px)"
61
+ });
62
+ export var deletedBlockOutline = convertToInlineCss({
63
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
64
+ borderRadius: "var(--ds-radius-small, 4px)"
65
+ });
66
+ export var deletedBlockOutlineRounded = convertToInlineCss({
67
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-gray, #7D818A)"),
68
+ borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
69
+ });
70
+ export var deletedRowStyle = convertToInlineCss({
71
+ color: "var(--ds-text-accent-gray, #505258)",
72
+ textDecoration: 'line-through',
73
+ opacity: 0.6,
74
+ display: 'table-row'
75
+ });
76
+ export var editingStyleQuoteNode = convertToInlineCss({
52
77
  borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)")
53
78
  });
54
- var editingStyleRuleNode = convertToInlineCss({
79
+ export var editingStyleRuleNode = convertToInlineCss({
55
80
  backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
56
81
  });
57
- var editingStyleNode = convertToInlineCss({
82
+ export var editingStyleNode = convertToInlineCss({
58
83
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
59
84
  borderRadius: "var(--ds-radius-small, 4px)"
60
85
  });
61
- var editingStyleCardBlockNode = convertToInlineCss({
86
+ export var editingStyleCardBlockNode = convertToInlineCss({
62
87
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
63
88
  borderRadius: "var(--ds-radius-medium, 6px)"
64
89
  });
65
- var standardDecorationMarkerVariableName = convertToInlineCss({
90
+ export var standardDecorationMarkerVariable = convertToInlineCss({
66
91
  '--diff-decoration-marker-color': "var(--ds-border-accent-purple, #AF59E1)"
67
- });
68
- export var getStandardNodeStyle = function getStandardNodeStyle(nodeName) {
69
- if (['mediaSingle', 'mediaGroup', 'table',
70
- // Handle table separately to avoid border issues
71
- 'tableRow', 'tableCell', 'tableHeader', 'paragraph',
72
- // Paragraph and heading nodes do not need special styling
73
- 'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
74
- // Layout nodes do not need special styling
75
- return undefined;
76
- }
77
- if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
78
- return standardDecorationMarkerVariableName;
79
- }
80
- if (nodeName === 'blockquote') {
81
- return editingStyleQuoteNode;
82
- }
83
- if (nodeName === 'rule') {
84
- return editingStyleRuleNode;
85
- }
86
- if (nodeName === 'blockCard') {
87
- return editingStyleCardBlockNode;
88
- }
89
- return editingStyleNode;
90
- };
92
+ });
@@ -28,43 +28,42 @@ export var deletedTraditionalContentStyleUnbounded = convertToInlineCss({
28
28
  pointerEvents: 'none',
29
29
  zIndex: 1
30
30
  });
31
- var traditionalStyleQuoteNode = convertToInlineCss({
31
+ export var deletedTraditionalStyleQuoteNode = convertToInlineCss({
32
+ marginTop: "var(--ds-space-150, 12px)",
33
+ paddingTop: "var(--ds-space-025, 2px)",
34
+ paddingBottom: "var(--ds-space-025, 2px)",
35
+ paddingLeft: "var(--ds-space-025, 2px)",
36
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
37
+ borderRadius: "var(--ds-radius-small, 4px)"
38
+ });
39
+ export var deletedTraditionalBlockOutline = convertToInlineCss({
40
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
41
+ borderRadius: "var(--ds-radius-small, 4px)"
42
+ });
43
+ export var deletedTraditionalBlockOutlineRounded = convertToInlineCss({
44
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-red, #E2483D)"),
45
+ borderRadius: "calc(".concat("var(--ds-radius-xsmall, 2px)", " + 1px)")
46
+ });
47
+ export var deletedTraditionalRowStyle = convertToInlineCss({
48
+ textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
49
+ textDecoration: 'line-through',
50
+ opacity: 0.6,
51
+ display: 'table-row'
52
+ });
53
+ export var traditionalStyleQuoteNode = convertToInlineCss({
32
54
  borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
33
55
  });
34
- var traditionalStyleRuleNode = convertToInlineCss({
56
+ export var traditionalStyleRuleNode = convertToInlineCss({
35
57
  backgroundColor: "var(--ds-border-accent-green, #22A06B)"
36
58
  });
37
- var traditionalStyleNode = convertToInlineCss({
59
+ export var traditionalStyleNode = convertToInlineCss({
38
60
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
39
61
  borderRadius: "var(--ds-radius-small, 4px)"
40
62
  });
41
- var traditionalStyleCardBlockNode = convertToInlineCss({
63
+ export var traditionalStyleCardBlockNode = convertToInlineCss({
42
64
  boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
43
65
  borderRadius: "var(--ds-radius-medium, 6px)"
44
66
  });
45
- var traditionalDecorationMarkerVariable = convertToInlineCss({
67
+ export var traditionalDecorationMarkerVariable = convertToInlineCss({
46
68
  '--diff-decoration-marker-color': "var(--ds-border-accent-green, #22A06B)"
47
- });
48
- export var getTraditionalNodeStyle = function getTraditionalNodeStyle(nodeName) {
49
- if (['mediaSingle', 'mediaGroup', 'table',
50
- // Handle table separately to avoid border issues
51
- 'tableRow', 'tableCell', 'tableHeader', 'paragraph',
52
- // Paragraph and heading nodes do not need special styling
53
- 'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
54
- // Layout nodes do not need special styling
55
- return undefined;
56
- }
57
- if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
58
- return traditionalDecorationMarkerVariable;
59
- }
60
- if (nodeName === 'blockquote') {
61
- return traditionalStyleQuoteNode;
62
- }
63
- if (nodeName === 'rule') {
64
- return traditionalStyleRuleNode;
65
- }
66
- if (nodeName === 'blockCard') {
67
- return traditionalStyleCardBlockNode;
68
- }
69
- return traditionalStyleNode;
70
- };
69
+ });
@@ -0,0 +1,69 @@
1
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode } from './colorSchemes/standard';
4
+ import { traditionalDecorationMarkerVariable, traditionalStyleQuoteNode, traditionalStyleRuleNode, traditionalStyleCardBlockNode, traditionalStyleNode } from './colorSchemes/traditional';
5
+ var getNodeClass = function getNodeClass(name) {
6
+ switch (name) {
7
+ case 'extension':
8
+ return 'show-diff-changed-decoration-node';
9
+ default:
10
+ return undefined;
11
+ }
12
+ };
13
+ var getBlockNodeStyle = function getBlockNodeStyle(nodeName, colorScheme) {
14
+ var isTraditional = colorScheme === 'traditional';
15
+ if (['mediaSingle', 'mediaGroup', 'table',
16
+ // Handle table separately to avoid border issues
17
+ 'tableRow', 'tableCell', 'tableHeader', 'paragraph',
18
+ // Paragraph and heading nodes do not need special styling
19
+ 'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
20
+ // Layout nodes do not need special styling
21
+ return undefined;
22
+ }
23
+ if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
24
+ return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
25
+ }
26
+ if (nodeName === 'blockquote') {
27
+ return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
28
+ }
29
+ if (nodeName === 'rule') {
30
+ return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
31
+ }
32
+ if (nodeName === 'blockCard') {
33
+ return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
34
+ }
35
+ return isTraditional ? traditionalStyleNode : editingStyleNode;
36
+ };
37
+
38
+ /**
39
+ * Inline decoration used for insertions as the content already exists in the document
40
+ *
41
+ * @param change Changeset "change" containing information about the change content + range
42
+ * @returns Prosemirror inline decoration
43
+ */
44
+ export var createBlockChangedDecoration = function createBlockChangedDecoration(_ref) {
45
+ var change = _ref.change,
46
+ colorScheme = _ref.colorScheme;
47
+ if (fg('platform_editor_show_diff_scroll_navigation')) {
48
+ var style = getBlockNodeStyle(change.name, colorScheme);
49
+ var className = getNodeClass(change.name);
50
+ if (style || className) {
51
+ return Decoration.node(change.from, change.to, {
52
+ style: style,
53
+ 'data-testid': 'show-diff-changed-decoration-node',
54
+ class: className
55
+ }, {
56
+ key: 'diff-block'
57
+ });
58
+ }
59
+ return undefined;
60
+ } else {
61
+ return Decoration.node(change.from, change.to, {
62
+ style: getBlockNodeStyle(change.name, colorScheme),
63
+ 'data-testid': 'show-diff-changed-decoration-node',
64
+ class: getNodeClass(change.name)
65
+ }, {
66
+ key: 'diff-block'
67
+ });
68
+ }
69
+ };