@atlaskit/editor-plugin-show-diff 12.1.1 → 12.1.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 +7 -0
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -1
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -1
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 12.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3d45d0ef1fb3f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d45d0ef1fb3f) -
|
|
8
|
+
Prevent block diff content from overlapping preceding editor nodes
|
|
9
|
+
|
|
3
10
|
## 12.1.1
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -20,7 +20,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
20
20
|
* that is not in the current document.
|
|
21
21
|
*/
|
|
22
22
|
var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
|
|
23
|
-
var _slice$content, _slice$content2, _slice$content3, _slice$content$firstC;
|
|
23
|
+
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
24
24
|
var change = _ref.change,
|
|
25
25
|
doc = _ref.doc,
|
|
26
26
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
@@ -77,6 +77,14 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
77
77
|
|
|
78
78
|
// For non-table content, use the existing span wrapper approach
|
|
79
79
|
var dom = document.createElement('span');
|
|
80
|
+
var $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
81
|
+
var isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
82
|
+
var hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
83
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isTopLevelInsert && hasPreviousBlock) {
|
|
84
|
+
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
85
|
+
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
86
|
+
dom.append(dom.ownerDocument.createElement('div'));
|
|
87
|
+
}
|
|
80
88
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
81
89
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
82
90
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
@@ -28,7 +28,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
28
28
|
diffType,
|
|
29
29
|
hideAddedDiffsUnderline = false
|
|
30
30
|
}) => {
|
|
31
|
-
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _slice$content$firstC;
|
|
31
|
+
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
32
32
|
const slice = doc.slice(change.fromA, change.toA);
|
|
33
33
|
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;
|
|
34
34
|
// Widget decoration used for deletions as the content is not in the document
|
|
@@ -61,6 +61,14 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
61
61
|
|
|
62
62
|
// For non-table content, use the existing span wrapper approach
|
|
63
63
|
const dom = document.createElement('span');
|
|
64
|
+
const $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
65
|
+
const isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
66
|
+
const hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
67
|
+
if (isExtendedEnabled(diffType) && isTopLevelInsert && hasPreviousBlock) {
|
|
68
|
+
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
69
|
+
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
70
|
+
dom.append(dom.ownerDocument.createElement('div'));
|
|
71
|
+
}
|
|
64
72
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
65
73
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
66
74
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
@@ -14,7 +14,7 @@ import { wrapBlockNodeView, injectInnerWrapper, createContentWrapper } from './u
|
|
|
14
14
|
* that is not in the current document.
|
|
15
15
|
*/
|
|
16
16
|
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref) {
|
|
17
|
-
var _slice$content, _slice$content2, _slice$content3, _slice$content$firstC;
|
|
17
|
+
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
18
18
|
var change = _ref.change,
|
|
19
19
|
doc = _ref.doc,
|
|
20
20
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
@@ -71,6 +71,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
71
71
|
|
|
72
72
|
// For non-table content, use the existing span wrapper approach
|
|
73
73
|
var dom = document.createElement('span');
|
|
74
|
+
var $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
75
|
+
var isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
76
|
+
var hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
77
|
+
if (isExtendedEnabled(diffType) && isTopLevelInsert && hasPreviousBlock) {
|
|
78
|
+
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
79
|
+
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
80
|
+
dom.append(dom.ownerDocument.createElement('div'));
|
|
81
|
+
}
|
|
74
82
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
75
83
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
76
84
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|