@atlaskit/editor-plugin-show-diff 15.0.1 → 15.1.2
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 +41 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +131 -79
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +32 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +87 -25
- package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +27 -4
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +17 -3
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
- package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +43 -14
- package/dist/cjs/pm-plugins/decorations/revealStyles.js +156 -0
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -5
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +4 -2
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +2 -1
- package/dist/cjs/pm-plugins/main.js +28 -10
- package/dist/cjs/pm-plugins/resolveDiffContributors.js +16 -9
- package/dist/cjs/pm-plugins/revealAnimation.js +524 -0
- package/dist/cjs/showDiffPlugin.js +42 -7
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +59 -9
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +30 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +62 -4
- package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +25 -3
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +18 -1
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
- package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +36 -9
- package/dist/es2019/pm-plugins/decorations/revealStyles.js +139 -0
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -6
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +6 -3
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +5 -2
- package/dist/es2019/pm-plugins/main.js +28 -9
- package/dist/es2019/pm-plugins/resolveDiffContributors.js +16 -8
- package/dist/es2019/pm-plugins/revealAnimation.js +495 -0
- package/dist/es2019/showDiffPlugin.js +37 -7
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +131 -79
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +30 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +87 -25
- package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +27 -4
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +17 -3
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +5 -3
- package/dist/esm/pm-plugins/decorations/extractContributorTags.js +43 -14
- package/dist/esm/pm-plugins/decorations/revealStyles.js +149 -0
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +25 -5
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +4 -2
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +2 -1
- package/dist/esm/pm-plugins/main.js +28 -10
- package/dist/esm/pm-plugins/resolveDiffContributors.js +16 -9
- package/dist/esm/pm-plugins/revealAnimation.js +518 -0
- package/dist/esm/showDiffPlugin.js +42 -7
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +24 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +5 -1
- package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +9 -3
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/revealStyles.d.ts +49 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +4 -3
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +6 -1
- package/dist/types/pm-plugins/resolveDiffContributors.d.ts +3 -2
- package/dist/types/pm-plugins/revealAnimation.d.ts +33 -0
- package/dist/types/showDiffPluginType.d.ts +29 -1
- package/package.json +9 -3
|
@@ -170,7 +170,8 @@ var isInsideTable = function isInsideTable(tables, pos) {
|
|
|
170
170
|
});
|
|
171
171
|
};
|
|
172
172
|
var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration(_ref5) {
|
|
173
|
-
var
|
|
173
|
+
var attributionKey = _ref5.attributionKey,
|
|
174
|
+
doc = _ref5.doc,
|
|
174
175
|
from = _ref5.from,
|
|
175
176
|
to = _ref5.to,
|
|
176
177
|
colorScheme = _ref5.colorScheme,
|
|
@@ -179,11 +180,14 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
179
180
|
activeIndexPos = _ref5.activeIndexPos,
|
|
180
181
|
_ref5$shouldHideDelet = _ref5.shouldHideDeleted,
|
|
181
182
|
shouldHideDeleted = _ref5$shouldHideDelet === void 0 ? false : _ref5$shouldHideDelet,
|
|
183
|
+
_ref5$showContributor = _ref5.showContributorTags,
|
|
184
|
+
showContributorTags = _ref5$showContributor === void 0 ? false : _ref5$showContributor,
|
|
182
185
|
_ref5$showIndicators = _ref5.showIndicators,
|
|
183
186
|
showIndicators = _ref5$showIndicators === void 0 ? false : _ref5$showIndicators,
|
|
184
187
|
diffType = _ref5.diffType,
|
|
185
188
|
_ref5$coarseTableCell = _ref5.coarseTableCellsOnly,
|
|
186
|
-
coarseTableCellsOnly = _ref5$coarseTableCell === void 0 ? false : _ref5$coarseTableCell
|
|
189
|
+
coarseTableCellsOnly = _ref5$coarseTableCell === void 0 ? false : _ref5$coarseTableCell,
|
|
190
|
+
tagMountContext = _ref5.tagMountContext;
|
|
187
191
|
var decorations = [];
|
|
188
192
|
// Coarse path: inside the large table, only cell/header overlays are kept — the
|
|
189
193
|
// table/row/paragraph decorations there are redundant and cause expensive per-cell
|
|
@@ -201,6 +205,7 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
201
205
|
var nodeEnd = pos + node.nodeSize;
|
|
202
206
|
var isActive = isRangeActive(activeIndexPos, pos, nodeEnd);
|
|
203
207
|
decorations.push.apply(decorations, _toConsumableArray(createBlockChangedDecoration({
|
|
208
|
+
attributionKey: attributionKey,
|
|
204
209
|
change: {
|
|
205
210
|
from: pos,
|
|
206
211
|
to: nodeEnd,
|
|
@@ -210,9 +215,11 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
210
215
|
isInserted: isInserted,
|
|
211
216
|
isActive: isActive,
|
|
212
217
|
shouldHideDeleted: shouldHideDeleted,
|
|
218
|
+
showContributorTags: showContributorTags,
|
|
213
219
|
showIndicators: showIndicators,
|
|
214
220
|
doc: doc,
|
|
215
|
-
diffType: diffType
|
|
221
|
+
diffType: diffType,
|
|
222
|
+
tagMountContext: tagMountContext
|
|
216
223
|
})));
|
|
217
224
|
}
|
|
218
225
|
});
|
|
@@ -241,30 +248,51 @@ export var isDeletedContentPlacedBelow = function isDeletedContentPlacedBelow(_r
|
|
|
241
248
|
// Inline-level (undefined) and sentence-level changes.
|
|
242
249
|
return inlineDeletedDiffPlacement === 'after';
|
|
243
250
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Single place `platform_editor_diff_hide_pure_deletions` is read, shared by the widget-anchor
|
|
254
|
+
* calculation and the decoration push below so the two cannot drift.
|
|
255
|
+
*
|
|
256
|
+
* The clean view ("new state") historically only suppressed a deleted side when the same change
|
|
257
|
+
* also carried an insertion. A PURE deletion — text removed with nothing put in its place — fell
|
|
258
|
+
* through and leaked struck-through text into a view that is supposed to show none. `smart` never
|
|
259
|
+
* showed this because it pairs a rewrite into a single change that always carries an insertion;
|
|
260
|
+
* `inline` emits delete-only changes, so it did.
|
|
261
|
+
*
|
|
262
|
+
* With the gate off this returns exactly what both callers computed before it existed.
|
|
263
|
+
*/
|
|
264
|
+
var shouldHideDeletedSide = function shouldHideDeletedSide(_ref7) {
|
|
265
|
+
var change = _ref7.change,
|
|
266
|
+
diffType = _ref7.diffType,
|
|
267
|
+
hideDeletedDiffs = _ref7.hideDeletedDiffs,
|
|
268
|
+
isInverted = _ref7.isInverted;
|
|
269
|
+
return isExtendedEnabled(diffType) && !isInverted && !!hideDeletedDiffs && (change.inserted.length > 0 || fg('platform_editor_diff_hide_pure_deletions'));
|
|
270
|
+
};
|
|
271
|
+
var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref8) {
|
|
272
|
+
var state = _ref8.state,
|
|
273
|
+
pluginState = _ref8.pluginState,
|
|
274
|
+
nodeViewSerializer = _ref8.nodeViewSerializer,
|
|
275
|
+
colorScheme = _ref8.colorScheme,
|
|
276
|
+
intl = _ref8.intl,
|
|
277
|
+
activeIndexPos = _ref8.activeIndexPos,
|
|
278
|
+
api = _ref8.api,
|
|
279
|
+
_ref8$isInverted = _ref8.isInverted,
|
|
280
|
+
isInverted = _ref8$isInverted === void 0 ? false : _ref8$isInverted,
|
|
281
|
+
_ref8$diffType = _ref8.diffType,
|
|
282
|
+
diffType = _ref8$diffType === void 0 ? getDefaultDiffType() : _ref8$diffType,
|
|
283
|
+
_ref8$hideDeletedDiff = _ref8.hideDeletedDiffs,
|
|
284
|
+
hideDeletedDiffs = _ref8$hideDeletedDiff === void 0 ? false : _ref8$hideDeletedDiff,
|
|
285
|
+
_ref8$hideAddedDiffsU = _ref8.hideAddedDiffsUnderline,
|
|
286
|
+
hideAddedDiffsUnderlineParam = _ref8$hideAddedDiffsU === void 0 ? false : _ref8$hideAddedDiffsU,
|
|
287
|
+
_ref8$showIndicators = _ref8.showIndicators,
|
|
288
|
+
showIndicators = _ref8$showIndicators === void 0 ? false : _ref8$showIndicators,
|
|
289
|
+
smartThresholds = _ref8.smartThresholds,
|
|
290
|
+
_ref8$deletedDiffPlac = _ref8.deletedDiffPlacement,
|
|
291
|
+
deletedDiffPlacement = _ref8$deletedDiffPlac === void 0 ? 'top' : _ref8$deletedDiffPlac,
|
|
292
|
+
_ref8$inlineDeletedDi = _ref8.inlineDeletedDiffPlacement,
|
|
293
|
+
inlineDeletedDiffPlacement = _ref8$inlineDeletedDi === void 0 ? 'before' : _ref8$inlineDeletedDi,
|
|
294
|
+
reveal = _ref8.reveal,
|
|
295
|
+
tagMountContext = _ref8.tagMountContext;
|
|
268
296
|
var originalDoc = pluginState.originalDoc,
|
|
269
297
|
steps = pluginState.steps,
|
|
270
298
|
stepAttributions = pluginState.stepAttributions,
|
|
@@ -291,12 +319,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
291
319
|
var simplifiedStepAttributions = [];
|
|
292
320
|
if (attributedChangesetEnabled) {
|
|
293
321
|
var simplifiedStepsWithAttribution = simplifyStepsWithAttribution(steps, stepAttributions !== null && stepAttributions !== void 0 ? stepAttributions : [], originalDoc);
|
|
294
|
-
simplifiedSteps = simplifiedStepsWithAttribution.map(function (
|
|
295
|
-
var step =
|
|
322
|
+
simplifiedSteps = simplifiedStepsWithAttribution.map(function (_ref9) {
|
|
323
|
+
var step = _ref9.step;
|
|
296
324
|
return step;
|
|
297
325
|
});
|
|
298
|
-
simplifiedStepAttributions = simplifiedStepsWithAttribution.map(function (
|
|
299
|
-
var stepAttribution =
|
|
326
|
+
simplifiedStepAttributions = simplifiedStepsWithAttribution.map(function (_ref0) {
|
|
327
|
+
var stepAttribution = _ref0.stepAttribution;
|
|
300
328
|
return stepAttribution;
|
|
301
329
|
});
|
|
302
330
|
} else {
|
|
@@ -330,11 +358,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
330
358
|
} finally {
|
|
331
359
|
_iterator.f();
|
|
332
360
|
}
|
|
333
|
-
var attrStepContexts = fg('platform_editor_reduce_diff_attr_sensitivity') ? pendingAttrSteps.flatMap(function (
|
|
334
|
-
var afterNode =
|
|
335
|
-
beforeNode =
|
|
336
|
-
mapIndex =
|
|
337
|
-
step =
|
|
361
|
+
var attrStepContexts = fg('platform_editor_reduce_diff_attr_sensitivity') ? pendingAttrSteps.flatMap(function (_ref1) {
|
|
362
|
+
var afterNode = _ref1.afterNode,
|
|
363
|
+
beforeNode = _ref1.beforeNode,
|
|
364
|
+
mapIndex = _ref1.mapIndex,
|
|
365
|
+
step = _ref1.step;
|
|
338
366
|
var finalPosition = new Mapping(stepMaps.slice(mapIndex + 1)).mapResult(step.pos);
|
|
339
367
|
if (finalPosition.deleted) {
|
|
340
368
|
return [];
|
|
@@ -349,8 +377,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
349
377
|
}), {}, {
|
|
350
378
|
step: step
|
|
351
379
|
})];
|
|
352
|
-
}) : pendingAttrSteps.map(function (
|
|
353
|
-
var step =
|
|
380
|
+
}) : pendingAttrSteps.map(function (_ref10) {
|
|
381
|
+
var step = _ref10.step;
|
|
354
382
|
return {
|
|
355
383
|
afterNode: tr.doc.nodeAt(step.pos),
|
|
356
384
|
beforeNode: originalDoc.nodeAt(step.pos),
|
|
@@ -487,7 +515,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
487
515
|
// change. Used to decide if indicator anchor positions should be adjusted
|
|
488
516
|
// inward — when the widget is present the anchor must stay at the block
|
|
489
517
|
// boundary to keep the indicator bar continuous with the deleted content.
|
|
490
|
-
var willRenderDeletedWidget = change.deleted.length > 0 && !isMarkOnly && !(
|
|
518
|
+
var willRenderDeletedWidget = change.deleted.length > 0 && !isMarkOnly && !shouldHideDeletedSide({
|
|
519
|
+
change: change,
|
|
520
|
+
diffType: diffType,
|
|
521
|
+
hideDeletedDiffs: hideDeletedDiffs,
|
|
522
|
+
isInverted: isInverted
|
|
523
|
+
});
|
|
491
524
|
if (isSmartNodeLevel) {
|
|
492
525
|
// For a large inserted table, skip the O(cells) inline decorations inside the
|
|
493
526
|
// table (the cell overlays added below provide the highlight without the
|
|
@@ -521,6 +554,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
521
554
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
522
555
|
hasDeletedWidget: willRenderDeletedWidget,
|
|
523
556
|
isDeletedWidgetBelow: isDeletedWidgetBelow,
|
|
557
|
+
reveal: reveal,
|
|
524
558
|
tagMountContext: tagMountContext
|
|
525
559
|
}))));
|
|
526
560
|
}
|
|
@@ -545,10 +579,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
545
579
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
546
580
|
hasDeletedWidget: willRenderDeletedWidget,
|
|
547
581
|
isDeletedWidgetBelow: isDeletedWidgetBelow,
|
|
582
|
+
reveal: reveal,
|
|
548
583
|
tagMountContext: tagMountContext
|
|
549
584
|
}))));
|
|
550
585
|
}
|
|
551
586
|
decorations.push.apply(decorations, _toConsumableArray(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
|
|
587
|
+
attributionKey: attributionKey,
|
|
552
588
|
doc: tr.doc,
|
|
553
589
|
from: change.fromB,
|
|
554
590
|
to: change.toB,
|
|
@@ -556,7 +592,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
556
592
|
}, isExtendedEnabled(diffType) && {
|
|
557
593
|
isInserted: isInserted,
|
|
558
594
|
shouldHideDeleted: shouldHideDeleted,
|
|
559
|
-
|
|
595
|
+
showContributorTags: showContributorTags,
|
|
596
|
+
showIndicators: showIndicators,
|
|
597
|
+
tagMountContext: tagMountContext
|
|
560
598
|
}), {}, {
|
|
561
599
|
activeIndexPos: activeIndexPos,
|
|
562
600
|
intl: intl,
|
|
@@ -565,11 +603,19 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
565
603
|
}))));
|
|
566
604
|
}
|
|
567
605
|
if (change.deleted.length > 0 && !isMarkOnly) {
|
|
568
|
-
var _shouldHideDeleted =
|
|
606
|
+
var _shouldHideDeleted = shouldHideDeletedSide({
|
|
607
|
+
change: change,
|
|
608
|
+
diffType: diffType,
|
|
609
|
+
hideDeletedDiffs: hideDeletedDiffs,
|
|
610
|
+
isInverted: isInverted
|
|
611
|
+
});
|
|
569
612
|
if (!_shouldHideDeleted) {
|
|
570
613
|
decorations.push.apply(decorations, _toConsumableArray(createNodeChangedDecorationWidget(_objectSpread(_objectSpread({
|
|
571
614
|
// The deleted side has no inline decoration, so the widget carries the actor.
|
|
572
615
|
attributionKey: attributionKey,
|
|
616
|
+
// Extended pipeline only, matching the inline path: the non-extended styles have no
|
|
617
|
+
// background for the wipe to act on.
|
|
618
|
+
reveal: isExtendedEnabled(diffType) ? reveal : undefined,
|
|
573
619
|
change: change,
|
|
574
620
|
doc: originalDoc,
|
|
575
621
|
nodeViewSerializer: nodeViewSerializer,
|
|
@@ -597,9 +643,9 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
597
643
|
// smart path. Only add the legacy step-range decoration when no equivalent changeset range was
|
|
598
644
|
// produced; otherwise the same content receives two inline decorations (and two navigation
|
|
599
645
|
// changes), usually one attribution colour and one default purple decoration.
|
|
600
|
-
getMarkChangeRanges(steps).filter(function (
|
|
601
|
-
var fromB =
|
|
602
|
-
toB =
|
|
646
|
+
getMarkChangeRanges(steps).filter(function (_ref11) {
|
|
647
|
+
var fromB = _ref11.fromB,
|
|
648
|
+
toB = _ref11.toB;
|
|
603
649
|
return !fg('confluence_ncs_step_diffing_version_history') || !changes.some(function (change) {
|
|
604
650
|
return change.fromB === fromB && change.toB === toB;
|
|
605
651
|
});
|
|
@@ -610,7 +656,8 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
610
656
|
colorScheme: colorScheme,
|
|
611
657
|
diffType: diffType,
|
|
612
658
|
isActive: isActive,
|
|
613
|
-
isInserted: true
|
|
659
|
+
isInserted: true,
|
|
660
|
+
reveal: reveal
|
|
614
661
|
})));
|
|
615
662
|
});
|
|
616
663
|
getAttrChangeRanges(tr.doc, attrStepContexts, originalDoc).forEach(function (change) {
|
|
@@ -700,44 +747,49 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
700
747
|
export var calculateDiffDecorations = memoizeOne(calculateDiffDecorationsInner,
|
|
701
748
|
// Cache results unless relevant inputs change. `tagMountContext` is deliberately absent: it is
|
|
702
749
|
// built once per plugin instance, so it can never be the reason a diff needs recalculating.
|
|
703
|
-
function (
|
|
704
|
-
var
|
|
705
|
-
var _ref13 = _slicedToArray(_ref11, 1),
|
|
706
|
-
_ref13$ = _ref13[0],
|
|
707
|
-
pluginState = _ref13$.pluginState,
|
|
708
|
-
state = _ref13$.state,
|
|
709
|
-
colorScheme = _ref13$.colorScheme,
|
|
710
|
-
intl = _ref13$.intl,
|
|
711
|
-
activeIndexPos = _ref13$.activeIndexPos,
|
|
712
|
-
isInverted = _ref13$.isInverted,
|
|
713
|
-
diffType = _ref13$.diffType,
|
|
714
|
-
hideDeletedDiffs = _ref13$.hideDeletedDiffs,
|
|
715
|
-
hideAddedDiffsUnderline = _ref13$.hideAddedDiffsUnderline,
|
|
716
|
-
showIndicators = _ref13$.showIndicators,
|
|
717
|
-
smartThresholds = _ref13$.smartThresholds,
|
|
718
|
-
deletedDiffPlacement = _ref13$.deletedDiffPlacement,
|
|
719
|
-
inlineDeletedDiffPlacement = _ref13$.inlineDeletedDiffPlacement;
|
|
750
|
+
function (_ref12, _ref13) {
|
|
751
|
+
var _ref17;
|
|
720
752
|
var _ref14 = _slicedToArray(_ref12, 1),
|
|
721
753
|
_ref14$ = _ref14[0],
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
754
|
+
pluginState = _ref14$.pluginState,
|
|
755
|
+
state = _ref14$.state,
|
|
756
|
+
colorScheme = _ref14$.colorScheme,
|
|
757
|
+
intl = _ref14$.intl,
|
|
758
|
+
activeIndexPos = _ref14$.activeIndexPos,
|
|
759
|
+
isInverted = _ref14$.isInverted,
|
|
760
|
+
diffType = _ref14$.diffType,
|
|
761
|
+
hideDeletedDiffs = _ref14$.hideDeletedDiffs,
|
|
762
|
+
hideAddedDiffsUnderline = _ref14$.hideAddedDiffsUnderline,
|
|
763
|
+
showIndicators = _ref14$.showIndicators,
|
|
764
|
+
smartThresholds = _ref14$.smartThresholds,
|
|
765
|
+
deletedDiffPlacement = _ref14$.deletedDiffPlacement,
|
|
766
|
+
inlineDeletedDiffPlacement = _ref14$.inlineDeletedDiffPlacement,
|
|
767
|
+
reveal = _ref14$.reveal;
|
|
768
|
+
var _ref15 = _slicedToArray(_ref13, 1),
|
|
769
|
+
_ref15$ = _ref15[0],
|
|
770
|
+
lastPluginState = _ref15$.pluginState,
|
|
771
|
+
lastState = _ref15$.state,
|
|
772
|
+
lastColorScheme = _ref15$.colorScheme,
|
|
773
|
+
lastIntl = _ref15$.intl,
|
|
774
|
+
lastActiveIndexPos = _ref15$.activeIndexPos,
|
|
775
|
+
lastIsInverted = _ref15$.isInverted,
|
|
776
|
+
lastDiffType = _ref15$.diffType,
|
|
777
|
+
lastHideDeletedDiffs = _ref15$.hideDeletedDiffs,
|
|
778
|
+
lastHideAddedDiffsUnderline = _ref15$.hideAddedDiffsUnderline,
|
|
779
|
+
lastShowIndicators = _ref15$.showIndicators,
|
|
780
|
+
lastSmartThresholds = _ref15$.smartThresholds,
|
|
781
|
+
lastDeletedDiffPlacement = _ref15$.deletedDiffPlacement,
|
|
782
|
+
lastInlineDeletedDiffPlacement = _ref15$.inlineDeletedDiffPlacement,
|
|
783
|
+
lastReveal = _ref15$.reveal;
|
|
735
784
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
736
785
|
if (isExtendedEnabled(diffType)) {
|
|
737
|
-
var
|
|
738
|
-
return (
|
|
786
|
+
var _ref16;
|
|
787
|
+
return (_ref16 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && isEqual(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && isEqual(pluginState.stepAttributions, lastPluginState.stepAttributions) &&
|
|
739
788
|
// Contributors can arrive after the first calculation; without this, tags never appear.
|
|
740
|
-
isEqual(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement
|
|
789
|
+
isEqual(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && isEqual(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement &&
|
|
790
|
+
// Turning the reveal on or off changes the emitted styles, so a cached result from the
|
|
791
|
+
// other setting would leave the diff painted in the wrong resting state.
|
|
792
|
+
isEqual(reveal, lastReveal)) !== null && _ref16 !== void 0 ? _ref16 : false;
|
|
741
793
|
}
|
|
742
|
-
return (
|
|
794
|
+
return (_ref17 = originalDocIsSame && isEqual(pluginState.steps, lastPluginState.steps) && isEqual(pluginState.stepAttributions, lastPluginState.stepAttributions) && isEqual(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isEqual(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref17 !== void 0 ? _ref17 : false;
|
|
743
795
|
});
|
|
@@ -682,6 +682,36 @@ export function buildInsertedInlineStyle(colors, isActive, hideAddedDiffsUnderli
|
|
|
682
682
|
return hideAddedDiffsUnderline ? buildInsertStyleExtendedNoUnderline(colors) : buildInsertStyleExtended(colors);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
+
/**
|
|
686
|
+
* The colours `buildInsertedInlineStyle()` above would paint, for the reveal to animate towards.
|
|
687
|
+
*
|
|
688
|
+
* MUST mirror that function: the reveal replaces the flat highlight with a sized gradient, so a
|
|
689
|
+
* divergence here means the animation settles on a different colour than a static render produces.
|
|
690
|
+
* `revealStyles.ts` in the test package asserts the two agree across the isActive /
|
|
691
|
+
* hideAddedDiffsUnderline matrix.
|
|
692
|
+
*
|
|
693
|
+
* A transparent border is how "no underline" is expressed: the box still reserves the 2px so the
|
|
694
|
+
* text does not shift when the underline arrives.
|
|
695
|
+
*/
|
|
696
|
+
export function getInsertedInlineRevealColors(colors, isActive, hideAddedDiffsUnderline) {
|
|
697
|
+
return {
|
|
698
|
+
background: isActive ? bgSubtlerPressed(colors.insertActiveColor) : bgSubtlest(colors.insertColor),
|
|
699
|
+
border: hideAddedDiffsUnderline ? 'transparent' : borderAccent(colors.insertColor)
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* The colours `buildDeletedInlineContentStyleExtended()` paints, for the reveal to animate towards.
|
|
705
|
+
* Deleted content's highlight does not vary with the active state — only its text does, which the
|
|
706
|
+
* reveal keeps as-is.
|
|
707
|
+
*/
|
|
708
|
+
export function getDeletedInlineRevealColors(colors) {
|
|
709
|
+
return {
|
|
710
|
+
background: bgSubtlest(colors.deleteColor),
|
|
711
|
+
border: borderAccent(colors.deleteColor)
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
|
|
685
715
|
/** The three visual states deleted inline content can be in. */
|
|
686
716
|
|
|
687
717
|
/**
|
|
@@ -3,12 +3,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
6
|
+
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
7
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
8
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
9
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
9
10
|
import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
|
|
10
11
|
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
11
12
|
import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
13
|
+
import { createContributorTagWidget } from './createContributorTagWidget';
|
|
12
14
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
13
15
|
import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
|
|
14
16
|
var displayNoneStyle = convertToInlineCss({
|
|
@@ -24,6 +26,29 @@ var UNSTYLED_NODES = ['mediaSingle', 'mediaGroup', 'table',
|
|
|
24
26
|
'heading', 'hardBreak', 'decisionList', 'taskList', 'bulletList', 'orderedList', 'layoutSection'];
|
|
25
27
|
var CELL_NODES = ['tableCell', 'tableHeader'];
|
|
26
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Block nodes that host a contributor tag of their own — those whose whole box reads as one change.
|
|
31
|
+
* Lists and tables are excluded: they decorate per item and per cell, with no one-tag-per-block
|
|
32
|
+
* design yet. `blockCard` covers the datasource variant, which is the same node type.
|
|
33
|
+
*/
|
|
34
|
+
var TAGGABLE_BLOCK_NODES = new Set(['blockCard', 'blockquote', 'bodiedExtension', 'codeBlock', 'embedCard', 'expand', 'extension', 'media', 'multiBodiedExtension', 'panel', 'rule']);
|
|
35
|
+
|
|
36
|
+
/** Panels, rules and media can also sit in a table cell, which is out of scope for block tags. */
|
|
37
|
+
var isInsideTable = function isInsideTable(doc, pos) {
|
|
38
|
+
return findParentNodeClosestToPos(doc.resolve(pos), function (node) {
|
|
39
|
+
return node.type.name === 'table';
|
|
40
|
+
}) !== undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Whether this block can host a contributor tag of its own. */
|
|
44
|
+
var canTagBlock = function canTagBlock(_ref) {
|
|
45
|
+
var diffType = _ref.diffType,
|
|
46
|
+
doc = _ref.doc,
|
|
47
|
+
from = _ref.from,
|
|
48
|
+
name = _ref.name;
|
|
49
|
+
return doc !== undefined && isExtendedEnabled(diffType) && TAGGABLE_BLOCK_NODES.has(name) && !isInsideTable(doc, from);
|
|
50
|
+
};
|
|
51
|
+
|
|
27
52
|
/** Positioning context for the cell overlay widget decorations. */
|
|
28
53
|
var cellPositionStyle = convertToInlineCss({
|
|
29
54
|
position: 'relative'
|
|
@@ -70,14 +95,14 @@ var getNodeClass = function getNodeClass(name) {
|
|
|
70
95
|
return undefined;
|
|
71
96
|
}
|
|
72
97
|
};
|
|
73
|
-
var getBlockNodeStyleNext = function getBlockNodeStyleNext(
|
|
74
|
-
var nodeName =
|
|
75
|
-
colorScheme =
|
|
76
|
-
|
|
77
|
-
isInserted =
|
|
78
|
-
|
|
79
|
-
isActive =
|
|
80
|
-
diffType =
|
|
98
|
+
var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref2) {
|
|
99
|
+
var nodeName = _ref2.nodeName,
|
|
100
|
+
colorScheme = _ref2.colorScheme,
|
|
101
|
+
_ref2$isInserted = _ref2.isInserted,
|
|
102
|
+
isInserted = _ref2$isInserted === void 0 ? true : _ref2$isInserted,
|
|
103
|
+
_ref2$isActive = _ref2.isActive,
|
|
104
|
+
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive,
|
|
105
|
+
diffType = _ref2.diffType;
|
|
81
106
|
if (UNSTYLED_NODES.includes(nodeName)) {
|
|
82
107
|
return undefined;
|
|
83
108
|
}
|
|
@@ -139,21 +164,33 @@ var isCellEmpty = function isCellEmpty(cellNode) {
|
|
|
139
164
|
* @param isActive Whether this node is part of the currently active/focused change
|
|
140
165
|
* @returns Prosemirror node decoration or undefined
|
|
141
166
|
*/
|
|
142
|
-
export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
isInserted =
|
|
147
|
-
|
|
148
|
-
isActive =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
export var createBlockChangedDecoration = function createBlockChangedDecoration(_ref3) {
|
|
168
|
+
var attributionKey = _ref3.attributionKey,
|
|
169
|
+
change = _ref3.change,
|
|
170
|
+
colorScheme = _ref3.colorScheme,
|
|
171
|
+
_ref3$isInserted = _ref3.isInserted,
|
|
172
|
+
isInserted = _ref3$isInserted === void 0 ? true : _ref3$isInserted,
|
|
173
|
+
_ref3$isActive = _ref3.isActive,
|
|
174
|
+
isActive = _ref3$isActive === void 0 ? false : _ref3$isActive,
|
|
175
|
+
_ref3$shouldHideDelet = _ref3.shouldHideDeleted,
|
|
176
|
+
shouldHideDeleted = _ref3$shouldHideDelet === void 0 ? false : _ref3$shouldHideDelet,
|
|
177
|
+
_ref3$showContributor = _ref3.showContributorTags,
|
|
178
|
+
showContributorTags = _ref3$showContributor === void 0 ? false : _ref3$showContributor,
|
|
179
|
+
_ref3$showIndicators = _ref3.showIndicators,
|
|
180
|
+
showIndicators = _ref3$showIndicators === void 0 ? false : _ref3$showIndicators,
|
|
181
|
+
doc = _ref3.doc,
|
|
182
|
+
diffType = _ref3.diffType,
|
|
183
|
+
tagMountContext = _ref3.tagMountContext;
|
|
155
184
|
var decorations = [];
|
|
156
|
-
|
|
185
|
+
// Derived from the node range so it survives a recalculation, as in
|
|
186
|
+
// `createInlineChangedDecoration`. Changes are disjoint, so no two of them decorate one node.
|
|
187
|
+
var diffId = showContributorTags ? "block-".concat(change.from, "-").concat(change.to) : crypto.randomUUID();
|
|
188
|
+
var shouldTagBlock = showContributorTags && canTagBlock({
|
|
189
|
+
diffType: diffType,
|
|
190
|
+
doc: doc,
|
|
191
|
+
from: change.from,
|
|
192
|
+
name: change.name
|
|
193
|
+
});
|
|
157
194
|
if (shouldHideDeleted) {
|
|
158
195
|
return [Decoration.node(change.from, change.to, {
|
|
159
196
|
style: displayNoneStyle
|
|
@@ -199,19 +236,27 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
199
236
|
});
|
|
200
237
|
var className = getNodeClass(change.name);
|
|
201
238
|
if (style || className) {
|
|
202
|
-
decorations.push(Decoration.node(change.from, change.to, {
|
|
239
|
+
decorations.push(Decoration.node(change.from, change.to, _objectSpread({
|
|
203
240
|
style: style,
|
|
204
241
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
205
242
|
class: className
|
|
206
|
-
},
|
|
243
|
+
}, shouldTagBlock && {
|
|
244
|
+
'data-diff-id': diffId
|
|
245
|
+
}), buildDiffDecorationSpec({
|
|
246
|
+
attributionKey: shouldTagBlock ? attributionKey : undefined,
|
|
247
|
+
colorScheme: colorScheme,
|
|
207
248
|
decorationType: 'block',
|
|
208
249
|
diffId: diffId,
|
|
209
250
|
isActive: isActive,
|
|
251
|
+
isInserted: isInserted,
|
|
210
252
|
nodeName: change.name,
|
|
211
253
|
diffType: diffType
|
|
212
254
|
})));
|
|
213
255
|
}
|
|
214
|
-
if (decorations.length
|
|
256
|
+
if (decorations.length === 0) {
|
|
257
|
+
return decorations;
|
|
258
|
+
}
|
|
259
|
+
if (showIndicators && doc && isExtendedEnabled(diffType)) {
|
|
215
260
|
decorations.push.apply(decorations, _toConsumableArray(createBlockIndicatorAnchorWidgets({
|
|
216
261
|
doc: doc,
|
|
217
262
|
from: change.from,
|
|
@@ -219,5 +264,22 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
219
264
|
diffId: diffId
|
|
220
265
|
})));
|
|
221
266
|
}
|
|
267
|
+
|
|
268
|
+
// `change.from` is just before the node, so the host sits outside it and the tag renders on the
|
|
269
|
+
// block's own top-left corner. Resolving inline content instead would put the host inside a
|
|
270
|
+
// container block's content DOM (panel, expand, blockquote).
|
|
271
|
+
if (shouldTagBlock && doc) {
|
|
272
|
+
var tagWidget = createContributorTagWidget({
|
|
273
|
+
anchorAtRangeStart: true,
|
|
274
|
+
doc: doc,
|
|
275
|
+
from: change.from,
|
|
276
|
+
to: change.to,
|
|
277
|
+
diffId: diffId,
|
|
278
|
+
mountContext: tagMountContext
|
|
279
|
+
});
|
|
280
|
+
if (tagWidget) {
|
|
281
|
+
decorations.push(tagWidget);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
222
284
|
return decorations;
|
|
223
285
|
};
|
|
@@ -105,14 +105,34 @@ var resolveInlineContentStart = function resolveInlineContentStart(doc, from, to
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
108
|
+
* The position just before the code block enclosing `pos`, or `undefined` when nothing does.
|
|
109
|
+
*
|
|
110
|
+
* `.code-block-content-wrapper` hides its block-axis overflow, so a host left inside the code has
|
|
111
|
+
* its tag clipped away. Hosting it before the block puts the tag on the block's top-left corner,
|
|
112
|
+
* where a whole-code-block change is tagged too (EDITOR-8766).
|
|
113
|
+
*/
|
|
114
|
+
var resolveCodeBlockStart = function resolveCodeBlockStart(doc, pos) {
|
|
115
|
+
var $pos = doc.resolve(pos);
|
|
116
|
+
for (var depth = $pos.depth; depth > 0; depth--) {
|
|
117
|
+
if ($pos.node(depth).type.name === 'codeBlock') {
|
|
118
|
+
return $pos.before(depth);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A widget hosting the contributor tag of one diff range, placed on the first character the range
|
|
126
|
+
* highlights — or, with `anchorAtRangeStart`, at `from` itself. Either way a host that would land
|
|
127
|
+
* inside a code block is hoisted out in front of it; see `resolveCodeBlockStart`.
|
|
110
128
|
*
|
|
111
129
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
112
130
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
113
131
|
*/
|
|
114
132
|
export var createContributorTagWidget = function createContributorTagWidget(_ref2) {
|
|
115
|
-
var
|
|
133
|
+
var _ref2$anchorAtRangeSt = _ref2.anchorAtRangeStart,
|
|
134
|
+
anchorAtRangeStart = _ref2$anchorAtRangeSt === void 0 ? false : _ref2$anchorAtRangeSt,
|
|
135
|
+
doc = _ref2.doc,
|
|
116
136
|
from = _ref2.from,
|
|
117
137
|
to = _ref2.to,
|
|
118
138
|
diffId = _ref2.diffId,
|
|
@@ -124,9 +144,12 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
124
144
|
// Reassigned when ProseMirror redraws this decoration, which it may do more than once for the
|
|
125
145
|
// same `Decoration` instance.
|
|
126
146
|
var mount;
|
|
147
|
+
var anchorPos = anchorAtRangeStart ? from : resolveInlineContentStart(doc, from, to);
|
|
148
|
+
// A change inside a code block is hoisted out of it; anything else keeps its own anchor.
|
|
149
|
+
var codeBlockPos = resolveCodeBlockStart(doc, anchorPos);
|
|
127
150
|
return Decoration.widget(
|
|
128
151
|
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
129
|
-
clampAnchorPosIntoCell(doc,
|
|
152
|
+
clampAnchorPosIntoCell(doc, codeBlockPos !== null && codeBlockPos !== void 0 ? codeBlockPos : anchorPos, 1), function () {
|
|
130
153
|
var host = buildContributorTagHost(diffId);
|
|
131
154
|
mount = mountContributorTag({
|
|
132
155
|
diffId: diffId,
|