@atlaskit/editor-plugin-show-diff 5.0.3 → 5.0.5
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 +14 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +56 -31
- package/dist/cjs/pm-plugins/colorSchemes/standard.js +32 -30
- package/dist/cjs/pm-plugins/colorSchemes/traditional.js +29 -30
- package/dist/cjs/pm-plugins/decorations.js +57 -16
- package/dist/cjs/pm-plugins/deletedBlocksHandler.js +15 -57
- package/dist/cjs/pm-plugins/deletedRowsHandler.js +9 -15
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +35 -9
- package/dist/es2019/pm-plugins/colorSchemes/standard.js +31 -29
- package/dist/es2019/pm-plugins/colorSchemes/traditional.js +28 -29
- package/dist/es2019/pm-plugins/decorations.js +51 -8
- package/dist/es2019/pm-plugins/deletedBlocksHandler.js +11 -53
- package/dist/es2019/pm-plugins/deletedRowsHandler.js +9 -14
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +56 -31
- package/dist/esm/pm-plugins/colorSchemes/standard.js +31 -29
- package/dist/esm/pm-plugins/colorSchemes/traditional.js +28 -29
- package/dist/esm/pm-plugins/decorations.js +59 -18
- package/dist/esm/pm-plugins/deletedBlocksHandler.js +11 -53
- package/dist/esm/pm-plugins/deletedRowsHandler.js +8 -14
- package/dist/types/pm-plugins/colorSchemes/standard.d.ts +10 -1
- package/dist/types/pm-plugins/colorSchemes/traditional.d.ts +9 -1
- package/dist/types/pm-plugins/decorations.d.ts +16 -9
- package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +0 -45
- package/dist/types/pm-plugins/deletedRowsHandler.d.ts +7 -1
- package/dist/types-ts4.5/pm-plugins/colorSchemes/standard.d.ts +10 -1
- package/dist/types-ts4.5/pm-plugins/colorSchemes/traditional.d.ts +9 -1
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +16 -9
- package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +0 -45
- package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +7 -1
- package/package.json +3 -3
|
@@ -8,16 +8,24 @@ import { getAttrChangeRanges, stepIsValidAttrChange } from './attributeDecoratio
|
|
|
8
8
|
import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
|
|
9
9
|
import { getMarkChangeRanges } from './markDecorations';
|
|
10
10
|
import { simplifySteps } from './simplifyChanges';
|
|
11
|
-
const calculateNodesForBlockDecoration = (
|
|
11
|
+
const calculateNodesForBlockDecoration = ({
|
|
12
|
+
doc,
|
|
13
|
+
from,
|
|
14
|
+
to,
|
|
15
|
+
colorScheme
|
|
16
|
+
}) => {
|
|
12
17
|
const decorations = [];
|
|
13
18
|
// Iterate over the document nodes within the range
|
|
14
19
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
15
20
|
if (node.isBlock) {
|
|
16
21
|
const decoration = createBlockChangedDecoration({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
change: {
|
|
23
|
+
from: pos,
|
|
24
|
+
to: pos + node.nodeSize,
|
|
25
|
+
name: node.type.name
|
|
26
|
+
},
|
|
27
|
+
colorScheme
|
|
28
|
+
});
|
|
21
29
|
if (decoration) {
|
|
22
30
|
decorations.push(decoration);
|
|
23
31
|
}
|
|
@@ -107,8 +115,17 @@ const calculateDiffDecorationsInner = ({
|
|
|
107
115
|
optimizedChanges.forEach(change => {
|
|
108
116
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
109
117
|
if (change.inserted.length > 0) {
|
|
110
|
-
decorations.push(createInlineChangedDecoration(
|
|
111
|
-
|
|
118
|
+
decorations.push(createInlineChangedDecoration({
|
|
119
|
+
change,
|
|
120
|
+
colorScheme,
|
|
121
|
+
isActive
|
|
122
|
+
}));
|
|
123
|
+
decorations.push(...calculateNodesForBlockDecoration({
|
|
124
|
+
doc: tr.doc,
|
|
125
|
+
from: change.fromB,
|
|
126
|
+
to: change.toB,
|
|
127
|
+
colorScheme
|
|
128
|
+
}));
|
|
112
129
|
}
|
|
113
130
|
if (change.deleted.length > 0) {
|
|
114
131
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
@@ -128,10 +145,19 @@ const calculateDiffDecorationsInner = ({
|
|
|
128
145
|
});
|
|
129
146
|
getMarkChangeRanges(steps).forEach(change => {
|
|
130
147
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
131
|
-
decorations.push(createInlineChangedDecoration(
|
|
148
|
+
decorations.push(createInlineChangedDecoration({
|
|
149
|
+
change,
|
|
150
|
+
colorScheme,
|
|
151
|
+
isActive
|
|
152
|
+
}));
|
|
132
153
|
});
|
|
133
154
|
getAttrChangeRanges(tr.doc, attrSteps).forEach(change => {
|
|
134
|
-
decorations.push(...calculateNodesForBlockDecoration(
|
|
155
|
+
decorations.push(...calculateNodesForBlockDecoration({
|
|
156
|
+
doc: tr.doc,
|
|
157
|
+
from: change.fromB,
|
|
158
|
+
to: change.toB,
|
|
159
|
+
colorScheme
|
|
160
|
+
}));
|
|
135
161
|
});
|
|
136
162
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
137
163
|
};
|
|
@@ -48,43 +48,45 @@ export const deletedContentStyleUnbounded = convertToInlineCss({
|
|
|
48
48
|
pointerEvents: 'none',
|
|
49
49
|
zIndex: 1
|
|
50
50
|
});
|
|
51
|
-
const
|
|
51
|
+
export const deletedStyleQuoteNode = convertToInlineCss({
|
|
52
|
+
borderLeft: `2px solid ${"var(--ds-border-accent-gray, #7D818A)"}`
|
|
53
|
+
});
|
|
54
|
+
export const 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 ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
60
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
61
|
+
});
|
|
62
|
+
export const deletedBlockOutline = convertToInlineCss({
|
|
63
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
64
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
65
|
+
});
|
|
66
|
+
export const deletedBlockOutlineRounded = convertToInlineCss({
|
|
67
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-gray, #7D818A)"}`,
|
|
68
|
+
borderRadius: `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`
|
|
69
|
+
});
|
|
70
|
+
export const 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 const editingStyleQuoteNode = convertToInlineCss({
|
|
52
77
|
borderLeft: `2px solid ${"var(--ds-border-accent-purple, #AF59E1)"}`
|
|
53
78
|
});
|
|
54
|
-
const editingStyleRuleNode = convertToInlineCss({
|
|
79
|
+
export const editingStyleRuleNode = convertToInlineCss({
|
|
55
80
|
backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
56
81
|
});
|
|
57
|
-
const editingStyleNode = convertToInlineCss({
|
|
82
|
+
export const editingStyleNode = convertToInlineCss({
|
|
58
83
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
59
84
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
60
85
|
});
|
|
61
|
-
const editingStyleCardBlockNode = convertToInlineCss({
|
|
86
|
+
export const editingStyleCardBlockNode = convertToInlineCss({
|
|
62
87
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
63
88
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
64
89
|
});
|
|
65
|
-
const
|
|
90
|
+
export const standardDecorationMarkerVariable = convertToInlineCss({
|
|
66
91
|
'--diff-decoration-marker-color': "var(--ds-border-accent-purple, #AF59E1)"
|
|
67
|
-
});
|
|
68
|
-
export const 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 const deletedTraditionalContentStyleUnbounded = convertToInlineCss({
|
|
|
28
28
|
pointerEvents: 'none',
|
|
29
29
|
zIndex: 1
|
|
30
30
|
});
|
|
31
|
-
const
|
|
31
|
+
export const 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 ${"var(--ds-border-accent-red, #E2483D)"}`,
|
|
37
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
38
|
+
});
|
|
39
|
+
export const deletedTraditionalBlockOutline = convertToInlineCss({
|
|
40
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-red, #E2483D)"}`,
|
|
41
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
42
|
+
});
|
|
43
|
+
export const deletedTraditionalBlockOutlineRounded = convertToInlineCss({
|
|
44
|
+
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-red, #E2483D)"}`,
|
|
45
|
+
borderRadius: `calc(${"var(--ds-radius-xsmall, 2px)"} + 1px)`
|
|
46
|
+
});
|
|
47
|
+
export const 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 const traditionalStyleQuoteNode = convertToInlineCss({
|
|
32
54
|
borderLeft: `2px solid ${"var(--ds-border-accent-green, #22A06B)"}`
|
|
33
55
|
});
|
|
34
|
-
const traditionalStyleRuleNode = convertToInlineCss({
|
|
56
|
+
export const traditionalStyleRuleNode = convertToInlineCss({
|
|
35
57
|
backgroundColor: "var(--ds-border-accent-green, #22A06B)"
|
|
36
58
|
});
|
|
37
|
-
const traditionalStyleNode = convertToInlineCss({
|
|
59
|
+
export const traditionalStyleNode = convertToInlineCss({
|
|
38
60
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-green, #22A06B)"}`,
|
|
39
61
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
40
62
|
});
|
|
41
|
-
const traditionalStyleCardBlockNode = convertToInlineCss({
|
|
63
|
+
export const traditionalStyleCardBlockNode = convertToInlineCss({
|
|
42
64
|
boxShadow: `0 0 0 1px ${"var(--ds-border-accent-green, #22A06B)"}`,
|
|
43
65
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
44
66
|
});
|
|
45
|
-
const traditionalDecorationMarkerVariable = convertToInlineCss({
|
|
67
|
+
export const traditionalDecorationMarkerVariable = convertToInlineCss({
|
|
46
68
|
'--diff-decoration-marker-color': "var(--ds-border-accent-green, #22A06B)"
|
|
47
|
-
});
|
|
48
|
-
export const 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
|
+
});
|
|
@@ -2,9 +2,9 @@ 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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, editingStyle, editingStyleActive, deletedContentStyleUnbounded, standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode } from './colorSchemes/standard';
|
|
6
|
+
import { deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded, traditionalInsertStyle, traditionalInsertStyleActive, traditionalDecorationMarkerVariable, traditionalStyleQuoteNode, traditionalStyleRuleNode, traditionalStyleCardBlockNode, traditionalStyleNode } from './colorSchemes/traditional';
|
|
7
|
+
import { handleBlockNodeView } from './deletedBlocksHandler';
|
|
8
8
|
import { handleDeletedRows } from './deletedRowsHandler';
|
|
9
9
|
import { findSafeInsertPos } from './findSafeInsertPos';
|
|
10
10
|
/**
|
|
@@ -13,7 +13,11 @@ import { findSafeInsertPos } from './findSafeInsertPos';
|
|
|
13
13
|
* @param change Changeset "change" containing information about the change content + range
|
|
14
14
|
* @returns Prosemirror inline decoration
|
|
15
15
|
*/
|
|
16
|
-
export const createInlineChangedDecoration = (
|
|
16
|
+
export const createInlineChangedDecoration = ({
|
|
17
|
+
change,
|
|
18
|
+
colorScheme,
|
|
19
|
+
isActive = false
|
|
20
|
+
}) => {
|
|
17
21
|
let style;
|
|
18
22
|
if (colorScheme === 'traditional') {
|
|
19
23
|
style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
@@ -45,8 +49,38 @@ const getNodeClass = name => {
|
|
|
45
49
|
return undefined;
|
|
46
50
|
}
|
|
47
51
|
};
|
|
48
|
-
const getBlockNodeStyle = (
|
|
49
|
-
|
|
52
|
+
const getBlockNodeStyle = (nodeName, colorScheme) => {
|
|
53
|
+
const isTraditional = colorScheme === 'traditional';
|
|
54
|
+
if (['mediaSingle', 'mediaGroup', 'table',
|
|
55
|
+
// Handle table separately to avoid border issues
|
|
56
|
+
'tableRow', 'tableCell', 'tableHeader', 'paragraph',
|
|
57
|
+
// Paragraph and heading nodes do not need special styling
|
|
58
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
59
|
+
// Layout nodes do not need special styling
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
63
|
+
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
64
|
+
}
|
|
65
|
+
if (nodeName === 'blockquote') {
|
|
66
|
+
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
67
|
+
}
|
|
68
|
+
if (nodeName === 'rule') {
|
|
69
|
+
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
70
|
+
}
|
|
71
|
+
if (nodeName === 'blockCard') {
|
|
72
|
+
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
73
|
+
}
|
|
74
|
+
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
79
|
+
*/
|
|
80
|
+
const createDeletedStyleWrapperWithoutOpacity = (colorScheme, isActive) => {
|
|
81
|
+
const wrapper = document.createElement('span');
|
|
82
|
+
wrapper.setAttribute('style', getDeletedContentStyle(colorScheme, isActive));
|
|
83
|
+
return wrapper;
|
|
50
84
|
};
|
|
51
85
|
|
|
52
86
|
/**
|
|
@@ -55,7 +89,10 @@ const getBlockNodeStyle = (name, colorScheme) => {
|
|
|
55
89
|
* @param change Changeset "change" containing information about the change content + range
|
|
56
90
|
* @returns Prosemirror inline decoration
|
|
57
91
|
*/
|
|
58
|
-
export const createBlockChangedDecoration = (
|
|
92
|
+
export const createBlockChangedDecoration = ({
|
|
93
|
+
change,
|
|
94
|
+
colorScheme
|
|
95
|
+
}) => {
|
|
59
96
|
if (fg('platform_editor_show_diff_scroll_navigation')) {
|
|
60
97
|
const style = getBlockNodeStyle(change.name, colorScheme);
|
|
61
98
|
const className = getNodeClass(change.name);
|
|
@@ -115,7 +152,13 @@ export const createDeletedContentDecoration = ({
|
|
|
115
152
|
}
|
|
116
153
|
const {
|
|
117
154
|
decorations
|
|
118
|
-
} = handleDeletedRows(
|
|
155
|
+
} = handleDeletedRows({
|
|
156
|
+
changes: [change],
|
|
157
|
+
originalDoc: doc,
|
|
158
|
+
newDoc,
|
|
159
|
+
nodeViewSerializer,
|
|
160
|
+
colorScheme
|
|
161
|
+
});
|
|
119
162
|
return decorations;
|
|
120
163
|
}
|
|
121
164
|
const serializer = nodeViewSerializer;
|
|
@@ -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 { deletedStyleQuoteNode, deletedStyleQuoteNodeWithLozenge, deletedBlockOutline, deletedBlockOutlineRounded } from './colorSchemes/standard';
|
|
5
|
+
import { deletedTraditionalStyleQuoteNode, deletedTraditionalBlockOutline, deletedTraditionalBlockOutlineRounded } from './colorSchemes/traditional';
|
|
4
6
|
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
|
-
});
|
|
40
7
|
const lozengeStyle = convertToInlineCss({
|
|
41
8
|
display: 'inline-flex',
|
|
42
9
|
boxSizing: 'border-box',
|
|
@@ -68,7 +35,7 @@ export const getDeletedStyleNode = (nodeName, colorScheme) => {
|
|
|
68
35
|
return undefined;
|
|
69
36
|
}
|
|
70
37
|
};
|
|
71
|
-
|
|
38
|
+
const shouldShowRemovedLozenge = nodeName => {
|
|
72
39
|
switch (nodeName) {
|
|
73
40
|
case 'expand':
|
|
74
41
|
case 'codeBlock':
|
|
@@ -83,7 +50,7 @@ export const shouldShowRemovedLozenge = nodeName => {
|
|
|
83
50
|
return false;
|
|
84
51
|
}
|
|
85
52
|
};
|
|
86
|
-
|
|
53
|
+
const shouldAddShowDiffDeletedNodeClass = nodeName => {
|
|
87
54
|
switch (nodeName) {
|
|
88
55
|
case 'mediaSingle':
|
|
89
56
|
case 'embedCard':
|
|
@@ -99,14 +66,14 @@ export const shouldAddShowDiffDeletedNodeClass = nodeName => {
|
|
|
99
66
|
* Checks if a node should apply deleted styles directly without wrapper
|
|
100
67
|
* to preserve natural block-level margins
|
|
101
68
|
*/
|
|
102
|
-
|
|
69
|
+
const shouldApplyDeletedStylesDirectly = nodeName => {
|
|
103
70
|
return nodeName === 'heading' || nodeName === 'blockquote' && !fg('platform_editor_ai_aifc_patch_ga_blockers');
|
|
104
71
|
};
|
|
105
72
|
|
|
106
73
|
/**
|
|
107
74
|
* Creates a "Removed" lozenge to be displayed at the top right corner of deleted block nodes
|
|
108
75
|
*/
|
|
109
|
-
|
|
76
|
+
const createRemovedLozenge = (intl, nodeName) => {
|
|
110
77
|
const container = document.createElement('span');
|
|
111
78
|
let borderTopRightRadius;
|
|
112
79
|
if (['expand', 'decisionList'].includes(nodeName || '')) {
|
|
@@ -140,7 +107,7 @@ export const createRemovedLozenge = (intl, nodeName) => {
|
|
|
140
107
|
/**
|
|
141
108
|
* Wraps a block node in a container with relative positioning to support absolute positioned lozenge
|
|
142
109
|
*/
|
|
143
|
-
|
|
110
|
+
const createBlockNodeWrapper = () => {
|
|
144
111
|
const wrapper = document.createElement('div');
|
|
145
112
|
const baseStyle = convertToInlineCss({
|
|
146
113
|
position: 'relative',
|
|
@@ -151,19 +118,10 @@ export const createBlockNodeWrapper = () => {
|
|
|
151
118
|
return wrapper;
|
|
152
119
|
};
|
|
153
120
|
|
|
154
|
-
/**
|
|
155
|
-
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
156
|
-
*/
|
|
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
121
|
/**
|
|
164
122
|
* Applies deleted styles directly to an HTML element by merging with existing styles
|
|
165
123
|
*/
|
|
166
|
-
|
|
124
|
+
const applyDeletedStylesToElement = (element, targetNode, colorScheme) => {
|
|
167
125
|
const currentStyle = element.getAttribute('style') || '';
|
|
168
126
|
const deletedContentStyle = getDeletedContentStyle(colorScheme);
|
|
169
127
|
const nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
|
|
@@ -173,7 +131,7 @@ export const applyDeletedStylesToElement = (element, targetNode, colorScheme) =>
|
|
|
173
131
|
/**
|
|
174
132
|
* Creates a content wrapper with deleted styles for a block node
|
|
175
133
|
*/
|
|
176
|
-
|
|
134
|
+
const createBlockNodeContentWrapper = (nodeView, targetNode, colorScheme) => {
|
|
177
135
|
const contentWrapper = document.createElement('div');
|
|
178
136
|
const nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
|
|
179
137
|
contentWrapper.setAttribute('style', `${getDeletedContentStyle(colorScheme)}${nodeStyle || ''}`);
|
|
@@ -187,7 +145,7 @@ export const createBlockNodeContentWrapper = (nodeView, targetNode, colorScheme)
|
|
|
187
145
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
188
146
|
* @returns true if embedCard was handled
|
|
189
147
|
*/
|
|
190
|
-
|
|
148
|
+
const handleEmbedCardWithLozenge = (dom, nodeView, targetNode, lozenge, colorScheme) => {
|
|
191
149
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
192
150
|
return false;
|
|
193
151
|
}
|
|
@@ -248,7 +206,7 @@ export const handleMediaSingleWithLozenge = (dom, nodeView, targetNode, lozenge,
|
|
|
248
206
|
/**
|
|
249
207
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
250
208
|
*/
|
|
251
|
-
|
|
209
|
+
const appendBlockNodeWithWrapper = (dom, nodeView, targetNode, colorScheme, intl) => {
|
|
252
210
|
const blockWrapper = createBlockNodeWrapper();
|
|
253
211
|
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
254
212
|
const lozenge = createRemovedLozenge(intl);
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
1
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
3
2
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
+
import { deletedRowStyle } from './colorSchemes/standard';
|
|
6
|
+
import { deletedTraditionalRowStyle } from './colorSchemes/traditional';
|
|
6
7
|
import { findSafeInsertPos } from './findSafeInsertPos';
|
|
7
|
-
const deletedRowStyle = convertToInlineCss({
|
|
8
|
-
color: "var(--ds-text-accent-gray, #505258)",
|
|
9
|
-
textDecoration: 'line-through',
|
|
10
|
-
opacity: 0.6,
|
|
11
|
-
display: 'table-row'
|
|
12
|
-
});
|
|
13
|
-
const deletedTraditionalRowStyle = convertToInlineCss({
|
|
14
|
-
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
15
|
-
textDecoration: 'line-through',
|
|
16
|
-
opacity: 0.6,
|
|
17
|
-
display: 'table-row'
|
|
18
|
-
});
|
|
19
8
|
/**
|
|
20
9
|
* Extracts information about deleted table rows from a change
|
|
21
10
|
*/
|
|
@@ -169,7 +158,13 @@ export const createDeletedRowsDecorations = ({
|
|
|
169
158
|
/**
|
|
170
159
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
171
160
|
*/
|
|
172
|
-
export const handleDeletedRows = (
|
|
161
|
+
export const handleDeletedRows = ({
|
|
162
|
+
changes,
|
|
163
|
+
originalDoc,
|
|
164
|
+
newDoc,
|
|
165
|
+
nodeViewSerializer,
|
|
166
|
+
colorScheme
|
|
167
|
+
}) => {
|
|
173
168
|
// First, expand the changes to include complete deleted rows
|
|
174
169
|
const deletedRows = expandDiffForDeletedRows(changes.filter(change => change.deleted.length > 0), originalDoc, newDoc);
|
|
175
170
|
const allDecorations = createDeletedRowsDecorations({
|
|
@@ -16,16 +16,23 @@ import { getAttrChangeRanges, stepIsValidAttrChange } from './attributeDecoratio
|
|
|
16
16
|
import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
|
|
17
17
|
import { getMarkChangeRanges } from './markDecorations';
|
|
18
18
|
import { simplifySteps } from './simplifyChanges';
|
|
19
|
-
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(
|
|
19
|
+
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref) {
|
|
20
|
+
var doc = _ref.doc,
|
|
21
|
+
from = _ref.from,
|
|
22
|
+
to = _ref.to,
|
|
23
|
+
colorScheme = _ref.colorScheme;
|
|
20
24
|
var decorations = [];
|
|
21
25
|
// Iterate over the document nodes within the range
|
|
22
26
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
23
27
|
if (node.isBlock) {
|
|
24
28
|
var decoration = createBlockChangedDecoration({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
change: {
|
|
30
|
+
from: pos,
|
|
31
|
+
to: pos + node.nodeSize,
|
|
32
|
+
name: node.type.name
|
|
33
|
+
},
|
|
34
|
+
colorScheme: colorScheme
|
|
35
|
+
});
|
|
29
36
|
if (decoration) {
|
|
30
37
|
decorations.push(decoration);
|
|
31
38
|
}
|
|
@@ -66,13 +73,13 @@ function optimizeChanges(changes) {
|
|
|
66
73
|
optimized.push(current);
|
|
67
74
|
return optimized;
|
|
68
75
|
}
|
|
69
|
-
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(
|
|
70
|
-
var state =
|
|
71
|
-
pluginState =
|
|
72
|
-
nodeViewSerializer =
|
|
73
|
-
colorScheme =
|
|
74
|
-
intl =
|
|
75
|
-
activeIndexPos =
|
|
76
|
+
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2) {
|
|
77
|
+
var state = _ref2.state,
|
|
78
|
+
pluginState = _ref2.pluginState,
|
|
79
|
+
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
80
|
+
colorScheme = _ref2.colorScheme,
|
|
81
|
+
intl = _ref2.intl,
|
|
82
|
+
activeIndexPos = _ref2.activeIndexPos;
|
|
76
83
|
var originalDoc = pluginState.originalDoc,
|
|
77
84
|
steps = pluginState.steps;
|
|
78
85
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
@@ -115,8 +122,17 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
115
122
|
optimizedChanges.forEach(function (change) {
|
|
116
123
|
var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
117
124
|
if (change.inserted.length > 0) {
|
|
118
|
-
decorations.push(createInlineChangedDecoration(
|
|
119
|
-
|
|
125
|
+
decorations.push(createInlineChangedDecoration({
|
|
126
|
+
change: change,
|
|
127
|
+
colorScheme: colorScheme,
|
|
128
|
+
isActive: isActive
|
|
129
|
+
}));
|
|
130
|
+
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration({
|
|
131
|
+
doc: tr.doc,
|
|
132
|
+
from: change.fromB,
|
|
133
|
+
to: change.toB,
|
|
134
|
+
colorScheme: colorScheme
|
|
135
|
+
})));
|
|
120
136
|
}
|
|
121
137
|
if (change.deleted.length > 0) {
|
|
122
138
|
var _isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
@@ -136,31 +152,40 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
136
152
|
});
|
|
137
153
|
getMarkChangeRanges(steps).forEach(function (change) {
|
|
138
154
|
var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
139
|
-
decorations.push(createInlineChangedDecoration(
|
|
155
|
+
decorations.push(createInlineChangedDecoration({
|
|
156
|
+
change: change,
|
|
157
|
+
colorScheme: colorScheme,
|
|
158
|
+
isActive: isActive
|
|
159
|
+
}));
|
|
140
160
|
});
|
|
141
161
|
getAttrChangeRanges(tr.doc, attrSteps).forEach(function (change) {
|
|
142
|
-
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(
|
|
162
|
+
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration({
|
|
163
|
+
doc: tr.doc,
|
|
164
|
+
from: change.fromB,
|
|
165
|
+
to: change.toB,
|
|
166
|
+
colorScheme: colorScheme
|
|
167
|
+
})));
|
|
143
168
|
});
|
|
144
169
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
145
170
|
};
|
|
146
171
|
export var calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
|
|
147
172
|
// Cache results unless relevant inputs change
|
|
148
|
-
function (
|
|
149
|
-
var
|
|
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;
|
|
173
|
+
function (_ref3, _ref4) {
|
|
174
|
+
var _ref7;
|
|
157
175
|
var _ref5 = _slicedToArray(_ref3, 1),
|
|
158
176
|
_ref5$ = _ref5[0],
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
177
|
+
pluginState = _ref5$.pluginState,
|
|
178
|
+
state = _ref5$.state,
|
|
179
|
+
colorScheme = _ref5$.colorScheme,
|
|
180
|
+
intl = _ref5$.intl,
|
|
181
|
+
activeIndexPos = _ref5$.activeIndexPos;
|
|
182
|
+
var _ref6 = _slicedToArray(_ref4, 1),
|
|
183
|
+
_ref6$ = _ref6[0],
|
|
184
|
+
lastPluginState = _ref6$.pluginState,
|
|
185
|
+
lastState = _ref6$.state,
|
|
186
|
+
lastColorScheme = _ref6$.colorScheme,
|
|
187
|
+
lastIntl = _ref6$.intl,
|
|
188
|
+
lastActiveIndexPos = _ref6$.activeIndexPos;
|
|
164
189
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
165
|
-
return (
|
|
190
|
+
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
191
|
});
|