@atlaskit/editor-plugin-show-diff 10.5.2 → 10.5.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 +8 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +13 -1
- package/dist/cjs/pm-plugins/decorations/colorSchemes/traditional.js +14 -1
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +83 -26
- package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +12 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/traditional.js +13 -0
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +67 -9
- package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +12 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/traditional.js +13 -0
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +85 -28
- package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +1 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/traditional.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 10.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`154b76531a593`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/154b76531a593) -
|
|
8
|
+
Fix table diff cell overlays to use rounded corners for inserting row diffs when
|
|
9
|
+
platform_editor_table_diff_rounded_corners is enabled
|
|
10
|
+
|
|
3
11
|
## 10.5.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.standardDecorationMarkerVariable = exports.editingStyleRuleNode = exports.editingStyleQuoteNode = exports.editingStyleNode = exports.editingStyleExtendedNoUnderline = exports.editingStyleExtended = exports.editingStyleCardBlockNode = exports.editingStyleActiveExtendedNoUnderline = exports.editingStyleActiveExtended = exports.editingStyleActive = exports.editingStyle = exports.editingContentStyleInBlockExtendedNoUnderline = exports.editingContentStyleInBlockExtended = exports.editingContentStyleInBlock = exports.deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedInlineContentStyleExtended = exports.deletedDecorationMarkerVariable = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = exports.deletedCellOverlayStyle = exports.deletedCellOverlayRoundedStyle = exports.deletedBlockOutlineRoundedActive = exports.deletedBlockOutlineRounded = exports.deletedBlockOutlineActive = exports.deletedBlockOutline = exports.addedCellOverlayStyle = void 0;
|
|
6
|
+
exports.standardDecorationMarkerVariable = exports.editingStyleRuleNode = exports.editingStyleQuoteNode = exports.editingStyleNode = exports.editingStyleExtendedNoUnderline = exports.editingStyleExtended = exports.editingStyleCardBlockNode = exports.editingStyleActiveExtendedNoUnderline = exports.editingStyleActiveExtended = exports.editingStyleActive = exports.editingStyle = exports.editingContentStyleInBlockExtendedNoUnderline = exports.editingContentStyleInBlockExtended = exports.editingContentStyleInBlock = exports.deletedStyleQuoteNodeWithLozengeActive = exports.deletedStyleQuoteNodeWithLozenge = exports.deletedStyleQuoteNode = exports.deletedRowStyle = exports.deletedInlineContentStyleExtended = exports.deletedDecorationMarkerVariable = exports.deletedContentStyleUnbounded = exports.deletedContentStyleNew = exports.deletedContentStyleActive = exports.deletedContentStyle = exports.deletedCellOverlayStyle = exports.deletedCellOverlayRoundedStyle = exports.deletedBlockOutlineRoundedActive = exports.deletedBlockOutlineRounded = exports.deletedBlockOutlineActive = exports.deletedBlockOutline = exports.addedCellOverlayStyle = exports.addedCellOverlayRoundedStyle = void 0;
|
|
7
7
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
8
|
// delete on platform_editor_diff_plugin_extended cleanup
|
|
9
9
|
var editingStyle = exports.editingStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
@@ -176,6 +176,18 @@ var addedCellOverlayStyle = exports.addedCellOverlayStyle = (0, _lazyNodeView.co
|
|
|
176
176
|
outline: "1px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
177
177
|
pointerEvents: 'none'
|
|
178
178
|
});
|
|
179
|
+
var addedCellOverlayRoundedStyle = exports.addedCellOverlayRoundedStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
180
|
+
position: 'absolute',
|
|
181
|
+
top: 0,
|
|
182
|
+
left: 0,
|
|
183
|
+
width: '100%',
|
|
184
|
+
height: '100%',
|
|
185
|
+
backgroundColor: "rgba(from ".concat("var(--ds-background-accent-purple-subtlest, #F8EEFE)", " r g b / 0.5)"),
|
|
186
|
+
zIndex: 2,
|
|
187
|
+
outline: "1px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
188
|
+
pointerEvents: 'none',
|
|
189
|
+
borderRadius: 'inherit'
|
|
190
|
+
});
|
|
179
191
|
var deletedCellOverlayStyle = exports.deletedCellOverlayStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
180
192
|
position: 'absolute',
|
|
181
193
|
top: 0,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.deletedTraditionalStyleQuoteNodeActive = exports.deletedTraditionalStyleQuoteNode = exports.deletedTraditionalRowStyle = exports.deletedTraditionalContentStyleUnboundedActive = exports.deletedTraditionalContentStyleUnbounded = exports.deletedTraditionalCellOverlayStyle = exports.deletedTraditionalCellOverlayRoundedStyle = exports.deletedTraditionalBlockOutlineRoundedNew = exports.deletedTraditionalBlockOutlineRoundedActive = exports.deletedTraditionalBlockOutlineRounded = exports.deletedTraditionalBlockOutlineNew = exports.deletedTraditionalBlockOutlineActive = exports.deletedTraditionalBlockOutline = void 0;
|
|
8
8
|
exports.getDeletedTraditionalInlineStyle = getDeletedTraditionalInlineStyle;
|
|
9
|
-
exports.traditionalStyleRuleNodeNew = exports.traditionalStyleRuleNodeActive = exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNodeNew = exports.traditionalStyleQuoteNodeActive = exports.traditionalStyleQuoteNode = exports.traditionalStyleNodeNew = exports.traditionalStyleNodeActive = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNodeNew = exports.traditionalStyleCardBlockNodeActive = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDeletedDecorationMarkerVariableNew = exports.traditionalDeletedDecorationMarkerVariableActive = exports.traditionalDeletedDecorationMarkerVariable = exports.traditionalDecorationMarkerVariableNew = exports.traditionalDecorationMarkerVariableActive = exports.traditionalDecorationMarkerVariable = exports.traditionalAddedCellOverlayStyleNew = exports.traditionalAddedCellOverlayStyle = void 0;
|
|
9
|
+
exports.traditionalStyleRuleNodeNew = exports.traditionalStyleRuleNodeActive = exports.traditionalStyleRuleNode = exports.traditionalStyleQuoteNodeNew = exports.traditionalStyleQuoteNodeActive = exports.traditionalStyleQuoteNode = exports.traditionalStyleNodeNew = exports.traditionalStyleNodeActive = exports.traditionalStyleNode = exports.traditionalStyleCardBlockNodeNew = exports.traditionalStyleCardBlockNodeActive = exports.traditionalStyleCardBlockNode = exports.traditionalInsertStyleActive = exports.traditionalInsertStyle = exports.traditionalDeletedDecorationMarkerVariableNew = exports.traditionalDeletedDecorationMarkerVariableActive = exports.traditionalDeletedDecorationMarkerVariable = exports.traditionalDecorationMarkerVariableNew = exports.traditionalDecorationMarkerVariableActive = exports.traditionalDecorationMarkerVariable = exports.traditionalAddedCellOverlayStyleNew = exports.traditionalAddedCellOverlayStyle = exports.traditionalAddedCellOverlayRoundedStyle = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
12
12
|
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; }
|
|
@@ -193,6 +193,19 @@ var traditionalAddedCellOverlayStyle = exports.traditionalAddedCellOverlayStyle
|
|
|
193
193
|
outline: "1px solid ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
194
194
|
pointerEvents: 'none'
|
|
195
195
|
});
|
|
196
|
+
var traditionalAddedCellOverlayRoundedStyle = exports.traditionalAddedCellOverlayRoundedStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
197
|
+
position: 'absolute',
|
|
198
|
+
top: 0,
|
|
199
|
+
left: 0,
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
backgroundColor: "rgba(from ".concat("var(--ds-background-accent-green-subtlest, #DCFFF1)", " r g b / 0.5)"),
|
|
203
|
+
zIndex: 2,
|
|
204
|
+
outline: "1px solid ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
205
|
+
pointerEvents: 'none',
|
|
206
|
+
border: 'inherit',
|
|
207
|
+
borderRadius: 'inherit'
|
|
208
|
+
});
|
|
196
209
|
var traditionalAddedCellOverlayStyleNew = exports.traditionalAddedCellOverlayStyleNew = (0, _lazyNodeView.convertToInlineCss)({
|
|
197
210
|
position: 'absolute',
|
|
198
211
|
top: 0,
|
|
@@ -11,6 +11,7 @@ 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 _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
15
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
15
16
|
var _standard = require("./colorSchemes/standard");
|
|
16
17
|
var _traditional = require("./colorSchemes/traditional");
|
|
@@ -21,14 +22,55 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
21
22
|
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; } } }; }
|
|
22
23
|
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; } }
|
|
23
24
|
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; }
|
|
25
|
+
/**
|
|
26
|
+
* Inserted table rows are rendered as decoration widgets, so their cells do not get the
|
|
27
|
+
* `data-reaches-*` attrs normally applied by the table cell node view. Mirror that boundary
|
|
28
|
+
* metadata here so the existing rounded-table CSS can round widget cells like real table cells.
|
|
29
|
+
*/
|
|
30
|
+
var getChangedRowCellEdgeAttrs = function getChangedRowCellEdgeAttrs(_ref) {
|
|
31
|
+
var rowNode = _ref.rowNode,
|
|
32
|
+
rowStart = _ref.rowStart,
|
|
33
|
+
tableMap = _ref.tableMap;
|
|
34
|
+
var cellEdgeAttrs = [];
|
|
35
|
+
rowNode.content.forEach(function (cellNode, cellOffset) {
|
|
36
|
+
if (cellNode.type.name !== 'tableCell' && cellNode.type.name !== 'tableHeader') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var cellRect = tableMap.findCell(rowStart + 1 + cellOffset);
|
|
40
|
+
cellEdgeAttrs.push({
|
|
41
|
+
reachesBottom: cellRect.bottom >= tableMap.height,
|
|
42
|
+
reachesLeft: cellRect.left === 0,
|
|
43
|
+
reachesRight: cellRect.right >= tableMap.width,
|
|
44
|
+
reachesTop: cellRect.top === 0
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return cellEdgeAttrs;
|
|
48
|
+
};
|
|
49
|
+
var applyCellEdgeAttrs = function applyCellEdgeAttrs(cell, edgeAttrs) {
|
|
50
|
+
if (!edgeAttrs) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (edgeAttrs.reachesTop) {
|
|
54
|
+
cell.setAttribute('data-reaches-top', 'true');
|
|
55
|
+
}
|
|
56
|
+
if (edgeAttrs.reachesBottom) {
|
|
57
|
+
cell.setAttribute('data-reaches-bottom', 'true');
|
|
58
|
+
}
|
|
59
|
+
if (edgeAttrs.reachesLeft) {
|
|
60
|
+
cell.setAttribute('data-reaches-left', 'true');
|
|
61
|
+
}
|
|
62
|
+
if (edgeAttrs.reachesRight) {
|
|
63
|
+
cell.setAttribute('data-reaches-right', 'true');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
24
66
|
/**
|
|
25
67
|
* Extracts information about deleted table rows from a change
|
|
26
68
|
*/
|
|
27
|
-
var extractChangedRows = function extractChangedRows(
|
|
28
|
-
var change =
|
|
29
|
-
originalDoc =
|
|
30
|
-
newDoc =
|
|
31
|
-
diffType =
|
|
69
|
+
var extractChangedRows = function extractChangedRows(_ref2) {
|
|
70
|
+
var change = _ref2.change,
|
|
71
|
+
originalDoc = _ref2.originalDoc,
|
|
72
|
+
newDoc = _ref2.newDoc,
|
|
73
|
+
diffType = _ref2.diffType;
|
|
32
74
|
var changedRows = [];
|
|
33
75
|
|
|
34
76
|
// Find the table in the original document
|
|
@@ -69,12 +111,18 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
69
111
|
// Check if this row overlaps with the deletion range
|
|
70
112
|
var rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
|
|
71
113
|
if (rowOverlapsChange && rowNode.type.name === 'tableRow' && ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isEmptyRow(rowNode))) {
|
|
114
|
+
var cellEdgeAttrs = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true) ? getChangedRowCellEdgeAttrs({
|
|
115
|
+
rowNode: rowNode,
|
|
116
|
+
rowStart: rowStart,
|
|
117
|
+
tableMap: oldTableMap
|
|
118
|
+
}) : undefined;
|
|
72
119
|
var startOfRow = newTableMap.mapByRow.slice().reverse().find(function (row) {
|
|
73
120
|
return row[0] + tableNew.pos < change.fromB && change.fromB < row[row.length - 1] + tableNew.pos;
|
|
74
121
|
});
|
|
75
122
|
changedRows.push({
|
|
76
123
|
rowIndex: rowIndex,
|
|
77
124
|
rowNode: rowNode,
|
|
125
|
+
cellEdgeAttrs: cellEdgeAttrs,
|
|
78
126
|
fromA: tableOld.pos + 1 + rowStart,
|
|
79
127
|
toA: tableOld.pos + 1 + rowEnd,
|
|
80
128
|
fromB: startOfRow ? startOfRow[0] + tableNew.start : change.fromB
|
|
@@ -123,7 +171,7 @@ var isEmptyRow = function isEmptyRow(rowNode) {
|
|
|
123
171
|
/**
|
|
124
172
|
* Creates a DOM representation of a deleted table row
|
|
125
173
|
*/
|
|
126
|
-
var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
174
|
+
var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
127
175
|
var tr = document.createElement('tr');
|
|
128
176
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
129
177
|
if (!isInserted) {
|
|
@@ -135,15 +183,23 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
135
183
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
136
184
|
|
|
137
185
|
// Serialize each cell in the row
|
|
186
|
+
var cellIndex = 0;
|
|
138
187
|
rowNode.content.forEach(function (cellNode) {
|
|
139
188
|
if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
|
|
140
189
|
var nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
|
|
141
190
|
if (nodeView) {
|
|
142
|
-
if (nodeView instanceof HTMLElement
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
191
|
+
if (nodeView instanceof HTMLElement) {
|
|
192
|
+
applyCellEdgeAttrs(nodeView, cellEdgeAttrs === null || cellEdgeAttrs === void 0 ? void 0 : cellEdgeAttrs[cellIndex]);
|
|
193
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
194
|
+
var overlay = document.createElement('span');
|
|
195
|
+
var isRoundedTable = (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
196
|
+
var isTraditional = colorScheme === 'traditional';
|
|
197
|
+
var deletedCellStyle = isTraditional ? _traditional.deletedTraditionalCellOverlayStyle : _standard.deletedCellOverlayStyle;
|
|
198
|
+
var addedCellStyle = isTraditional ? isRoundedTable ? _traditional.traditionalAddedCellOverlayRoundedStyle : _traditional.traditionalAddedCellOverlayStyle : isRoundedTable ? _standard.addedCellOverlayRoundedStyle : _standard.addedCellOverlayStyle;
|
|
199
|
+
var overlayStyle = isInserted ? addedCellStyle : deletedCellStyle;
|
|
200
|
+
overlay.setAttribute('style', overlayStyle);
|
|
201
|
+
nodeView.appendChild(overlay);
|
|
202
|
+
}
|
|
147
203
|
}
|
|
148
204
|
tr.appendChild(nodeView);
|
|
149
205
|
} else {
|
|
@@ -153,6 +209,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
153
209
|
tr.appendChild(serializedContent);
|
|
154
210
|
}
|
|
155
211
|
}
|
|
212
|
+
cellIndex++;
|
|
156
213
|
}
|
|
157
214
|
});
|
|
158
215
|
return tr;
|
|
@@ -161,11 +218,11 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
161
218
|
/**
|
|
162
219
|
* Expands a diff to include whole changed rows when table rows are affected
|
|
163
220
|
*/
|
|
164
|
-
var expandDiffForChangedRows = function expandDiffForChangedRows(
|
|
165
|
-
var changes =
|
|
166
|
-
originalDoc =
|
|
167
|
-
newDoc =
|
|
168
|
-
diffType =
|
|
221
|
+
var expandDiffForChangedRows = function expandDiffForChangedRows(_ref3) {
|
|
222
|
+
var changes = _ref3.changes,
|
|
223
|
+
originalDoc = _ref3.originalDoc,
|
|
224
|
+
newDoc = _ref3.newDoc,
|
|
225
|
+
diffType = _ref3.diffType;
|
|
169
226
|
var rowInfo = [];
|
|
170
227
|
var _iterator = _createForOfIteratorHelper(changes),
|
|
171
228
|
_step;
|
|
@@ -194,15 +251,15 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
|
|
|
194
251
|
/**
|
|
195
252
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
196
253
|
*/
|
|
197
|
-
var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(
|
|
198
|
-
var changes =
|
|
199
|
-
originalDoc =
|
|
200
|
-
newDoc =
|
|
201
|
-
nodeViewSerializer =
|
|
202
|
-
colorScheme =
|
|
203
|
-
|
|
204
|
-
isInserted =
|
|
205
|
-
diffType =
|
|
254
|
+
var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(_ref4) {
|
|
255
|
+
var changes = _ref4.changes,
|
|
256
|
+
originalDoc = _ref4.originalDoc,
|
|
257
|
+
newDoc = _ref4.newDoc,
|
|
258
|
+
nodeViewSerializer = _ref4.nodeViewSerializer,
|
|
259
|
+
colorScheme = _ref4.colorScheme,
|
|
260
|
+
_ref4$isInserted = _ref4.isInserted,
|
|
261
|
+
isInserted = _ref4$isInserted === void 0 ? false : _ref4$isInserted,
|
|
262
|
+
diffType = _ref4.diffType;
|
|
206
263
|
// First, expand the changes to include complete deleted rows
|
|
207
264
|
var changedRows = expandDiffForChangedRows({
|
|
208
265
|
changes: changes.filter(function (change) {
|
|
@@ -213,7 +270,7 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
|
|
|
213
270
|
diffType: diffType
|
|
214
271
|
});
|
|
215
272
|
return changedRows.map(function (changedRow) {
|
|
216
|
-
var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
273
|
+
var rowDOM = createChangedRowDOM(changedRow.rowNode, changedRow.cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
217
274
|
|
|
218
275
|
// Find safe insertion position for the deleted row
|
|
219
276
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, changedRow.fromB - 1,
|
|
@@ -170,6 +170,18 @@ export const addedCellOverlayStyle = convertToInlineCss({
|
|
|
170
170
|
outline: `1px solid ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
171
171
|
pointerEvents: 'none'
|
|
172
172
|
});
|
|
173
|
+
export const addedCellOverlayRoundedStyle = convertToInlineCss({
|
|
174
|
+
position: 'absolute',
|
|
175
|
+
top: 0,
|
|
176
|
+
left: 0,
|
|
177
|
+
width: '100%',
|
|
178
|
+
height: '100%',
|
|
179
|
+
backgroundColor: `rgba(from ${"var(--ds-background-accent-purple-subtlest, #F8EEFE)"} r g b / 0.5)`,
|
|
180
|
+
zIndex: 2,
|
|
181
|
+
outline: `1px solid ${"var(--ds-border-accent-purple, #AF59E1)"}`,
|
|
182
|
+
pointerEvents: 'none',
|
|
183
|
+
borderRadius: 'inherit'
|
|
184
|
+
});
|
|
173
185
|
export const deletedCellOverlayStyle = convertToInlineCss({
|
|
174
186
|
position: 'absolute',
|
|
175
187
|
top: 0,
|
|
@@ -185,6 +185,19 @@ export const traditionalAddedCellOverlayStyle = convertToInlineCss({
|
|
|
185
185
|
outline: `1px solid ${"var(--ds-border-accent-green, #22A06B)"}`,
|
|
186
186
|
pointerEvents: 'none'
|
|
187
187
|
});
|
|
188
|
+
export const traditionalAddedCellOverlayRoundedStyle = convertToInlineCss({
|
|
189
|
+
position: 'absolute',
|
|
190
|
+
top: 0,
|
|
191
|
+
left: 0,
|
|
192
|
+
width: '100%',
|
|
193
|
+
height: '100%',
|
|
194
|
+
backgroundColor: `rgba(from ${"var(--ds-background-accent-green-subtlest, #DCFFF1)"} r g b / 0.5)`,
|
|
195
|
+
zIndex: 2,
|
|
196
|
+
outline: `1px solid ${"var(--ds-border-accent-green, #22A06B)"}`,
|
|
197
|
+
pointerEvents: 'none',
|
|
198
|
+
border: 'inherit',
|
|
199
|
+
borderRadius: 'inherit'
|
|
200
|
+
});
|
|
188
201
|
export const traditionalAddedCellOverlayStyleNew = convertToInlineCss({
|
|
189
202
|
position: 'absolute',
|
|
190
203
|
top: 0,
|
|
@@ -2,11 +2,54 @@ import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document
|
|
|
2
2
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
6
|
-
import { addedCellOverlayStyle, deletedRowStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
7
|
-
import { deletedTraditionalRowStyle, deletedTraditionalCellOverlayStyle, traditionalAddedCellOverlayStyle } from './colorSchemes/traditional';
|
|
7
|
+
import { addedCellOverlayStyle, addedCellOverlayRoundedStyle, deletedRowStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
8
|
+
import { deletedTraditionalRowStyle, deletedTraditionalCellOverlayStyle, traditionalAddedCellOverlayStyle, traditionalAddedCellOverlayRoundedStyle } from './colorSchemes/traditional';
|
|
8
9
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
9
10
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
11
|
+
/**
|
|
12
|
+
* Inserted table rows are rendered as decoration widgets, so their cells do not get the
|
|
13
|
+
* `data-reaches-*` attrs normally applied by the table cell node view. Mirror that boundary
|
|
14
|
+
* metadata here so the existing rounded-table CSS can round widget cells like real table cells.
|
|
15
|
+
*/
|
|
16
|
+
const getChangedRowCellEdgeAttrs = ({
|
|
17
|
+
rowNode,
|
|
18
|
+
rowStart,
|
|
19
|
+
tableMap
|
|
20
|
+
}) => {
|
|
21
|
+
const cellEdgeAttrs = [];
|
|
22
|
+
rowNode.content.forEach((cellNode, cellOffset) => {
|
|
23
|
+
if (cellNode.type.name !== 'tableCell' && cellNode.type.name !== 'tableHeader') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const cellRect = tableMap.findCell(rowStart + 1 + cellOffset);
|
|
27
|
+
cellEdgeAttrs.push({
|
|
28
|
+
reachesBottom: cellRect.bottom >= tableMap.height,
|
|
29
|
+
reachesLeft: cellRect.left === 0,
|
|
30
|
+
reachesRight: cellRect.right >= tableMap.width,
|
|
31
|
+
reachesTop: cellRect.top === 0
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return cellEdgeAttrs;
|
|
35
|
+
};
|
|
36
|
+
const applyCellEdgeAttrs = (cell, edgeAttrs) => {
|
|
37
|
+
if (!edgeAttrs) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (edgeAttrs.reachesTop) {
|
|
41
|
+
cell.setAttribute('data-reaches-top', 'true');
|
|
42
|
+
}
|
|
43
|
+
if (edgeAttrs.reachesBottom) {
|
|
44
|
+
cell.setAttribute('data-reaches-bottom', 'true');
|
|
45
|
+
}
|
|
46
|
+
if (edgeAttrs.reachesLeft) {
|
|
47
|
+
cell.setAttribute('data-reaches-left', 'true');
|
|
48
|
+
}
|
|
49
|
+
if (edgeAttrs.reachesRight) {
|
|
50
|
+
cell.setAttribute('data-reaches-right', 'true');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
10
53
|
/**
|
|
11
54
|
* Extracts information about deleted table rows from a change
|
|
12
55
|
*/
|
|
@@ -52,10 +95,16 @@ const extractChangedRows = ({
|
|
|
52
95
|
// Check if this row overlaps with the deletion range
|
|
53
96
|
const rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
|
|
54
97
|
if (rowOverlapsChange && rowNode.type.name === 'tableRow' && (isExtendedEnabled(diffType) || !isEmptyRow(rowNode))) {
|
|
98
|
+
const cellEdgeAttrs = isExtendedEnabled(diffType) && expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true) ? getChangedRowCellEdgeAttrs({
|
|
99
|
+
rowNode,
|
|
100
|
+
rowStart,
|
|
101
|
+
tableMap: oldTableMap
|
|
102
|
+
}) : undefined;
|
|
55
103
|
const startOfRow = newTableMap.mapByRow.slice().reverse().find(row => row[0] + tableNew.pos < change.fromB && change.fromB < row[row.length - 1] + tableNew.pos);
|
|
56
104
|
changedRows.push({
|
|
57
105
|
rowIndex,
|
|
58
106
|
rowNode,
|
|
107
|
+
cellEdgeAttrs,
|
|
59
108
|
fromA: tableOld.pos + 1 + rowStart,
|
|
60
109
|
toA: tableOld.pos + 1 + rowEnd,
|
|
61
110
|
fromB: startOfRow ? startOfRow[0] + tableNew.start : change.fromB
|
|
@@ -102,7 +151,7 @@ const isEmptyRow = rowNode => {
|
|
|
102
151
|
/**
|
|
103
152
|
* Creates a DOM representation of a deleted table row
|
|
104
153
|
*/
|
|
105
|
-
const createChangedRowDOM = (rowNode, nodeViewSerializer, colorScheme, isInserted, diffType) => {
|
|
154
|
+
const createChangedRowDOM = (rowNode, cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType) => {
|
|
106
155
|
const tr = document.createElement('tr');
|
|
107
156
|
if (isExtendedEnabled(diffType)) {
|
|
108
157
|
if (!isInserted) {
|
|
@@ -114,15 +163,23 @@ const createChangedRowDOM = (rowNode, nodeViewSerializer, colorScheme, isInserte
|
|
|
114
163
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
115
164
|
|
|
116
165
|
// Serialize each cell in the row
|
|
166
|
+
let cellIndex = 0;
|
|
117
167
|
rowNode.content.forEach(cellNode => {
|
|
118
168
|
if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
|
|
119
169
|
const nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
|
|
120
170
|
if (nodeView) {
|
|
121
|
-
if (nodeView instanceof HTMLElement
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
171
|
+
if (nodeView instanceof HTMLElement) {
|
|
172
|
+
applyCellEdgeAttrs(nodeView, cellEdgeAttrs === null || cellEdgeAttrs === void 0 ? void 0 : cellEdgeAttrs[cellIndex]);
|
|
173
|
+
if (isExtendedEnabled(diffType)) {
|
|
174
|
+
const overlay = document.createElement('span');
|
|
175
|
+
const isRoundedTable = expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
176
|
+
const isTraditional = colorScheme === 'traditional';
|
|
177
|
+
const deletedCellStyle = isTraditional ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
|
|
178
|
+
const addedCellStyle = isTraditional ? isRoundedTable ? traditionalAddedCellOverlayRoundedStyle : traditionalAddedCellOverlayStyle : isRoundedTable ? addedCellOverlayRoundedStyle : addedCellOverlayStyle;
|
|
179
|
+
const overlayStyle = isInserted ? addedCellStyle : deletedCellStyle;
|
|
180
|
+
overlay.setAttribute('style', overlayStyle);
|
|
181
|
+
nodeView.appendChild(overlay);
|
|
182
|
+
}
|
|
126
183
|
}
|
|
127
184
|
tr.appendChild(nodeView);
|
|
128
185
|
} else {
|
|
@@ -132,6 +189,7 @@ const createChangedRowDOM = (rowNode, nodeViewSerializer, colorScheme, isInserte
|
|
|
132
189
|
tr.appendChild(serializedContent);
|
|
133
190
|
}
|
|
134
191
|
}
|
|
192
|
+
cellIndex++;
|
|
135
193
|
}
|
|
136
194
|
});
|
|
137
195
|
return tr;
|
|
@@ -182,7 +240,7 @@ export const createChangedRowDecorationWidgets = ({
|
|
|
182
240
|
diffType
|
|
183
241
|
});
|
|
184
242
|
return changedRows.map(changedRow => {
|
|
185
|
-
const rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
243
|
+
const rowDOM = createChangedRowDOM(changedRow.rowNode, changedRow.cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
186
244
|
|
|
187
245
|
// Find safe insertion position for the deleted row
|
|
188
246
|
const safeInsertPos = findSafeInsertPos(newDoc, changedRow.fromB - 1,
|
|
@@ -170,6 +170,18 @@ export var addedCellOverlayStyle = convertToInlineCss({
|
|
|
170
170
|
outline: "1px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
171
171
|
pointerEvents: 'none'
|
|
172
172
|
});
|
|
173
|
+
export var addedCellOverlayRoundedStyle = convertToInlineCss({
|
|
174
|
+
position: 'absolute',
|
|
175
|
+
top: 0,
|
|
176
|
+
left: 0,
|
|
177
|
+
width: '100%',
|
|
178
|
+
height: '100%',
|
|
179
|
+
backgroundColor: "rgba(from ".concat("var(--ds-background-accent-purple-subtlest, #F8EEFE)", " r g b / 0.5)"),
|
|
180
|
+
zIndex: 2,
|
|
181
|
+
outline: "1px solid ".concat("var(--ds-border-accent-purple, #AF59E1)"),
|
|
182
|
+
pointerEvents: 'none',
|
|
183
|
+
borderRadius: 'inherit'
|
|
184
|
+
});
|
|
173
185
|
export var deletedCellOverlayStyle = convertToInlineCss({
|
|
174
186
|
position: 'absolute',
|
|
175
187
|
top: 0,
|
|
@@ -184,6 +184,19 @@ export var traditionalAddedCellOverlayStyle = convertToInlineCss({
|
|
|
184
184
|
outline: "1px solid ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
185
185
|
pointerEvents: 'none'
|
|
186
186
|
});
|
|
187
|
+
export var traditionalAddedCellOverlayRoundedStyle = convertToInlineCss({
|
|
188
|
+
position: 'absolute',
|
|
189
|
+
top: 0,
|
|
190
|
+
left: 0,
|
|
191
|
+
width: '100%',
|
|
192
|
+
height: '100%',
|
|
193
|
+
backgroundColor: "rgba(from ".concat("var(--ds-background-accent-green-subtlest, #DCFFF1)", " r g b / 0.5)"),
|
|
194
|
+
zIndex: 2,
|
|
195
|
+
outline: "1px solid ".concat("var(--ds-border-accent-green, #22A06B)"),
|
|
196
|
+
pointerEvents: 'none',
|
|
197
|
+
border: 'inherit',
|
|
198
|
+
borderRadius: 'inherit'
|
|
199
|
+
});
|
|
187
200
|
export var traditionalAddedCellOverlayStyleNew = convertToInlineCss({
|
|
188
201
|
position: 'absolute',
|
|
189
202
|
top: 0,
|
|
@@ -9,19 +9,61 @@ import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document
|
|
|
9
9
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
11
11
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
13
|
-
import { addedCellOverlayStyle, deletedRowStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
14
|
-
import { deletedTraditionalRowStyle, deletedTraditionalCellOverlayStyle, traditionalAddedCellOverlayStyle } from './colorSchemes/traditional';
|
|
14
|
+
import { addedCellOverlayStyle, addedCellOverlayRoundedStyle, deletedRowStyle, deletedCellOverlayStyle } from './colorSchemes/standard';
|
|
15
|
+
import { deletedTraditionalRowStyle, deletedTraditionalCellOverlayStyle, traditionalAddedCellOverlayStyle, traditionalAddedCellOverlayRoundedStyle } from './colorSchemes/traditional';
|
|
15
16
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
16
17
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
18
|
+
/**
|
|
19
|
+
* Inserted table rows are rendered as decoration widgets, so their cells do not get the
|
|
20
|
+
* `data-reaches-*` attrs normally applied by the table cell node view. Mirror that boundary
|
|
21
|
+
* metadata here so the existing rounded-table CSS can round widget cells like real table cells.
|
|
22
|
+
*/
|
|
23
|
+
var getChangedRowCellEdgeAttrs = function getChangedRowCellEdgeAttrs(_ref) {
|
|
24
|
+
var rowNode = _ref.rowNode,
|
|
25
|
+
rowStart = _ref.rowStart,
|
|
26
|
+
tableMap = _ref.tableMap;
|
|
27
|
+
var cellEdgeAttrs = [];
|
|
28
|
+
rowNode.content.forEach(function (cellNode, cellOffset) {
|
|
29
|
+
if (cellNode.type.name !== 'tableCell' && cellNode.type.name !== 'tableHeader') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var cellRect = tableMap.findCell(rowStart + 1 + cellOffset);
|
|
33
|
+
cellEdgeAttrs.push({
|
|
34
|
+
reachesBottom: cellRect.bottom >= tableMap.height,
|
|
35
|
+
reachesLeft: cellRect.left === 0,
|
|
36
|
+
reachesRight: cellRect.right >= tableMap.width,
|
|
37
|
+
reachesTop: cellRect.top === 0
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return cellEdgeAttrs;
|
|
41
|
+
};
|
|
42
|
+
var applyCellEdgeAttrs = function applyCellEdgeAttrs(cell, edgeAttrs) {
|
|
43
|
+
if (!edgeAttrs) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (edgeAttrs.reachesTop) {
|
|
47
|
+
cell.setAttribute('data-reaches-top', 'true');
|
|
48
|
+
}
|
|
49
|
+
if (edgeAttrs.reachesBottom) {
|
|
50
|
+
cell.setAttribute('data-reaches-bottom', 'true');
|
|
51
|
+
}
|
|
52
|
+
if (edgeAttrs.reachesLeft) {
|
|
53
|
+
cell.setAttribute('data-reaches-left', 'true');
|
|
54
|
+
}
|
|
55
|
+
if (edgeAttrs.reachesRight) {
|
|
56
|
+
cell.setAttribute('data-reaches-right', 'true');
|
|
57
|
+
}
|
|
58
|
+
};
|
|
17
59
|
/**
|
|
18
60
|
* Extracts information about deleted table rows from a change
|
|
19
61
|
*/
|
|
20
|
-
var extractChangedRows = function extractChangedRows(
|
|
21
|
-
var change =
|
|
22
|
-
originalDoc =
|
|
23
|
-
newDoc =
|
|
24
|
-
diffType =
|
|
62
|
+
var extractChangedRows = function extractChangedRows(_ref2) {
|
|
63
|
+
var change = _ref2.change,
|
|
64
|
+
originalDoc = _ref2.originalDoc,
|
|
65
|
+
newDoc = _ref2.newDoc,
|
|
66
|
+
diffType = _ref2.diffType;
|
|
25
67
|
var changedRows = [];
|
|
26
68
|
|
|
27
69
|
// Find the table in the original document
|
|
@@ -62,12 +104,18 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
62
104
|
// Check if this row overlaps with the deletion range
|
|
63
105
|
var rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
|
|
64
106
|
if (rowOverlapsChange && rowNode.type.name === 'tableRow' && (isExtendedEnabled(diffType) || !isEmptyRow(rowNode))) {
|
|
107
|
+
var cellEdgeAttrs = isExtendedEnabled(diffType) && expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true) ? getChangedRowCellEdgeAttrs({
|
|
108
|
+
rowNode: rowNode,
|
|
109
|
+
rowStart: rowStart,
|
|
110
|
+
tableMap: oldTableMap
|
|
111
|
+
}) : undefined;
|
|
65
112
|
var startOfRow = newTableMap.mapByRow.slice().reverse().find(function (row) {
|
|
66
113
|
return row[0] + tableNew.pos < change.fromB && change.fromB < row[row.length - 1] + tableNew.pos;
|
|
67
114
|
});
|
|
68
115
|
changedRows.push({
|
|
69
116
|
rowIndex: rowIndex,
|
|
70
117
|
rowNode: rowNode,
|
|
118
|
+
cellEdgeAttrs: cellEdgeAttrs,
|
|
71
119
|
fromA: tableOld.pos + 1 + rowStart,
|
|
72
120
|
toA: tableOld.pos + 1 + rowEnd,
|
|
73
121
|
fromB: startOfRow ? startOfRow[0] + tableNew.start : change.fromB
|
|
@@ -116,7 +164,7 @@ var isEmptyRow = function isEmptyRow(rowNode) {
|
|
|
116
164
|
/**
|
|
117
165
|
* Creates a DOM representation of a deleted table row
|
|
118
166
|
*/
|
|
119
|
-
var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
167
|
+
var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
120
168
|
var tr = document.createElement('tr');
|
|
121
169
|
if (isExtendedEnabled(diffType)) {
|
|
122
170
|
if (!isInserted) {
|
|
@@ -128,15 +176,23 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
128
176
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
129
177
|
|
|
130
178
|
// Serialize each cell in the row
|
|
179
|
+
var cellIndex = 0;
|
|
131
180
|
rowNode.content.forEach(function (cellNode) {
|
|
132
181
|
if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
|
|
133
182
|
var nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
|
|
134
183
|
if (nodeView) {
|
|
135
|
-
if (nodeView instanceof HTMLElement
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
184
|
+
if (nodeView instanceof HTMLElement) {
|
|
185
|
+
applyCellEdgeAttrs(nodeView, cellEdgeAttrs === null || cellEdgeAttrs === void 0 ? void 0 : cellEdgeAttrs[cellIndex]);
|
|
186
|
+
if (isExtendedEnabled(diffType)) {
|
|
187
|
+
var overlay = document.createElement('span');
|
|
188
|
+
var isRoundedTable = expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
189
|
+
var isTraditional = colorScheme === 'traditional';
|
|
190
|
+
var deletedCellStyle = isTraditional ? deletedTraditionalCellOverlayStyle : deletedCellOverlayStyle;
|
|
191
|
+
var addedCellStyle = isTraditional ? isRoundedTable ? traditionalAddedCellOverlayRoundedStyle : traditionalAddedCellOverlayStyle : isRoundedTable ? addedCellOverlayRoundedStyle : addedCellOverlayStyle;
|
|
192
|
+
var overlayStyle = isInserted ? addedCellStyle : deletedCellStyle;
|
|
193
|
+
overlay.setAttribute('style', overlayStyle);
|
|
194
|
+
nodeView.appendChild(overlay);
|
|
195
|
+
}
|
|
140
196
|
}
|
|
141
197
|
tr.appendChild(nodeView);
|
|
142
198
|
} else {
|
|
@@ -146,6 +202,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
146
202
|
tr.appendChild(serializedContent);
|
|
147
203
|
}
|
|
148
204
|
}
|
|
205
|
+
cellIndex++;
|
|
149
206
|
}
|
|
150
207
|
});
|
|
151
208
|
return tr;
|
|
@@ -154,11 +211,11 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
154
211
|
/**
|
|
155
212
|
* Expands a diff to include whole changed rows when table rows are affected
|
|
156
213
|
*/
|
|
157
|
-
var expandDiffForChangedRows = function expandDiffForChangedRows(
|
|
158
|
-
var changes =
|
|
159
|
-
originalDoc =
|
|
160
|
-
newDoc =
|
|
161
|
-
diffType =
|
|
214
|
+
var expandDiffForChangedRows = function expandDiffForChangedRows(_ref3) {
|
|
215
|
+
var changes = _ref3.changes,
|
|
216
|
+
originalDoc = _ref3.originalDoc,
|
|
217
|
+
newDoc = _ref3.newDoc,
|
|
218
|
+
diffType = _ref3.diffType;
|
|
162
219
|
var rowInfo = [];
|
|
163
220
|
var _iterator = _createForOfIteratorHelper(changes),
|
|
164
221
|
_step;
|
|
@@ -187,15 +244,15 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
|
|
|
187
244
|
/**
|
|
188
245
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
189
246
|
*/
|
|
190
|
-
export var createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(
|
|
191
|
-
var changes =
|
|
192
|
-
originalDoc =
|
|
193
|
-
newDoc =
|
|
194
|
-
nodeViewSerializer =
|
|
195
|
-
colorScheme =
|
|
196
|
-
|
|
197
|
-
isInserted =
|
|
198
|
-
diffType =
|
|
247
|
+
export var createChangedRowDecorationWidgets = function createChangedRowDecorationWidgets(_ref4) {
|
|
248
|
+
var changes = _ref4.changes,
|
|
249
|
+
originalDoc = _ref4.originalDoc,
|
|
250
|
+
newDoc = _ref4.newDoc,
|
|
251
|
+
nodeViewSerializer = _ref4.nodeViewSerializer,
|
|
252
|
+
colorScheme = _ref4.colorScheme,
|
|
253
|
+
_ref4$isInserted = _ref4.isInserted,
|
|
254
|
+
isInserted = _ref4$isInserted === void 0 ? false : _ref4$isInserted,
|
|
255
|
+
diffType = _ref4.diffType;
|
|
199
256
|
// First, expand the changes to include complete deleted rows
|
|
200
257
|
var changedRows = expandDiffForChangedRows({
|
|
201
258
|
changes: changes.filter(function (change) {
|
|
@@ -206,7 +263,7 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
206
263
|
diffType: diffType
|
|
207
264
|
});
|
|
208
265
|
return changedRows.map(function (changedRow) {
|
|
209
|
-
var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
266
|
+
var rowDOM = createChangedRowDOM(changedRow.rowNode, changedRow.cellEdgeAttrs, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
210
267
|
|
|
211
268
|
// Find safe insertion position for the deleted row
|
|
212
269
|
var safeInsertPos = findSafeInsertPos(newDoc, changedRow.fromB - 1,
|
|
@@ -37,5 +37,6 @@ export declare const editingStyleCardBlockNode: string;
|
|
|
37
37
|
export declare const standardDecorationMarkerVariable: string;
|
|
38
38
|
export declare const deletedDecorationMarkerVariable: string;
|
|
39
39
|
export declare const addedCellOverlayStyle: string;
|
|
40
|
+
export declare const addedCellOverlayRoundedStyle: string;
|
|
40
41
|
export declare const deletedCellOverlayStyle: string;
|
|
41
42
|
export declare const deletedCellOverlayRoundedStyle: string;
|
|
@@ -35,6 +35,7 @@ export declare const traditionalDeletedDecorationMarkerVariable: string;
|
|
|
35
35
|
export declare const traditionalDeletedDecorationMarkerVariableNew: string;
|
|
36
36
|
export declare const traditionalDeletedDecorationMarkerVariableActive: string;
|
|
37
37
|
export declare const traditionalAddedCellOverlayStyle: string;
|
|
38
|
+
export declare const traditionalAddedCellOverlayRoundedStyle: string;
|
|
38
39
|
export declare const traditionalAddedCellOverlayStyleNew: string;
|
|
39
40
|
export declare const deletedTraditionalCellOverlayStyle: string;
|
|
40
41
|
export declare const deletedTraditionalCellOverlayRoundedStyle: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.3",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
29
29
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^132.
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^132.1.0",
|
|
32
32
|
"@atlaskit/tokens": "^16.2.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^1.0.0",
|