@atlaskit/editor-plugin-show-diff 4.1.2 → 4.1.3

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.
@@ -2,38 +2,11 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { getStandardNodeStyle, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, editingStyle, editingStyleActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
6
+ import { getTraditionalNodeStyle, deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded, traditionalInsertStyle, traditionalInsertStyleActive } from './colorSchemes/traditional';
5
7
  import { createDeletedStyleWrapperWithoutOpacity, handleBlockNodeView } from './deletedBlocksHandler';
6
8
  import { handleDeletedRows } from './deletedRowsHandler';
7
9
  import { findSafeInsertPos } from './findSafeInsertPos';
8
- var editingStyle = convertToInlineCss({
9
- background: "var(--ds-background-accent-purple-subtlest, #F8EEFE)",
10
- textDecoration: 'underline',
11
- textDecorationStyle: 'dotted',
12
- textDecorationThickness: "var(--ds-space-025, 2px)",
13
- textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
14
- });
15
- var editingStyleActive = convertToInlineCss({
16
- background: "var(--ds-background-accent-purple-subtler, #EED7FC)",
17
- textDecoration: 'underline',
18
- textDecorationStyle: 'dotted',
19
- textDecorationThickness: "var(--ds-space-025, 2px)",
20
- textDecorationColor: "var(--ds-text-accent-purple, #803FA5)"
21
- });
22
- var traditionalInsertStyle = convertToInlineCss({
23
- background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
24
- textDecoration: 'underline',
25
- textDecorationStyle: 'solid',
26
- textDecorationThickness: "var(--ds-space-025, 2px)",
27
- textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
28
- });
29
- var traditionalInsertStyleActive = convertToInlineCss({
30
- background: "var(--ds-background-accent-green-subtler, #BAF3DB)",
31
- textDecoration: 'underline',
32
- textDecorationStyle: 'solid',
33
- textDecorationThickness: "var(--ds-space-025, 2px)",
34
- textDecorationColor: "var(--ds-text-accent-green, #216E4E)"
35
- });
36
-
37
10
  /**
38
11
  * Inline decoration used for insertions as the content already exists in the document
39
12
  *
@@ -53,124 +26,6 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
53
26
  'data-testid': 'show-diff-changed-decoration'
54
27
  }, {});
55
28
  };
56
- var getEditorStyleNode = function getEditorStyleNode(nodeName, colourScheme) {
57
- switch (nodeName) {
58
- case 'blockquote':
59
- return colourScheme === 'traditional' ? traditionalStyleQuoteNode : editingStyleQuoteNode;
60
- case 'mediaSingle':
61
- case 'mediaGroup':
62
- case 'table':
63
- case 'tableRow':
64
- case 'tableCell':
65
- case 'tableHeader':
66
- return undefined;
67
- // Handle table separately to avoid border issues
68
- case 'paragraph':
69
- case 'heading':
70
- case 'hardBreak':
71
- return undefined;
72
- // Paragraph and heading nodes do not need special styling
73
- case 'decisionList':
74
- case 'taskList':
75
- case 'taskItem':
76
- case 'bulletList':
77
- case 'orderedList':
78
- return undefined;
79
- case 'extension':
80
- case 'embedCard':
81
- case 'listItem':
82
- return convertToInlineCss({
83
- '--diff-decoration-marker-color': colourScheme === 'traditional' ? "var(--ds-border-accent-green, #22A06B)" : "var(--ds-border-accent-purple, #AF59E1)"
84
- });
85
- case 'layoutSection':
86
- return undefined;
87
- // Layout nodes do not need special styling
88
- case 'rule':
89
- return colourScheme === 'traditional' ? traditionalStyleRuleNode : editingStyleRuleNode;
90
- case 'blockCard':
91
- return colourScheme === 'traditional' ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
92
- default:
93
- return colourScheme === 'traditional' ? traditionalStyleNode : editingStyleNode;
94
- }
95
- };
96
- var editingStyleQuoteNode = convertToInlineCss({
97
- borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)")
98
- });
99
- var traditionalStyleQuoteNode = convertToInlineCss({
100
- borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
101
- });
102
- var editingStyleRuleNode = convertToInlineCss({
103
- backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
104
- });
105
- var traditionalStyleRuleNode = convertToInlineCss({
106
- backgroundColor: "var(--ds-border-accent-green, #22A06B)"
107
- });
108
- var editingStyleNode = convertToInlineCss({
109
- boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
110
- borderRadius: "var(--ds-radius-small, 4px)"
111
- });
112
- var traditionalStyleNode = convertToInlineCss({
113
- boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
114
- borderRadius: "var(--ds-radius-small, 4px)"
115
- });
116
- var editingStyleCardBlockNode = convertToInlineCss({
117
- boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
118
- borderRadius: "var(--ds-radius-medium, 6px)"
119
- });
120
- var traditionalStyleCardBlockNode = convertToInlineCss({
121
- boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
122
- borderRadius: "var(--ds-radius-medium, 6px)"
123
- });
124
- var deletedContentStyle = convertToInlineCss({
125
- color: "var(--ds-text-accent-gray, #505258)",
126
- textDecoration: 'line-through',
127
- position: 'relative',
128
- opacity: 0.6
129
- });
130
- var deletedContentStyleActive = convertToInlineCss({
131
- color: "var(--ds-text, #292A2E)",
132
- textDecoration: 'line-through',
133
- textDecorationColor: "var(--ds-text-accent-gray, #505258)",
134
- position: 'relative',
135
- opacity: 1
136
- });
137
- var deletedContentStyleNew = convertToInlineCss({
138
- color: "var(--ds-text-accent-gray, #505258)",
139
- textDecoration: 'line-through',
140
- position: 'relative',
141
- opacity: 0.8
142
- });
143
- var deletedContentStyleNewActive = convertToInlineCss({
144
- color: "var(--ds-text, #292A2E)",
145
- textDecoration: 'line-through',
146
- textDecorationColor: "var(--ds-text-accent-gray, #505258)",
147
- position: 'relative',
148
- opacity: 1
149
- });
150
- var deletedContentStyleUnbounded = convertToInlineCss({
151
- position: 'absolute',
152
- top: '50%',
153
- width: '100%',
154
- display: 'inline-block',
155
- borderTop: "1px solid ".concat("var(--ds-text-accent-gray, #505258)"),
156
- pointerEvents: 'none',
157
- zIndex: 1
158
- });
159
- var deletedTraditionalContentStyle = convertToInlineCss({
160
- textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
161
- textDecoration: 'line-through',
162
- position: 'relative',
163
- opacity: 1
164
- });
165
- var deletedTraditionalContentStyleUnbounded = convertToInlineCss({
166
- position: 'absolute',
167
- top: '50%',
168
- width: '100%',
169
- display: 'inline-block',
170
- borderTop: "1px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
171
- pointerEvents: 'none',
172
- zIndex: 1
173
- });
174
29
  export var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
175
30
  return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
176
31
  };
@@ -192,6 +47,9 @@ var getNodeClass = function getNodeClass(name) {
192
47
  return undefined;
193
48
  }
194
49
  };
50
+ var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
51
+ return colourScheme === 'traditional' ? getTraditionalNodeStyle(name) : getStandardNodeStyle(name);
52
+ };
195
53
 
196
54
  /**
197
55
  * Inline decoration used for insertions as the content already exists in the document
@@ -201,11 +59,24 @@ var getNodeClass = function getNodeClass(name) {
201
59
  */
202
60
  export var createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
203
61
  return Decoration.node(change.from, change.to, {
204
- style: getEditorStyleNode(change.name, colourScheme),
62
+ style: getBlockNodeStyle(change.name, colourScheme),
205
63
  'data-testid': 'show-diff-changed-decoration-node',
206
64
  class: getNodeClass(change.name)
207
65
  }, {});
208
66
  };
