@atlaskit/editor-plugin-show-diff 14.3.2 → 14.4.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 +30 -0
- package/afm-cc/tsconfig.json +18 -0
- package/afm-products/tsconfig.json +18 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +47 -26
- package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +61 -9
- package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +77 -20
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +10 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +2 -0
- package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +52 -7
- package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +172 -0
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +37 -5
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +40 -7
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +31 -5
- package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +128 -0
- package/dist/cjs/pm-plugins/main.js +57 -6
- package/dist/cjs/pm-plugins/resolveDiffContributors.js +143 -0
- package/dist/cjs/showDiffPlugin.js +21 -6
- package/dist/cjs/ui/ContributorTag/ContributorTag.compiled.css +29 -0
- package/dist/cjs/ui/ContributorTag/ContributorTag.js +383 -0
- package/dist/cjs/ui/ContributorTag/ContributorTagWidget.js +50 -0
- package/dist/cjs/ui/ContributorTag/messages.js +24 -0
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +48 -27
- package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +39 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +53 -11
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +9 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +2 -0
- package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +43 -1
- package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +163 -0
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +38 -5
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +38 -6
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +30 -2
- package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +101 -0
- package/dist/es2019/pm-plugins/main.js +52 -3
- package/dist/es2019/pm-plugins/resolveDiffContributors.js +128 -0
- package/dist/es2019/showDiffPlugin.js +20 -5
- package/dist/es2019/ui/ContributorTag/ContributorTag.compiled.css +29 -0
- package/dist/es2019/ui/ContributorTag/ContributorTag.js +312 -0
- package/dist/es2019/ui/ContributorTag/ContributorTagWidget.js +43 -0
- package/dist/es2019/ui/ContributorTag/messages.js +18 -0
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +49 -28
- package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +60 -8
- package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +77 -19
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +9 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +2 -0
- package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +51 -6
- package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +166 -0
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +37 -5
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +40 -7
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +30 -5
- package/dist/esm/pm-plugins/decorations/extractContributorTags.js +122 -0
- package/dist/esm/pm-plugins/main.js +57 -6
- package/dist/esm/pm-plugins/resolveDiffContributors.js +137 -0
- package/dist/esm/showDiffPlugin.js +21 -6
- package/dist/esm/ui/ContributorTag/ContributorTag.compiled.css +29 -0
- package/dist/esm/ui/ContributorTag/ContributorTag.js +375 -0
- package/dist/esm/ui/ContributorTag/ContributorTagWidget.js +43 -0
- package/dist/esm/ui/ContributorTag/messages.js +18 -0
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +7 -1
- package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +10 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +24 -2
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +7 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +1 -2
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createAnchorDecorationWidgets.d.ts +14 -0
- package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +55 -0
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +5 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -1
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +28 -3
- package/dist/types/pm-plugins/decorations/extractContributorTags.d.ts +9 -0
- package/dist/types/pm-plugins/main.d.ts +8 -2
- package/dist/types/pm-plugins/resolveDiffContributors.d.ts +7 -0
- package/dist/types/showDiffPluginType.d.ts +65 -2
- package/dist/types/ui/ContributorTag/ContributorTag.d.ts +37 -0
- package/dist/types/ui/ContributorTag/ContributorTagWidget.d.ts +22 -0
- package/dist/types/ui/ContributorTag/messages.d.ts +6 -0
- package/package.json +17 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 14.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 14.4.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 14.4.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`844f6fce7d9c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/844f6fce7d9c4) -
|
|
20
|
+
Render the diff contributor tag from its own widget decoration instead of positioning an overlay
|
|
21
|
+
with CSS anchor positioning, and declare react-dom as a peer dependency for the portal into that
|
|
22
|
+
widget. Behind the confluence_ncs_step_diffing_version_history gate.
|
|
23
|
+
- [`844f6fce7d9c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/844f6fce7d9c4) -
|
|
24
|
+
[ux] Attributed diff changes now render a contributor tag naming who made the change, tinted to
|
|
25
|
+
match the change's attribution colour, behind the `confluence_ncs_step_diffing_version_history`
|
|
26
|
+
gate. Adds an optional `contributorProfiles` list to the attributed `showDiff` params, from which
|
|
27
|
+
the plugin resolves the contributors it credits.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
|
|
3
33
|
## 14.3.2
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
{
|
|
21
21
|
"path": "../../adf-schema/afm-cc/tsconfig.json"
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../../design-system/avatar/afm-cc/tsconfig.json"
|
|
25
|
+
},
|
|
23
26
|
{
|
|
24
27
|
"path": "../../custom-steps/afm-cc/tsconfig.json"
|
|
25
28
|
},
|
|
@@ -38,18 +41,33 @@
|
|
|
38
41
|
{
|
|
39
42
|
"path": "../../editor-tables/afm-cc/tsconfig.json"
|
|
40
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../../design-system/icon-lab/afm-cc/tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../design-system/logo/afm-cc/tsconfig.json"
|
|
49
|
+
},
|
|
41
50
|
{
|
|
42
51
|
"path": "../../../platform/feature-experiments/afm-cc/tsconfig.json"
|
|
43
52
|
},
|
|
44
53
|
{
|
|
45
54
|
"path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
|
|
46
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"path": "../../../design-system/primitives/afm-cc/tsconfig.json"
|
|
58
|
+
},
|
|
47
59
|
{
|
|
48
60
|
"path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
|
|
49
61
|
},
|
|
50
62
|
{
|
|
51
63
|
"path": "../../../design-system/tokens/afm-cc/tsconfig.json"
|
|
52
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"path": "../../../design-system/tooltip/afm-cc/tsconfig.json"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"path": "../../../design-system/visually-hidden/afm-cc/tsconfig.json"
|
|
70
|
+
},
|
|
53
71
|
{
|
|
54
72
|
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
55
73
|
}
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
{
|
|
21
21
|
"path": "../../adf-schema/afm-products/tsconfig.json"
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../../design-system/avatar/afm-products/tsconfig.json"
|
|
25
|
+
},
|
|
23
26
|
{
|
|
24
27
|
"path": "../../custom-steps/afm-products/tsconfig.json"
|
|
25
28
|
},
|
|
@@ -38,18 +41,33 @@
|
|
|
38
41
|
{
|
|
39
42
|
"path": "../../editor-tables/afm-products/tsconfig.json"
|
|
40
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../../design-system/icon-lab/afm-products/tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../design-system/logo/afm-products/tsconfig.json"
|
|
49
|
+
},
|
|
41
50
|
{
|
|
42
51
|
"path": "../../../platform/feature-experiments/afm-products/tsconfig.json"
|
|
43
52
|
},
|
|
44
53
|
{
|
|
45
54
|
"path": "../../../platform/feature-flags/afm-products/tsconfig.json"
|
|
46
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"path": "../../../design-system/primitives/afm-products/tsconfig.json"
|
|
58
|
+
},
|
|
47
59
|
{
|
|
48
60
|
"path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
|
|
49
61
|
},
|
|
50
62
|
{
|
|
51
63
|
"path": "../../../design-system/tokens/afm-products/tsconfig.json"
|
|
52
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"path": "../../../design-system/tooltip/afm-products/tsconfig.json"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"path": "../../../design-system/visually-hidden/afm-products/tsconfig.json"
|
|
70
|
+
},
|
|
53
71
|
{
|
|
54
72
|
"path": "../../editor-common/afm-products/tsconfig.json"
|
|
55
73
|
}
|
|
@@ -24,6 +24,7 @@ var _createInlineChangedDecoration = require("../decorations/createInlineChanged
|
|
|
24
24
|
var _createNodeChangedDecorationWidget = require("../decorations/createNodeChangedDecorationWidget");
|
|
25
25
|
var _attributions = require("../decorations/colorSchemes/attributions");
|
|
26
26
|
var _decorationKeys = require("../decorations/decorationKeys");
|
|
27
|
+
var _extractContributorTags = require("../decorations/extractContributorTags");
|
|
27
28
|
var _getAttrChangeRanges = require("../decorations/utils/getAttrChangeRanges");
|
|
28
29
|
var _getMarkChangeRanges = require("../decorations/utils/getMarkChangeRanges");
|
|
29
30
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
@@ -82,19 +83,12 @@ var getAttributedChanges = function getAttributedChanges(_ref2) {
|
|
|
82
83
|
originalDoc = _ref2.originalDoc,
|
|
83
84
|
steppedDoc = _ref2.steppedDoc,
|
|
84
85
|
diffType = _ref2.diffType,
|
|
85
|
-
tr = _ref2.tr
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
tr = _ref2.tr;
|
|
87
|
+
// `smart` is deliberately absent here, even though `getChanges` applies it: the classifier drops
|
|
88
|
+
// the step attribution and promotes ranges to sentence/paragraph/node granularity, so a promoted
|
|
89
|
+
// range covers several actors' steps and the latest-writer rule credits all of it to one of them.
|
|
90
|
+
// The attributed changeset keeps step granularity instead.
|
|
88
91
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
89
|
-
if (diffType === 'smart' && (0, _fg.fg)('platform_editor_ai_smart_diff')) {
|
|
90
|
-
return (0, _classifySmartChanges.classifySmartChanges)({
|
|
91
|
-
changes: (0, _simplifyChangesWithAttribution.simplifyChangesWithAttribution)(attributedChanges, tr.doc),
|
|
92
|
-
originalDoc: originalDoc,
|
|
93
|
-
newDoc: tr.doc,
|
|
94
|
-
locale: intl.locale,
|
|
95
|
-
thresholds: smartThresholds
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
92
|
if (diffType === 'step') {
|
|
99
93
|
return attributedChanges;
|
|
100
94
|
}
|
|
@@ -277,13 +271,16 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
277
271
|
_ref7$deletedDiffPlac = _ref7.deletedDiffPlacement,
|
|
278
272
|
deletedDiffPlacement = _ref7$deletedDiffPlac === void 0 ? 'top' : _ref7$deletedDiffPlac,
|
|
279
273
|
_ref7$inlineDeletedDi = _ref7.inlineDeletedDiffPlacement,
|
|
280
|
-
inlineDeletedDiffPlacement = _ref7$inlineDeletedDi === void 0 ? 'before' : _ref7$inlineDeletedDi
|
|
274
|
+
inlineDeletedDiffPlacement = _ref7$inlineDeletedDi === void 0 ? 'before' : _ref7$inlineDeletedDi,
|
|
275
|
+
tagMountContext = _ref7.tagMountContext;
|
|
281
276
|
var originalDoc = pluginState.originalDoc,
|
|
282
277
|
steps = pluginState.steps,
|
|
283
278
|
stepAttributions = pluginState.stepAttributions,
|
|
279
|
+
contributors = pluginState.contributors,
|
|
284
280
|
isDisplayingChanges = pluginState.isDisplayingChanges;
|
|
285
281
|
if (!originalDoc || !isDisplayingChanges) {
|
|
286
282
|
return {
|
|
283
|
+
contributorTags: [],
|
|
287
284
|
decorations: _view.DecorationSet.empty,
|
|
288
285
|
diffDescriptors: []
|
|
289
286
|
};
|
|
@@ -295,9 +292,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
295
292
|
var tr = state.tr;
|
|
296
293
|
var steppedDoc = originalDoc;
|
|
297
294
|
var attributionColoringEnabled = (0, _attributions.isAttributionColoringEnabled)(stepAttributions);
|
|
295
|
+
var showContributorTags = (0, _attributions.isContributorTagsEnabled)(stepAttributions, contributors);
|
|
296
|
+
// Tags need the attributed changeset even on diffs with too few actors to be worth colouring.
|
|
297
|
+
var attributedChangesetEnabled = attributionColoringEnabled || showContributorTags;
|
|
298
298
|
var simplifiedSteps;
|
|
299
299
|
var simplifiedStepAttributions = [];
|
|
300
|
-
if (
|
|
300
|
+
if (attributedChangesetEnabled) {
|
|
301
301
|
var simplifiedStepsWithAttribution = (0, _simplifySteps.simplifyStepsWithAttribution)(steps, stepAttributions !== null && stepAttributions !== void 0 ? stepAttributions : [], originalDoc);
|
|
302
302
|
simplifiedSteps = simplifiedStepsWithAttribution.map(function (_ref8) {
|
|
303
303
|
var step = _ref8.step;
|
|
@@ -385,6 +385,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
385
385
|
});
|
|
386
386
|
if (!recoveredViaContentEquality) {
|
|
387
387
|
return {
|
|
388
|
+
contributorTags: [],
|
|
388
389
|
decorations: _view.DecorationSet.empty,
|
|
389
390
|
diffDescriptors: []
|
|
390
391
|
};
|
|
@@ -397,7 +398,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
397
398
|
var changes;
|
|
398
399
|
var attributedChanges = [];
|
|
399
400
|
var attributionColors;
|
|
400
|
-
if (
|
|
401
|
+
if (attributedChangesetEnabled) {
|
|
401
402
|
var changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc, function (left, right) {
|
|
402
403
|
return (0, _attributions.getAttributionKey)(left) === (0, _attributions.getAttributionKey)(right) ? left.stepIndex > right.stepIndex ? left : right :
|
|
403
404
|
// `prosemirror-changeset` uses null as its incompatible-data sentinel even
|
|
@@ -409,17 +410,22 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
409
410
|
});
|
|
410
411
|
}));
|
|
411
412
|
attributedChanges = (0, _diffBySteps.diffBySteps)(originalDoc, simplifiedSteps, simplifiedStepAttributions);
|
|
412
|
-
|
|
413
|
+
// The attributed pipeline gives no guarantee that its output ranges are disjoint — see
|
|
414
|
+
// `collapseOverlappingChanges`.
|
|
415
|
+
var uncollapsedChanges = getAttributedChanges({
|
|
413
416
|
changeset: changeset,
|
|
414
417
|
originalDoc: originalDoc,
|
|
415
418
|
steppedDoc: steppedDoc,
|
|
416
419
|
diffType: diffType,
|
|
417
420
|
tr: tr,
|
|
418
|
-
attributedChanges: attributedChanges
|
|
419
|
-
intl: intl,
|
|
420
|
-
smartThresholds: smartThresholds
|
|
421
|
+
attributedChanges: attributedChanges
|
|
421
422
|
});
|
|
422
|
-
|
|
423
|
+
changes = (0, _simplifyChangesWithAttribution.collapseOverlappingChanges)(uncollapsedChanges);
|
|
424
|
+
|
|
425
|
+
// Still colours-only: a tags-only diff keeps the plain colour scheme.
|
|
426
|
+
if (attributionColoringEnabled) {
|
|
427
|
+
attributionColors = (0, _attributions.createAttributionColorMap)(simplifiedStepAttributions);
|
|
428
|
+
}
|
|
423
429
|
} else {
|
|
424
430
|
var _changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc, undefined, tokenEncoder).addSteps(steppedDoc, stepMaps, tr.doc);
|
|
425
431
|
changes = getChanges({
|
|
@@ -446,6 +452,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
446
452
|
var isInserted = !isInverted;
|
|
447
453
|
var createDecorationsForChange = function createDecorationsForChange(change) {
|
|
448
454
|
var changeColorScheme = attributionColors ? (0, _attributions.getColorSchemeForChange)(change, attributedChanges, attributionColors, colorScheme) : colorScheme;
|
|
455
|
+
var attributionKey = showContributorTags ? (0, _attributions.getAttributionKeyForChange)(change, attributedChanges) : undefined;
|
|
449
456
|
var isActive = isRangeActive(activeIndexPos, change.fromB, change.toB);
|
|
450
457
|
|
|
451
458
|
// The deleted side of a mark-only change is a byte-identical copy of the new text, so it is
|
|
@@ -505,6 +512,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
505
512
|
continue;
|
|
506
513
|
}
|
|
507
514
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
|
|
515
|
+
attributionKey: attributionKey,
|
|
508
516
|
change: {
|
|
509
517
|
fromB: from,
|
|
510
518
|
toB: to
|
|
@@ -516,10 +524,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
516
524
|
}, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
|
|
517
525
|
isInserted: isInserted,
|
|
518
526
|
shouldHideDeleted: shouldHideDeleted,
|
|
527
|
+
showContributorTags: showContributorTags,
|
|
519
528
|
showIndicators: showIndicators,
|
|
520
529
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
521
530
|
hasDeletedWidget: willRenderDeletedWidget,
|
|
522
|
-
isDeletedWidgetBelow: isDeletedWidgetBelow
|
|
531
|
+
isDeletedWidgetBelow: isDeletedWidgetBelow,
|
|
532
|
+
tagMountContext: tagMountContext
|
|
523
533
|
}))));
|
|
524
534
|
}
|
|
525
535
|
} catch (err) {
|
|
@@ -529,6 +539,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
529
539
|
}
|
|
530
540
|
} else {
|
|
531
541
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
|
|
542
|
+
attributionKey: attributionKey,
|
|
532
543
|
change: change,
|
|
533
544
|
doc: tr.doc,
|
|
534
545
|
colorScheme: changeColorScheme,
|
|
@@ -537,10 +548,12 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
537
548
|
}, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
|
|
538
549
|
isInserted: isInserted,
|
|
539
550
|
shouldHideDeleted: shouldHideDeleted,
|
|
551
|
+
showContributorTags: showContributorTags,
|
|
540
552
|
showIndicators: showIndicators,
|
|
541
553
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
542
554
|
hasDeletedWidget: willRenderDeletedWidget,
|
|
543
|
-
isDeletedWidgetBelow: isDeletedWidgetBelow
|
|
555
|
+
isDeletedWidgetBelow: isDeletedWidgetBelow,
|
|
556
|
+
tagMountContext: tagMountContext
|
|
544
557
|
}))));
|
|
545
558
|
}
|
|
546
559
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
|
|
@@ -563,13 +576,17 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
563
576
|
var _shouldHideDeleted = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? !isInverted && hideDeletedDiffs && change.inserted.length > 0 : false;
|
|
564
577
|
if (!_shouldHideDeleted) {
|
|
565
578
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread(_objectSpread({
|
|
579
|
+
// The deleted side has no inline decoration, so the widget carries the actor.
|
|
580
|
+
attributionKey: attributionKey,
|
|
566
581
|
change: change,
|
|
567
582
|
doc: originalDoc,
|
|
568
583
|
nodeViewSerializer: nodeViewSerializer,
|
|
569
584
|
colorScheme: changeColorScheme,
|
|
570
585
|
newDoc: tr.doc,
|
|
571
586
|
intl: intl,
|
|
572
|
-
activeIndexPos: activeIndexPos
|
|
587
|
+
activeIndexPos: activeIndexPos,
|
|
588
|
+
showContributorTags: showContributorTags,
|
|
589
|
+
tagMountContext: tagMountContext
|
|
573
590
|
}, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
|
|
574
591
|
isInserted: !isInserted,
|
|
575
592
|
diffType: diffType,
|
|
@@ -688,12 +705,14 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref7
|
|
|
688
705
|
});
|
|
689
706
|
var decorationSet = _view.DecorationSet.empty.add(tr.doc, decorations);
|
|
690
707
|
return {
|
|
708
|
+
contributorTags: showContributorTags ? (0, _extractContributorTags.extractContributorTags)(decorationSet, contributors) : [],
|
|
691
709
|
decorations: decorationSet,
|
|
692
710
|
diffDescriptors: (0, _decorationKeys.extractDiffDescriptors)(decorationSet)
|
|
693
711
|
};
|
|
694
712
|
};
|
|
695
713
|
var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
|
|
696
|
-
// Cache results unless relevant inputs change
|
|
714
|
+
// Cache results unless relevant inputs change. `tagMountContext` is deliberately absent: it is
|
|
715
|
+
// built once per plugin instance, so it can never be the reason a diff needs recalculating.
|
|
697
716
|
function (_ref11, _ref12) {
|
|
698
717
|
var _ref16;
|
|
699
718
|
var _ref13 = (0, _slicedToArray2.default)(_ref11, 1),
|
|
@@ -729,7 +748,9 @@ function (_ref11, _ref12) {
|
|
|
729
748
|
var originalDocIsSame = lastPluginState.originalDoc && pluginState.originalDoc && pluginState.originalDoc.eq(lastPluginState.originalDoc);
|
|
730
749
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
731
750
|
var _ref15;
|
|
732
|
-
return (_ref15 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) &&
|
|
751
|
+
return (_ref15 = colorScheme === lastColorScheme && intl.locale === lastIntl.locale && isInverted === lastIsInverted && diffType === lastDiffType && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) &&
|
|
752
|
+
// Contributors can arrive after the first calculation; without this, tags never appear.
|
|
753
|
+
(0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && hideDeletedDiffs === lastHideDeletedDiffs && hideAddedDiffsUnderline === lastHideAddedDiffsUnderline && showIndicators === lastShowIndicators && (0, _isEqual.default)(smartThresholds, lastSmartThresholds) && deletedDiffPlacement === lastDeletedDiffPlacement && inlineDeletedDiffPlacement === lastInlineDeletedDiffPlacement) !== null && _ref15 !== void 0 ? _ref15 : false;
|
|
733
754
|
}
|
|
734
|
-
return (_ref16 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref16 !== void 0 ? _ref16 : false;
|
|
755
|
+
return (_ref16 = originalDocIsSame && (0, _isEqual.default)(pluginState.steps, lastPluginState.steps) && (0, _isEqual.default)(pluginState.stepAttributions, lastPluginState.stepAttributions) && (0, _isEqual.default)(pluginState.contributors, lastPluginState.contributors) && state.doc.eq(lastState.doc) && colorScheme === lastColorScheme && intl.locale === lastIntl.locale && (0, _isEqual.default)(activeIndexPos, lastActiveIndexPos) && hideDeletedDiffs === lastHideDeletedDiffs) !== null && _ref16 !== void 0 ? _ref16 : false;
|
|
735
756
|
});
|
|
@@ -4,17 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.simplifyChangesWithAttribution = void 0;
|
|
7
|
+
exports.simplifyChangesWithAttribution = exports.collapseOverlappingChanges = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _prosemirrorChangeset = require("prosemirror-changeset");
|
|
11
11
|
var _attributions = require("../decorations/colorSchemes/attributions");
|
|
12
12
|
var _optimizeChanges = require("./optimizeChanges");
|
|
13
|
+
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; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
15
|
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; } } }; }
|
|
14
16
|
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; } }
|
|
15
17
|
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; }
|
|
16
|
-
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; }
|
|
17
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
18
|
var getAttributionIdentity = function getAttributionIdentity(change) {
|
|
19
19
|
var identities = new Set();
|
|
20
20
|
for (var _i = 0, _arr = [].concat((0, _toConsumableArray2.default)(change.deleted), (0, _toConsumableArray2.default)(change.inserted)); _i < _arr.length; _i++) {
|
|
@@ -32,6 +32,58 @@ var getAttributionIdentity = function getAttributionIdentity(change) {
|
|
|
32
32
|
mergeable: true
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
+
var byNewDocRange = function byNewDocRange(left, right) {
|
|
36
|
+
return left.fromB - right.fromB || left.toB - right.toB;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Collapses changes whose new-document ranges strictly overlap. Attribution runs are simplified
|
|
41
|
+
* independently, so runs either side of an unattributed step can come back covering the same
|
|
42
|
+
* characters — which stacks two inline decorations and renders one contributor tag per copy.
|
|
43
|
+
*
|
|
44
|
+
* Merging keeps every span from both sides, so the latest-writer rule still decides whose tag is
|
|
45
|
+
* shown. Ranges that merely touch are left alone, so an unattributed edit next to an attributed one
|
|
46
|
+
* is not credited to it.
|
|
47
|
+
*/
|
|
48
|
+
var collapseOverlappingChanges = exports.collapseOverlappingChanges = function collapseOverlappingChanges(changes) {
|
|
49
|
+
if (changes.length <= 1) {
|
|
50
|
+
return changes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// A zero-length new-document range paints no inline decoration, so it is kept aside rather than
|
|
54
|
+
// folded into a neighbouring insertion.
|
|
55
|
+
var emptyRanges = changes.filter(function (change) {
|
|
56
|
+
return change.toB <= change.fromB;
|
|
57
|
+
});
|
|
58
|
+
var collapsed = [];
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(changes.filter(function (change) {
|
|
60
|
+
return change.toB > change.fromB;
|
|
61
|
+
}).sort(byNewDocRange)),
|
|
62
|
+
_step;
|
|
63
|
+
try {
|
|
64
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
65
|
+
var change = _step.value;
|
|
66
|
+
var current = collapsed[collapsed.length - 1];
|
|
67
|
+
if (current && change.fromB < current.toB) {
|
|
68
|
+
collapsed[collapsed.length - 1] = {
|
|
69
|
+
fromA: Math.min(current.fromA, change.fromA),
|
|
70
|
+
toA: Math.max(current.toA, change.toA),
|
|
71
|
+
fromB: Math.min(current.fromB, change.fromB),
|
|
72
|
+
toB: Math.max(current.toB, change.toB),
|
|
73
|
+
deleted: [].concat((0, _toConsumableArray2.default)(current.deleted), (0, _toConsumableArray2.default)(change.deleted)),
|
|
74
|
+
inserted: [].concat((0, _toConsumableArray2.default)(current.inserted), (0, _toConsumableArray2.default)(change.inserted))
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
collapsed.push(_objectSpread({}, change));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_iterator.e(err);
|
|
82
|
+
} finally {
|
|
83
|
+
_iterator.f();
|
|
84
|
+
}
|
|
85
|
+
return [].concat(collapsed, (0, _toConsumableArray2.default)(emptyRanges)).sort(byNewDocRange);
|
|
86
|
+
};
|
|
35
87
|
|
|
36
88
|
/**
|
|
37
89
|
* Simplifies and optimizes consecutive changes without crossing an attribution boundary.
|
|
@@ -62,12 +114,12 @@ var simplifyChangesWithAttribution = exports.simplifyChangesWithAttribution = fu
|
|
|
62
114
|
run = [];
|
|
63
115
|
runIdentity = undefined;
|
|
64
116
|
};
|
|
65
|
-
var
|
|
66
|
-
|
|
117
|
+
var _iterator2 = _createForOfIteratorHelper(changes),
|
|
118
|
+
_step2;
|
|
67
119
|
try {
|
|
68
|
-
for (
|
|
120
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
69
121
|
var _runIdentity;
|
|
70
|
-
var change =
|
|
122
|
+
var change = _step2.value;
|
|
71
123
|
var identity = getAttributionIdentity(change);
|
|
72
124
|
var canJoinRun = ((_runIdentity = runIdentity) === null || _runIdentity === void 0 ? void 0 : _runIdentity.mergeable) === true && identity.mergeable && runIdentity.key === identity.key;
|
|
73
125
|
if (run.length > 0 && !canJoinRun) {
|
|
@@ -80,9 +132,9 @@ var simplifyChangesWithAttribution = exports.simplifyChangesWithAttribution = fu
|
|
|
80
132
|
}
|
|
81
133
|
}
|
|
82
134
|
} catch (err) {
|
|
83
|
-
|
|
135
|
+
_iterator2.e(err);
|
|
84
136
|
} finally {
|
|
85
|
-
|
|
137
|
+
_iterator2.f();
|
|
86
138
|
}
|
|
87
139
|
flush();
|
|
88
140
|
return result;
|
|
@@ -4,16 +4,25 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.isAttributionColoringEnabled = exports.getColorSchemeForChange = exports.getAttributionKey = exports.createAttributionColorMap = exports.areAttributionColorGatesEnabled = void 0;
|
|
7
|
+
exports.resolveContributors = exports.isContributorTagsEnabled = exports.isAttributionColoringEnabled = exports.getColorSchemeForChange = exports.getAttributionKeyForChange = exports.getAttributionKey = exports.createAttributionColorMap = exports.areAttributionColorGatesEnabled = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
12
|
var _utils = require("@atlaskit/editor-shared-styles/utils");
|
|
11
13
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
12
14
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
13
15
|
var _types = require("./types");
|
|
16
|
+
var _excluded = ["attribution", "connectedTo"];
|
|
17
|
+
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; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
19
|
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; } } }; }
|
|
15
20
|
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; } }
|
|
16
21
|
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; }
|
|
22
|
+
/** A contributor with both of its identities collapsed to internal attribution keys. */
|
|
23
|
+
|
|
24
|
+
/** Contributors addressed by attribution key. The key format is internal. */
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Normalise the attribution identity once so a valid lookup key always has a valid participant
|
|
19
28
|
* colour seed. `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared
|
|
@@ -48,6 +57,40 @@ var getAttributionKey = exports.getAttributionKey = function getAttributionKey(a
|
|
|
48
57
|
var _getAttributionIdenti;
|
|
49
58
|
return (_getAttributionIdenti = getAttributionIdentity(attribution)) === null || _getAttributionIdenti === void 0 ? void 0 : _getAttributionIdenti.key;
|
|
50
59
|
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Public contributor list to internal key-addressed record. A contributor whose attribution carries
|
|
63
|
+
* no identity is dropped, since it could never match a step. Later entries win.
|
|
64
|
+
*/
|
|
65
|
+
var resolveContributors = exports.resolveContributors = function resolveContributors(contributors) {
|
|
66
|
+
if (!(contributors !== null && contributors !== void 0 && contributors.length)) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
var resolved = {};
|
|
70
|
+
var _iterator = _createForOfIteratorHelper(contributors),
|
|
71
|
+
_step;
|
|
72
|
+
try {
|
|
73
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
74
|
+
var _ref = _step.value;
|
|
75
|
+
var attribution = _ref.attribution,
|
|
76
|
+
connectedTo = _ref.connectedTo,
|
|
77
|
+
tagContributor = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
78
|
+
var key = getAttributionKey(attribution);
|
|
79
|
+
if (!key) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
var connectedToKey = connectedTo ? getAttributionKey(connectedTo) : undefined;
|
|
83
|
+
resolved[key] = _objectSpread(_objectSpread({}, tagContributor), connectedToKey ? {
|
|
84
|
+
connectedToKey: connectedToKey
|
|
85
|
+
} : {});
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
_iterator.e(err);
|
|
89
|
+
} finally {
|
|
90
|
+
_iterator.f();
|
|
91
|
+
}
|
|
92
|
+
return Object.keys(resolved).length > 0 ? resolved : undefined;
|
|
93
|
+
};
|
|
51
94
|
var areAttributionColorGatesEnabled = exports.areAttributionColorGatesEnabled = function areAttributionColorGatesEnabled() {
|
|
52
95
|
return (0, _fg.fg)('confluence_ncs_step_diffing_version_history') && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor');
|
|
53
96
|
};
|
|
@@ -60,13 +103,23 @@ var isAttributionColoringEnabled = exports.isAttributionColoringEnabled = functi
|
|
|
60
103
|
}));
|
|
61
104
|
return attributionKeys.size > 1;
|
|
62
105
|
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Shares the colours' gates, but with a lower bar: colouring needs two actors to tell apart, whereas
|
|
109
|
+
* a tag only has to name one.
|
|
110
|
+
*/
|
|
111
|
+
var isContributorTagsEnabled = exports.isContributorTagsEnabled = function isContributorTagsEnabled(stepAttributions, contributors) {
|
|
112
|
+
return areAttributionColorGatesEnabled() && Boolean(stepAttributions === null || stepAttributions === void 0 ? void 0 : stepAttributions.some(function (attribution) {
|
|
113
|
+
return getAttributionKey(attribution) !== undefined;
|
|
114
|
+
})) && contributors !== undefined && Object.keys(contributors).length > 0;
|
|
115
|
+
};
|
|
63
116
|
var createAttributionColorMap = exports.createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
|
|
64
117
|
var colors = new Map();
|
|
65
|
-
var
|
|
66
|
-
|
|
118
|
+
var _iterator2 = _createForOfIteratorHelper(stepAttributions),
|
|
119
|
+
_step2;
|
|
67
120
|
try {
|
|
68
|
-
for (
|
|
69
|
-
var attribution =
|
|
121
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
122
|
+
var attribution = _step2.value;
|
|
70
123
|
var identity = getAttributionIdentity(attribution);
|
|
71
124
|
if (!identity || colors.has(identity.key)) {
|
|
72
125
|
continue;
|
|
@@ -79,9 +132,9 @@ var createAttributionColorMap = exports.createAttributionColorMap = function cre
|
|
|
79
132
|
}
|
|
80
133
|
}
|
|
81
134
|
} catch (err) {
|
|
82
|
-
|
|
135
|
+
_iterator2.e(err);
|
|
83
136
|
} finally {
|
|
84
|
-
|
|
137
|
+
_iterator2.f();
|
|
85
138
|
}
|
|
86
139
|
return colors;
|
|
87
140
|
};
|
|
@@ -105,19 +158,23 @@ var changesOverlap = function changesOverlap(change, attributedChange) {
|
|
|
105
158
|
var deletedOverlap = change.deleted.length > 0 && attributedChange.deleted.length > 0 && rangesOverlap(change.fromA, change.toA, attributedChange.fromA, attributedChange.toA);
|
|
106
159
|
return insertedOverlap || deletedOverlap;
|
|
107
160
|
};
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
161
|
+
var getAttributionKeyForChanges = function getAttributionKeyForChanges(changes) {
|
|
162
|
+
return getAttributionKey(getLatestAttribution(changes));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The attribution key owning a change. Inline and step changes retain direct attribution spans, so
|
|
167
|
+
* resolve those first. Grouped and smart-classified changes can lose that data; for those, fall
|
|
168
|
+
* back to the latest overlapping attributed step.
|
|
169
|
+
*/
|
|
170
|
+
var getAttributionKeyForChange = exports.getAttributionKeyForChange = function getAttributionKeyForChange(change, attributedChanges) {
|
|
171
|
+
var _getAttributionKeyFor;
|
|
172
|
+
return (_getAttributionKeyFor = getAttributionKeyForChanges([change])) !== null && _getAttributionKeyFor !== void 0 ? _getAttributionKeyFor : getAttributionKeyForChanges(attributedChanges.filter(function (attributedChange) {
|
|
173
|
+
return changesOverlap(change, attributedChange);
|
|
174
|
+
}));
|
|
111
175
|
};
|
|
112
176
|
var getColorSchemeForChange = exports.getColorSchemeForChange = function getColorSchemeForChange(change, attributedChanges, attributionColors, fallback) {
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(_ref = (_getParticipantColorS = getParticipantColorSchemeForChanges([change], attributionColors)) !== null && _getParticipantColorS !== void 0 ? _getParticipantColorS :
|
|
117
|
-
// Grouping and smart classification can produce changes without direct attribution data. For
|
|
118
|
-
// those transformed changes, retain the overlap-based lookup as a fallback.
|
|
119
|
-
getParticipantColorSchemeForChanges(attributedChanges.filter(function (attributedChange) {
|
|
120
|
-
return changesOverlap(change, attributedChange);
|
|
121
|
-
}), attributionColors)) !== null && _ref !== void 0 ? _ref : fallback
|
|
122
|
-
);
|
|
177
|
+
var _attributionColors$ge;
|
|
178
|
+
var key = getAttributionKeyForChange(change, attributedChanges);
|
|
179
|
+
return key ? (_attributionColors$ge = attributionColors.get(key)) !== null && _attributionColors$ge !== void 0 ? _attributionColors$ge : fallback : fallback;
|
|
123
180
|
};
|
|
@@ -65,6 +65,7 @@ exports.buildInsertStyleRuleNodeActive = buildInsertStyleRuleNodeActive;
|
|
|
65
65
|
exports.buildInsertStyleRuleNodeNew = buildInsertStyleRuleNodeNew;
|
|
66
66
|
exports.buildInsertedBlockNodeStyle = buildInsertedBlockNodeStyle;
|
|
67
67
|
exports.buildInsertedInlineStyle = buildInsertedInlineStyle;
|
|
68
|
+
exports.getAccentTokens = getAccentTokens;
|
|
68
69
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
69
70
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
70
71
|
var _constants = require("@atlaskit/editor-shared-styles/constants");
|
|
@@ -213,6 +214,15 @@ function textAccent(color) {
|
|
|
213
214
|
return isParticipantColorScheme(color) ? participantColorTokenSets[color].textAccent : textAccentMap[color];
|
|
214
215
|
}
|
|
215
216
|
|
|
217
|
+
/** Presentation tokens for one diff colour, shared by highlights and contributor tags. */
|
|
218
|
+
function getAccentTokens(color) {
|
|
219
|
+
return {
|
|
220
|
+
background: bgSubtlest(color),
|
|
221
|
+
border: borderAccent(color),
|
|
222
|
+
text: textAccent(color)
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
216
226
|
/** Ring colour for an active (scroll-target) deleted block outline. */
|
|
217
227
|
function deletedBlockOutlineActiveRing(colors) {
|
|
218
228
|
return colors.deletedBlockOutlineActiveEmphasis === 'border' ? borderAccent(colors.deleteActiveColor) : bgSubtlerPressed(colors.deleteActiveColor);
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PARTICIPANT_COLOR_SCHEMES = void 0;
|
|
7
|
+
/** Schemes consumers may explicitly request through the show-diff API. */
|
|
8
|
+
|
|
7
9
|
/** Attribution-only participant slots selected by the plugin, never by consumers. */
|
|
8
10
|
var PARTICIPANT_COLOR_SCHEMES = exports.PARTICIPANT_COLOR_SCHEMES = ['red-bolder', 'blue-bolder', 'green-bolder', 'yellow-bolder', 'purple-bolder', 'magenta-bolder', 'teal-bolder', 'orange-bolder', 'lime-bolder', 'gray-bolder', 'blue-subtle', 'red-subtle', 'orange-subtle', 'yellow-subtle', 'green-subtle', 'teal-subtle', 'purple-subtle', 'magenta-subtle'];
|
|
9
11
|
|