@atlaskit/editor-plugin-show-diff 4.1.2 → 4.1.4
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 +16 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +5 -2
- package/dist/cjs/pm-plugins/colorSchemes/standard.js +96 -0
- package/dist/cjs/pm-plugins/colorSchemes/traditional.js +76 -0
- package/dist/cjs/pm-plugins/decorations.js +62 -195
- package/dist/cjs/pm-plugins/main.js +9 -3
- package/dist/cjs/showDiffPlugin.js +2 -1
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +5 -2
- package/dist/es2019/pm-plugins/colorSchemes/standard.js +90 -0
- package/dist/es2019/pm-plugins/colorSchemes/traditional.js +70 -0
- package/dist/es2019/pm-plugins/decorations.js +57 -189
- package/dist/es2019/pm-plugins/main.js +6 -2
- package/dist/es2019/showDiffPlugin.js +3 -2
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +5 -2
- package/dist/esm/pm-plugins/colorSchemes/standard.js +90 -0
- package/dist/esm/pm-plugins/colorSchemes/traditional.js +70 -0
- package/dist/esm/pm-plugins/decorations.js +56 -189
- package/dist/esm/pm-plugins/main.js +8 -2
- package/dist/esm/showDiffPlugin.js +3 -2
- package/dist/types/pm-plugins/colorSchemes/standard.d.ts +8 -0
- package/dist/types/pm-plugins/colorSchemes/traditional.d.ts +5 -0
- package/dist/types/pm-plugins/decorations.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/colorSchemes/standard.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/colorSchemes/traditional.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 4.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4031146a0af6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4031146a0af6d) -
|
|
8
|
+
Updating the PR to calculate the correct number of decorations for display.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.1.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`ea378cb5c7a31`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ea378cb5c7a31) -
|
|
16
|
+
EDITOR-5632: no-op refactors to simplify code
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 4.1.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -27,11 +27,14 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
27
27
|
// Iterate over the document nodes within the range
|
|
28
28
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
29
29
|
if (node.isBlock) {
|
|
30
|
-
|
|
30
|
+
var decoration = (0, _decorations.createBlockChangedDecoration)({
|
|
31
31
|
from: pos,
|
|
32
32
|
to: pos + node.nodeSize,
|
|
33
33
|
name: node.type.name
|
|
34
|
-
}, colourScheme)
|
|
34
|
+
}, colourScheme);
|
|
35
|
+
if (decoration) {
|
|
36
|
+
decorations.push(decoration);
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
});
|
|
37
40
|
return decorations;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getStandardNodeStyle = exports.editingStyleActive = exports.editingStyle = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNewActive = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = void 0;
|
|
7
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
+
var editingStyle = exports.editingStyle = (0, _lazyNodeView.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 = exports.editingStyleActive = (0, _lazyNodeView.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 deletedContentStyle = exports.deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
23
|
+
color: "var(--ds-text-accent-gray, #505258)",
|
|
24
|
+
textDecoration: 'line-through',
|
|
25
|
+
position: 'relative',
|
|
26
|
+
opacity: 0.6
|
|
27
|
+
});
|
|
28
|
+
var deletedContentStyleActive = exports.deletedContentStyleActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
29
|
+
color: "var(--ds-text, #292A2E)",
|
|
30
|
+
textDecoration: 'line-through',
|
|
31
|
+
textDecorationColor: "var(--ds-text-accent-gray, #505258)",
|
|
32
|
+
position: 'relative',
|
|
33
|
+
opacity: 1
|
|
34
|
+
});
|
|
35
|
+
var deletedContentStyleNew = exports.deletedContentStyleNew = (0, _lazyNodeView.convertToInlineCss)({
|
|
36
|
+
color: "var(--ds-text-accent-gray, #505258)",
|
|
37
|
+
textDecoration: 'line-through',
|
|
38
|
+
position: 'relative',
|
|
39
|
+
opacity: 0.8
|
|
40
|
+
});
|
|
41
|
+
var deletedContentStyleNewActive = exports.deletedContentStyleNewActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
42
|
+
color: "var(--ds-text, #292A2E)",
|
|
43
|
+
textDecoration: 'line-through',
|
|
44
|
+
textDecorationColor: "var(--ds-text-accent-gray, #505258)",
|
|
45
|
+
position: 'relative',
|
|
46
|
+
opacity: 1
|
|
47
|
+
});
|
|
48
|
+
var deletedContentStyleUnbounded = exports.deletedContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
top: '50%',
|
|
51
|
+
width: '100%',
|
|
52
|
+
display: 'inline-block',
|
|
53
|
+
borderTop: "1px solid ".concat("var(--ds-text-accent-gray, #505258)"),
|
|
54
|
+
pointerEvents: 'none',
|
|
55
|
+
zIndex: 1
|
|
56
|
+
});
|
|
57
|
+
var editingStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
58
|
+
borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)")
|
|
59
|
+
});
|
|
60
|
+
var editingStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
61
|
+
backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
62
|
+
});
|
|
63
|
+
var editingStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
64
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
65
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
66
|
+
});
|
|
67
|
+
var editingStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
68
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
69
|
+
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
70
|
+
});
|
|
71
|
+
var standardDecorationMarkerVariableName = (0, _lazyNodeView.convertToInlineCss)({
|
|
72
|
+
'--diff-decoration-marker-color': "var(--ds-border-accent-purple, #AF59E1)"
|
|
73
|
+
});
|
|
74
|
+
var getStandardNodeStyle = exports.getStandardNodeStyle = function getStandardNodeStyle(nodeName) {
|
|
75
|
+
if (['mediaSingle', 'mediaGroup', 'table',
|
|
76
|
+
// Handle table separately to avoid border issues
|
|
77
|
+
'tableRow', 'tableCell', 'tableHeader', 'paragraph',
|
|
78
|
+
// Paragraph and heading nodes do not need special styling
|
|
79
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
80
|
+
// Layout nodes do not need special styling
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
84
|
+
return standardDecorationMarkerVariableName;
|
|
85
|
+
}
|
|
86
|
+
if (nodeName === 'blockquote') {
|
|
87
|
+
return editingStyleQuoteNode;
|
|
88
|
+
}
|
|
89
|
+
if (nodeName === 'rule') {
|
|
90
|
+
return editingStyleRuleNode;
|
|
91
|
+
}
|
|
92
|
+
if (nodeName === 'blockCard') {
|
|
93
|
+
return editingStyleCardBlockNode;
|
|
94
|
+
}
|
|
95
|
+
return editingStyleNode;
|
|
96
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.getTraditionalNodeStyle = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyle = void 0;
|
|
7
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
+
var traditionalInsertStyle = exports.traditionalInsertStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
9
|
+
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
10
|
+
textDecoration: 'underline',
|
|
11
|
+
textDecorationStyle: 'solid',
|
|
12
|
+
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
13
|
+
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
14
|
+
});
|
|
15
|
+
var traditionalInsertStyleActive = exports.traditionalInsertStyleActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
16
|
+
background: "var(--ds-background-accent-green-subtler, #BAF3DB)",
|
|
17
|
+
textDecoration: 'underline',
|
|
18
|
+
textDecorationStyle: 'solid',
|
|
19
|
+
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
20
|
+
textDecorationColor: "var(--ds-text-accent-green, #216E4E)"
|
|
21
|
+
});
|
|
22
|
+
var deletedTraditionalContentStyle = exports.deletedTraditionalContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
23
|
+
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
24
|
+
textDecoration: 'line-through',
|
|
25
|
+
position: 'relative',
|
|
26
|
+
opacity: 1
|
|
27
|
+
});
|
|
28
|
+
var deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: '50%',
|
|
31
|
+
width: '100%',
|
|
32
|
+
display: 'inline-block',
|
|
33
|
+
borderTop: "1px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
zIndex: 1
|
|
36
|
+
});
|
|
37
|
+
var traditionalStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
38
|
+
borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
|
|
39
|
+
});
|
|
40
|
+
var traditionalStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
41
|
+
backgroundColor: "var(--ds-border-accent-green, #22A06B)"
|
|
42
|
+
});
|
|
43
|
+
var traditionalStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
44
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
45
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
46
|
+
});
|
|
47
|
+
var traditionalStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
48
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
49
|
+
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
50
|
+
});
|
|
51
|
+
var traditionalDecorationMarkerVariable = (0, _lazyNodeView.convertToInlineCss)({
|
|
52
|
+
'--diff-decoration-marker-color': "var(--ds-border-accent-green, #22A06B)"
|
|
53
|
+
});
|
|
54
|
+
var getTraditionalNodeStyle = exports.getTraditionalNodeStyle = function getTraditionalNodeStyle(nodeName) {
|
|
55
|
+
if (['mediaSingle', 'mediaGroup', 'table',
|
|
56
|
+
// Handle table separately to avoid border issues
|
|
57
|
+
'tableRow', 'tableCell', 'tableHeader', 'paragraph',
|
|
58
|
+
// Paragraph and heading nodes do not need special styling
|
|
59
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'taskItem', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
60
|
+
// Layout nodes do not need special styling
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
64
|
+
return traditionalDecorationMarkerVariable;
|
|
65
|
+
}
|
|
66
|
+
if (nodeName === 'blockquote') {
|
|
67
|
+
return traditionalStyleQuoteNode;
|
|
68
|
+
}
|
|
69
|
+
if (nodeName === 'rule') {
|
|
70
|
+
return traditionalStyleRuleNode;
|
|
71
|
+
}
|
|
72
|
+
if (nodeName === 'blockCard') {
|
|
73
|
+
return traditionalStyleCardBlockNode;
|
|
74
|
+
}
|
|
75
|
+
return traditionalStyleNode;
|
|
76
|
+
};
|
|
@@ -8,38 +8,11 @@ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
|
8
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
10
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
|
+
var _standard = require("./colorSchemes/standard");
|
|
12
|
+
var _traditional = require("./colorSchemes/traditional");
|
|
11
13
|
var _deletedBlocksHandler = require("./deletedBlocksHandler");
|
|
12
14
|
var _deletedRowsHandler = require("./deletedRowsHandler");
|
|
13
15
|
var _findSafeInsertPos = require("./findSafeInsertPos");
|
|
14
|
-
var editingStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
15
|
-
background: "var(--ds-background-accent-purple-subtlest, #F8EEFE)",
|
|
16
|
-
textDecoration: 'underline',
|
|
17
|
-
textDecorationStyle: 'dotted',
|
|
18
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
19
|
-
textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
20
|
-
});
|
|
21
|
-
var editingStyleActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
22
|
-
background: "var(--ds-background-accent-purple-subtler, #EED7FC)",
|
|
23
|
-
textDecoration: 'underline',
|
|
24
|
-
textDecorationStyle: 'dotted',
|
|
25
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
26
|
-
textDecorationColor: "var(--ds-text-accent-purple, #803FA5)"
|
|
27
|
-
});
|
|
28
|
-
var traditionalInsertStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
29
|
-
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
30
|
-
textDecoration: 'underline',
|
|
31
|
-
textDecorationStyle: 'solid',
|
|
32
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
33
|
-
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
34
|
-
});
|
|
35
|
-
var traditionalInsertStyleActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
36
|
-
background: "var(--ds-background-accent-green-subtler, #BAF3DB)",
|
|
37
|
-
textDecoration: 'underline',
|
|
38
|
-
textDecorationStyle: 'solid',
|
|
39
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
40
|
-
textDecorationColor: "var(--ds-text-accent-green, #216E4E)"
|
|
41
|
-
});
|
|
42
|
-
|
|
43
16
|
/**
|
|
44
17
|
* Inline decoration used for insertions as the content already exists in the document
|
|
45
18
|
*
|
|
@@ -50,145 +23,29 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
50
23
|
var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
51
24
|
var style;
|
|
52
25
|
if (colourScheme === 'traditional') {
|
|
53
|
-
style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
26
|
+
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
|
|
54
27
|
} else {
|
|
55
|
-
style = isActive ? editingStyleActive : editingStyle;
|
|
28
|
+
style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
|
|
56
29
|
}
|
|
57
30
|
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
58
31
|
style: style,
|
|
59
32
|
'data-testid': 'show-diff-changed-decoration'
|
|
60
|
-
}, {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
switch (nodeName) {
|
|
64
|
-
case 'blockquote':
|
|
65
|
-
return colourScheme === 'traditional' ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
66
|
-
case 'mediaSingle':
|
|
67
|
-
case 'mediaGroup':
|
|
68
|
-
case 'table':
|
|
69
|
-
case 'tableRow':
|
|
70
|
-
case 'tableCell':
|
|
71
|
-
case 'tableHeader':
|
|
72
|
-
return undefined;
|
|
73
|
-
// Handle table separately to avoid border issues
|
|
74
|
-
case 'paragraph':
|
|
75
|
-
case 'heading':
|
|
76
|
-
case 'hardBreak':
|
|
77
|
-
return undefined;
|
|
78
|
-
// Paragraph and heading nodes do not need special styling
|
|
79
|
-
case 'decisionList':
|
|
80
|
-
case 'taskList':
|
|
81
|
-
case 'taskItem':
|
|
82
|
-
case 'bulletList':
|
|
83
|
-
case 'orderedList':
|
|
84
|
-
return undefined;
|
|
85
|
-
case 'extension':
|
|
86
|
-
case 'embedCard':
|
|
87
|
-
case 'listItem':
|
|
88
|
-
return (0, _lazyNodeView.convertToInlineCss)({
|
|
89
|
-
'--diff-decoration-marker-color': colourScheme === 'traditional' ? "var(--ds-border-accent-green, #22A06B)" : "var(--ds-border-accent-purple, #AF59E1)"
|
|
90
|
-
});
|
|
91
|
-
case 'layoutSection':
|
|
92
|
-
return undefined;
|
|
93
|
-
// Layout nodes do not need special styling
|
|
94
|
-
case 'rule':
|
|
95
|
-
return colourScheme === 'traditional' ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
96
|
-
case 'blockCard':
|
|
97
|
-
return colourScheme === 'traditional' ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
98
|
-
default:
|
|
99
|
-
return colourScheme === 'traditional' ? traditionalStyleNode : editingStyleNode;
|
|
100
|
-
}
|
|
33
|
+
}, {
|
|
34
|
+
key: 'diff-inline'
|
|
35
|
+
});
|
|
101
36
|
};
|
|
102
|
-
var editingStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
103
|
-
borderLeft: "2px solid ".concat("var(--ds-border-accent-purple, #AF59E1)")
|
|
104
|
-
});
|
|
105
|
-
var traditionalStyleQuoteNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
106
|
-
borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
|
|
107
|
-
});
|
|
108
|
-
var editingStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
109
|
-
backgroundColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
110
|
-
});
|
|
111
|
-
var traditionalStyleRuleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
112
|
-
backgroundColor: "var(--ds-border-accent-green, #22A06B)"
|
|
113
|
-
});
|
|
114
|
-
var editingStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
115
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
116
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
117
|
-
});
|
|
118
|
-
var traditionalStyleNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
119
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
120
|
-
borderRadius: "var(--ds-radius-small, 4px)"
|
|
121
|
-
});
|
|
122
|
-
var editingStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
123
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
124
|
-
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
125
|
-
});
|
|
126
|
-
var traditionalStyleCardBlockNode = (0, _lazyNodeView.convertToInlineCss)({
|
|
127
|
-
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
128
|
-
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
129
|
-
});
|
|
130
|
-
var deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
131
|
-
color: "var(--ds-text-accent-gray, #505258)",
|
|
132
|
-
textDecoration: 'line-through',
|
|
133
|
-
position: 'relative',
|
|
134
|
-
opacity: 0.6
|
|
135
|
-
});
|
|
136
|
-
var deletedContentStyleActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
137
|
-
color: "var(--ds-text, #292A2E)",
|
|
138
|
-
textDecoration: 'line-through',
|
|
139
|
-
textDecorationColor: "var(--ds-text-accent-gray, #505258)",
|
|
140
|
-
position: 'relative',
|
|
141
|
-
opacity: 1
|
|
142
|
-
});
|
|
143
|
-
var deletedContentStyleNew = (0, _lazyNodeView.convertToInlineCss)({
|
|
144
|
-
color: "var(--ds-text-accent-gray, #505258)",
|
|
145
|
-
textDecoration: 'line-through',
|
|
146
|
-
position: 'relative',
|
|
147
|
-
opacity: 0.8
|
|
148
|
-
});
|
|
149
|
-
var deletedContentStyleNewActive = (0, _lazyNodeView.convertToInlineCss)({
|
|
150
|
-
color: "var(--ds-text, #292A2E)",
|
|
151
|
-
textDecoration: 'line-through',
|
|
152
|
-
textDecorationColor: "var(--ds-text-accent-gray, #505258)",
|
|
153
|
-
position: 'relative',
|
|
154
|
-
opacity: 1
|
|
155
|
-
});
|
|
156
|
-
var deletedContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
157
|
-
position: 'absolute',
|
|
158
|
-
top: '50%',
|
|
159
|
-
width: '100%',
|
|
160
|
-
display: 'inline-block',
|
|
161
|
-
borderTop: "1px solid ".concat("var(--ds-text-accent-gray, #505258)"),
|
|
162
|
-
pointerEvents: 'none',
|
|
163
|
-
zIndex: 1
|
|
164
|
-
});
|
|
165
|
-
var deletedTraditionalContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
166
|
-
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
167
|
-
textDecoration: 'line-through',
|
|
168
|
-
position: 'relative',
|
|
169
|
-
opacity: 1
|
|
170
|
-
});
|
|
171
|
-
var deletedTraditionalContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
172
|
-
position: 'absolute',
|
|
173
|
-
top: '50%',
|
|
174
|
-
width: '100%',
|
|
175
|
-
display: 'inline-block',
|
|
176
|
-
borderTop: "1px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
177
|
-
pointerEvents: 'none',
|
|
178
|
-
zIndex: 1
|
|
179
|
-
});
|
|
180
37
|
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
|
|
181
|
-
return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
38
|
+
return colourScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
|
|
182
39
|
};
|
|
183
40
|
var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
|
|
184
41
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
185
42
|
if (colourScheme === 'traditional') {
|
|
186
|
-
return deletedTraditionalContentStyle;
|
|
43
|
+
return _traditional.deletedTraditionalContentStyle;
|
|
187
44
|
}
|
|
188
45
|
if (isActive) {
|
|
189
|
-
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
|
|
46
|
+
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNewActive : _standard.deletedContentStyleActive;
|
|
190
47
|
}
|
|
191
|
-
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
48
|
+
return (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? _standard.deletedContentStyleNew : _standard.deletedContentStyle;
|
|
192
49
|
};
|
|
193
50
|
var getNodeClass = function getNodeClass(name) {
|
|
194
51
|
switch (name) {
|
|
@@ -198,6 +55,9 @@ var getNodeClass = function getNodeClass(name) {
|
|
|
198
55
|
return undefined;
|
|
199
56
|
}
|
|
200
57
|
};
|
|
58
|
+
var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
|
|
59
|
+
return colourScheme === 'traditional' ? (0, _traditional.getTraditionalNodeStyle)(name) : (0, _standard.getStandardNodeStyle)(name);
|
|
60
|
+
};
|
|
201
61
|
|
|
202
62
|
/**
|
|
203
63
|
* Inline decoration used for insertions as the content already exists in the document
|
|
@@ -206,11 +66,41 @@ var getNodeClass = function getNodeClass(name) {
|
|
|
206
66
|
* @returns Prosemirror inline decoration
|
|
207
67
|
*/
|
|
208
68
|
var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colourScheme) {
|
|
209
|
-
|
|
210
|
-
style
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
69
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
|
|
70
|
+
var style = getBlockNodeStyle(change.name, colourScheme);
|
|
71
|
+
var className = getNodeClass(change.name);
|
|
72
|
+
if (style || className) {
|
|
73
|
+
return _view.Decoration.node(change.from, change.to, {
|
|
74
|
+
style: style,
|
|
75
|
+
'data-testid': 'show-diff-changed-decoration-node',
|
|
76
|
+
class: className
|
|
77
|
+
}, {
|
|
78
|
+
key: 'diff-block'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
} else {
|
|
83
|
+
return _view.Decoration.node(change.from, change.to, {
|
|
84
|
+
style: getBlockNodeStyle(change.name, colourScheme),
|
|
85
|
+
'data-testid': 'show-diff-changed-decoration-node',
|
|
86
|
+
class: getNodeClass(change.name)
|
|
87
|
+
}, {
|
|
88
|
+
key: 'diff-block'
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var createContentWrapper = function createContentWrapper(colourScheme) {
|
|
93
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
94
|
+
var wrapper = document.createElement('span');
|
|
95
|
+
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
96
|
+
position: 'relative',
|
|
97
|
+
width: 'fit-content'
|
|
98
|
+
});
|
|
99
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme, isActive)));
|
|
100
|
+
var strikethrough = document.createElement('span');
|
|
101
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
|
|
102
|
+
wrapper.append(strikethrough);
|
|
103
|
+
return wrapper;
|
|
214
104
|
};
|
|
215
105
|
var createDeletedContentDecoration = exports.createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
216
106
|
var change = _ref.change,
|
|
@@ -257,20 +147,6 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
257
147
|
* or sliced End depth is and match only the entire node.
|
|
258
148
|
*/
|
|
259
149
|
slice.content.forEach(function (node) {
|
|
260
|
-
// Create a wrapper for each node with strikethrough
|
|
261
|
-
var createWrapperWithStrikethrough = function createWrapperWithStrikethrough() {
|
|
262
|
-
var wrapper = document.createElement('span');
|
|
263
|
-
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
264
|
-
position: 'relative',
|
|
265
|
-
width: 'fit-content'
|
|
266
|
-
});
|
|
267
|
-
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colourScheme, isActive)));
|
|
268
|
-
var strikethrough = document.createElement('span');
|
|
269
|
-
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
|
|
270
|
-
wrapper.append(strikethrough);
|
|
271
|
-
return wrapper;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
150
|
// Helper function to handle multiple child nodes
|
|
275
151
|
var handleMultipleChildNodes = function handleMultipleChildNodes(node) {
|
|
276
152
|
if (node.content.childCount > 1 && node.type.inlineContent) {
|
|
@@ -278,16 +154,15 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
278
154
|
var childNodeView = serializer.tryCreateNodeView(childNode);
|
|
279
155
|
if (childNodeView) {
|
|
280
156
|
var lineBreak = document.createElement('br');
|
|
281
|
-
targetNode = node;
|
|
282
157
|
dom.append(lineBreak);
|
|
283
|
-
var wrapper =
|
|
158
|
+
var wrapper = createContentWrapper(colourScheme, isActive);
|
|
284
159
|
wrapper.append(childNodeView);
|
|
285
160
|
dom.append(wrapper);
|
|
286
161
|
} else {
|
|
287
162
|
// Fallback to serializing the individual child node
|
|
288
163
|
var serializedChild = serializer.serializeNode(childNode);
|
|
289
164
|
if (serializedChild) {
|
|
290
|
-
var _wrapper =
|
|
165
|
+
var _wrapper = createContentWrapper(colourScheme, isActive);
|
|
291
166
|
_wrapper.append(serializedChild);
|
|
292
167
|
dom.append(_wrapper);
|
|
293
168
|
}
|
|
@@ -302,21 +177,15 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
302
177
|
var isFirst = slice.content.firstChild === node;
|
|
303
178
|
var isLast = slice.content.lastChild === node;
|
|
304
179
|
var hasInlineContent = node.content.childCount > 0 && node.type.inlineContent === true;
|
|
305
|
-
var targetNode;
|
|
306
180
|
var fallbackSerialization;
|
|
181
|
+
if (handleMultipleChildNodes(node)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
307
184
|
if ((isFirst || isLast && slice.content.childCount > 2) && hasInlineContent) {
|
|
308
|
-
if (handleMultipleChildNodes(node)) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
targetNode = node;
|
|
312
185
|
fallbackSerialization = function fallbackSerialization() {
|
|
313
186
|
return serializer.serializeFragment(node.content);
|
|
314
187
|
};
|
|
315
188
|
} else if (isLast && slice.content.childCount === 2) {
|
|
316
|
-
if (handleMultipleChildNodes(node)) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
targetNode = node;
|
|
320
189
|
fallbackSerialization = function fallbackSerialization() {
|
|
321
190
|
if (node.type.name === 'text') {
|
|
322
191
|
return document.createTextNode(node.text || '');
|
|
@@ -329,27 +198,23 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
329
198
|
return serializer.serializeFragment(node.content);
|
|
330
199
|
};
|
|
331
200
|
} else {
|
|
332
|
-
if (handleMultipleChildNodes(node)) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
targetNode = node;
|
|
336
201
|
fallbackSerialization = function fallbackSerialization() {
|
|
337
202
|
return serializer.serializeNode(node);
|
|
338
203
|
};
|
|
339
204
|
}
|
|
340
205
|
|
|
341
206
|
// Try to create node view, fallback to serialization
|
|
342
|
-
var nodeView = serializer.tryCreateNodeView(
|
|
207
|
+
var nodeView = serializer.tryCreateNodeView(node);
|
|
343
208
|
if (nodeView) {
|
|
344
|
-
if (
|
|
345
|
-
var wrapper =
|
|
209
|
+
if (node.isInline) {
|
|
210
|
+
var wrapper = createContentWrapper(colourScheme, isActive);
|
|
346
211
|
wrapper.append(nodeView);
|
|
347
212
|
dom.append(wrapper);
|
|
348
213
|
} else {
|
|
349
214
|
// Handle all block nodes with unified function
|
|
350
|
-
(0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView,
|
|
215
|
+
(0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, node, colourScheme, intl);
|
|
351
216
|
}
|
|
352
|
-
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(
|
|
217
|
+
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
353
218
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
|
354
219
|
return;
|
|
355
220
|
} else {
|
|
@@ -366,5 +231,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
366
231
|
// Widget decoration used for deletions as the content is not in the document
|
|
367
232
|
// and we want to display the deleted content with a style.
|
|
368
233
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
|
|
369
|
-
return [_view.Decoration.widget(safeInsertPos, dom
|
|
234
|
+
return [_view.Decoration.widget(safeInsertPos, dom, {
|
|
235
|
+
key: 'diff-widget'
|
|
236
|
+
})];
|
|
370
237
|
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.showDiffPluginKey = exports.createPlugin = void 0;
|
|
7
|
+
exports.showDiffPluginKey = exports.getScrollableDecorations = exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _processRawValue = require("@atlaskit/editor-common/process-raw-value");
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
@@ -17,6 +17,12 @@ var _NodeViewSerializer = require("./NodeViewSerializer");
|
|
|
17
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
19
|
var showDiffPluginKey = exports.showDiffPluginKey = new _state2.PluginKey('showDiffPlugin');
|
|
20
|
+
var getScrollableDecorations = exports.getScrollableDecorations = function getScrollableDecorations(set) {
|
|
21
|
+
var _set$find;
|
|
22
|
+
return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
|
|
23
|
+
return spec.key === 'diff-inline' || spec.key === 'diff-widget' || spec.key === 'diff-block';
|
|
24
|
+
})) !== null && _set$find !== void 0 ? _set$find : [];
|
|
25
|
+
};
|
|
20
26
|
var createPlugin = exports.createPlugin = function createPlugin(config, getIntl) {
|
|
21
27
|
var nodeViewSerializer = new _NodeViewSerializer.NodeViewSerializer({});
|
|
22
28
|
var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
|
|
@@ -43,7 +49,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
43
49
|
if (!pluginState || pluginState.decorations.find().length === 0) {
|
|
44
50
|
return;
|
|
45
51
|
}
|
|
46
|
-
var decorations = pluginState.decorations
|
|
52
|
+
var decorations = getScrollableDecorations(pluginState.decorations);
|
|
47
53
|
var decoration = decorations[(_pluginState$activeIn = pluginState.activeIndex) !== null && _pluginState$activeIn !== void 0 ? _pluginState$activeIn : 0];
|
|
48
54
|
if (!decoration) {
|
|
49
55
|
return;
|
|
@@ -99,7 +105,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
99
105
|
});
|
|
100
106
|
} 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') && (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
|
|
101
107
|
// Update the active index in plugin state and recalculate decorations
|
|
102
|
-
var _decorations = currentPluginState.decorations
|
|
108
|
+
var _decorations = getScrollableDecorations(currentPluginState.decorations);
|
|
103
109
|
if (_decorations.length > 0) {
|
|
104
110
|
var _currentPluginState$a;
|
|
105
111
|
var nextIndex = (_currentPluginState$a = currentPluginState.activeIndex) !== null && _currentPluginState$a !== void 0 ? _currentPluginState$a : 0;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.showDiffPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var _main = require("./pm-plugins/main");
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -61,7 +62,7 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
var pluginState = _main.showDiffPluginKey.getState(editorState);
|
|
64
|
-
var decorationCount = (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
|
|
65
|
+
var decorationCount = (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? (0, _main.getScrollableDecorations)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations) : (pluginState === null || pluginState === void 0 || (_pluginState$decorati = pluginState.decorations) === null || _pluginState$decorati === void 0 ? void 0 : _pluginState$decorati.find()) || [];
|
|
65
66
|
return {
|
|
66
67
|
isDisplayingChanges: decorationCount.length > 0,
|
|
67
68
|
activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
|
|
@@ -13,11 +13,14 @@ const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
|
|
|
13
13
|
// Iterate over the document nodes within the range
|
|
14
14
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
15
15
|
if (node.isBlock) {
|
|
16
|
-
|
|
16
|
+
const decoration = createBlockChangedDecoration({
|
|
17
17
|
from: pos,
|
|
18
18
|
to: pos + node.nodeSize,
|
|
19
19
|
name: node.type.name
|
|
20
|
-
}, colourScheme)
|
|
20
|
+
}, colourScheme);
|
|
21
|
+
if (decoration) {
|
|
22
|
+
decorations.push(decoration);
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
26
|
return decorations;
|