67
+ var createContentWrapper = function createContentWrapper(colourScheme) {
68
+ var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
69
+ var wrapper = document.createElement('span');
70
+ var baseStyle = convertToInlineCss({
71
+ position: 'relative',
72
+ width: 'fit-content'
73
+ });
74
+ wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme, isActive)));
75
+ var strikethrough = document.createElement('span');
76
+ strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
77
+ wrapper.append(strikethrough);
78
+ return wrapper;
79
+ };
209
80
  export var createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
210
81
  var change = _ref.change,
211
82
  doc = _ref.doc,
@@ -251,20 +122,6 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
251
122
  * or sliced End depth is and match only the entire node.
252
123
  */
253
124
  slice.content.forEach(function (node) {
254
- // Create a wrapper for each node with strikethrough
255
- var createWrapperWithStrikethrough = function createWrapperWithStrikethrough() {
256
- var wrapper = document.createElement('span');
257
- var baseStyle = convertToInlineCss({
258
- position: 'relative',
259
- width: 'fit-content'
260
- });
261
- wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme, isActive)));
262
- var strikethrough = document.createElement('span');
263
- strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
264
- wrapper.append(strikethrough);
265
- return wrapper;
266
- };
267
-
268
125
  // Helper function to handle multiple child nodes
269
126
  var handleMultipleChildNodes = function handleMultipleChildNodes(node) {
270
127
  if (node.content.childCount > 1 && node.type.inlineContent) {
@@ -272,16 +129,15 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
272
129
  var childNodeView = serializer.tryCreateNodeView(childNode);
273
130
  if (childNodeView) {
274
131
  var lineBreak = document.createElement('br');
275
- targetNode = node;
276
132
  dom.append(lineBreak);
277
- var wrapper = createWrapperWithStrikethrough();
133
+ var wrapper = createContentWrapper(colourScheme, isActive);
278
134
  wrapper.append(childNodeView);
279
135
  dom.append(wrapper);
280
136
  } else {
281
137
  // Fallback to serializing the individual child node
282
138
  var serializedChild = serializer.serializeNode(childNode);
283
139
  if (serializedChild) {
284
- var _wrapper = createWrapperWithStrikethrough();
140
+ var _wrapper = createContentWrapper(colourScheme, isActive);
285
141
  _wrapper.append(serializedChild);
286
142
  dom.append(_wrapper);
287
143
  }
@@ -296,21 +152,15 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
296
152
  var isFirst = slice.content.firstChild === node;
297
153
  var isLast = slice.content.lastChild === node;
298
154
  var hasInlineContent = node.content.childCount > 0 && node.type.inlineContent === true;
299
- var targetNode;
300
155
  var fallbackSerialization;
156
+ if (handleMultipleChildNodes(node)) {
157
+ return;
158
+ }
301
159
  if ((isFirst || isLast && slice.content.childCount > 2) && hasInlineContent) {
302
- if (handleMultipleChildNodes(node)) {
303
- return;
304
- }
305
- targetNode = node;
306
160
  fallbackSerialization = function fallbackSerialization() {
307
161
  return serializer.serializeFragment(node.content);
308
162
  };
309
163
  } else if (isLast && slice.content.childCount === 2) {
310
- if (handleMultipleChildNodes(node)) {
311
- return;
312
- }
313
- targetNode = node;
314
164
  fallbackSerialization = function fallbackSerialization() {
315
165
  if (node.type.name === 'text') {
316
166
  return document.createTextNode(node.text || '');
@@ -323,27 +173,23 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
323
173
  return serializer.serializeFragment(node.content);
324
174
  };
325
175
  } else {
326
- if (handleMultipleChildNodes(node)) {
327
- return;
328
- }
329
- targetNode = node;
330
176
  fallbackSerialization = function fallbackSerialization() {
331
177
  return serializer.serializeNode(node);
332
178
  };
333
179
  }
334
180
 
335
181
  // Try to create node view, fallback to serialization
336
- var nodeView = serializer.tryCreateNodeView(targetNode);
182
+ var nodeView = serializer.tryCreateNodeView(node);
337
183
  if (nodeView) {
338
- if (targetNode.isInline) {
339
- var wrapper = createWrapperWithStrikethrough();
184
+ if (node.isInline) {
185
+ var wrapper = createContentWrapper(colourScheme, isActive);
340
186
  wrapper.append(nodeView);
341
187
  dom.append(wrapper);
342
188
  } else {
343
189
  // Handle all block nodes with unified function
344
- handleBlockNodeView(dom, nodeView, targetNode, colourScheme, intl);
190
+ handleBlockNodeView(dom, nodeView, node, colourScheme, intl);
345
191
  }
346
- } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(targetNode.type.name)) {
192
+ } else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
347
193
  // Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
348
194
  return;
349
195
  } else {
@@ -0,0 +1,8 @@
1
+ export declare const editingStyle: string;
2
+ export declare const editingStyleActive: string;
3
+ export declare const deletedContentStyle: string;
4
+ export declare const deletedContentStyleActive: string;
5
+ export declare const deletedContentStyleNew: string;
6
+ export declare const deletedContentStyleNewActive: string;
7
+ export declare const deletedContentStyleUnbounded: string;
8
+ export declare const getStandardNodeStyle: (nodeName: string) => string | undefined;
@@ -0,0 +1,5 @@
1
+ export declare const traditionalInsertStyle: string;
2
+ export declare const traditionalInsertStyleActive: string;
3
+ export declare const deletedTraditionalContentStyle: string;
4
+ export declare const deletedTraditionalContentStyleUnbounded: string;
5
+ export declare const getTraditionalNodeStyle: (nodeName: string) => string | undefined;
@@ -0,0 +1,8 @@
1
+ export declare const editingStyle: string;
2
+ export declare const editingStyleActive: string;
3
+ export declare const deletedContentStyle: string;
4
+ export declare const deletedContentStyleActive: string;
5
+ export declare const deletedContentStyleNew: string;
6
+ export declare const deletedContentStyleNewActive: string;
7
+ export declare const deletedContentStyleUnbounded: string;
8
+ export declare const getStandardNodeStyle: (nodeName: string) => string | undefined;
@@ -0,0 +1,5 @@
1
+ export declare const traditionalInsertStyle: string;
2
+ export declare const traditionalInsertStyleActive: string;
3
+ export declare const deletedTraditionalContentStyle: string;
4
+ export declare const deletedTraditionalContentStyleUnbounded: string;
5
+ export declare const getTraditionalNodeStyle: (nodeName: string) => string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,11 +28,11 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^52.0.0",
31
+ "@atlaskit/adf-schema": "^52.1.0",
32
32
  "@atlaskit/editor-prosemirror": "^7.3.0",
33
33
  "@atlaskit/editor-tables": "^2.9.0",
34
34
  "@atlaskit/platform-feature-flags": "^1.1.0",
35
- "@atlaskit/tmp-editor-statsig": "^32.0.0",
35
+ "@atlaskit/tmp-editor-statsig": "^32.10.0",
36
36
  "@atlaskit/tokens": "^11.0.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "lodash": "^4.17.21",
@@ -40,7 +40,7 @@
40
40
  "prosemirror-changeset": "^2.3.1"
41
41
  },
42
42
  "peerDependencies": {
43
- "@atlaskit/editor-common": "^111.20.0",
43
+ "@atlaskit/editor-common": "^111.24.0",
44
44
  "react": "^18.2.0"
45
45
  },
46
46
  "techstack": {