@atlaskit/editor-plugin-show-diff 16.0.5 → 16.0.6
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 +11 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +82 -8
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +7 -1
- package/dist/cjs/ui/ContributorTag/contributorTagController.js +38 -1
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +79 -8
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +7 -1
- package/dist/es2019/ui/ContributorTag/contributorTagController.js +37 -2
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +79 -8
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +7 -1
- package/dist/esm/ui/ContributorTag/contributorTagController.js +39 -2
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +25 -4
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +11 -0
- package/dist/types/ui/ContributorTag/contributorTagController.d.ts +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 16.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9e68346721d6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e68346721d6d) -
|
|
8
|
+
Show deleted text in the contributor's colour, strikethrough included, and hold its background
|
|
9
|
+
highlight back until the change is active or hovered. When it arrives, the highlight is a light
|
|
10
|
+
tint under a darker contributor-hue underline — the same treatment hovered and active, rather than
|
|
11
|
+
deepening the background when active.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 16.0.5
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.DELETED_HIGHLIGHT_BORDER_VAR = exports.DELETED_HIGHLIGHT_BG_VAR = void 0;
|
|
7
8
|
exports.buildAddedCellOverlayRoundedStyle = buildAddedCellOverlayRoundedStyle;
|
|
8
9
|
exports.buildAddedCellOverlayStyle = buildAddedCellOverlayStyle;
|
|
9
10
|
exports.buildAddedCellOverlayStyleNew = buildAddedCellOverlayStyleNew;
|
|
@@ -66,6 +67,8 @@ exports.buildInsertStyleRuleNodeNew = buildInsertStyleRuleNodeNew;
|
|
|
66
67
|
exports.buildInsertedBlockNodeStyle = buildInsertedBlockNodeStyle;
|
|
67
68
|
exports.buildInsertedInlineStyle = buildInsertedInlineStyle;
|
|
68
69
|
exports.getAccentTokens = getAccentTokens;
|
|
70
|
+
exports.getDeletedHighlightHoverBorderColor = getDeletedHighlightHoverBorderColor;
|
|
71
|
+
exports.getDeletedHighlightHoverColor = getDeletedHighlightHoverColor;
|
|
69
72
|
exports.getDeletedInlineRevealColors = getDeletedInlineRevealColors;
|
|
70
73
|
exports.getInsertedInlineRevealColors = getInsertedInlineRevealColors;
|
|
71
74
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -73,6 +76,21 @@ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
|
73
76
|
var _getStandardDeletedTextDecorationStyle = require("./getStandardDeletedTextDecorationStyle");
|
|
74
77
|
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; }
|
|
75
78
|
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; }
|
|
79
|
+
/**
|
|
80
|
+
* Hover highlight for deleted text under an 'onEmphasis' scheme. Inline styles cannot express
|
|
81
|
+
* `:hover`, so the resting style resolves its background from this property and
|
|
82
|
+
* `ContributorTagController` sets it while the change is hovered. Custom properties inherit, so
|
|
83
|
+
* setting it on the element carrying `data-diff-id` also reaches the inner wrappers a
|
|
84
|
+
* deleted-content widget paints its background on.
|
|
85
|
+
*/
|
|
86
|
+
var DELETED_HIGHLIGHT_BG_VAR = exports.DELETED_HIGHLIGHT_BG_VAR = '--show-diff-deleted-highlight-bg';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Bottom border of that same hover highlight, kept separate from `DELETED_HIGHLIGHT_BG_VAR` so an
|
|
90
|
+
* 'underline' scheme can darken the border without darkening the tint behind it.
|
|
91
|
+
*/
|
|
92
|
+
var DELETED_HIGHLIGHT_BORDER_VAR = exports.DELETED_HIGHLIGHT_BORDER_VAR = '--show-diff-deleted-highlight-border';
|
|
93
|
+
|
|
76
94
|
// token() is a build-time transform needing static literals, so pre-compute every colour's
|
|
77
95
|
// tokens here and index by name at runtime.
|
|
78
96
|
|
|
@@ -639,20 +657,52 @@ function buildDeletedDecorationMarkerVariableSimple(colors) {
|
|
|
639
657
|
});
|
|
640
658
|
}
|
|
641
659
|
|
|
642
|
-
/**
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
660
|
+
/** Whether the emphasised state is stated in the bottom border rather than a deeper highlight. */
|
|
661
|
+
function usesUnderlineEmphasis(colors) {
|
|
662
|
+
return colors.deletedInlineActiveEmphasis === 'underline';
|
|
663
|
+
}
|
|
664
|
+
|
|
646
665
|
/** Extended deleted inline style — background highlight with an accent or background-matched bottom border. */
|
|
647
666
|
function buildDeletedInlineContentStyleExtended(colors) {
|
|
648
667
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
649
|
-
|
|
668
|
+
// Resting 'onEmphasis' paints nothing; the highlight arrives when the hover variables are set. The
|
|
669
|
+
// active state takes the literal branch below, so hover cannot disturb it.
|
|
670
|
+
if (colors.deletedInlineHighlight === 'onEmphasis' && !isActive) {
|
|
671
|
+
return (0, _lazyNodeView.convertToInlineCss)({
|
|
672
|
+
backgroundColor: "var(".concat(DELETED_HIGHLIGHT_BG_VAR, ", transparent)"),
|
|
673
|
+
// Reserved while transparent, so the highlight arriving does not shift the text.
|
|
674
|
+
borderBottom: "2px solid var(".concat(DELETED_HIGHLIGHT_BORDER_VAR, ", transparent)"),
|
|
675
|
+
padding: "1px 0 2px"
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Under 'underline' emphasis the highlight stays on its resting tint — the same one hover paints —
|
|
680
|
+
// so only the border carries the emphasis.
|
|
681
|
+
var isUnderlineEmphasis = isActive && usesUnderlineEmphasis(colors);
|
|
682
|
+
var backgroundColor = isActive && !isUnderlineEmphasis && colors.deletedInlineBorderTone === 'background' ? bgSubtlerPressed(colors.deleteActiveColor) : bgSubtlest(colors.deleteColor);
|
|
683
|
+
var borderColor = isUnderlineEmphasis ? borderAccent(colors.deleteActiveColor) : colors.deletedInlineBorderTone === 'background' ? backgroundColor : borderAccent(colors.deleteColor);
|
|
650
684
|
return (0, _lazyNodeView.convertToInlineCss)({
|
|
651
685
|
backgroundColor: backgroundColor,
|
|
652
|
-
borderBottom: "2px solid ".concat(
|
|
686
|
+
borderBottom: "2px solid ".concat(borderColor),
|
|
653
687
|
padding: "1px 0 2px"
|
|
654
688
|
});
|
|
655
689
|
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Glyph opacity for the 'glyphTint' treatment. 'onEmphasis' schemes are opaque in every state: with
|
|
693
|
+
* no highlight behind the glyph at rest, the accent text token has to carry the contrast on its own.
|
|
694
|
+
*/
|
|
695
|
+
function deletedGlyphOpacity(colors, state) {
|
|
696
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
697
|
+
return 1;
|
|
698
|
+
}
|
|
699
|
+
if (state === 'active') {
|
|
700
|
+
return colors.deleteTextColor ? 0.83 : 1;
|
|
701
|
+
}
|
|
702
|
+
return colors.deleteTextColor || state === 'new' ? 0.83 : 0.6;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** 'glyphTint' deleted inline style — tints the glyph itself via `color:`. */
|
|
656
706
|
function buildDeletedInlineStyleStandard(colors, state) {
|
|
657
707
|
var _colors$deleteTextCol5;
|
|
658
708
|
if (state === 'active') {
|
|
@@ -662,14 +712,14 @@ function buildDeletedInlineStyleStandard(colors, state) {
|
|
|
662
712
|
}, (0, _getStandardDeletedTextDecorationStyle.getStandardDeletedTextDecorationStyle)()), {}, {
|
|
663
713
|
textDecorationColor: textAccent((_colors$deleteTextCol4 = colors.deleteTextColor) !== null && _colors$deleteTextCol4 !== void 0 ? _colors$deleteTextCol4 : colors.deleteColor),
|
|
664
714
|
position: 'relative',
|
|
665
|
-
opacity: colors
|
|
715
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
666
716
|
}));
|
|
667
717
|
}
|
|
668
718
|
return (0, _lazyNodeView.convertToInlineCss)(_objectSpread(_objectSpread({
|
|
669
719
|
color: textAccent((_colors$deleteTextCol5 = colors.deleteTextColor) !== null && _colors$deleteTextCol5 !== void 0 ? _colors$deleteTextCol5 : colors.deleteColor)
|
|
670
720
|
}, (0, _getStandardDeletedTextDecorationStyle.getStandardDeletedTextDecorationStyle)()), {}, {
|
|
671
721
|
position: 'relative',
|
|
672
|
-
opacity: colors
|
|
722
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
673
723
|
}));
|
|
674
724
|
}
|
|
675
725
|
|
|
@@ -821,12 +871,36 @@ function getInsertedInlineRevealColors(colors, isActive, hideAddedDiffsUnderline
|
|
|
821
871
|
* reveal keeps as-is.
|
|
822
872
|
*/
|
|
823
873
|
function getDeletedInlineRevealColors(colors) {
|
|
874
|
+
// Nothing to wipe in where the resting state paints no highlight.
|
|
875
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
876
|
+
return {
|
|
877
|
+
background: 'transparent',
|
|
878
|
+
border: 'transparent'
|
|
879
|
+
};
|
|
880
|
+
}
|
|
824
881
|
return {
|
|
825
882
|
background: bgSubtlest(colors.deleteColor),
|
|
826
883
|
border: borderAccent(colors.deleteColor)
|
|
827
884
|
};
|
|
828
885
|
}
|
|
829
886
|
|
|
887
|
+
/**
|
|
888
|
+
* Value for `DELETED_HIGHLIGHT_BG_VAR` while a change is hovered — the same tint an 'always' scheme
|
|
889
|
+
* paints at rest, so hovering restores the appearance rather than introducing a third one.
|
|
890
|
+
*/
|
|
891
|
+
function getDeletedHighlightHoverColor(colors) {
|
|
892
|
+
return bgSubtlest(colors.deleteColor);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Value for `DELETED_HIGHLIGHT_BORDER_VAR` while a change is hovered. An 'underline' scheme states
|
|
897
|
+
* both hover and active in the border, so the two read alike; anything else keeps the border on the
|
|
898
|
+
* tint, as it was before the border had a variable of its own.
|
|
899
|
+
*/
|
|
900
|
+
function getDeletedHighlightHoverBorderColor(colors) {
|
|
901
|
+
return usesUnderlineEmphasis(colors) ? borderAccent(colors.deleteActiveColor) : getDeletedHighlightHoverColor(colors);
|
|
902
|
+
}
|
|
903
|
+
|
|
830
904
|
/** The three visual states deleted inline content can be in. */
|
|
831
905
|
|
|
832
906
|
/**
|
|
@@ -30,6 +30,7 @@ var traditionalScheme = exports.traditionalScheme = {
|
|
|
30
30
|
roundedAddedCellOverlayInheritsBorder: true,
|
|
31
31
|
insertedInlineTreatment: 'underline',
|
|
32
32
|
deletedInlineTreatment: 'strikethrough',
|
|
33
|
+
deletedInlineHighlight: 'always',
|
|
33
34
|
insertedNodeEmphasis: 'stateful',
|
|
34
35
|
deletedNodeEmphasis: 'stateful',
|
|
35
36
|
deletedQuoteNodeActiveTone: 'backgroundPressed',
|
|
@@ -58,6 +59,7 @@ var standardScheme = exports.standardScheme = {
|
|
|
58
59
|
roundedAddedCellOverlayInheritsBorder: false,
|
|
59
60
|
insertedInlineTreatment: 'borderBottom',
|
|
60
61
|
deletedInlineTreatment: 'glyphTint',
|
|
62
|
+
deletedInlineHighlight: 'always',
|
|
61
63
|
insertedNodeEmphasis: 'static',
|
|
62
64
|
deletedNodeEmphasis: 'static',
|
|
63
65
|
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
@@ -70,7 +72,11 @@ var createAttributionScheme = function createAttributionScheme(color) {
|
|
|
70
72
|
insertActiveColor: color,
|
|
71
73
|
deleteColor: color,
|
|
72
74
|
deletedInlineBorderTone: 'background',
|
|
73
|
-
|
|
75
|
+
// Like the public schemes, the highlight holds its resting tint when active.
|
|
76
|
+
deletedInlineActiveEmphasis: 'underline',
|
|
77
|
+
// The contributor's own hue, so deleted text reads as theirs without a highlight behind it.
|
|
78
|
+
deleteTextColor: color,
|
|
79
|
+
deletedInlineHighlight: 'onEmphasis',
|
|
74
80
|
deleteActiveColor: color,
|
|
75
81
|
deletedCellColor: color
|
|
76
82
|
});
|
|
@@ -120,6 +120,8 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
120
120
|
/** Guards a deferred bind that a later model change has already superseded. */
|
|
121
121
|
(0, _defineProperty2.default)(this, "bindToken", 0);
|
|
122
122
|
(0, _defineProperty2.default)(this, "fullLabel", '');
|
|
123
|
+
/** The bound highlights themselves, so hover can write the deleted highlight onto them. */
|
|
124
|
+
(0, _defineProperty2.default)(this, "highlightElements", []);
|
|
123
125
|
(0, _defineProperty2.default)(this, "isDestroyed", false);
|
|
124
126
|
/** Last visibility written, so a teardown knows whether there is anything on screen to fade. */
|
|
125
127
|
(0, _defineProperty2.default)(this, "isVisible", false);
|
|
@@ -387,6 +389,30 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
387
389
|
var isVisible = Boolean((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.isActive) || this.revealSources.size > 0;
|
|
388
390
|
this.isVisible = isVisible;
|
|
389
391
|
setRevealed(this.dom.tag, isVisible);
|
|
392
|
+
this.applyHighlightHover();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Brings the deleted highlight up alongside the tag, for the schemes that paint none at rest —
|
|
397
|
+
* see `DELETED_HIGHLIGHT_BG_VAR`. Keyed on `revealSources` rather than on the tag's own
|
|
398
|
+
* visibility: an active change paints its highlight from its decoration style, which this must
|
|
399
|
+
* not be able to override.
|
|
400
|
+
*/
|
|
401
|
+
}, {
|
|
402
|
+
key: "applyHighlightHover",
|
|
403
|
+
value: function applyHighlightHover() {
|
|
404
|
+
var _this$model$colorSche, _this$model2;
|
|
405
|
+
var isHovered = this.revealSources.size > 0;
|
|
406
|
+
var colors = _schemes.colorSchemeRegistry[(_this$model$colorSche = (_this$model2 = this.model) === null || _this$model2 === void 0 ? void 0 : _this$model2.colorScheme) !== null && _this$model$colorSche !== void 0 ? _this$model$colorSche : 'standard'];
|
|
407
|
+
this.highlightElements.forEach(function (highlight) {
|
|
408
|
+
if (isHovered) {
|
|
409
|
+
highlight.style.setProperty(_factory.DELETED_HIGHLIGHT_BG_VAR, (0, _factory.getDeletedHighlightHoverColor)(colors));
|
|
410
|
+
highlight.style.setProperty(_factory.DELETED_HIGHLIGHT_BORDER_VAR, (0, _factory.getDeletedHighlightHoverBorderColor)(colors));
|
|
411
|
+
} else {
|
|
412
|
+
highlight.style.removeProperty(_factory.DELETED_HIGHLIGHT_BG_VAR);
|
|
413
|
+
highlight.style.removeProperty(_factory.DELETED_HIGHLIGHT_BORDER_VAR);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
390
416
|
}
|
|
391
417
|
|
|
392
418
|
/**
|
|
@@ -494,7 +520,8 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
494
520
|
// `bindAll` takes a single target, and a change can render more than one highlight. Each is its
|
|
495
521
|
// own member of `revealSources`, so the pointer can cross between them without the set
|
|
496
522
|
// emptying.
|
|
497
|
-
this.
|
|
523
|
+
this.highlightElements = Array.from(highlights);
|
|
524
|
+
this.unbindHighlights = this.highlightElements.map(function (highlight) {
|
|
498
525
|
return (0, _bindEventListener.bindAll)(highlight, [{
|
|
499
526
|
type: 'mouseenter',
|
|
500
527
|
listener: _this6.trackRevealSource(highlight, true)
|
|
@@ -503,6 +530,9 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
503
530
|
listener: _this6.trackRevealSource(highlight, false)
|
|
504
531
|
}]);
|
|
505
532
|
});
|
|
533
|
+
// The pointer may already be over a highlight by the time this binds, a draw pass after it
|
|
534
|
+
// entered.
|
|
535
|
+
this.applyHighlightHover();
|
|
506
536
|
}
|
|
507
537
|
}, {
|
|
508
538
|
key: "unbindHighlightState",
|
|
@@ -511,6 +541,13 @@ var ContributorTagController = exports.ContributorTagController = /*#__PURE__*/f
|
|
|
511
541
|
return unbind();
|
|
512
542
|
});
|
|
513
543
|
this.unbindHighlights = [];
|
|
544
|
+
// Cleared before the elements are released: ProseMirror reuses decoration DOM, so a hover left
|
|
545
|
+
// written on one would paint a highlight nothing is holding up.
|
|
546
|
+
this.highlightElements.forEach(function (highlight) {
|
|
547
|
+
highlight.style.removeProperty(_factory.DELETED_HIGHLIGHT_BG_VAR);
|
|
548
|
+
highlight.style.removeProperty(_factory.DELETED_HIGHLIGHT_BORDER_VAR);
|
|
549
|
+
});
|
|
550
|
+
this.highlightElements = [];
|
|
514
551
|
}
|
|
515
552
|
}]);
|
|
516
553
|
}();
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { getStandardDeletedTextDecorationStyle } from './getStandardDeletedTextDecorationStyle';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Hover highlight for deleted text under an 'onEmphasis' scheme. Inline styles cannot express
|
|
6
|
+
* `:hover`, so the resting style resolves its background from this property and
|
|
7
|
+
* `ContributorTagController` sets it while the change is hovered. Custom properties inherit, so
|
|
8
|
+
* setting it on the element carrying `data-diff-id` also reaches the inner wrappers a
|
|
9
|
+
* deleted-content widget paints its background on.
|
|
10
|
+
*/
|
|
11
|
+
export const DELETED_HIGHLIGHT_BG_VAR = '--show-diff-deleted-highlight-bg';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Bottom border of that same hover highlight, kept separate from `DELETED_HIGHLIGHT_BG_VAR` so an
|
|
15
|
+
* 'underline' scheme can darken the border without darkening the tint behind it.
|
|
16
|
+
*/
|
|
17
|
+
export const DELETED_HIGHLIGHT_BORDER_VAR = '--show-diff-deleted-highlight-border';
|
|
18
|
+
|
|
4
19
|
// token() is a build-time transform needing static literals, so pre-compute every colour's
|
|
5
20
|
// tokens here and index by name at runtime.
|
|
6
21
|
|
|
@@ -569,19 +584,51 @@ export function buildDeletedDecorationMarkerVariableSimple(colors) {
|
|
|
569
584
|
});
|
|
570
585
|
}
|
|
571
586
|
|
|
572
|
-
/**
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
587
|
+
/** Whether the emphasised state is stated in the bottom border rather than a deeper highlight. */
|
|
588
|
+
function usesUnderlineEmphasis(colors) {
|
|
589
|
+
return colors.deletedInlineActiveEmphasis === 'underline';
|
|
590
|
+
}
|
|
591
|
+
|
|
576
592
|
/** Extended deleted inline style — background highlight with an accent or background-matched bottom border. */
|
|
577
593
|
export function buildDeletedInlineContentStyleExtended(colors, isActive = false) {
|
|
578
|
-
|
|
594
|
+
// Resting 'onEmphasis' paints nothing; the highlight arrives when the hover variables are set. The
|
|
595
|
+
// active state takes the literal branch below, so hover cannot disturb it.
|
|
596
|
+
if (colors.deletedInlineHighlight === 'onEmphasis' && !isActive) {
|
|
597
|
+
return convertToInlineCss({
|
|
598
|
+
backgroundColor: `var(${DELETED_HIGHLIGHT_BG_VAR}, transparent)`,
|
|
599
|
+
// Reserved while transparent, so the highlight arriving does not shift the text.
|
|
600
|
+
borderBottom: `2px solid var(${DELETED_HIGHLIGHT_BORDER_VAR}, transparent)`,
|
|
601
|
+
padding: `1px 0 2px`
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Under 'underline' emphasis the highlight stays on its resting tint — the same one hover paints —
|
|
606
|
+
// so only the border carries the emphasis.
|
|
607
|
+
const isUnderlineEmphasis = isActive && usesUnderlineEmphasis(colors);
|
|
608
|
+
const backgroundColor = isActive && !isUnderlineEmphasis && colors.deletedInlineBorderTone === 'background' ? bgSubtlerPressed(colors.deleteActiveColor) : bgSubtlest(colors.deleteColor);
|
|
609
|
+
const borderColor = isUnderlineEmphasis ? borderAccent(colors.deleteActiveColor) : colors.deletedInlineBorderTone === 'background' ? backgroundColor : borderAccent(colors.deleteColor);
|
|
579
610
|
return convertToInlineCss({
|
|
580
611
|
backgroundColor,
|
|
581
|
-
borderBottom: `2px solid ${
|
|
612
|
+
borderBottom: `2px solid ${borderColor}`,
|
|
582
613
|
padding: `1px 0 2px`
|
|
583
614
|
});
|
|
584
615
|
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Glyph opacity for the 'glyphTint' treatment. 'onEmphasis' schemes are opaque in every state: with
|
|
619
|
+
* no highlight behind the glyph at rest, the accent text token has to carry the contrast on its own.
|
|
620
|
+
*/
|
|
621
|
+
function deletedGlyphOpacity(colors, state) {
|
|
622
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
623
|
+
return 1;
|
|
624
|
+
}
|
|
625
|
+
if (state === 'active') {
|
|
626
|
+
return colors.deleteTextColor ? 0.83 : 1;
|
|
627
|
+
}
|
|
628
|
+
return colors.deleteTextColor || state === 'new' ? 0.83 : 0.6;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** 'glyphTint' deleted inline style — tints the glyph itself via `color:`. */
|
|
585
632
|
export function buildDeletedInlineStyleStandard(colors, state) {
|
|
586
633
|
var _colors$deleteTextCol5;
|
|
587
634
|
if (state === 'active') {
|
|
@@ -591,14 +638,14 @@ export function buildDeletedInlineStyleStandard(colors, state) {
|
|
|
591
638
|
...getStandardDeletedTextDecorationStyle(),
|
|
592
639
|
textDecorationColor: textAccent((_colors$deleteTextCol4 = colors.deleteTextColor) !== null && _colors$deleteTextCol4 !== void 0 ? _colors$deleteTextCol4 : colors.deleteColor),
|
|
593
640
|
position: 'relative',
|
|
594
|
-
opacity: colors
|
|
641
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
595
642
|
});
|
|
596
643
|
}
|
|
597
644
|
return convertToInlineCss({
|
|
598
645
|
color: textAccent((_colors$deleteTextCol5 = colors.deleteTextColor) !== null && _colors$deleteTextCol5 !== void 0 ? _colors$deleteTextCol5 : colors.deleteColor),
|
|
599
646
|
...getStandardDeletedTextDecorationStyle(),
|
|
600
647
|
position: 'relative',
|
|
601
|
-
opacity: colors
|
|
648
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
602
649
|
});
|
|
603
650
|
}
|
|
604
651
|
|
|
@@ -752,12 +799,36 @@ export function getInsertedInlineRevealColors(colors, isActive, hideAddedDiffsUn
|
|
|
752
799
|
* reveal keeps as-is.
|
|
753
800
|
*/
|
|
754
801
|
export function getDeletedInlineRevealColors(colors) {
|
|
802
|
+
// Nothing to wipe in where the resting state paints no highlight.
|
|
803
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
804
|
+
return {
|
|
805
|
+
background: 'transparent',
|
|
806
|
+
border: 'transparent'
|
|
807
|
+
};
|
|
808
|
+
}
|
|
755
809
|
return {
|
|
756
810
|
background: bgSubtlest(colors.deleteColor),
|
|
757
811
|
border: borderAccent(colors.deleteColor)
|
|
758
812
|
};
|
|
759
813
|
}
|
|
760
814
|
|
|
815
|
+
/**
|
|
816
|
+
* Value for `DELETED_HIGHLIGHT_BG_VAR` while a change is hovered — the same tint an 'always' scheme
|
|
817
|
+
* paints at rest, so hovering restores the appearance rather than introducing a third one.
|
|
818
|
+
*/
|
|
819
|
+
export function getDeletedHighlightHoverColor(colors) {
|
|
820
|
+
return bgSubtlest(colors.deleteColor);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Value for `DELETED_HIGHLIGHT_BORDER_VAR` while a change is hovered. An 'underline' scheme states
|
|
825
|
+
* both hover and active in the border, so the two read alike; anything else keeps the border on the
|
|
826
|
+
* tint, as it was before the border had a variable of its own.
|
|
827
|
+
*/
|
|
828
|
+
export function getDeletedHighlightHoverBorderColor(colors) {
|
|
829
|
+
return usesUnderlineEmphasis(colors) ? borderAccent(colors.deleteActiveColor) : getDeletedHighlightHoverColor(colors);
|
|
830
|
+
}
|
|
831
|
+
|
|
761
832
|
/** The three visual states deleted inline content can be in. */
|
|
762
833
|
|
|
763
834
|
/**
|
|
@@ -21,6 +21,7 @@ export const traditionalScheme = {
|
|
|
21
21
|
roundedAddedCellOverlayInheritsBorder: true,
|
|
22
22
|
insertedInlineTreatment: 'underline',
|
|
23
23
|
deletedInlineTreatment: 'strikethrough',
|
|
24
|
+
deletedInlineHighlight: 'always',
|
|
24
25
|
insertedNodeEmphasis: 'stateful',
|
|
25
26
|
deletedNodeEmphasis: 'stateful',
|
|
26
27
|
deletedQuoteNodeActiveTone: 'backgroundPressed',
|
|
@@ -49,6 +50,7 @@ export const standardScheme = {
|
|
|
49
50
|
roundedAddedCellOverlayInheritsBorder: false,
|
|
50
51
|
insertedInlineTreatment: 'borderBottom',
|
|
51
52
|
deletedInlineTreatment: 'glyphTint',
|
|
53
|
+
deletedInlineHighlight: 'always',
|
|
52
54
|
insertedNodeEmphasis: 'static',
|
|
53
55
|
deletedNodeEmphasis: 'static',
|
|
54
56
|
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
@@ -62,7 +64,11 @@ const createAttributionScheme = color => {
|
|
|
62
64
|
insertActiveColor: color,
|
|
63
65
|
deleteColor: color,
|
|
64
66
|
deletedInlineBorderTone: 'background',
|
|
65
|
-
|
|
67
|
+
// Like the public schemes, the highlight holds its resting tint when active.
|
|
68
|
+
deletedInlineActiveEmphasis: 'underline',
|
|
69
|
+
// The contributor's own hue, so deleted text reads as theirs without a highlight behind it.
|
|
70
|
+
deleteTextColor: color,
|
|
71
|
+
deletedInlineHighlight: 'onEmphasis',
|
|
66
72
|
deleteActiveColor: color,
|
|
67
73
|
deletedCellColor: color
|
|
68
74
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { bind, bindAll } from 'bind-event-listener';
|
|
3
3
|
import { VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
4
|
-
import { getAccentTokens } from '../../pm-plugins/decorations/colorSchemes/factory';
|
|
4
|
+
import { DELETED_HIGHLIGHT_BG_VAR, DELETED_HIGHLIGHT_BORDER_VAR, getAccentTokens, getDeletedHighlightHoverBorderColor, getDeletedHighlightHoverColor } from '../../pm-plugins/decorations/colorSchemes/factory';
|
|
5
5
|
import { colorSchemeRegistry } from '../../pm-plugins/decorations/colorSchemes/schemes';
|
|
6
6
|
import { buildContributorTagDom, CONTRIBUTOR_TAG_REVEALED_ATTRIBUTE, CONTRIBUTOR_TAG_TOOLTIP_STYLES, TAG_EXIT_FALLBACK_MS } from './buildContributorTagDom';
|
|
7
7
|
import { contributorAvatarRenderer } from './contributorAvatarRenderer';
|
|
@@ -104,6 +104,8 @@ export class ContributorTagController {
|
|
|
104
104
|
/** Guards a deferred bind that a later model change has already superseded. */
|
|
105
105
|
_defineProperty(this, "bindToken", 0);
|
|
106
106
|
_defineProperty(this, "fullLabel", '');
|
|
107
|
+
/** The bound highlights themselves, so hover can write the deleted highlight onto them. */
|
|
108
|
+
_defineProperty(this, "highlightElements", []);
|
|
107
109
|
_defineProperty(this, "isDestroyed", false);
|
|
108
110
|
/** Last visibility written, so a teardown knows whether there is anything on screen to fade. */
|
|
109
111
|
_defineProperty(this, "isVisible", false);
|
|
@@ -346,6 +348,28 @@ export class ContributorTagController {
|
|
|
346
348
|
const isVisible = Boolean((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.isActive) || this.revealSources.size > 0;
|
|
347
349
|
this.isVisible = isVisible;
|
|
348
350
|
setRevealed(this.dom.tag, isVisible);
|
|
351
|
+
this.applyHighlightHover();
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Brings the deleted highlight up alongside the tag, for the schemes that paint none at rest —
|
|
356
|
+
* see `DELETED_HIGHLIGHT_BG_VAR`. Keyed on `revealSources` rather than on the tag's own
|
|
357
|
+
* visibility: an active change paints its highlight from its decoration style, which this must
|
|
358
|
+
* not be able to override.
|
|
359
|
+
*/
|
|
360
|
+
applyHighlightHover() {
|
|
361
|
+
var _this$model$colorSche, _this$model2;
|
|
362
|
+
const isHovered = this.revealSources.size > 0;
|
|
363
|
+
const colors = colorSchemeRegistry[(_this$model$colorSche = (_this$model2 = this.model) === null || _this$model2 === void 0 ? void 0 : _this$model2.colorScheme) !== null && _this$model$colorSche !== void 0 ? _this$model$colorSche : 'standard'];
|
|
364
|
+
this.highlightElements.forEach(highlight => {
|
|
365
|
+
if (isHovered) {
|
|
366
|
+
highlight.style.setProperty(DELETED_HIGHLIGHT_BG_VAR, getDeletedHighlightHoverColor(colors));
|
|
367
|
+
highlight.style.setProperty(DELETED_HIGHLIGHT_BORDER_VAR, getDeletedHighlightHoverBorderColor(colors));
|
|
368
|
+
} else {
|
|
369
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BG_VAR);
|
|
370
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BORDER_VAR);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
349
373
|
}
|
|
350
374
|
|
|
351
375
|
/**
|
|
@@ -443,16 +467,27 @@ export class ContributorTagController {
|
|
|
443
467
|
// `bindAll` takes a single target, and a change can render more than one highlight. Each is its
|
|
444
468
|
// own member of `revealSources`, so the pointer can cross between them without the set
|
|
445
469
|
// emptying.
|
|
446
|
-
this.
|
|
470
|
+
this.highlightElements = Array.from(highlights);
|
|
471
|
+
this.unbindHighlights = this.highlightElements.map(highlight => bindAll(highlight, [{
|
|
447
472
|
type: 'mouseenter',
|
|
448
473
|
listener: this.trackRevealSource(highlight, true)
|
|
449
474
|
}, {
|
|
450
475
|
type: 'mouseleave',
|
|
451
476
|
listener: this.trackRevealSource(highlight, false)
|
|
452
477
|
}]));
|
|
478
|
+
// The pointer may already be over a highlight by the time this binds, a draw pass after it
|
|
479
|
+
// entered.
|
|
480
|
+
this.applyHighlightHover();
|
|
453
481
|
}
|
|
454
482
|
unbindHighlightState() {
|
|
455
483
|
this.unbindHighlights.forEach(unbind => unbind());
|
|
456
484
|
this.unbindHighlights = [];
|
|
485
|
+
// Cleared before the elements are released: ProseMirror reuses decoration DOM, so a hover left
|
|
486
|
+
// written on one would paint a highlight nothing is holding up.
|
|
487
|
+
this.highlightElements.forEach(highlight => {
|
|
488
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BG_VAR);
|
|
489
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BORDER_VAR);
|
|
490
|
+
});
|
|
491
|
+
this.highlightElements = [];
|
|
457
492
|
}
|
|
458
493
|
}
|
|
@@ -4,6 +4,21 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
5
5
|
import { getStandardDeletedTextDecorationStyle } from './getStandardDeletedTextDecorationStyle';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Hover highlight for deleted text under an 'onEmphasis' scheme. Inline styles cannot express
|
|
9
|
+
* `:hover`, so the resting style resolves its background from this property and
|
|
10
|
+
* `ContributorTagController` sets it while the change is hovered. Custom properties inherit, so
|
|
11
|
+
* setting it on the element carrying `data-diff-id` also reaches the inner wrappers a
|
|
12
|
+
* deleted-content widget paints its background on.
|
|
13
|
+
*/
|
|
14
|
+
export var DELETED_HIGHLIGHT_BG_VAR = '--show-diff-deleted-highlight-bg';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Bottom border of that same hover highlight, kept separate from `DELETED_HIGHLIGHT_BG_VAR` so an
|
|
18
|
+
* 'underline' scheme can darken the border without darkening the tint behind it.
|
|
19
|
+
*/
|
|
20
|
+
export var DELETED_HIGHLIGHT_BORDER_VAR = '--show-diff-deleted-highlight-border';
|
|
21
|
+
|
|
7
22
|
// token() is a build-time transform needing static literals, so pre-compute every colour's
|
|
8
23
|
// tokens here and index by name at runtime.
|
|
9
24
|
|
|
@@ -570,20 +585,52 @@ export function buildDeletedDecorationMarkerVariableSimple(colors) {
|
|
|
570
585
|
});
|
|
571
586
|
}
|
|
572
587
|
|
|
573
|
-
/**
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
588
|
+
/** Whether the emphasised state is stated in the bottom border rather than a deeper highlight. */
|
|
589
|
+
function usesUnderlineEmphasis(colors) {
|
|
590
|
+
return colors.deletedInlineActiveEmphasis === 'underline';
|
|
591
|
+
}
|
|
592
|
+
|
|
577
593
|
/** Extended deleted inline style — background highlight with an accent or background-matched bottom border. */
|
|
578
594
|
export function buildDeletedInlineContentStyleExtended(colors) {
|
|
579
595
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
580
|
-
|
|
596
|
+
// Resting 'onEmphasis' paints nothing; the highlight arrives when the hover variables are set. The
|
|
597
|
+
// active state takes the literal branch below, so hover cannot disturb it.
|
|
598
|
+
if (colors.deletedInlineHighlight === 'onEmphasis' && !isActive) {
|
|
599
|
+
return convertToInlineCss({
|
|
600
|
+
backgroundColor: "var(".concat(DELETED_HIGHLIGHT_BG_VAR, ", transparent)"),
|
|
601
|
+
// Reserved while transparent, so the highlight arriving does not shift the text.
|
|
602
|
+
borderBottom: "2px solid var(".concat(DELETED_HIGHLIGHT_BORDER_VAR, ", transparent)"),
|
|
603
|
+
padding: "1px 0 2px"
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// Under 'underline' emphasis the highlight stays on its resting tint — the same one hover paints —
|
|
608
|
+
// so only the border carries the emphasis.
|
|
609
|
+
var isUnderlineEmphasis = isActive && usesUnderlineEmphasis(colors);
|
|
610
|
+
var backgroundColor = isActive && !isUnderlineEmphasis && colors.deletedInlineBorderTone === 'background' ? bgSubtlerPressed(colors.deleteActiveColor) : bgSubtlest(colors.deleteColor);
|
|
611
|
+
var borderColor = isUnderlineEmphasis ? borderAccent(colors.deleteActiveColor) : colors.deletedInlineBorderTone === 'background' ? backgroundColor : borderAccent(colors.deleteColor);
|
|
581
612
|
return convertToInlineCss({
|
|
582
613
|
backgroundColor: backgroundColor,
|
|
583
|
-
borderBottom: "2px solid ".concat(
|
|
614
|
+
borderBottom: "2px solid ".concat(borderColor),
|
|
584
615
|
padding: "1px 0 2px"
|
|
585
616
|
});
|
|
586
617
|
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Glyph opacity for the 'glyphTint' treatment. 'onEmphasis' schemes are opaque in every state: with
|
|
621
|
+
* no highlight behind the glyph at rest, the accent text token has to carry the contrast on its own.
|
|
622
|
+
*/
|
|
623
|
+
function deletedGlyphOpacity(colors, state) {
|
|
624
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
625
|
+
return 1;
|
|
626
|
+
}
|
|
627
|
+
if (state === 'active') {
|
|
628
|
+
return colors.deleteTextColor ? 0.83 : 1;
|
|
629
|
+
}
|
|
630
|
+
return colors.deleteTextColor || state === 'new' ? 0.83 : 0.6;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** 'glyphTint' deleted inline style — tints the glyph itself via `color:`. */
|
|
587
634
|
export function buildDeletedInlineStyleStandard(colors, state) {
|
|
588
635
|
var _colors$deleteTextCol5;
|
|
589
636
|
if (state === 'active') {
|
|
@@ -593,14 +640,14 @@ export function buildDeletedInlineStyleStandard(colors, state) {
|
|
|
593
640
|
}, getStandardDeletedTextDecorationStyle()), {}, {
|
|
594
641
|
textDecorationColor: textAccent((_colors$deleteTextCol4 = colors.deleteTextColor) !== null && _colors$deleteTextCol4 !== void 0 ? _colors$deleteTextCol4 : colors.deleteColor),
|
|
595
642
|
position: 'relative',
|
|
596
|
-
opacity: colors
|
|
643
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
597
644
|
}));
|
|
598
645
|
}
|
|
599
646
|
return convertToInlineCss(_objectSpread(_objectSpread({
|
|
600
647
|
color: textAccent((_colors$deleteTextCol5 = colors.deleteTextColor) !== null && _colors$deleteTextCol5 !== void 0 ? _colors$deleteTextCol5 : colors.deleteColor)
|
|
601
648
|
}, getStandardDeletedTextDecorationStyle()), {}, {
|
|
602
649
|
position: 'relative',
|
|
603
|
-
opacity: colors
|
|
650
|
+
opacity: deletedGlyphOpacity(colors, state)
|
|
604
651
|
}));
|
|
605
652
|
}
|
|
606
653
|
|
|
@@ -752,12 +799,36 @@ export function getInsertedInlineRevealColors(colors, isActive, hideAddedDiffsUn
|
|
|
752
799
|
* reveal keeps as-is.
|
|
753
800
|
*/
|
|
754
801
|
export function getDeletedInlineRevealColors(colors) {
|
|
802
|
+
// Nothing to wipe in where the resting state paints no highlight.
|
|
803
|
+
if (colors.deletedInlineHighlight === 'onEmphasis') {
|
|
804
|
+
return {
|
|
805
|
+
background: 'transparent',
|
|
806
|
+
border: 'transparent'
|
|
807
|
+
};
|
|
808
|
+
}
|
|
755
809
|
return {
|
|
756
810
|
background: bgSubtlest(colors.deleteColor),
|
|
757
811
|
border: borderAccent(colors.deleteColor)
|
|
758
812
|
};
|
|
759
813
|
}
|
|
760
814
|
|
|
815
|
+
/**
|
|
816
|
+
* Value for `DELETED_HIGHLIGHT_BG_VAR` while a change is hovered — the same tint an 'always' scheme
|
|
817
|
+
* paints at rest, so hovering restores the appearance rather than introducing a third one.
|
|
818
|
+
*/
|
|
819
|
+
export function getDeletedHighlightHoverColor(colors) {
|
|
820
|
+
return bgSubtlest(colors.deleteColor);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Value for `DELETED_HIGHLIGHT_BORDER_VAR` while a change is hovered. An 'underline' scheme states
|
|
825
|
+
* both hover and active in the border, so the two read alike; anything else keeps the border on the
|
|
826
|
+
* tint, as it was before the border had a variable of its own.
|
|
827
|
+
*/
|
|
828
|
+
export function getDeletedHighlightHoverBorderColor(colors) {
|
|
829
|
+
return usesUnderlineEmphasis(colors) ? borderAccent(colors.deleteActiveColor) : getDeletedHighlightHoverColor(colors);
|
|
830
|
+
}
|
|
831
|
+
|
|
761
832
|
/** The three visual states deleted inline content can be in. */
|
|
762
833
|
|
|
763
834
|
/**
|
|
@@ -24,6 +24,7 @@ export var traditionalScheme = {
|
|
|
24
24
|
roundedAddedCellOverlayInheritsBorder: true,
|
|
25
25
|
insertedInlineTreatment: 'underline',
|
|
26
26
|
deletedInlineTreatment: 'strikethrough',
|
|
27
|
+
deletedInlineHighlight: 'always',
|
|
27
28
|
insertedNodeEmphasis: 'stateful',
|
|
28
29
|
deletedNodeEmphasis: 'stateful',
|
|
29
30
|
deletedQuoteNodeActiveTone: 'backgroundPressed',
|
|
@@ -52,6 +53,7 @@ export var standardScheme = {
|
|
|
52
53
|
roundedAddedCellOverlayInheritsBorder: false,
|
|
53
54
|
insertedInlineTreatment: 'borderBottom',
|
|
54
55
|
deletedInlineTreatment: 'glyphTint',
|
|
56
|
+
deletedInlineHighlight: 'always',
|
|
55
57
|
insertedNodeEmphasis: 'static',
|
|
56
58
|
deletedNodeEmphasis: 'static',
|
|
57
59
|
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
@@ -64,7 +66,11 @@ var createAttributionScheme = function createAttributionScheme(color) {
|
|
|
64
66
|
insertActiveColor: color,
|
|
65
67
|
deleteColor: color,
|
|
66
68
|
deletedInlineBorderTone: 'background',
|
|
67
|
-
|
|
69
|
+
// Like the public schemes, the highlight holds its resting tint when active.
|
|
70
|
+
deletedInlineActiveEmphasis: 'underline',
|
|
71
|
+
// The contributor's own hue, so deleted text reads as theirs without a highlight behind it.
|
|
72
|
+
deleteTextColor: color,
|
|
73
|
+
deletedInlineHighlight: 'onEmphasis',
|
|
68
74
|
deleteActiveColor: color,
|
|
69
75
|
deletedCellColor: color
|
|
70
76
|
});
|
|
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import { bind, bindAll } from 'bind-event-listener';
|
|
6
6
|
import { VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
7
|
-
import { getAccentTokens } from '../../pm-plugins/decorations/colorSchemes/factory';
|
|
7
|
+
import { DELETED_HIGHLIGHT_BG_VAR, DELETED_HIGHLIGHT_BORDER_VAR, getAccentTokens, getDeletedHighlightHoverBorderColor, getDeletedHighlightHoverColor } from '../../pm-plugins/decorations/colorSchemes/factory';
|
|
8
8
|
import { colorSchemeRegistry } from '../../pm-plugins/decorations/colorSchemes/schemes';
|
|
9
9
|
import { buildContributorTagDom, CONTRIBUTOR_TAG_REVEALED_ATTRIBUTE, CONTRIBUTOR_TAG_TOOLTIP_STYLES, TAG_EXIT_FALLBACK_MS } from './buildContributorTagDom';
|
|
10
10
|
import { contributorAvatarRenderer } from './contributorAvatarRenderer';
|
|
@@ -113,6 +113,8 @@ export var ContributorTagController = /*#__PURE__*/function () {
|
|
|
113
113
|
/** Guards a deferred bind that a later model change has already superseded. */
|
|
114
114
|
_defineProperty(this, "bindToken", 0);
|
|
115
115
|
_defineProperty(this, "fullLabel", '');
|
|
116
|
+
/** The bound highlights themselves, so hover can write the deleted highlight onto them. */
|
|
117
|
+
_defineProperty(this, "highlightElements", []);
|
|
116
118
|
_defineProperty(this, "isDestroyed", false);
|
|
117
119
|
/** Last visibility written, so a teardown knows whether there is anything on screen to fade. */
|
|
118
120
|
_defineProperty(this, "isVisible", false);
|
|
@@ -380,6 +382,30 @@ export var ContributorTagController = /*#__PURE__*/function () {
|
|
|
380
382
|
var isVisible = Boolean((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.isActive) || this.revealSources.size > 0;
|
|
381
383
|
this.isVisible = isVisible;
|
|
382
384
|
setRevealed(this.dom.tag, isVisible);
|
|
385
|
+
this.applyHighlightHover();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Brings the deleted highlight up alongside the tag, for the schemes that paint none at rest —
|
|
390
|
+
* see `DELETED_HIGHLIGHT_BG_VAR`. Keyed on `revealSources` rather than on the tag's own
|
|
391
|
+
* visibility: an active change paints its highlight from its decoration style, which this must
|
|
392
|
+
* not be able to override.
|
|
393
|
+
*/
|
|
394
|
+
}, {
|
|
395
|
+
key: "applyHighlightHover",
|
|
396
|
+
value: function applyHighlightHover() {
|
|
397
|
+
var _this$model$colorSche, _this$model2;
|
|
398
|
+
var isHovered = this.revealSources.size > 0;
|
|
399
|
+
var colors = colorSchemeRegistry[(_this$model$colorSche = (_this$model2 = this.model) === null || _this$model2 === void 0 ? void 0 : _this$model2.colorScheme) !== null && _this$model$colorSche !== void 0 ? _this$model$colorSche : 'standard'];
|
|
400
|
+
this.highlightElements.forEach(function (highlight) {
|
|
401
|
+
if (isHovered) {
|
|
402
|
+
highlight.style.setProperty(DELETED_HIGHLIGHT_BG_VAR, getDeletedHighlightHoverColor(colors));
|
|
403
|
+
highlight.style.setProperty(DELETED_HIGHLIGHT_BORDER_VAR, getDeletedHighlightHoverBorderColor(colors));
|
|
404
|
+
} else {
|
|
405
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BG_VAR);
|
|
406
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BORDER_VAR);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
383
409
|
}
|
|
384
410
|
|
|
385
411
|
/**
|
|
@@ -487,7 +513,8 @@ export var ContributorTagController = /*#__PURE__*/function () {
|
|
|
487
513
|
// `bindAll` takes a single target, and a change can render more than one highlight. Each is its
|
|
488
514
|
// own member of `revealSources`, so the pointer can cross between them without the set
|
|
489
515
|
// emptying.
|
|
490
|
-
this.
|
|
516
|
+
this.highlightElements = Array.from(highlights);
|
|
517
|
+
this.unbindHighlights = this.highlightElements.map(function (highlight) {
|
|
491
518
|
return bindAll(highlight, [{
|
|
492
519
|
type: 'mouseenter',
|
|
493
520
|
listener: _this6.trackRevealSource(highlight, true)
|
|
@@ -496,6 +523,9 @@ export var ContributorTagController = /*#__PURE__*/function () {
|
|
|
496
523
|
listener: _this6.trackRevealSource(highlight, false)
|
|
497
524
|
}]);
|
|
498
525
|
});
|
|
526
|
+
// The pointer may already be over a highlight by the time this binds, a draw pass after it
|
|
527
|
+
// entered.
|
|
528
|
+
this.applyHighlightHover();
|
|
499
529
|
}
|
|
500
530
|
}, {
|
|
501
531
|
key: "unbindHighlightState",
|
|
@@ -504,6 +534,13 @@ export var ContributorTagController = /*#__PURE__*/function () {
|
|
|
504
534
|
return unbind();
|
|
505
535
|
});
|
|
506
536
|
this.unbindHighlights = [];
|
|
537
|
+
// Cleared before the elements are released: ProseMirror reuses decoration DOM, so a hover left
|
|
538
|
+
// written on one would paint a highlight nothing is holding up.
|
|
539
|
+
this.highlightElements.forEach(function (highlight) {
|
|
540
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BG_VAR);
|
|
541
|
+
highlight.style.removeProperty(DELETED_HIGHLIGHT_BORDER_VAR);
|
|
542
|
+
});
|
|
543
|
+
this.highlightElements = [];
|
|
507
544
|
}
|
|
508
545
|
}]);
|
|
509
546
|
}();
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { AdsAccentColor, DiffColorScheme } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hover highlight for deleted text under an 'onEmphasis' scheme. Inline styles cannot express
|
|
4
|
+
* `:hover`, so the resting style resolves its background from this property and
|
|
5
|
+
* `ContributorTagController` sets it while the change is hovered. Custom properties inherit, so
|
|
6
|
+
* setting it on the element carrying `data-diff-id` also reaches the inner wrappers a
|
|
7
|
+
* deleted-content widget paints its background on.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DELETED_HIGHLIGHT_BG_VAR = "--show-diff-deleted-highlight-bg";
|
|
10
|
+
/**
|
|
11
|
+
* Bottom border of that same hover highlight, kept separate from `DELETED_HIGHLIGHT_BG_VAR` so an
|
|
12
|
+
* 'underline' scheme can darken the border without darkening the tint behind it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DELETED_HIGHLIGHT_BORDER_VAR = "--show-diff-deleted-highlight-border";
|
|
2
15
|
/**
|
|
3
16
|
* Presentation tokens for a contributor tag in one diff colour.
|
|
4
17
|
*
|
|
@@ -92,12 +105,9 @@ export declare function buildDecorationMarkerVariableActive(colors: DiffColorSch
|
|
|
92
105
|
export declare function buildDeletedDecorationMarkerVariable(colors: DiffColorScheme): string;
|
|
93
106
|
/** Opacity only, no position or strikethrough. Used by 'static' schemes. */
|
|
94
107
|
export declare function buildDeletedDecorationMarkerVariableSimple(colors: DiffColorScheme): string;
|
|
95
|
-
/**
|
|
96
|
-
* 'glyphTint' deleted inline style — tints the glyph itself via `color:`. Opacity ramps 0.6
|
|
97
|
-
* default, 0.83 "new", 1 active.
|
|
98
|
-
*/
|
|
99
108
|
/** Extended deleted inline style — background highlight with an accent or background-matched bottom border. */
|
|
100
109
|
export declare function buildDeletedInlineContentStyleExtended(colors: DiffColorScheme, isActive?: boolean): string;
|
|
110
|
+
/** 'glyphTint' deleted inline style — tints the glyph itself via `color:`. */
|
|
101
111
|
export declare function buildDeletedInlineStyleStandard(colors: DiffColorScheme, state: 'default' | 'new' | 'active'): string;
|
|
102
112
|
/** Deleted node decoration marker — "new" state. */
|
|
103
113
|
export declare function buildDeletedDecorationMarkerVariableNew(colors: DiffColorScheme): string;
|
|
@@ -142,6 +152,17 @@ export declare function getDeletedInlineRevealColors(colors: DiffColorScheme): {
|
|
|
142
152
|
background: string;
|
|
143
153
|
border: string;
|
|
144
154
|
};
|
|
155
|
+
/**
|
|
156
|
+
* Value for `DELETED_HIGHLIGHT_BG_VAR` while a change is hovered — the same tint an 'always' scheme
|
|
157
|
+
* paints at rest, so hovering restores the appearance rather than introducing a third one.
|
|
158
|
+
*/
|
|
159
|
+
export declare function getDeletedHighlightHoverColor(colors: DiffColorScheme): string;
|
|
160
|
+
/**
|
|
161
|
+
* Value for `DELETED_HIGHLIGHT_BORDER_VAR` while a change is hovered. An 'underline' scheme states
|
|
162
|
+
* both hover and active in the border, so the two read alike; anything else keeps the border on the
|
|
163
|
+
* tint, as it was before the border had a variable of its own.
|
|
164
|
+
*/
|
|
165
|
+
export declare function getDeletedHighlightHoverBorderColor(colors: DiffColorScheme): string;
|
|
145
166
|
/** The three visual states deleted inline content can be in. */
|
|
146
167
|
export type DeletedInlineState = 'active' | 'default' | 'new';
|
|
147
168
|
/**
|
|
@@ -26,8 +26,19 @@ export type DiffColorScheme = {
|
|
|
26
26
|
deletedCellColor: AdsAccentColor;
|
|
27
27
|
/** Opacity of the deleted cell overlay background. Counterpart to `insertedCellOpacity`. */
|
|
28
28
|
deletedCellOpacity: number;
|
|
29
|
+
/**
|
|
30
|
+
* Emphasised deleted text — hovered or active: deepen the highlight, or hold the resting tint and
|
|
31
|
+
* darken the bottom border instead. Defaults to 'background'. Only the attribution schemes take
|
|
32
|
+
* 'underline', so it reaches no one outside their gates.
|
|
33
|
+
*/
|
|
34
|
+
deletedInlineActiveEmphasis?: 'background' | 'underline';
|
|
29
35
|
/** Bottom border tone for deleted text highlights. Defaults to accent. */
|
|
30
36
|
deletedInlineBorderTone?: 'accent' | 'background';
|
|
37
|
+
/**
|
|
38
|
+
* Deleted text highlight: painted at rest, or only once the change is active or hovered. See
|
|
39
|
+
* `DELETED_HIGHLIGHT_BG_VAR` for how 'onEmphasis' resolves the hovered half.
|
|
40
|
+
*/
|
|
41
|
+
deletedInlineHighlight: 'always' | 'onEmphasis';
|
|
31
42
|
/** Deleted inline content: tint the strikethrough, or tint and dim the glyph itself. */
|
|
32
43
|
deletedInlineTreatment: 'strikethrough' | 'glyphTint';
|
|
33
44
|
/** Resting "REMOVED" lozenge tint. Gray in both current schemes; the active state uses `deleteActiveColor`. */
|
|
@@ -36,6 +36,8 @@ export declare class ContributorTagController {
|
|
|
36
36
|
private boundSelector;
|
|
37
37
|
private dom;
|
|
38
38
|
private fullLabel;
|
|
39
|
+
/** The bound highlights themselves, so hover can write the deleted highlight onto them. */
|
|
40
|
+
private highlightElements;
|
|
39
41
|
private host;
|
|
40
42
|
private isDestroyed;
|
|
41
43
|
/** Last visibility written, so a teardown knows whether there is anything on screen to fade. */
|
|
@@ -82,6 +84,13 @@ export declare class ContributorTagController {
|
|
|
82
84
|
* the tag is attached yet, and whether motion is wanted at all are all the stylesheet's to answer.
|
|
83
85
|
*/
|
|
84
86
|
private applyVisibility;
|
|
87
|
+
/**
|
|
88
|
+
* Brings the deleted highlight up alongside the tag, for the schemes that paint none at rest —
|
|
89
|
+
* see `DELETED_HIGHLIGHT_BG_VAR`. Keyed on `revealSources` rather than on the tag's own
|
|
90
|
+
* visibility: an active change paints its highlight from its decoration style, which this must
|
|
91
|
+
* not be able to override.
|
|
92
|
+
*/
|
|
93
|
+
private applyHighlightHover;
|
|
85
94
|
/**
|
|
86
95
|
* The full label is always the tooltip, whether or not the name it draws is clipped: a name longer
|
|
87
96
|
* than `MAX_TAG_WIDTH` is ellipsised, and a connected pair spells out a contributor the tag does
|