@atlaskit/editor-plugin-show-diff 4.1.4 → 5.0.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 +17 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +11 -11
- package/dist/cjs/pm-plugins/decorations.js +21 -21
- package/dist/cjs/pm-plugins/deletedBlocksHandler.js +22 -22
- package/dist/cjs/pm-plugins/deletedRowsHandler.js +7 -7
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +11 -11
- package/dist/es2019/pm-plugins/decorations.js +20 -20
- package/dist/es2019/pm-plugins/deletedBlocksHandler.js +22 -22
- package/dist/es2019/pm-plugins/deletedRowsHandler.js +7 -7
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +11 -11
- package/dist/esm/pm-plugins/decorations.js +21 -21
- package/dist/esm/pm-plugins/deletedBlocksHandler.js +22 -22
- package/dist/esm/pm-plugins/deletedRowsHandler.js +7 -7
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -2
- package/dist/types/pm-plugins/decorations.d.ts +6 -6
- package/dist/types/pm-plugins/deletedBlocksHandler.d.ts +8 -8
- package/dist/types/pm-plugins/deletedRowsHandler.d.ts +3 -3
- package/dist/types/showDiffPluginType.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +6 -6
- package/dist/types-ts4.5/pm-plugins/deletedBlocksHandler.d.ts +8 -8
- package/dist/types-ts4.5/pm-plugins/deletedRowsHandler.d.ts +3 -3
- package/dist/types-ts4.5/showDiffPluginType.d.ts +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 5.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 5.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [`b5af20d6e019c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b5af20d6e019c) -
|
|
14
|
+
EDITOR-5632: Change colourScheme param to colorScheme for standardisation.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 4.1.4
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -22,7 +22,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
22
22
|
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; }
|
|
23
23
|
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; }
|
|
24
24
|
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; } // eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
25
|
-
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to,
|
|
25
|
+
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(doc, from, to, colorScheme) {
|
|
26
26
|
var decorations = [];
|
|
27
27
|
// Iterate over the document nodes within the range
|
|
28
28
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
@@ -31,7 +31,7 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
31
31
|
from: pos,
|
|
32
32
|
to: pos + node.nodeSize,
|
|
33
33
|
name: node.type.name
|
|
34
|
-
},
|
|
34
|
+
}, colorScheme);
|
|
35
35
|
if (decoration) {
|
|
36
36
|
decorations.push(decoration);
|
|
37
37
|
}
|
|
@@ -76,7 +76,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
76
76
|
var state = _ref.state,
|
|
77
77
|
pluginState = _ref.pluginState,
|
|
78
78
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
79
|
-
|
|
79
|
+
colorScheme = _ref.colorScheme,
|
|
80
80
|
intl = _ref.intl,
|
|
81
81
|
activeIndexPos = _ref.activeIndexPos;
|
|
82
82
|
var originalDoc = pluginState.originalDoc,
|
|
@@ -121,8 +121,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
121
121
|
optimizedChanges.forEach(function (change) {
|
|
122
122
|
var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
123
123
|
if (change.inserted.length > 0) {
|
|
124
|
-
decorations.push((0, _decorations.createInlineChangedDecoration)(change,
|
|
125
|
-
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB,
|
|
124
|
+
decorations.push((0, _decorations.createInlineChangedDecoration)(change, colorScheme, isActive));
|
|
125
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
|
|
126
126
|
}
|
|
127
127
|
if (change.deleted.length > 0) {
|
|
128
128
|
var _isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
@@ -130,7 +130,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
130
130
|
change: change,
|
|
131
131
|
doc: originalDoc,
|
|
132
132
|
nodeViewSerializer: nodeViewSerializer,
|
|
133
|
-
|
|
133
|
+
colorScheme: colorScheme,
|
|
134
134
|
newDoc: tr.doc,
|
|
135
135
|
intl: intl,
|
|
136
136
|
isActive: _isActive
|
|
@@ -142,10 +142,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref)
|
|
|
142
142
|
});
|
|
143
143
|
(0, _markDecorations.getMarkChangeRanges)(steps).forEach(function (change) {
|
|
144
144
|
var isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
145
|
-
decorations.push((0, _decorations.createInlineChangedDecoration)(change,
|
|
145
|
+
decorations.push((0, _decorations.createInlineChangedDecoration)(change, colorScheme, isActive));
|
|
146
146
|
});
|
|
147
147
|
(0, _attributeDecorations.getAttrChangeRanges)(tr.doc, attrSteps).forEach(function (change) {
|
|
148
|
-
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB,
|
|
148
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme)));
|
|
149
149
|
});
|
|
150
150
|
return _view.DecorationSet.empty.add(tr.doc, decorations);
|
|
151
151
|
};
|
|
@@ -157,16 +157,16 @@ function (_ref2, _ref3) {
|
|
|
157
157
|
_ref4$ = _ref4[0],
|
|
158
158
|
pluginState = _ref4$.pluginState,
|
|
159
159
|
state = _ref4$.state,
|
|
160
|
-
|
|
160
|
+
colorScheme = _ref4$.colorScheme,
|
|
161
161
|
intl = _ref4$.intl,
|
|
162
162
|
activeIndexPos = _ref4$.activeIndexPos;
|
|
163
163
|
var _ref5 = (0, _slicedToArray2.default)(_ref3, 1),
|
|
164
164
|
_ref5$ = _ref5[0],
|
|
165
165
|
lastPluginState = _ref5$.pluginState,
|
|
166
166
|
lastState = _ref5$.state,
|
|
167
|
-
|
|
167
|
+
lastColorScheme = _ref5$.colorScheme,
|
|
168
168
|
lastIntl = _ref5$.intl,
|
|
169
169
|
lastActiveIndexPos = _ref5$.activeIndexPos;
|
|
170
170
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
171
|
-
return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) &&
|
|
171
|
+
return (_ref6 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos)) !== null && _ref6 !== void 0 ? _ref6 : false;
|
|
172
172
|
});
|
|
@@ -19,10 +19,10 @@ var _findSafeInsertPos = require("./findSafeInsertPos");
|
|
|
19
19
|
* @param change Changeset "change" containing information about the change content + range
|
|
20
20
|
* @returns Prosemirror inline decoration
|
|
21
21
|
*/
|
|
22
|
-
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change,
|
|
22
|
+
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change, colorScheme) {
|
|
23
23
|
var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
24
24
|
var style;
|
|
25
|
-
if (
|
|
25
|
+
if (colorScheme === 'traditional') {
|
|
26
26
|
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
|
|
27
27
|
} else {
|
|
28
28
|
style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
|
|
@@ -34,12 +34,12 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
34
34
|
key: 'diff-inline'
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(
|
|
38
|
-
return
|
|
37
|
+
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
38
|
+
return colorScheme === 'traditional' ? _traditional.deletedTraditionalContentStyleUnbounded : _standard.deletedContentStyleUnbounded;
|
|
39
39
|
};
|
|
40
|
-
var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(
|
|
40
|
+
var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
41
41
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
42
|
-
if (
|
|
42
|
+
if (colorScheme === 'traditional') {
|
|
43
43
|
return _traditional.deletedTraditionalContentStyle;
|
|
44
44
|
}
|
|
45
45
|
if (isActive) {
|
|
@@ -55,8 +55,8 @@ var getNodeClass = function getNodeClass(name) {
|
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
var getBlockNodeStyle = function getBlockNodeStyle(name,
|
|
59
|
-
return
|
|
58
|
+
var getBlockNodeStyle = function getBlockNodeStyle(name, colorScheme) {
|
|
59
|
+
return colorScheme === 'traditional' ? (0, _traditional.getTraditionalNodeStyle)(name) : (0, _standard.getStandardNodeStyle)(name);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -65,9 +65,9 @@ var getBlockNodeStyle = function getBlockNodeStyle(name, colourScheme) {
|
|
|
65
65
|
* @param change Changeset "change" containing information about the change content + range
|
|
66
66
|
* @returns Prosemirror inline decoration
|
|
67
67
|
*/
|
|
68
|
-
var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change,
|
|
68
|
+
var createBlockChangedDecoration = exports.createBlockChangedDecoration = function createBlockChangedDecoration(change, colorScheme) {
|
|
69
69
|
if ((0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation')) {
|
|
70
|
-
var style = getBlockNodeStyle(change.name,
|
|
70
|
+
var style = getBlockNodeStyle(change.name, colorScheme);
|
|
71
71
|
var className = getNodeClass(change.name);
|
|
72
72
|
if (style || className) {
|
|
73
73
|
return _view.Decoration.node(change.from, change.to, {
|
|
@@ -81,7 +81,7 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
81
81
|
return undefined;
|
|
82
82
|
} else {
|
|
83
83
|
return _view.Decoration.node(change.from, change.to, {
|
|
84
|
-
style: getBlockNodeStyle(change.name,
|
|
84
|
+
style: getBlockNodeStyle(change.name, colorScheme),
|
|
85
85
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
86
86
|
class: getNodeClass(change.name)
|
|
87
87
|
}, {
|
|
@@ -89,16 +89,16 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
var createContentWrapper = function createContentWrapper(
|
|
92
|
+
var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
93
93
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
94
94
|
var wrapper = document.createElement('span');
|
|
95
95
|
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
96
96
|
position: 'relative',
|
|
97
97
|
width: 'fit-content'
|
|
98
98
|
});
|
|
99
|
-
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(
|
|
99
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
|
|
100
100
|
var strikethrough = document.createElement('span');
|
|
101
|
-
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(
|
|
101
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme));
|
|
102
102
|
wrapper.append(strikethrough);
|
|
103
103
|
return wrapper;
|
|
104
104
|
};
|
|
@@ -106,7 +106,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
106
106
|
var change = _ref.change,
|
|
107
107
|
doc = _ref.doc,
|
|
108
108
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
109
|
-
|
|
109
|
+
colorScheme = _ref.colorScheme,
|
|
110
110
|
newDoc = _ref.newDoc,
|
|
111
111
|
intl = _ref.intl,
|
|
112
112
|
_ref$isActive = _ref.isActive,
|
|
@@ -132,7 +132,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
132
132
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga')) {
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
-
var _handleDeletedRows = (0, _deletedRowsHandler.handleDeletedRows)([change], doc, newDoc, nodeViewSerializer,
|
|
135
|
+
var _handleDeletedRows = (0, _deletedRowsHandler.handleDeletedRows)([change], doc, newDoc, nodeViewSerializer, colorScheme),
|
|
136
136
|
decorations = _handleDeletedRows.decorations;
|
|
137
137
|
return decorations;
|
|
138
138
|
}
|
|
@@ -155,14 +155,14 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
155
155
|
if (childNodeView) {
|
|
156
156
|
var lineBreak = document.createElement('br');
|
|
157
157
|
dom.append(lineBreak);
|
|
158
|
-
var wrapper = createContentWrapper(
|
|
158
|
+
var wrapper = createContentWrapper(colorScheme, isActive);
|
|
159
159
|
wrapper.append(childNodeView);
|
|
160
160
|
dom.append(wrapper);
|
|
161
161
|
} else {
|
|
162
162
|
// Fallback to serializing the individual child node
|
|
163
163
|
var serializedChild = serializer.serializeNode(childNode);
|
|
164
164
|
if (serializedChild) {
|
|
165
|
-
var _wrapper = createContentWrapper(
|
|
165
|
+
var _wrapper = createContentWrapper(colorScheme, isActive);
|
|
166
166
|
_wrapper.append(serializedChild);
|
|
167
167
|
dom.append(_wrapper);
|
|
168
168
|
}
|
|
@@ -207,12 +207,12 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
207
207
|
var nodeView = serializer.tryCreateNodeView(node);
|
|
208
208
|
if (nodeView) {
|
|
209
209
|
if (node.isInline) {
|
|
210
|
-
var wrapper = createContentWrapper(
|
|
210
|
+
var wrapper = createContentWrapper(colorScheme, isActive);
|
|
211
211
|
wrapper.append(nodeView);
|
|
212
212
|
dom.append(wrapper);
|
|
213
213
|
} else {
|
|
214
214
|
// Handle all block nodes with unified function
|
|
215
|
-
(0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, node,
|
|
215
|
+
(0, _deletedBlocksHandler.handleBlockNodeView)(dom, nodeView, node, colorScheme, intl);
|
|
216
216
|
}
|
|
217
217
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
218
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
|
|
@@ -220,7 +220,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
220
220
|
} else {
|
|
221
221
|
var fallbackNode = fallbackSerialization();
|
|
222
222
|
if (fallbackNode) {
|
|
223
|
-
var _wrapper2 = (0, _deletedBlocksHandler.createDeletedStyleWrapperWithoutOpacity)(
|
|
223
|
+
var _wrapper2 = (0, _deletedBlocksHandler.createDeletedStyleWrapperWithoutOpacity)(colorScheme, isActive);
|
|
224
224
|
_wrapper2.append(fallbackNode);
|
|
225
225
|
dom.append(_wrapper2);
|
|
226
226
|
}
|
|
@@ -63,8 +63,8 @@ var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
63
63
|
whiteSpace: 'nowrap',
|
|
64
64
|
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
65
65
|
});
|
|
66
|
-
var getDeletedStyleNode = exports.getDeletedStyleNode = function getDeletedStyleNode(nodeName,
|
|
67
|
-
var isTraditional =
|
|
66
|
+
var getDeletedStyleNode = exports.getDeletedStyleNode = function getDeletedStyleNode(nodeName, colorScheme) {
|
|
67
|
+
var isTraditional = colorScheme === 'traditional';
|
|
68
68
|
switch (nodeName) {
|
|
69
69
|
case 'blockquote':
|
|
70
70
|
return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? isTraditional ? deletedTraditionalStyleQuoteNode : deletedStyleQuoteNodeWithLozenge : deletedStyleQuoteNode;
|
|
@@ -163,29 +163,29 @@ var createBlockNodeWrapper = exports.createBlockNodeWrapper = function createBlo
|
|
|
163
163
|
/**
|
|
164
164
|
* Wraps content with deleted styling without opacity (for use when content is a direct child of dom)
|
|
165
165
|
*/
|
|
166
|
-
var createDeletedStyleWrapperWithoutOpacity = exports.createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(
|
|
166
|
+
var createDeletedStyleWrapperWithoutOpacity = exports.createDeletedStyleWrapperWithoutOpacity = function createDeletedStyleWrapperWithoutOpacity(colorScheme, isActive) {
|
|
167
167
|
var wrapper = document.createElement('span');
|
|
168
|
-
wrapper.setAttribute('style', (0, _decorations.getDeletedContentStyle)(
|
|
168
|
+
wrapper.setAttribute('style', (0, _decorations.getDeletedContentStyle)(colorScheme, isActive));
|
|
169
169
|
return wrapper;
|
|
170
170
|
};
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
173
|
* Applies deleted styles directly to an HTML element by merging with existing styles
|
|
174
174
|
*/
|
|
175
|
-
var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode,
|
|
175
|
+
var applyDeletedStylesToElement = exports.applyDeletedStylesToElement = function applyDeletedStylesToElement(element, targetNode, colorScheme) {
|
|
176
176
|
var currentStyle = element.getAttribute('style') || '';
|
|
177
|
-
var deletedContentStyle = (0, _decorations.getDeletedContentStyle)(
|
|
178
|
-
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name,
|
|
177
|
+
var deletedContentStyle = (0, _decorations.getDeletedContentStyle)(colorScheme);
|
|
178
|
+
var nodeSpecificStyle = getDeletedStyleNode(targetNode.type.name, colorScheme) || '';
|
|
179
179
|
element.setAttribute('style', "".concat(currentStyle).concat(deletedContentStyle).concat(nodeSpecificStyle));
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* Creates a content wrapper with deleted styles for a block node
|
|
184
184
|
*/
|
|
185
|
-
var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode,
|
|
185
|
+
var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = function createBlockNodeContentWrapper(nodeView, targetNode, colorScheme) {
|
|
186
186
|
var contentWrapper = document.createElement('div');
|
|
187
|
-
var nodeStyle = getDeletedStyleNode(targetNode.type.name,
|
|
188
|
-
contentWrapper.setAttribute('style', "".concat((0, _decorations.getDeletedContentStyle)(
|
|
187
|
+
var nodeStyle = getDeletedStyleNode(targetNode.type.name, colorScheme);
|
|
188
|
+
contentWrapper.setAttribute('style', "".concat((0, _decorations.getDeletedContentStyle)(colorScheme)).concat(nodeStyle || ''));
|
|
189
189
|
contentWrapper.append(nodeView);
|
|
190
190
|
return contentWrapper;
|
|
191
191
|
};
|
|
@@ -196,7 +196,7 @@ var createBlockNodeContentWrapper = exports.createBlockNodeContentWrapper = func
|
|
|
196
196
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
197
197
|
* @returns true if embedCard was handled
|
|
198
198
|
*/
|
|
199
|
-
var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge,
|
|
199
|
+
var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
|
|
200
200
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
201
201
|
return false;
|
|
202
202
|
}
|
|
@@ -217,7 +217,7 @@ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function h
|
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
220
|
-
var showDiffDeletedNodeClass =
|
|
220
|
+
var showDiffDeletedNodeClass = colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
|
|
221
221
|
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
222
222
|
}
|
|
223
223
|
dom.append(nodeView);
|
|
@@ -228,7 +228,7 @@ var handleEmbedCardWithLozenge = exports.handleEmbedCardWithLozenge = function h
|
|
|
228
228
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
229
229
|
* @returns true if mediaSingle was handled, false otherwise
|
|
230
230
|
*/
|
|
231
|
-
var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge,
|
|
231
|
+
var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) {
|
|
232
232
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
233
233
|
return false;
|
|
234
234
|
}
|
|
@@ -247,7 +247,7 @@ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = functi
|
|
|
247
247
|
|
|
248
248
|
// Add deleted node class if needed
|
|
249
249
|
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
250
|
-
var showDiffDeletedNodeClass =
|
|
250
|
+
var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
|
|
251
251
|
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
252
252
|
}
|
|
253
253
|
dom.append(nodeView);
|
|
@@ -257,22 +257,22 @@ var handleMediaSingleWithLozenge = exports.handleMediaSingleWithLozenge = functi
|
|
|
257
257
|
/**
|
|
258
258
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
259
259
|
*/
|
|
260
|
-
var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode,
|
|
260
|
+
var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl) {
|
|
261
261
|
var blockWrapper = createBlockNodeWrapper();
|
|
262
262
|
if (shouldShowRemovedLozenge(targetNode.type.name)) {
|
|
263
263
|
var lozenge = createRemovedLozenge(intl);
|
|
264
|
-
if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge,
|
|
264
|
+
if (handleEmbedCardWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme) && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers')) {
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge,
|
|
267
|
+
if (handleMediaSingleWithLozenge(dom, nodeView, targetNode, lozenge, colorScheme)) {
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
blockWrapper.append(lozenge);
|
|
271
271
|
}
|
|
272
|
-
var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode,
|
|
272
|
+
var contentWrapper = createBlockNodeContentWrapper(nodeView, targetNode, colorScheme);
|
|
273
273
|
blockWrapper.append(contentWrapper);
|
|
274
274
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
275
|
-
var showDiffDeletedNodeClass =
|
|
275
|
+
var showDiffDeletedNodeClass = colorScheme === 'traditional' && (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_patch_ga_blockers') ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node';
|
|
276
276
|
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
277
277
|
}
|
|
278
278
|
dom.append(blockWrapper);
|
|
@@ -283,13 +283,13 @@ var appendBlockNodeWithWrapper = exports.appendBlockNodeWithWrapper = function a
|
|
|
283
283
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
284
284
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
285
285
|
*/
|
|
286
|
-
var handleBlockNodeView = exports.handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode,
|
|
286
|
+
var handleBlockNodeView = exports.handleBlockNodeView = function handleBlockNodeView(dom, nodeView, targetNode, colorScheme, intl) {
|
|
287
287
|
if (shouldApplyDeletedStylesDirectly(targetNode.type.name) && nodeView instanceof HTMLElement) {
|
|
288
288
|
// Apply deleted styles directly to preserve natural block-level margins
|
|
289
|
-
applyDeletedStylesToElement(nodeView, targetNode,
|
|
289
|
+
applyDeletedStylesToElement(nodeView, targetNode, colorScheme);
|
|
290
290
|
dom.append(nodeView);
|
|
291
291
|
} else {
|
|
292
292
|
// Use wrapper approach for other block nodes
|
|
293
|
-
appendBlockNodeWithWrapper(dom, nodeView, targetNode,
|
|
293
|
+
appendBlockNodeWithWrapper(dom, nodeView, targetNode, colorScheme, intl);
|
|
294
294
|
}
|
|
295
295
|
};
|
|
@@ -65,7 +65,7 @@ var extractDeletedRows = function extractDeletedRows(change, originalDoc, newDoc
|
|
|
65
65
|
var changeEndInTable = change.toA - tableOld.pos - 1;
|
|
66
66
|
var currentOffset = 0;
|
|
67
67
|
var rowIndex = 0;
|
|
68
|
-
tableOld.node.content.forEach(function (rowNode
|
|
68
|
+
tableOld.node.content.forEach(function (rowNode) {
|
|
69
69
|
var rowStart = currentOffset;
|
|
70
70
|
var rowEnd = currentOffset + rowNode.nodeSize;
|
|
71
71
|
|
|
@@ -126,9 +126,9 @@ var isEmptyRow = function isEmptyRow(rowNode) {
|
|
|
126
126
|
/**
|
|
127
127
|
* Creates a DOM representation of a deleted table row
|
|
128
128
|
*/
|
|
129
|
-
var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer,
|
|
129
|
+
var createDeletedRowDOM = function createDeletedRowDOM(rowNode, nodeViewSerializer, colorScheme) {
|
|
130
130
|
var tr = document.createElement('tr');
|
|
131
|
-
tr.setAttribute('style',
|
|
131
|
+
tr.setAttribute('style', colorScheme === 'traditional' ? deletedTraditionalRowStyle : deletedRowStyle);
|
|
132
132
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
133
133
|
|
|
134
134
|
// Serialize each cell in the row
|
|
@@ -181,9 +181,9 @@ var createDeletedRowsDecorations = exports.createDeletedRowsDecorations = functi
|
|
|
181
181
|
originalDoc = _ref.originalDoc,
|
|
182
182
|
newDoc = _ref.newDoc,
|
|
183
183
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
184
|
-
|
|
184
|
+
colorScheme = _ref.colorScheme;
|
|
185
185
|
return deletedRows.map(function (deletedRow) {
|
|
186
|
-
var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer,
|
|
186
|
+
var rowDOM = createDeletedRowDOM(deletedRow.rowNode, nodeViewSerializer, colorScheme);
|
|
187
187
|
|
|
188
188
|
// Find safe insertion position for the deleted row
|
|
189
189
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, deletedRow.fromB - 1,
|
|
@@ -196,7 +196,7 @@ var createDeletedRowsDecorations = exports.createDeletedRowsDecorations = functi
|
|
|
196
196
|
/**
|
|
197
197
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
198
198
|
*/
|
|
199
|
-
var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer,
|
|
199
|
+
var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(changes, originalDoc, newDoc, nodeViewSerializer, colorScheme) {
|
|
200
200
|
// First, expand the changes to include complete deleted rows
|
|
201
201
|
var deletedRows = expandDiffForDeletedRows(changes.filter(function (change) {
|
|
202
202
|
return change.deleted.length > 0;
|
|
@@ -206,7 +206,7 @@ var handleDeletedRows = exports.handleDeletedRows = function handleDeletedRows(c
|
|
|
206
206
|
originalDoc: originalDoc,
|
|
207
207
|
newDoc: newDoc,
|
|
208
208
|
nodeViewSerializer: nodeViewSerializer,
|
|
209
|
-
|
|
209
|
+
colorScheme: colorScheme
|
|
210
210
|
});
|
|
211
211
|
return {
|
|
212
212
|
decorations: allDecorations
|
|
@@ -91,7 +91,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
91
91
|
state: newState,
|
|
92
92
|
pluginState: newPluginState,
|
|
93
93
|
nodeViewSerializer: nodeViewSerializer,
|
|
94
|
-
|
|
94
|
+
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
95
95
|
intl: getIntl(),
|
|
96
96
|
activeIndexPos: (0, _platformFeatureFlags.fg)('platform_editor_show_diff_scroll_navigation') ? newPluginState.activeIndexPos : undefined
|
|
97
97
|
});
|
|
@@ -127,7 +127,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl)
|
|
|
127
127
|
state: newState,
|
|
128
128
|
pluginState: newPluginState,
|
|
129
129
|
nodeViewSerializer: nodeViewSerializer,
|
|
130
|
-
|
|
130
|
+
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
131
131
|
intl: getIntl(),
|
|
132
132
|
activeIndexPos: newPluginState.activeIndexPos
|
|
133
133
|
});
|
|
@@ -8,7 +8,7 @@ import { getAttrChangeRanges, stepIsValidAttrChange } from './attributeDecoratio
|
|
|
8
8
|
import { createInlineChangedDecoration, createDeletedContentDecoration, createBlockChangedDecoration } from './decorations';
|
|
9
9
|
import { getMarkChangeRanges } from './markDecorations';
|
|
10
10
|
import { simplifySteps } from './simplifyChanges';
|
|
11
|
-
const calculateNodesForBlockDecoration = (doc, from, to,
|
|
11
|
+
const calculateNodesForBlockDecoration = (doc, from, to, colorScheme) => {
|
|
12
12
|
const decorations = [];
|
|
13
13
|
// Iterate over the document nodes within the range
|
|
14
14
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
@@ -17,7 +17,7 @@ const calculateNodesForBlockDecoration = (doc, from, to, colourScheme) => {
|
|
|
17
17
|
from: pos,
|
|
18
18
|
to: pos + node.nodeSize,
|
|
19
19
|
name: node.type.name
|
|
20
|
-
},
|
|
20
|
+
}, colorScheme);
|
|
21
21
|
if (decoration) {
|
|
22
22
|
decorations.push(decoration);
|
|
23
23
|
}
|
|
@@ -66,7 +66,7 @@ const calculateDiffDecorationsInner = ({
|
|
|
66
66
|
state,
|
|
67
67
|
pluginState,
|
|
68
68
|
nodeViewSerializer,
|
|
69
|
-
|
|
69
|
+
colorScheme,
|
|
70
70
|
intl,
|
|
71
71
|
activeIndexPos
|
|
72
72
|
}) => {
|
|
@@ -107,8 +107,8 @@ const calculateDiffDecorationsInner = ({
|
|
|
107
107
|
optimizedChanges.forEach(change => {
|
|
108
108
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
109
109
|
if (change.inserted.length > 0) {
|
|
110
|
-
decorations.push(createInlineChangedDecoration(change,
|
|
111
|
-
decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB,
|
|
110
|
+
decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
|
|
111
|
+
decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme));
|
|
112
112
|
}
|
|
113
113
|
if (change.deleted.length > 0) {
|
|
114
114
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
@@ -116,7 +116,7 @@ const calculateDiffDecorationsInner = ({
|
|
|
116
116
|
change,
|
|
117
117
|
doc: originalDoc,
|
|
118
118
|
nodeViewSerializer,
|
|
119
|
-
|
|
119
|
+
colorScheme,
|
|
120
120
|
newDoc: tr.doc,
|
|
121
121
|
intl,
|
|
122
122
|
isActive
|
|
@@ -128,10 +128,10 @@ const calculateDiffDecorationsInner = ({
|
|
|
128
128
|
});
|
|
129
129
|
getMarkChangeRanges(steps).forEach(change => {
|
|
130
130
|
const isActive = activeIndexPos && change.fromB >= activeIndexPos.from && change.toB <= activeIndexPos.to;
|
|
131
|
-
decorations.push(createInlineChangedDecoration(change,
|
|
131
|
+
decorations.push(createInlineChangedDecoration(change, colorScheme, isActive));
|
|
132
132
|
});
|
|
133
133
|
getAttrChangeRanges(tr.doc, attrSteps).forEach(change => {
|
|
134
|
-
decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB,
|
|
134
|
+
decorations.push(...calculateNodesForBlockDecoration(tr.doc, change.fromB, change.toB, colorScheme));
|
|
135
135
|
});
|
|
136
136
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
137
137
|
};
|
|
@@ -140,17 +140,17 @@ export const calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner
|
|
|
140
140
|
([{
|
|
141
141
|
pluginState,
|
|
142
142
|
state,
|
|
143
|
-
|
|
143
|
+
colorScheme,
|
|
144
144
|
intl,
|
|
145
145
|
activeIndexPos
|
|
146
146
|
}], [{
|
|
147
147
|
pluginState: lastPluginState,
|
|
148
148
|
state: lastState,
|
|
149
|
-
|
|
149
|
+
colorScheme: lastColorScheme,
|
|
150
150
|
intl: lastIntl,
|
|
151
151
|
activeIndexPos: lastActiveIndexPos
|
|
152
152
|
}]) => {
|
|
153
153
|
var _ref;
|
|
154
154
|
const originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
155
|
-
return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) &&
|
|
155
|
+
return (_ref = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos)) !== null && _ref !== void 0 ? _ref : false;
|
|
156
156
|
});
|