@atlaskit/editor-plugin-show-diff 14.0.4 → 14.1.0
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 +9 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +172 -97
- 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/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 +90 -19
- 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/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 +173 -98
- 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/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/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 +3 -3
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.simplifySteps = simplifySteps;
|
|
8
|
+
exports.simplifyStepsWithAttribution = simplifyStepsWithAttribution;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
10
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
8
11
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
9
12
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
13
|
+
var _attributions = require("../decorations/colorSchemes/attributions");
|
|
10
14
|
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; } } }; }
|
|
11
15
|
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; } }
|
|
12
16
|
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; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
13
19
|
/**
|
|
14
20
|
* Attempts to merge two consecutive ReplaceStep operations.
|
|
15
21
|
* This merges steps where:
|
|
@@ -51,21 +57,67 @@ function simplifySteps(steps, originalDoc) {
|
|
|
51
57
|
return acc;
|
|
52
58
|
}, []);
|
|
53
59
|
}
|
|
60
|
+
var mergeAttributions = function mergeAttributions(first, second) {
|
|
61
|
+
var _second$wasOffline;
|
|
62
|
+
if (!first) {
|
|
63
|
+
return second;
|
|
64
|
+
}
|
|
65
|
+
if (!second) {
|
|
66
|
+
return first;
|
|
67
|
+
}
|
|
68
|
+
return _objectSpread(_objectSpread(_objectSpread({}, first), second), {}, {
|
|
69
|
+
wasOffline: first.wasOffline === true || second.wasOffline === true ? true : (_second$wasOffline = second.wasOffline) !== null && _second$wasOffline !== void 0 ? _second$wasOffline : first.wasOffline
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Attribution-preserving variant of `simplifySteps`.
|
|
75
|
+
*
|
|
76
|
+
* Steps may only merge when they have the same effective actor identity. Keeping the attribution
|
|
77
|
+
* coupled to the step also ensures filtering a no-op/analytics step cannot shift array indexes.
|
|
78
|
+
*/
|
|
79
|
+
function simplifyStepsWithAttribution(steps, stepAttributions, originalDoc) {
|
|
80
|
+
var stepsToFilter = removeUnusedAttributedSteps(steps.map(function (step, index) {
|
|
81
|
+
return {
|
|
82
|
+
step: step,
|
|
83
|
+
stepAttribution: stepAttributions[index]
|
|
84
|
+
};
|
|
85
|
+
}), originalDoc);
|
|
86
|
+
return stepsToFilter.filter(function (_ref) {
|
|
87
|
+
var step = _ref.step;
|
|
88
|
+
return !(step instanceof _steps.AnalyticsStep);
|
|
89
|
+
}).reduce(function (acc, current) {
|
|
90
|
+
var _previous$step$merge, _previous$step$merge2, _previous$step;
|
|
91
|
+
var previous = acc[acc.length - 1];
|
|
92
|
+
var isSameIdentity = previous && (0, _attributions.getAttributionKey)(previous.stepAttribution) === (0, _attributions.getAttributionKey)(current.stepAttribution);
|
|
93
|
+
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;
|
|
94
|
+
if (merged) {
|
|
95
|
+
acc[acc.length - 1] = {
|
|
96
|
+
step: merged,
|
|
97
|
+
stepAttribution: mergeAttributions(previous.stepAttribution, current.stepAttribution)
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
acc.push(current);
|
|
101
|
+
}
|
|
102
|
+
return acc;
|
|
103
|
+
}, []);
|
|
104
|
+
}
|
|
54
105
|
|
|
55
106
|
/**
|
|
56
107
|
* Does a first pass to remove steps that don't impact the document
|
|
57
108
|
*/
|
|
58
|
-
function
|
|
109
|
+
function removeUnusedAttributedSteps(stepsWithAttribution, originalDoc) {
|
|
59
110
|
var finalSteps = [];
|
|
60
111
|
var firstPassDoc = originalDoc;
|
|
61
|
-
var _iterator = _createForOfIteratorHelper(
|
|
112
|
+
var _iterator = _createForOfIteratorHelper(stepsWithAttribution),
|
|
62
113
|
_step;
|
|
63
114
|
try {
|
|
64
115
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
65
|
-
var
|
|
116
|
+
var stepWithAttribution = _step.value;
|
|
117
|
+
var step = stepWithAttribution.step;
|
|
66
118
|
var result = step.apply(firstPassDoc);
|
|
67
119
|
if (result.failed === null && result.doc && !(0, _document.areNodesEqualIgnoreAttrs)(firstPassDoc, result.doc, ['localId'])) {
|
|
68
|
-
finalSteps.push(
|
|
120
|
+
finalSteps.push(stepWithAttribution);
|
|
69
121
|
firstPassDoc = result.doc;
|
|
70
122
|
}
|
|
71
123
|
}
|
|
@@ -75,4 +127,29 @@ function removeUnusedSteps(steps, originalDoc) {
|
|
|
75
127
|
_iterator.f();
|
|
76
128
|
}
|
|
77
129
|
return finalSteps;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Does a first pass to remove steps that don't impact the document
|
|
134
|
+
*/
|
|
135
|
+
function removeUnusedSteps(steps, originalDoc) {
|
|
136
|
+
var finalSteps = [];
|
|
137
|
+
var firstPassDoc = originalDoc;
|
|
138
|
+
var _iterator2 = _createForOfIteratorHelper(steps),
|
|
139
|
+
_step2;
|
|
140
|
+
try {
|
|
141
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
142
|
+
var step = _step2.value;
|
|
143
|
+
var result = step.apply(firstPassDoc);
|
|
144
|
+
if (result.failed === null && result.doc && !(0, _document.areNodesEqualIgnoreAttrs)(firstPassDoc, result.doc, ['localId'])) {
|
|
145
|
+
finalSteps.push(step);
|
|
146
|
+
firstPassDoc = result.doc;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
_iterator2.e(err);
|
|
151
|
+
} finally {
|
|
152
|
+
_iterator2.f();
|
|
153
|
+
}
|
|
154
|
+
return finalSteps;
|
|
78
155
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isAttributionColoringEnabled = exports.getColorSchemeForChange = exports.getAttributionKey = exports.createAttributionColorMap = exports.areAttributionColorGatesEnabled = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
12
|
+
var ATTRIBUTION_COLOR_PALETTE = ['purple', 'blue', 'teal', 'magenta', 'orange', 'green'];
|
|
13
|
+
|
|
14
|
+
/** `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared users. */
|
|
15
|
+
var getAttributionKey = exports.getAttributionKey = function getAttributionKey(attribution) {
|
|
16
|
+
var _attribution$userId, _attribution$agentId, _attribution$agentTyp;
|
|
17
|
+
var userId = attribution === null || attribution === void 0 || (_attribution$userId = attribution.userId) === null || _attribution$userId === void 0 ? void 0 : _attribution$userId.trim();
|
|
18
|
+
var agentId = attribution === null || attribution === void 0 || (_attribution$agentId = attribution.agentId) === null || _attribution$agentId === void 0 ? void 0 : _attribution$agentId.trim();
|
|
19
|
+
var agentType = attribution === null || attribution === void 0 || (_attribution$agentTyp = attribution.agentType) === null || _attribution$agentTyp === void 0 ? void 0 : _attribution$agentTyp.trim();
|
|
20
|
+
if (!userId && !agentId && !agentType) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
var agentIdentity = agentId || (agentType ? "type:".concat(agentType) : '');
|
|
24
|
+
return "user:".concat(userId !== null && userId !== void 0 ? userId : '', "|agent:").concat(agentIdentity);
|
|
25
|
+
};
|
|
26
|
+
var areAttributionColorGatesEnabled = exports.areAttributionColorGatesEnabled = function areAttributionColorGatesEnabled() {
|
|
27
|
+
return (0, _fg.fg)('confluence_ncs_step_diffing_version_history') && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor');
|
|
28
|
+
};
|
|
29
|
+
var isAttributionColoringEnabled = exports.isAttributionColoringEnabled = function isAttributionColoringEnabled(stepAttributions) {
|
|
30
|
+
return areAttributionColorGatesEnabled() && (stepAttributions === null || stepAttributions === void 0 ? void 0 : stepAttributions.some(function (attribution) {
|
|
31
|
+
return getAttributionKey(attribution) !== undefined;
|
|
32
|
+
})) === true;
|
|
33
|
+
};
|
|
34
|
+
var createAttributionColorMap = exports.createAttributionColorMap = function createAttributionColorMap(stepAttributions) {
|
|
35
|
+
var keys = Array.from(new Set(stepAttributions.map(getAttributionKey).filter(function (key) {
|
|
36
|
+
return key !== undefined;
|
|
37
|
+
}))).sort();
|
|
38
|
+
return new Map(keys.map(function (key, index) {
|
|
39
|
+
return [key, ATTRIBUTION_COLOR_PALETTE[index % ATTRIBUTION_COLOR_PALETTE.length]];
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
var getLatestAttribution = function getLatestAttribution(changes) {
|
|
43
|
+
var data = changes.flatMap(function (change) {
|
|
44
|
+
return [].concat((0, _toConsumableArray2.default)(change.deleted), (0, _toConsumableArray2.default)(change.inserted));
|
|
45
|
+
}).map(function (span) {
|
|
46
|
+
return span.data;
|
|
47
|
+
}).filter(function (value) {
|
|
48
|
+
return (0, _typeof2.default)(value) === 'object' && value !== null && 'stepIndex' in value && typeof value.stepIndex === 'number';
|
|
49
|
+
});
|
|
50
|
+
return data.reduce(function (latest, attribution) {
|
|
51
|
+
return !latest || attribution.stepIndex > latest.stepIndex ? attribution : latest;
|
|
52
|
+
}, undefined);
|
|
53
|
+
};
|
|
54
|
+
var rangesOverlap = function rangesOverlap(fromA, toA, fromB, toB) {
|
|
55
|
+
return fromA < toB && fromB < toA;
|
|
56
|
+
};
|
|
57
|
+
var changesOverlap = function changesOverlap(change, attributedChange) {
|
|
58
|
+
var insertedOverlap = change.inserted.length > 0 && attributedChange.inserted.length > 0 && rangesOverlap(change.fromB, change.toB, attributedChange.fromB, attributedChange.toB);
|
|
59
|
+
var deletedOverlap = change.deleted.length > 0 && attributedChange.deleted.length > 0 && rangesOverlap(change.fromA, change.toA, attributedChange.fromA, attributedChange.toA);
|
|
60
|
+
return insertedOverlap || deletedOverlap;
|
|
61
|
+
};
|
|
62
|
+
var getColorSchemeForChange = exports.getColorSchemeForChange = function getColorSchemeForChange(change, attributedChanges, attributionColors, fallback) {
|
|
63
|
+
var _attributionColors$ge;
|
|
64
|
+
var key = getAttributionKey(getLatestAttribution(attributedChanges.filter(function (attributedChange) {
|
|
65
|
+
return changesOverlap(change, attributedChange);
|
|
66
|
+
})));
|
|
67
|
+
return key ? (_attributionColors$ge = attributionColors.get(key)) !== null && _attributionColors$ge !== void 0 ? _attributionColors$ge : fallback : fallback;
|
|
68
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.traditionalScheme = exports.standardScheme = exports.colorSchemeRegistry = void 0;
|
|
7
|
+
exports.traditionalScheme = exports.standardScheme = exports.getLegacyColorScheme = exports.colorSchemeRegistry = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
7
11
|
/** Green insertions, red deletions. */
|
|
8
12
|
var traditionalScheme = exports.traditionalScheme = {
|
|
9
13
|
insertColor: 'green',
|
|
@@ -58,9 +62,29 @@ var standardScheme = exports.standardScheme = {
|
|
|
58
62
|
deletedQuoteNodeActiveTone: 'borderAccent',
|
|
59
63
|
strikesDeletedEmbedCard: false
|
|
60
64
|
};
|
|
65
|
+
var createAttributionScheme = function createAttributionScheme(color) {
|
|
66
|
+
return _objectSpread(_objectSpread({}, standardScheme), {}, {
|
|
67
|
+
insertColor: color,
|
|
68
|
+
insertActiveColor: color,
|
|
69
|
+
deleteColor: color,
|
|
70
|
+
deleteActiveColor: color,
|
|
71
|
+
deletedCellColor: color
|
|
72
|
+
});
|
|
73
|
+
};
|
|
61
74
|
|
|
62
|
-
/** Maps
|
|
75
|
+
/** Maps public schemes and attribution-only accents to their data objects. */
|
|
63
76
|
var colorSchemeRegistry = exports.colorSchemeRegistry = {
|
|
77
|
+
blue: createAttributionScheme('blue'),
|
|
78
|
+
green: createAttributionScheme('green'),
|
|
79
|
+
magenta: createAttributionScheme('magenta'),
|
|
80
|
+
orange: createAttributionScheme('orange'),
|
|
81
|
+
purple: createAttributionScheme('purple'),
|
|
82
|
+
teal: createAttributionScheme('teal'),
|
|
64
83
|
traditional: traditionalScheme,
|
|
65
84
|
standard: standardScheme
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
|
|
88
|
+
var getLegacyColorScheme = exports.getLegacyColorScheme = function getLegacyColorScheme(colorScheme) {
|
|
89
|
+
return colorScheme === 'standard' || colorScheme === 'traditional' ? colorScheme : undefined;
|
|
66
90
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createBlockChangedDecoration = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
12
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
@@ -16,6 +17,8 @@ var _schemes = require("./colorSchemes/schemes");
|
|
|
16
17
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
17
18
|
var _decorationKeys = require("./decorationKeys");
|
|
18
19
|
var _createBlockChangedDecorationStyles = require("./createBlockChangedDecoration.styles.legacy");
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
19
22
|
var displayNoneStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
20
23
|
display: 'none'
|
|
21
24
|
});
|
|
@@ -105,7 +108,9 @@ var getBlockNodeStyleNext = function getBlockNodeStyleNext(_ref) {
|
|
|
105
108
|
* same style strings for both shipped schemes; see EDITOR-8281.
|
|
106
109
|
*/
|
|
107
110
|
var getBlockNodeStyle = function getBlockNodeStyle(props) {
|
|
108
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : (0, _createBlockChangedDecorationStyles.getBlockNodeStyleLegacy)(props)
|
|
111
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getBlockNodeStyleNext(props) : (0, _createBlockChangedDecorationStyles.getBlockNodeStyleLegacy)(_objectSpread(_objectSpread({}, props), {}, {
|
|
112
|
+
colorScheme: (0, _schemes.getLegacyColorScheme)(props.colorScheme)
|
|
113
|
+
}));
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
/**
|
|
@@ -179,7 +184,7 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
179
184
|
var isEmptyCellBeingFilled = !isInserted && !!cellNode && isCellEmpty(cellNode);
|
|
180
185
|
var useAddedStyle = isInserted || isEmptyCellBeingFilled;
|
|
181
186
|
var cellOverlayStyle = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? useAddedStyle ? isRoundedTable ? (0, _factory.buildAddedCellOverlayRoundedStyle)(colors) : (0, _factory.buildAddedCellOverlayStyle)(colors) : isRoundedTable ? (0, _factory.buildDeletedCellOverlayRoundedStyle)(colors) : (0, _factory.buildDeletedCellOverlayStyle)(colors) : (0, _createBlockChangedDecorationStyles.resolveCellOverlayStyleLegacy)({
|
|
182
|
-
colorScheme: colorScheme,
|
|
187
|
+
colorScheme: (0, _schemes.getLegacyColorScheme)(colorScheme),
|
|
183
188
|
isRoundedTable: isRoundedTable,
|
|
184
189
|
useAddedStyle: useAddedStyle
|
|
185
190
|
});
|
|
@@ -141,7 +141,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
|
|
|
141
141
|
|
|
142
142
|
// Inserted rows keep their natural styling; the row strikethrough is deletions only.
|
|
143
143
|
if (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted) {
|
|
144
|
-
tr.setAttribute('style', (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? (0, _factory.buildDeletedRowStyle)(colors) : (0, _createChangedRowDecorationWidgetsStyles.resolveDeletedRowStyleLegacy)(colorScheme));
|
|
144
|
+
tr.setAttribute('style', (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? (0, _factory.buildDeletedRowStyle)(colors) : (0, _createChangedRowDecorationWidgetsStyles.resolveDeletedRowStyleLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme)));
|
|
145
145
|
}
|
|
146
146
|
tr.setAttribute('data-testid', 'show-diff-deleted-row');
|
|
147
147
|
|
|
@@ -157,7 +157,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, cellEdgeAttrs, n
|
|
|
157
157
|
var overlay = document.createElement('span');
|
|
158
158
|
var isRoundedTable = (0, _expValEquals.expValEquals)('platform_editor_table_diff_rounded_corners', 'isEnabled', true);
|
|
159
159
|
var overlayStyle = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? isInserted ? isRoundedTable ? (0, _factory.buildAddedCellOverlayRoundedStyle)(colors) : (0, _factory.buildAddedCellOverlayStyle)(colors) : isRoundedTable ? (0, _factory.buildDeletedCellOverlayRoundedStyle)(colors) : (0, _factory.buildDeletedCellOverlayStyle)(colors) : (0, _createChangedRowDecorationWidgetsStyles.resolveCellOverlayStyleLegacy)({
|
|
160
|
-
colorScheme: colorScheme,
|
|
160
|
+
colorScheme: (0, _schemes.getLegacyColorScheme)(colorScheme),
|
|
161
161
|
isInserted: isInserted,
|
|
162
162
|
isRoundedTable: isRoundedTable
|
|
163
163
|
});
|
|
@@ -77,7 +77,9 @@ var resolveInlineChangedStyleRefactored = function resolveInlineChangedStyleRefa
|
|
|
77
77
|
* verbatim pre-refactor per-scheme constants when it is off.
|
|
78
78
|
*/
|
|
79
79
|
var resolveInlineChangedStyle = function resolveInlineChangedStyle(args) {
|
|
80
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : (0, _createInlineChangedDecorationStyles.resolveInlineChangedStyleLegacy)(args)
|
|
80
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveInlineChangedStyleRefactored(args) : (0, _createInlineChangedDecorationStyles.resolveInlineChangedStyleLegacy)(_objectSpread(_objectSpread({}, args), {}, {
|
|
81
|
+
colorScheme: (0, _schemes.getLegacyColorScheme)(args.colorScheme)
|
|
82
|
+
}));
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
/**
|
|
@@ -91,7 +93,7 @@ var resolveAtomicInlineAttrs = function resolveAtomicInlineAttrs(inlineNodeName,
|
|
|
91
93
|
className: getAtomicInlineNodeClassName(inlineNodeName),
|
|
92
94
|
styleSuffix: (0, _factory.buildAtomicInlineChangedCSSVariables)(colors)
|
|
93
95
|
} : {
|
|
94
|
-
className: (0, _createInlineChangedDecorationStyles.getAtomicInlineNodeClassNameLegacy)(inlineNodeName, colorScheme),
|
|
96
|
+
className: (0, _createInlineChangedDecorationStyles.getAtomicInlineNodeClassNameLegacy)(inlineNodeName, (0, _schemes.getLegacyColorScheme)(colorScheme)),
|
|
95
97
|
styleSuffix: ''
|
|
96
98
|
};
|
|
97
99
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.resolveRemovedLozengeStyle = exports.resolveNestedInsertedNodeStyle = exports.resolveDeletedNodeCSSVariables = exports.resolveCellOverlayStyle = exports.isTextLikeBlockNode = exports.isMultiContainerBlockNode = exports.hasRestingDeletedRing = exports.getInsertedContentStyle = exports.getDeletedContentStyleUnbounded = exports.getDeletedContentStyle = exports.getChangedNodeStyle = exports.getChangedContentStyle = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
8
10
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
11
|
var _isExtendedEnabled = require("../../isExtendedEnabled");
|
|
10
12
|
var _factory = require("../colorSchemes/factory");
|
|
11
13
|
var _schemes = require("../colorSchemes/schemes");
|
|
12
14
|
var _wrapBlockNodeViewStyles = require("./wrapBlockNodeViewStyles.legacy");
|
|
13
|
-
|
|
15
|
+
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; }
|
|
16
|
+
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; } /**
|
|
14
17
|
* Style resolution for the `wrapBlockNodeView` nodeview decorations.
|
|
15
18
|
*
|
|
16
19
|
* Every exported resolver is a single gate: the `colorSchemeRegistry` + `factory.ts`
|
|
@@ -22,7 +25,6 @@ var _wrapBlockNodeViewStyles = require("./wrapBlockNodeViewStyles.legacy");
|
|
|
22
25
|
* On cleanup (EDITOR-8281): drop the `isExperimentEnabled` dispatch and the `*Legacy` imports,
|
|
23
26
|
* keeping the `*Next` bodies.
|
|
24
27
|
*/
|
|
25
|
-
|
|
26
28
|
var DEFAULT_COLOR_SCHEME = 'standard';
|
|
27
29
|
var getColorScheme = function getColorScheme(colorScheme) {
|
|
28
30
|
return _schemes.colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : DEFAULT_COLOR_SCHEME];
|
|
@@ -142,7 +144,7 @@ var getChangedContentStyle = exports.getChangedContentStyle = function getChange
|
|
|
142
144
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
143
145
|
var diffType = arguments.length > 3 ? arguments[3] : undefined;
|
|
144
146
|
var hideAddedDiffsUnderline = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
145
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getChangedContentStyleLegacy)(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline);
|
|
147
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getChangedContentStyleNext(colorScheme, isActive, isInserted, diffType, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getChangedContentStyleLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme), isActive, isInserted, diffType, hideAddedDiffsUnderline);
|
|
146
148
|
};
|
|
147
149
|
|
|
148
150
|
/** Node-specific style for a changed block node, or `undefined` when the node type has none. */
|
|
@@ -151,27 +153,27 @@ var getChangedNodeStyle = exports.getChangedNodeStyle = function getChangedNodeS
|
|
|
151
153
|
var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
152
154
|
var diffType = arguments.length > 4 ? arguments[4] : undefined;
|
|
153
155
|
var hideAddedDiffsUnderline = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
154
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getChangedNodeStyleLegacy)(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
156
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getChangedNodeStyleNext(nodeName, colorScheme, isInserted, isActive, diffType, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getChangedNodeStyleLegacy)(nodeName, (0, _schemes.getLegacyColorScheme)(colorScheme), isInserted, isActive, diffType, hideAddedDiffsUnderline);
|
|
155
157
|
};
|
|
156
158
|
|
|
157
159
|
/** The positioned line drawn across deleted content spanning an unbounded range. */
|
|
158
160
|
var getDeletedContentStyleUnbounded = exports.getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colorScheme) {
|
|
159
161
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
160
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyleUnboundedLegacy)(colorScheme, isActive);
|
|
162
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleUnboundedNext(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyleUnboundedLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme), isActive);
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
/** Inline style for inserted content. */
|
|
164
166
|
var getInsertedContentStyle = exports.getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
165
167
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
166
168
|
var hideAddedDiffsUnderline = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
167
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getInsertedContentStyleLegacy)(colorScheme, isActive, hideAddedDiffsUnderline);
|
|
169
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getInsertedContentStyleNext(colorScheme, isActive, hideAddedDiffsUnderline) : (0, _wrapBlockNodeViewStyles.getInsertedContentStyleLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme), isActive, hideAddedDiffsUnderline);
|
|
168
170
|
};
|
|
169
171
|
|
|
170
172
|
/** Inline style for deleted content. */
|
|
171
173
|
var getDeletedContentStyle = exports.getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
172
174
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
173
175
|
var diffType = arguments.length > 2 ? arguments[2] : undefined;
|
|
174
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyleLegacy)(colorScheme, isActive, diffType);
|
|
176
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? getDeletedContentStyleNext(colorScheme, isActive, diffType) : (0, _wrapBlockNodeViewStyles.getDeletedContentStyleLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme), isActive, diffType);
|
|
175
177
|
};
|
|
176
178
|
|
|
177
179
|
/**
|
|
@@ -179,12 +181,14 @@ var getDeletedContentStyle = exports.getDeletedContentStyle = function getDelete
|
|
|
179
181
|
* `querySelectorAll('td, th')` loop in `wrapBlockNodeView.ts` resolves it once.
|
|
180
182
|
*/
|
|
181
183
|
var resolveCellOverlayStyle = exports.resolveCellOverlayStyle = function resolveCellOverlayStyle(args) {
|
|
182
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : (0, _wrapBlockNodeViewStyles.resolveCellOverlayStyleLegacy)(args)
|
|
184
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveCellOverlayStyleNext(args) : (0, _wrapBlockNodeViewStyles.resolveCellOverlayStyleLegacy)(_objectSpread(_objectSpread({}, args), {}, {
|
|
185
|
+
colorScheme: (0, _schemes.getLegacyColorScheme)(args.colorScheme)
|
|
186
|
+
}));
|
|
183
187
|
};
|
|
184
188
|
|
|
185
189
|
/** Inner style for the "Removed" lozenge on a deleted block node. */
|
|
186
190
|
var resolveRemovedLozengeStyle = exports.resolveRemovedLozengeStyle = function resolveRemovedLozengeStyle(colorScheme, isActive) {
|
|
187
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.resolveRemovedLozengeStyleLegacy)(colorScheme, isActive);
|
|
191
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? resolveRemovedLozengeStyleNext(colorScheme, isActive) : (0, _wrapBlockNodeViewStyles.resolveRemovedLozengeStyleLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme), isActive);
|
|
188
192
|
};
|
|
189
193
|
|
|
190
194
|
/**
|
|
@@ -201,7 +205,7 @@ var resolveNestedInsertedNodeStyle = exports.resolveNestedInsertedNodeStyle = fu
|
|
|
201
205
|
* is what the `show-diff-deleted-outline-new` class styles in editor-core's smartCardStyles.
|
|
202
206
|
*/
|
|
203
207
|
var hasRestingDeletedRing = exports.hasRestingDeletedRing = function hasRestingDeletedRing(colorScheme) {
|
|
204
|
-
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : (0, _wrapBlockNodeViewStyles.hasRestingDeletedRingLegacy)(colorScheme);
|
|
208
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_show_diff_color_scheme_refactor') ? hasRestingDeletedRingNext(colorScheme) : (0, _wrapBlockNodeViewStyles.hasRestingDeletedRingLegacy)((0, _schemes.getLegacyColorScheme)(colorScheme));
|
|
205
209
|
};
|
|
206
210
|
|
|
207
211
|
/**
|
|
@@ -37,6 +37,7 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
37
37
|
var defaultDiffType = (0, _isExtendedEnabled.getDefaultDiffType)();
|
|
38
38
|
return _objectSpread({
|
|
39
39
|
steps: [],
|
|
40
|
+
stepAttributions: [],
|
|
40
41
|
originalDoc: undefined,
|
|
41
42
|
decorations: _view.DecorationSet.empty,
|
|
42
43
|
isDisplayingChanges: false
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.showDiffPlugin = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
|
10
11
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -12,11 +13,31 @@ var _getDeletedWidgets2 = require("./pm-plugins/getDeletedWidgets");
|
|
|
12
13
|
var _getScrollableDecorations = require("./pm-plugins/getScrollableDecorations");
|
|
13
14
|
var _main = require("./pm-plugins/main");
|
|
14
15
|
var _IndicatorBarContentComponent = require("./ui/IndicatorBar/IndicatorBarContentComponent");
|
|
16
|
+
var _excluded = ["stepsWithAttribution"];
|
|
15
17
|
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; }
|
|
16
18
|
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; }
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var normalizeShowDiffParams = function normalizeShowDiffParams(params) {
|
|
20
|
+
if (!params || !('stepsWithAttribution' in params)) {
|
|
21
|
+
return params ? _objectSpread(_objectSpread({}, params), {}, {
|
|
22
|
+
stepAttributions: []
|
|
23
|
+
}) : params;
|
|
24
|
+
}
|
|
25
|
+
var stepsWithAttribution = params.stepsWithAttribution,
|
|
26
|
+
rest = (0, _objectWithoutProperties2.default)(params, _excluded);
|
|
27
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
28
|
+
steps: stepsWithAttribution.map(function (_ref) {
|
|
29
|
+
var step = _ref.step;
|
|
30
|
+
return step;
|
|
31
|
+
}),
|
|
32
|
+
stepAttributions: stepsWithAttribution.map(function (_ref2) {
|
|
33
|
+
var stepAttribution = _ref2.stepAttribution;
|
|
34
|
+
return stepAttribution;
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
39
|
+
var api = _ref3.api,
|
|
40
|
+
config = _ref3.config;
|
|
20
41
|
// Captured from the plugin's view lifecycle (see `createPlugin`) so read-only actions can access
|
|
21
42
|
// the current state without exposing the plugin key to consumers.
|
|
22
43
|
var editorView;
|
|
@@ -32,21 +53,21 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
32
53
|
},
|
|
33
54
|
commands: {
|
|
34
55
|
showDiff: function showDiff(params) {
|
|
35
|
-
return function (
|
|
36
|
-
var tr =
|
|
56
|
+
return function (_ref4) {
|
|
57
|
+
var tr = _ref4.tr;
|
|
37
58
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
38
59
|
var _api$userIntent;
|
|
39
60
|
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
|
|
40
61
|
tr: tr
|
|
41
62
|
});
|
|
42
63
|
}
|
|
43
|
-
return tr.setMeta(_main.showDiffPluginKey, _objectSpread(_objectSpread({}, params), {}, {
|
|
64
|
+
return tr.setMeta(_main.showDiffPluginKey, _objectSpread(_objectSpread({}, normalizeShowDiffParams(params)), {}, {
|
|
44
65
|
action: 'SHOW_DIFF'
|
|
45
66
|
}));
|
|
46
67
|
};
|
|
47
68
|
},
|
|
48
|
-
hideDiff: function hideDiff(
|
|
49
|
-
var tr =
|
|
69
|
+
hideDiff: function hideDiff(_ref5) {
|
|
70
|
+
var tr = _ref5.tr;
|
|
50
71
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
51
72
|
var _api$userIntent2;
|
|
52
73
|
api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
@@ -55,17 +76,18 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
55
76
|
}
|
|
56
77
|
return tr.setMeta(_main.showDiffPluginKey, {
|
|
57
78
|
steps: [],
|
|
79
|
+
stepAttributions: [],
|
|
58
80
|
action: 'HIDE_DIFF'
|
|
59
81
|
});
|
|
60
82
|
},
|
|
61
|
-
scrollToNext: function scrollToNext(
|
|
62
|
-
var tr =
|
|
83
|
+
scrollToNext: function scrollToNext(_ref6) {
|
|
84
|
+
var tr = _ref6.tr;
|
|
63
85
|
return tr.setMeta(_main.showDiffPluginKey, {
|
|
64
86
|
action: 'SCROLL_TO_NEXT'
|
|
65
87
|
});
|
|
66
88
|
},
|
|
67
|
-
scrollToPrevious: function scrollToPrevious(
|
|
68
|
-
var tr =
|
|
89
|
+
scrollToPrevious: function scrollToPrevious(_ref7) {
|
|
90
|
+
var tr = _ref7.tr;
|
|
69
91
|
return tr.setMeta(_main.showDiffPluginKey, {
|
|
70
92
|
action: 'SCROLL_TO_PREVIOUS'
|
|
71
93
|
});
|
|
@@ -74,8 +96,8 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
74
96
|
pmPlugins: function pmPlugins() {
|
|
75
97
|
return [{
|
|
76
98
|
name: 'showDiffPlugin',
|
|
77
|
-
plugin: function plugin(
|
|
78
|
-
var getIntl =
|
|
99
|
+
plugin: function plugin(_ref8) {
|
|
100
|
+
var getIntl = _ref8.getIntl;
|
|
79
101
|
return (0, _main.createPlugin)(config, getIntl, api, setEditorView);
|
|
80
102
|
}
|
|
81
103
|
}];
|