@atlaskit/editor-plugin-show-diff 9.1.1 → 10.0.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 +24 -19
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +14 -14
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +10 -1
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +13 -12
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +8 -8
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +49 -8
- package/dist/cjs/pm-plugins/main.js +41 -29
- package/dist/cjs/showDiffPlugin.js +8 -4
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +21 -16
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +15 -15
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +9 -1
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +14 -13
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -9
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +44 -7
- package/dist/es2019/pm-plugins/main.js +19 -5
- package/dist/es2019/showDiffPlugin.js +8 -2
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +24 -19
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +15 -15
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +10 -1
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +14 -13
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -9
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +47 -7
- package/dist/esm/pm-plugins/main.js +41 -29
- package/dist/esm/showDiffPlugin.js +8 -4
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +7 -2
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +27 -6
- package/dist/types/pm-plugins/main.d.ts +6 -1
- package/dist/types/showDiffPluginType.d.ts +9 -0
- package/package.json +21 -29
- package/show-diff-plugin/package.json +1 -8
- package/show-diff-plugin-type/package.json +1 -8
- package/dist/types-ts4.5/entry-points/show-diff-plugin-type.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/show-diff-plugin.d.ts +0 -1
- package/dist/types-ts4.5/index.d.ts +0 -2
- package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +0 -80
- package/dist/types-ts4.5/pm-plugins/areDocsEqualByBlockStructureAndText.d.ts +0 -12
- package/dist/types-ts4.5/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +0 -21
- package/dist/types-ts4.5/pm-plugins/calculateDiff/diffBySteps.d.ts +0 -4
- package/dist/types-ts4.5/pm-plugins/calculateDiff/groupChangesByBlock.d.ts +0 -7
- package/dist/types-ts4.5/pm-plugins/calculateDiff/optimizeChanges.d.ts +0 -6
- package/dist/types-ts4.5/pm-plugins/calculateDiff/simplifySteps.d.ts +0 -3
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/standard.d.ts +0 -30
- package/dist/types-ts4.5/pm-plugins/decorations/colorSchemes/traditional.d.ts +0 -39
- package/dist/types-ts4.5/pm-plugins/decorations/createBlockChangedDecoration.d.ts +0 -21
- package/dist/types-ts4.5/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +0 -18
- package/dist/types-ts4.5/pm-plugins/decorations/createInlineChangedDecoration.d.ts +0 -18
- package/dist/types-ts4.5/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +0 -23
- package/dist/types-ts4.5/pm-plugins/decorations/decorationKeys.d.ts +0 -23
- package/dist/types-ts4.5/pm-plugins/decorations/utils/findSafeInsertPos.d.ts +0 -9
- package/dist/types-ts4.5/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +0 -19
- package/dist/types-ts4.5/pm-plugins/decorations/utils/getMarkChangeRanges.d.ts +0 -7
- package/dist/types-ts4.5/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +0 -17
- package/dist/types-ts4.5/pm-plugins/enforceCustomStepRegisters.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/getScrollableDecorations.d.ts +0 -27
- package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -29
- package/dist/types-ts4.5/pm-plugins/scrollToDiff.d.ts +0 -15
- package/dist/types-ts4.5/showDiffPlugin.d.ts +0 -2
- package/dist/types-ts4.5/showDiffPluginType.d.ts +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
|
|
8
|
+
Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
|
|
9
|
+
|
|
10
|
+
Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
|
|
11
|
+
|
|
12
|
+
Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
- "typesVersions": {
|
|
16
|
+
- ">=4.5 <4.9": {
|
|
17
|
+
- "*": [
|
|
18
|
+
- "dist/types-ts4.5/*",
|
|
19
|
+
- "dist/types-ts4.5/index.d.ts"
|
|
20
|
+
- ]
|
|
21
|
+
- }
|
|
22
|
+
- },
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- [`4759c2ac86196`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4759c2ac86196) -
|
|
28
|
+
EDITOR-7523: Add diff descriptors with new diff ids and types.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
|
|
34
|
+
## 9.1.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
|
|
3
40
|
## 9.1.1
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -18,6 +18,7 @@ var _areDocsEqualByBlockStructureAndText = require("../areDocsEqualByBlockStruct
|
|
|
18
18
|
var _createBlockChangedDecoration = require("../decorations/createBlockChangedDecoration");
|
|
19
19
|
var _createInlineChangedDecoration = require("../decorations/createInlineChangedDecoration");
|
|
20
20
|
var _createNodeChangedDecorationWidget = require("../decorations/createNodeChangedDecorationWidget");
|
|
21
|
+
var _decorationKeys = require("../decorations/decorationKeys");
|
|
21
22
|
var _getAttrChangeRanges = require("../decorations/utils/getAttrChangeRanges");
|
|
22
23
|
var _getMarkChangeRanges = require("../decorations/utils/getMarkChangeRanges");
|
|
23
24
|
var _diffBySteps = require("./diffBySteps");
|
|
@@ -65,7 +66,7 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
65
66
|
if (node.isBlock && (!(0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || pos + node.nodeSize <= to)) {
|
|
66
67
|
var nodeEnd = pos + node.nodeSize;
|
|
67
68
|
var isActive = activeIndexPos && pos === activeIndexPos.from && nodeEnd === activeIndexPos.to;
|
|
68
|
-
|
|
69
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createBlockChangedDecoration.createBlockChangedDecoration)({
|
|
69
70
|
change: {
|
|
70
71
|
from: pos,
|
|
71
72
|
to: nodeEnd,
|
|
@@ -75,10 +76,7 @@ var calculateNodesForBlockDecoration = function calculateNodesForBlockDecoration
|
|
|
75
76
|
isInserted: isInserted,
|
|
76
77
|
isActive: isActive,
|
|
77
78
|
shouldHideDeleted: shouldHideDeleted
|
|
78
|
-
});
|
|
79
|
-
if (blockChangedDecorations.length) {
|
|
80
|
-
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(blockChangedDecorations));
|
|
81
|
-
}
|
|
79
|
+
})));
|
|
82
80
|
}
|
|
83
81
|
});
|
|
84
82
|
return decorations;
|
|
@@ -100,7 +98,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
100
98
|
var originalDoc = pluginState.originalDoc,
|
|
101
99
|
steps = pluginState.steps;
|
|
102
100
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
103
|
-
return
|
|
101
|
+
return {
|
|
102
|
+
decorations: _view.DecorationSet.empty,
|
|
103
|
+
diffDescriptors: []
|
|
104
|
+
};
|
|
104
105
|
}
|
|
105
106
|
var tr = state.tr;
|
|
106
107
|
var steppedDoc = originalDoc;
|
|
@@ -143,7 +144,10 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
146
|
if (!recoveredViaContentEquality) {
|
|
146
|
-
return
|
|
147
|
+
return {
|
|
148
|
+
decorations: _view.DecorationSet.empty,
|
|
149
|
+
diffDescriptors: []
|
|
150
|
+
};
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
var changeset = _prosemirrorChangeset.ChangeSet.create(originalDoc).addSteps(steppedDoc, stepMaps, tr.doc);
|
|
@@ -162,14 +166,14 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
162
166
|
var isInserted = !isInverted;
|
|
163
167
|
if (change.inserted.length > 0) {
|
|
164
168
|
var shouldHideDeleted = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? isInverted && hideDeletedDiffs : false;
|
|
165
|
-
decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
|
|
169
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)(_objectSpread({
|
|
166
170
|
change: change,
|
|
167
171
|
colorScheme: colorScheme,
|
|
168
172
|
isActive: isActive
|
|
169
173
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
170
174
|
isInserted: isInserted,
|
|
171
175
|
shouldHideDeleted: shouldHideDeleted
|
|
172
|
-
})));
|
|
176
|
+
}))));
|
|
173
177
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration(_objectSpread(_objectSpread({
|
|
174
178
|
doc: tr.doc,
|
|
175
179
|
from: change.fromB,
|
|
@@ -186,7 +190,7 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
186
190
|
if (change.deleted.length > 0) {
|
|
187
191
|
var _shouldHideDeleted = (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? !isInverted && hideDeletedDiffs : false;
|
|
188
192
|
if (!_shouldHideDeleted) {
|
|
189
|
-
|
|
193
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createNodeChangedDecorationWidget.createNodeChangedDecorationWidget)(_objectSpread({
|
|
190
194
|
change: change,
|
|
191
195
|
doc: originalDoc,
|
|
192
196
|
nodeViewSerializer: nodeViewSerializer,
|
|
@@ -197,32 +201,29 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
197
201
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
198
202
|
isInserted: !isInserted,
|
|
199
203
|
diffType: diffType
|
|
200
|
-
}));
|
|
201
|
-
if (decoration) {
|
|
202
|
-
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(decoration));
|
|
203
|
-
}
|
|
204
|
+
}))));
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
});
|
|
207
208
|
(0, _getMarkChangeRanges.getMarkChangeRanges)(steps).forEach(function (change) {
|
|
208
209
|
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
209
|
-
decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
|
|
210
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
|
|
210
211
|
change: change,
|
|
211
212
|
colorScheme: colorScheme,
|
|
212
213
|
isActive: isActive,
|
|
213
214
|
isInserted: true
|
|
214
|
-
}));
|
|
215
|
+
})));
|
|
215
216
|
});
|
|
216
217
|
(0, _getAttrChangeRanges.getAttrChangeRanges)(tr.doc, attrSteps).forEach(function (change) {
|
|
217
218
|
if (change.isInline) {
|
|
218
219
|
// Inline nodes (e.g. date) need an inline decoration rather than a block decoration
|
|
219
220
|
var isActive = activeIndexPos && change.fromB === activeIndexPos.from && change.toB === activeIndexPos.to;
|
|
220
|
-
decorations.push((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
|
|
221
|
+
decorations.push.apply(decorations, (0, _toConsumableArray2.default)((0, _createInlineChangedDecoration.createInlineChangedDecoration)({
|
|
221
222
|
change: change,
|
|
222
223
|
colorScheme: colorScheme,
|
|
223
224
|
isActive: isActive,
|
|
224
225
|
isInserted: true
|
|
225
|
-
}));
|
|
226
|
+
})));
|
|
226
227
|
} else {
|
|
227
228
|
decorations.push.apply(decorations, (0, _toConsumableArray2.default)(calculateNodesForBlockDecoration({
|
|
228
229
|
doc: tr.doc,
|
|
@@ -235,7 +236,11 @@ var calculateDiffDecorationsInner = function calculateDiffDecorationsInner(_ref3
|
|
|
235
236
|
})));
|
|
236
237
|
}
|
|
237
238
|
});
|
|
238
|
-
|
|
239
|
+
var decorationSet = _view.DecorationSet.empty.add(tr.doc, decorations);
|
|
240
|
+
return {
|
|
241
|
+
decorations: decorationSet,
|
|
242
|
+
diffDescriptors: (0, _decorationKeys.extractDiffDescriptors)(decorationSet)
|
|
243
|
+
};
|
|
239
244
|
};
|
|
240
245
|
var calculateDiffDecorations = exports.calculateDiffDecorations = (0, _memoizeOne.default)(calculateDiffDecorationsInner,
|
|
241
246
|
// Cache results unless relevant inputs change
|
|
@@ -115,15 +115,16 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
115
115
|
_ref2$shouldHideDelet = _ref2.shouldHideDeleted,
|
|
116
116
|
shouldHideDeleted = _ref2$shouldHideDelet === void 0 ? false : _ref2$shouldHideDelet;
|
|
117
117
|
var decorations = [];
|
|
118
|
+
var diffId = crypto.randomUUID();
|
|
118
119
|
if (shouldHideDeleted) {
|
|
119
120
|
return [_view.Decoration.node(change.from, change.to, {
|
|
120
121
|
style: displayNoneStyle
|
|
121
|
-
}, {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
123
|
+
decorationType: 'block',
|
|
124
|
+
diffId: diffId,
|
|
125
|
+
isActive: isActive,
|
|
125
126
|
nodeName: change.name
|
|
126
|
-
})];
|
|
127
|
+
}))];
|
|
127
128
|
}
|
|
128
129
|
var style;
|
|
129
130
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && ['tableCell', 'tableHeader'].includes(change.name)) {
|
|
@@ -132,11 +133,10 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
132
133
|
cellOverlay.setAttribute('style', cellOverlayStyle);
|
|
133
134
|
decorations.push(
|
|
134
135
|
// change.to - 1 to position the overlay inside the end of the cell
|
|
136
|
+
// this key doesn't use the spec / key builder since this is just for
|
|
137
|
+
// decorating the cells, this is part of a bigger table diff
|
|
135
138
|
_view.Decoration.widget(change.to - 1, cellOverlay, {
|
|
136
|
-
key:
|
|
137
|
-
type: _decorationKeys.DiffDecorationKey.widget,
|
|
138
|
-
isActive: isActive
|
|
139
|
-
})
|
|
139
|
+
key: 'cell-overlay-decoration'
|
|
140
140
|
}));
|
|
141
141
|
}
|
|
142
142
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
@@ -159,12 +159,12 @@ var createBlockChangedDecoration = exports.createBlockChangedDecoration = functi
|
|
|
159
159
|
style: style,
|
|
160
160
|
'data-testid': 'show-diff-changed-decoration-node',
|
|
161
161
|
class: className
|
|
162
|
-
}, {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
163
|
+
decorationType: 'block',
|
|
164
|
+
diffId: diffId,
|
|
165
|
+
isActive: isActive,
|
|
166
166
|
nodeName: change.name
|
|
167
|
-
}));
|
|
167
|
+
})));
|
|
168
168
|
}
|
|
169
169
|
return decorations;
|
|
170
170
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createChangedRowDecorationWidgets = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _document = require("@atlaskit/editor-common/utils/document");
|
|
10
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -13,7 +14,10 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
|
13
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
15
|
var _standard = require("./colorSchemes/standard");
|
|
15
16
|
var _traditional = require("./colorSchemes/traditional");
|
|
17
|
+
var _decorationKeys = require("./decorationKeys");
|
|
16
18
|
var _findSafeInsertPos = require("./utils/findSafeInsertPos");
|
|
19
|
+
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; }
|
|
20
|
+
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
21
|
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; } } }; }
|
|
18
22
|
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; } }
|
|
19
23
|
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; }
|
|
@@ -210,6 +214,11 @@ var createChangedRowDecorationWidgets = exports.createChangedRowDecorationWidget
|
|
|
210
214
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, changedRow.fromB - 1,
|
|
211
215
|
// -1 to find the first safe position from the table
|
|
212
216
|
originalDoc.slice(changedRow.fromA, changedRow.toA));
|
|
213
|
-
|
|
217
|
+
var diffId = crypto.randomUUID();
|
|
218
|
+
return _view.Decoration.widget(safeInsertPos, rowDOM, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
219
|
+
decorationType: 'widget',
|
|
220
|
+
diffId: diffId,
|
|
221
|
+
isActive: false
|
|
222
|
+
})));
|
|
214
223
|
});
|
|
215
224
|
};
|
|
@@ -29,14 +29,15 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
29
29
|
isInserted = _ref$isInserted === void 0 ? true : _ref$isInserted,
|
|
30
30
|
_ref$shouldHideDelete = _ref.shouldHideDeleted,
|
|
31
31
|
shouldHideDeleted = _ref$shouldHideDelete === void 0 ? false : _ref$shouldHideDelete;
|
|
32
|
+
var diffId = crypto.randomUUID();
|
|
32
33
|
if (shouldHideDeleted) {
|
|
33
|
-
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
34
|
+
return [_view.Decoration.inline(change.fromB, change.toB, {
|
|
34
35
|
style: displayNoneStyle
|
|
35
|
-
}, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
36
|
+
}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
37
|
+
decorationType: 'inline',
|
|
38
|
+
diffId: diffId,
|
|
39
|
+
isActive: isActive
|
|
40
|
+
}))];
|
|
40
41
|
}
|
|
41
42
|
var style;
|
|
42
43
|
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
@@ -66,12 +67,12 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
66
67
|
style = isActive ? _standard.editingStyleActive : _standard.editingStyle;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
70
|
+
return [_view.Decoration.inline(change.fromB, change.toB, {
|
|
70
71
|
style: style,
|
|
71
72
|
'data-testid': 'show-diff-changed-decoration'
|
|
72
|
-
}, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
73
|
+
}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
74
|
+
decorationType: 'inline',
|
|
75
|
+
diffId: diffId,
|
|
76
|
+
isActive: isActive
|
|
77
|
+
}))];
|
|
77
78
|
};
|
|
@@ -122,7 +122,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
122
122
|
var safeInsertPos = (0, _findSafeInsertPos.findSafeInsertPos)(newDoc, change.fromB, slice);
|
|
123
123
|
var isActive = activeIndexPos && safeInsertPos === activeIndexPos.from && safeInsertPos === activeIndexPos.to;
|
|
124
124
|
if (slice.content.content.length === 0 || shouldSkipDeletedEmptyParagraphDecoration) {
|
|
125
|
-
return;
|
|
125
|
+
return [];
|
|
126
126
|
}
|
|
127
127
|
var isTableCellContent = slice.content.content.some(function () {
|
|
128
128
|
return slice.content.content.some(function (siblingNode) {
|
|
@@ -135,7 +135,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
if (isTableCellContent) {
|
|
138
|
-
return;
|
|
138
|
+
return [];
|
|
139
139
|
}
|
|
140
140
|
if (isTableRowContent) {
|
|
141
141
|
return (0, _createChangedRowDecorationWidgets.createChangedRowDecorationWidgets)({
|
|
@@ -256,14 +256,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
259
|
+
var diffId = crypto.randomUUID();
|
|
259
260
|
var decorations = [];
|
|
260
|
-
decorations.push(_view.Decoration.widget(safeInsertPos, dom, _objectSpread({
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})
|
|
261
|
+
decorations.push(_view.Decoration.widget(safeInsertPos, dom, (0, _decorationKeys.buildDiffDecorationSpec)(_objectSpread({
|
|
262
|
+
decorationType: 'widget',
|
|
263
|
+
diffId: diffId,
|
|
264
|
+
isActive: isActive
|
|
265
265
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
266
266
|
side: -1
|
|
267
|
-
})));
|
|
267
|
+
}))));
|
|
268
268
|
return decorations;
|
|
269
269
|
};
|
|
@@ -1,24 +1,29 @@
|
|
|
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.
|
|
7
|
+
exports.extractDiffDescriptors = exports.buildDiffDecorationSpec = exports.buildDiffDecorationKey = exports.DiffDecorationKey = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
|
+
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; }
|
|
11
|
+
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
12
|
/**
|
|
8
13
|
* Shared prefix for every decoration key produced by the show-diff plugin.
|
|
9
14
|
* All keys derive from this, so the full set of plugin decorations can be
|
|
10
15
|
* identified by this single prefix.
|
|
11
16
|
*/
|
|
12
|
-
var
|
|
17
|
+
var DIFF_DECORATION_FAMILY = 'diff';
|
|
13
18
|
/**
|
|
14
19
|
* The kinds of decoration the show-diff plugin produces. Each value is the
|
|
15
20
|
* leading segment of the generated key, so a decoration's kind can be matched
|
|
16
21
|
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
17
22
|
*/
|
|
18
23
|
var DiffDecorationKey = exports.DiffDecorationKey = {
|
|
19
|
-
inline: "".concat(
|
|
20
|
-
block: "".concat(
|
|
21
|
-
widget: "".concat(
|
|
24
|
+
inline: "".concat(DIFF_DECORATION_FAMILY, "-inline"),
|
|
25
|
+
block: "".concat(DIFF_DECORATION_FAMILY, "-block"),
|
|
26
|
+
widget: "".concat(DIFF_DECORATION_FAMILY, "-widget")
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
/**
|
|
@@ -26,7 +31,43 @@ var DiffDecorationKey = exports.DiffDecorationKey = {
|
|
|
26
31
|
* (e.g. `diff-inline-active`).
|
|
27
32
|
*/
|
|
28
33
|
var buildDiffDecorationKey = exports.buildDiffDecorationKey = function buildDiffDecorationKey(_ref) {
|
|
29
|
-
var
|
|
30
|
-
isActive = _ref.isActive
|
|
31
|
-
|
|
34
|
+
var decorationKeyPrefix = _ref.decorationKeyPrefix,
|
|
35
|
+
isActive = _ref.isActive,
|
|
36
|
+
diffId = _ref.diffId;
|
|
37
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
38
|
+
return "".concat(decorationKeyPrefix, "-").concat(diffId, "-").concat(isActive ? 'active' : 'inactive');
|
|
39
|
+
}
|
|
40
|
+
return isActive !== undefined ? "".concat(decorationKeyPrefix, "-").concat(isActive ? 'active' : 'inactive') : decorationKeyPrefix;
|
|
41
|
+
};
|
|
42
|
+
var buildDiffDecorationSpec = exports.buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref2) {
|
|
43
|
+
var decorationType = _ref2.decorationType,
|
|
44
|
+
diffId = _ref2.diffId,
|
|
45
|
+
isActive = _ref2.isActive,
|
|
46
|
+
nodeName = _ref2.nodeName,
|
|
47
|
+
side = _ref2.side;
|
|
48
|
+
return _objectSpread(_objectSpread({
|
|
49
|
+
decorationFamily: DIFF_DECORATION_FAMILY,
|
|
50
|
+
decorationType: decorationType,
|
|
51
|
+
diffId: diffId,
|
|
52
|
+
key: buildDiffDecorationKey({
|
|
53
|
+
decorationKeyPrefix: DiffDecorationKey[decorationType],
|
|
54
|
+
diffId: diffId,
|
|
55
|
+
isActive: isActive
|
|
56
|
+
})
|
|
57
|
+
}, nodeName ? {
|
|
58
|
+
nodeName: nodeName
|
|
59
|
+
} : {}), side !== undefined ? {
|
|
60
|
+
side: side
|
|
61
|
+
} : {});
|
|
62
|
+
};
|
|
63
|
+
var extractDiffDescriptors = exports.extractDiffDescriptors = function extractDiffDescriptors(decorations) {
|
|
64
|
+
return decorations.find(undefined, undefined, function (spec) {
|
|
65
|
+
return spec.decorationFamily === 'diff';
|
|
66
|
+
}).map(function (_ref3) {
|
|
67
|
+
var spec = _ref3.spec;
|
|
68
|
+
return {
|
|
69
|
+
id: spec.diffId,
|
|
70
|
+
type: spec.decorationType
|
|
71
|
+
};
|
|
72
|
+
});
|
|
32
73
|
};
|
|
@@ -41,7 +41,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
41
41
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
42
42
|
isInverted: false,
|
|
43
43
|
diffType: 'inline',
|
|
44
|
-
hideDeletedDiffs: false
|
|
44
|
+
hideDeletedDiffs: false,
|
|
45
|
+
diffDescriptors: []
|
|
45
46
|
} : {});
|
|
46
47
|
},
|
|
47
48
|
apply: function apply(tr, currentPluginState, oldState, newState) {
|
|
@@ -56,21 +57,26 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
56
57
|
activeIndex: undefined
|
|
57
58
|
});
|
|
58
59
|
// Calculate and store decorations in state
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
var _calculateDiffDecorat = (0, _calculateDiffDecorations.calculateDiffDecorations)(_objectSpread({
|
|
61
|
+
state: newState,
|
|
62
|
+
pluginState: newPluginState,
|
|
63
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
64
|
+
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
65
|
+
intl: getIntl(),
|
|
66
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
67
|
+
api: api
|
|
68
|
+
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
69
|
+
isInverted: (_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.isInverted,
|
|
70
|
+
diffType: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.diffType,
|
|
71
|
+
hideDeletedDiffs: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.hideDeletedDiffs
|
|
72
|
+
} : {})),
|
|
73
|
+
decorations = _calculateDiffDecorat.decorations,
|
|
74
|
+
diffDescriptors = _calculateDiffDecorat.diffDescriptors;
|
|
75
|
+
// Update the decorations and their ids
|
|
73
76
|
newPluginState.decorations = decorations;
|
|
77
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
78
|
+
newPluginState.diffDescriptors = diffDescriptors;
|
|
79
|
+
}
|
|
74
80
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
75
81
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
76
82
|
decorations: _view.DecorationSet.empty,
|
|
@@ -79,7 +85,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
79
85
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
80
86
|
isInverted: false,
|
|
81
87
|
diffType: 'inline',
|
|
82
|
-
hideDeletedDiffs: false
|
|
88
|
+
hideDeletedDiffs: false,
|
|
89
|
+
diffDescriptors: []
|
|
83
90
|
} : {});
|
|
84
91
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
|
|
85
92
|
// Update the active index in plugin state and recalculate decorations
|
|
@@ -109,20 +116,25 @@ var createPlugin = exports.createPlugin = function createPlugin(config, getIntl,
|
|
|
109
116
|
} : undefined
|
|
110
117
|
});
|
|
111
118
|
// Recalculate decorations with the new active index
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
var _calculateDiffDecorat2 = (0, _calculateDiffDecorations.calculateDiffDecorations)(_objectSpread({
|
|
120
|
+
state: newState,
|
|
121
|
+
pluginState: newPluginState,
|
|
122
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
123
|
+
colorScheme: config === null || config === void 0 ? void 0 : config.colorScheme,
|
|
124
|
+
intl: getIntl(),
|
|
125
|
+
activeIndexPos: newPluginState.activeIndexPos,
|
|
126
|
+
api: api
|
|
127
|
+
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
128
|
+
isInverted: newPluginState.isInverted,
|
|
129
|
+
diffType: newPluginState.diffType,
|
|
130
|
+
hideDeletedDiffs: newPluginState.hideDeletedDiffs
|
|
131
|
+
} : {})),
|
|
132
|
+
updatedDecorations = _calculateDiffDecorat2.decorations,
|
|
133
|
+
updatedDiffDescriptors = _calculateDiffDecorat2.diffDescriptors;
|
|
125
134
|
newPluginState.decorations = updatedDecorations;
|
|
135
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
136
|
+
newPluginState.diffDescriptors = updatedDiffDescriptors;
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
} else {
|
|
128
140
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), meta);
|
|
@@ -68,18 +68,22 @@ var showDiffPlugin = exports.showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
68
68
|
},
|
|
69
69
|
getSharedState: function getSharedState(editorState) {
|
|
70
70
|
if (!editorState) {
|
|
71
|
-
return {
|
|
71
|
+
return _objectSpread({
|
|
72
72
|
isDisplayingChanges: false,
|
|
73
73
|
activeIndex: undefined
|
|
74
|
-
}
|
|
74
|
+
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
75
|
+
diffDescriptors: []
|
|
76
|
+
} : {});
|
|
75
77
|
}
|
|
76
78
|
var pluginState = _main.showDiffPluginKey.getState(editorState);
|
|
77
79
|
var decorationCount = (0, _getScrollableDecorations.getScrollableDecorations)(pluginState === null || pluginState === void 0 ? void 0 : pluginState.decorations, editorState.doc);
|
|
78
|
-
return {
|
|
80
|
+
return _objectSpread({
|
|
79
81
|
isDisplayingChanges: decorationCount.length > 0,
|
|
80
82
|
activeIndex: pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex,
|
|
81
83
|
numberOfChanges: decorationCount.length
|
|
82
|
-
}
|
|
84
|
+
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) ? {
|
|
85
|
+
diffDescriptors: pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffDescriptors
|
|
86
|
+
} : {});
|
|
83
87
|
}
|
|
84
88
|
};
|
|
85
89
|
};
|