@atlaskit/editor-plugin-show-diff 14.3.2 → 14.4.0
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 +18 -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 +16 -7
|
@@ -8,13 +8,33 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
8
8
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
|
|
9
9
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
11
|
+
import { isDiffDecoration, isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
11
12
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
12
13
|
import { getScrollableDecorations } from './getScrollableDecorations';
|
|
13
14
|
import { getDefaultDiffType, isExtendedEnabled } from './isExtendedEnabled';
|
|
14
15
|
import { NodeViewSerializer } from './NodeViewSerializer';
|
|
15
16
|
import { scrollToDecoration } from './scrollToDiff';
|
|
16
17
|
export var showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Tags whose diff decoration survived the transaction. A document change can map a decoration away
|
|
20
|
+
* without any `showDiff`/`hideDiff` following it, and a tag left behind has no host to render into.
|
|
21
|
+
* Returns the given array when every tag is still live.
|
|
22
|
+
*/
|
|
23
|
+
var dropOrphanedContributorTags = function dropOrphanedContributorTags(contributorTags, decorations) {
|
|
24
|
+
if (!(contributorTags !== null && contributorTags !== void 0 && contributorTags.length)) {
|
|
25
|
+
return contributorTags;
|
|
26
|
+
}
|
|
27
|
+
var liveDiffIds = new Set(decorations.find(undefined, undefined, isDiffDecorationSpec).filter(isDiffDecoration).map(function (_ref) {
|
|
28
|
+
var spec = _ref.spec;
|
|
29
|
+
return spec.diffId;
|
|
30
|
+
}));
|
|
31
|
+
var liveTags = contributorTags.filter(function (_ref2) {
|
|
32
|
+
var diffId = _ref2.diffId;
|
|
33
|
+
return liveDiffIds.has(diffId);
|
|
34
|
+
});
|
|
35
|
+
return liveTags.length === contributorTags.length ? contributorTags : liveTags;
|
|
36
|
+
};
|
|
37
|
+
export var createPlugin = function createPlugin(config, getIntl, api, portalProviderAPI, onEditorView) {
|
|
18
38
|
enforceCustomStepRegisters();
|
|
19
39
|
var nodeViewSerializer = new NodeViewSerializer({});
|
|
20
40
|
var setNodeViewSerializer = function setNodeViewSerializer(editorView) {
|
|
@@ -22,6 +42,23 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
22
42
|
editorView: editorView
|
|
23
43
|
});
|
|
24
44
|
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* This editor's own content root. The contributor tags scope every DOM lookup to it, so they take
|
|
48
|
+
* it from the view the plugin was mounted on rather than resolving `.ProseMirror` by class name
|
|
49
|
+
* from a decoration — a class this package does not own, and one whose nearest match is the wrong
|
|
50
|
+
* editor whenever editors are nested. A getter because the view arrives with the ProseMirror view
|
|
51
|
+
* lifecycle, which decorations are calculated independently of.
|
|
52
|
+
*/
|
|
53
|
+
var currentEditorView;
|
|
54
|
+
var tagMountContext = portalProviderAPI ? {
|
|
55
|
+
api: api,
|
|
56
|
+
getEditorRoot: function getEditorRoot() {
|
|
57
|
+
var _currentEditorView$do, _currentEditorView;
|
|
58
|
+
return (_currentEditorView$do = (_currentEditorView = currentEditorView) === null || _currentEditorView === void 0 ? void 0 : _currentEditorView.dom) !== null && _currentEditorView$do !== void 0 ? _currentEditorView$do : null;
|
|
59
|
+
},
|
|
60
|
+
portalProviderAPI: portalProviderAPI
|
|
61
|
+
} : undefined;
|
|
25
62
|
return new SafePlugin({
|
|
26
63
|
key: showDiffPluginKey,
|
|
27
64
|
state: {
|
|
@@ -62,7 +99,8 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
62
99
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
63
100
|
intl: getIntl(),
|
|
64
101
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
65
|
-
api: api
|
|
102
|
+
api: api,
|
|
103
|
+
tagMountContext: tagMountContext
|
|
66
104
|
}, isExtendedEnabled((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
|
|
67
105
|
isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
|
|
68
106
|
diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
|
|
@@ -73,10 +111,12 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
73
111
|
deletedDiffPlacement: (_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.deletedDiffPlacement,
|
|
74
112
|
inlineDeletedDiffPlacement: (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.inlineDeletedDiffPlacement
|
|
75
113
|
} : {})),
|
|
114
|
+
contributorTags = _calculateDiffDecorat.contributorTags,
|
|
76
115
|
decorations = _calculateDiffDecorat.decorations,
|
|
77
116
|
diffDescriptors = _calculateDiffDecorat.diffDescriptors;
|
|
78
117
|
// Update the decorations and their ids
|
|
79
118
|
newPluginState.decorations = decorations;
|
|
119
|
+
newPluginState.contributorTags = contributorTags;
|
|
80
120
|
if (isExtendedEnabled((_newPluginState0 = newPluginState) === null || _newPluginState0 === void 0 ? void 0 : _newPluginState0.diffType)) {
|
|
81
121
|
newPluginState.diffDescriptors = diffDescriptors;
|
|
82
122
|
}
|
|
@@ -84,7 +124,8 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
84
124
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
85
125
|
decorations: DecorationSet.empty,
|
|
86
126
|
isDisplayingChanges: false,
|
|
87
|
-
activeIndex: undefined
|
|
127
|
+
activeIndex: undefined,
|
|
128
|
+
contributorTags: []
|
|
88
129
|
}, isExtendedEnabled(currentPluginState.diffType) ? {
|
|
89
130
|
isInverted: false,
|
|
90
131
|
diffType: getDefaultDiffType(),
|
|
@@ -128,7 +169,8 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
128
169
|
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
129
170
|
intl: getIntl(),
|
|
130
171
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
131
|
-
api: api
|
|
172
|
+
api: api,
|
|
173
|
+
tagMountContext: tagMountContext
|
|
132
174
|
}, isExtendedEnabled(newPluginState.diffType) ? {
|
|
133
175
|
isInverted: newPluginState.isInverted,
|
|
134
176
|
diffType: newPluginState.diffType,
|
|
@@ -139,9 +181,11 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
139
181
|
deletedDiffPlacement: newPluginState.deletedDiffPlacement,
|
|
140
182
|
inlineDeletedDiffPlacement: newPluginState.inlineDeletedDiffPlacement
|
|
141
183
|
} : {})),
|
|
184
|
+
updatedContributorTags = _calculateDiffDecorat2.contributorTags,
|
|
142
185
|
updatedDecorations = _calculateDiffDecorat2.decorations,
|
|
143
186
|
updatedDiffDescriptors = _calculateDiffDecorat2.diffDescriptors;
|
|
144
187
|
newPluginState.decorations = updatedDecorations;
|
|
188
|
+
newPluginState.contributorTags = updatedContributorTags;
|
|
145
189
|
if (isExtendedEnabled(newPluginState.diffType)) {
|
|
146
190
|
newPluginState.diffDescriptors = updatedDiffDescriptors;
|
|
147
191
|
}
|
|
@@ -150,13 +194,19 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
150
194
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), meta);
|
|
151
195
|
}
|
|
152
196
|
}
|
|
153
|
-
|
|
154
|
-
|
|
197
|
+
var mappedDecorations = newPluginState.decorations.map(tr.mapping, tr.doc);
|
|
198
|
+
var nextState = _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
199
|
+
decorations: mappedDecorations
|
|
155
200
|
});
|
|
201
|
+
if (tr.docChanged) {
|
|
202
|
+
nextState.contributorTags = dropOrphanedContributorTags(newPluginState.contributorTags, mappedDecorations);
|
|
203
|
+
}
|
|
204
|
+
return nextState;
|
|
156
205
|
}
|
|
157
206
|
},
|
|
158
207
|
view: function view(editorView) {
|
|
159
208
|
setNodeViewSerializer(editorView);
|
|
209
|
+
currentEditorView = editorView;
|
|
160
210
|
onEditorView === null || onEditorView === void 0 || onEditorView(editorView);
|
|
161
211
|
var isFirst = true;
|
|
162
212
|
var previousActiveIndex;
|
|
@@ -210,6 +260,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
210
260
|
var _cancelPendingScrollT3;
|
|
211
261
|
(_cancelPendingScrollT3 = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT3 === void 0 || _cancelPendingScrollT3();
|
|
212
262
|
cancelPendingScrollToDecoration = null;
|
|
263
|
+
currentEditorView = undefined;
|
|
213
264
|
onEditorView === null || onEditorView === void 0 || onEditorView(undefined);
|
|
214
265
|
}
|
|
215
266
|
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; } } }; }
|
|
5
|
+
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; } }
|
|
6
|
+
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; }
|
|
7
|
+
import { getAttributionKey } from './decorations/colorSchemes/attributions';
|
|
8
|
+
|
|
9
|
+
/** A brand name, so a literal rather than a translated message. */
|
|
10
|
+
var ROVO_AGENT_NAME = 'Rovo';
|
|
11
|
+
|
|
12
|
+
/** `agentType` values that render as "Rovo" rather than as a generic external agent. */
|
|
13
|
+
var ROVO_AGENT_TYPES = new Set(['convo-ai', 'rovo_chat']);
|
|
14
|
+
var hasAgentIdentity = function hasAgentIdentity(attribution) {
|
|
15
|
+
var _attribution$agentId, _attribution$agentTyp;
|
|
16
|
+
return Boolean(((_attribution$agentId = attribution.agentId) === null || _attribution$agentId === void 0 ? void 0 : _attribution$agentId.trim()) || ((_attribution$agentTyp = attribution.agentType) === null || _attribution$agentTyp === void 0 ? void 0 : _attribution$agentTyp.trim()));
|
|
17
|
+
};
|
|
18
|
+
var toProfilesByAccountId = function toProfilesByAccountId(profiles) {
|
|
19
|
+
var profilesByAccountId = new Map();
|
|
20
|
+
profiles === null || profiles === void 0 || profiles.forEach(function (profile) {
|
|
21
|
+
// Trimmed to match how attribution ids are keyed, so the two sides compare like for like.
|
|
22
|
+
var accountId = profile.accountId.trim();
|
|
23
|
+
if (accountId && !profilesByAccountId.has(accountId)) {
|
|
24
|
+
profilesByAccountId.set(accountId, profile);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return profilesByAccountId;
|
|
28
|
+
};
|
|
29
|
+
var resolveUser = function resolveUser(userId, profilesByAccountId) {
|
|
30
|
+
var profile = profilesByAccountId.get(userId);
|
|
31
|
+
return profile ? {
|
|
32
|
+
avatarUrl: profile.avatarUrl,
|
|
33
|
+
kind: 'user',
|
|
34
|
+
name: profile.name
|
|
35
|
+
} : undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** An agent always resolves: its profile, else "Rovo" for a first-party type, else external. */
|
|
39
|
+
var resolveAgent = function resolveAgent(attribution, profilesByAccountId) {
|
|
40
|
+
var _attribution$agentId2, _attribution$agentTyp2;
|
|
41
|
+
var agentId = (_attribution$agentId2 = attribution.agentId) === null || _attribution$agentId2 === void 0 ? void 0 : _attribution$agentId2.trim();
|
|
42
|
+
var agentProfile = agentId ? profilesByAccountId.get(agentId) : undefined;
|
|
43
|
+
if (agentProfile) {
|
|
44
|
+
return {
|
|
45
|
+
agentKind: 'identified',
|
|
46
|
+
avatarUrl: agentProfile.avatarUrl,
|
|
47
|
+
kind: 'agent',
|
|
48
|
+
name: agentProfile.name
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var agentType = (_attribution$agentTyp2 = attribution.agentType) === null || _attribution$agentTyp2 === void 0 ? void 0 : _attribution$agentTyp2.trim().toLowerCase();
|
|
52
|
+
|
|
53
|
+
// An empty name lets the tag fall back to its own localised "External agent" label.
|
|
54
|
+
return agentType && ROVO_AGENT_TYPES.has(agentType) ? {
|
|
55
|
+
agentKind: 'rovo',
|
|
56
|
+
kind: 'agent',
|
|
57
|
+
name: ROVO_AGENT_NAME
|
|
58
|
+
} : {
|
|
59
|
+
agentKind: 'external',
|
|
60
|
+
kind: 'agent',
|
|
61
|
+
name: ''
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* One contributor per distinct actor behind the attributed steps, resolved against the identities
|
|
67
|
+
* the consumer supplied. Returns `undefined` if any actor cannot be named: a half-credited diff
|
|
68
|
+
* reads as "nobody touched this", so the whole list is dropped and the plain diff renders instead.
|
|
69
|
+
*/
|
|
70
|
+
export var resolveDiffContributors = function resolveDiffContributors(stepsWithAttribution, profiles) {
|
|
71
|
+
var profilesByAccountId = toProfilesByAccountId(profiles);
|
|
72
|
+
var contributors = [];
|
|
73
|
+
/** Keyed as the plugin keys changes, so no two entries can collapse onto one another. */
|
|
74
|
+
var creditedActors = new Set();
|
|
75
|
+
var _iterator = _createForOfIteratorHelper(stepsWithAttribution),
|
|
76
|
+
_step;
|
|
77
|
+
try {
|
|
78
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
79
|
+
var _stepAttribution$user;
|
|
80
|
+
var stepAttribution = _step.value.stepAttribution;
|
|
81
|
+
// An attribution naming nobody (e.g. one carrying only `wasOffline`) has nobody to credit.
|
|
82
|
+
var actor = stepAttribution ? getAttributionKey(stepAttribution) : undefined;
|
|
83
|
+
if (!stepAttribution || !actor || creditedActors.has(actor)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
var userId = (_stepAttribution$user = stepAttribution.userId) === null || _stepAttribution$user === void 0 ? void 0 : _stepAttribution$user.trim();
|
|
87
|
+
if (hasAgentIdentity(stepAttribution)) {
|
|
88
|
+
var agent = resolveAgent(stepAttribution, profilesByAccountId);
|
|
89
|
+
if (!userId) {
|
|
90
|
+
// Agent mode: the agent acted on its own, so it is credited on its own.
|
|
91
|
+
contributors.push(_objectSpread(_objectSpread({}, agent), {}, {
|
|
92
|
+
attribution: stepAttribution
|
|
93
|
+
}));
|
|
94
|
+
creditedActors.add(actor);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// User-invoked agent: credit both actors and link the agent back to the invoking user.
|
|
99
|
+
var invokingUser = {
|
|
100
|
+
userId: userId
|
|
101
|
+
};
|
|
102
|
+
var _user = resolveUser(userId, profilesByAccountId);
|
|
103
|
+
if (!_user) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Skipped if the invoking user's own step already credited them.
|
|
108
|
+
var invokingUserActor = getAttributionKey(invokingUser);
|
|
109
|
+
if (invokingUserActor && !creditedActors.has(invokingUserActor)) {
|
|
110
|
+
contributors.push(_objectSpread(_objectSpread({}, _user), {}, {
|
|
111
|
+
attribution: invokingUser
|
|
112
|
+
}));
|
|
113
|
+
creditedActors.add(invokingUserActor);
|
|
114
|
+
}
|
|
115
|
+
contributors.push(_objectSpread(_objectSpread({}, agent), {}, {
|
|
116
|
+
attribution: stepAttribution,
|
|
117
|
+
connectedTo: invokingUser
|
|
118
|
+
}));
|
|
119
|
+
creditedActors.add(actor);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
var user = userId ? resolveUser(userId, profilesByAccountId) : undefined;
|
|
123
|
+
if (!user) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
contributors.push(_objectSpread(_objectSpread({}, user), {}, {
|
|
127
|
+
attribution: stepAttribution
|
|
128
|
+
}));
|
|
129
|
+
creditedActors.add(actor);
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
_iterator.e(err);
|
|
133
|
+
} finally {
|
|
134
|
+
_iterator.f();
|
|
135
|
+
}
|
|
136
|
+
return contributors.length > 0 ? contributors : undefined;
|
|
137
|
+
};
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
var _excluded = ["stepsWithAttribution"];
|
|
3
|
+
var _excluded = ["stepsWithAttribution", "contributorProfiles"];
|
|
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
|
import React from 'react';
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { areAttributionColorGatesEnabled, resolveContributors } from './pm-plugins/decorations/colorSchemes/attributions';
|
|
8
9
|
import { getDeletedWidgets as _getDeletedWidgets } from './pm-plugins/getDeletedWidgets';
|
|
9
10
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
10
11
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
12
|
+
import { resolveDiffContributors } from './pm-plugins/resolveDiffContributors';
|
|
11
13
|
import { IndicatorBarContentComponent } from './ui/IndicatorBar/IndicatorBarContentComponent';
|
|
12
14
|
var normalizeShowDiffParams = function normalizeShowDiffParams(params) {
|
|
13
15
|
if (!params || !('stepsWithAttribution' in params)) {
|
|
16
|
+
// Cleared so a previous attributed diff's contributors cannot leak onto an unattributed one.
|
|
14
17
|
return params ? _objectSpread(_objectSpread({}, params), {}, {
|
|
15
|
-
stepAttributions: []
|
|
18
|
+
stepAttributions: [],
|
|
19
|
+
contributors: undefined
|
|
16
20
|
}) : params;
|
|
17
21
|
}
|
|
18
22
|
var stepsWithAttribution = params.stepsWithAttribution,
|
|
23
|
+
contributorProfiles = params.contributorProfiles,
|
|
19
24
|
rest = _objectWithoutProperties(params, _excluded);
|
|
20
25
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
26
|
+
// Resolved and keyed at the public boundary so both the contributor model and the attribution-key
|
|
27
|
+
// format stay internal.
|
|
28
|
+
contributors: areAttributionColorGatesEnabled() ? resolveContributors(resolveDiffContributors(stepsWithAttribution, contributorProfiles)) : undefined,
|
|
21
29
|
steps: stepsWithAttribution.map(function (_ref) {
|
|
22
30
|
var step = _ref.step;
|
|
23
31
|
return step;
|
|
@@ -70,6 +78,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
|
70
78
|
return tr.setMeta(showDiffPluginKey, {
|
|
71
79
|
steps: [],
|
|
72
80
|
stepAttributions: [],
|
|
81
|
+
contributors: undefined,
|
|
73
82
|
action: 'HIDE_DIFF'
|
|
74
83
|
});
|
|
75
84
|
},
|
|
@@ -89,9 +98,12 @@ export var showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
|
89
98
|
pmPlugins: function pmPlugins() {
|
|
90
99
|
return [{
|
|
91
100
|
name: 'showDiffPlugin',
|
|
101
|
+
// Contributor tags mount into their own decoration widgets through the portal
|
|
102
|
+
// provider, the way the rest of the editor renders React into decorations.
|
|
92
103
|
plugin: function plugin(_ref8) {
|
|
93
|
-
var getIntl = _ref8.getIntl
|
|
94
|
-
|
|
104
|
+
var getIntl = _ref8.getIntl,
|
|
105
|
+
nodeViewPortalProviderAPI = _ref8.nodeViewPortalProviderAPI;
|
|
106
|
+
return createPlugin(config, getIntl, api, nodeViewPortalProviderAPI, setEditorView);
|
|
95
107
|
}
|
|
96
108
|
}];
|
|
97
109
|
},
|
|
@@ -99,9 +111,11 @@ export var showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
|
99
111
|
if (!expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
100
112
|
return null;
|
|
101
113
|
}
|
|
102
|
-
|
|
114
|
+
// Rendered here so it shares the DOM context of the decoration anchor spans. Contributor
|
|
115
|
+
// tags are not: each one mounts into the host element its own decoration draws.
|
|
116
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IndicatorBarContentComponent, {
|
|
103
117
|
api: api
|
|
104
|
-
});
|
|
118
|
+
}));
|
|
105
119
|
},
|
|
106
120
|
getSharedState: function getSharedState(editorState) {
|
|
107
121
|
if (!editorState) {
|
|
@@ -119,6 +133,7 @@ export var showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
|
119
133
|
activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
|
|
120
134
|
numberOfChanges: decorationCount.length
|
|
121
135
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
136
|
+
contributorTags: pluginState === null || pluginState === void 0 ? void 0 : pluginState.contributorTags,
|
|
122
137
|
diffDescriptors: pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffDescriptors,
|
|
123
138
|
showIndicators: pluginState === null || pluginState === void 0 ? void 0 : pluginState.showIndicators
|
|
124
139
|
} : {});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
._11c8wadc{font:var(--ds-font-body-small,normal 400 9pt/1pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
+
._zulp1b66{gap:var(--ds-space-050,4px)}
|
|
4
|
+
._18zr1b66{padding-inline:var(--ds-space-050,4px)}
|
|
5
|
+
._1rjcv77o{padding-block:var(--ds-space-025,2px)}
|
|
6
|
+
._12l2r5cr{margin-inline-end:var(--ds-space-negative-050,-4px)}
|
|
7
|
+
._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
8
|
+
._18m915vq{overflow-y:hidden}
|
|
9
|
+
._1bto1l2s{text-overflow:ellipsis}
|
|
10
|
+
._1doc1dm9{border-bottom-width:var(--ds-border-width-selected,2px)}
|
|
11
|
+
._1e02idpf{inset-inline-start:0}
|
|
12
|
+
._1e0c116y{display:inline-flex}
|
|
13
|
+
._1e0c1ule{display:block}
|
|
14
|
+
._1il9nqa1{border-bottom-style:solid}
|
|
15
|
+
._1o9zidpf{flex-shrink:0}
|
|
16
|
+
._1pbykb7n{z-index:1}
|
|
17
|
+
._1reo15vq{overflow-x:hidden}
|
|
18
|
+
._1ul9idpf{min-width:0}
|
|
19
|
+
._4cvr1h6o{align-items:center}
|
|
20
|
+
._94n51osq{bottom:100%}
|
|
21
|
+
._kqswstnw{position:absolute}
|
|
22
|
+
._lcxv1wug{pointer-events:auto}
|
|
23
|
+
._lcxvglyw{pointer-events:none}
|
|
24
|
+
._o5721q9c{white-space:nowrap}
|
|
25
|
+
._p12f1osq{max-width:100%}
|
|
26
|
+
._tzy4idpf{opacity:0}
|
|
27
|
+
._tzy4kb7n{opacity:1}
|
|
28
|
+
._uiztglyw{-webkit-user-select:none;-ms-user-select:none;user-select:none}
|
|
29
|
+
._vchhusvi{box-sizing:border-box}
|