@atlaskit/editor-plugin-show-diff 10.1.23 → 10.2.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 +37 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/cjs/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -2
- package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +841 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/helpers.js +135 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/segmentText.js +331 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/thresholds.js +46 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +8 -5
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/cjs/pm-plugins/isExtendedEnabled.js +20 -0
- package/dist/cjs/pm-plugins/main.js +21 -16
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -29
- package/dist/es2019/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
- package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +689 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/helpers.js +106 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/segmentText.js +283 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/thresholds.js +45 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +31 -16
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +9 -5
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -34
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/es2019/pm-plugins/isExtendedEnabled.js +12 -0
- package/dist/es2019/pm-plugins/main.js +21 -16
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/esm/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
- package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +834 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/helpers.js +128 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/segmentText.js +325 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/thresholds.js +39 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +9 -5
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
- package/dist/esm/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/esm/pm-plugins/isExtendedEnabled.js +14 -0
- package/dist/esm/pm-plugins/main.js +21 -16
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +3 -1
- package/dist/types/pm-plugins/calculateDiff/groupChangesByBlock.d.ts +9 -0
- package/dist/types/pm-plugins/calculateDiff/smart/classifySmartChanges.d.ts +26 -0
- package/dist/types/pm-plugins/calculateDiff/smart/helpers.d.ts +44 -0
- package/dist/types/pm-plugins/calculateDiff/smart/segmentText.d.ts +32 -0
- package/dist/types/pm-plugins/calculateDiff/smart/thresholds.d.ts +44 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +4 -2
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +5 -3
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +6 -4
- package/dist/types/pm-plugins/getScrollableDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/isExtendedEnabled.d.ts +11 -0
- package/dist/types/pm-plugins/main.d.ts +11 -1
- package/dist/types/showDiffPluginType.d.ts +20 -1
- package/docs/smart-diff-design.md +240 -0
- package/package.json +7 -2
|
@@ -11,7 +11,7 @@ var _document = require("@atlaskit/editor-common/utils/document");
|
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
13
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
14
|
-
var
|
|
14
|
+
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
15
15
|
var _standard = require("./colorSchemes/standard");
|
|
16
16
|
var _traditional = require("./colorSchemes/traditional");
|
|
17
17
|
var _decorationKeys = require("./decorationKeys");
|
|
@@ -27,7 +27,8 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
27
27
|
var extractChangedRows = function extractChangedRows(_ref) {
|
|
28
28
|
var change = _ref.change,
|
|
29
29
|
originalDoc = _ref.originalDoc,
|
|
30
|
-
newDoc = _ref.newDoc
|
|
30
|
+
newDoc = _ref.newDoc,
|
|
31
|
+
diffType = _ref.diffType;
|
|
31
32
|
var changedRows = [];
|
|
32
33
|
|
|
33
34
|
// Find the table in the original document
|
|
@@ -67,7 +68,7 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
67
68
|
|
|
68
69
|
// Check if this row overlaps with the deletion range
|
|
69
70
|
var rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
|
|
70
|
-
if (rowOverlapsChange && rowNode.type.name === 'tableRow' && ((0,
|
|
71
|
+
if (rowOverlapsChange && rowNode.type.name === 'tableRow' && ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isEmptyRow(rowNode))) {
|
|
71
72
|
var startOfRow = newTableMap.mapByRow.slice().reverse().find(function (row) {
|
|
72
73
|
return row[0] + tableNew.pos < change.fromB && change.fromB < row[row.length - 1] + tableNew.pos;
|
|
73
74
|
});
|
|
@@ -122,9 +123,9 @@ var isEmptyRow = function isEmptyRow(rowNode) {
|
|
|
122
123
|
/**
|
|
123
124
|
* Creates a DOM representation of a deleted table row
|
|
124
125
|
*/
|
|
125
|
-
var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted) {
|
|
126
|
+
var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializer, colorScheme, isInserted, diffType) {
|
|
126
127
|
var tr = document.createElement('tr');
|
|
127
|
-
if ((0,
|
|
128
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
128
129
|
if (!isInserted) {
|
|
129
130
|
tr.setAttribute('style', colorScheme === 'traditional' ? _traditional.deletedTraditionalRowStyle : _standard.deletedRowStyle);
|
|
130
131
|
}
|
|
@@ -138,7 +139,7 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
138
139
|
if (cellNode.type.name === 'tableCell' || cellNode.type.name === 'tableHeader') {
|
|
139
140
|
var nodeView = nodeViewSerializer.tryCreateNodeView(cellNode);
|
|
140
141
|
if (nodeView) {
|
|
141
|
-
if (nodeView instanceof HTMLElement && (0,
|
|
142
|
+
if (nodeView instanceof HTMLElement && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
142
143
|
var overlay = document.createElement('span');
|
|
143
144
|
var overlayStyle = colorScheme === 'traditional' ? isInserted ? _traditional.traditionalAddedCellOverlayStyle : _traditional.deletedTraditionalCellOverlayStyle : isInserted ? _standard.addedCellOverlayStyle : _standard.deletedCellOverlayStyle;
|
|
144
145
|
overlay.setAttribute('style', overlayStyle);
|
|
@@ -163,7 +164,8 @@ var createChangedRowDOM = function createChangedRowDOM(rowNode, nodeViewSerializ
|
|
|
163
164
|
var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
|
|
164
165
|
var changes = _ref2.changes,
|
|
165
166
|
originalDoc = _ref2.originalDoc,
|
|
166
|
-
newDoc = _ref2.newDoc
|
|
167
|
+
newDoc = _ref2.newDoc,
|
|
168
|
+
diffType = _ref2.diffType;
|
|
167
169
|
var rowInfo = [];
|
|
168
170
|
var _iterator = _createForOfIteratorHelper(changes),
|
|
169
171
|
_step;
|
|
@@ -174,7 +176,8 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref2) {
|
|
|
174
176
|
var changedRows = extractChangedRows({
|
|
175
177
|
change: change,
|
|
176
178
|
originalDoc: originalDoc,
|
|
177
|
-
newDoc: newDoc
|
|
179
|
+
newDoc: newDoc,
|
|
180
|
+
diffType: diffType
|
|
178
181
|
});
|
|
179
182
|
if (changedRows.length > 0) {
|
|
180
183
|
rowInfo.push.apply(rowInfo, (0, _toConsumableArray2.default)(changedRows));
|
|
@@ -198,17 +201,19 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
|
|
|
198
201
|
nodeViewSerializer = _ref3.nodeViewSerializer,
|
|
199
202
|
colorScheme = _ref3.colorScheme,
|
|
200
203
|
_ref3$isInserted = _ref3.isInserted,
|
|
201
|
-
isInserted = _ref3$isInserted === void 0 ? false : _ref3$isInserted
|
|
204
|
+
isInserted = _ref3$isInserted === void 0 ? false : _ref3$isInserted,
|
|
205
|
+
diffType = _ref3.diffType;
|
|
202
206
|
// First, expand the changes to include complete deleted rows
|
|
203
207
|
var changedRows = expandDiffForChangedRows({
|
|
204
208
|
changes: changes.filter(function (change) {
|
|
205
209
|
return change.deleted.length > 0;
|
|
206
210
|
}),
|
|
207
211
|
originalDoc: originalDoc,
|
|
208
|
-
newDoc: newDoc
|
|
212
|
+
newDoc: newDoc,
|
|
213
|
+
diffType: diffType
|
|
209
214
|
});
|
|
210
215
|
return changedRows.map(function (changedRow) {
|
|
211
|
-
var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted);
|
|
216
|
+
var rowDOM = createChangedRowDOM(changedRow.rowNode, nodeViewSerializer, colorScheme, isInserted, diffType);
|
|
212
217
|
|
|
213
218
|
// Find safe insertion position for the deleted row
|
|
214
219
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, changedRow.fromB - 1,
|
|
@@ -218,7 +223,8 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
|
|
|
218
223
|
return _view.Decoration.widget(safeInsertPos, rowDOM, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
219
224
|
decorationType: 'widget',
|
|
220
225
|
diffId: diffId,
|
|
221
|
-
isActive: false
|
|
226
|
+
isActive: false,
|
|
227
|
+
diffType: diffType
|
|
222
228
|
})));
|
|
223
229
|
});
|
|
224
230
|
};
|
|
@@ -8,7 +8,7 @@ exports.createInlineChangedDecoration = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
-
var
|
|
11
|
+
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
12
12
|
var _standard = require("./colorSchemes/standard");
|
|
13
13
|
var _traditional = require("./colorSchemes/traditional");
|
|
14
14
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
@@ -34,7 +34,8 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
34
34
|
shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete,
|
|
35
35
|
_ref$showIndicators = _ref.showIndicators,
|
|
36
36
|
showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
|
|
37
|
-
doc = _ref.doc
|
|
37
|
+
doc = _ref.doc,
|
|
38
|
+
diffType = _ref.diffType;
|
|
38
39
|
var diffId = crypto.randomUUID();
|
|
39
40
|
if (shouldHideDeleted) {
|
|
40
41
|
return [_view.Decoration.inline(change.fromB, change.toB, {
|
|
@@ -46,7 +47,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
46
47
|
}))];
|
|
47
48
|
}
|
|
48
49
|
var style;
|
|
49
|
-
if ((0,
|
|
50
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
50
51
|
if (isInserted) {
|
|
51
52
|
if (colorScheme === 'traditional') {
|
|
52
53
|
style = isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
|
|
@@ -61,7 +62,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
61
62
|
/**
|
|
62
63
|
* Merge into existing styles when cleaning up
|
|
63
64
|
*/
|
|
64
|
-
if ((0,
|
|
65
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
65
66
|
style += _standard.deletedInlineContentStyleExtended;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -81,7 +82,7 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
81
82
|
diffId: diffId,
|
|
82
83
|
isActive: isActive
|
|
83
84
|
}))];
|
|
84
|
-
if (showIndicators && doc && (0,
|
|
85
|
+
if (showIndicators && doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
85
86
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createAnchorDecorationWidgets.createInlineIndicatorAnchorWidgets)({
|
|
86
87
|
doc: doc,
|
|
87
88
|
from: change.fromB,
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createNodeChangedDecorationWidget = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
-
var
|
|
10
|
+
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
11
11
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
12
12
|
var _createChangedRowDecorationWidgets = require("./createChangedRowDecorationWidgets");
|
|
13
13
|
var _decorationKeys = require("./decorationKeys");
|
|
@@ -31,12 +31,18 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
31
31
|
_ref$isInserted = _ref.isInserted,
|
|
32
32
|
isInserted = _ref$isInserted === void 0 ? false : _ref$isInserted,
|
|
33
33
|
_ref$showIndicators = _ref.showIndicators,
|
|
34
|
-
showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators
|
|
34
|
+
showIndicators = _ref$showIndicators === void 0 ? false : _ref$showIndicators,
|
|
35
|
+
_ref$placeBelow = _ref.placeBelow,
|
|
36
|
+
placeBelow = _ref$placeBelow === void 0 ? false : _ref$placeBelow,
|
|
37
|
+
diffType = _ref.diffType;
|
|
35
38
|
var slice = doc.slice(change.fromA, change.toA);
|
|
36
39
|
var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.childCount) === 1 && (slice === null || slice === void 0 || (_slice$content2 = slice.content) === null || _slice$content2 === void 0 || (_slice$content2 = _slice$content2.firstChild) === null || _slice$content2 === void 0 ? void 0 : _slice$content2.type.name) === 'paragraph' && (slice === null || slice === void 0 || (_slice$content3 = slice.content) === null || _slice$content3 === void 0 || (_slice$content3 = _slice$content3.firstChild) === null || _slice$content3 === void 0 ? void 0 : _slice$content3.content.size) === 0;
|
|
37
40
|
// Widget decoration used for deletions as the content is not in the document
|
|
38
41
|
// and we want to display the deleted content with a style.
|
|
39
|
-
|
|
42
|
+
// For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
|
|
43
|
+
// node renders beneath its replacement; otherwise anchor at the start (change.fromB).
|
|
44
|
+
var anchorPos = placeBelow ? change.toB : change.fromB;
|
|
45
|
+
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, anchorPos, slice);
|
|
40
46
|
var isActive = activeIndexPos && safeInsertPos === activeIndexPos.from && safeInsertPos === activeIndexPos.to;
|
|
41
47
|
if (slice.content.content.length === 0 || shouldSkipDeletedEmptyParagraphDecoration) {
|
|
42
48
|
return [];
|
|
@@ -61,7 +67,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
61
67
|
newDoc: newDoc,
|
|
62
68
|
nodeViewSerializer: nodeViewSerializer,
|
|
63
69
|
colorScheme: colorScheme,
|
|
64
|
-
isInserted: isInserted
|
|
70
|
+
isInserted: isInserted,
|
|
71
|
+
diffType: diffType
|
|
65
72
|
});
|
|
66
73
|
}
|
|
67
74
|
var serializer = nodeViewSerializer;
|
|
@@ -74,7 +81,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
74
81
|
// Observe DOM mutations and override the transform on .rich-media-item elements
|
|
75
82
|
// after React mounts to prevent the image from shifting outside its parent container.
|
|
76
83
|
var constrainMediaObserver;
|
|
77
|
-
if ((0,
|
|
84
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
78
85
|
constrainMediaObserver = new MutationObserver(function () {
|
|
79
86
|
var richMediaItems = dom.querySelectorAll('.rich-media-item');
|
|
80
87
|
richMediaItems.forEach(function (el) {
|
|
@@ -111,14 +118,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
111
118
|
if (childNodeView) {
|
|
112
119
|
var lineBreak = document.createElement('br');
|
|
113
120
|
dom.append(lineBreak);
|
|
114
|
-
var wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted);
|
|
121
|
+
var wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted, diffType);
|
|
115
122
|
wrapper.append(childNodeView);
|
|
116
123
|
dom.append(wrapper);
|
|
117
124
|
} else {
|
|
118
125
|
// Fallback to serializing the individual child node
|
|
119
126
|
var serializedChild = serializer.serializeNode(childNode);
|
|
120
127
|
if (serializedChild) {
|
|
121
|
-
var _wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted);
|
|
128
|
+
var _wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted, diffType);
|
|
122
129
|
_wrapper.append(serializedChild);
|
|
123
130
|
dom.append(_wrapper);
|
|
124
131
|
}
|
|
@@ -163,7 +170,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
163
170
|
var nodeView = serializer.tryCreateNodeView(node);
|
|
164
171
|
if (nodeView) {
|
|
165
172
|
if (node.isInline) {
|
|
166
|
-
var wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted);
|
|
173
|
+
var wrapper = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted, diffType);
|
|
167
174
|
wrapper.append(nodeView);
|
|
168
175
|
dom.append(wrapper);
|
|
169
176
|
} else {
|
|
@@ -175,7 +182,8 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
175
182
|
colorScheme: colorScheme,
|
|
176
183
|
intl: intl,
|
|
177
184
|
isActive: isActive,
|
|
178
|
-
isInserted: isInserted
|
|
185
|
+
isInserted: isInserted,
|
|
186
|
+
diffType: diffType
|
|
179
187
|
});
|
|
180
188
|
}
|
|
181
189
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
@@ -189,11 +197,12 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
189
197
|
node: fallbackNode,
|
|
190
198
|
colorScheme: colorScheme,
|
|
191
199
|
isActive: isActive,
|
|
192
|
-
isInserted: isInserted
|
|
200
|
+
isInserted: isInserted,
|
|
201
|
+
diffType: diffType
|
|
193
202
|
});
|
|
194
203
|
dom.append(injectedNode);
|
|
195
204
|
} else {
|
|
196
|
-
var _wrapper2 = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted);
|
|
205
|
+
var _wrapper2 = (0, _wrapBlockNodeView.createContentWrapper)(colorScheme, isActive, isInserted, diffType);
|
|
197
206
|
_wrapper2.append(fallbackNode);
|
|
198
207
|
dom.append(_wrapper2);
|
|
199
208
|
}
|
|
@@ -201,7 +210,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
201
210
|
}
|
|
202
211
|
});
|
|
203
212
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
204
|
-
if (showIndicators && (0,
|
|
213
|
+
if (showIndicators && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
205
214
|
var leftAnchor = (0, _createAnchorDecorationWidgets.createLeftAnchorWidget)({
|
|
206
215
|
doc: newDoc,
|
|
207
216
|
from: safeInsertPos,
|
|
@@ -217,9 +226,12 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
217
226
|
decorations.push(_view.Decoration.widget(safeInsertPos, dom, _objectSpread(_objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)(_objectSpread({
|
|
218
227
|
decorationType: 'widget',
|
|
219
228
|
diffId: diffId,
|
|
220
|
-
isActive: isActive
|
|
221
|
-
|
|
222
|
-
|
|
229
|
+
isActive: isActive,
|
|
230
|
+
diffType: diffType
|
|
231
|
+
}, (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && {
|
|
232
|
+
// placeBelow anchors at the end of the new content, so render on the
|
|
233
|
+
// trailing side (1); otherwise render before the new content (-1).
|
|
234
|
+
side: placeBelow ? 1 : -1
|
|
223
235
|
}))), {}, {
|
|
224
236
|
destroy: function destroy() {
|
|
225
237
|
var _constrainMediaObserv2;
|
|
@@ -242,14 +254,15 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
242
254
|
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
|
|
243
255
|
var resolvedPos = newDoc.resolve(change.fromB);
|
|
244
256
|
var isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
|
|
245
|
-
if (isFirstDocChild && isSingleBlock && isPureDeletion && (0,
|
|
257
|
+
if (isFirstDocChild && isSingleBlock && isPureDeletion && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
246
258
|
var emptyWidgetSpan = document.createElement('span');
|
|
247
259
|
emptyWidgetSpan.style.display = 'block';
|
|
248
260
|
// Use a design token for the margin to keep spacing consistent with the design system
|
|
249
261
|
emptyWidgetSpan.style.marginTop = "var(--ds-space-100, 8px)";
|
|
250
262
|
var widget = _view.Decoration.widget(safeInsertPos, emptyWidgetSpan, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
251
263
|
decorationType: 'widget',
|
|
252
|
-
diffId: crypto.randomUUID()
|
|
264
|
+
diffId: crypto.randomUUID(),
|
|
265
|
+
diffType: diffType
|
|
253
266
|
})));
|
|
254
267
|
decorations.push(widget);
|
|
255
268
|
}
|
|
@@ -9,7 +9,7 @@ exports.buildAnchorDecorationSpec = buildAnchorDecorationSpec;
|
|
|
9
9
|
exports.isDiffDecorationSpec = exports.isDiffDecoration = exports.isAnchorDecorationSpec = exports.extractDiffDescriptors = exports.buildDiffDecorationSpec = exports.buildDiffDecorationKey = void 0;
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var
|
|
12
|
+
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
13
13
|
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; }
|
|
14
14
|
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; }
|
|
15
15
|
/**
|
|
@@ -51,8 +51,9 @@ var buildAnchorDecorationKey = exports.buildAnchorDecorationKey = function build
|
|
|
51
51
|
var buildDiffDecorationKey = exports.buildDiffDecorationKey = function buildDiffDecorationKey(_ref2) {
|
|
52
52
|
var decorationKeyPrefix = _ref2.decorationKeyPrefix,
|
|
53
53
|
isActive = _ref2.isActive,
|
|
54
|
-
diffId = _ref2.diffId
|
|
55
|
-
|
|
54
|
+
diffId = _ref2.diffId,
|
|
55
|
+
diffType = _ref2.diffType;
|
|
56
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
56
57
|
return "".concat(decorationKeyPrefix, "-").concat(diffId, "-").concat(isActive ? 'active' : 'inactive');
|
|
57
58
|
}
|
|
58
59
|
return isActive !== undefined ? "".concat(decorationKeyPrefix, "-").concat(isActive ? 'active' : 'inactive') : decorationKeyPrefix;
|
|
@@ -62,7 +63,8 @@ var buildDiffDecorationSpec = exports.buildDiffDecorationSpec = function buildDi
|
|
|
62
63
|
diffId = _ref3.diffId,
|
|
63
64
|
isActive = _ref3.isActive,
|
|
64
65
|
nodeName = _ref3.nodeName,
|
|
65
|
-
side = _ref3.side
|
|
66
|
+
side = _ref3.side,
|
|
67
|
+
diffType = _ref3.diffType;
|
|
66
68
|
return _objectSpread(_objectSpread({
|
|
67
69
|
decorationFamily: DecorationFamily.diff,
|
|
68
70
|
decorationType: decorationType,
|
|
@@ -70,7 +72,8 @@ var buildDiffDecorationSpec = exports.buildDiffDecorationSpec = function buildDi
|
|
|
70
72
|
key: buildDiffDecorationKey({
|
|
71
73
|
decorationKeyPrefix: DiffDecorationKey[decorationType],
|
|
72
74
|
diffId: diffId,
|
|
73
|
-
isActive: isActive
|
|
75
|
+
isActive: isActive,
|
|
76
|
+
diffType: diffType
|
|
74
77
|
})
|
|
75
78
|
}, nodeName ? {
|
|
76
79
|
nodeName: nodeName
|
|
@@ -10,6 +10,7 @@ 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
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
|
+
var _isExtendedEnabled = require("../../isExtendedEnabled");
|
|
13
14
|
var _standard = require("../colorSchemes/standard");
|
|
14
15
|
var _traditional = require("../colorSchemes/traditional");
|
|
15
16
|
var lozengeStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
@@ -63,7 +64,8 @@ var lozengeStyleActiveTraditional = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
63
64
|
var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
|
|
64
65
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
65
66
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
66
|
-
|
|
67
|
+
var diffType = arguments.length > 3 ? arguments[3] : undefined;
|
|
68
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted) {
|
|
67
69
|
if (colorScheme === 'traditional') {
|
|
68
70
|
return isActive ? _traditional.traditionalInsertStyleActive : _traditional.traditionalInsertStyle;
|
|
69
71
|
}
|
|
@@ -80,8 +82,9 @@ var getChangedContentStyle = function getChangedContentStyle(colorScheme) {
|
|
|
80
82
|
var getChangedNodeStyle = function getChangedNodeStyle(nodeName, colorScheme) {
|
|
81
83
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
82
84
|
var isActive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
85
|
+
var diffType = arguments.length > 4 ? arguments[4] : undefined;
|
|
83
86
|
var isTraditional = colorScheme === 'traditional';
|
|
84
|
-
if ((0,
|
|
87
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted) {
|
|
85
88
|
if (isMultiContainerBlockNode(nodeName)) {
|
|
86
89
|
return _standard.editingContentStyleInBlockExtended;
|
|
87
90
|
}
|
|
@@ -230,11 +233,12 @@ var applyStylesToElement = function applyStylesToElement(_ref3) {
|
|
|
230
233
|
targetNode = _ref3.targetNode,
|
|
231
234
|
colorScheme = _ref3.colorScheme,
|
|
232
235
|
isActive = _ref3.isActive,
|
|
233
|
-
isInserted = _ref3.isInserted
|
|
236
|
+
isInserted = _ref3.isInserted,
|
|
237
|
+
diffType = _ref3.diffType;
|
|
234
238
|
var currentStyle = element.getAttribute('style') || '';
|
|
235
|
-
var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
239
|
+
var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
236
240
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
237
|
-
var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
|
|
241
|
+
var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
|
|
238
242
|
element.setAttribute('style', "".concat(currentStyle).concat(contentStyle).concat(nodeSpecificStyle));
|
|
239
243
|
};
|
|
240
244
|
var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4) {
|
|
@@ -242,10 +246,11 @@ var applyMultiContainerLikeStyles = function applyMultiContainerLikeStyles(_ref4
|
|
|
242
246
|
targetNode = _ref4.targetNode,
|
|
243
247
|
colorScheme = _ref4.colorScheme,
|
|
244
248
|
isActive = _ref4.isActive,
|
|
245
|
-
isInserted = _ref4.isInserted
|
|
249
|
+
isInserted = _ref4.isInserted,
|
|
250
|
+
diffType = _ref4.diffType;
|
|
246
251
|
var currentStyle = element.getAttribute('style') || '';
|
|
247
252
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
248
|
-
var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
|
|
253
|
+
var nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
|
|
249
254
|
if (targetNode.type.name === 'decisionList') {
|
|
250
255
|
element.querySelectorAll('li').forEach(function (listItem) {
|
|
251
256
|
var currentListItemStyle = listItem.getAttribute('style') || '';
|
|
@@ -269,9 +274,14 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref5)
|
|
|
269
274
|
targetNode = _ref5.targetNode,
|
|
270
275
|
colorScheme = _ref5.colorScheme,
|
|
271
276
|
isActive = _ref5.isActive,
|
|
272
|
-
isInserted = _ref5.isInserted
|
|
273
|
-
|
|
274
|
-
var
|
|
277
|
+
isInserted = _ref5.isInserted,
|
|
278
|
+
diffType = _ref5.diffType;
|
|
279
|
+
var currentStyle = element.getAttribute('style') || '';
|
|
280
|
+
var nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType) || '';
|
|
281
|
+
if (nodeSpecificStyle) {
|
|
282
|
+
element.setAttribute('style', "".concat(currentStyle).concat(nodeSpecificStyle));
|
|
283
|
+
}
|
|
284
|
+
var contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
275
285
|
var walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
276
286
|
var textNodesToWrap = [];
|
|
277
287
|
var currentNode = walker.nextNode();
|
|
@@ -297,16 +307,17 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref6
|
|
|
297
307
|
targetNode = _ref6.targetNode,
|
|
298
308
|
colorScheme = _ref6.colorScheme,
|
|
299
309
|
isActive = _ref6.isActive,
|
|
300
|
-
isInserted = _ref6.isInserted
|
|
310
|
+
isInserted = _ref6.isInserted,
|
|
311
|
+
diffType = _ref6.diffType;
|
|
301
312
|
var contentWrapper = document.createElement('div');
|
|
302
313
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
303
|
-
var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
|
|
314
|
+
var nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType);
|
|
304
315
|
|
|
305
316
|
// When the extended experiment is enabled and the content is inserted,
|
|
306
317
|
// block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
|
|
307
318
|
// should not also get the inline content style (borderBottom underline) on their container.
|
|
308
|
-
var shouldSkipContentStyle = (0,
|
|
309
|
-
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
319
|
+
var shouldSkipContentStyle = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isInserted && nodeStyle !== undefined;
|
|
320
|
+
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
310
321
|
contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
|
|
311
322
|
contentWrapper.append(nodeView);
|
|
312
323
|
return contentWrapper;
|
|
@@ -420,10 +431,11 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
|
|
|
420
431
|
_ref9$isActive = _ref9.isActive,
|
|
421
432
|
isActive = _ref9$isActive === void 0 ? false : _ref9$isActive,
|
|
422
433
|
_ref9$isInserted = _ref9.isInserted,
|
|
423
|
-
isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted
|
|
434
|
+
isInserted = _ref9$isInserted === void 0 ? false : _ref9$isInserted,
|
|
435
|
+
diffType = _ref9.diffType;
|
|
424
436
|
var blockWrapper = createBlockNodeWrapper();
|
|
425
437
|
var targetNodeName = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.getBaseNodeTypeName)(targetNode.type) : targetNode.type.name;
|
|
426
|
-
if (shouldShowRemovedLozenge(targetNodeName) && (!(0,
|
|
438
|
+
if (shouldShowRemovedLozenge(targetNodeName) && (!(0, _isExtendedEnabled.isExtendedEnabled)(diffType) || !isInserted)) {
|
|
427
439
|
var lozenge = createRemovedLozenge(intl, isActive, colorScheme);
|
|
428
440
|
if (handleEmbedCardWithLozenge({
|
|
429
441
|
dom: dom,
|
|
@@ -452,7 +464,8 @@ var wrapBlockNode = function wrapBlockNode(_ref9) {
|
|
|
452
464
|
targetNode: targetNode,
|
|
453
465
|
colorScheme: colorScheme,
|
|
454
466
|
isActive: isActive,
|
|
455
|
-
isInserted: isInserted
|
|
467
|
+
isInserted: isInserted,
|
|
468
|
+
diffType: diffType
|
|
456
469
|
});
|
|
457
470
|
blockWrapper.append(contentWrapper);
|
|
458
471
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
@@ -485,8 +498,9 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
485
498
|
_ref0$isActive = _ref0.isActive,
|
|
486
499
|
isActive = _ref0$isActive === void 0 ? false : _ref0$isActive,
|
|
487
500
|
_ref0$isInserted = _ref0.isInserted,
|
|
488
|
-
isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted
|
|
489
|
-
|
|
501
|
+
isInserted = _ref0$isInserted === void 0 ? false : _ref0$isInserted,
|
|
502
|
+
diffType = _ref0.diffType;
|
|
503
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
490
504
|
if (nodeView instanceof HTMLElement) {
|
|
491
505
|
if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
|
|
492
506
|
applyMultiContainerLikeStyles({
|
|
@@ -494,7 +508,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
494
508
|
targetNode: targetNode,
|
|
495
509
|
colorScheme: colorScheme,
|
|
496
510
|
isActive: isActive,
|
|
497
|
-
isInserted: isInserted
|
|
511
|
+
isInserted: isInserted,
|
|
512
|
+
diffType: diffType
|
|
498
513
|
});
|
|
499
514
|
dom.append(nodeView);
|
|
500
515
|
return;
|
|
@@ -505,7 +520,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
505
520
|
targetNode: targetNode,
|
|
506
521
|
colorScheme: colorScheme,
|
|
507
522
|
isActive: isActive,
|
|
508
|
-
isInserted: isInserted
|
|
523
|
+
isInserted: isInserted,
|
|
524
|
+
diffType: diffType
|
|
509
525
|
});
|
|
510
526
|
dom.append(nodeView);
|
|
511
527
|
return;
|
|
@@ -527,7 +543,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
527
543
|
colorScheme: colorScheme,
|
|
528
544
|
intl: intl,
|
|
529
545
|
isActive: isActive,
|
|
530
|
-
isInserted: isInserted
|
|
546
|
+
isInserted: isInserted,
|
|
547
|
+
diffType: diffType
|
|
531
548
|
});
|
|
532
549
|
return;
|
|
533
550
|
} else {
|
|
@@ -538,7 +555,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
538
555
|
targetNode: targetNode,
|
|
539
556
|
colorScheme: colorScheme,
|
|
540
557
|
isActive: isActive,
|
|
541
|
-
isInserted: isInserted
|
|
558
|
+
isInserted: isInserted,
|
|
559
|
+
diffType: diffType
|
|
542
560
|
});
|
|
543
561
|
dom.append(nodeView);
|
|
544
562
|
} else {
|
|
@@ -549,7 +567,8 @@ var wrapBlockNodeView = exports.wrapBlockNodeView = function wrapBlockNodeView(_
|
|
|
549
567
|
colorScheme: colorScheme,
|
|
550
568
|
intl: intl,
|
|
551
569
|
isActive: isActive,
|
|
552
|
-
isInserted: isInserted
|
|
570
|
+
isInserted: isInserted,
|
|
571
|
+
diffType: diffType
|
|
553
572
|
});
|
|
554
573
|
}
|
|
555
574
|
}
|
|
@@ -573,10 +592,11 @@ var getInsertedContentStyle = function getInsertedContentStyle(colorScheme) {
|
|
|
573
592
|
};
|
|
574
593
|
var getDeletedContentStyle = function getDeletedContentStyle(colorScheme) {
|
|
575
594
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
595
|
+
var diffType = arguments.length > 2 ? arguments[2] : undefined;
|
|
576
596
|
if (colorScheme === 'traditional') {
|
|
577
597
|
return (0, _traditional.getDeletedTraditionalInlineStyle)(isActive);
|
|
578
598
|
}
|
|
579
|
-
if ((0,
|
|
599
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
580
600
|
return (isActive ? _standard.deletedContentStyleActive : _standard.deletedContentStyleNew) + _standard.deletedInlineContentStyleExtended;
|
|
581
601
|
}
|
|
582
602
|
return isActive ? _standard.deletedContentStyleActive : _standard.deletedContentStyleNew;
|
|
@@ -591,9 +611,10 @@ var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrappe
|
|
|
591
611
|
var node = _ref1.node,
|
|
592
612
|
colorScheme = _ref1.colorScheme,
|
|
593
613
|
isActive = _ref1.isActive,
|
|
594
|
-
isInserted = _ref1.isInserted
|
|
614
|
+
isInserted = _ref1.isInserted,
|
|
615
|
+
diffType = _ref1.diffType;
|
|
595
616
|
var wrapper = document.createElement('span');
|
|
596
|
-
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
|
|
617
|
+
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive, diffType));
|
|
597
618
|
(0, _toConsumableArray2.default)(node.childNodes).forEach(function (child) {
|
|
598
619
|
var removedChild = node.removeChild(child);
|
|
599
620
|
wrapper.append(removedChild);
|
|
@@ -608,22 +629,23 @@ var injectInnerWrapper = exports.injectInnerWrapper = function injectInnerWrappe
|
|
|
608
629
|
var createContentWrapper = exports.createContentWrapper = function createContentWrapper(colorScheme) {
|
|
609
630
|
var isActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
610
631
|
var isInserted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
632
|
+
var diffType = arguments.length > 3 ? arguments[3] : undefined;
|
|
611
633
|
var wrapper = document.createElement('span');
|
|
612
634
|
var baseStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
613
635
|
position: 'relative',
|
|
614
636
|
width: 'fit-content'
|
|
615
637
|
});
|
|
616
|
-
if ((0,
|
|
638
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
617
639
|
if (isInserted) {
|
|
618
640
|
wrapper.setAttribute('style', "".concat(baseStyle).concat(getInsertedContentStyle(colorScheme, isActive)));
|
|
619
641
|
} else {
|
|
620
|
-
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
|
|
642
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive, diffType)));
|
|
621
643
|
var strikethrough = document.createElement('span');
|
|
622
644
|
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
623
645
|
wrapper.append(strikethrough);
|
|
624
646
|
}
|
|
625
647
|
} else {
|
|
626
|
-
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive)));
|
|
648
|
+
wrapper.setAttribute('style', "".concat(baseStyle).concat(getDeletedContentStyle(colorScheme, isActive, diffType)));
|
|
627
649
|
var _strikethrough = document.createElement('span');
|
|
628
650
|
_strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
629
651
|
wrapper.append(_strikethrough);
|
|
@@ -8,8 +8,8 @@ exports.getScrollableDecorations = void 0;
|
|
|
8
8
|
exports.isInlineDiffDecorationRenderableInDoc = isInlineDiffDecorationRenderableInDoc;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
11
|
var _decorationKeys = require("./decorations/decorationKeys");
|
|
12
|
+
var _isExtendedEnabled = require("./isExtendedEnabled");
|
|
13
13
|
/**
|
|
14
14
|
* True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
|
|
15
15
|
* Block-only subtrees (e.g. empty paragraphs, block cards with no inline children) return false.
|
|
@@ -69,24 +69,24 @@ function specHasDiffKeyPrefix(spec, keyPrefix) {
|
|
|
69
69
|
* @param doc - Current document; when set, diff-inline ranges are validated against this doc
|
|
70
70
|
* @returns Array of scrollable decorations, sorted and deduplicated
|
|
71
71
|
*/
|
|
72
|
-
var getScrollableDecorations = exports.getScrollableDecorations = function getScrollableDecorations(set, doc) {
|
|
72
|
+
var getScrollableDecorations = exports.getScrollableDecorations = function getScrollableDecorations(set, doc, diffType) {
|
|
73
73
|
if (!set) {
|
|
74
74
|
return [];
|
|
75
75
|
}
|
|
76
76
|
var isBlockDecoration = function isBlockDecoration(decoration) {
|
|
77
77
|
var _decoration$spec$key$, _decoration$spec;
|
|
78
|
-
return (0,
|
|
78
|
+
return (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? (0, _decorationKeys.isDiffDecoration)(decoration) && decoration.spec.decorationType === 'block' : (_decoration$spec$key$ = (_decoration$spec = decoration.spec) === null || _decoration$spec === void 0 || (_decoration$spec = _decoration$spec.key) === null || _decoration$spec === void 0 ? void 0 : _decoration$spec.startsWith(_decorationKeys.DiffDecorationKey.block)) !== null && _decoration$spec$key$ !== void 0 ? _decoration$spec$key$ : false;
|
|
79
79
|
};
|
|
80
80
|
var isInlineDecoration = function isInlineDecoration(decoration) {
|
|
81
81
|
var _decoration$spec$key$2, _decoration$spec2;
|
|
82
|
-
return (0,
|
|
82
|
+
return (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? (0, _decorationKeys.isDiffDecoration)(decoration) && decoration.spec.decorationType === 'inline' : (_decoration$spec$key$2 = (_decoration$spec2 = decoration.spec) === null || _decoration$spec2 === void 0 || (_decoration$spec2 = _decoration$spec2.key) === null || _decoration$spec2 === void 0 ? void 0 : _decoration$spec2.startsWith(_decorationKeys.DiffDecorationKey.inline)) !== null && _decoration$spec$key$2 !== void 0 ? _decoration$spec$key$2 : false;
|
|
83
83
|
};
|
|
84
84
|
var isWidgetDecoration = function isWidgetDecoration(decoration) {
|
|
85
85
|
var _decoration$spec$key$3, _decoration$spec3;
|
|
86
|
-
return (0,
|
|
86
|
+
return (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? (0, _decorationKeys.isDiffDecoration)(decoration) && decoration.spec.decorationType === 'widget' : (_decoration$spec$key$3 = (_decoration$spec3 = decoration.spec) === null || _decoration$spec3 === void 0 || (_decoration$spec3 = _decoration$spec3.key) === null || _decoration$spec3 === void 0 ? void 0 : _decoration$spec3.startsWith(_decorationKeys.DiffDecorationKey.widget)) !== null && _decoration$spec$key$3 !== void 0 ? _decoration$spec$key$3 : false;
|
|
87
87
|
};
|
|
88
88
|
var seenBlockKeys = new Set();
|
|
89
|
-
var allDecorations = (0,
|
|
89
|
+
var allDecorations = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) ? set.find(undefined, undefined, _decorationKeys.isDiffDecorationSpec) : set.find(undefined, undefined, function (spec) {
|
|
90
90
|
return specHasDiffKeyPrefix(spec, _decorationKeys.DiffDecorationKey.inline) || specHasDiffKeyPrefix(spec, _decorationKeys.DiffDecorationKey.widget) || specHasDiffKeyPrefix(spec, _decorationKeys.DiffDecorationKey.block);
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isExtendedEnabled = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
9
|
+
/**
|
|
10
|
+
* The "extended" diff pipeline is normally gated by `platform_editor_diff_plugin_extended`.
|
|
11
|
+
* The `smart` diff type REQUIRES the extended pipeline, so whenever `smart` is active (and its
|
|
12
|
+
* own gate `platform_editor_ai_smart_diff` is on) the extended pipeline is force-enabled,
|
|
13
|
+
* independent of the extended gate. For all other diff types the extended gate alone decides.
|
|
14
|
+
*
|
|
15
|
+
* Pass the active `diffType` so callers deep in the decoration layer render the extended shape
|
|
16
|
+
* when `smart` is active even if `platform_editor_diff_plugin_extended` is off.
|
|
17
|
+
*/
|
|
18
|
+
var isExtendedEnabled = exports.isExtendedEnabled = function isExtendedEnabled(diffType) {
|
|
19
|
+
return (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || diffType === 'smart' && (0, _platformFeatureFlags.fg)('platform_editor_ai_smart_diff');
|
|
20
|
+
};
|