@atlaskit/editor-plugin-show-diff 13.0.11 → 13.1.1
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 +32 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +259 -23
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +21 -5
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +87 -105
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +124 -0
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +37 -0
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +109 -59
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +67 -0
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +30 -168
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +205 -0
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +225 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +247 -23
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +20 -4
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +85 -105
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +118 -0
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +33 -0
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +82 -37
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +62 -0
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +15 -140
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +143 -0
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +200 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +248 -23
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +20 -4
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +87 -105
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +118 -0
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +15 -12
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.js +32 -0
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +109 -59
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +61 -0
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +15 -153
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +198 -0
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +218 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +78 -6
- package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +3 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +13 -3
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.d.ts +14 -0
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.styles.legacy.d.ts +22 -0
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.d.ts +26 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +39 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.d.ts +40 -0
- package/package.json +4 -3
|
@@ -8,15 +8,65 @@ exports.createBlockChangedDecoration = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
14
|
+
var _factory = require("./colorSchemes/factory");
|
|
15
|
+
var _schemes = require("./colorSchemes/schemes");
|
|
15
16
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
16
17
|
var _decorationKeys = require("./decorationKeys");
|
|
18
|
+
var _createBlockChangedDecorationStyles = require("./createBlockChangedDecoration.styles.legacy");
|
|
17
19
|
var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
18
20
|
display: 'none'
|
|
19
21
|
});
|
|
22
|
+
var DEFAULT_COLOR_SCHEME = 'standard';
|
|
23
|
+
|
|
24
|
+
/** Nodes that carry no decoration styling of their own — layout, lists, text blocks, media groups. */
|
|
25
|
+
var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
|
|
26
|
+
// Handle table separately to avoid border issues
|
|
27
|
+
'tableRow', 'paragraph',
|
|
28
|
+
// Paragraph and heading nodes do not need special styling
|
|
29
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
|
|
30
|
+
var CELL_NODES = ['tableCell', 'tableHeader'];
|
|
31
|
+
|
|
32
|
+
/** Positioning context for the cell overlay widget decorations. */
|
|
33
|
+
var cellPositionStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
34
|
+
position: 'relative'
|
|
35
|
+
});
|
|
36
|
+
var getInsertedBlockNodeShape = function getInsertedBlockNodeShape(nodeName) {
|
|
37
|
+
switch (nodeName) {
|
|
38
|
+
case 'blockquote':
|
|
39
|
+
return 'quote';
|
|
40
|
+
case 'rule':
|
|
41
|
+
return 'rule';
|
|
42
|
+
case 'blockCard':
|
|
43
|
+
return 'cardBlock';
|
|
44
|
+
case 'extension':
|
|
45
|
+
case 'embedCard':
|
|
46
|
+
case 'listItem':
|
|
47
|
+
return 'marker';
|
|
48
|
+
default:
|
|
49
|
+
return 'node';
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var getDeletedBlockNodeCategory = function getDeletedBlockNodeCategory(nodeName) {
|
|
53
|
+
switch (nodeName) {
|
|
54
|
+
case 'blockquote':
|
|
55
|
+
return 'quote';
|
|
56
|
+
// Media nodes inside mediaSingle should not get position:relative
|
|
57
|
+
// as it shifts the image outside its parent container (e.g. panel)
|
|
58
|
+
case 'media':
|
|
59
|
+
case 'panel':
|
|
60
|
+
return 'container';
|
|
61
|
+
case 'listItem':
|
|
62
|
+
return 'listItem';
|
|
63
|
+
case 'extension':
|
|
64
|
+
case 'embedCard':
|
|
65
|
+
return 'marker';
|
|
66
|
+
default:
|
|
67
|
+
return 'generic';
|
|
68
|
+
}
|
|
69
|
+
};
|
|
20
70
|
var getNodeClass = function getNodeClass(name) {
|
|
21
71
|
switch (name) {
|
|
22
72
|
case 'extension':
|
|
@@ -25,7 +75,7 @@ var getNodeClass = function getNodeClass(name) {
|
|
|
25
75
|
return undefined;
|
|
26
76
|
}
|
|
27
77
|
};
|
|
28
|
-
var
|
|
78
|
+
var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
|
|
29
79
|
var nodeName = _ref.nodeName,
|
|
30
80
|
colorScheme = _ref.colorScheme,
|
|
31
81
|
_ref$isInserted = _ref.isInserted,
|
|
@@ -33,90 +83,29 @@ var getBlockNodeStyle = function getBlockNodeStyle(_ref) {
|
|
|
33
83
|
_ref$isActive = _ref.isActive,
|
|
34
84
|
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
35
85
|
diffType = _ref.diffType;
|
|
36
|
-
|
|
37
|
-
if (['mediaSingle', 'mediaGroup', 'table',
|
|
38
|
-
// Handle table separately to avoid border issues
|
|
39
|
-
'tableRow', 'paragraph',
|
|
40
|
-
// Paragraph and heading nodes do not need special styling
|
|
41
|
-
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
42
|
-
// Layout nodes do not need special styling
|
|
86
|
+
if (UNSTYLED_NODES.includes(nodeName)) {
|
|
43
87
|
return undefined;
|
|
44
88
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!isInserted && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
49
|
-
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedDecorationMarkerVariable;
|
|
50
|
-
}
|
|
51
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
52
|
-
}
|
|
53
|
-
if (['tableCell', 'tableHeader'].includes(nodeName)) {
|
|
54
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
55
|
-
// This is used for positioning the cell overlay widget decorations
|
|
56
|
-
return (0, _lazyNodeView.convertToInlineCss)({
|
|
57
|
-
position: 'relative'
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
// When gate is off, it should return undefined as above
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
if (nodeName === 'panel') {
|
|
64
|
-
if (!isInserted && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
65
|
-
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedDecorationMarkerVariable;
|
|
66
|
-
}
|
|
67
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
68
|
-
}
|
|
69
|
-
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
70
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
71
|
-
if (isInserted) {
|
|
72
|
-
return isTraditional && isActive ? _traditional.traditionalDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDecorationMarkerVariableNew : _standard.standardDecorationMarkerVariable;
|
|
73
|
-
} else {
|
|
74
|
-
if (nodeName === 'listItem') {
|
|
75
|
-
return isTraditional && isActive ? _traditional.traditionalDeletedDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDeletedDecorationMarkerVariableNew : _standard.deletedDecorationMarkerVariable;
|
|
76
|
-
}
|
|
77
|
-
return isTraditional && isActive ? _traditional.traditionalDeletedDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDeletedDecorationMarkerVariableNew : _standard.deletedContentStyleNew;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return isTraditional && isActive ? _traditional.traditionalDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDecorationMarkerVariableNew : _standard.standardDecorationMarkerVariable;
|
|
81
|
-
}
|
|
82
|
-
if (nodeName === 'blockquote') {
|
|
83
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
84
|
-
if (isInserted) {
|
|
85
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleQuoteNodeActive : _traditional.traditionalStyleQuoteNodeNew : _standard.editingStyleQuoteNode;
|
|
86
|
-
} else {
|
|
87
|
-
return isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNode;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleQuoteNodeActive : _traditional.traditionalStyleQuoteNodeNew : _standard.editingStyleQuoteNode;
|
|
91
|
-
}
|
|
92
|
-
if (nodeName === 'rule') {
|
|
93
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
94
|
-
if (isInserted) {
|
|
95
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleRuleNodeActive : _traditional.traditionalStyleRuleNodeNew : _standard.editingStyleRuleNode;
|
|
96
|
-
} else {
|
|
97
|
-
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleRuleNodeActive : _traditional.traditionalStyleRuleNodeNew : _standard.editingStyleRuleNode;
|
|
89
|
+
if (CELL_NODES.includes(nodeName)) {
|
|
90
|
+
// When the gate is off, cells get no styling — as with UNSTYLED_NODES above.
|
|
91
|
+
return (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? cellPositionStyle : undefined;
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleCardBlockNodeActive : _traditional.traditionalStyleCardBlockNodeNew : _standard.editingStyleCardBlockNode;
|
|
111
|
-
}
|
|
112
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
113
|
-
if (isInserted) {
|
|
114
|
-
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
115
|
-
} else {
|
|
116
|
-
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
117
|
-
}
|
|
93
|
+
var colors = _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
|
|
94
|
+
|
|
95
|
+
// Deleted nodes only differ under the extended experience; otherwise all are insertions.
|
|
96
|
+
if (!isInserted && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
97
|
+
return (0, _factory.buildDeletedBlockNodeStyle)(colors, getDeletedBlockNodeCategory(nodeName), isActive);
|
|
118
98
|
}
|
|
119
|
-
return
|
|
99
|
+
return (0, _factory.buildInsertedBlockNodeStyle)(colors, getInsertedBlockNodeShape(nodeName), isActive);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Dispatches to the registry-driven implementation, or to the verbatim pre-refactor one for the
|
|
104
|
+
* OFF cohort of `platform_editor_show_diff_color_scheme_refactor`. Both are built to emit the
|
|
105
|
+
* same style strings for both shipped schemes; see EDITOR-8281.
|
|
106
|
+
*/
|
|
107
|
+
var getBlockNodeStyle = function getBlockNodeStyle(props) {
|
|
108
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : (0, _createBlockChangedDecorationStyles.getBlockNodeStyleLegacy)(props);
|
|
120
109
|
};
|
|
121
110
|
|
|
122
111
|
/**
|
|
@@ -179,20 +168,21 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
179
168
|
diffType: diffType
|
|
180
169
|
}))];
|
|
181
170
|
}
|
|
182
|
-
|
|
183
|
-
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && ['tableCell', 'tableHeader'].includes(change.name)) {
|
|
171
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && CELL_NODES.includes(change.name)) {
|
|
184
172
|
var cellOverlay = document.createElement('div');
|
|
185
|
-
var
|
|
173
|
+
var colors = _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
|
|
186
174
|
var isRoundedTable = (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
187
|
-
var addedCellStyle = isTraditional ? isRoundedTable ? _traditional.traditionalAddedCellOverlayRoundedStyle : _traditional.traditionalAddedCellOverlayStyle : isRoundedTable ? _standard.addedCellOverlayRoundedStyle : _standard.addedCellOverlayStyle;
|
|
188
|
-
var deletedCellStyle = isTraditional ? isRoundedTable ? _traditional.deletedTraditionalCellOverlayRoundedStyle : _traditional.deletedTraditionalCellOverlayStyle : isRoundedTable ? _standard.deletedCellOverlayRoundedStyle : _standard.deletedCellOverlayStyle;
|
|
189
175
|
|
|
190
176
|
// On an inverted diff, an empty cell being filled is an addition, so give it the
|
|
191
177
|
// added (purple) overlay instead of the deleted (grey) one (EDITOR-8442).
|
|
192
178
|
var cellNode = doc === null || doc === void 0 ? void 0 : doc.nodeAt(change.from);
|
|
193
179
|
var isEmptyCellBeingFilled = !isInserted && !!cellNode && isCellEmpty(cellNode);
|
|
194
180
|
var useAddedStyle = isInserted || isEmptyCellBeingFilled;
|
|
195
|
-
var cellOverlayStyle = useAddedStyle ?
|
|
181
|
+
var cellOverlayStyle = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? useAddedStyle ? isRoundedTable ? (0, _factory.buildAddedCellOverlayRoundedStyle)(colors) : (0, _factory.buildAddedCellOverlayStyle)(colors) : isRoundedTable ? (0, _factory.buildDeletedCellOverlayRoundedStyle)(colors) : (0, _factory.buildDeletedCellOverlayStyle)(colors) : (0, _createBlockChangedDecorationStyles.resolveCellOverlayStyleLegacy)({
|
|
182
|
+
colorScheme: colorScheme,
|
|
183
|
+
isRoundedTable: isRoundedTable,
|
|
184
|
+
useAddedStyle: useAddedStyle
|
|
185
|
+
});
|
|
196
186
|
cellOverlay.setAttribute('style', cellOverlayStyle);
|
|
197
187
|
decorations.push(
|
|
198
188
|
// change.to - 1 to position the overlay inside the end of the cell
|
|
@@ -202,22 +192,14 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
202
192
|
key: 'cell-overlay-decoration'
|
|
203
193
|
}));
|
|
204
194
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
} else {
|
|
214
|
-
style = getBlockNodeStyle({
|
|
215
|
-
nodeName: change.name,
|
|
216
|
-
colorScheme: colorScheme,
|
|
217
|
-
isActive: isActive,
|
|
218
|
-
diffType: diffType
|
|
219
|
-
});
|
|
220
|
-
}
|
|
195
|
+
// isInserted is only read under the extended experience, so pass it unconditionally.
|
|
196
|
+
var style = getBlockNodeStyle({
|
|
197
|
+
nodeName: change.name,
|
|
198
|
+
colorScheme: colorScheme,
|
|
199
|
+
isInserted: isInserted,
|
|
200
|
+
isActive: isActive,
|
|
201
|
+
diffType: diffType
|
|
202
|
+
});
|
|
221
203
|
var className = getNodeClass(change.name);
|
|
222
204
|
if (style || className) {
|
|
223
205
|
decorations.push(_view.Decoration.node(change.from, change.to, {
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveCellOverlayStyleLegacy = exports.getBlockNodeStyleLegacy = void 0;
|
|
7
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
+
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
9
|
+
var _standard = require("./colorSchemes/standard");
|
|
10
|
+
var _traditional = require("./colorSchemes/traditional");
|
|
11
|
+
/**
|
|
12
|
+
* Pre-refactor code preserved for the OFF cohort of
|
|
13
|
+
* `platform_editor_show_diff_color_scheme_refactor`.
|
|
14
|
+
*
|
|
15
|
+
* This is a verbatim copy of the `getBlockNodeStyle` and the cell-overlay style selection that
|
|
16
|
+
* lived in `createBlockChangedDecoration.ts` before the `colorSchemeRegistry` + `factory.ts`
|
|
17
|
+
* migration. Do not modify it — it exists so the OFF cohort keeps the exact pre-refactor style
|
|
18
|
+
* strings. Delete this file at cleanup, together with `colorSchemes/standard.ts`,
|
|
19
|
+
* `colorSchemes/traditional.ts` (EDITOR-8281).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Verbatim copy of the pre-refactor cell-overlay style selection. */
|
|
23
|
+
var resolveCellOverlayStyleLegacy = exports.resolveCellOverlayStyleLegacy = function resolveCellOverlayStyleLegacy(_ref) {
|
|
24
|
+
var colorScheme = _ref.colorScheme,
|
|
25
|
+
isRoundedTable = _ref.isRoundedTable,
|
|
26
|
+
useAddedStyle = _ref.useAddedStyle;
|
|
27
|
+
var isTraditional = colorScheme === 'traditional';
|
|
28
|
+
var addedCellStyle = isTraditional ? isRoundedTable ? _traditional.traditionalAddedCellOverlayRoundedStyle : _traditional.traditionalAddedCellOverlayStyle : isRoundedTable ? _standard.addedCellOverlayRoundedStyle : _standard.addedCellOverlayStyle;
|
|
29
|
+
var deletedCellStyle = isTraditional ? isRoundedTable ? _traditional.deletedTraditionalCellOverlayRoundedStyle : _traditional.deletedTraditionalCellOverlayStyle : isRoundedTable ? _standard.deletedCellOverlayRoundedStyle : _standard.deletedCellOverlayStyle;
|
|
30
|
+
return useAddedStyle ? addedCellStyle : deletedCellStyle;
|
|
31
|
+
};
|
|
32
|
+
var getBlockNodeStyleLegacy = exports.getBlockNodeStyleLegacy = function getBlockNodeStyleLegacy(_ref2) {
|
|
33
|
+
var nodeName = _ref2.nodeName,
|
|
34
|
+
colorScheme = _ref2.colorScheme,
|
|
35
|
+
_ref2$isInserted = _ref2.isInserted,
|
|
36
|
+
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
|
|
37
|
+
_ref2$isActive = _ref2.isActive,
|
|
38
|
+
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
|
|
39
|
+
diffType = _ref2.diffType;
|
|
40
|
+
var isTraditional = colorScheme === 'traditional';
|
|
41
|
+
if (['mediaSingle', 'mediaGroup', 'table',
|
|
42
|
+
// Handle table separately to avoid border issues
|
|
43
|
+
'tableRow', 'paragraph',
|
|
44
|
+
// Paragraph and heading nodes do not need special styling
|
|
45
|
+
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'].includes(nodeName)) {
|
|
46
|
+
// Layout nodes do not need special styling
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
// Media nodes inside mediaSingle should not get position:relative
|
|
50
|
+
// as it shifts the image outside its parent container (e.g. panel)
|
|
51
|
+
if (nodeName === 'media') {
|
|
52
|
+
if (!isInserted && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
53
|
+
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedDecorationMarkerVariable;
|
|
54
|
+
}
|
|
55
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
56
|
+
}
|
|
57
|
+
if (['tableCell', 'tableHeader'].includes(nodeName)) {
|
|
58
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
59
|
+
// This is used for positioning the cell overlay widget decorations
|
|
60
|
+
return (0, _lazyNodeView.convertToInlineCss)({
|
|
61
|
+
position: 'relative'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// When gate is off, it should return undefined as above
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
if (nodeName === 'panel') {
|
|
68
|
+
if (!isInserted && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
69
|
+
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedDecorationMarkerVariable;
|
|
70
|
+
}
|
|
71
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
72
|
+
}
|
|
73
|
+
if (['extension', 'embedCard', 'listItem'].includes(nodeName)) {
|
|
74
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
75
|
+
if (isInserted) {
|
|
76
|
+
return isTraditional && isActive ? _traditional.traditionalDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDecorationMarkerVariableNew : _standard.standardDecorationMarkerVariable;
|
|
77
|
+
} else {
|
|
78
|
+
if (nodeName === 'listItem') {
|
|
79
|
+
return isTraditional && isActive ? _traditional.traditionalDeletedDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDeletedDecorationMarkerVariableNew : _standard.deletedDecorationMarkerVariable;
|
|
80
|
+
}
|
|
81
|
+
return isTraditional && isActive ? _traditional.traditionalDeletedDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDeletedDecorationMarkerVariableNew : _standard.deletedContentStyleNew;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return isTraditional && isActive ? _traditional.traditionalDecorationMarkerVariableActive : isTraditional ? _traditional.traditionalDecorationMarkerVariableNew : _standard.standardDecorationMarkerVariable;
|
|
85
|
+
}
|
|
86
|
+
if (nodeName === 'blockquote') {
|
|
87
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
88
|
+
if (isInserted) {
|
|
89
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleQuoteNodeActive : _traditional.traditionalStyleQuoteNodeNew : _standard.editingStyleQuoteNode;
|
|
90
|
+
} else {
|
|
91
|
+
return isTraditional ? _traditional.deletedTraditionalStyleQuoteNode : _standard.deletedStyleQuoteNode;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleQuoteNodeActive : _traditional.traditionalStyleQuoteNodeNew : _standard.editingStyleQuoteNode;
|
|
95
|
+
}
|
|
96
|
+
if (nodeName === 'rule') {
|
|
97
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
98
|
+
if (isInserted) {
|
|
99
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleRuleNodeActive : _traditional.traditionalStyleRuleNodeNew : _standard.editingStyleRuleNode;
|
|
100
|
+
} else {
|
|
101
|
+
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleRuleNodeActive : _traditional.traditionalStyleRuleNodeNew : _standard.editingStyleRuleNode;
|
|
105
|
+
}
|
|
106
|
+
if (nodeName === 'blockCard') {
|
|
107
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
108
|
+
if (isInserted) {
|
|
109
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleCardBlockNodeActive : _traditional.traditionalStyleCardBlockNodeNew : _standard.editingStyleCardBlockNode;
|
|
110
|
+
} else {
|
|
111
|
+
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleCardBlockNodeActive : _traditional.traditionalStyleCardBlockNodeNew : _standard.editingStyleCardBlockNode;
|
|
115
|
+
}
|
|
116
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
117
|
+
if (isInserted) {
|
|
118
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
119
|
+
} else {
|
|
120
|
+
return isTraditional ? (0, _traditional.getDeletedTraditionalInlineStyle)(false) : _standard.deletedContentStyleNew;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return isTraditional ? isActive ? _traditional.traditionalStyleNodeActive : _traditional.traditionalStyleNodeNew : _standard.editingStyleNode;
|
|
124
|
+
};
|
|
@@ -11,10 +11,12 @@ var _document = require("@atlaskit/editor-common/utils/document");
|
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
13
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
14
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
16
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
17
|
+
var _factory = require("./colorSchemes/factory");
|
|
18
|
+
var _schemes = require("./colorSchemes/schemes");
|
|
19
|
+
var _createChangedRowDecorationWidgetsStyles = require("./createChangedRowDecorationWidgets.styles.legacy");
|
|
18
20
|
var _decorationKeys = require("./decorationKeys");
|
|
19
21
|
var _findSafeInsertPos = require("./utils/findSafeInsertPos");
|
|
20
22
|
var _tableCellEdgeAttrs = require("./utils/tableCellEdgeAttrs");
|
|
@@ -23,6 +25,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
23
25
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
24
26
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
25
27
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
28
|
+
var DEFAULT_COLOR_SCHEME = 'standard';
|
|
26
29
|
/**
|
|
27
30
|
* Extracts information about deleted table rows from a change
|
|
28
31
|
*/
|
|
@@ -133,12 +136,11 @@ var isEmptyRow = function isEmptyRow(rowNode) {
|
|
|
133
136
|
*/
|
|
134
137
|
var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
135
138
|
var tr = document.createElement('tr');
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
tr.setAttribute('style', colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle);
|
|
139
|
+
var colors = _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
|
|
140
|
+
|
|
141
|
+
// Inserted rows keep their natural styling; the row strikethrough is deletions only.
|
|
142
|
+
if (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted) {
|
|
143
|
+
tr.setAttribute('style', (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? (0, _factory.buildDeletedRowStyle)(colors) : (0, _createChangedRowDecorationWidgetsStyles.resolveDeletedRowStyleLegacy)(colorScheme));
|
|
142
144
|
}
|
|
143
145
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
144
146
|
|
|
@@ -153,10 +155,11 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
|
|
|
153
155
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
154
156
|
var overlay = document.createElement('span');
|
|
155
157
|
var isRoundedTable = (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
var overlayStyle = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? isInserted ? isRoundedTable ? (0, _factory.buildAddedCellOverlayRoundedStyle)(colors) : (0, _factory.buildAddedCellOverlayStyle)(colors) : isRoundedTable ? (0, _factory.buildDeletedCellOverlayRoundedStyle)(colors) : (0, _factory.buildDeletedCellOverlayStyle)(colors) : (0, _createChangedRowDecorationWidgetsStyles.resolveCellOverlayStyleLegacy)({
|
|
159
|
+
colorScheme: colorScheme,
|
|
160
|
+
isInserted: isInserted,
|
|
161
|
+
isRoundedTable: isRoundedTable
|
|
162
|
+
});
|
|
160
163
|
overlay.setAttribute('style', overlayStyle);
|
|
161
164
|
nodeView.appendChild(overlay);
|
|
162
165
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveDeletedRowStyleLegacy = exports.resolveCellOverlayStyleLegacy = void 0;
|
|
7
|
+
var _standard = require("./colorSchemes/standard");
|
|
8
|
+
var _traditional = require("./colorSchemes/traditional");
|
|
9
|
+
/**
|
|
10
|
+
* Pre-refactor code preserved for the OFF cohort of
|
|
11
|
+
* `platform_editor_show_diff_color_scheme_refactor`.
|
|
12
|
+
*
|
|
13
|
+
* These resolvers reproduce the per-scheme string-constant style decisions that
|
|
14
|
+
* `createChangedRowDOM` made before the `colorSchemeRegistry` + `factory.ts` migration, verbatim.
|
|
15
|
+
*
|
|
16
|
+
* Do not modify. Delete this file at experiment cleanup (EDITOR-8281).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Pre-refactor deleted-row style for the `<tr>` element.
|
|
21
|
+
*/
|
|
22
|
+
var resolveDeletedRowStyleLegacy = exports.resolveDeletedRowStyleLegacy = function resolveDeletedRowStyleLegacy(colorScheme) {
|
|
23
|
+
return colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Pre-refactor cell overlay style.
|
|
28
|
+
*/
|
|
29
|
+
var resolveCellOverlayStyleLegacy = exports.resolveCellOverlayStyleLegacy = function resolveCellOverlayStyleLegacy(_ref) {
|
|
30
|
+
var colorScheme = _ref.colorScheme,
|
|
31
|
+
isInserted = _ref.isInserted,
|
|
32
|
+
isRoundedTable = _ref.isRoundedTable;
|
|
33
|
+
var isTraditional = colorScheme === 'traditional';
|
|
34
|
+
var deletedCellStyle = isTraditional ? isRoundedTable ? _traditional.deletedTraditionalCellOverlayRoundedStyle : _traditional.deletedTraditionalCellOverlayStyle : isRoundedTable ? _standard.deletedCellOverlayRoundedStyle : _standard.deletedCellOverlayStyle;
|
|
35
|
+
var addedCellStyle = isTraditional ? isRoundedTable ? _traditional.traditionalAddedCellOverlayRoundedStyle : _traditional.traditionalAddedCellOverlayStyle : isRoundedTable ? _standard.addedCellOverlayRoundedStyle : _standard.addedCellOverlayStyle;
|
|
36
|
+
return isInserted ? addedCellStyle : deletedCellStyle;
|
|
37
|
+
};
|