@atlaskit/editor-plugin-show-diff 6.1.1 → 6.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +17 -8
- package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +1 -1
- package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +39 -2
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +34 -26
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -4
- package/dist/cjs/pm-plugins/main.js +7 -4
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +16 -8
- package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +1 -1
- package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +38 -1
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +33 -27
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +13 -6
- package/dist/es2019/pm-plugins/main.js +5 -2
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +17 -8
- package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +1 -1
- package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +38 -1
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +35 -27
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +11 -5
- package/dist/esm/pm-plugins/main.js +7 -4
- package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +9 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +8 -5
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +8 -5
- package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode } from './colorSchemes/standard';
|
|
5
|
-
import { traditionalDecorationMarkerVariable, traditionalStyleQuoteNode, traditionalStyleRuleNode, traditionalStyleCardBlockNode, traditionalStyleNode, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from './colorSchemes/traditional';
|
|
5
|
+
import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleNode, traditionalStyleNodeActive, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from './colorSchemes/traditional';
|
|
6
6
|
const getNodeClass = name => {
|
|
7
7
|
switch (name) {
|
|
8
8
|
case 'extension':
|
|
@@ -14,7 +14,8 @@ const getNodeClass = name => {
|
|
|
14
14
|
const getBlockNodeStyle = ({
|
|
15
15
|
nodeName,
|
|
16
16
|
colorScheme,
|
|
17
|
-
isInserted = true
|
|
17
|
+
isInserted = true,
|
|
18
|
+
isActive = false
|
|
18
19
|
}) => {
|
|
19
20
|
const isTraditional = colorScheme === 'traditional';
|
|
20
21
|
if (['mediaSingle', 'mediaGroup', 'table',
|
|
@@ -28,73 +29,78 @@ const getBlockNodeStyle = ({
|
|
|
28
29
|
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
29
30
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
30
31
|
if (isInserted) {
|
|
31
|
-
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
32
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
32
33
|
} else {
|
|
33
34
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
37
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
37
38
|
}
|
|
38
39
|
if (nodeName === 'blockquote') {
|
|
39
40
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
40
41
|
if (isInserted) {
|
|
41
|
-
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
42
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
42
43
|
} else {
|
|
43
44
|
return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNode;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
47
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
47
48
|
}
|
|
48
49
|
if (nodeName === 'rule') {
|
|
49
50
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
50
51
|
if (isInserted) {
|
|
51
|
-
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
52
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNode : editingStyleRuleNode;
|
|
52
53
|
} else {
|
|
53
54
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
57
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNode : editingStyleRuleNode;
|
|
57
58
|
}
|
|
58
59
|
if (nodeName === 'blockCard') {
|
|
59
60
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
60
61
|
if (isInserted) {
|
|
61
|
-
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
62
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
62
63
|
} else {
|
|
63
64
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
67
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
67
68
|
}
|
|
68
69
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
69
70
|
if (isInserted) {
|
|
70
|
-
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
71
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNode : editingStyleNode;
|
|
71
72
|
} else {
|
|
72
73
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
76
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNode : editingStyleNode;
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
+
* Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
|
|
80
81
|
*
|
|
81
|
-
* @param change
|
|
82
|
-
* @
|
|
82
|
+
* @param change Node range and name
|
|
83
|
+
* @param colorScheme Optional color scheme
|
|
84
|
+
* @param isActive Whether this node is part of the currently active/focused change
|
|
85
|
+
* @returns Prosemirror node decoration or undefined
|
|
83
86
|
*/
|
|
84
87
|
export const createBlockChangedDecoration = ({
|
|
85
88
|
change,
|
|
86
89
|
colorScheme,
|
|
87
|
-
isInserted = true
|
|
90
|
+
isInserted = true,
|
|
91
|
+
isActive = false
|
|
88
92
|
}) => {
|
|
89
93
|
let style = getBlockNodeStyle({
|
|
90
94
|
nodeName: change.name,
|
|
91
|
-
colorScheme
|
|
95
|
+
colorScheme,
|
|
96
|
+
isActive
|
|
92
97
|
});
|
|
93
98
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
94
99
|
style = getBlockNodeStyle({
|
|
95
100
|
nodeName: change.name,
|
|
96
101
|
colorScheme,
|
|
97
|
-
isInserted
|
|
102
|
+
isInserted,
|
|
103
|
+
isActive
|
|
98
104
|
});
|
|
99
105
|
}
|
|
100
106
|
const className = getNodeClass(change.name);
|
|
@@ -107,15 +113,15 @@ export const createBlockChangedDecoration = ({
|
|
|
107
113
|
}, {
|
|
108
114
|
key: 'diff-block'
|
|
109
115
|
});
|
|
116
|
+
} else {
|
|
117
|
+
return undefined;
|
|
110
118
|
}
|
|
111
|
-
return undefined;
|
|
112
|
-
} else {
|
|
113
|
-
return Decoration.node(change.from, change.to, {
|
|
114
|
-
style,
|
|
115
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
116
|
-
class: className
|
|
117
|
-
}, {
|
|
118
|
-
key: 'diff-block'
|
|
119
|
-
});
|
|
120
119
|
}
|
|
120
|
+
return Decoration.node(change.from, change.to, {
|
|
121
|
+
style,
|
|
122
|
+
'data-testid': 'show-diff-changed-decoration-node',
|
|
123
|
+
class: className
|
|
124
|
+
}, {
|
|
125
|
+
key: 'diff-block'
|
|
126
|
+
});
|
|
121
127
|
};
|
|
@@ -2,11 +2,16 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
|
|
5
|
-
import { traditionalInsertStyle, traditionalInsertStyleActive, deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded } from './colorSchemes/traditional';
|
|
5
|
+
import { traditionalInsertStyle, traditionalInsertStyleActive, deletedTraditionalContentStyle, deletedTraditionalContentStyleActive, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
|
|
6
6
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
7
7
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
8
8
|
import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
9
|
-
const getDeletedContentStyleUnbounded = colorScheme
|
|
9
|
+
const getDeletedContentStyleUnbounded = (colorScheme, isActive = false) => {
|
|
10
|
+
if (colorScheme === 'traditional' && isActive) {
|
|
11
|
+
return deletedTraditionalContentStyleUnboundedActive;
|
|
12
|
+
}
|
|
13
|
+
return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
14
|
+
};
|
|
10
15
|
const getInsertedContentStyle = (colorScheme, isActive = false) => {
|
|
11
16
|
if (colorScheme === 'traditional') {
|
|
12
17
|
if (isActive) {
|
|
@@ -21,7 +26,7 @@ const getInsertedContentStyle = (colorScheme, isActive = false) => {
|
|
|
21
26
|
};
|
|
22
27
|
const getDeletedContentStyle = (colorScheme, isActive = false) => {
|
|
23
28
|
if (colorScheme === 'traditional') {
|
|
24
|
-
return deletedTraditionalContentStyle;
|
|
29
|
+
return isActive ? deletedTraditionalContentStyleActive : deletedTraditionalContentStyle;
|
|
25
30
|
}
|
|
26
31
|
if (isActive) {
|
|
27
32
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
|
|
@@ -229,7 +234,9 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
229
234
|
// Widget decoration used for deletions as the content is not in the document
|
|
230
235
|
// and we want to display the deleted content with a style.
|
|
231
236
|
const safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
const decorations = [];
|
|
238
|
+
decorations.push(Decoration.widget(safeInsertPos, dom, {
|
|
239
|
+
key: `diff-widget-${isActive ? 'active' : 'inactive'}`
|
|
240
|
+
}));
|
|
241
|
+
return decorations;
|
|
235
242
|
};
|
|
@@ -10,8 +10,11 @@ import { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
10
10
|
import { scrollToActiveDecoration } from './scrollToActiveDecoration';
|
|
11
11
|
export const showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
12
12
|
export const getScrollableDecorations = set => {
|
|
13
|
-
var _set$find;
|
|
14
|
-
return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, spec =>
|
|
13
|
+
var _set$find$sort;
|
|
14
|
+
return (_set$find$sort = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, spec => {
|
|
15
|
+
var _spec$key;
|
|
16
|
+
return spec.key === 'diff-inline' || ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith('diff-widget')) || spec.key === 'diff-block';
|
|
17
|
+
}).sort((a, b) => a.from - b.from)) !== null && _set$find$sort !== void 0 ? _set$find$sort : [];
|
|
15
18
|
};
|
|
16
19
|
export const createPlugin = (config, getIntl, api) => {
|
|
17
20
|
const nodeViewSerializer = new NodeViewSerializer({});
|
|
@@ -25,19 +25,23 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
25
25
|
to = _ref.to,
|
|
26
26
|
colorScheme = _ref.colorScheme,
|
|
27
27
|
_ref$isInserted = _ref.isInserted,
|
|
28
|
-
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted
|
|
28
|
+
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
|
|
29
|
+
activeIndexPos = _ref.activeIndexPos;
|
|
29
30
|
var decorations = [];
|
|
30
31
|
// Iterate over the document nodes within the range
|
|
31
32
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
32
33
|
if (node.isBlock && (!expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || pos + node.nodeSize <= to)) {
|
|
34
|
+
var nodeEnd = pos + node.nodeSize;
|
|
35
|
+
var isActive = activeIndexPos && pos === activeIndexPos.from && nodeEnd === activeIndexPos.to;
|
|
33
36
|
var decoration = createBlockChangedDecoration({
|
|
34
37
|
change: {
|
|
35
38
|
from: pos,
|
|
36
|
-
to:
|
|
39
|
+
to: nodeEnd,
|
|
37
40
|
name: node.type.name
|
|
38
41
|
},
|
|
39
42
|
colorScheme: colorScheme,
|
|
40
|
-
isInserted: isInserted
|
|
43
|
+
isInserted: isInserted,
|
|
44
|
+
isActive: isActive
|
|
41
45
|
});
|
|
42
46
|
if (decoration) {
|
|
43
47
|
decorations.push(decoration);
|
|
@@ -141,7 +145,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
141
145
|
var optimizedChanges = optimizeChanges(changes);
|
|
142
146
|
var decorations = [];
|
|
143
147
|
optimizedChanges.forEach(function (change) {
|
|
144
|
-
var isActive = activeIndexPos && change.fromB
|
|
148
|
+
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
145
149
|
// Our default operations are insertions, so it should match the opposite of isInverted.
|
|
146
150
|
var isInserted = !isInverted;
|
|
147
151
|
if (change.inserted.length > 0) {
|
|
@@ -152,17 +156,20 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
152
156
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
153
157
|
isInserted: isInserted
|
|
154
158
|
})));
|
|
155
|
-
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread({
|
|
159
|
+
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
|
|
156
160
|
doc: tr.doc,
|
|
157
161
|
from: change.fromB,
|
|
158
162
|
to: change.toB,
|
|
159
163
|
colorScheme: colorScheme
|
|
160
164
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
161
165
|
isInserted: isInserted
|
|
166
|
+
}), {}, {
|
|
167
|
+
activeIndexPos: activeIndexPos,
|
|
168
|
+
intl: intl
|
|
162
169
|
}))));
|
|
163
170
|
}
|
|
164
171
|
if (change.deleted.length > 0) {
|
|
165
|
-
var _isActive = activeIndexPos && change.fromB
|
|
172
|
+
var _isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.fromB === activeIndexPos.to;
|
|
166
173
|
var decoration = createNodeChangedDecorationWidget(_objectSpread({
|
|
167
174
|
change: change,
|
|
168
175
|
doc: originalDoc,
|
|
@@ -180,7 +187,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
180
187
|
}
|
|
181
188
|
});
|
|
182
189
|
getMarkChangeRanges(steps).forEach(function (change) {
|
|
183
|
-
var isActive = activeIndexPos && change.fromB
|
|
190
|
+
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
184
191
|
decorations.push(createInlineChangedDecoration({
|
|
185
192
|
change: change,
|
|
186
193
|
colorScheme: colorScheme,
|
|
@@ -194,7 +201,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref2
|
|
|
194
201
|
from: change.fromB,
|
|
195
202
|
to: change.toB,
|
|
196
203
|
colorScheme: colorScheme,
|
|
197
|
-
isInserted: true
|
|
204
|
+
isInserted: true,
|
|
205
|
+
activeIndexPos: activeIndexPos,
|
|
206
|
+
intl: intl
|
|
198
207
|
})));
|
|
199
208
|
});
|
|
200
209
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
@@ -7,7 +7,7 @@ export var editingStyle = convertToInlineCss({
|
|
|
7
7
|
textDecorationColor: "var(--ds-border-accent-purple, #AF59E1)"
|
|
8
8
|
});
|
|
9
9
|
export var editingStyleActive = convertToInlineCss({
|
|
10
|
-
background: "var(--ds-background-accent-purple-subtler, #
|
|
10
|
+
background: "var(--ds-background-accent-purple-subtler-pressed, #D8A0F7)",
|
|
11
11
|
textDecoration: 'underline',
|
|
12
12
|
textDecorationStyle: 'dotted',
|
|
13
13
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
@@ -7,7 +7,7 @@ export var traditionalInsertStyle = convertToInlineCss({
|
|
|
7
7
|
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
8
8
|
});
|
|
9
9
|
export var traditionalInsertStyleActive = convertToInlineCss({
|
|
10
|
-
background: "var(--ds-background-accent-green-subtler, #
|
|
10
|
+
background: "var(--ds-background-accent-green-subtler-pressed, #7EE2B8)",
|
|
11
11
|
textDecoration: 'underline',
|
|
12
12
|
textDecorationStyle: 'solid',
|
|
13
13
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
@@ -19,6 +19,15 @@ export var deletedTraditionalContentStyle = convertToInlineCss({
|
|
|
19
19
|
position: 'relative',
|
|
20
20
|
opacity: 1
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
/** Emphasised (pressed) strikethrough for traditional removed text when active */
|
|
24
|
+
export var deletedTraditionalContentStyleActive = convertToInlineCss({
|
|
25
|
+
textDecorationColor: "var(--ds-text-accent-red, #AE2E24)",
|
|
26
|
+
textDecoration: 'line-through',
|
|
27
|
+
backgroundColor: "var(--ds-background-accent-red-subtlest-pressed, #FFB8B2)",
|
|
28
|
+
position: 'relative',
|
|
29
|
+
opacity: 1
|
|
30
|
+
});
|
|
22
31
|
export var deletedTraditionalContentStyleUnbounded = convertToInlineCss({
|
|
23
32
|
position: 'absolute',
|
|
24
33
|
top: '50%',
|
|
@@ -28,6 +37,17 @@ export var deletedTraditionalContentStyleUnbounded = convertToInlineCss({
|
|
|
28
37
|
pointerEvents: 'none',
|
|
29
38
|
zIndex: 1
|
|
30
39
|
});
|
|
40
|
+
|
|
41
|
+
/** Emphasised (pressed) strikethrough line for traditional when active */
|
|
42
|
+
export var deletedTraditionalContentStyleUnboundedActive = convertToInlineCss({
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
top: '50%',
|
|
45
|
+
width: '100%',
|
|
46
|
+
display: 'inline-block',
|
|
47
|
+
borderTop: "1px solid ".concat("var(--ds-text-accent-red-bolder, #5D1F1A)"),
|
|
48
|
+
pointerEvents: 'none',
|
|
49
|
+
zIndex: 1
|
|
50
|
+
});
|
|
31
51
|
export var deletedTraditionalStyleQuoteNode = convertToInlineCss({
|
|
32
52
|
marginTop: "var(--ds-space-150, 12px)",
|
|
33
53
|
paddingTop: "var(--ds-space-025, 2px)",
|
|
@@ -53,20 +73,37 @@ export var deletedTraditionalRowStyle = convertToInlineCss({
|
|
|
53
73
|
export var traditionalStyleQuoteNode = convertToInlineCss({
|
|
54
74
|
borderLeft: "2px solid ".concat("var(--ds-border-accent-green, #22A06B)")
|
|
55
75
|
});
|
|
76
|
+
export var traditionalStyleQuoteNodeActive = convertToInlineCss({
|
|
77
|
+
borderLeft: "2px solid ".concat("var(--ds-background-accent-green-subtler-pressed, #7EE2B8)")
|
|
78
|
+
});
|
|
56
79
|
export var traditionalStyleRuleNode = convertToInlineCss({
|
|
57
80
|
backgroundColor: "var(--ds-border-accent-green, #22A06B)"
|
|
58
81
|
});
|
|
82
|
+
export var traditionalStyleRuleNodeActive = convertToInlineCss({
|
|
83
|
+
backgroundColor: "var(--ds-background-accent-green-subtler-pressed, #7EE2B8)"
|
|
84
|
+
});
|
|
59
85
|
export var traditionalStyleNode = convertToInlineCss({
|
|
60
86
|
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
61
87
|
borderRadius: "var(--ds-radius-small, 4px)"
|
|
62
88
|
});
|
|
89
|
+
export var traditionalStyleNodeActive = convertToInlineCss({
|
|
90
|
+
boxShadow: "0 0 0 2px ".concat("var(--ds-background-accent-green-subtler-pressed, #7EE2B8)"),
|
|
91
|
+
borderRadius: "var(--ds-radius-small, 4px)"
|
|
92
|
+
});
|
|
63
93
|
export var traditionalStyleCardBlockNode = convertToInlineCss({
|
|
64
94
|
boxShadow: "0 0 0 1px ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
65
95
|
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
66
96
|
});
|
|
97
|
+
export var traditionalStyleCardBlockNodeActive = convertToInlineCss({
|
|
98
|
+
boxShadow: "0 0 0 1px ".concat("var(--ds-background-accent-green-subtler-pressed, #7EE2B8)"),
|
|
99
|
+
borderRadius: "var(--ds-radius-medium, 6px)"
|
|
100
|
+
});
|
|
67
101
|
export var traditionalDecorationMarkerVariable = convertToInlineCss({
|
|
68
102
|
'--diff-decoration-marker-color': "var(--ds-border-accent-green, #22A06B)"
|
|
69
103
|
});
|
|
104
|
+
export var traditionalDecorationMarkerVariableActive = convertToInlineCss({
|
|
105
|
+
'--diff-decoration-marker-color': "var(--ds-text-accent-green, #216E4E)"
|
|
106
|
+
});
|
|
70
107
|
export var traditionalAddedCellOverlayStyle = convertToInlineCss({
|
|
71
108
|
position: 'absolute',
|
|
72
109
|
top: 0,
|
|
@@ -2,7 +2,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { standardDecorationMarkerVariable, editingStyleQuoteNode, editingStyleRuleNode, editingStyleCardBlockNode, editingStyleNode, deletedContentStyleNew, deletedStyleQuoteNode } from './colorSchemes/standard';
|
|
5
|
-
import { traditionalDecorationMarkerVariable, traditionalStyleQuoteNode, traditionalStyleRuleNode, traditionalStyleCardBlockNode, traditionalStyleNode, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from './colorSchemes/traditional';
|
|
5
|
+
import { traditionalDecorationMarkerVariable, traditionalDecorationMarkerVariableActive, traditionalStyleQuoteNode, traditionalStyleQuoteNodeActive, traditionalStyleRuleNode, traditionalStyleRuleNodeActive, traditionalStyleCardBlockNode, traditionalStyleCardBlockNodeActive, traditionalStyleNode, traditionalStyleNodeActive, deletedTraditionalContentStyle, deletedTraditionalStyleQuoteNode } from './colorSchemes/traditional';
|
|
6
6
|
var getNodeClass = function getNodeClass(name) {
|
|
7
7
|
switch (name) {
|
|
8
8
|
case 'extension':
|
|
@@ -15,7 +15,9 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
|
|
|
15
15
|
var nodeName = _ref.nodeName,
|
|
16
16
|
colorScheme = _ref.colorScheme,
|
|
17
17
|
_ref$isInserted = _ref.isInserted,
|
|
18
|
-
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted
|
|
18
|
+
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
|
|
19
|
+
_ref$isActive = _ref.isActive,
|
|
20
|
+
isActive = _ref$isActive === void 0 ? false : _ref$isActive;
|
|
19
21
|
var isTraditional = colorScheme === 'traditional';
|
|
20
22
|
if (['mediaSingle', 'mediaGroup', 'table',
|
|
21
23
|
// Handle table separately to avoid border issues
|
|
@@ -28,73 +30,79 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
|
|
|
28
30
|
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
29
31
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
30
32
|
if (isInserted) {
|
|
31
|
-
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
33
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
32
34
|
} else {
|
|
33
35
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
return isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
38
|
+
return isTraditional && isActive ? traditionalDecorationMarkerVariableActive : isTraditional ? traditionalDecorationMarkerVariable : standardDecorationMarkerVariable;
|
|
37
39
|
}
|
|
38
40
|
if (nodeName === 'blockquote') {
|
|
39
41
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
40
42
|
if (isInserted) {
|
|
41
|
-
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
43
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
42
44
|
} else {
|
|
43
45
|
return isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNode;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
return isTraditional ? traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
48
|
+
return isTraditional ? isActive ? traditionalStyleQuoteNodeActive : traditionalStyleQuoteNode : editingStyleQuoteNode;
|
|
47
49
|
}
|
|
48
50
|
if (nodeName === 'rule') {
|
|
49
51
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
50
52
|
if (isInserted) {
|
|
51
|
-
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
53
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNode : editingStyleRuleNode;
|
|
52
54
|
} else {
|
|
53
55
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
return isTraditional ? traditionalStyleRuleNode : editingStyleRuleNode;
|
|
58
|
+
return isTraditional ? isActive ? traditionalStyleRuleNodeActive : traditionalStyleRuleNode : editingStyleRuleNode;
|
|
57
59
|
}
|
|
58
60
|
if (nodeName === 'blockCard') {
|
|
59
61
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
60
62
|
if (isInserted) {
|
|
61
|
-
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
63
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
62
64
|
} else {
|
|
63
65
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
return isTraditional ? traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
68
|
+
return isTraditional ? isActive ? traditionalStyleCardBlockNodeActive : traditionalStyleCardBlockNode : editingStyleCardBlockNode;
|
|
67
69
|
}
|
|
68
70
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
69
71
|
if (isInserted) {
|
|
70
|
-
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
72
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNode : editingStyleNode;
|
|
71
73
|
} else {
|
|
72
74
|
return isTraditional ? deletedTraditionalContentStyle : deletedContentStyleNew;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
return isTraditional ? traditionalStyleNode : editingStyleNode;
|
|
77
|
+
return isTraditional ? isActive ? traditionalStyleNodeActive : traditionalStyleNode : editingStyleNode;
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
|
|
80
82
|
*
|
|
81
|
-
* @param change
|
|
82
|
-
* @
|
|
83
|
+
* @param change Node range and name
|
|
84
|
+
* @param colorScheme Optional color scheme
|
|
85
|
+
* @param isActive Whether this node is part of the currently active/focused change
|
|
86
|
+
* @returns Prosemirror node decoration or undefined
|
|
83
87
|
*/
|
|
84
88
|
export var createBlockChangedDecoration = function createBlockChangedDecoration(_ref2) {
|
|
85
89
|
var change = _ref2.change,
|
|
86
90
|
colorScheme = _ref2.colorScheme,
|
|
87
91
|
_ref2$isInserted = _ref2.isInserted,
|
|
88
|
-
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted
|
|
92
|
+
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
|
|
93
|
+
_ref2$isActive = _ref2.isActive,
|
|
94
|
+
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive;
|
|
89
95
|
var style = getBlockNodeStyle({
|
|
90
96
|
nodeName: change.name,
|
|
91
|
-
colorScheme: colorScheme
|
|
97
|
+
colorScheme: colorScheme,
|
|
98
|
+
isActive: isActive
|
|
92
99
|
});
|
|
93
100
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
94
101
|
style = getBlockNodeStyle({
|
|
95
102
|
nodeName: change.name,
|
|
96
103
|
colorScheme: colorScheme,
|
|
97
|
-
isInserted: isInserted
|
|
104
|
+
isInserted: isInserted,
|
|
105
|
+
isActive: isActive
|
|
98
106
|
});
|
|
99
107
|
}
|
|
100
108
|
var className = getNodeClass(change.name);
|
|
@@ -107,15 +115,15 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
107
115
|
}, {
|
|
108
116
|
key: 'diff-block'
|
|
109
117
|
});
|
|
118
|
+
} else {
|
|
119
|
+
return undefined;
|
|
110
120
|
}
|
|
111
|
-
return undefined;
|
|
112
|
-
} else {
|
|
113
|
-
return Decoration.node(change.from, change.to, {
|
|
114
|
-
style: style,
|
|
115
|
-
'data-testid': 'show-diff-changed-decoration-node',
|
|
116
|
-
class: className
|
|
117
|
-
}, {
|
|
118
|
-
key: 'diff-block'
|
|
119
|
-
});
|
|
120
121
|
}
|
|
122
|
+
return Decoration.node(change.from, change.to, {
|
|
123
|
+
style: style,
|
|
124
|
+
'data-testid': 'show-diff-changed-decoration-node',
|
|
125
|
+
class: className
|
|
126
|
+
}, {
|
|
127
|
+
key: 'diff-block'
|
|
128
|
+
});
|
|
121
129
|
};
|
|
@@ -3,11 +3,15 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
5
|
import { editingStyle, editingStyleActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleNewActive, deletedContentStyleUnbounded } from './colorSchemes/standard';
|
|
6
|
-
import { traditionalInsertStyle, traditionalInsertStyleActive, deletedTraditionalContentStyle, deletedTraditionalContentStyleUnbounded } from './colorSchemes/traditional';
|
|
6
|
+
import { traditionalInsertStyle, traditionalInsertStyleActive, deletedTraditionalContentStyle, deletedTraditionalContentStyleActive, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive } from './colorSchemes/traditional';
|
|
7
7
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
8
8
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
9
9
|
import { wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
10
10
|
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
11
|
+
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
12
|
+
if (colorScheme === 'traditional' && isActive) {
|
|
13
|
+
return deletedTraditionalContentStyleUnboundedActive;
|
|
14
|
+
}
|
|
11
15
|
return colorScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
12
16
|
};
|
|
13
17
|
var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
@@ -26,7 +30,7 @@ var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
|
26
30
|
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
27
31
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
28
32
|
if (colorScheme === 'traditional') {
|
|
29
|
-
return deletedTraditionalContentStyle;
|
|
33
|
+
return isActive ? deletedTraditionalContentStyleActive : deletedTraditionalContentStyle;
|
|
30
34
|
}
|
|
31
35
|
if (isActive) {
|
|
32
36
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNewActive : deletedContentStyleActive;
|
|
@@ -247,7 +251,9 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
247
251
|
// Widget decoration used for deletions as the content is not in the document
|
|
248
252
|
// and we want to display the deleted content with a style.
|
|
249
253
|
var safeInsertPos = findSafeInsertPos(newDoc, change.fromB, slice);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
var decorations = [];
|
|
255
|
+
decorations.push(Decoration.widget(safeInsertPos, dom, {
|
|
256
|
+
key: "diff-widget-".concat(isActive ? 'active' : 'inactive')
|
|
257
|
+
}));
|
|
258
|
+
return decorations;
|
|
253
259
|
};
|
|
@@ -13,10 +13,13 @@ import { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
13
13
|
import { scrollToActiveDecoration } from './scrollToActiveDecoration';
|
|
14
14
|
export var showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
15
15
|
export var getScrollableDecorations = function getScrollableDecorations(set) {
|
|
16
|
-
var _set$find;
|
|
17
|
-
return (_set$find = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
var _set$find$sort;
|
|
17
|
+
return (_set$find$sort = set === null || set === void 0 ? void 0 : set.find(undefined, undefined, function (spec) {
|
|
18
|
+
var _spec$key;
|
|
19
|
+
return spec.key === 'diff-inline' || ((_spec$key = spec.key) === null || _spec$key === void 0 ? void 0 : _spec$key.startsWith('diff-widget')) || spec.key === 'diff-block';
|
|
20
|
+
}).sort(function (a, b) {
|
|
21
|
+
return a.from - b.from;
|
|
22
|
+
})) !== null && _set$find$sort !== void 0 ? _set$find$sort : [];
|
|
20
23
|
};
|
|
21
24
|
export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
22
25
|
var nodeViewSerializer = new NodeViewSerializer({});
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
export declare const traditionalInsertStyle: string;
|
|
2
2
|
export declare const traditionalInsertStyleActive: string;
|
|
3
3
|
export declare const deletedTraditionalContentStyle: string;
|
|
4
|
+
/** Emphasised (pressed) strikethrough for traditional removed text when active */
|
|
5
|
+
export declare const deletedTraditionalContentStyleActive: string;
|
|
4
6
|
export declare const deletedTraditionalContentStyleUnbounded: string;
|
|
7
|
+
/** Emphasised (pressed) strikethrough line for traditional when active */
|
|
8
|
+
export declare const deletedTraditionalContentStyleUnboundedActive: string;
|
|
5
9
|
export declare const deletedTraditionalStyleQuoteNode: string;
|
|
6
10
|
export declare const deletedTraditionalBlockOutline: string;
|
|
7
11
|
export declare const deletedTraditionalBlockOutlineRounded: string;
|
|
8
12
|
export declare const deletedTraditionalRowStyle: string;
|
|
9
13
|
export declare const traditionalStyleQuoteNode: string;
|
|
14
|
+
export declare const traditionalStyleQuoteNodeActive: string;
|
|
10
15
|
export declare const traditionalStyleRuleNode: string;
|
|
16
|
+
export declare const traditionalStyleRuleNodeActive: string;
|
|
11
17
|
export declare const traditionalStyleNode: string;
|
|
18
|
+
export declare const traditionalStyleNodeActive: string;
|
|
12
19
|
export declare const traditionalStyleCardBlockNode: string;
|
|
20
|
+
export declare const traditionalStyleCardBlockNodeActive: string;
|
|
13
21
|
export declare const traditionalDecorationMarkerVariable: string;
|
|
22
|
+
export declare const traditionalDecorationMarkerVariableActive: string;
|
|
14
23
|
export declare const traditionalAddedCellOverlayStyle: string;
|
|
15
24
|
export declare const deletedTraditionalCellOverlayStyle: string;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
|
|
5
5
|
*
|
|
6
|
-
* @param change
|
|
7
|
-
* @
|
|
6
|
+
* @param change Node range and name
|
|
7
|
+
* @param colorScheme Optional color scheme
|
|
8
|
+
* @param isActive Whether this node is part of the currently active/focused change
|
|
9
|
+
* @returns Prosemirror node decoration or undefined
|
|
8
10
|
*/
|
|
9
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, }: {
|
|
11
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, }: {
|
|
10
12
|
change: {
|
|
11
13
|
from: number;
|
|
12
14
|
name: string;
|
|
13
15
|
to: number;
|
|
14
16
|
};
|
|
15
17
|
colorScheme?: ColorScheme;
|
|
16
|
-
|
|
18
|
+
isActive?: boolean;
|
|
19
|
+
isInserted?: boolean;
|
|
17
20
|
}) => Decoration | undefined;
|
|
@@ -9,7 +9,7 @@ import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
|
9
9
|
* that is not in the current document.
|
|
10
10
|
*/
|
|
11
11
|
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, isActive, isInserted, }: {
|
|
12
|
-
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted">;
|
|
12
|
+
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted" | "toB">;
|
|
13
13
|
colorScheme?: ColorScheme;
|
|
14
14
|
doc: PMNode;
|
|
15
15
|
intl: IntlShape;
|