@atlaskit/editor-plugin-show-diff 8.4.5 → 8.4.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.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +13 -27
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +12 -34
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +30 -32
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +5 -9
- package/dist/cjs/pm-plugins/main.js +13 -18
- package/dist/cjs/showDiffPlugin.js +1 -3
- package/dist/es2019/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +15 -27
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -32
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +24 -26
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +6 -10
- package/dist/es2019/pm-plugins/main.js +13 -18
- package/dist/es2019/showDiffPlugin.js +1 -3
- package/dist/esm/pm-plugins/areDocsEqualByBlockStructureAndText.js +6 -10
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +13 -20
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +14 -27
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +12 -34
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +30 -32
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +6 -10
- package/dist/esm/pm-plugins/main.js +13 -18
- package/dist/esm/showDiffPlugin.js +1 -3
- package/package.json +4 -11
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
6
|
-
import {
|
|
5
|
+
import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
7
6
|
const displayNoneStyle = convertToInlineCss({
|
|
8
7
|
display: 'none'
|
|
9
8
|
});
|
|
@@ -26,7 +25,7 @@ const getBlockNodeStyle = ({
|
|
|
26
25
|
// Handle table separately to avoid border issues
|
|
27
26
|
'tableRow', 'paragraph',
|
|
28
27
|
// Paragraph and heading nodes do not need special styling
|
|
29
|
-
'heading', 'hardBreak', 'decisionList', 'taskList',
|
|
28
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
30
29
|
// Layout nodes do not need special styling
|
|
31
30
|
return undefined;
|
|
32
31
|
}
|
|
@@ -43,51 +42,51 @@ const getBlockNodeStyle = ({
|
|
|
43
42
|
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
44
43
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
45
44
|
if (isInserted) {
|
|
46
|
-
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ?
|
|
45
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
|
|
47
46
|
} else {
|
|
48
|
-
return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ?
|
|
47
|
+
return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ? traditionalDeletedDecorationMarkerVariableNew : deletedContentStyleNew;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ?
|
|
50
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
|
|
52
51
|
}
|
|
53
52
|
if (nodeName === 'blockquote') {
|
|
54
53
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
55
54
|
if (isInserted) {
|
|
56
|
-
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive :
|
|
55
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
|
|
57
56
|
} else {
|
|
58
57
|
return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNode;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive :
|
|
60
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
|
|
62
61
|
}
|
|
63
62
|
if (nodeName === 'rule') {
|
|
64
63
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
65
64
|
if (isInserted) {
|
|
66
|
-
return isTraditional ? isActive ? traditionalStyleRuleNodeActive :
|
|
65
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
|
|
67
66
|
} else {
|
|
68
67
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
return isTraditional ? isActive ? traditionalStyleRuleNodeActive :
|
|
70
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
|
|
72
71
|
}
|
|
73
72
|
if (nodeName === 'blockCard') {
|
|
74
73
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
75
74
|
if (isInserted) {
|
|
76
|
-
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive :
|
|
75
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
|
|
77
76
|
} else {
|
|
78
77
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive :
|
|
80
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
|
|
82
81
|
}
|
|
83
82
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
84
83
|
if (isInserted) {
|
|
85
|
-
return isTraditional ? isActive ? traditionalStyleNodeActive :
|
|
84
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
|
|
86
85
|
} else {
|
|
87
86
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
|
-
return isTraditional ? isActive ? traditionalStyleNodeActive :
|
|
89
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
/**
|
|
@@ -140,20 +139,9 @@ export const createBlockChangedDecoration = ({
|
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
const className = getNodeClass(change.name);
|
|
143
|
-
if (
|
|
144
|
-
if (style || className) {
|
|
145
|
-
decorations.push(Decoration.node(change.from, change.to, {
|
|
146
|
-
style: style,
|
|
147
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
148
|
-
class: className
|
|
149
|
-
}, {
|
|
150
|
-
key: 'diff-block',
|
|
151
|
-
nodeName: change.name
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
142
|
+
if (style || className) {
|
|
155
143
|
decorations.push(Decoration.node(change.from, change.to, {
|
|
156
|
-
style,
|
|
144
|
+
style: style,
|
|
157
145
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
158
146
|
class: className
|
|
159
147
|
}, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentBackground } from './colorSchemes/standard';
|
|
6
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
|
|
@@ -42,21 +41,6 @@ const getDeletedContentStyle = (colorScheme, isActive = false) => {
|
|
|
42
41
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
/**
|
|
46
|
-
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
47
|
-
*/
|
|
48
|
-
const createDeletedStyleWrapperWithoutOpacity = (colorScheme, isActive) => {
|
|
49
|
-
const wrapper = document.createElement('span');
|
|
50
|
-
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
51
|
-
wrapper.setAttribute('style',
|
|
52
|
-
// Merge into existing styles when cleaning up
|
|
53
|
-
getDeletedContentStyle(colorScheme, isActive) + deletedInlineContentBackground);
|
|
54
|
-
} else {
|
|
55
|
-
wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
|
|
56
|
-
}
|
|
57
|
-
return wrapper;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
44
|
/**
|
|
61
45
|
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
62
46
|
* the wrapper needs to be injected inside the node around the child content
|
|
@@ -117,7 +101,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
117
101
|
}) => {
|
|
118
102
|
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first;
|
|
119
103
|
const slice = doc.slice(change.fromA, change.toA);
|
|
120
|
-
const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice === null || slice === void 0 ? void 0 : (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.childCount) === 1 && (slice === null || slice === void 0 ? void 0 : (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : (_slice$content2$first = _slice$content2.firstChild) === null || _slice$content2$first === void 0 ? void 0 : _slice$content2$first.type.name) === 'paragraph' && (slice === null || slice === void 0 ? void 0 : (_slice$content3 = slice.content) === null || _slice$content3 === void 0 ? void 0 : (_slice$content3$first = _slice$content3.firstChild) === null || _slice$content3$first === void 0 ? void 0 : _slice$content3$first.content.size) === 0
|
|
104
|
+
const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice === null || slice === void 0 ? void 0 : (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.childCount) === 1 && (slice === null || slice === void 0 ? void 0 : (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : (_slice$content2$first = _slice$content2.firstChild) === null || _slice$content2$first === void 0 ? void 0 : _slice$content2$first.type.name) === 'paragraph' && (slice === null || slice === void 0 ? void 0 : (_slice$content3 = slice.content) === null || _slice$content3 === void 0 ? void 0 : (_slice$content3$first = _slice$content3.firstChild) === null || _slice$content3$first === void 0 ? void 0 : _slice$content3$first.content.size) === 0;
|
|
121
105
|
// Widget decoration used for deletions as the content is not in the document
|
|
122
106
|
// and we want to display the deleted content with a style.
|
|
123
107
|
const safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
|
|
@@ -228,22 +212,16 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
228
212
|
} else {
|
|
229
213
|
const fallbackNode = fallbackSerialization();
|
|
230
214
|
if (fallbackNode) {
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
dom.append(injectedNode);
|
|
240
|
-
} else {
|
|
241
|
-
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
242
|
-
wrapper.append(fallbackNode);
|
|
243
|
-
dom.append(wrapper);
|
|
244
|
-
}
|
|
215
|
+
if (fallbackNode instanceof HTMLElement) {
|
|
216
|
+
const injectedNode = injectInnerWrapper({
|
|
217
|
+
node: fallbackNode,
|
|
218
|
+
colorScheme,
|
|
219
|
+
isActive,
|
|
220
|
+
isInserted
|
|
221
|
+
});
|
|
222
|
+
dom.append(injectedNode);
|
|
245
223
|
} else {
|
|
246
|
-
const wrapper =
|
|
224
|
+
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
247
225
|
wrapper.append(fallbackNode);
|
|
248
226
|
dom.append(wrapper);
|
|
249
227
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
const filterUndefined = x => !!x;
|
|
5
4
|
|
|
6
5
|
// Attributes that indicate a change in media image
|
|
@@ -34,33 +33,32 @@ export const getAttrChangeRanges = (doc, steps) => {
|
|
|
34
33
|
const stepAttrs = getStepAttrs(step);
|
|
35
34
|
const $pos = doc.resolve(step.pos);
|
|
36
35
|
const nodeAtPos = doc.nodeAt(step.pos);
|
|
37
|
-
if (expValEquals('platform_editor_show_diff_improvements', 'isEnabled', true)) {
|
|
38
|
-
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
39
|
-
if (stepAttrs.some(v => dateAttrs.includes(v)) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date') {
|
|
40
|
-
return {
|
|
41
|
-
fromB: step.pos,
|
|
42
|
-
toB: step.pos + nodeAtPos.nodeSize,
|
|
43
|
-
isInline: true
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
36
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
37
|
+
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
38
|
+
if (stepAttrs.some(v => dateAttrs.includes(v)) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date') {
|
|
39
|
+
return {
|
|
40
|
+
fromB: step.pos,
|
|
41
|
+
toB: step.pos + nodeAtPos.nodeSize,
|
|
42
|
+
isInline: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
// taskItem node: state attribute change — highlight the taskItem node
|
|
47
|
+
if (stepAttrs.some(v => taskItemAttrs.includes(v)) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'taskItem') {
|
|
48
|
+
return {
|
|
49
|
+
fromB: step.pos,
|
|
50
|
+
toB: step.pos + nodeAtPos.nodeSize
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// extension nodes: any attribute change except localId — highlight the node
|
|
55
|
+
if (nodeAtPos && extensionNodeNames.includes(nodeAtPos.type.name) && stepAttrs.some(v => !extensionExcludedAttrs.includes(v))) {
|
|
56
|
+
const isInline = nodeAtPos.type.name === 'inlineExtension';
|
|
57
|
+
return {
|
|
58
|
+
fromB: step.pos,
|
|
59
|
+
toB: step.pos + nodeAtPos.nodeSize,
|
|
60
|
+
isInline
|
|
61
|
+
};
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
// media node: id/collection/url attribute change — highlight the mediaSingle parent
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlock, editingStyle, editingStyleActive, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
6
|
-
import {
|
|
5
|
+
import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
7
6
|
const lozengeStyle = convertToInlineCss({
|
|
8
7
|
display: 'inline-flex',
|
|
9
8
|
boxSizing: 'border-box',
|
|
@@ -77,10 +76,7 @@ const getChangedNodeStyle = (nodeName, colorScheme, isInserted = false, isActive
|
|
|
77
76
|
return undefined;
|
|
78
77
|
}
|
|
79
78
|
if (isTraditional) {
|
|
80
|
-
|
|
81
|
-
return isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew;
|
|
82
|
-
}
|
|
83
|
-
return isActive ? traditionalStyleNodeActive : traditionalStyleNode;
|
|
79
|
+
return isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew;
|
|
84
80
|
}
|
|
85
81
|
return editingStyleNode;
|
|
86
82
|
}
|
|
@@ -93,13 +89,13 @@ const getChangedNodeStyle = (nodeName, colorScheme, isInserted = false, isActive
|
|
|
93
89
|
case 'expand':
|
|
94
90
|
case 'decisionList':
|
|
95
91
|
if (isTraditional) {
|
|
96
|
-
return isActive ? deletedTraditionalBlockOutlineActive :
|
|
92
|
+
return isActive ? deletedTraditionalBlockOutlineActive : deletedTraditionalBlockOutlineNew;
|
|
97
93
|
}
|
|
98
94
|
return isActive ? deletedBlockOutlineActive : deletedBlockOutline;
|
|
99
95
|
case 'panel':
|
|
100
96
|
case 'codeBlock':
|
|
101
97
|
if (isTraditional) {
|
|
102
|
-
return isActive ? deletedTraditionalBlockOutlineRoundedActive :
|
|
98
|
+
return isActive ? deletedTraditionalBlockOutlineRoundedActive : deletedTraditionalBlockOutlineRoundedNew;
|
|
103
99
|
}
|
|
104
100
|
return isActive ? deletedBlockOutlineRoundedActive : deletedBlockOutlineRounded;
|
|
105
101
|
default:
|
|
@@ -142,7 +138,7 @@ const maybeAddDeletedOutlineNewClass = ({
|
|
|
142
138
|
if (name !== 'mediaSingle' && name !== 'embedCard') {
|
|
143
139
|
return;
|
|
144
140
|
}
|
|
145
|
-
if (colorScheme === 'traditional' && !isActive
|
|
141
|
+
if (colorScheme === 'traditional' && !isActive) {
|
|
146
142
|
nodeView.classList.add('show-diff-deleted-outline-new');
|
|
147
143
|
}
|
|
148
144
|
};
|
|
@@ -167,7 +163,7 @@ const applyCellOverlayStyles = ({
|
|
|
167
163
|
}) => {
|
|
168
164
|
element.querySelectorAll('td, th').forEach(cell => {
|
|
169
165
|
const overlay = document.createElement('span');
|
|
170
|
-
const overlayStyle = colorScheme === 'traditional' ? isInserted ?
|
|
166
|
+
const overlayStyle = colorScheme === 'traditional' ? isInserted ? traditionalAddedCellOverlayStyleNew : deletedTraditionalCellOverlayStyle : isInserted ? addedCellOverlayStyle : deletedCellOverlayStyle;
|
|
171
167
|
overlay.setAttribute('style', overlayStyle);
|
|
172
168
|
cell.appendChild(overlay);
|
|
173
169
|
});
|
|
@@ -3,7 +3,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
7
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
9
8
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
@@ -12,9 +11,7 @@ import { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
12
11
|
import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
|
|
13
12
|
export const showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
14
13
|
export const createPlugin = (config, getIntl, api) => {
|
|
15
|
-
|
|
16
|
-
enforceCustomStepRegisters();
|
|
17
|
-
}
|
|
14
|
+
enforceCustomStepRegisters();
|
|
18
15
|
const nodeViewSerializer = new NodeViewSerializer({});
|
|
19
16
|
const setNodeViewSerializer = editorView => {
|
|
20
17
|
nodeViewSerializer.init({
|
|
@@ -58,7 +55,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
58
55
|
nodeViewSerializer,
|
|
59
56
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
60
57
|
intl: getIntl(),
|
|
61
|
-
activeIndexPos:
|
|
58
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
62
59
|
api,
|
|
63
60
|
...(expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
64
61
|
isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
|
|
@@ -85,7 +82,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
85
82
|
hideDeletedDiffs: false
|
|
86
83
|
} : {})
|
|
87
84
|
};
|
|
88
|
-
} else if ((
|
|
85
|
+
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
|
|
89
86
|
// Update the active index in plugin state and recalculate decorations
|
|
90
87
|
const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc);
|
|
91
88
|
if (decorations.length > 0) {
|
|
@@ -175,19 +172,17 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
175
172
|
}
|
|
176
173
|
|
|
177
174
|
// Check for any potential scroll side-effects
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|
|
188
|
-
}
|
|
189
|
-
cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
|
|
175
|
+
const activeIndexChanged = (pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && pluginState.activeIndex !== previousActiveIndex;
|
|
176
|
+
previousActiveIndex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex;
|
|
177
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
178
|
+
var _cancelPendingScrollT2, _api$expand, _api$expand$commands;
|
|
179
|
+
(_cancelPendingScrollT2 = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT2 === void 0 ? void 0 : _cancelPendingScrollT2();
|
|
180
|
+
const scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc);
|
|
181
|
+
const activeDecoration = scrollableDecorations[pluginState.activeIndex];
|
|
182
|
+
if (activeDecoration && api !== null && api !== void 0 && (_api$expand = api.expand) !== null && _api$expand !== void 0 && (_api$expand$commands = _api$expand.commands) !== null && _api$expand$commands !== void 0 && _api$expand$commands.toggleExpandRange) {
|
|
183
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|
|
190
184
|
}
|
|
185
|
+
cancelPendingScrollToDecoration = scrollToActiveDecoration(view, scrollableDecorations, pluginState.activeIndex);
|
|
191
186
|
}
|
|
192
187
|
},
|
|
193
188
|
destroy() {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
1
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
3
2
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
4
3
|
export const showDiffPlugin = ({
|
|
@@ -47,7 +46,6 @@ export const showDiffPlugin = ({
|
|
|
47
46
|
}];
|
|
48
47
|
},
|
|
49
48
|
getSharedState: editorState => {
|
|
50
|
-
var _pluginState$decorati;
|
|
51
49
|
if (!editorState) {
|
|
52
50
|
return {
|
|
53
51
|
isDisplayingChanges: false,
|
|
@@ -55,7 +53,7 @@ export const showDiffPlugin = ({
|
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
const pluginState = showDiffPluginKey.getState(editorState);
|
|
58
|
-
const decorationCount =
|
|
56
|
+
const decorationCount = getScrollableDecorations(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations, editorState.doc);
|
|
59
57
|
return {
|
|
60
58
|
isDisplayingChanges: decorationCount.length > 0,
|
|
61
59
|
activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Transform } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Returns a copy of the document with all marks removed from all text.
|
|
@@ -42,13 +41,10 @@ export function areDocsEqualByBlockStructureAndText(doc1, doc2) {
|
|
|
42
41
|
if (doc1.textContent !== doc2.textContent) {
|
|
43
42
|
return false;
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return doc1.nodeSize === doc2.nodeSize && isBlockStructureEqual(stripped1, stripped2);
|
|
52
|
-
}
|
|
53
|
-
return doc1.nodeSize === doc2.nodeSize && isBlockStructureEqual(doc1, doc2);
|
|
44
|
+
// Strip marks before comparing so that mark-driven text fragmentation
|
|
45
|
+
// (e.g. annotation mark reordering producing different childCounts) does not
|
|
46
|
+
// cause false inequalities.
|
|
47
|
+
var stripped1 = stripMarks(doc1);
|
|
48
|
+
var stripped2 = stripMarks(doc2);
|
|
49
|
+
return doc1.nodeSize === doc2.nodeSize && isBlockStructureEqual(stripped1, stripped2);
|
|
54
50
|
}
|
|
@@ -12,7 +12,6 @@ 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 { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
16
|
import { areDocsEqualByBlockStructureAndText } from '../areDocsEqualByBlockStructureAndText';
|
|
18
17
|
import { createBlockChangedDecoration } from '../decorations/createBlockChangedDecoration';
|
|
@@ -125,25 +124,19 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
125
124
|
_iterator.f();
|
|
126
125
|
}
|
|
127
126
|
if (!areNodesEqualIgnoreAttrs(steppedDoc, tr.doc)) {
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
recoveredViaContentEquality: recoveredViaContentEquality
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
if (fg('platform_editor_show_diff_equality_fallback')) {
|
|
143
|
-
if (!recoveredViaContentEquality) {
|
|
144
|
-
return DecorationSet.empty;
|
|
127
|
+
var _api$analytics;
|
|
128
|
+
var recoveredViaContentEquality = areDocsEqualByBlockStructureAndText(steppedDoc, tr.doc);
|
|
129
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
130
|
+
eventType: 'track',
|
|
131
|
+
action: 'nodesNotEqual',
|
|
132
|
+
actionSubject: 'showDiff',
|
|
133
|
+
attributes: {
|
|
134
|
+
docSizeEqual: steppedDoc.nodeSize === tr.doc.nodeSize,
|
|
135
|
+
colorScheme: colorScheme,
|
|
136
|
+
recoveredViaContentEquality: recoveredViaContentEquality
|
|
145
137
|
}
|
|
146
|
-
}
|
|
138
|
+
});
|
|
139
|
+
if (!recoveredViaContentEquality) {
|
|
147
140
|
return DecorationSet.empty;
|
|
148
141
|
}
|
|
149
142
|
}
|
|
@@ -215,7 +208,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
215
208
|
}));
|
|
216
209
|
});
|
|
217
210
|
getAttrChangeRanges(tr.doc, attrSteps).forEach(function (change) {
|
|
218
|
-
if (
|
|
211
|
+
if (change.isInline) {
|
|
219
212
|
// Inline nodes (e.g. date) need an inline decoration rather than a block decoration
|
|
220
213
|
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
221
214
|
decorations.push(createInlineChangedDecoration({
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
3
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode, addedCellOverlayStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
7
|
-
import {
|
|
5
|
+
import { traditionalDecorationMarkerVariableActive, traditionalDecorationMarkerVariableNew, traditionalDeletedDecorationMarkerVariableActive, traditionalDeletedDecorationMarkerVariableNew, traditionalStyleQuoteNodeActive, traditionalStyleQuoteNodeNew, traditionalStyleRuleNodeActive, traditionalStyleRuleNodeNew, traditionalStyleCardBlockNodeActive, traditionalStyleCardBlockNodeNew, traditionalStyleNodeActive, traditionalStyleNodeNew, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, traditionalAddedCellOverlayStyle, deletedTraditionalCellOverlayStyle } from './colorSchemes/traditional';
|
|
8
6
|
var displayNoneStyle = convertToInlineCss({
|
|
9
7
|
display: 'none'
|
|
10
8
|
});
|
|
@@ -28,7 +26,7 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
|
|
|
28
26
|
// Handle table separately to avoid border issues
|
|
29
27
|
'tableRow', 'paragraph',
|
|
30
28
|
// Paragraph and heading nodes do not need special styling
|
|
31
|
-
'heading', 'hardBreak', 'decisionList', 'taskList'
|
|
29
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
32
30
|
// Layout nodes do not need special styling
|
|
33
31
|
return undefined;
|
|
34
32
|
}
|
|
@@ -45,51 +43,51 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
|
|
|
45
43
|
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
46
44
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
47
45
|
if (isInserted) {
|
|
48
|
-
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ?
|
|
46
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
|
|
49
47
|
} else {
|
|
50
|
-
return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ?
|
|
48
|
+
return isTraditional && isActive ? traditionalDeletedDecorationMarkerVariableActive : isTraditional ? traditionalDeletedDecorationMarkerVariableNew : deletedContentStyleNew;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ?
|
|
51
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariableNew : standardDecorationMarkerVariable;
|
|
54
52
|
}
|
|
55
53
|
if (nodeName === 'blockquote') {
|
|
56
54
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
57
55
|
if (isInserted) {
|
|
58
|
-
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive :
|
|
56
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
|
|
59
57
|
} else {
|
|
60
58
|
return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNode;
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
|
-
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive :
|
|
61
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNodeNew : editingStyleQuoteNode;
|
|
64
62
|
}
|
|
65
63
|
if (nodeName === 'rule') {
|
|
66
64
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
67
65
|
if (isInserted) {
|
|
68
|
-
return isTraditional ? isActive ? traditionalStyleRuleNodeActive :
|
|
66
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
|
|
69
67
|
} else {
|
|
70
68
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
return isTraditional ? isActive ? traditionalStyleRuleNodeActive :
|
|
71
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNodeNew : editingStyleRuleNode;
|
|
74
72
|
}
|
|
75
73
|
if (nodeName === 'blockCard') {
|
|
76
74
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
77
75
|
if (isInserted) {
|
|
78
|
-
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive :
|
|
76
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
|
|
79
77
|
} else {
|
|
80
78
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
|
-
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive :
|
|
81
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNodeNew : editingStyleCardBlockNode;
|
|
84
82
|
}
|
|
85
83
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
86
84
|
if (isInserted) {
|
|
87
|
-
return isTraditional ? isActive ? traditionalStyleNodeActive :
|
|
85
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
|
|
88
86
|
} else {
|
|
89
87
|
return isTraditional ? getDeletedTraditionalInlineStyle(false) : deletedContentStyleNew;
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
|
-
return isTraditional ? isActive ? traditionalStyleNodeActive :
|
|
90
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNodeNew : editingStyleNode;
|
|
93
91
|
};
|
|
94
92
|
|
|
95
93
|
/**
|
|
@@ -144,18 +142,7 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
144
142
|
});
|
|
145
143
|
}
|
|
146
144
|
var className = getNodeClass(change.name);
|
|
147
|
-
if (
|
|
148
|
-
if (style || className) {
|
|
149
|
-
decorations.push(Decoration.node(change.from, change.to, {
|
|
150
|
-
style: style,
|
|
151
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
152
|
-
class: className
|
|
153
|
-
}, {
|
|
154
|
-
key: 'diff-block',
|
|
155
|
-
nodeName: change.name
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
145
|
+
if (style || className) {
|
|
159
146
|
decorations.push(Decoration.node(change.from, change.to, {
|
|
160
147
|
style: style,
|
|
161
148
|
'data-testid': 'show-diff-changed-decoration-node',
|