@atlaskit/editor-plugin-show-diff 15.1.6 → 15.1.8
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 +45 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +32 -7
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +25 -4
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +40 -14
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +14 -0
- package/dist/cjs/pm-plugins/resolveDiffContributors.js +58 -7
- package/dist/cjs/ui/ContributorTag/buildContributorTagDom.js +70 -14
- package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +8 -2
- package/dist/cjs/ui/ContributorTag/contributorTagController.js +169 -150
- package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +5 -1
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +17 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +25 -4
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +40 -14
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +14 -0
- package/dist/es2019/pm-plugins/resolveDiffContributors.js +57 -4
- package/dist/es2019/ui/ContributorTag/buildContributorTagDom.js +69 -13
- package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +8 -2
- package/dist/es2019/ui/ContributorTag/contributorTagController.js +164 -104
- package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +5 -1
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +32 -7
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +25 -4
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +40 -14
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +14 -0
- package/dist/esm/pm-plugins/resolveDiffContributors.js +58 -7
- package/dist/esm/ui/ContributorTag/buildContributorTagDom.js +69 -13
- package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +8 -2
- package/dist/esm/ui/ContributorTag/contributorTagController.js +171 -152
- package/dist/esm/ui/ContributorTag/contributorTagIcons.js +5 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +8 -2
- package/dist/types/showDiffPluginType.d.ts +2 -2
- package/dist/types/ui/ContributorTag/buildContributorTagDom.d.ts +32 -3
- package/dist/types/ui/ContributorTag/contributorTagController.d.ts +32 -12
- package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +2 -2
- package/package.json +5 -5
|
@@ -16,9 +16,6 @@ var _schemes = require("../../pm-plugins/decorations/colorSchemes/schemes");
|
|
|
16
16
|
var _buildContributorTagDom = require("./buildContributorTagDom");
|
|
17
17
|
var _contributorAvatarRenderer = require("./contributorAvatarRenderer");
|
|
18
18
|
var _messages = require("./messages");
|
|
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; } } }; }
|
|
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; } }
|
|
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
19
|
var getContributorName = function getContributorName(contributor, formatMessage) {
|
|
23
20
|
var _contributor$name, _contributor$agentKin;
|
|
24
21
|
var name = (_contributor$name = contributor.name) === null || _contributor$name === void 0 ? void 0 : _contributor$name.trim();
|
|
@@ -35,8 +32,8 @@ var getContributorName = function getContributorName(contributor, formatMessage)
|
|
|
35
32
|
};
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
|
-
* Resolves the tag's accent from the same scheme value
|
|
39
|
-
* two can never drift.
|
|
35
|
+
* Resolves the tag's accent from the same scheme value the highlight was drawn from, so the colour
|
|
36
|
+
* the two carry can never drift — only the tone does, which is `getAccentTokens`'s to pick.
|
|
40
37
|
*/
|
|
41
38
|
var getTagAccent = function getTagAccent(_ref) {
|
|
42
39
|
var colorScheme = _ref.colorScheme,
|
|
@@ -47,35 +44,70 @@ var getTagAccent = function getTagAccent(_ref) {
|
|
|
47
44
|
return (0, _factory.getAccentTokens)(accent);
|
|
48
45
|
};
|
|
49
46
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Keyboard focus, as a member of `revealSources` alongside the elements the pointer can be over. It
|
|
49
|
+
* has no element of its own to key on — the tag is already in the set under its own hover.
|
|
50
|
+
*/
|
|
51
|
+
var FOCUS_SOURCE = Symbol('contributor-tag-focus');
|
|
52
|
+
|
|
53
|
+
/** Moves the tag between the two ends of the fade `contributorTagStyles` declares. */
|
|
54
|
+
var setRevealed = function setRevealed(tag, isVisible) {
|
|
55
|
+
tag.toggleAttribute(_buildContributorTagDom.CONTRIBUTOR_TAG_REVEALED_ATTRIBUTE, isVisible);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether flipping the tag's state will actually run a transition on it.
|
|
60
|
+
*
|
|
61
|
+
* Asked of the element rather than of `matchMedia`, because reduced motion and a missing stylesheet
|
|
62
|
+
* both compute to a zero duration — and a transition that never starts fires no `transitionend`, so
|
|
63
|
+
* a tag waiting for one would sit on screen until the backstop timeout.
|
|
64
|
+
*
|
|
65
|
+
* Read only when a tag is being taken down: it resolves style.
|
|
66
|
+
*/
|
|
67
|
+
var willTransition = function willTransition(tag) {
|
|
68
|
+
return window.getComputedStyle(tag).transitionDuration.split(',').some(function (duration) {
|
|
69
|
+
return parseFloat(duration) > 0;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Fades a tag that is still on screen out, and releases it once the fade has finished.
|
|
75
|
+
*
|
|
76
|
+
* No controller owns the element by the time this runs — it is released up front so a republished
|
|
77
|
+
* model's tag can fade in over the top — so everything the removal needs is captured here.
|
|
78
|
+
*/
|
|
79
|
+
var fadeTagOut = function fadeTagOut(tag, release) {
|
|
80
|
+
setRevealed(tag, false);
|
|
81
|
+
|
|
82
|
+
// Nothing to wait for: reduced motion, or no stylesheet to fade it with.
|
|
83
|
+
if (!willTransition(tag)) {
|
|
84
|
+
release();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
var unbind;
|
|
88
|
+
var isFinished = false;
|
|
89
|
+
var finish = function finish() {
|
|
90
|
+
var _unbind;
|
|
91
|
+
// Whichever of the two signals arrives first wins; the other must not release twice.
|
|
92
|
+
if (isFinished) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
isFinished = true;
|
|
96
|
+
(_unbind = unbind) === null || _unbind === void 0 || _unbind();
|
|
97
|
+
unbind = undefined;
|
|
98
|
+
clearTimeout(fallbackId);
|
|
99
|
+
release();
|
|
100
|
+
};
|
|
101
|
+
unbind = (0, _bindEventListener.bind)(tag, {
|
|
102
|
+
type: 'transitionend',
|
|
103
|
+
// `transitionend` bubbles, and opacity is not the only property that could ever carry one.
|
|
104
|
+
listener: function listener(event) {
|
|
105
|
+
if (event.target === tag && event.propertyName === 'opacity') {
|
|
106
|
+
finish();
|
|
71
107
|
}
|
|
72
108
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
} finally {
|
|
76
|
-
_iterator.f();
|
|
77
|
-
}
|
|
78
|
-
return start;
|
|
109
|
+
});
|
|
110
|
+
var fallbackId = setTimeout(finish, _buildContributorTagDom.TAG_EXIT_FALLBACK_MS);
|
|
79
111
|
};
|
|
80
112
|
|
|
81
113
|
/** The contributors a tag draws, keyed so a republished model can be recognised as the same pair. */
|
|
@@ -104,8 +136,18 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
104
136
|
(0, _defineProperty2.default)(this, "bindToken", 0);
|
|
105
137
|
(0, _defineProperty2.default)(this, "fullLabel", '');
|
|
106
138
|
(0, _defineProperty2.default)(this, "isDestroyed", false);
|
|
107
|
-
|
|
108
|
-
(0, _defineProperty2.default)(this, "
|
|
139
|
+
/** Last visibility written, so a teardown knows whether there is anything on screen to fade. */
|
|
140
|
+
(0, _defineProperty2.default)(this, "isVisible", false);
|
|
141
|
+
/**
|
|
142
|
+
* Everything currently asking for the tag to be up, other than the model: each hovered highlight,
|
|
143
|
+
* the tag itself while the pointer is on it, and `FOCUS_SOURCE` while it holds focus.
|
|
144
|
+
*
|
|
145
|
+
* One set rather than independent booleans, which is what let the exit's trailing delay go: a
|
|
146
|
+
* pointer crossing from the highlight onto the tag removes one member and adds another in the same
|
|
147
|
+
* dispatch, so no style is resolved in between and the browser never starts the exit. Booleans
|
|
148
|
+
* could not see each other, so the crossing wrote the tag out and straight back in.
|
|
149
|
+
*/
|
|
150
|
+
(0, _defineProperty2.default)(this, "revealSources", new Set());
|
|
109
151
|
(0, _defineProperty2.default)(this, "unbindHighlights", []);
|
|
110
152
|
this.options = options;
|
|
111
153
|
}
|
|
@@ -167,65 +209,101 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
167
209
|
this.renderLabels(next);
|
|
168
210
|
this.applyAccent(next);
|
|
169
211
|
this.syncHighlightBindings(next);
|
|
170
|
-
this.
|
|
212
|
+
this.applyVisibility();
|
|
171
213
|
this.syncTooltip();
|
|
172
214
|
}
|
|
173
215
|
|
|
174
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Takes the tag's DOM down, keeping the subscription so a republished model redraws it.
|
|
218
|
+
*
|
|
219
|
+
* A tag that is still on screen is released here and fades out on its own, so a republished
|
|
220
|
+
* model's tag fades in over the top of the outgoing one — see `fadeTagOut`.
|
|
221
|
+
*/
|
|
175
222
|
}, {
|
|
176
223
|
key: "teardownTag",
|
|
177
224
|
value: function teardownTag() {
|
|
178
|
-
var _this$unbindTag, _this$tooltip
|
|
225
|
+
var _this$unbindTag, _this$tooltip;
|
|
226
|
+
// Unbound synchronously, ahead of any fade: a tag on its way out must not be revealed again by
|
|
227
|
+
// the pointer, and these listeners are what hold this controller.
|
|
179
228
|
this.unbindHighlightState();
|
|
180
229
|
this.boundSelector = undefined;
|
|
181
230
|
(_this$unbindTag = this.unbindTag) === null || _this$unbindTag === void 0 || _this$unbindTag.call(this);
|
|
182
231
|
this.unbindTag = undefined;
|
|
232
|
+
// Destroyed rather than carried through the fade: it is a popover in the top layer.
|
|
183
233
|
(_this$tooltip = this.tooltip) === null || _this$tooltip === void 0 || _this$tooltip.destroy();
|
|
184
234
|
this.tooltip = undefined;
|
|
185
235
|
this.tooltipContent = undefined;
|
|
186
|
-
this.
|
|
187
|
-
|
|
188
|
-
|
|
236
|
+
var dom = this.dom,
|
|
237
|
+
isVisible = this.isVisible;
|
|
238
|
+
// Destroying an avatar removes its element, so the avatars go with whoever removes the tag —
|
|
239
|
+
// destroyed here and it would fade out empty.
|
|
240
|
+
var avatars = this.avatars;
|
|
189
241
|
this.avatars = [];
|
|
190
|
-
(_this$dom = this.dom) === null || _this$dom === void 0 || _this$dom.root.remove();
|
|
191
242
|
this.dom = undefined;
|
|
192
|
-
this.
|
|
193
|
-
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
|
|
243
|
+
this.isVisible = false;
|
|
244
|
+
// The set belongs to the listeners just unbound: a stale member would draw the tag as visible
|
|
245
|
+
// with the pointer nowhere near it.
|
|
246
|
+
this.revealSources.clear();
|
|
247
|
+
if (!dom) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
var release = function release() {
|
|
251
|
+
avatars.forEach(function (avatar) {
|
|
252
|
+
return avatar.destroy();
|
|
253
|
+
});
|
|
254
|
+
dom.root.remove();
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Nothing on screen to fade. `isConnected` covers ProseMirror destroying the widget: a fade on
|
|
258
|
+
// a detached element never starts.
|
|
259
|
+
if (!isVisible || !dom.tag.isConnected) {
|
|
260
|
+
release();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
fadeTagOut(dom.tag, release);
|
|
197
264
|
}
|
|
198
265
|
}, {
|
|
199
266
|
key: "bindTag",
|
|
200
267
|
value: function bindTag(_ref4) {
|
|
201
|
-
var _this3 = this;
|
|
202
268
|
var tag = _ref4.tag;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
_this3.applyStyles();
|
|
207
|
-
};
|
|
208
|
-
};
|
|
269
|
+
// `mouseover`/`mouseout` rather than the enter/leave pair, because they are what fire as the
|
|
270
|
+
// pointer moves between the tag's own children. Both are keyed on the tag, so those moves add
|
|
271
|
+
// and remove the same member and the set never empties.
|
|
209
272
|
this.unbindTag = (0, _bindEventListener.bindAll)(tag, [{
|
|
210
273
|
type: 'mouseover',
|
|
211
|
-
listener:
|
|
274
|
+
listener: this.trackRevealSource(tag, true)
|
|
212
275
|
}, {
|
|
213
276
|
type: 'mouseout',
|
|
214
|
-
listener:
|
|
277
|
+
listener: this.trackRevealSource(tag, false)
|
|
215
278
|
}, {
|
|
216
279
|
type: 'focus',
|
|
217
|
-
listener:
|
|
280
|
+
listener: this.trackRevealSource(FOCUS_SOURCE, true)
|
|
218
281
|
}, {
|
|
219
282
|
type: 'blur',
|
|
220
|
-
listener:
|
|
283
|
+
listener: this.trackRevealSource(FOCUS_SOURCE, false)
|
|
221
284
|
}]);
|
|
222
285
|
}
|
|
286
|
+
|
|
287
|
+
/** One listener shape for every reveal source, so all of them land in the same set. */
|
|
288
|
+
}, {
|
|
289
|
+
key: "trackRevealSource",
|
|
290
|
+
value: function trackRevealSource(source, isRevealing) {
|
|
291
|
+
var _this3 = this;
|
|
292
|
+
return function () {
|
|
293
|
+
if (isRevealing) {
|
|
294
|
+
_this3.revealSources.add(source);
|
|
295
|
+
} else {
|
|
296
|
+
_this3.revealSources.delete(source);
|
|
297
|
+
}
|
|
298
|
+
_this3.applyVisibility();
|
|
299
|
+
};
|
|
300
|
+
}
|
|
223
301
|
}, {
|
|
224
302
|
key: "renderAvatars",
|
|
225
303
|
value: function renderAvatars(model) {
|
|
226
|
-
var _this$
|
|
304
|
+
var _this$dom,
|
|
227
305
|
_this4 = this;
|
|
228
|
-
var _ref5 = (_this$
|
|
306
|
+
var _ref5 = (_this$dom = this.dom) !== null && _this$dom !== void 0 ? _this$dom : {},
|
|
229
307
|
container = _ref5.avatars;
|
|
230
308
|
if (!container) {
|
|
231
309
|
return;
|
|
@@ -285,8 +363,8 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
285
363
|
var agentName = isPrimaryAgent ? primaryName : secondaryName;
|
|
286
364
|
var userName = isPrimaryAgent ? secondaryName : primaryName;
|
|
287
365
|
|
|
288
|
-
// A connected pair only ever shows the agent; the pair is spelled out in the label, because
|
|
289
|
-
//
|
|
366
|
+
// A connected pair only ever shows the agent; the pair is spelled out in the label, because the
|
|
367
|
+
// tag is capped at `MAX_TAG_WIDTH` and two names rarely fit inside it.
|
|
290
368
|
this.dom.name.textContent = model.connectedContributor ? agentName || primaryName : primaryName;
|
|
291
369
|
this.fullLabel = model.connectedContributor ? formatMessage(_messages.contributorTagMessages.changedByConnected, {
|
|
292
370
|
agentName: agentName,
|
|
@@ -314,34 +392,34 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
314
392
|
}
|
|
315
393
|
var accent = this.accentOf(model);
|
|
316
394
|
this.dom.tag.style.setProperty('background-color', accent.background);
|
|
317
|
-
this.dom.tag.style.setProperty('border-bottom-color', accent.border);
|
|
318
395
|
this.dom.name.style.setProperty('color', accent.text);
|
|
319
396
|
this.avatars.forEach(function (avatar) {
|
|
320
397
|
return avatar.setRingColor(accent.background);
|
|
321
398
|
});
|
|
322
399
|
}
|
|
323
400
|
|
|
324
|
-
/**
|
|
401
|
+
/**
|
|
402
|
+
* Visibility — the one thing the model does not carry on its own, because hover is not in it.
|
|
403
|
+
*
|
|
404
|
+
* One idempotent attribute write, with nothing to guard: whether the flip is a real one, whether
|
|
405
|
+
* the tag is attached yet, and whether motion is wanted at all are all the stylesheet's to answer.
|
|
406
|
+
*/
|
|
325
407
|
}, {
|
|
326
|
-
key: "
|
|
327
|
-
value: function
|
|
408
|
+
key: "applyVisibility",
|
|
409
|
+
value: function applyVisibility() {
|
|
328
410
|
var _this$model;
|
|
329
411
|
if (!this.dom) {
|
|
330
412
|
return;
|
|
331
413
|
}
|
|
332
|
-
this.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this.maxWidthPx === undefined ? '' : "max(".concat(Math.round(this.maxWidthPx), "px, ").concat(_buildContributorTagDom.MIN_TAG_WIDTH, ")"));
|
|
336
|
-
var isVisible = Boolean((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.isActive) || this.isHighlightHovered || this.isHoveredOrFocused;
|
|
337
|
-
this.dom.tag.style.setProperty('opacity', isVisible ? '1' : '0');
|
|
338
|
-
this.dom.tag.style.setProperty('pointer-events', isVisible ? 'auto' : 'none');
|
|
414
|
+
var isVisible = Boolean((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.isActive) || this.revealSources.size > 0;
|
|
415
|
+
this.isVisible = isVisible;
|
|
416
|
+
setRevealed(this.dom.tag, isVisible);
|
|
339
417
|
}
|
|
340
418
|
|
|
341
419
|
/**
|
|
342
|
-
* The full label is always the tooltip, whether or not the name it draws is clipped:
|
|
343
|
-
*
|
|
344
|
-
*
|
|
420
|
+
* The full label is always the tooltip, whether or not the name it draws is clipped: a name longer
|
|
421
|
+
* than `MAX_TAG_WIDTH` is ellipsised, and a connected pair spells out a contributor the tag does
|
|
422
|
+
* not show at any width.
|
|
345
423
|
*
|
|
346
424
|
* `VanillaTooltip` has no "set new content" call, so it is rebuilt when the label changes — the
|
|
347
425
|
* shape of `syncVanillaDisabledTooltip` in `mentionNodeView`.
|
|
@@ -372,9 +450,9 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
372
450
|
}
|
|
373
451
|
|
|
374
452
|
/**
|
|
375
|
-
* Observes the highlight this tag describes, for what CSS here cannot see: its hover state
|
|
453
|
+
* Observes the highlight this tag describes, for what CSS here cannot see: its hover state. The
|
|
376
454
|
* highlight is a ProseMirror decoration in a different DOM subtree, so listeners are bound
|
|
377
|
-
* imperatively via `data-diff-id
|
|
455
|
+
* imperatively via `data-diff-id`.
|
|
378
456
|
*
|
|
379
457
|
* Deliberately not routed through plugin state: a transaction per pointer move would re-run the
|
|
380
458
|
* memoised decoration calculation.
|
|
@@ -394,8 +472,8 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
394
472
|
this.boundSelector = selector;
|
|
395
473
|
this.unbindHighlightState();
|
|
396
474
|
|
|
397
|
-
// ProseMirror draws the tag's host in the same pass as the highlights
|
|
398
|
-
//
|
|
475
|
+
// ProseMirror draws the tag's host in the same pass as the highlights it binds to, so those may
|
|
476
|
+
// not be in the document yet. A microtask lands once that pass has finished.
|
|
399
477
|
var pendingBind = ++this.bindToken;
|
|
400
478
|
queueMicrotask(function () {
|
|
401
479
|
if (!_this5.isDestroyed && pendingBind === _this5.bindToken) {
|
|
@@ -406,91 +484,32 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
406
484
|
}, {
|
|
407
485
|
key: "bindHighlightState",
|
|
408
486
|
value: function bindHighlightState(selector) {
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
//
|
|
412
|
-
// inside this one, cannot
|
|
413
|
-
|
|
414
|
-
var highlights =
|
|
415
|
-
if (!
|
|
487
|
+
var _this$options$getEdit,
|
|
488
|
+
_this6 = this;
|
|
489
|
+
// Scoped to this editor's content root, so a tag can only ever bind to the decorations its own
|
|
490
|
+
// plugin instance rendered — another editor on the page, or one nested inside this one, cannot
|
|
491
|
+
// reveal this tag.
|
|
492
|
+
var highlights = (_this$options$getEdit = this.options.getEditorRoot()) === null || _this$options$getEdit === void 0 ? void 0 : _this$options$getEdit.querySelectorAll(selector);
|
|
493
|
+
if (!(highlights !== null && highlights !== void 0 && highlights.length)) {
|
|
416
494
|
return;
|
|
417
495
|
}
|
|
418
496
|
|
|
419
|
-
//
|
|
420
|
-
//
|
|
421
|
-
|
|
422
|
-
var measure = function measure() {
|
|
423
|
-
var _findChangeStartLine;
|
|
424
|
-
// Counted by distinct line box, not by client rect: an inline node inside the change (a
|
|
425
|
-
// mention, emoji, date) splits the highlight into several rects on the same line, and
|
|
426
|
-
// treating that as a wrap would drop the width clamp on changes that never wrapped.
|
|
427
|
-
var lineTops = new Set();
|
|
428
|
-
for (var _i = 0, _ownElements = ownElements; _i < _ownElements.length; _i++) {
|
|
429
|
-
var highlight = _ownElements[_i];
|
|
430
|
-
var _iterator3 = _createForOfIteratorHelper(highlight.getClientRects()),
|
|
431
|
-
_step3;
|
|
432
|
-
try {
|
|
433
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
434
|
-
var rect = _step3.value;
|
|
435
|
-
lineTops.add(Math.round(rect.top));
|
|
436
|
-
}
|
|
437
|
-
} catch (err) {
|
|
438
|
-
_iterator3.e(err);
|
|
439
|
-
} finally {
|
|
440
|
-
_iterator3.f();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// A wrapped change's first line says nothing useful about how wide the tag may be.
|
|
445
|
-
_this6.maxWidthPx = lineTops.size > 1 ? undefined : (_findChangeStartLine = findChangeStartLine(ownElements)) === null || _findChangeStartLine === void 0 ? void 0 : _findChangeStartLine.width;
|
|
446
|
-
_this6.applyStyles();
|
|
447
|
-
};
|
|
448
|
-
measure();
|
|
449
|
-
|
|
450
|
-
// An inline element cannot be observed itself (ResizeObserver skips boxes with no principal
|
|
451
|
-
// box), so the block it sits in is observed instead.
|
|
452
|
-
this.resizeObserver = new ResizeObserver(measure);
|
|
453
|
-
var _iterator4 = _createForOfIteratorHelper(new Set(ownElements.map(function (_ref7) {
|
|
454
|
-
var parentElement = _ref7.parentElement;
|
|
455
|
-
return parentElement;
|
|
456
|
-
}))),
|
|
457
|
-
_step4;
|
|
458
|
-
try {
|
|
459
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
460
|
-
var parent = _step4.value;
|
|
461
|
-
if (parent) {
|
|
462
|
-
this.resizeObserver.observe(parent);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// `bindAll` takes a single target, and a change can render more than one highlight.
|
|
467
|
-
} catch (err) {
|
|
468
|
-
_iterator4.e(err);
|
|
469
|
-
} finally {
|
|
470
|
-
_iterator4.f();
|
|
471
|
-
}
|
|
497
|
+
// `bindAll` takes a single target, and a change can render more than one highlight. Each is its
|
|
498
|
+
// own member of `revealSources`, so the pointer can cross between them without the set
|
|
499
|
+
// emptying.
|
|
472
500
|
this.unbindHighlights = Array.from(highlights).map(function (highlight) {
|
|
473
501
|
return (0, _bindEventListener.bindAll)(highlight, [{
|
|
474
502
|
type: 'mouseenter',
|
|
475
|
-
listener:
|
|
476
|
-
_this6.isHighlightHovered = true;
|
|
477
|
-
_this6.applyStyles();
|
|
478
|
-
}
|
|
503
|
+
listener: _this6.trackRevealSource(highlight, true)
|
|
479
504
|
}, {
|
|
480
505
|
type: 'mouseleave',
|
|
481
|
-
listener:
|
|
482
|
-
_this6.isHighlightHovered = false;
|
|
483
|
-
_this6.applyStyles();
|
|
484
|
-
}
|
|
506
|
+
listener: _this6.trackRevealSource(highlight, false)
|
|
485
507
|
}]);
|
|
486
508
|
});
|
|
487
509
|
}
|
|
488
510
|
}, {
|
|
489
511
|
key: "unbindHighlightState",
|
|
490
512
|
value: function unbindHighlightState() {
|
|
491
|
-
var _this$resizeObserver;
|
|
492
|
-
(_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.disconnect();
|
|
493
|
-
this.resizeObserver = undefined;
|
|
494
513
|
this.unbindHighlights.forEach(function (unbind) {
|
|
495
514
|
return unbind();
|
|
496
515
|
});
|
|
@@ -8,7 +8,7 @@ exports.getContributorTagIcon = void 0;
|
|
|
8
8
|
* The icons a contributor tag can draw, as inline SVG.
|
|
9
9
|
*
|
|
10
10
|
* Neither `@atlaskit/icon`, `@atlaskit/icon-lab` nor `@atlaskit/logo` exposes a raw-SVG entry
|
|
11
|
-
* point, so the markup is copied here rather than kept as a React island for
|
|
11
|
+
* point, so the markup is copied here rather than kept as a React island for these glyphs. Keep in
|
|
12
12
|
* sync with the sources named on each constant.
|
|
13
13
|
*
|
|
14
14
|
* The Rovo hex is the `brand` appearance, whose `--rovo-*-color` variables resolve to `initial` in
|
|
@@ -23,8 +23,12 @@ var AI_BOT_ICON_SVG = "<svg width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0
|
|
|
23
23
|
|
|
24
24
|
/** `RovoHexIcon` from `@atlaskit/logo/rovo-hex/icon`, at the 16px `xxsmall` renders. */
|
|
25
25
|
var ROVO_HEX_ICON_SVG = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" role=\"presentation\" style=\"display:block\"><path fill=\"#1868db\" fill-rule=\"evenodd\" d=\"m13.227 16.789-7.154 4.169-3.403-1.96a2.72 2.72 0 0 1-1.362-2.355V7.366c0-.973.518-1.87 1.361-2.354l6.044-3.487-.038.114a3.6 3.6 0 0 0-.172 1.088v9.278c0 1.274.68 2.45 1.786 3.085z\" clip-rule=\"evenodd\"/><path fill=\"#6a9a23\" fill-rule=\"evenodd\" d=\"m11.296 15.671-7.193 4.153 6.607 3.812a2.73 2.73 0 0 0 2.676.026l.048-.033a2.73 2.73 0 0 0 1.232-1.525 2.7 2.7 0 0 0 .127-.822v-3.594z\" clip-rule=\"evenodd\"/><path fill=\"#af59e1\" fill-rule=\"evenodd\" d=\"m21.477 5.003-4.404-2.539-5.904 4.89 2.69 1.556a3.56 3.56 0 0 1 1.785 3.086v9.277a3.6 3.6 0 0 1-.21 1.202l6.044-3.486a2.71 2.71 0 0 0 1.362-2.355V7.357c0-.97-.521-1.87-1.363-2.354\" clip-rule=\"evenodd\"/><path fill=\"#fca700\" fill-rule=\"evenodd\" d=\"M12.74 8.266 9.353 6.312V2.718c0-.283.044-.56.127-.821A2.73 2.73 0 0 1 10.71.372V.37a.4.4 0 0 0 .048-.033 2.73 2.73 0 0 1 2.676.026l6.499 3.75z\" clip-rule=\"evenodd\"/></svg>";
|
|
26
|
+
|
|
27
|
+
/** ClaudeLogo from ai-mate/studio-browse-kit, inset to fit the agent hexagon. */
|
|
28
|
+
var CLAUDE_ICON_SVG = "<svg width=\"12\" height=\"12\" viewBox=\"8 8 32 32\" role=\"presentation\" style=\"display:block\"><path fill=\"#FFFFFF\" d=\"M14.2785 29.274L20.5732 25.7445L20.6785 25.4369L20.5732 25.2669H20.2653L19.2122 25.2021L15.6152 25.105L12.4962 24.9755L9.47443 24.8136L8.71291 24.6517L8 23.7126L8.07291 23.2431L8.71291 22.8141L9.62835 22.895L11.6537 23.0326L14.6916 23.2431L16.8952 23.3726L20.16 23.7126H20.6785L20.7514 23.5022L20.5732 23.3726L20.4354 23.2431L17.2922 21.1141L13.8896 18.8636L12.1073 17.5684L11.1433 16.9127L10.6572 16.2975L10.4466 14.9537L11.3215 13.9904L12.4962 14.0713L12.7959 14.1523L13.9868 15.067L16.5306 17.0342L19.8522 19.4789L20.3382 19.8836L20.5327 19.746L20.557 19.6489L20.3382 19.2846L18.5316 16.0223L16.6035 12.7033L15.7448 11.3271L15.518 10.5014C15.437 10.1614 15.3803 9.87807 15.3803 9.52998L16.3767 8.17809L16.9276 8L18.2562 8.17809L18.8152 8.6638L19.6415 10.55L20.9782 13.5209L23.0522 17.5603L23.6597 18.7584L23.9838 19.8674L24.1053 20.2074H24.3159V20.0132L24.4861 17.7384L24.802 14.9456L25.1099 11.3514L25.2152 10.3395L25.7175 9.12522L26.7139 8.46952L27.4916 8.84189L28.1316 9.75664L28.0425 10.3476L27.6618 12.8166L26.9165 16.6861L26.4304 19.2765H26.7139L27.038 18.9527L28.3504 17.2122L30.5539 14.4599L31.5261 13.3671L32.6603 12.1609L33.3894 11.5861H34.7666L35.7792 13.0918L35.3256 14.6461L33.9079 16.4432L32.7332 17.9651L31.0481 20.2317L29.9949 22.045L30.0922 22.1907L30.3433 22.1665L34.1509 21.3569L36.2086 20.9846L38.6633 20.5636L39.7732 21.0817L39.8947 21.6079L39.4572 22.6845L36.8324 23.3322L33.7539 23.9474L29.1686 25.0321L29.1119 25.0726L29.1767 25.1536L31.2425 25.3478L32.1256 25.3964H34.2886L38.3149 25.6959L39.3681 26.3921L40 27.2421L39.8947 27.8897L38.2744 28.7154L36.0871 28.1973L30.9833 26.9831L29.2334 26.5459H28.9904V26.6916L30.4486 28.1164L33.122 30.5287L36.4678 33.6372L36.638 34.4063L36.2086 35.0134L35.7549 34.9486L32.8142 32.7387L31.68 31.743L29.1119 29.5816H28.9418V29.8082L29.5332 30.6744L32.6603 35.3696L32.8223 36.8105L32.5954 37.28L31.7853 37.5634L30.8942 37.4015L29.0633 34.8353L27.1757 31.9454L25.6527 29.3549L25.4663 29.4602L24.5671 39.1338L24.1458 39.6276L23.1737 40L22.3635 39.3848L21.9342 38.3891L22.3635 36.422L22.882 33.8558L23.3033 31.8158L23.6841 29.2821L23.9109 28.4402L23.8947 28.3835L23.7084 28.4078L21.7965 31.0306L18.8881 34.9567L16.5873 37.4177L16.0365 37.6362L15.0805 37.1424L15.1696 36.2601L15.7043 35.4748L18.8881 31.4273L20.8081 28.9178L22.0476 27.4688L22.0395 27.2583H21.9666L13.5089 32.7468L12.002 32.9411L11.3539 32.3339L11.4349 31.3382L11.7428 31.0144L14.2866 29.2659L14.2785 29.274Z\"/></svg>";
|
|
26
29
|
var markup = {
|
|
27
30
|
aiBot: AI_BOT_ICON_SVG,
|
|
31
|
+
claude: CLAUDE_ICON_SVG,
|
|
28
32
|
person: PERSON_ICON_SVG,
|
|
29
33
|
rovoHex: ROVO_HEX_ICON_SVG
|
|
30
34
|
};
|
|
@@ -6,7 +6,7 @@ import { Mapping } from '@atlaskit/editor-prosemirror/transform';
|
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
9
|
-
import {
|
|
9
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
10
10
|
import { areDocsEqualByBlockStructureAndText } from '../areDocsEqualByBlockStructureAndText';
|
|
11
11
|
import { createDocMarginAnchorWidget } from '../decorations/createAnchorDecorationWidgets';
|
|
12
12
|
import { createBlockChangedDecoration } from '../decorations/createBlockChangedDecoration';
|
|
@@ -482,8 +482,9 @@ const calculateDiffDecorationsInner = ({
|
|
|
482
482
|
// gets highlighted, and structural gaps never do.
|
|
483
483
|
const isSmartNodeLevel = diffType === 'smart' && fg('platform_editor_ai_smart_diff') && smartChangeLevel(change) === 'node';
|
|
484
484
|
// For a large inserted table, skip the per-cell inline decorations that
|
|
485
|
-
// freeze the browser on re-render. Only active
|
|
486
|
-
|
|
485
|
+
// freeze the browser on re-render. Only active when Review moment is
|
|
486
|
+
// eligible (xstate + M1).
|
|
487
|
+
const useCoarseTableDecoration = isSmartNodeLevel && expValEqualsNoExposure('platform_editor_ai_xstate_migration', 'isEnabled', true) && UNSAFE_expValNoExposure('platform_editor_ai_streaming_ux_experience_m1', 'isEnabled', false) === true && isLargeInsertedTableRange(tr.doc, change.fromB, change.toB);
|
|
487
488
|
// Whether the deleted-content widget will actually be rendered for this
|
|
488
489
|
// change. Used to decide if indicator anchor positions should be adjusted
|
|
489
490
|
// inward — when the widget is present the anchor must stay at the block
|
|
@@ -670,7 +671,7 @@ const calculateDiffDecorationsInner = ({
|
|
|
670
671
|
}));
|
|
671
672
|
// If the original node position is known (e.g. a panel type change), also render
|
|
672
673
|
// the old block node as a "deleted" widget so the reviewer sees the before/after.
|
|
673
|
-
const isSmartNodeLevelAttrChange = diffType === 'smart' && fg('platform_editor_ai_smart_diff') &&
|
|
674
|
+
const isSmartNodeLevelAttrChange = diffType === 'smart' && fg('platform_editor_ai_smart_diff') && expValEqualsNoExposure('platform_editor_ai_xstate_migration', 'isEnabled', true) && UNSAFE_expValNoExposure('platform_editor_ai_streaming_ux_experience_m1', 'isEnabled', false) === true;
|
|
674
675
|
if (isSmartNodeLevelAttrChange && change.fromA !== undefined && change.toA !== undefined) {
|
|
675
676
|
const placeBelow = deletedDiffPlacement === 'bottom';
|
|
676
677
|
decorations.push(...createNodeChangedDecorationWidget({
|
|
@@ -103,6 +103,23 @@ export const isContributorTagsEnabled = (stepAttributions, contributors) => areA
|
|
|
103
103
|
export const createAttributionColorMap = stepAttributions => {
|
|
104
104
|
const colors = new Map();
|
|
105
105
|
const allocatedColors = new Set();
|
|
106
|
+
|
|
107
|
+
// Reserve shared brand colours before hashing other actors, regardless of step order.
|
|
108
|
+
for (const attribution of stepAttributions) {
|
|
109
|
+
const identity = getAttributionIdentity(attribution);
|
|
110
|
+
if (!identity) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const {
|
|
114
|
+
index,
|
|
115
|
+
isFixed
|
|
116
|
+
} = getParticipantColor(identity.colorSeed, attribution === null || attribution === void 0 ? void 0 : attribution.agentType);
|
|
117
|
+
const color = HASHED_PARTICIPANT_COLOR_SCHEMES[index];
|
|
118
|
+
if (isFixed && color) {
|
|
119
|
+
colors.set(identity.key, color);
|
|
120
|
+
allocatedColors.add(color);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
106
123
|
for (const attribution of stepAttributions) {
|
|
107
124
|
const identity = getAttributionIdentity(attribution);
|
|
108
125
|
if (!identity || colors.has(identity.key)) {
|
|
@@ -62,6 +62,18 @@ const bgSubtlerPressedMap = {
|
|
|
62
62
|
gray: "var(--ds-background-accent-gray-subtler-pressed, #8C8F97)",
|
|
63
63
|
lime: "var(--ds-background-accent-lime-subtler-pressed, #B3DF72)"
|
|
64
64
|
};
|
|
65
|
+
const bgBolderMap = {
|
|
66
|
+
green: "var(--ds-background-accent-green-bolder, #1F845A)",
|
|
67
|
+
teal: "var(--ds-background-accent-teal-bolder, #227D9B)",
|
|
68
|
+
blue: "var(--ds-background-accent-blue-bolder, #1868DB)",
|
|
69
|
+
purple: "var(--ds-background-accent-purple-bolder, #964AC0)",
|
|
70
|
+
red: "var(--ds-background-accent-red-bolder, #C9372C)",
|
|
71
|
+
orange: "var(--ds-background-accent-orange-bolder, #BD5B00)",
|
|
72
|
+
yellow: "var(--ds-background-accent-yellow-bolder, #946F00)",
|
|
73
|
+
magenta: "var(--ds-background-accent-magenta-bolder, #AE4787)",
|
|
74
|
+
gray: "var(--ds-background-accent-gray-bolder, #6B6E76)",
|
|
75
|
+
lime: "var(--ds-background-accent-lime-bolder, #5B7F24)"
|
|
76
|
+
};
|
|
65
77
|
const borderAccentMap = {
|
|
66
78
|
green: "var(--ds-border-accent-green, #22A06B)",
|
|
67
79
|
teal: "var(--ds-border-accent-teal, #2898BD)",
|
|
@@ -95,6 +107,9 @@ function bgSubtlestPressed(color) {
|
|
|
95
107
|
function bgSubtler(color) {
|
|
96
108
|
return bgSubtlerMap[color];
|
|
97
109
|
}
|
|
110
|
+
function bgBolder(color) {
|
|
111
|
+
return bgBolderMap[color];
|
|
112
|
+
}
|
|
98
113
|
function bgSubtlerPressed(color) {
|
|
99
114
|
return bgSubtlerPressedMap[color];
|
|
100
115
|
}
|
|
@@ -105,12 +120,18 @@ function textAccent(color) {
|
|
|
105
120
|
return textAccentMap[color];
|
|
106
121
|
}
|
|
107
122
|
|
|
108
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Presentation tokens for a contributor tag in one diff colour.
|
|
125
|
+
*
|
|
126
|
+
* A `bolder` fill rather than the `subtlest` tint the highlight uses: the tag is a label on the
|
|
127
|
+
* change, and at tag size a tint reads as a second, weaker highlight sitting above the real one.
|
|
128
|
+
* `inverse` is the only text tone that reads on a bolder fill, and it needs no per-colour map —
|
|
129
|
+
* which is also why the tag carries no border: the fill alone bounds it.
|
|
130
|
+
*/
|
|
109
131
|
export function getAccentTokens(color) {
|
|
110
132
|
return {
|
|
111
|
-
background:
|
|
112
|
-
|
|
113
|
-
text: textAccent(color)
|
|
133
|
+
background: bgBolder(color),
|
|
134
|
+
text: "var(--ds-text-inverse, #FFFFFF)"
|
|
114
135
|
};
|
|
115
136
|
}
|
|
116
137
|
|