@atlaskit/editor-plugin-show-diff 10.1.7 → 10.1.9
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 +15 -0
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +28 -1
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -1
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +28 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 10.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`86eb94526dc1d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/86eb94526dc1d) -
|
|
8
|
+
[EDITOR-7841] Fix bug where diff widgets missing margin when the diff is the first node of the
|
|
9
|
+
document
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.1.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 10.1.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -106,7 +106,7 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
|
106
106
|
* that is not in the current document.
|
|
107
107
|
*/
|
|
108
108
|
var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
109
|
-
var _slice$content, _slice$content2, _slice$content3;
|
|
109
|
+
var _slice$content, _slice$content2, _slice$content3, _slice$content$firstC;
|
|
110
110
|
var change = _ref2.change,
|
|
111
111
|
doc = _ref2.doc,
|
|
112
112
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
@@ -281,5 +281,32 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
281
281
|
}, (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
282
282
|
side: -1
|
|
283
283
|
}))));
|
|
284
|
+
|
|
285
|
+
// When a single block node is purely deleted at the very start of the doc (first child),
|
|
286
|
+
// the deleted widget decoration overlaps with the existing first child's decoration.
|
|
287
|
+
// To fix this, we insert an additional empty widget span before the deleted content
|
|
288
|
+
// to push it down and create visual separation.
|
|
289
|
+
//
|
|
290
|
+
// Conditions for the placeholder:
|
|
291
|
+
// 1. isPureDeletion: change.fromB === change.toB — nothing was inserted at the same position.
|
|
292
|
+
// Node type changes (e.g. paragraph → heading) have both a deletion and an insertion,
|
|
293
|
+
// so fromB !== toB — we skip the placeholder in that case.
|
|
294
|
+
// 2. isSingleBlock: exactly one block node was deleted (not inline, not multi-block).
|
|
295
|
+
// 3. safeInsertPos: that it is the first node
|
|
296
|
+
var isPureDeletion = change.fromB === change.toB;
|
|
297
|
+
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
|
|
298
|
+
var resolvedPos = newDoc.resolve(change.fromB);
|
|
299
|
+
var isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
|
|
300
|
+
if (isFirstDocChild && isSingleBlock && isPureDeletion && (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
301
|
+
var emptyWidgetSpan = document.createElement('span');
|
|
302
|
+
emptyWidgetSpan.style.display = 'block';
|
|
303
|
+
// Use a design token for the margin to keep spacing consistent with the design system
|
|
304
|
+
emptyWidgetSpan.style.marginTop = "var(--ds-space-100, 8px)";
|
|
305
|
+
var widget = _view.Decoration.widget(safeInsertPos, emptyWidgetSpan, _objectSpread({}, (0, _decorationKeys.buildDiffDecorationSpec)({
|
|
306
|
+
decorationType: 'widget',
|
|
307
|
+
diffId: crypto.randomUUID()
|
|
308
|
+
})));
|
|
309
|
+
decorations.push(widget);
|
|
310
|
+
}
|
|
284
311
|
return decorations;
|
|
285
312
|
};
|
|
@@ -102,7 +102,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
102
102
|
isInserted = false,
|
|
103
103
|
showIndicators = false
|
|
104
104
|
}) => {
|
|
105
|
-
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first;
|
|
105
|
+
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _slice$content$firstC;
|
|
106
106
|
const slice = doc.slice(change.fromA, change.toA);
|
|
107
107
|
const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice === null || slice === void 0 ? void 0 : (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.childCount) === 1 && (slice === null || slice === void 0 ? void 0 : (_slice$content2 = slice.content) === null || _slice$content2 === void 0 ? void 0 : (_slice$content2$first = _slice$content2.firstChild) === null || _slice$content2$first === void 0 ? void 0 : _slice$content2$first.type.name) === 'paragraph' && (slice === null || slice === void 0 ? void 0 : (_slice$content3 = slice.content) === null || _slice$content3 === void 0 ? void 0 : (_slice$content3$first = _slice$content3.firstChild) === null || _slice$content3$first === void 0 ? void 0 : _slice$content3$first.content.size) === 0;
|
|
108
108
|
// Widget decoration used for deletions as the content is not in the document
|
|
@@ -255,5 +255,34 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
255
255
|
side: -1
|
|
256
256
|
})
|
|
257
257
|
})));
|
|
258
|
+
|
|
259
|
+
// When a single block node is purely deleted at the very start of the doc (first child),
|
|
260
|
+
// the deleted widget decoration overlaps with the existing first child's decoration.
|
|
261
|
+
// To fix this, we insert an additional empty widget span before the deleted content
|
|
262
|
+
// to push it down and create visual separation.
|
|
263
|
+
//
|
|
264
|
+
// Conditions for the placeholder:
|
|
265
|
+
// 1. isPureDeletion: change.fromB === change.toB — nothing was inserted at the same position.
|
|
266
|
+
// Node type changes (e.g. paragraph → heading) have both a deletion and an insertion,
|
|
267
|
+
// so fromB !== toB — we skip the placeholder in that case.
|
|
268
|
+
// 2. isSingleBlock: exactly one block node was deleted (not inline, not multi-block).
|
|
269
|
+
// 3. safeInsertPos: that it is the first node
|
|
270
|
+
const isPureDeletion = change.fromB === change.toB;
|
|
271
|
+
const isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
|
|
272
|
+
const resolvedPos = newDoc.resolve(change.fromB);
|
|
273
|
+
const isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
|
|
274
|
+
if (isFirstDocChild && isSingleBlock && isPureDeletion && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
275
|
+
const emptyWidgetSpan = document.createElement('span');
|
|
276
|
+
emptyWidgetSpan.style.display = 'block';
|
|
277
|
+
// Use a design token for the margin to keep spacing consistent with the design system
|
|
278
|
+
emptyWidgetSpan.style.marginTop = "var(--ds-space-100, 8px)";
|
|
279
|
+
const widget = Decoration.widget(safeInsertPos, emptyWidgetSpan, {
|
|
280
|
+
...buildDiffDecorationSpec({
|
|
281
|
+
decorationType: 'widget',
|
|
282
|
+
diffId: crypto.randomUUID()
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
decorations.push(widget);
|
|
286
|
+
}
|
|
258
287
|
return decorations;
|
|
259
288
|
};
|
|
@@ -99,7 +99,7 @@ var createContentWrapper = function createContentWrapper(colorScheme) {
|
|
|
99
99
|
* that is not in the current document.
|
|
100
100
|
*/
|
|
101
101
|
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
102
|
-
var _slice$content, _slice$content2, _slice$content3;
|
|
102
|
+
var _slice$content, _slice$content2, _slice$content3, _slice$content$firstC;
|
|
103
103
|
var change = _ref2.change,
|
|
104
104
|
doc = _ref2.doc,
|
|
105
105
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
@@ -274,5 +274,32 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
274
274
|
}, expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) && {
|
|
275
275
|
side: -1
|
|
276
276
|
}))));
|
|
277
|
+
|
|
278
|
+
// When a single block node is purely deleted at the very start of the doc (first child),
|
|
279
|
+
// the deleted widget decoration overlaps with the existing first child's decoration.
|
|
280
|
+
// To fix this, we insert an additional empty widget span before the deleted content
|
|
281
|
+
// to push it down and create visual separation.
|
|
282
|
+
//
|
|
283
|
+
// Conditions for the placeholder:
|
|
284
|
+
// 1. isPureDeletion: change.fromB === change.toB — nothing was inserted at the same position.
|
|
285
|
+
// Node type changes (e.g. paragraph → heading) have both a deletion and an insertion,
|
|
286
|
+
// so fromB !== toB — we skip the placeholder in that case.
|
|
287
|
+
// 2. isSingleBlock: exactly one block node was deleted (not inline, not multi-block).
|
|
288
|
+
// 3. safeInsertPos: that it is the first node
|
|
289
|
+
var isPureDeletion = change.fromB === change.toB;
|
|
290
|
+
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
|
|
291
|
+
var resolvedPos = newDoc.resolve(change.fromB);
|
|
292
|
+
var isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
|
|
293
|
+
if (isFirstDocChild && isSingleBlock && isPureDeletion && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
294
|
+
var emptyWidgetSpan = document.createElement('span');
|
|
295
|
+
emptyWidgetSpan.style.display = 'block';
|
|
296
|
+
// Use a design token for the margin to keep spacing consistent with the design system
|
|
297
|
+
emptyWidgetSpan.style.marginTop = "var(--ds-space-100, 8px)";
|
|
298
|
+
var widget = Decoration.widget(safeInsertPos, emptyWidgetSpan, _objectSpread({}, buildDiffDecorationSpec({
|
|
299
|
+
decorationType: 'widget',
|
|
300
|
+
diffId: crypto.randomUUID()
|
|
301
|
+
})));
|
|
302
|
+
decorations.push(widget);
|
|
303
|
+
}
|
|
277
304
|
return decorations;
|
|
278
305
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.9",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
29
29
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^114.0.0",
|
|
32
32
|
"@atlaskit/tokens": "^15.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^0.20.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/adf-utils": "^20.0.0",
|
|
41
41
|
"@atlaskit/button": "^24.1.0",
|
|
42
42
|
"@atlaskit/css": "^1.0.0",
|
|
43
|
-
"@atlaskit/editor-core": "^221.
|
|
43
|
+
"@atlaskit/editor-core": "^221.4.0",
|
|
44
44
|
"@atlaskit/editor-json-transformer": "^9.0.0",
|
|
45
45
|
"@atlaskit/form": "^16.0.0",
|
|
46
46
|
"@atlaskit/primitives": "^20.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react-intl": "^7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^116.
|
|
56
|
+
"@atlaskit/editor-common": "^116.14.0",
|
|
57
57
|
"react": "^18.2.0"
|
|
58
58
|
},
|
|
59
59
|
"techstack": {
|