@atlaskit/editor-plugin-show-diff 28.0.0 → 28.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/pm-plugins/decorations/createReplacedCellDecorations.js +3 -0
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +19 -10
- package/dist/es2019/pm-plugins/decorations/createReplacedCellDecorations.js +4 -1
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +15 -8
- package/dist/esm/pm-plugins/decorations/createReplacedCellDecorations.js +4 -1
- package/dist/esm/pm-plugins/getScrollableDecorations.js +19 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 28.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 28.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`57af9733630db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57af9733630db) -
|
|
14
|
+
Keep replaced table-cell suggestions visible below sticky headers and scroll to the suggested
|
|
15
|
+
content instead of the deleted text in grouped inverted diffs under
|
|
16
|
+
platform_editor_ai_show_diff_patch_2_fix.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 28.0.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -197,6 +197,9 @@ var createCellContentWidgets = function createCellContentWidgets(_ref2) {
|
|
|
197
197
|
return [];
|
|
198
198
|
}
|
|
199
199
|
dom.setAttribute('data-testid', isInserted ? 'show-diff-changed-decoration' : 'show-diff-deleted-decoration');
|
|
200
|
+
if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
201
|
+
dom.style.setProperty('scroll-margin-top', _decorationKeys.scrollMarginTopValue);
|
|
202
|
+
}
|
|
200
203
|
var diffId = crypto.randomUUID();
|
|
201
204
|
if (showIndicators && (0, _fg.fg)('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
202
205
|
// The indicator bar of a widget anchors its top and bottom to the widget itself. Without this
|
|
@@ -78,7 +78,7 @@ function contributorOf(decoration) {
|
|
|
78
78
|
*
|
|
79
79
|
* One group per contributor within a run of touching ranges — see `contributorOf`.
|
|
80
80
|
*/
|
|
81
|
-
function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
81
|
+
function groupTouchingDecorations(decorations, isInlineDecoration, doc) {
|
|
82
82
|
if (decorations.length < 2) {
|
|
83
83
|
return decorations;
|
|
84
84
|
}
|
|
@@ -149,14 +149,23 @@ function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
|
149
149
|
return representative;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
// A widget on a more negative side paints before the live content. A replaced cell can
|
|
153
|
+
// host it at from + 1; if no such widget exists, use the original lookup at from.
|
|
154
|
+
// Keep the group's range for navigation and active-range calculation, but scroll to the widget.
|
|
155
|
+
var scrollTarget;
|
|
156
|
+
var startNode = doc === null || doc === void 0 ? void 0 : doc.nodeAt(from);
|
|
157
|
+
if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_1')) {
|
|
158
|
+
if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_2_fix') && ((startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableCell' || (startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableHeader')) {
|
|
159
|
+
scrollTarget = group.find(function (decoration) {
|
|
160
|
+
return decoration.from === from + 1 && decorationSide(decoration) < decorationSide(representative);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (!scrollTarget) {
|
|
164
|
+
scrollTarget = group.find(function (decoration) {
|
|
165
|
+
return decoration.from === from && decorationSide(decoration) < decorationSide(representative);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
160
169
|
if (!scrollTarget && representative.from === from && representative.to === to) {
|
|
161
170
|
return representative;
|
|
162
171
|
}
|
|
@@ -237,7 +246,7 @@ var getScrollableDecorations = exports.getScrollableDecorations = function getSc
|
|
|
237
246
|
var result;
|
|
238
247
|
if ((0, _fg.fg)('confluence_ncs_step_diffing_version_history')) {
|
|
239
248
|
// Group overlapping or directly touching ranges into one customer-facing edit.
|
|
240
|
-
result = groupTouchingDecorations([].concat((0, _toConsumableArray2.default)(blocks), (0, _toConsumableArray2.default)(inlines), (0, _toConsumableArray2.default)(widgets)), isInlineDecoration);
|
|
249
|
+
result = groupTouchingDecorations([].concat((0, _toConsumableArray2.default)(blocks), (0, _toConsumableArray2.default)(inlines), (0, _toConsumableArray2.default)(widgets)), isInlineDecoration, doc);
|
|
241
250
|
} else {
|
|
242
251
|
// Legacy behavior: exclude blocks that contain or are contained by an inline decoration.
|
|
243
252
|
var nonOverlappingBlocks = blocks.filter(function (block) {
|
|
@@ -9,7 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
9
9
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
10
10
|
import { createBlockChangedDecoration } from './createBlockChangedDecoration';
|
|
11
11
|
import { createInlineChangedDecoration } from './createInlineChangedDecoration';
|
|
12
|
-
import { buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
|
|
12
|
+
import { buildAnchorDecorationKey, buildDiffDecorationSpec, scrollMarginTopValue } from './decorationKeys';
|
|
13
13
|
import { isCellAttrChanged, isCellBackgroundChanged, normalizeCellBackground } from './utils/cellAttrs';
|
|
14
14
|
import { injectInnerWrapper, wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
15
15
|
const CELL_TYPE_NAMES = ['tableCell', 'tableHeader'];
|
|
@@ -183,6 +183,9 @@ const createCellContentWidgets = ({
|
|
|
183
183
|
return [];
|
|
184
184
|
}
|
|
185
185
|
dom.setAttribute('data-testid', isInserted ? 'show-diff-changed-decoration' : 'show-diff-deleted-decoration');
|
|
186
|
+
if (fg('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
187
|
+
dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
|
|
188
|
+
}
|
|
186
189
|
const diffId = crypto.randomUUID();
|
|
187
190
|
if (showIndicators && fg('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
188
191
|
// The indicator bar of a widget anchors its top and bottom to the widget itself. Without this
|
|
@@ -67,7 +67,7 @@ function contributorOf(decoration) {
|
|
|
67
67
|
*
|
|
68
68
|
* One group per contributor within a run of touching ranges — see `contributorOf`.
|
|
69
69
|
*/
|
|
70
|
-
function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
70
|
+
function groupTouchingDecorations(decorations, isInlineDecoration, doc) {
|
|
71
71
|
if (decorations.length < 2) {
|
|
72
72
|
return decorations;
|
|
73
73
|
}
|
|
@@ -126,12 +126,19 @@ function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
|
126
126
|
return representative;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
// A widget on a more negative side paints before the live content. A replaced cell can
|
|
130
|
+
// host it at from + 1; if no such widget exists, use the original lookup at from.
|
|
131
|
+
// Keep the group's range for navigation and active-range calculation, but scroll to the widget.
|
|
132
|
+
let scrollTarget;
|
|
133
|
+
const startNode = doc === null || doc === void 0 ? void 0 : doc.nodeAt(from);
|
|
134
|
+
if (fg('platform_editor_ai_show_diff_patch_1')) {
|
|
135
|
+
if (fg('platform_editor_ai_show_diff_patch_2_fix') && ((startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableCell' || (startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableHeader')) {
|
|
136
|
+
scrollTarget = group.find(decoration => decoration.from === from + 1 && decorationSide(decoration) < decorationSide(representative));
|
|
137
|
+
}
|
|
138
|
+
if (!scrollTarget) {
|
|
139
|
+
scrollTarget = group.find(decoration => decoration.from === from && decorationSide(decoration) < decorationSide(representative));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
135
142
|
if (!scrollTarget && representative.from === from && representative.to === to) {
|
|
136
143
|
return representative;
|
|
137
144
|
}
|
|
@@ -205,7 +212,7 @@ export const getScrollableDecorations = (set, doc) => {
|
|
|
205
212
|
let result;
|
|
206
213
|
if (fg('confluence_ncs_step_diffing_version_history')) {
|
|
207
214
|
// Group overlapping or directly touching ranges into one customer-facing edit.
|
|
208
|
-
result = groupTouchingDecorations([...blocks, ...inlines, ...widgets], isInlineDecoration);
|
|
215
|
+
result = groupTouchingDecorations([...blocks, ...inlines, ...widgets], isInlineDecoration, doc);
|
|
209
216
|
} else {
|
|
210
217
|
// Legacy behavior: exclude blocks that contain or are contained by an inline decoration.
|
|
211
218
|
const nonOverlappingBlocks = blocks.filter(block => !inlines.some(inline => isRangeFullyInside(block.from, block.to, inline.from, inline.to) || isRangeFullyInside(inline.from, inline.to, block.from, block.to)));
|
|
@@ -13,7 +13,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
|
13
13
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
14
14
|
import { createBlockChangedDecoration } from './createBlockChangedDecoration';
|
|
15
15
|
import { createInlineChangedDecoration } from './createInlineChangedDecoration';
|
|
16
|
-
import { buildAnchorDecorationKey, buildDiffDecorationSpec } from './decorationKeys';
|
|
16
|
+
import { buildAnchorDecorationKey, buildDiffDecorationSpec, scrollMarginTopValue } from './decorationKeys';
|
|
17
17
|
import { isCellAttrChanged, isCellBackgroundChanged, normalizeCellBackground } from './utils/cellAttrs';
|
|
18
18
|
import { injectInnerWrapper, wrapBlockNodeView } from './utils/wrapBlockNodeView';
|
|
19
19
|
var CELL_TYPE_NAMES = ['tableCell', 'tableHeader'];
|
|
@@ -190,6 +190,9 @@ var createCellContentWidgets = function createCellContentWidgets(_ref2) {
|
|
|
190
190
|
return [];
|
|
191
191
|
}
|
|
192
192
|
dom.setAttribute('data-testid', isInserted ? 'show-diff-changed-decoration' : 'show-diff-deleted-decoration');
|
|
193
|
+
if (fg('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
194
|
+
dom.style.setProperty('scroll-margin-top', scrollMarginTopValue);
|
|
195
|
+
}
|
|
193
196
|
var diffId = crypto.randomUUID();
|
|
194
197
|
if (showIndicators && fg('platform_editor_ai_show_diff_patch_2_fix')) {
|
|
195
198
|
// The indicator bar of a widget anchors its top and bottom to the widget itself. Without this
|
|
@@ -71,7 +71,7 @@ function contributorOf(decoration) {
|
|
|
71
71
|
*
|
|
72
72
|
* One group per contributor within a run of touching ranges — see `contributorOf`.
|
|
73
73
|
*/
|
|
74
|
-
function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
74
|
+
function groupTouchingDecorations(decorations, isInlineDecoration, doc) {
|
|
75
75
|
if (decorations.length < 2) {
|
|
76
76
|
return decorations;
|
|
77
77
|
}
|
|
@@ -142,14 +142,23 @@ function groupTouchingDecorations(decorations, isInlineDecoration) {
|
|
|
142
142
|
return representative;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
// A widget on a more negative side paints before the live content. A replaced cell can
|
|
146
|
+
// host it at from + 1; if no such widget exists, use the original lookup at from.
|
|
147
|
+
// Keep the group's range for navigation and active-range calculation, but scroll to the widget.
|
|
148
|
+
var scrollTarget;
|
|
149
|
+
var startNode = doc === null || doc === void 0 ? void 0 : doc.nodeAt(from);
|
|
150
|
+
if (fg('platform_editor_ai_show_diff_patch_1')) {
|
|
151
|
+
if (fg('platform_editor_ai_show_diff_patch_2_fix') && ((startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableCell' || (startNode === null || startNode === void 0 ? void 0 : startNode.type.name) === 'tableHeader')) {
|
|
152
|
+
scrollTarget = group.find(function (decoration) {
|
|
153
|
+
return decoration.from === from + 1 && decorationSide(decoration) < decorationSide(representative);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (!scrollTarget) {
|
|
157
|
+
scrollTarget = group.find(function (decoration) {
|
|
158
|
+
return decoration.from === from && decorationSide(decoration) < decorationSide(representative);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
153
162
|
if (!scrollTarget && representative.from === from && representative.to === to) {
|
|
154
163
|
return representative;
|
|
155
164
|
}
|
|
@@ -230,7 +239,7 @@ export var getScrollableDecorations = function getScrollableDecorations(set, doc
|
|
|
230
239
|
var result;
|
|
231
240
|
if (fg('confluence_ncs_step_diffing_version_history')) {
|
|
232
241
|
// Group overlapping or directly touching ranges into one customer-facing edit.
|
|
233
|
-
result = groupTouchingDecorations([].concat(_toConsumableArray(blocks), _toConsumableArray(inlines), _toConsumableArray(widgets)), isInlineDecoration);
|
|
242
|
+
result = groupTouchingDecorations([].concat(_toConsumableArray(blocks), _toConsumableArray(inlines), _toConsumableArray(widgets)), isInlineDecoration, doc);
|
|
234
243
|
} else {
|
|
235
244
|
// Legacy behavior: exclude blocks that contain or are contained by an inline decoration.
|
|
236
245
|
var nonOverlappingBlocks = blocks.filter(function (block) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "28.0.
|
|
3
|
+
"version": "28.0.2",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
41
41
|
"@atlaskit/primitives": "^22.6.0",
|
|
42
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^247.0.0",
|
|
43
43
|
"@atlaskit/tokens": "^20.8.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@compiled/react": "^1.0.2",
|