@atlaskit/editor-plugin-show-diff 15.1.6 → 15.1.7
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 +35 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- 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/ui/ContributorTag/buildContributorTagDom.js +70 -14
- package/dist/cjs/ui/ContributorTag/contributorTagController.js +169 -150
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- 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/ui/ContributorTag/buildContributorTagDom.js +69 -13
- package/dist/es2019/ui/ContributorTag/contributorTagController.js +164 -104
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +5 -4
- 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/ui/ContributorTag/buildContributorTagDom.js +69 -13
- package/dist/esm/ui/ContributorTag/contributorTagController.js +171 -152
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +8 -2
- package/dist/types/ui/ContributorTag/buildContributorTagDom.d.ts +32 -3
- package/dist/types/ui/ContributorTag/contributorTagController.d.ts +32 -12
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
6
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
|
+
import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
|
|
8
9
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
9
10
|
import { hasVisibleContent } from '../utils/hasVisibleContent';
|
|
10
11
|
import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
|
|
@@ -17,6 +18,25 @@ import { REVEAL_ATTR, resolveRevealStyle } from './revealStyles';
|
|
|
17
18
|
var displayNoneStyle = convertToInlineCss({
|
|
18
19
|
display: 'none'
|
|
19
20
|
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Stacks the change's highlight below its contributor tag, so no highlight can slice through a tag:
|
|
24
|
+
* a tag overlays the line *above* its own change, and a highlight already on that line — the tail of
|
|
25
|
+
* this change, or another change entirely — would otherwise paint straight over it.
|
|
26
|
+
*
|
|
27
|
+
* The tag still reads as attached to the change rather than laid on top of it, because it cannot
|
|
28
|
+
* paint over this highlight at all: its bottom edge is pinned to the highlight's top edge and
|
|
29
|
+
* clipped there. See `CONTRIBUTOR_TAG_Z_INDEX`.
|
|
30
|
+
*
|
|
31
|
+
* prosemirror-view places the tag's host widget as a *sibling* of this decoration's span, so
|
|
32
|
+
* painting order is decided by stacking level — and the host is absolutely positioned at
|
|
33
|
+
* `CONTRIBUTOR_TAG_Z_INDEX`. `position: relative` is what makes `z-index` apply to an otherwise
|
|
34
|
+
* static inline box; it adds no offset.
|
|
35
|
+
*/
|
|
36
|
+
var stackBelowContributorTagStyle = convertToInlineCss({
|
|
37
|
+
position: 'relative',
|
|
38
|
+
zIndex: CONTRIBUTOR_TAG_Z_INDEX - 1
|
|
39
|
+
});
|
|
20
40
|
var getColorScheme = function getColorScheme(colorScheme) {
|
|
21
41
|
return colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
|
|
22
42
|
};
|
|
@@ -176,8 +196,23 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
176
196
|
});
|
|
177
197
|
var isAtomicInlineInsertion = isAtomicInlineNode && isInserted;
|
|
178
198
|
var atomicInlineAttrs = isAtomicInlineInsertion ? resolveAtomicInlineAttrs(inlineNodeName, colorScheme, colors) : undefined;
|
|
199
|
+
|
|
200
|
+
// Built from the raw change range, not the indicator anchors resolved below: a tag lines up with
|
|
201
|
+
// the changed text, while the bar's anchors are held on a block boundary when a deleted widget
|
|
202
|
+
// renders beside them.
|
|
203
|
+
//
|
|
204
|
+
// Built up here, ahead of where it is pushed, so the highlight's stacking below keys off whether a
|
|
205
|
+
// tag exists rather than re-deriving the condition and risking disagreement.
|
|
206
|
+
var tagWidget = canTagChange && doc ? createContributorTagWidget({
|
|
207
|
+
doc: doc,
|
|
208
|
+
from: change.fromB,
|
|
209
|
+
to: change.toB,
|
|
210
|
+
diffId: diffId,
|
|
211
|
+
mountContext: tagMountContext
|
|
212
|
+
}) : undefined;
|
|
213
|
+
var inlineStyle = [style, atomicInlineAttrs === null || atomicInlineAttrs === void 0 ? void 0 : atomicInlineAttrs.styleSuffix, tagWidget ? stackBelowContributorTagStyle : undefined].filter(Boolean).join('');
|
|
179
214
|
var decorations = [Decoration.inline(change.fromB, change.toB, _objectSpread(_objectSpread(_objectSpread({
|
|
180
|
-
style:
|
|
215
|
+
style: inlineStyle
|
|
181
216
|
}, atomicInlineAttrs && {
|
|
182
217
|
class: atomicInlineAttrs.className
|
|
183
218
|
}), revealed && _defineProperty({}, REVEAL_ATTR, revealed.role)), {}, {
|
|
@@ -228,19 +263,10 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
228
263
|
})));
|
|
229
264
|
}
|
|
230
265
|
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
doc: doc,
|
|
236
|
-
from: change.fromB,
|
|
237
|
-
to: change.toB,
|
|
238
|
-
diffId: diffId,
|
|
239
|
-
mountContext: tagMountContext
|
|
240
|
-
});
|
|
241
|
-
if (tagWidget) {
|
|
242
|
-
decorations.push(tagWidget);
|
|
243
|
-
}
|
|
266
|
+
// Pushed after the indicator anchors so the decoration order is unchanged — see `tagWidget` above
|
|
267
|
+
// for why it is built before them.
|
|
268
|
+
if (tagWidget) {
|
|
269
|
+
decorations.push(tagWidget);
|
|
244
270
|
}
|
|
245
271
|
return decorations;
|
|
246
272
|
};
|
|
@@ -3,6 +3,7 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
3
3
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
5
5
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { isExtendedEnabled } from '../../isExtendedEnabled';
|
|
8
9
|
import { applyRevealToElement } from '../revealStyles';
|
|
@@ -277,6 +278,16 @@ var applyInlineLeafNodeStyles = function applyInlineLeafNodeStyles(_ref8) {
|
|
|
277
278
|
});
|
|
278
279
|
});
|
|
279
280
|
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Editor CSS makes `blockquote` `inline-block` for its block formatting context. Inside a widget
|
|
284
|
+
* that collapses the indicator bar: the container is an inline `span`, so its anchor rect comes from
|
|
285
|
+
* font metrics, not from an inline-level child. `flow-root` keeps the formatting context but is
|
|
286
|
+
* block-level — unlike `block`, which lets the child paragraph's top margin collapse out.
|
|
287
|
+
*/
|
|
288
|
+
var quoteBlockLevelStyle = convertToInlineCss({
|
|
289
|
+
display: 'flow-root'
|
|
290
|
+
});
|
|
280
291
|
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref9) {
|
|
281
292
|
var element = _ref9.element,
|
|
282
293
|
targetNode = _ref9.targetNode,
|
|
@@ -540,6 +551,9 @@ export var wrapBlockNodeView = function wrapBlockNodeView(_ref12) {
|
|
|
540
551
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
541
552
|
highlightInlineLeafNodes: highlightInlineLeafNodes
|
|
542
553
|
});
|
|
554
|
+
if (targetNode.type.name === 'blockquote' && fg('platform_editor_ai_show_diff_patch_1')) {
|
|
555
|
+
appendStyleToElement(nodeView, quoteBlockLevelStyle);
|
|
556
|
+
}
|
|
543
557
|
dom.append(nodeView);
|
|
544
558
|
return;
|
|
545
559
|
}
|
|
@@ -4,43 +4,98 @@ export var CONTRIBUTOR_TAG_TESTID = 'diff-contributor-tag';
|
|
|
4
4
|
export var CONTRIBUTOR_TAG_NAME_TESTID = 'diff-contributor-tag-name';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Ceiling for the tag width. A constant rather than the width of the change: a change is routinely a
|
|
8
|
+
* word or two, and clamping to it ellipsised the contributor's name — the one thing the tag exists to
|
|
9
|
+
* show. Longer names are ellipsised into the tooltip.
|
|
9
10
|
*/
|
|
10
|
-
export var
|
|
11
|
+
export var MAX_TAG_WIDTH = '200px';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The tag sits on the line above the change, so it has to paint over that line to be readable —
|
|
15
|
+
* including any diff highlight already on it, which would otherwise slice straight through the tag.
|
|
16
|
+
* Hence one level above `akEditorUnitZIndex`, where the highlights sit; exported because the
|
|
17
|
+
* change's own highlight is stacked one level below it — see `stackBelowContributorTagStyle` in
|
|
18
|
+
* `createInlineChangedDecoration`.
|
|
19
|
+
*
|
|
20
|
+
* Painting above its own highlight is only safe because the tag can never reach it: `bottom: 100%`
|
|
21
|
+
* puts the root's bottom edge exactly on the highlight's top edge, and the root's `overflow: clip`
|
|
22
|
+
* keeps every pixel the tag paints inside it.
|
|
23
|
+
*/
|
|
24
|
+
export var CONTRIBUTOR_TAG_Z_INDEX = 2;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The plugin's whole side of the tag's motion: the fade and the hidden state are
|
|
28
|
+
* `contributorTagStyles` in both EditorContentContainer stylesheets, keyed on this literal and the
|
|
29
|
+
* one below — rename in step. This package cannot import `@atlaskit/editor-core` at runtime, so the
|
|
30
|
+
* plugin emits the hook and editor-core owns the rule, as `VanillaTooltip` does with
|
|
31
|
+
* `VANILLA_TOOLTIP_DEFAULT_CLASS`.
|
|
32
|
+
*/
|
|
33
|
+
export var CONTRIBUTOR_TAG_CLASS = 'ak-editor-diff-contributor-tag';
|
|
34
|
+
|
|
35
|
+
/** Toggled by the controller to move the tag between the fade's two ends. */
|
|
36
|
+
export var CONTRIBUTOR_TAG_REVEALED_ATTRIBUTE = 'data-revealed';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Backstop for removing a fading-out tag: a cancelled transition fires no `transitionend`. Must stay
|
|
40
|
+
* above the fade's 600ms, which lives in another package's stylesheet and cannot be read back as a
|
|
41
|
+
* number — hence the wide margin. Raise in step with that duration.
|
|
42
|
+
*/
|
|
43
|
+
export var TAG_EXIT_FALLBACK_MS = 1200;
|
|
11
44
|
|
|
12
45
|
// Positioned against the host widget its decoration renders on the change's first character:
|
|
13
46
|
// `bottom: 100%` lifts the tag onto the line above, `inset-inline-start` starts it on that
|
|
14
47
|
// character.
|
|
15
48
|
var constraintStyle = convertToInlineCss({
|
|
16
|
-
|
|
49
|
+
// `flex`, not `block`: a block box lays the tag on a line box whose strut is the *paragraph's*
|
|
50
|
+
// line-height (~24px) against the tag's ~20px, so `bottom: 100%` pins that leftover strut to the
|
|
51
|
+
// change and the tag floats above it. A flex container has no line box.
|
|
52
|
+
display: 'flex',
|
|
17
53
|
position: 'absolute',
|
|
18
54
|
bottom: '100%',
|
|
19
55
|
insetInlineStart: 0,
|
|
56
|
+
// On the root, since that is the absolutely positioned box; the tag below fills it.
|
|
57
|
+
maxWidth: MAX_TAG_WIDTH,
|
|
20
58
|
minWidth: 0,
|
|
21
|
-
//
|
|
22
|
-
|
|
59
|
+
// This box's bottom edge is the join with the highlight, and the tag paints *above* that
|
|
60
|
+
// highlight — so anything spilling past this edge would read as the tag laid on top of the change
|
|
61
|
+
// rather than attached to it. The reveal's `translateY` is exactly that spill: it starts the tag
|
|
62
|
+
// 4px low, and clipping the part that hangs over the highlight turns the rise into an unfurl out
|
|
63
|
+
// of the join. `clip`, not `hidden`: `hidden` would make this a scroll container, and focusing the
|
|
64
|
+
// tag mid-reveal would scroll it 4px out of alignment for good.
|
|
65
|
+
//
|
|
66
|
+
// The tooltip is unaffected — it is a `popover`, so it paints in the top layer, which no
|
|
67
|
+
// ancestor's clip reaches.
|
|
68
|
+
overflow: 'clip',
|
|
69
|
+
zIndex: CONTRIBUTOR_TAG_Z_INDEX,
|
|
23
70
|
// It renders inside the document and it is not content: dragging a selection across the change
|
|
24
71
|
// must not select it.
|
|
25
72
|
userSelect: 'none'
|
|
26
73
|
});
|
|
27
74
|
|
|
28
|
-
// `backgroundColor
|
|
29
|
-
//
|
|
75
|
+
// `backgroundColor` comes from the model, and is set by the controller. `opacity`, `pointer-events`
|
|
76
|
+
// and the transition between their two states are in `contributorTagStyles` — see
|
|
77
|
+
// `CONTRIBUTOR_TAG_CLASS`.
|
|
30
78
|
var tagStyle = convertToInlineCss({
|
|
31
79
|
display: 'inline-flex',
|
|
32
80
|
alignItems: 'center',
|
|
33
81
|
gap: "var(--ds-space-050, 4px)",
|
|
34
|
-
// Never wider than the
|
|
82
|
+
// Never wider than `MAX_TAG_WIDTH` on the root; overflow is ellipsised on the name below.
|
|
35
83
|
maxWidth: '100%',
|
|
36
84
|
minWidth: 0,
|
|
37
85
|
overflow: 'hidden',
|
|
38
86
|
paddingInline: "var(--ds-space-050, 4px)",
|
|
39
87
|
paddingBlock: "var(--ds-space-025, 2px)",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
// Top corners only: the bottom edge butts onto the change, and a rounded corner there would let
|
|
89
|
+
// the page background through at the join.
|
|
90
|
+
borderTopLeftRadius: "var(--ds-radius-small, 4px)",
|
|
91
|
+
borderTopRightRadius: "var(--ds-radius-small, 4px)",
|
|
92
|
+
borderBottomLeftRadius: 0,
|
|
93
|
+
borderBottomRightRadius: 0,
|
|
94
|
+
// Deliberately no bottom border: the change already carries the accent as its own underline, and
|
|
95
|
+
// a second rule directly above it reads as two objects rather than one label on one change.
|
|
96
|
+
//
|
|
97
|
+
// Deliberately no `elevation.shadow.overlay`: its `0 8px 12px` offset casts downwards onto the
|
|
98
|
+
// change, which reads as a gap between the tag and the content it captions.
|
|
44
99
|
font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
45
100
|
whiteSpace: 'nowrap',
|
|
46
101
|
boxSizing: 'border-box'
|
|
@@ -91,6 +146,7 @@ var createSpan = function createSpan(doc, style) {
|
|
|
91
146
|
export var buildContributorTagDom = function buildContributorTagDom(doc) {
|
|
92
147
|
var root = createSpan(doc, constraintStyle);
|
|
93
148
|
var tag = createSpan(doc, tagStyle, {
|
|
149
|
+
class: CONTRIBUTOR_TAG_CLASS,
|
|
94
150
|
'data-testid': CONTRIBUTOR_TAG_TESTID,
|
|
95
151
|
// Deliberately no `aria-label`: it would be announced ahead of the element's contents, but
|
|
96
152
|
// design requires the contributor *after* the change — hence the visually hidden label.
|