@atlaskit/editor-plugin-show-diff 13.0.3 → 13.0.4
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 +8 -0
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -3
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -3
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +10 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 13.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fe858303d6a81`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fe858303d6a81) -
|
|
8
|
+
[ux] Under `platform_editor_diff_plugin_extended`, prevent a replacement of the first document
|
|
9
|
+
heading from overlapping its diff.
|
|
10
|
+
|
|
3
11
|
## 13.0.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -96,7 +96,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
96
96
|
* that is not in the current document.
|
|
97
97
|
*/
|
|
98
98
|
var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
99
|
-
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
99
|
+
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
100
100
|
var change = _ref2.change,
|
|
101
101
|
doc = _ref2.doc,
|
|
102
102
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
@@ -172,11 +172,18 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
172
172
|
var $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
173
173
|
var isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
174
174
|
var hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
175
|
-
|
|
175
|
+
var isFirstDocHeadingReplacement = (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && !placeBelow && change.fromB === 0 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'heading' && ((_newDoc$firstChild = newDoc.firstChild) === null || _newDoc$firstChild === void 0 ? void 0 : _newDoc$firstChild.type.name) === 'heading';
|
|
176
|
+
if ((0, _isExtendedEnabled.isExtendedEnabled)(diffType) && isTopLevelInsert && hasPreviousBlock && !isFirstDocHeadingReplacement) {
|
|
176
177
|
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
177
178
|
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
178
179
|
dom.append(dom.ownerDocument.createElement('div'));
|
|
179
180
|
}
|
|
181
|
+
if (isFirstDocHeadingReplacement) {
|
|
182
|
+
// The replacement widget is the visual first block, while the real first document node has
|
|
183
|
+
// its top margin reset. Add a compact gap after the widget so the two diff blocks do not overlap.
|
|
184
|
+
dom.style.display = 'block';
|
|
185
|
+
dom.style.marginBottom = "var(--ds-space-200, 16px)";
|
|
186
|
+
}
|
|
180
187
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
181
188
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
182
189
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
@@ -346,7 +353,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
346
353
|
// block before it. Add an empty widget matching the following heading so the editor's own heading
|
|
347
354
|
// styles supply the appropriate spacing. For other node types, retain the existing generic spacer.
|
|
348
355
|
var isPureDeletion = change.fromB === change.toB;
|
|
349
|
-
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$
|
|
356
|
+
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.isBlock);
|
|
350
357
|
var isDiffWidgetAtStartOfDoc = $safeInsertPos.depth === 0 && $safeInsertPos.index(0) === 0;
|
|
351
358
|
if (isDiffWidgetAtStartOfDoc && isSingleBlock && isPureDeletion && (0, _isExtendedEnabled.isExtendedEnabled)(diffType)) {
|
|
352
359
|
var followingNode = $safeInsertPos.nodeAfter;
|
|
@@ -105,7 +105,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
105
105
|
diffType,
|
|
106
106
|
hideAddedDiffsUnderline = false
|
|
107
107
|
}) => {
|
|
108
|
-
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
108
|
+
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
109
109
|
const slice = doc.slice(change.fromA, change.toA);
|
|
110
110
|
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;
|
|
111
111
|
// Widget decoration used for deletions as the content is not in the document
|
|
@@ -157,11 +157,18 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
157
157
|
const $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
158
158
|
const isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
159
159
|
const hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
160
|
-
|
|
160
|
+
const isFirstDocHeadingReplacement = isExtendedEnabled(diffType) && !placeBelow && change.fromB === 0 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'heading' && ((_newDoc$firstChild = newDoc.firstChild) === null || _newDoc$firstChild === void 0 ? void 0 : _newDoc$firstChild.type.name) === 'heading';
|
|
161
|
+
if (isExtendedEnabled(diffType) && isTopLevelInsert && hasPreviousBlock && !isFirstDocHeadingReplacement) {
|
|
161
162
|
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
162
163
|
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
163
164
|
dom.append(dom.ownerDocument.createElement('div'));
|
|
164
165
|
}
|
|
166
|
+
if (isFirstDocHeadingReplacement) {
|
|
167
|
+
// The replacement widget is the visual first block, while the real first document node has
|
|
168
|
+
// its top margin reset. Add a compact gap after the widget so the two diff blocks do not overlap.
|
|
169
|
+
dom.style.display = 'block';
|
|
170
|
+
dom.style.marginBottom = "var(--ds-space-200, 16px)";
|
|
171
|
+
}
|
|
165
172
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
166
173
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
167
174
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
@@ -329,7 +336,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
329
336
|
// block before it. Add an empty widget matching the following heading so the editor's own heading
|
|
330
337
|
// styles supply the appropriate spacing. For other node types, retain the existing generic spacer.
|
|
331
338
|
const isPureDeletion = change.fromB === change.toB;
|
|
332
|
-
const isSingleBlock = slice.content.childCount === 1 && ((_slice$content$
|
|
339
|
+
const isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.isBlock);
|
|
333
340
|
const isDiffWidgetAtStartOfDoc = $safeInsertPos.depth === 0 && $safeInsertPos.index(0) === 0;
|
|
334
341
|
if (isDiffWidgetAtStartOfDoc && isSingleBlock && isPureDeletion && isExtendedEnabled(diffType)) {
|
|
335
342
|
const followingNode = $safeInsertPos.nodeAfter;
|
|
@@ -89,7 +89,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
89
89
|
* that is not in the current document.
|
|
90
90
|
*/
|
|
91
91
|
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
92
|
-
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC;
|
|
92
|
+
var _slice$content, _slice$content2, _slice$content3, _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
93
93
|
var change = _ref2.change,
|
|
94
94
|
doc = _ref2.doc,
|
|
95
95
|
nodeViewSerializer = _ref2.nodeViewSerializer,
|
|
@@ -165,11 +165,18 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
165
165
|
var $safeInsertPos = newDoc.resolve(safeInsertPos);
|
|
166
166
|
var isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
167
167
|
var hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
168
|
-
|
|
168
|
+
var isFirstDocHeadingReplacement = isExtendedEnabled(diffType) && !placeBelow && change.fromB === 0 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'heading' && ((_newDoc$firstChild = newDoc.firstChild) === null || _newDoc$firstChild === void 0 ? void 0 : _newDoc$firstChild.type.name) === 'heading';
|
|
169
|
+
if (isExtendedEnabled(diffType) && isTopLevelInsert && hasPreviousBlock && !isFirstDocHeadingReplacement) {
|
|
169
170
|
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
170
171
|
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
171
172
|
dom.append(dom.ownerDocument.createElement('div'));
|
|
172
173
|
}
|
|
174
|
+
if (isFirstDocHeadingReplacement) {
|
|
175
|
+
// The replacement widget is the visual first block, while the real first document node has
|
|
176
|
+
// its top margin reset. Add a compact gap after the widget so the two diff blocks do not overlap.
|
|
177
|
+
dom.style.display = 'block';
|
|
178
|
+
dom.style.marginBottom = "var(--ds-space-200, 16px)";
|
|
179
|
+
}
|
|
173
180
|
// When mediaSingle nodes are rendered inside a widget decoration (e.g. as part of
|
|
174
181
|
// a replaced panel), the centering CSS (margin-left: 50%; transform: translateX(-50%))
|
|
175
182
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
@@ -339,7 +346,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
339
346
|
// block before it. Add an empty widget matching the following heading so the editor's own heading
|
|
340
347
|
// styles supply the appropriate spacing. For other node types, retain the existing generic spacer.
|
|
341
348
|
var isPureDeletion = change.fromB === change.toB;
|
|
342
|
-
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$
|
|
349
|
+
var isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.isBlock);
|
|
343
350
|
var isDiffWidgetAtStartOfDoc = $safeInsertPos.depth === 0 && $safeInsertPos.index(0) === 0;
|
|
344
351
|
if (isDiffWidgetAtStartOfDoc && isSingleBlock && isPureDeletion && isExtendedEnabled(diffType)) {
|
|
345
352
|
var followingNode = $safeInsertPos.nodeAfter;
|