@atlaskit/editor-plugin-show-diff 14.0.3 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 14.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`62c3227f6a3ac`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62c3227f6a3ac) -
|
|
8
|
+
[CCI-19031] Fix large-table diffs suppressing decorations on adjacent inserted content. When a
|
|
9
|
+
paragraph (or other block) is inserted next to a large table, the smart classifier coalesces them
|
|
10
|
+
into a single node-level change. The coarse large-table decoration path now scopes cell-only
|
|
11
|
+
suppression to the table subtree, so adjacent inserted content keeps its highlight and indicator
|
|
12
|
+
instead of being dropped.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 14.0.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.isDeletedContentPlacedBelow = exports.calculateDiffDecorations = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
12
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
13
13
|
var _prosemirrorChangeset = require("prosemirror-changeset");
|
|
@@ -115,27 +115,51 @@ var isLargeInsertedTableRange = function isLargeInsertedTableRange(doc, from, to
|
|
|
115
115
|
});
|
|
116
116
|
return containsTable && leafCount > LARGE_TABLE_LEAF_THRESHOLD;
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
118
|
+
|
|
119
|
+
// Collect the [from, to) ranges of every `table` node overlapping `[from, to)`. The coarse
|
|
120
|
+
// large-table path must only suppress decorations inside these ranges
|
|
121
|
+
var tableRanges = function tableRanges(doc, from, to) {
|
|
122
|
+
var ranges = [];
|
|
123
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
124
|
+
if (node.type.name === 'table') {
|
|
125
|
+
ranges.push([pos, pos + node.nodeSize]);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
});
|
|
130
|
+
return ranges;
|
|
131
|
+
};
|
|
132
|
+
var isInsideTable = function isInsideTable(tables, pos) {
|
|
133
|
+
return tables.some(function (_ref2) {
|
|
134
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
135
|
+
tFrom = _ref3[0],
|
|
136
|
+
tTo = _ref3[1];
|
|
137
|
+
return pos >= tFrom && pos < tTo;
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref4) {
|
|
141
|
+
var doc = _ref4.doc,
|
|
142
|
+
from = _ref4.from,
|
|
143
|
+
to = _ref4.to,
|
|
144
|
+
colorScheme = _ref4.colorScheme,
|
|
145
|
+
_ref4$isInserted = _ref4.isInserted,
|
|
146
|
+
isInserted = _ref4$isInserted === void 0 ? true : _ref4$isInserted,
|
|
147
|
+
activeIndexPos = _ref4.activeIndexPos,
|
|
148
|
+
_ref4$shouldHideDelet = _ref4.shouldHideDeleted,
|
|
149
|
+
shouldHideDeleted = _ref4$shouldHideDelet === void 0 ? false : _ref4$shouldHideDelet,
|
|
150
|
+
_ref4$showIndicators = _ref4.showIndicators,
|
|
151
|
+
showIndicators = _ref4$showIndicators === void 0 ? false : _ref4$showIndicators,
|
|
152
|
+
diffType = _ref4.diffType,
|
|
153
|
+
_ref4$coarseTableCell = _ref4.coarseTableCellsOnly,
|
|
154
|
+
coarseTableCellsOnly = _ref4$coarseTableCell === void 0 ? false : _ref4$coarseTableCell;
|
|
133
155
|
var decorations = [];
|
|
156
|
+
// Coarse path: inside the large table, only cell/header overlays are kept — the
|
|
157
|
+
// table/row/paragraph decorations there are redundant and cause expensive per-cell
|
|
158
|
+
// re-render. Blocks outside the table keep their normal decorations.
|
|
159
|
+
var coarseTables = coarseTableCellsOnly ? tableRanges(doc, from, to) : [];
|
|
134
160
|
// Iterate over the document nodes within the range
|
|
135
161
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
136
|
-
|
|
137
|
-
// decorations are redundant and cause expensive per-cell re-render.
|
|
138
|
-
if (coarseTableCellsOnly) {
|
|
162
|
+
if (coarseTableCellsOnly && isInsideTable(coarseTables, pos)) {
|
|
139
163
|
var name = node.type.name;
|
|
140
164
|
if (name !== 'tableCell' && name !== 'tableHeader') {
|
|
141
165
|
return;
|
|
@@ -173,10 +197,10 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
173
197
|
*
|
|
174
198
|
* Callers are responsible for the `smart` diffType and gate checks.
|
|
175
199
|
*/
|
|
176
|
-
var isDeletedContentPlacedBelow = exports.isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(
|
|
177
|
-
var change =
|
|
178
|
-
deletedDiffPlacement =
|
|
179
|
-
inlineDeletedDiffPlacement =
|
|
200
|
+
var isDeletedContentPlacedBelow = exports.isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(_ref5) {
|
|
201
|
+
var change = _ref5.change,
|
|
202
|
+
deletedDiffPlacement = _ref5.deletedDiffPlacement,
|
|
203
|
+
inlineDeletedDiffPlacement = _ref5.inlineDeletedDiffPlacement;
|
|
180
204
|
var level = (0, _helpers.smartChangeLevel)(change);
|
|
181
205
|
if (level === 'node' || level === 'paragraph') {
|
|
182
206
|
return deletedDiffPlacement === 'bottom';
|
|
@@ -185,29 +209,29 @@ var isDeletedContentPlacedBelow = exports.isDeletedContentPlacedBelow = function
|
|
|
185
209
|
// Inline-level (undefined) and sentence-level changes.
|
|
186
210
|
return inlineDeletedDiffPlacement === 'after';
|
|
187
211
|
};
|
|
188
|
-
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(
|
|
189
|
-
var state =
|
|
190
|
-
pluginState =
|
|
191
|
-
nodeViewSerializer =
|
|
192
|
-
colorScheme =
|
|
193
|
-
intl =
|
|
194
|
-
activeIndexPos =
|
|
195
|
-
api =
|
|
196
|
-
|
|
197
|
-
isInverted =
|
|
198
|
-
|
|
199
|
-
diffType =
|
|
200
|
-
|
|
201
|
-
hideDeletedDiffs =
|
|
202
|
-
|
|
203
|
-
hideAddedDiffsUnderlineParam =
|
|
204
|
-
|
|
205
|
-
showIndicators =
|
|
206
|
-
smartThresholds =
|
|
207
|
-
|
|
208
|
-
deletedDiffPlacement =
|
|
209
|
-
|
|
210
|
-
inlineDeletedDiffPlacement =
|
|
212
|
+
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref6) {
|
|
213
|
+
var state = _ref6.state,
|
|
214
|
+
pluginState = _ref6.pluginState,
|
|
215
|
+
nodeViewSerializer = _ref6.nodeViewSerializer,
|
|
216
|
+
colorScheme = _ref6.colorScheme,
|
|
217
|
+
intl = _ref6.intl,
|
|
218
|
+
activeIndexPos = _ref6.activeIndexPos,
|
|
219
|
+
api = _ref6.api,
|
|
220
|
+
_ref6$isInverted = _ref6.isInverted,
|
|
221
|
+
isInverted = _ref6$isInverted === void 0 ? false : _ref6$isInverted,
|
|
222
|
+
_ref6$diffType = _ref6.diffType,
|
|
223
|
+
diffType = _ref6$diffType === void 0 ? (0, _isExtendedEnabled.getDefaultDiffType)() : _ref6$diffType,
|
|
224
|
+
_ref6$hideDeletedDiff = _ref6.hideDeletedDiffs,
|
|
225
|
+
hideDeletedDiffs = _ref6$hideDeletedDiff === void 0 ? false : _ref6$hideDeletedDiff,
|
|
226
|
+
_ref6$hideAddedDiffsU = _ref6.hideAddedDiffsUnderline,
|
|
227
|
+
hideAddedDiffsUnderlineParam = _ref6$hideAddedDiffsU === void 0 ? false : _ref6$hideAddedDiffsU,
|
|
228
|
+
_ref6$showIndicators = _ref6.showIndicators,
|
|
229
|
+
showIndicators = _ref6$showIndicators === void 0 ? false : _ref6$showIndicators,
|
|
230
|
+
smartThresholds = _ref6.smartThresholds,
|
|
231
|
+
_ref6$deletedDiffPlac = _ref6.deletedDiffPlacement,
|
|
232
|
+
deletedDiffPlacement = _ref6$deletedDiffPlac === void 0 ? 'top' : _ref6$deletedDiffPlac,
|
|
233
|
+
_ref6$inlineDeletedDi = _ref6.inlineDeletedDiffPlacement,
|
|
234
|
+
inlineDeletedDiffPlacement = _ref6$inlineDeletedDi === void 0 ? 'before' : _ref6$inlineDeletedDi;
|
|
211
235
|
var originalDoc = pluginState.originalDoc,
|
|
212
236
|
steps = pluginState.steps,
|
|
213
237
|
isDisplayingChanges = pluginState.isDisplayingChanges;
|
|
@@ -328,10 +352,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
328
352
|
// inward — when the widget is present the anchor must stay at the block
|
|
329
353
|
// boundary to keep the indicator bar continuous with the deleted content.
|
|
330
354
|
var willRenderDeletedWidget = change.deleted.length > 0 && !((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && !isInverted && hideDeletedDiffs && change.inserted.length > 0);
|
|
331
|
-
if (
|
|
332
|
-
//
|
|
333
|
-
// provide the highlight without the
|
|
334
|
-
|
|
355
|
+
if (isSmartNodeLevel) {
|
|
356
|
+
// For a large inserted table, skip the O(cells) inline decorations inside the
|
|
357
|
+
// table (the cell overlays added below provide the highlight without the
|
|
358
|
+
// expensive content re-render); leaf blocks outside the table still get theirs.
|
|
359
|
+
var coarseTables = useCoarseTableDecoration ? tableRanges(tr.doc, change.fromB, change.toB) : [];
|
|
335
360
|
var _iterator2 = _createForOfIteratorHelper(leafTextblockRanges(tr.doc, change.fromB, change.toB)),
|
|
336
361
|
_step2;
|
|
337
362
|
try {
|
|
@@ -339,6 +364,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
339
364
|
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
340
365
|
from = _step2$value[0],
|
|
341
366
|
to = _step2$value[1];
|
|
367
|
+
if (useCoarseTableDecoration && isInsideTable(coarseTables, from)) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
342
370
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
|
|
343
371
|
change: {
|
|
344
372
|
fromB: from,
|
|
@@ -518,42 +546,42 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
518
546
|
};
|
|
519
547
|
var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
|
|
520
548
|
// Cache results unless relevant inputs change
|
|
521
|
-
function (
|
|
522
|
-
var
|
|
523
|
-
var
|
|
524
|
-
|
|
525
|
-
pluginState =
|
|
526
|
-
state =
|
|
527
|
-
colorScheme =
|
|
528
|
-
intl =
|
|
529
|
-
activeIndexPos =
|
|
530
|
-
isInverted =
|
|
531
|
-
diffType =
|
|
532
|
-
hideDeletedDiffs =
|
|
533
|
-
hideAddedDiffsUnderline =
|
|
534
|
-
showIndicators =
|
|
535
|
-
smartThresholds =
|
|
536
|
-
deletedDiffPlacement =
|
|
537
|
-
inlineDeletedDiffPlacement =
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
lastPluginState =
|
|
541
|
-
lastState =
|
|
542
|
-
lastColorScheme =
|
|
543
|
-
lastIntl =
|
|
544
|
-
lastActiveIndexPos =
|
|
545
|
-
lastIsInverted =
|
|
546
|
-
lastDiffType =
|
|
547
|
-
lastHideDeletedDiffs =
|
|
548
|
-
lastHideAddedDiffsUnderline =
|
|
549
|
-
lastShowIndicators =
|
|
550
|
-
lastSmartThresholds =
|
|
551
|
-
lastDeletedDiffPlacement =
|
|
552
|
-
lastInlineDeletedDiffPlacement =
|
|
549
|
+
function (_ref7, _ref8) {
|
|
550
|
+
var _ref10;
|
|
551
|
+
var _ref9 = (0, _slicedToArray2.default)(_ref7, 1),
|
|
552
|
+
_ref9$ = _ref9[0],
|
|
553
|
+
pluginState = _ref9$.pluginState,
|
|
554
|
+
state = _ref9$.state,
|
|
555
|
+
colorScheme = _ref9$.colorScheme,
|
|
556
|
+
intl = _ref9$.intl,
|
|
557
|
+
activeIndexPos = _ref9$.activeIndexPos,
|
|
558
|
+
isInverted = _ref9$.isInverted,
|
|
559
|
+
diffType = _ref9$.diffType,
|
|
560
|
+
hideDeletedDiffs = _ref9$.hideDeletedDiffs,
|
|
561
|
+
hideAddedDiffsUnderline = _ref9$.hideAddedDiffsUnderline,
|
|
562
|
+
showIndicators = _ref9$.showIndicators,
|
|
563
|
+
smartThresholds = _ref9$.smartThresholds,
|
|
564
|
+
deletedDiffPlacement = _ref9$.deletedDiffPlacement,
|
|
565
|
+
inlineDeletedDiffPlacement = _ref9$.inlineDeletedDiffPlacement;
|
|
566
|
+
var _ref0 = (0, _slicedToArray2.default)(_ref8, 1),
|
|
567
|
+
_ref0$ = _ref0[0],
|
|
568
|
+
lastPluginState = _ref0$.pluginState,
|
|
569
|
+
lastState = _ref0$.state,
|
|
570
|
+
lastColorScheme = _ref0$.colorScheme,
|
|
571
|
+
lastIntl = _ref0$.intl,
|
|
572
|
+
lastActiveIndexPos = _ref0$.activeIndexPos,
|
|
573
|
+
lastIsInverted = _ref0$.isInverted,
|
|
574
|
+
lastDiffType = _ref0$.diffType,
|
|
575
|
+
lastHideDeletedDiffs = _ref0$.hideDeletedDiffs,
|
|
576
|
+
lastHideAddedDiffsUnderline = _ref0$.hideAddedDiffsUnderline,
|
|
577
|
+
lastShowIndicators = _ref0$.showIndicators,
|
|
578
|
+
lastSmartThresholds = _ref0$.smartThresholds,
|
|
579
|
+
lastDeletedDiffPlacement = _ref0$.deletedDiffPlacement,
|
|
580
|
+
lastInlineDeletedDiffPlacement = _ref0$.inlineDeletedDiffPlacement;
|
|
553
581
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
554
582
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
555
|
-
var
|
|
556
|
-
return (
|
|
583
|
+
var _ref1;
|
|
584
|
+
return (_ref1 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref1 !== void 0 ? _ref1 : false;
|
|
557
585
|
}
|
|
558
|
-
return (
|
|
586
|
+
return (_ref10 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref10 !== void 0 ? _ref10 : false;
|
|
559
587
|
});
|
|
@@ -101,6 +101,21 @@ const isLargeInsertedTableRange = (doc, from, to) => {
|
|
|
101
101
|
});
|
|
102
102
|
return containsTable && leafCount > LARGE_TABLE_LEAF_THRESHOLD;
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
// Collect the [from, to) ranges of every `table` node overlapping `[from, to)`. The coarse
|
|
106
|
+
// large-table path must only suppress decorations inside these ranges
|
|
107
|
+
const tableRanges = (doc, from, to) => {
|
|
108
|
+
const ranges = [];
|
|
109
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
110
|
+
if (node.type.name === 'table') {
|
|
111
|
+
ranges.push([pos, pos + node.nodeSize]);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
return ranges;
|
|
117
|
+
};
|
|
118
|
+
const isInsideTable = (tables, pos) => tables.some(([tFrom, tTo]) => pos >= tFrom && pos < tTo);
|
|
104
119
|
const calculateNodesForBlockDecoration = ({
|
|
105
120
|
doc,
|
|
106
121
|
from,
|
|
@@ -114,11 +129,13 @@ const calculateNodesForBlockDecoration = ({
|
|
|
114
129
|
coarseTableCellsOnly = false
|
|
115
130
|
}) => {
|
|
116
131
|
const decorations = [];
|
|
132
|
+
// Coarse path: inside the large table, only cell/header overlays are kept — the
|
|
133
|
+
// table/row/paragraph decorations there are redundant and cause expensive per-cell
|
|
134
|
+
// re-render. Blocks outside the table keep their normal decorations.
|
|
135
|
+
const coarseTables = coarseTableCellsOnly ? tableRanges(doc, from, to) : [];
|
|
117
136
|
// Iterate over the document nodes within the range
|
|
118
137
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
119
|
-
|
|
120
|
-
// decorations are redundant and cause expensive per-cell re-render.
|
|
121
|
-
if (coarseTableCellsOnly) {
|
|
138
|
+
if (coarseTableCellsOnly && isInsideTable(coarseTables, pos)) {
|
|
122
139
|
const name = node.type.name;
|
|
123
140
|
if (name !== 'tableCell' && name !== 'tableHeader') {
|
|
124
141
|
return;
|
|
@@ -301,11 +318,15 @@ const calculateDiffDecorationsInner = ({
|
|
|
301
318
|
// inward — when the widget is present the anchor must stay at the block
|
|
302
319
|
// boundary to keep the indicator bar continuous with the deleted content.
|
|
303
320
|
const willRenderDeletedWidget = change.deleted.length > 0 && !(isExtendedEnabled(diffType) && !isInverted && hideDeletedDiffs && change.inserted.length > 0);
|
|
304
|
-
if (
|
|
305
|
-
//
|
|
306
|
-
// provide the highlight without the
|
|
307
|
-
|
|
321
|
+
if (isSmartNodeLevel) {
|
|
322
|
+
// For a large inserted table, skip the O(cells) inline decorations inside the
|
|
323
|
+
// table (the cell overlays added below provide the highlight without the
|
|
324
|
+
// expensive content re-render); leaf blocks outside the table still get theirs.
|
|
325
|
+
const coarseTables = useCoarseTableDecoration ? tableRanges(tr.doc, change.fromB, change.toB) : [];
|
|
308
326
|
for (const [from, to] of leafTextblockRanges(tr.doc, change.fromB, change.toB)) {
|
|
327
|
+
if (useCoarseTableDecoration && isInsideTable(coarseTables, from)) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
309
330
|
decorations.push(...createInlineChangedDecoration({
|
|
310
331
|
change: {
|
|
311
332
|
fromB: from,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
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; }
|
|
5
5
|
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) { _defineProperty(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; }
|
|
6
6
|
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; } } }; }
|
|
@@ -108,27 +108,51 @@ var isLargeInsertedTableRange = function isLargeInsertedTableRange(doc, from, to
|
|
|
108
108
|
});
|
|
109
109
|
return containsTable && leafCount > LARGE_TABLE_LEAF_THRESHOLD;
|
|
110
110
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
111
|
+
|
|
112
|
+
// Collect the [from, to) ranges of every `table` node overlapping `[from, to)`. The coarse
|
|
113
|
+
// large-table path must only suppress decorations inside these ranges
|
|
114
|
+
var tableRanges = function tableRanges(doc, from, to) {
|
|
115
|
+
var ranges = [];
|
|
116
|
+
doc.nodesBetween(from, to, function (node, pos) {
|
|
117
|
+
if (node.type.name === 'table') {
|
|
118
|
+
ranges.push([pos, pos + node.nodeSize]);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
return ranges;
|
|
124
|
+
};
|
|
125
|
+
var isInsideTable = function isInsideTable(tables, pos) {
|
|
126
|
+
return tables.some(function (_ref2) {
|
|
127
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
128
|
+
tFrom = _ref3[0],
|
|
129
|
+
tTo = _ref3[1];
|
|
130
|
+
return pos >= tFrom && pos < tTo;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref4) {
|
|
134
|
+
var doc = _ref4.doc,
|
|
135
|
+
from = _ref4.from,
|
|
136
|
+
to = _ref4.to,
|
|
137
|
+
colorScheme = _ref4.colorScheme,
|
|
138
|
+
_ref4$isInserted = _ref4.isInserted,
|
|
139
|
+
isInserted = _ref4$isInserted === void 0 ? true : _ref4$isInserted,
|
|
140
|
+
activeIndexPos = _ref4.activeIndexPos,
|
|
141
|
+
_ref4$shouldHideDelet = _ref4.shouldHideDeleted,
|
|
142
|
+
shouldHideDeleted = _ref4$shouldHideDelet === void 0 ? false : _ref4$shouldHideDelet,
|
|
143
|
+
_ref4$showIndicators = _ref4.showIndicators,
|
|
144
|
+
showIndicators = _ref4$showIndicators === void 0 ? false : _ref4$showIndicators,
|
|
145
|
+
diffType = _ref4.diffType,
|
|
146
|
+
_ref4$coarseTableCell = _ref4.coarseTableCellsOnly,
|
|
147
|
+
coarseTableCellsOnly = _ref4$coarseTableCell === void 0 ? false : _ref4$coarseTableCell;
|
|
126
148
|
var decorations = [];
|
|
149
|
+
// Coarse path: inside the large table, only cell/header overlays are kept — the
|
|
150
|
+
// table/row/paragraph decorations there are redundant and cause expensive per-cell
|
|
151
|
+
// re-render. Blocks outside the table keep their normal decorations.
|
|
152
|
+
var coarseTables = coarseTableCellsOnly ? tableRanges(doc, from, to) : [];
|
|
127
153
|
// Iterate over the document nodes within the range
|
|
128
154
|
doc.nodesBetween(from, to, function (node, pos) {
|
|
129
|
-
|
|
130
|
-
// decorations are redundant and cause expensive per-cell re-render.
|
|
131
|
-
if (coarseTableCellsOnly) {
|
|
155
|
+
if (coarseTableCellsOnly && isInsideTable(coarseTables, pos)) {
|
|
132
156
|
var name = node.type.name;
|
|
133
157
|
if (name !== 'tableCell' && name !== 'tableHeader') {
|
|
134
158
|
return;
|
|
@@ -166,10 +190,10 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
166
190
|
*
|
|
167
191
|
* Callers are responsible for the `smart` diffType and gate checks.
|
|
168
192
|
*/
|
|
169
|
-
export var isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(
|
|
170
|
-
var change =
|
|
171
|
-
deletedDiffPlacement =
|
|
172
|
-
inlineDeletedDiffPlacement =
|
|
193
|
+
export var isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(_ref5) {
|
|
194
|
+
var change = _ref5.change,
|
|
195
|
+
deletedDiffPlacement = _ref5.deletedDiffPlacement,
|
|
196
|
+
inlineDeletedDiffPlacement = _ref5.inlineDeletedDiffPlacement;
|
|
173
197
|
var level = smartChangeLevel(change);
|
|
174
198
|
if (level === 'node' || level === 'paragraph') {
|
|
175
199
|
return deletedDiffPlacement === 'bottom';
|
|
@@ -178,29 +202,29 @@ export var isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(_r
|
|
|
178
202
|
// Inline-level (undefined) and sentence-level changes.
|
|
179
203
|
return inlineDeletedDiffPlacement === 'after';
|
|
180
204
|
};
|
|
181
|
-
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(
|
|
182
|
-
var state =
|
|
183
|
-
pluginState =
|
|
184
|
-
nodeViewSerializer =
|
|
185
|
-
colorScheme =
|
|
186
|
-
intl =
|
|
187
|
-
activeIndexPos =
|
|
188
|
-
api =
|
|
189
|
-
|
|
190
|
-
isInverted =
|
|
191
|
-
|
|
192
|
-
diffType =
|
|
193
|
-
|
|
194
|
-
hideDeletedDiffs =
|
|
195
|
-
|
|
196
|
-
hideAddedDiffsUnderlineParam =
|
|
197
|
-
|
|
198
|
-
showIndicators =
|
|
199
|
-
smartThresholds =
|
|
200
|
-
|
|
201
|
-
deletedDiffPlacement =
|
|
202
|
-
|
|
203
|
-
inlineDeletedDiffPlacement =
|
|
205
|
+
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref6) {
|
|
206
|
+
var state = _ref6.state,
|
|
207
|
+
pluginState = _ref6.pluginState,
|
|
208
|
+
nodeViewSerializer = _ref6.nodeViewSerializer,
|
|
209
|
+
colorScheme = _ref6.colorScheme,
|
|
210
|
+
intl = _ref6.intl,
|
|
211
|
+
activeIndexPos = _ref6.activeIndexPos,
|
|
212
|
+
api = _ref6.api,
|
|
213
|
+
_ref6$isInverted = _ref6.isInverted,
|
|
214
|
+
isInverted = _ref6$isInverted === void 0 ? false : _ref6$isInverted,
|
|
215
|
+
_ref6$diffType = _ref6.diffType,
|
|
216
|
+
diffType = _ref6$diffType === void 0 ? getDefaultDiffType() : _ref6$diffType,
|
|
217
|
+
_ref6$hideDeletedDiff = _ref6.hideDeletedDiffs,
|
|
218
|
+
hideDeletedDiffs = _ref6$hideDeletedDiff === void 0 ? false : _ref6$hideDeletedDiff,
|
|
219
|
+
_ref6$hideAddedDiffsU = _ref6.hideAddedDiffsUnderline,
|
|
220
|
+
hideAddedDiffsUnderlineParam = _ref6$hideAddedDiffsU === void 0 ? false : _ref6$hideAddedDiffsU,
|
|
221
|
+
_ref6$showIndicators = _ref6.showIndicators,
|
|
222
|
+
showIndicators = _ref6$showIndicators === void 0 ? false : _ref6$showIndicators,
|
|
223
|
+
smartThresholds = _ref6.smartThresholds,
|
|
224
|
+
_ref6$deletedDiffPlac = _ref6.deletedDiffPlacement,
|
|
225
|
+
deletedDiffPlacement = _ref6$deletedDiffPlac === void 0 ? 'top' : _ref6$deletedDiffPlac,
|
|
226
|
+
_ref6$inlineDeletedDi = _ref6.inlineDeletedDiffPlacement,
|
|
227
|
+
inlineDeletedDiffPlacement = _ref6$inlineDeletedDi === void 0 ? 'before' : _ref6$inlineDeletedDi;
|
|
204
228
|
var originalDoc = pluginState.originalDoc,
|
|
205
229
|
steps = pluginState.steps,
|
|
206
230
|
isDisplayingChanges = pluginState.isDisplayingChanges;
|
|
@@ -321,10 +345,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
321
345
|
// inward — when the widget is present the anchor must stay at the block
|
|
322
346
|
// boundary to keep the indicator bar continuous with the deleted content.
|
|
323
347
|
var willRenderDeletedWidget = change.deleted.length > 0 && !(isExtendedEnabled(diffType) && !isInverted && hideDeletedDiffs && change.inserted.length > 0);
|
|
324
|
-
if (
|
|
325
|
-
//
|
|
326
|
-
// provide the highlight without the
|
|
327
|
-
|
|
348
|
+
if (isSmartNodeLevel) {
|
|
349
|
+
// For a large inserted table, skip the O(cells) inline decorations inside the
|
|
350
|
+
// table (the cell overlays added below provide the highlight without the
|
|
351
|
+
// expensive content re-render); leaf blocks outside the table still get theirs.
|
|
352
|
+
var coarseTables = useCoarseTableDecoration ? tableRanges(tr.doc, change.fromB, change.toB) : [];
|
|
328
353
|
var _iterator2 = _createForOfIteratorHelper(leafTextblockRanges(tr.doc, change.fromB, change.toB)),
|
|
329
354
|
_step2;
|
|
330
355
|
try {
|
|
@@ -332,6 +357,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
332
357
|
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
333
358
|
from = _step2$value[0],
|
|
334
359
|
to = _step2$value[1];
|
|
360
|
+
if (useCoarseTableDecoration && isInsideTable(coarseTables, from)) {
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
335
363
|
decorations.push.apply(decorations, _toConsumableArray(createInlineChangedDecoration(_objectSpread({
|
|
336
364
|
change: {
|
|
337
365
|
fromB: from,
|
|
@@ -511,42 +539,42 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref4
|
|
|
511
539
|
};
|
|
512
540
|
export var calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
|
|
513
541
|
// Cache results unless relevant inputs change
|
|
514
|
-
function (
|
|
515
|
-
var
|
|
516
|
-
var
|
|
517
|
-
|
|
518
|
-
pluginState =
|
|
519
|
-
state =
|
|
520
|
-
colorScheme =
|
|
521
|
-
intl =
|
|
522
|
-
activeIndexPos =
|
|
523
|
-
isInverted =
|
|
524
|
-
diffType =
|
|
525
|
-
hideDeletedDiffs =
|
|
526
|
-
hideAddedDiffsUnderline =
|
|
527
|
-
showIndicators =
|
|
528
|
-
smartThresholds =
|
|
529
|
-
deletedDiffPlacement =
|
|
530
|
-
inlineDeletedDiffPlacement =
|
|
531
|
-
var
|
|
532
|
-
|
|
533
|
-
lastPluginState =
|
|
534
|
-
lastState =
|
|
535
|
-
lastColorScheme =
|
|
536
|
-
lastIntl =
|
|
537
|
-
lastActiveIndexPos =
|
|
538
|
-
lastIsInverted =
|
|
539
|
-
lastDiffType =
|
|
540
|
-
lastHideDeletedDiffs =
|
|
541
|
-
lastHideAddedDiffsUnderline =
|
|
542
|
-
lastShowIndicators =
|
|
543
|
-
lastSmartThresholds =
|
|
544
|
-
lastDeletedDiffPlacement =
|
|
545
|
-
lastInlineDeletedDiffPlacement =
|
|
542
|
+
function (_ref7, _ref8) {
|
|
543
|
+
var _ref10;
|
|
544
|
+
var _ref9 = _slicedToArray(_ref7, 1),
|
|
545
|
+
_ref9$ = _ref9[0],
|
|
546
|
+
pluginState = _ref9$.pluginState,
|
|
547
|
+
state = _ref9$.state,
|
|
548
|
+
colorScheme = _ref9$.colorScheme,
|
|
549
|
+
intl = _ref9$.intl,
|
|
550
|
+
activeIndexPos = _ref9$.activeIndexPos,
|
|
551
|
+
isInverted = _ref9$.isInverted,
|
|
552
|
+
diffType = _ref9$.diffType,
|
|
553
|
+
hideDeletedDiffs = _ref9$.hideDeletedDiffs,
|
|
554
|
+
hideAddedDiffsUnderline = _ref9$.hideAddedDiffsUnderline,
|
|
555
|
+
showIndicators = _ref9$.showIndicators,
|
|
556
|
+
smartThresholds = _ref9$.smartThresholds,
|
|
557
|
+
deletedDiffPlacement = _ref9$.deletedDiffPlacement,
|
|
558
|
+
inlineDeletedDiffPlacement = _ref9$.inlineDeletedDiffPlacement;
|
|
559
|
+
var _ref0 = _slicedToArray(_ref8, 1),
|
|
560
|
+
_ref0$ = _ref0[0],
|
|
561
|
+
lastPluginState = _ref0$.pluginState,
|
|
562
|
+
lastState = _ref0$.state,
|
|
563
|
+
lastColorScheme = _ref0$.colorScheme,
|
|
564
|
+
lastIntl = _ref0$.intl,
|
|
565
|
+
lastActiveIndexPos = _ref0$.activeIndexPos,
|
|
566
|
+
lastIsInverted = _ref0$.isInverted,
|
|
567
|
+
lastDiffType = _ref0$.diffType,
|
|
568
|
+
lastHideDeletedDiffs = _ref0$.hideDeletedDiffs,
|
|
569
|
+
lastHideAddedDiffsUnderline = _ref0$.hideAddedDiffsUnderline,
|
|
570
|
+
lastShowIndicators = _ref0$.showIndicators,
|
|
571
|
+
lastSmartThresholds = _ref0$.smartThresholds,
|
|
572
|
+
lastDeletedDiffPlacement = _ref0$.deletedDiffPlacement,
|
|
573
|
+
lastInlineDeletedDiffPlacement = _ref0$.inlineDeletedDiffPlacement;
|
|
546
574
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
547
575
|
if (isExtendedEnabled(diffType)) {
|
|
548
|
-
var
|
|
549
|
-
return (
|
|
576
|
+
var _ref1;
|
|
577
|
+
return (_ref1 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref1 !== void 0 ? _ref1 : false;
|
|
550
578
|
}
|
|
551
|
-
return (
|
|
579
|
+
return (_ref10 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref10 !== void 0 ? _ref10 : false;
|
|
552
580
|
});
|