@atlaskit/editor-plugin-show-diff 14.0.4 → 14.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +215 -103
- package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +20 -9
- package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +89 -0
- package/dist/cjs/pm-plugins/calculateDiff/simplifySteps.js +81 -4
- package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +68 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +26 -2
- package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +5 -1
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +7 -2
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +2 -2
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +59 -30
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -10
- package/dist/cjs/pm-plugins/main.js +1 -0
- package/dist/cjs/showDiffPlugin.js +36 -14
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +130 -22
- package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +17 -9
- package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +64 -0
- package/dist/es2019/pm-plugins/calculateDiff/simplifySteps.js +64 -1
- package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +37 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +19 -2
- package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +1 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +6 -3
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -3
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +55 -30
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +12 -9
- package/dist/es2019/pm-plugins/main.js +1 -0
- package/dist/es2019/showDiffPlugin.js +23 -1
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +216 -104
- package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +20 -9
- package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +82 -0
- package/dist/esm/pm-plugins/calculateDiff/simplifySteps.js +79 -5
- package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +61 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +24 -1
- package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +1 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +8 -3
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +59 -30
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -9
- package/dist/esm/pm-plugins/main.js +1 -0
- package/dist/esm/showDiffPlugin.js +36 -14
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +2 -1
- package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +7 -0
- package/dist/types/pm-plugins/calculateDiff/simplifySteps.d.ts +10 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +12 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +5 -3
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +6 -1
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +12 -2
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +3 -1
- package/dist/types/showDiffPluginType.d.ts +29 -1
- package/package.json +10 -7
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
3
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
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; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
7
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
5
8
|
import { areNodesEqualIgnoreAttrs } from '@atlaskit/editor-common/utils/document';
|
|
6
9
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
-
|
|
10
|
+
import { getAttributionKey } from '../decorations/colorSchemes/attributions';
|
|
8
11
|
/**
|
|
9
12
|
* Attempts to merge two consecutive ReplaceStep operations.
|
|
10
13
|
* This merges steps where:
|
|
@@ -46,21 +49,67 @@ export function simplifySteps(steps, originalDoc) {
|
|
|
46
49
|
return acc;
|
|
47
50
|
}, []);
|
|
48
51
|
}
|
|
52
|
+
var mergeAttributions = function mergeAttributions(first, second) {
|
|
53
|
+
var _second$wasOffline;
|
|
54
|
+
if (!first) {
|
|
55
|
+
return second;
|
|
56
|
+
}
|
|
57
|
+
if (!second) {
|
|
58
|
+
return first;
|
|
59
|
+
}
|
|
60
|
+
return _objectSpread(_objectSpread(_objectSpread({}, first), second), {}, {
|
|
61
|
+
wasOffline: first.wasOffline === true || second.wasOffline === true ? true : (_second$wasOffline = second.wasOffline) !== null && _second$wasOffline !== void 0 ? _second$wasOffline : first.wasOffline
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Attribution-preserving variant of `simplifySteps`.
|
|
67
|
+
*
|
|
68
|
+
* Steps may only merge when they have the same effective actor identity. Keeping the attribution
|
|
69
|
+
* coupled to the step also ensures filtering a no-op/analytics step cannot shift array indexes.
|
|
70
|
+
*/
|
|
71
|
+
export function simplifyStepsWithAttribution(steps, stepAttributions, originalDoc) {
|
|
72
|
+
var stepsToFilter = removeUnusedAttributedSteps(steps.map(function (step, index) {
|
|
73
|
+
return {
|
|
74
|
+
step: step,
|
|
75
|
+
stepAttribution: stepAttributions[index]
|
|
76
|
+
};
|
|
77
|
+
}), originalDoc);
|
|
78
|
+
return stepsToFilter.filter(function (_ref) {
|
|
79
|
+
var step = _ref.step;
|
|
80
|
+
return !(step instanceof AnalyticsStep);
|
|
81
|
+
}).reduce(function (acc, current) {
|
|
82
|
+
var _previous$step$merge, _previous$step$merge2, _previous$step;
|
|
83
|
+
var previous = acc[acc.length - 1];
|
|
84
|
+
var isSameIdentity = previous && getAttributionKey(previous.stepAttribution) === getAttributionKey(current.stepAttribution);
|
|
85
|
+
var merged = isSameIdentity ? (_previous$step$merge = (_previous$step$merge2 = (_previous$step = previous.step).merge) === null || _previous$step$merge2 === void 0 ? void 0 : _previous$step$merge2.call(_previous$step, current.step)) !== null && _previous$step$merge !== void 0 ? _previous$step$merge : mergeReplaceSteps(previous.step, current.step) : null;
|
|
86
|
+
if (merged) {
|
|
87
|
+
acc[acc.length - 1] = {
|
|
88
|
+
step: merged,
|
|
89
|
+
stepAttribution: mergeAttributions(previous.stepAttribution, current.stepAttribution)
|
|
90
|
+
};
|
|
91
|
+
} else {
|
|
92
|
+
acc.push(current);
|
|
93
|
+
}
|
|
94
|
+
return acc;
|
|
95
|
+
}, []);
|
|
96
|
+
}
|
|
49
97
|
|
|
50
98
|
/**
|
|
51
99
|
* Does a first pass to remove steps that don't impact the document
|
|
52
100
|
*/
|
|
53
|
-
function
|
|
101
|
+
function removeUnusedAttributedSteps(stepsWithAttribution, originalDoc) {
|
|
54
102
|
var finalSteps = [];
|
|
55
103
|
var firstPassDoc = originalDoc;
|
|
56
|
-
var _iterator = _createForOfIteratorHelper(
|
|
104
|
+
var _iterator = _createForOfIteratorHelper(stepsWithAttribution),
|
|
57
105
|
_step;
|
|
58
106
|
try {
|
|
59
107
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
60
|
-
var
|
|
108
|
+
var stepWithAttribution = _step.value;
|
|
109
|
+
var step = stepWithAttribution.step;
|
|
61
110
|
var result = step.apply(firstPassDoc);
|
|
62
111
|
if (result.failed === null && result.doc && !areNodesEqualIgnoreAttrs(firstPassDoc, result.doc, ['localId'])) {
|
|
63
|
-
finalSteps.push(
|
|
112
|
+
finalSteps.push(stepWithAttribution);
|
|
64
113
|
firstPassDoc = result.doc;
|
|
65
114
|
}
|
|
66
115
|
}
|
|
@@ -70,4 +119,29 @@ function removeUnusedSteps(steps, originalDoc) {
|
|
|
70
119
|
_iterator.f();
|
|
71
120
|
}
|
|
72
121
|
return finalSteps;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Does a first pass to remove steps that don't impact the document
|
|
126
|
+
*/
|
|
127
|
+
function removeUnusedSteps(steps, originalDoc) {
|
|
128
|
+
var finalSteps = [];
|
|
129
|
+
var firstPassDoc = originalDoc;
|
|
130
|
+
var _iterator2 = _createForOfIteratorHelper(steps),
|
|
131
|
+
_step2;
|
|
132
|
+
try {
|
|
133
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
134
|
+
var step = _step2.value;
|
|
135
|
+
var result = step.apply(firstPassDoc);
|
|
136
|
+
if (result.failed === null && result.doc && !areNodesEqualIgnoreAttrs(firstPassDoc, result.doc, ['localId'])) {
|
|
137
|
+
finalSteps.push(step);
|
|
138
|
+
firstPassDoc = result.doc;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
_iterator2.e(err);
|
|
143
|
+
} finally {
|
|
144
|
+
_iterator2.f();
|
|
145
|
+
}
|
|
146
|
+
return finalSteps;
|
|
73
147
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
|
+
var ATTRIBUTION_COLOR_PALETTE = ['purple', 'blue', 'teal', 'magenta', 'orange', 'green'];
|
|
6
|
+
|
|
7
|
+
/** `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared users. */
|
|
8
|
+
export var getAttributionKey = function getAttributionKey(attribution) {
|
|
9
|
+
var _attribution$userId, _attribution$agentId, _attribution$agentTyp;
|
|
10
|
+
var userId = attribution === null || attribution === void 0 || (_attribution$userId = attribution.userId) === null || _attribution$userId === void 0 ? void 0 : _attribution$userId.trim();
|
|
11
|
+
var agentId = attribution === null || attribution === void 0 || (_attribution$agentId = attribution.agentId) === null || _attribution$agentId === void 0 ? void 0 : _attribution$agentId.trim();
|
|
12
|
+
var agentType = attribution === null || attribution === void 0 || (_attribution$agentTyp = attribution.agentType) === null || _attribution$agentTyp === void 0 ? void 0 : _attribution$agentTyp.trim();
|
|
13
|
+
if (!userId && !agentId && !agentType) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
var agentIdentity = agentId || (agentType ? "type:".concat(agentType) : '');
|
|
17
|
+
return "user:".concat(userId !== null && userId !== void 0 ? userId : '', "|agent:").concat(agentIdentity);
|
|
18
|
+
};
|
|
19
|
+
export var areAttributionColorGatesEnabled = function areAttributionColorGatesEnabled() {
|
|
20
|
+
return fg('confluence_ncs_step_diffing_version_history') && isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor');
|
|
21
|
+
};
|
|
22
|
+
export var isAttributionColoringEnabled = function isAttributionColoringEnabled(stepAttributions) {
|
|
23
|
+
return areAttributionColorGatesEnabled() && (stepAttributions === null || stepAttributions === void 0 ? void 0 : stepAttributions.some(function (attribution) {
|
|
24
|
+
return getAttributionKey(attribution) !== undefined;
|
|
25
|
+
})) === true;
|
|
26
|
+
};
|
|
27
|
+
export var createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
|
|
28
|
+
var keys = Array.from(new Set(stepAttributions.map(getAttributionKey).filter(function (key) {
|
|
29
|
+
return key !== undefined;
|
|
30
|
+
}))).sort();
|
|
31
|
+
return new Map(keys.map(function (key, index) {
|
|
32
|
+
return [key, ATTRIBUTION_COLOR_PALETTE[index % ATTRIBUTION_COLOR_PALETTE.length]];
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
var getLatestAttribution = function getLatestAttribution(changes) {
|
|
36
|
+
var data = changes.flatMap(function (change) {
|
|
37
|
+
return [].concat(_toConsumableArray(change.deleted), _toConsumableArray(change.inserted));
|
|
38
|
+
}).map(function (span) {
|
|
39
|
+
return span.data;
|
|
40
|
+
}).filter(function (value) {
|
|
41
|
+
return _typeof(value) === 'object' && value !== null && 'stepIndex' in value && typeof value.stepIndex === 'number';
|
|
42
|
+
});
|
|
43
|
+
return data.reduce(function (latest, attribution) {
|
|
44
|
+
return !latest || attribution.stepIndex > latest.stepIndex ? attribution : latest;
|
|
45
|
+
}, undefined);
|
|
46
|
+
};
|
|
47
|
+
var rangesOverlap = function rangesOverlap(fromA, toA, fromB, toB) {
|
|
48
|
+
return fromA < toB && fromB < toA;
|
|
49
|
+
};
|
|
50
|
+
var changesOverlap = function changesOverlap(change, attributedChange) {
|
|
51
|
+
var insertedOverlap = change.inserted.length > 0 && attributedChange.inserted.length > 0 && rangesOverlap(change.fromB, change.toB, attributedChange.fromB, attributedChange.toB);
|
|
52
|
+
var deletedOverlap = change.deleted.length > 0 && attributedChange.deleted.length > 0 && rangesOverlap(change.fromA, change.toA, attributedChange.fromA, attributedChange.toA);
|
|
53
|
+
return insertedOverlap || deletedOverlap;
|
|
54
|
+
};
|
|
55
|
+
export var getColorSchemeForChange = function getColorSchemeForChange(change, attributedChanges, attributionColors, fallback) {
|
|
56
|
+
var _attributionColors$ge;
|
|
57
|
+
var key = getAttributionKey(getLatestAttribution(attributedChanges.filter(function (attributedChange) {
|
|
58
|
+
return changesOverlap(change, attributedChange);
|
|
59
|
+
})));
|
|
60
|
+
return key ? (_attributionColors$ge = attributionColors.get(key)) !== null && _attributionColors$ge !== void 0 ? _attributionColors$ge : fallback : fallback;
|
|
61
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1
4
|
/** Green insertions, red deletions. */
|
|
2
5
|
export var traditionalScheme = {
|
|
3
6
|
insertColor: 'green',
|
|
@@ -52,9 +55,29 @@ export var standardScheme = {
|
|
|
52
55
|
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
53
56
|
strikesDeletedEmbedCard: false
|
|
54
57
|
};
|
|
58
|
+
var createAttributionScheme = function createAttributionScheme(color) {
|
|
59
|
+
return _objectSpread(_objectSpread({}, standardScheme), {}, {
|
|
60
|
+
insertColor: color,
|
|
61
|
+
insertActiveColor: color,
|
|
62
|
+
deleteColor: color,
|
|
63
|
+
deleteActiveColor: color,
|
|
64
|
+
deletedCellColor: color
|
|
65
|
+
});
|
|
66
|
+
};
|
|
55
67
|
|
|
56
|
-
/** Maps
|
|
68
|
+
/** Maps public schemes and attribution-only accents to their data objects. */
|
|
57
69
|
export var colorSchemeRegistry = {
|
|
70
|
+
blue: createAttributionScheme('blue'),
|
|
71
|
+
green: createAttributionScheme('green'),
|
|
72
|
+
magenta: createAttributionScheme('magenta'),
|
|
73
|
+
orange: createAttributionScheme('orange'),
|
|
74
|
+
purple: createAttributionScheme('purple'),
|
|
75
|
+
teal: createAttributionScheme('teal'),
|
|
58
76
|
traditional: traditionalScheme,
|
|
59
77
|
standard: standardScheme
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
|
|
81
|
+
export var getLegacyColorScheme = function getLegacyColorScheme(colorScheme) {
|
|
82
|
+
return colorScheme === 'standard' || colorScheme === 'traditional' ? colorScheme : undefined;
|
|
60
83
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
3
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
9
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
7
10
|
import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedBlockNodeStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildInsertedBlockNodeStyle } from './colorSchemes/factory';
|
|
8
|
-
import { colorSchemeRegistry } from './colorSchemes/schemes';
|
|
11
|
+
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
9
12
|
import { createBlockIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
10
13
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
11
14
|
import { getBlockNodeStyleLegacy, resolveCellOverlayStyleLegacy } from './createBlockChangedDecoration.styles.legacy';
|
|
@@ -98,7 +101,9 @@ var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
|
|
|
98
101
|
* same style strings for both shipped schemes; see EDITOR-8281.
|
|
99
102
|
*/
|
|
100
103
|
var getBlockNodeStyle = function getBlockNodeStyle(props) {
|
|
101
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : getBlockNodeStyleLegacy(props)
|
|
104
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : getBlockNodeStyleLegacy(_objectSpread(_objectSpread({}, props), {}, {
|
|
105
|
+
colorScheme: getLegacyColorScheme(props.colorScheme)
|
|
106
|
+
}));
|
|
102
107
|
};
|
|
103
108
|
|
|
104
109
|
/**
|
|
@@ -172,7 +177,7 @@ export var createBlockChangedDecoration = function createBlockChangedDecoration(
|
|
|
172
177
|
var isEmptyCellBeingFilled = !isInserted && !!cellNode && isCellEmpty(cellNode);
|
|
173
178
|
var useAddedStyle = isInserted || isEmptyCellBeingFilled;
|
|
174
179
|
var cellOverlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? useAddedStyle ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
|
|
175
|
-
colorScheme: colorScheme,
|
|
180
|
+
colorScheme: getLegacyColorScheme(colorScheme),
|
|
176
181
|
isRoundedTable: isRoundedTable,
|
|
177
182
|
useAddedStyle: useAddedStyle
|
|
178
183
|
});
|
|
@@ -13,7 +13,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
13
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
14
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
15
15
|
import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildDeletedRowStyle } from './colorSchemes/factory';
|
|
16
|
-
import { colorSchemeRegistry } from './colorSchemes/schemes';
|
|
16
|
+
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
17
17
|
import { resolveCellOverlayStyleLegacy, resolveDeletedRowStyleLegacy } from './createChangedRowDecorationWidgets.styles.legacy';
|
|
18
18
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
19
19
|
import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
@@ -134,7 +134,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
|
|
|
134
134
|
|
|
135
135
|
// Inserted rows keep their natural styling; the row strikethrough is deletions only.
|
|
136
136
|
if (!isExtendedEnabled(diffType) || !isInserted) {
|
|
137
|
-
tr.setAttribute('style', isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? buildDeletedRowStyle(colors) : resolveDeletedRowStyleLegacy(colorScheme));
|
|
137
|
+
tr.setAttribute('style', isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? buildDeletedRowStyle(colors) : resolveDeletedRowStyleLegacy(getLegacyColorScheme(colorScheme)));
|
|
138
138
|
}
|
|
139
139
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
140
140
|
|
|
@@ -150,7 +150,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
|
|
|
150
150
|
var overlay = document.createElement('span');
|
|
151
151
|
var isRoundedTable = expValEquals('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
152
152
|
var overlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? isInserted ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
|
|
153
|
-
colorScheme: colorScheme,
|
|
153
|
+
colorScheme: getLegacyColorScheme(colorScheme),
|
|
154
154
|
isInserted: isInserted,
|
|
155
155
|
isRoundedTable: isRoundedTable
|
|
156
156
|
});
|
|
@@ -7,7 +7,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
9
9
|
import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
|
|
10
|
-
import { colorSchemeRegistry } from './colorSchemes/schemes';
|
|
10
|
+
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
11
11
|
import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
12
12
|
import { getAtomicInlineNodeClassNameLegacy, resolveInlineChangedStyleLegacy } from './createInlineChangedDecoration.styles.legacy';
|
|
13
13
|
import { buildDiffDecorationSpec } from './decorationKeys';
|
|
@@ -70,7 +70,9 @@ var resolveInlineChangedStyleRefactored = function resolveInlineChangedStyleRefa
|
|
|
70
70
|
* verbatim pre-refactor per-scheme constants when it is off.
|
|
71
71
|
*/
|
|
72
72
|
var resolveInlineChangedStyle = function resolveInlineChangedStyle(args) {
|
|
73
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : resolveInlineChangedStyleLegacy(args)
|
|
73
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : resolveInlineChangedStyleLegacy(_objectSpread(_objectSpread({}, args), {}, {
|
|
74
|
+
colorScheme: getLegacyColorScheme(args.colorScheme)
|
|
75
|
+
}));
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -84,7 +86,7 @@ var resolveAtomicInlineAttrs = function resolveAtomicInlineAttrs(inlineNodeName,
|
|
|
84
86
|
className: getAtomicInlineNodeClassName(inlineNodeName),
|
|
85
87
|
styleSuffix: buildAtomicInlineChangedCSSVariables(colors)
|
|
86
88
|
} : {
|
|
87
|
-
className: getAtomicInlineNodeClassNameLegacy(inlineNodeName, colorScheme),
|
|
89
|
+
className: getAtomicInlineNodeClassNameLegacy(inlineNodeName, getLegacyColorScheme(colorScheme)),
|
|
88
90
|
styleSuffix: ''
|
|
89
91
|
};
|
|
90
92
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import isEqual from 'lodash/isEqual';
|
|
5
|
+
import omit from 'lodash/omit';
|
|
4
6
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
5
7
|
import { isExperimentEnabled } from '@atlaskit/editor-common/deprecated-platform-feature-experiments';
|
|
6
8
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
7
9
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
12
|
import { getRequiredIncludedDiffableAttrs, isDiffableAttr } from './diffableAttrs';
|
|
10
13
|
var filterUndefined = function filterUndefined(x) {
|
|
@@ -34,33 +37,57 @@ var isInlineAttrChangeNodeName = function isInlineAttrChangeNodeName(nodeName) {
|
|
|
34
37
|
// Extension node type names. Their "any attr except localId" exclude rule lives
|
|
35
38
|
// in the shared `diffableAttrs` map and is applied via `isDiffableAttr` below.
|
|
36
39
|
var extensionNodeNames = ['extension', 'inlineExtension', 'bodiedExtension'];
|
|
40
|
+
var transientExtensionAttrPaths = ['localId', 'parameters.macroParams._parentId'];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Removes extension metadata that can change between document versions without changing the
|
|
44
|
+
* extension's user-visible configuration.
|
|
45
|
+
*/
|
|
46
|
+
var getComparableExtensionAttrs = function getComparableExtensionAttrs(node) {
|
|
47
|
+
return omit(node.attrs, transientExtensionAttrPaths);
|
|
48
|
+
};
|
|
49
|
+
var haveSameRelevantExtensionAttrs = function haveSameRelevantExtensionAttrs(beforeNode, afterNode) {
|
|
50
|
+
return isEqual(getComparableExtensionAttrs(beforeNode), getComparableExtensionAttrs(afterNode));
|
|
51
|
+
};
|
|
37
52
|
var getStepAttrs = function getStepAttrs(step) {
|
|
38
53
|
if (step instanceof AttrStep) {
|
|
39
54
|
return [step.attr];
|
|
40
55
|
}
|
|
41
|
-
if (step
|
|
56
|
+
if (step.attrs) {
|
|
42
57
|
return Object.keys(step.attrs);
|
|
43
58
|
}
|
|
44
59
|
return [];
|
|
45
60
|
};
|
|
46
|
-
export var getAttrChangeRanges = function getAttrChangeRanges(doc,
|
|
47
|
-
return
|
|
61
|
+
export var getAttrChangeRanges = function getAttrChangeRanges(doc, attrStepContexts, originalDoc) {
|
|
62
|
+
return attrStepContexts.map(function (attrStepContext) {
|
|
63
|
+
var afterNode = attrStepContext.afterNode,
|
|
64
|
+
beforeNode = attrStepContext.beforeNode,
|
|
65
|
+
finalPos = attrStepContext.finalPos,
|
|
66
|
+
originalPos = attrStepContext.originalPos,
|
|
67
|
+
step = attrStepContext.step;
|
|
48
68
|
if (!(step instanceof AttrStep) && !(step instanceof SetAttrsStep)) {
|
|
49
69
|
return undefined;
|
|
50
70
|
}
|
|
51
71
|
var stepAttrs = getStepAttrs(step);
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
// SetAttrsStep contains the complete replacement attrs, not only the attrs that changed.
|
|
73
|
+
// Keep the legacy payload-based checks until the rollout gate is enabled, and fall back
|
|
74
|
+
// to them if either step-time node is unavailable.
|
|
75
|
+
var attrsToCheck = fg('platform_editor_reduce_diff_attr_sensitivity') && beforeNode && afterNode ? stepAttrs.filter(function (attrName) {
|
|
76
|
+
return !isEqual(beforeNode.attrs[attrName], afterNode.attrs[attrName]);
|
|
77
|
+
}) : stepAttrs;
|
|
78
|
+
var $pos = doc.resolve(finalPos);
|
|
79
|
+
var nodeAtPos = doc.nodeAt(finalPos);
|
|
80
|
+
var originalNodeAtPos = originalPos === undefined ? null : originalDoc.nodeAt(originalPos);
|
|
54
81
|
|
|
55
82
|
// date node: timestamp attribute change — highlight the date node itself (inline)
|
|
56
|
-
if (
|
|
83
|
+
if (attrsToCheck.some(function (v) {
|
|
57
84
|
return dateAttrs.includes(v);
|
|
58
85
|
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'date' && !isExperimentEnabled('platform_editor_improve_inline_diffs', function () {
|
|
59
86
|
return expValEquals('platform_editor_improve_inline_diffs', 'isEnabled', true);
|
|
60
87
|
})) {
|
|
61
88
|
return {
|
|
62
|
-
fromB:
|
|
63
|
-
toB:
|
|
89
|
+
fromB: finalPos,
|
|
90
|
+
toB: finalPos + nodeAtPos.nodeSize,
|
|
64
91
|
isInline: true,
|
|
65
92
|
inlineNodeName: 'date'
|
|
66
93
|
};
|
|
@@ -75,30 +102,29 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps, origin
|
|
|
75
102
|
var nodeName = nodeAtPos.type.name;
|
|
76
103
|
if (isInlineAttrChangeNodeName(nodeName)) {
|
|
77
104
|
var watchedAttrs = inlineNodeAttrMap[nodeName];
|
|
78
|
-
if (
|
|
105
|
+
if (attrsToCheck.some(function (v) {
|
|
79
106
|
return watchedAttrs.includes(v);
|
|
80
107
|
})) {
|
|
81
|
-
var originalNodeAtPos = originalDoc === null || originalDoc === void 0 ? void 0 : originalDoc.nodeAt(step.pos);
|
|
82
108
|
return _objectSpread({
|
|
83
|
-
fromB:
|
|
84
|
-
toB:
|
|
109
|
+
fromB: finalPos,
|
|
110
|
+
toB: finalPos + nodeAtPos.nodeSize,
|
|
85
111
|
isInline: true,
|
|
86
112
|
inlineNodeName: nodeName
|
|
87
|
-
}, originalNodeAtPos && {
|
|
88
|
-
fromA:
|
|
89
|
-
toA:
|
|
113
|
+
}, originalPos !== undefined && originalNodeAtPos && {
|
|
114
|
+
fromA: originalPos,
|
|
115
|
+
toA: originalPos + originalNodeAtPos.nodeSize
|
|
90
116
|
});
|
|
91
117
|
}
|
|
92
118
|
}
|
|
93
119
|
}
|
|
94
120
|
|
|
95
121
|
// taskItem node: state attribute change — highlight the taskItem node
|
|
96
|
-
if (
|
|
122
|
+
if (attrsToCheck.some(function (v) {
|
|
97
123
|
return taskItemAttrs.includes(v);
|
|
98
124
|
}) && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type.name) === 'taskItem') {
|
|
99
125
|
return {
|
|
100
|
-
fromB:
|
|
101
|
-
toB:
|
|
126
|
+
fromB: finalPos,
|
|
127
|
+
toB: finalPos + nodeAtPos.nodeSize
|
|
102
128
|
};
|
|
103
129
|
}
|
|
104
130
|
|
|
@@ -106,33 +132,36 @@ export var getAttrChangeRanges = function getAttrChangeRanges(doc, steps, origin
|
|
|
106
132
|
// (e.g. note -> warning) — highlight the new panel and, when the original node
|
|
107
133
|
// is resolvable, expose its range (fromA/toA) so the caller can render the old
|
|
108
134
|
// panel as a "deleted" widget for a before/after comparison.
|
|
109
|
-
if (
|
|
135
|
+
if (attrsToCheck.some(function (v) {
|
|
110
136
|
return panelAttrs.includes(v);
|
|
111
137
|
}) && nodeAtPos && getBaseNodeTypeName(nodeAtPos.type) === 'panel') {
|
|
112
|
-
var _originalNodeAtPos = originalDoc === null || originalDoc === void 0 ? void 0 : originalDoc.nodeAt(step.pos);
|
|
113
138
|
return _objectSpread({
|
|
114
|
-
fromB:
|
|
115
|
-
toB:
|
|
116
|
-
},
|
|
117
|
-
fromA:
|
|
118
|
-
toA:
|
|
139
|
+
fromB: finalPos,
|
|
140
|
+
toB: finalPos + nodeAtPos.nodeSize
|
|
141
|
+
}, originalPos !== undefined && originalNodeAtPos && {
|
|
142
|
+
fromA: originalPos,
|
|
143
|
+
toA: originalPos + originalNodeAtPos.nodeSize
|
|
119
144
|
});
|
|
120
145
|
}
|
|
121
146
|
|
|
122
|
-
//
|
|
123
|
-
|
|
147
|
+
// Extension nodes: highlight changes to user-visible configuration. When enabled,
|
|
148
|
+
// transient extension metadata is ignored by the comparison below.
|
|
149
|
+
if (nodeAtPos && extensionNodeNames.includes(nodeAtPos.type.name) && attrsToCheck.some(function (v) {
|
|
124
150
|
return isDiffableAttr(nodeAtPos.type.name, v);
|
|
125
151
|
})) {
|
|
152
|
+
if (fg('platform_editor_reduce_diff_attr_sensitivity') && beforeNode && afterNode && beforeNode.type === afterNode.type && haveSameRelevantExtensionAttrs(beforeNode, afterNode)) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
126
155
|
var isInline = nodeAtPos.type.name === 'inlineExtension';
|
|
127
156
|
return {
|
|
128
|
-
fromB:
|
|
129
|
-
toB:
|
|
157
|
+
fromB: finalPos,
|
|
158
|
+
toB: finalPos + nodeAtPos.nodeSize,
|
|
130
159
|
isInline: isInline
|
|
131
160
|
};
|
|
132
161
|
}
|
|
133
162
|
|
|
134
163
|
// media node: id/collection/url attribute change — highlight the mediaSingle parent
|
|
135
|
-
if (
|
|
164
|
+
if (attrsToCheck.some(function (v) {
|
|
136
165
|
return mediaAttrs.includes(v);
|
|
137
166
|
}) && $pos.parent.type === doc.type.schema.nodes.mediaSingle) {
|
|
138
167
|
var startPos = $pos.pos + $pos.parentOffset;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1
4
|
/**
|
|
2
5
|
* Style resolution for the `wrapBlockNodeView` nodeview decorations.
|
|
3
6
|
*
|
|
@@ -14,7 +17,7 @@ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-e
|
|
|
14
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
18
|
import { isExtendedEnabled } from '../../isExtendedEnabled';
|
|
16
19
|
import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildAddedCellOverlayStyleNew, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildDeletedInlineContentStyle, buildDeletedInlineContentStyleExtended, buildDeletedLozengeActiveStyle, buildDeletedLozengeStyle, buildDeletedNodeCSSVariables, buildDeletedQuoteNodeWithLozengeStyle, buildDeletedStrikethroughLine, buildDeletedWrappedBlockOutline, buildInsertedBlockNodeStyle, buildInsertedInlineStyle, buildInsertStyleInBlockExtended, buildInsertStyleInBlockExtendedNoUnderline, buildInsertStyleNode } from '../colorSchemes/factory';
|
|
17
|
-
import { colorSchemeRegistry, standardScheme } from '../colorSchemes/schemes';
|
|
20
|
+
import { colorSchemeRegistry, getLegacyColorScheme, standardScheme } from '../colorSchemes/schemes';
|
|
18
21
|
import { getChangedContentStyleLegacy, getChangedNodeStyleLegacy, getDeletedContentStyleLegacy, getDeletedContentStyleUnboundedLegacy, getInsertedContentStyleLegacy, hasRestingDeletedRingLegacy, resolveCellOverlayStyleLegacy, resolveNestedInsertedNodeStyleLegacy, resolveRemovedLozengeStyleLegacy } from './wrapBlockNodeViewStyles.legacy';
|
|
19
22
|
var DEFAULT_COLOR_SCHEME = 'standard';
|
|
20
23
|
var getColorScheme = function getColorScheme(colorScheme) {
|
|
@@ -135,7 +138,7 @@ export var getChangedContentStyle = function getChangedContentStyle(colorScheme)
|
|
|
135
138
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
136
139
|
var diffType = arguments.length > 3 ? arguments[3] : undefined;
|
|
137
140
|
var hideAddedDiffsUnderline = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
138
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : getChangedContentStyleLegacy(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
|
|
141
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : getChangedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, isInserted, diffType, hideAddedDiffsUnderline);
|
|
139
142
|
};
|
|
140
143
|
|
|
141
144
|
/** Node-specific style for a changed block node, or `undefined` when the node type has none. */
|
|
@@ -144,27 +147,27 @@ export var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorSch
|
|
|
144
147
|
var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
145
148
|
var diffType = arguments.length > 4 ? arguments[4] : undefined;
|
|
146
149
|
var hideAddedDiffsUnderline = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
147
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : getChangedNodeStyleLegacy(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
150
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : getChangedNodeStyleLegacy(nodeName, getLegacyColorScheme(colorScheme), isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
148
151
|
};
|
|
149
152
|
|
|
150
153
|
/** The positioned line drawn across deleted content spanning an unbounded range. */
|
|
151
154
|
export var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
152
155
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
153
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : getDeletedContentStyleUnboundedLegacy(colorScheme, isActive);
|
|
156
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : getDeletedContentStyleUnboundedLegacy(getLegacyColorScheme(colorScheme), isActive);
|
|
154
157
|
};
|
|
155
158
|
|
|
156
159
|
/** Inline style for inserted content. */
|
|
157
160
|
export var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
158
161
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
159
162
|
var hideAddedDiffsUnderline = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
160
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : getInsertedContentStyleLegacy(colorScheme, isActive, hideAddedDiffsUnderline);
|
|
163
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : getInsertedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, hideAddedDiffsUnderline);
|
|
161
164
|
};
|
|
162
165
|
|
|
163
166
|
/** Inline style for deleted content. */
|
|
164
167
|
export var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
165
168
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
166
169
|
var diffType = arguments.length > 2 ? arguments[2] : undefined;
|
|
167
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : getDeletedContentStyleLegacy(colorScheme, isActive, diffType);
|
|
170
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : getDeletedContentStyleLegacy(getLegacyColorScheme(colorScheme), isActive, diffType);
|
|
168
171
|
};
|
|
169
172
|
|
|
170
173
|
/**
|
|
@@ -172,12 +175,14 @@ export var getDeletedContentStyle = function getDeletedContentStyle(colorScheme)
|
|
|
172
175
|
* `querySelectorAll('td, th')` loop in `wrapBlockNodeView.ts` resolves it once.
|
|
173
176
|
*/
|
|
174
177
|
export var resolveCellOverlayStyle = function resolveCellOverlayStyle(args) {
|
|
175
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : resolveCellOverlayStyleLegacy(args)
|
|
178
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : resolveCellOverlayStyleLegacy(_objectSpread(_objectSpread({}, args), {}, {
|
|
179
|
+
colorScheme: getLegacyColorScheme(args.colorScheme)
|
|
180
|
+
}));
|
|
176
181
|
};
|
|
177
182
|
|
|
178
183
|
/** Inner style for the "Removed" lozenge on a deleted block node. */
|
|
179
184
|
export var resolveRemovedLozengeStyle = function resolveRemovedLozengeStyle(colorScheme, isActive) {
|
|
180
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : resolveRemovedLozengeStyleLegacy(colorScheme, isActive);
|
|
185
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : resolveRemovedLozengeStyleLegacy(getLegacyColorScheme(colorScheme), isActive);
|
|
181
186
|
};
|
|
182
187
|
|
|
183
188
|
/**
|
|
@@ -194,7 +199,7 @@ export var resolveNestedInsertedNodeStyle = function resolveNestedInsertedNodeSt
|
|
|
194
199
|
* is what the `show-diff-deleted-outline-new` class styles in editor-core's smartCardStyles.
|
|
195
200
|
*/
|
|
196
201
|
export var hasRestingDeletedRing = function hasRestingDeletedRing(colorScheme) {
|
|
197
|
-
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : hasRestingDeletedRingLegacy(colorScheme);
|
|
202
|
+
return isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : hasRestingDeletedRingLegacy(getLegacyColorScheme(colorScheme));
|
|
198
203
|
};
|
|
199
204
|
|
|
200
205
|
/**
|
|
@@ -30,6 +30,7 @@ export var createPlugin = function createPlugin(config, getIntl, api, onEditorVi
|
|
|
30
30
|
var defaultDiffType = getDefaultDiffType();
|
|
31
31
|
return _objectSpread({
|
|
32
32
|
steps: [],
|
|
33
|
+
stepAttributions: [],
|
|
33
34
|
originalDoc: undefined,
|
|
34
35
|
decorations: DecorationSet.empty,
|
|
35
36
|
isDisplayingChanges: false
|