@atlaskit/editor-plugin-show-diff 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/pm-plugins/NodeViewSerializer.js +25 -5
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +57 -16
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +13 -2
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +153 -106
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +13 -3
- package/dist/es2019/pm-plugins/NodeViewSerializer.js +25 -5
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +57 -15
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +13 -2
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +64 -19
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -4
- package/dist/esm/pm-plugins/NodeViewSerializer.js +25 -5
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +57 -16
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +13 -2
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +154 -107
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +13 -3
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +22 -10
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +16 -0
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +7 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 14.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`86e4ff02ed98c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/86e4ff02ed98c) -
|
|
8
|
+
[ux] Collapse the per-scheme show-diff selectors onto one class per visual role, behind
|
|
9
|
+
`platform_editor_show_diff_color_scheme_refactor`. No rendered change in either cohort.
|
|
10
|
+
|
|
11
|
+
With the experiment on, `wrapBlockNodeView` marks deleted media, embed and blockquote nodeviews
|
|
12
|
+
with `show-diff-deleted-node-next` and emits the scheme's colours as `--diff-delete-*` custom
|
|
13
|
+
properties, so editor-core carries one set of selectors instead of one per scheme. The
|
|
14
|
+
atomic-inline highlight (date, emoji, mention, status) works the same way. Two new scheme fields —
|
|
15
|
+
`deletedMediaRingColor` and `strikesDeletedEmbedCard` — replace the last literal colours on that
|
|
16
|
+
path, both set to today's values.
|
|
17
|
+
|
|
18
|
+
With it off, the pre-refactor classes and per-scheme selectors run unchanged. Both selector sets
|
|
19
|
+
ship together for the life of the experiment, keyed on disjoint base classes.
|
|
20
|
+
|
|
21
|
+
- [`e5bea22208fbe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e5bea22208fbe) -
|
|
22
|
+
Fix deleted diffs dropping atomic inline nodes: when a deleted paragraph or table cell contains an
|
|
23
|
+
atomic inline node (e.g. date, status), it now serializes via its node view instead of lossy
|
|
24
|
+
schema `toDOM`, so dates no longer disappear and status lozenges keep their styling. Plain and
|
|
25
|
+
marked text is unaffected. Gated behind the `platform_editor_show_diff_deleted_nodeview_content`
|
|
26
|
+
experiment.
|
|
27
|
+
|
|
3
28
|
## 14.0.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ exports.NodeViewSerializer = void 0;
|
|
|
8
8
|
exports.isEditorViewWithNodeViews = isEditorViewWithNodeViews;
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
12
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
13
|
/**
|
|
13
14
|
* Utilities for working with ProseMirror node views and DOM serialization within the
|
|
@@ -103,11 +104,29 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
103
104
|
return null;
|
|
104
105
|
}
|
|
105
106
|
var constructor = (_this$nodeViews = this.nodeViews) === null || _this$nodeViews === void 0 ? void 0 : _this$nodeViews[targetNode.type.name];
|
|
106
|
-
|
|
107
|
+
var isBlocklisted = this.nodeViewBlocklist.has(targetNode.type.name);
|
|
108
|
+
|
|
109
|
+
// Do not bail out a blocklisted container when it holds an atomic inline node
|
|
110
|
+
// (e.g. date, status) whose schema toDOM is lossy. Text keeps bailing so the caller
|
|
111
|
+
// renders it inline
|
|
112
|
+
var hasAtomicInlineChild = function hasAtomicInlineChild(node) {
|
|
113
|
+
var found = false;
|
|
114
|
+
node.forEach(function (child) {
|
|
115
|
+
if (child.isLeaf && !child.isText) {
|
|
116
|
+
found = true;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return found;
|
|
120
|
+
};
|
|
121
|
+
var serializeAtomicContainer = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_deleted_nodeview_content') && !targetNode.isInline && hasAtomicInlineChild(targetNode);
|
|
122
|
+
if (isBlocklisted && !serializeAtomicContainer) {
|
|
107
123
|
return null;
|
|
108
124
|
}
|
|
109
125
|
try {
|
|
110
|
-
|
|
126
|
+
// No constructor, or (gated) the node's own view is blocklisted: render the toDOM
|
|
127
|
+
// shell and recurse via appendChildNodes so nested atomic inline nodes render via
|
|
128
|
+
// their node views instead of their lossy schema toDOM.
|
|
129
|
+
if (!constructor || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_deleted_nodeview_content') && isBlocklisted) {
|
|
111
130
|
var _targetNode$type$spec, _targetNode$type$spec2;
|
|
112
131
|
if (targetNode.isInline) {
|
|
113
132
|
return null;
|
|
@@ -120,11 +139,12 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
120
139
|
_dom = _DOMSerializer$render.dom,
|
|
121
140
|
_contentDOM = _DOMSerializer$render.contentDOM;
|
|
122
141
|
if (_dom instanceof HTMLElement) {
|
|
123
|
-
|
|
142
|
+
// Legacy shortcut: a single-child paragraph serializes its inline content
|
|
143
|
+
// directly (no <p> wrapper). Applies only to a non-blocklisted paragraph with
|
|
144
|
+
// no node view
|
|
145
|
+
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_deleted_nodeview_content') && targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
124
146
|
return this.serializeFragment(targetNode.content);
|
|
125
147
|
}
|
|
126
|
-
|
|
127
|
-
// Iteratively populate children
|
|
128
148
|
this.appendChildNodes(targetNode.children, _contentDOM);
|
|
129
149
|
}
|
|
130
150
|
return _dom;
|
|
@@ -94,6 +94,17 @@ var bgSubtlestPressedMap = {
|
|
|
94
94
|
magenta: "var(--ds-background-accent-magenta-subtlest-pressed, #FCB6E1)",
|
|
95
95
|
gray: "var(--ds-background-accent-gray-subtlest-pressed, #B7B9BE)"
|
|
96
96
|
};
|
|
97
|
+
var bgSubtlerMap = {
|
|
98
|
+
green: "var(--ds-background-accent-green-subtler, #BAF3DB)",
|
|
99
|
+
teal: "var(--ds-background-accent-teal-subtler, #C6EDFB)",
|
|
100
|
+
blue: "var(--ds-background-accent-blue-subtler, #CFE1FD)",
|
|
101
|
+
purple: "var(--ds-background-accent-purple-subtler, #EED7FC)",
|
|
102
|
+
red: "var(--ds-background-accent-red-subtler, #FFD5D2)",
|
|
103
|
+
orange: "var(--ds-background-accent-orange-subtler, #FCE4A6)",
|
|
104
|
+
yellow: "var(--ds-background-accent-yellow-subtler, #F5E989)",
|
|
105
|
+
magenta: "var(--ds-background-accent-magenta-subtler, #FDD0EC)",
|
|
106
|
+
gray: "var(--ds-background-accent-gray-subtler, #DDDEE1)"
|
|
107
|
+
};
|
|
97
108
|
var bgSubtlerPressedMap = {
|
|
98
109
|
green: "var(--ds-background-accent-green-subtler-pressed, #7EE2B8)",
|
|
99
110
|
teal: "var(--ds-background-accent-teal-subtler-pressed, #9DD9EE)",
|
|
@@ -133,6 +144,9 @@ function bgSubtlest(color) {
|
|
|
133
144
|
function bgSubtlestPressed(color) {
|
|
134
145
|
return bgSubtlestPressedMap[color];
|
|
135
146
|
}
|
|
147
|
+
function bgSubtler(color) {
|
|
148
|
+
return bgSubtlerMap[color];
|
|
149
|
+
}
|
|
136
150
|
function bgSubtlerPressed(color) {
|
|
137
151
|
return bgSubtlerPressedMap[color];
|
|
138
152
|
}
|
|
@@ -671,7 +685,7 @@ function buildDeletedCellOverlayStyle(colors) {
|
|
|
671
685
|
left: 0,
|
|
672
686
|
width: '100%',
|
|
673
687
|
height: '100%',
|
|
674
|
-
backgroundColor: "rgba(from ".concat(bgSubtlest(colors.deletedCellColor), " r g b /
|
|
688
|
+
backgroundColor: "rgba(from ".concat(bgSubtlest(colors.deletedCellColor), " r g b / ").concat(colors.deletedCellOpacity, ")"),
|
|
675
689
|
zIndex: 1,
|
|
676
690
|
outline: "1px solid ".concat(deletedCellOutline(colors)),
|
|
677
691
|
pointerEvents: 'none'
|
|
@@ -686,7 +700,7 @@ function buildDeletedCellOverlayRoundedStyle(colors) {
|
|
|
686
700
|
left: 0,
|
|
687
701
|
width: '100%',
|
|
688
702
|
height: '100%',
|
|
689
|
-
backgroundColor: "rgba(from ".concat(bgSubtlest(colors.deletedCellColor), " r g b /
|
|
703
|
+
backgroundColor: "rgba(from ".concat(bgSubtlest(colors.deletedCellColor), " r g b / ").concat(colors.deletedCellOpacity, ")"),
|
|
690
704
|
zIndex: 2,
|
|
691
705
|
outline: "1px solid ".concat(deletedCellOutline(colors)),
|
|
692
706
|
pointerEvents: 'none',
|
|
@@ -743,7 +757,7 @@ function buildDeletedStrikethroughLine(colors, isActive) {
|
|
|
743
757
|
|
|
744
758
|
// --- Deleted-content "REMOVED" lozenge ---
|
|
745
759
|
|
|
746
|
-
/** Structural CSS shared by both lozenge states — everything except the
|
|
760
|
+
/** Structural CSS shared by both lozenge states — everything except the tint and the label colour. */
|
|
747
761
|
var deletedLozengeBase = {
|
|
748
762
|
display: 'inline-flex',
|
|
749
763
|
boxSizing: 'border-box',
|
|
@@ -756,23 +770,30 @@ var deletedLozengeBase = {
|
|
|
756
770
|
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)",
|
|
757
771
|
fontWeight: "var(--ds-font-weight-bold, 653)",
|
|
758
772
|
textOverflow: 'ellipsis',
|
|
759
|
-
whiteSpace: 'nowrap'
|
|
760
|
-
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
773
|
+
whiteSpace: 'nowrap'
|
|
761
774
|
};
|
|
762
775
|
|
|
763
776
|
/**
|
|
764
|
-
*
|
|
765
|
-
*
|
|
777
|
+
* Label colour for both lozenge states. `inverse` is a fixed tone that reads on any tint, which is
|
|
778
|
+
* why the resting lozenge could get away with a hardcoded gray background; a scheme that tints the
|
|
779
|
+
* lozenge itself needs `accent` instead.
|
|
766
780
|
*/
|
|
767
|
-
function
|
|
781
|
+
function deletedLozengeTextColor(colors) {
|
|
782
|
+
return colors.deletedLozengeTextTone === 'accent' ? textAccent(colors.deletedLozengeColor) : "var(--ds-text-warning-inverse, #292A2E)";
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** The "REMOVED" lozenge on a deleted block node — resting state, tinted with deletedLozengeColor. */
|
|
786
|
+
function buildDeletedLozengeStyle(colors) {
|
|
768
787
|
return (0, _lazyNodeView.convertToInlineCss)(_objectSpread(_objectSpread({}, deletedLozengeBase), {}, {
|
|
769
|
-
|
|
788
|
+
color: deletedLozengeTextColor(colors),
|
|
789
|
+
backgroundColor: bgSubtler(colors.deletedLozengeColor)
|
|
770
790
|
}));
|
|
771
791
|
}
|
|
772
792
|
|
|
773
793
|
/** The "REMOVED" lozenge — active state, tinted with the scheme's deleteActiveColor. */
|
|
774
794
|
function buildDeletedLozengeActiveStyle(colors) {
|
|
775
795
|
return (0, _lazyNodeView.convertToInlineCss)(_objectSpread(_objectSpread({}, deletedLozengeBase), {}, {
|
|
796
|
+
color: deletedLozengeTextColor(colors),
|
|
776
797
|
backgroundColor: bgSubtlerPressed(colors.deleteActiveColor)
|
|
777
798
|
}));
|
|
778
799
|
}
|
|
@@ -903,18 +924,38 @@ function buildAtomicInlineChangedCSSVariables(colors) {
|
|
|
903
924
|
}
|
|
904
925
|
|
|
905
926
|
/**
|
|
906
|
-
* Deleted-node wrapper variables, one per visual role in editor-core's `showDiffDeletedNodeStyles
|
|
907
|
-
*
|
|
927
|
+
* Deleted-node wrapper variables, one per visual role in editor-core's `showDiffDeletedNodeStyles`.
|
|
928
|
+
* Emitted by `wrapBlockNodeView` alongside `show-diff-deleted-node-vars` — the class is named for
|
|
929
|
+
* these properties — so one set of selectors in editor-core covers both schemes.
|
|
930
|
+
*
|
|
931
|
+
* The three `stateful`-only variables are omitted for `static` (standard) so editor-core's fallback
|
|
932
|
+
* wins, which is what standard rendered before:
|
|
933
|
+
* - `--diff-delete-opacity` — the fallback is 0.6 or 0.8 depending on
|
|
934
|
+
* `platform_editor_enghealth_a11y_jan_fixes`, a split the scheme must not flatten.
|
|
935
|
+
* - `--diff-delete-ring-width` — traditional's deleted media ring tracks the inherited marker ring
|
|
936
|
+
* width instead of a fixed 1px.
|
|
937
|
+
* - `--diff-delete-text-decoration-color` — standard's blockquote strike must stay `currentColor`.
|
|
908
938
|
*
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
939
|
+
* `--diff-delete-media-ring-color` is emitted for every scheme: the a11y-fixes treatment rings
|
|
940
|
+
* deleted media red even where `deleteColor` is gray, so it needs its own role.
|
|
941
|
+
*
|
|
942
|
+
* `--diff-delete-embed-strike-line` carries the *presence* of the deleted-embedCard strike, not its
|
|
943
|
+
* colour — standard draws none. Encoding it as `line-through`/`none` is what lets the ON cohort drop
|
|
944
|
+
* the `-traditional` class entirely.
|
|
945
|
+
*
|
|
946
|
+
* Only reached when `platform_editor_show_diff_color_scheme_refactor` is on; the OFF cohort takes
|
|
947
|
+
* its values from the per-scheme selectors in editor-core instead.
|
|
912
948
|
*/
|
|
913
949
|
function buildDeletedNodeCSSVariables(colors) {
|
|
914
|
-
return (0, _lazyNodeView.convertToInlineCss)({
|
|
950
|
+
return (0, _lazyNodeView.convertToInlineCss)(_objectSpread({
|
|
915
951
|
'--diff-delete-color': borderAccent(colors.deleteColor),
|
|
916
952
|
'--diff-delete-color-new': bgSubtlest(colors.deleteColor),
|
|
917
953
|
'--diff-delete-color-active': bgSubtlerPressed(colors.deleteActiveColor),
|
|
954
|
+
'--diff-delete-media-ring-color': borderAccent(colors.deletedMediaRingColor),
|
|
955
|
+
'--diff-delete-embed-strike-line': colors.strikesDeletedEmbedCard ? 'line-through' : 'none'
|
|
956
|
+
}, colors.deletedNodeEmphasis === 'stateful' ? {
|
|
957
|
+
'--diff-delete-opacity': '1',
|
|
958
|
+
'--diff-delete-ring-width': 'var(--diff-decoration-marker-ring-width, 1px)',
|
|
918
959
|
'--diff-delete-text-decoration-color': borderAccent(colors.deleteColor)
|
|
919
|
-
});
|
|
960
|
+
} : {}));
|
|
920
961
|
}
|
|
@@ -12,6 +12,10 @@ var traditionalScheme = exports.traditionalScheme = {
|
|
|
12
12
|
deleteColor: 'red',
|
|
13
13
|
deleteActiveColor: 'red',
|
|
14
14
|
deletedCellColor: 'gray',
|
|
15
|
+
deletedCellOpacity: 0.5,
|
|
16
|
+
deletedLozengeColor: 'gray',
|
|
17
|
+
deletedLozengeTextTone: 'inverse',
|
|
18
|
+
deletedMediaRingColor: 'red',
|
|
15
19
|
deletedRowTreatment: 'strikeColor',
|
|
16
20
|
insertedCellOpacity: 0.5,
|
|
17
21
|
deletedQuoteNodeShape: 'ring',
|
|
@@ -23,7 +27,8 @@ var traditionalScheme = exports.traditionalScheme = {
|
|
|
23
27
|
deletedInlineTreatment: 'strikethrough',
|
|
24
28
|
insertedNodeEmphasis: 'stateful',
|
|
25
29
|
deletedNodeEmphasis: 'stateful',
|
|
26
|
-
deletedQuoteNodeActiveTone: 'backgroundPressed'
|
|
30
|
+
deletedQuoteNodeActiveTone: 'backgroundPressed',
|
|
31
|
+
strikesDeletedEmbedCard: true
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
/** Purple insertions, gray deletions (red on active). */
|
|
@@ -34,6 +39,11 @@ var standardScheme = exports.standardScheme = {
|
|
|
34
39
|
deleteColor: 'gray',
|
|
35
40
|
deleteActiveColor: 'red',
|
|
36
41
|
deletedCellColor: 'gray',
|
|
42
|
+
deletedCellOpacity: 0.5,
|
|
43
|
+
deletedLozengeColor: 'gray',
|
|
44
|
+
deletedLozengeTextTone: 'inverse',
|
|
45
|
+
// Red, not `deleteColor`'s gray: a11y-fixes rings deleted media red in both schemes.
|
|
46
|
+
deletedMediaRingColor: 'red',
|
|
37
47
|
deletedRowTreatment: 'textTint',
|
|
38
48
|
insertedCellOpacity: 0.2,
|
|
39
49
|
deletedQuoteNodeShape: 'borderLeft',
|
|
@@ -45,7 +55,8 @@ var standardScheme = exports.standardScheme = {
|
|
|
45
55
|
deletedInlineTreatment: 'glyphTint',
|
|
46
56
|
insertedNodeEmphasis: 'static',
|
|
47
57
|
deletedNodeEmphasis: 'static',
|
|
48
|
-
deletedQuoteNodeActiveTone: 'borderAccent'
|
|
58
|
+
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
59
|
+
strikesDeletedEmbedCard: false
|
|
49
60
|
};
|
|
50
61
|
|
|
51
62
|
/** Maps the public ColorScheme string to its data object. Adding a scheme = one entry here. */
|
|
@@ -9,6 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
12
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
12
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
14
|
var _isExtendedEnabled = require("../../isExtendedEnabled");
|
|
14
15
|
var _tableCellEdgeAttrs = require("./tableCellEdgeAttrs");
|
|
@@ -54,6 +55,67 @@ var maybeAddDeletedOutlineNewClass = function maybeAddDeletedOutlineNewClass(_re
|
|
|
54
55
|
nodeView.classList.add('show-diff-deleted-outline-new');
|
|
55
56
|
}
|
|
56
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Pre-refactor markup for a deleted media/embed/blockquote nodeview: one class per scheme, and no
|
|
60
|
+
* custom properties — the colours come from the matching per-scheme selectors in editor-core.
|
|
61
|
+
*
|
|
62
|
+
* Delete this together with those selectors at experiment cleanup (EDITOR-8281).
|
|
63
|
+
*/
|
|
64
|
+
var applyDeletedNodeMarkupLegacy = function applyDeletedNodeMarkupLegacy(_ref2) {
|
|
65
|
+
var nodeView = _ref2.nodeView,
|
|
66
|
+
targetNode = _ref2.targetNode,
|
|
67
|
+
colorScheme = _ref2.colorScheme,
|
|
68
|
+
_ref2$isActive = _ref2.isActive,
|
|
69
|
+
isActive = _ref2$isActive === void 0 ? false : _ref2$isActive;
|
|
70
|
+
nodeView.classList.add(colorScheme === 'traditional' ? 'show-diff-deleted-node-traditional' : 'show-diff-deleted-node');
|
|
71
|
+
if (isActive) {
|
|
72
|
+
nodeView.classList.add('show-diff-deleted-active');
|
|
73
|
+
}
|
|
74
|
+
maybeAddDeletedOutlineNewClass({
|
|
75
|
+
nodeView: nodeView,
|
|
76
|
+
targetNode: targetNode,
|
|
77
|
+
colorScheme: colorScheme,
|
|
78
|
+
isActive: isActive
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Registry-driven markup: one scheme-agnostic class, plus the scheme's colours as custom properties,
|
|
84
|
+
* so editor-core needs one selector per visual role instead of one per scheme.
|
|
85
|
+
*
|
|
86
|
+
* `show-diff-deleted-node-vars` *replaces* the legacy classes rather than joining them. Both sets of
|
|
87
|
+
* selectors live in editor-core for the life of the experiment, and they have equal specificity, so
|
|
88
|
+
* a shared base class would leave the winner up to source order.
|
|
89
|
+
*
|
|
90
|
+
* The `-vars` suffix names what the class means — this node carries its scheme colours as
|
|
91
|
+
* `--diff-delete-*` custom properties — rather than when it arrived, so it still reads correctly
|
|
92
|
+
* once the legacy classes are gone.
|
|
93
|
+
*/
|
|
94
|
+
var applyDeletedNodeMarkupNext = function applyDeletedNodeMarkupNext(_ref3) {
|
|
95
|
+
var nodeView = _ref3.nodeView,
|
|
96
|
+
targetNode = _ref3.targetNode,
|
|
97
|
+
colorScheme = _ref3.colorScheme,
|
|
98
|
+
_ref3$isActive = _ref3.isActive,
|
|
99
|
+
isActive = _ref3$isActive === void 0 ? false : _ref3$isActive;
|
|
100
|
+
nodeView.classList.add('show-diff-deleted-node-vars');
|
|
101
|
+
if (isActive) {
|
|
102
|
+
nodeView.classList.add('show-diff-deleted-active');
|
|
103
|
+
}
|
|
104
|
+
maybeAddDeletedOutlineNewClass({
|
|
105
|
+
nodeView: nodeView,
|
|
106
|
+
targetNode: targetNode,
|
|
107
|
+
colorScheme: colorScheme,
|
|
108
|
+
isActive: isActive
|
|
109
|
+
});
|
|
110
|
+
var currentStyle = nodeView.getAttribute('style') || '';
|
|
111
|
+
var separator = currentStyle && !currentStyle.trimEnd().endsWith(';') ? ';' : '';
|
|
112
|
+
nodeView.setAttribute('style', "".concat(currentStyle).concat(separator).concat((0, _wrapBlockNodeViewStyles.resolveDeletedNodeCSSVariables)(colorScheme)));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** Single gate for the deleted-node classes and custom properties. */
|
|
116
|
+
var applyDeletedNodeMarkup = function applyDeletedNodeMarkup(args) {
|
|
117
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? applyDeletedNodeMarkupNext(args) : applyDeletedNodeMarkupLegacy(args);
|
|
118
|
+
};
|
|
57
119
|
|
|
58
120
|
/**
|
|
59
121
|
* Checks if a node should apply deleted styles directly without wrapper
|
|
@@ -62,10 +124,10 @@ var maybeAddDeletedOutlineNewClass = function maybeAddDeletedOutlineNewClass(_re
|
|
|
62
124
|
var shouldApplyStylesDirectly = function shouldApplyStylesDirectly(nodeName) {
|
|
63
125
|
return nodeName === 'heading';
|
|
64
126
|
};
|
|
65
|
-
var applyCellOverlayStyles = function applyCellOverlayStyles(
|
|
66
|
-
var element =
|
|
67
|
-
colorScheme =
|
|
68
|
-
isInserted =
|
|
127
|
+
var applyCellOverlayStyles = function applyCellOverlayStyles(_ref4) {
|
|
128
|
+
var element = _ref4.element,
|
|
129
|
+
colorScheme = _ref4.colorScheme,
|
|
130
|
+
isInserted = _ref4.isInserted;
|
|
69
131
|
var isRoundedTable = (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
70
132
|
var overlayStyle = (0, _wrapBlockNodeViewStyles.resolveCellOverlayStyle)({
|
|
71
133
|
colorScheme: colorScheme,
|
|
@@ -123,30 +185,30 @@ var createBlockNodeWrapper = function createBlockNodeWrapper() {
|
|
|
123
185
|
/**
|
|
124
186
|
* Applies styles directly to an HTML element by merging with existing styles
|
|
125
187
|
*/
|
|
126
|
-
var applyStylesToElement = function applyStylesToElement(
|
|
127
|
-
var element =
|
|
128
|
-
targetNode =
|
|
129
|
-
colorScheme =
|
|
130
|
-
isActive =
|
|
131
|
-
isInserted =
|
|
132
|
-
diffType =
|
|
133
|
-
|
|
134
|
-
hideAddedDiffsUnderline =
|
|
188
|
+
var applyStylesToElement = function applyStylesToElement(_ref5) {
|
|
189
|
+
var element = _ref5.element,
|
|
190
|
+
targetNode = _ref5.targetNode,
|
|
191
|
+
colorScheme = _ref5.colorScheme,
|
|
192
|
+
isActive = _ref5.isActive,
|
|
193
|
+
isInserted = _ref5.isInserted,
|
|
194
|
+
diffType = _ref5.diffType,
|
|
195
|
+
_ref5$hideAddedDiffsU = _ref5.hideAddedDiffsUnderline,
|
|
196
|
+
hideAddedDiffsUnderline = _ref5$hideAddedDiffsU === void 0 ? false : _ref5$hideAddedDiffsU;
|
|
135
197
|
var currentStyle = element.getAttribute('style') || '';
|
|
136
198
|
var contentStyle = (0, _wrapBlockNodeViewStyles.getChangedContentStyle)(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
|
|
137
199
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
138
200
|
var nodeSpecificStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
139
201
|
element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
|
|
140
202
|
};
|
|
141
|
-
var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(
|
|
142
|
-
var element =
|
|
143
|
-
targetNode =
|
|
144
|
-
colorScheme =
|
|
145
|
-
isActive =
|
|
146
|
-
isInserted =
|
|
147
|
-
diffType =
|
|
148
|
-
|
|
149
|
-
hideAddedDiffsUnderline =
|
|
203
|
+
var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref6) {
|
|
204
|
+
var element = _ref6.element,
|
|
205
|
+
targetNode = _ref6.targetNode,
|
|
206
|
+
colorScheme = _ref6.colorScheme,
|
|
207
|
+
isActive = _ref6.isActive,
|
|
208
|
+
isInserted = _ref6.isInserted,
|
|
209
|
+
diffType = _ref6.diffType,
|
|
210
|
+
_ref6$hideAddedDiffsU = _ref6.hideAddedDiffsUnderline,
|
|
211
|
+
hideAddedDiffsUnderline = _ref6$hideAddedDiffsU === void 0 ? false : _ref6$hideAddedDiffsU;
|
|
150
212
|
var currentStyle = element.getAttribute('style') || '';
|
|
151
213
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
152
214
|
var nodeSpecificStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
@@ -171,15 +233,15 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4
|
|
|
171
233
|
}
|
|
172
234
|
element.setAttribute('style', "".concat(currentStyle, ";").concat(nodeSpecificStyle));
|
|
173
235
|
};
|
|
174
|
-
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(
|
|
175
|
-
var element =
|
|
176
|
-
targetNode =
|
|
177
|
-
colorScheme =
|
|
178
|
-
isActive =
|
|
179
|
-
isInserted =
|
|
180
|
-
diffType =
|
|
181
|
-
|
|
182
|
-
hideAddedDiffsUnderline =
|
|
236
|
+
var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref7) {
|
|
237
|
+
var element = _ref7.element,
|
|
238
|
+
targetNode = _ref7.targetNode,
|
|
239
|
+
colorScheme = _ref7.colorScheme,
|
|
240
|
+
isActive = _ref7.isActive,
|
|
241
|
+
isInserted = _ref7.isInserted,
|
|
242
|
+
diffType = _ref7.diffType,
|
|
243
|
+
_ref7$hideAddedDiffsU = _ref7.hideAddedDiffsUnderline,
|
|
244
|
+
hideAddedDiffsUnderline = _ref7$hideAddedDiffsU === void 0 ? false : _ref7$hideAddedDiffsU;
|
|
183
245
|
var currentStyle = element.getAttribute('style') || '';
|
|
184
246
|
var nodeSpecificStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNode.type.name, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) || '';
|
|
185
247
|
if (nodeSpecificStyle) {
|
|
@@ -206,15 +268,15 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref5)
|
|
|
206
268
|
/**
|
|
207
269
|
* Creates a content wrapper with deleted styles for a block node
|
|
208
270
|
*/
|
|
209
|
-
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(
|
|
210
|
-
var nodeView =
|
|
211
|
-
targetNode =
|
|
212
|
-
colorScheme =
|
|
213
|
-
isActive =
|
|
214
|
-
isInserted =
|
|
215
|
-
diffType =
|
|
216
|
-
|
|
217
|
-
hideAddedDiffsUnderline =
|
|
271
|
+
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref8) {
|
|
272
|
+
var nodeView = _ref8.nodeView,
|
|
273
|
+
targetNode = _ref8.targetNode,
|
|
274
|
+
colorScheme = _ref8.colorScheme,
|
|
275
|
+
isActive = _ref8.isActive,
|
|
276
|
+
isInserted = _ref8.isInserted,
|
|
277
|
+
diffType = _ref8.diffType,
|
|
278
|
+
_ref8$hideAddedDiffsU = _ref8.hideAddedDiffsUnderline,
|
|
279
|
+
hideAddedDiffsUnderline = _ref8$hideAddedDiffsU === void 0 ? false : _ref8$hideAddedDiffsU;
|
|
218
280
|
var contentWrapper = document.createElement('div');
|
|
219
281
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
220
282
|
var nodeStyle = (0, _wrapBlockNodeViewStyles.getChangedNodeStyle)(targetNodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
@@ -235,14 +297,14 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
|
|
|
235
297
|
* to wait for the rich-media-item to appear before attaching the lozenge.
|
|
236
298
|
* @returns true if embedCard was handled
|
|
237
299
|
*/
|
|
238
|
-
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(
|
|
239
|
-
var dom =
|
|
240
|
-
nodeView =
|
|
241
|
-
targetNode =
|
|
242
|
-
lozenge =
|
|
243
|
-
colorScheme =
|
|
244
|
-
|
|
245
|
-
isActive =
|
|
300
|
+
var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref9) {
|
|
301
|
+
var dom = _ref9.dom,
|
|
302
|
+
nodeView = _ref9.nodeView,
|
|
303
|
+
targetNode = _ref9.targetNode,
|
|
304
|
+
lozenge = _ref9.lozenge,
|
|
305
|
+
colorScheme = _ref9.colorScheme,
|
|
306
|
+
_ref9$isActive = _ref9.isActive,
|
|
307
|
+
isActive = _ref9$isActive === void 0 ? false : _ref9$isActive;
|
|
246
308
|
if (targetNode.type.name !== 'embedCard' || !(nodeView instanceof HTMLElement)) {
|
|
247
309
|
return false;
|
|
248
310
|
}
|
|
@@ -263,12 +325,7 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref7) {
|
|
|
263
325
|
});
|
|
264
326
|
}
|
|
265
327
|
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
266
|
-
|
|
267
|
-
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
268
|
-
if (isActive) {
|
|
269
|
-
nodeView.classList.add('show-diff-deleted-active');
|
|
270
|
-
}
|
|
271
|
-
maybeAddDeletedOutlineNewClass({
|
|
328
|
+
applyDeletedNodeMarkup({
|
|
272
329
|
nodeView: nodeView,
|
|
273
330
|
targetNode: targetNode,
|
|
274
331
|
colorScheme: colorScheme,
|
|
@@ -283,14 +340,14 @@ var handleEmbedCardWithLozenge = function handleEmbedCardWithLozenge(_ref7) {
|
|
|
283
340
|
* Handles special mediaSingle node rendering with lozenge on child media element
|
|
284
341
|
* @returns true if mediaSingle was handled, false otherwise
|
|
285
342
|
*/
|
|
286
|
-
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(
|
|
287
|
-
var dom =
|
|
288
|
-
nodeView =
|
|
289
|
-
targetNode =
|
|
290
|
-
lozenge =
|
|
291
|
-
colorScheme =
|
|
292
|
-
|
|
293
|
-
isActive =
|
|
343
|
+
var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref0) {
|
|
344
|
+
var dom = _ref0.dom,
|
|
345
|
+
nodeView = _ref0.nodeView,
|
|
346
|
+
targetNode = _ref0.targetNode,
|
|
347
|
+
lozenge = _ref0.lozenge,
|
|
348
|
+
colorScheme = _ref0.colorScheme,
|
|
349
|
+
_ref0$isActive = _ref0.isActive,
|
|
350
|
+
isActive = _ref0$isActive === void 0 ? false : _ref0$isActive;
|
|
294
351
|
if (targetNode.type.name !== 'mediaSingle' || !(nodeView instanceof HTMLElement)) {
|
|
295
352
|
return false;
|
|
296
353
|
}
|
|
@@ -309,12 +366,7 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref8)
|
|
|
309
366
|
|
|
310
367
|
// Add deleted node class if needed
|
|
311
368
|
if (shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
312
|
-
|
|
313
|
-
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
314
|
-
if (isActive) {
|
|
315
|
-
nodeView.classList.add('show-diff-deleted-active');
|
|
316
|
-
}
|
|
317
|
-
maybeAddDeletedOutlineNewClass({
|
|
369
|
+
applyDeletedNodeMarkup({
|
|
318
370
|
nodeView: nodeView,
|
|
319
371
|
targetNode: targetNode,
|
|
320
372
|
colorScheme: colorScheme,
|
|
@@ -328,19 +380,19 @@ var handleMediaSingleWithLozenge = function handleMediaSingleWithLozenge(_ref8)
|
|
|
328
380
|
/**
|
|
329
381
|
* Appends a block node with wrapper, lozenge, and appropriate styling
|
|
330
382
|
*/
|
|
331
|
-
var wrapBlockNode = function wrapBlockNode(
|
|
332
|
-
var dom =
|
|
333
|
-
nodeView =
|
|
334
|
-
targetNode =
|
|
335
|
-
colorScheme =
|
|
336
|
-
intl =
|
|
337
|
-
|
|
338
|
-
isActive =
|
|
339
|
-
|
|
340
|
-
isInserted =
|
|
341
|
-
diffType =
|
|
342
|
-
|
|
343
|
-
hideAddedDiffsUnderline =
|
|
383
|
+
var wrapBlockNode = function wrapBlockNode(_ref1) {
|
|
384
|
+
var dom = _ref1.dom,
|
|
385
|
+
nodeView = _ref1.nodeView,
|
|
386
|
+
targetNode = _ref1.targetNode,
|
|
387
|
+
colorScheme = _ref1.colorScheme,
|
|
388
|
+
intl = _ref1.intl,
|
|
389
|
+
_ref1$isActive = _ref1.isActive,
|
|
390
|
+
isActive = _ref1$isActive === void 0 ? false : _ref1$isActive,
|
|
391
|
+
_ref1$isInserted = _ref1.isInserted,
|
|
392
|
+
isInserted = _ref1$isInserted === void 0 ? false : _ref1$isInserted,
|
|
393
|
+
diffType = _ref1.diffType,
|
|
394
|
+
_ref1$hideAddedDiffsU = _ref1.hideAddedDiffsUnderline,
|
|
395
|
+
hideAddedDiffsUnderline = _ref1$hideAddedDiffsU === void 0 ? false : _ref1$hideAddedDiffsU;
|
|
344
396
|
var blockWrapper = createBlockNodeWrapper();
|
|
345
397
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
346
398
|
if (shouldShowRemovedLozenge(targetNodeName) && (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted)) {
|
|
@@ -378,12 +430,7 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
|
|
|
378
430
|
});
|
|
379
431
|
blockWrapper.append(contentWrapper);
|
|
380
432
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
381
|
-
|
|
382
|
-
nodeView.classList.add(showDiffDeletedNodeClass);
|
|
383
|
-
if (isActive) {
|
|
384
|
-
nodeView.classList.add('show-diff-deleted-active');
|
|
385
|
-
}
|
|
386
|
-
maybeAddDeletedOutlineNewClass({
|
|
433
|
+
applyDeletedNodeMarkup({
|
|
387
434
|
nodeView: nodeView,
|
|
388
435
|
targetNode: targetNode,
|
|
389
436
|
colorScheme: colorScheme,
|
|
@@ -398,19 +445,19 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
|
|
|
398
445
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
399
446
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
400
447
|
*/
|
|
401
|
-
var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(
|
|
402
|
-
var dom =
|
|
403
|
-
nodeView =
|
|
404
|
-
targetNode =
|
|
405
|
-
colorScheme =
|
|
406
|
-
intl =
|
|
407
|
-
|
|
408
|
-
isActive =
|
|
409
|
-
|
|
410
|
-
isInserted =
|
|
411
|
-
diffType =
|
|
412
|
-
|
|
413
|
-
hideAddedDiffsUnderline =
|
|
448
|
+
var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_ref10) {
|
|
449
|
+
var dom = _ref10.dom,
|
|
450
|
+
nodeView = _ref10.nodeView,
|
|
451
|
+
targetNode = _ref10.targetNode,
|
|
452
|
+
colorScheme = _ref10.colorScheme,
|
|
453
|
+
intl = _ref10.intl,
|
|
454
|
+
_ref10$isActive = _ref10.isActive,
|
|
455
|
+
isActive = _ref10$isActive === void 0 ? false : _ref10$isActive,
|
|
456
|
+
_ref10$isInserted = _ref10.isInserted,
|
|
457
|
+
isInserted = _ref10$isInserted === void 0 ? false : _ref10$isInserted,
|
|
458
|
+
diffType = _ref10.diffType,
|
|
459
|
+
_ref10$hideAddedDiffs = _ref10.hideAddedDiffsUnderline,
|
|
460
|
+
hideAddedDiffsUnderline = _ref10$hideAddedDiffs === void 0 ? false : _ref10$hideAddedDiffs;
|
|
414
461
|
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
415
462
|
if (nodeView instanceof HTMLElement) {
|
|
416
463
|
if (isInserted && (0, _wrapBlockNodeViewStyles.isMultiContainerBlockNode)(targetNode.type.name)) {
|
|
@@ -499,12 +546,12 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
499
546
|
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
500
547
|
* the wrapper needs to be injected inside the node around the child content.
|
|
501
548
|
*/
|
|
502
|
-
var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrapper(
|
|
503
|
-
var node =
|
|
504
|
-
colorScheme =
|
|
505
|
-
isActive =
|
|
506
|
-
isInserted =
|
|
507
|
-
diffType =
|
|
549
|
+
var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrapper(_ref11) {
|
|
550
|
+
var node = _ref11.node,
|
|
551
|
+
colorScheme = _ref11.colorScheme,
|
|
552
|
+
isActive = _ref11.isActive,
|
|
553
|
+
isInserted = _ref11.isInserted,
|
|
554
|
+
diffType = _ref11.diffType;
|
|
508
555
|
var wrapper = document.createElement('span');
|
|
509
556
|
wrapper.setAttribute('style', isInserted ? (0, _wrapBlockNodeViewStyles.getInsertedContentStyle)(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyle)(colorScheme, isActive, diffType));
|
|
510
557
|
(0, _toConsumableArray2.default)(node.childNodes).forEach(function (child) {
|