@atlaskit/editor-plugin-show-diff 19.0.3 → 19.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 +11 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +57 -93
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +1 -1
- package/dist/cjs/pm-plugins/decorations/colorSchemes/standard.js +1 -26
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +12 -24
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +25 -57
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +22 -60
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +8 -16
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +7 -22
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +34 -52
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +6 -14
- package/dist/cjs/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +3 -8
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +132 -205
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +13 -20
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +6 -10
- package/dist/cjs/pm-plugins/getDefaultDiffType.js +10 -0
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +5 -15
- package/dist/cjs/pm-plugins/main.js +45 -53
- package/dist/cjs/pm-plugins/resolveDiffContributors.js +18 -4
- package/dist/cjs/showDiffPlugin.js +14 -24
- package/dist/cjs/showDiffPluginType.js +1 -1
- package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +19 -9
- package/dist/cjs/ui/ContributorTag/contributorTagController.js +28 -3
- package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +2 -2
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +67 -105
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +1 -1
- package/dist/es2019/pm-plugins/decorations/colorSchemes/standard.js +0 -26
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +11 -23
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +25 -57
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +22 -60
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +8 -18
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +8 -23
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +34 -54
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +6 -16
- package/dist/es2019/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +2 -7
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +53 -125
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +11 -12
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +6 -7
- package/dist/es2019/pm-plugins/getDefaultDiffType.js +2 -0
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +6 -19
- package/dist/es2019/pm-plugins/main.js +49 -65
- package/dist/es2019/pm-plugins/resolveDiffContributors.js +18 -3
- package/dist/es2019/showDiffPlugin.js +12 -24
- package/dist/es2019/showDiffPluginType.js +1 -1
- package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +19 -9
- package/dist/es2019/ui/ContributorTag/contributorTagController.js +30 -2
- package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +2 -2
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +56 -92
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +1 -1
- package/dist/esm/pm-plugins/decorations/colorSchemes/standard.js +0 -26
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +12 -24
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.js +25 -57
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +22 -60
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +8 -16
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.js +8 -23
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +34 -52
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +6 -14
- package/dist/esm/pm-plugins/decorations/utils/createDeletedLineBreakWidget.js +3 -8
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +132 -205
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +13 -20
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.js +6 -10
- package/dist/esm/pm-plugins/getDefaultDiffType.js +4 -0
- package/dist/esm/pm-plugins/getScrollableDecorations.js +6 -16
- package/dist/esm/pm-plugins/main.js +44 -52
- package/dist/esm/pm-plugins/resolveDiffContributors.js +18 -4
- package/dist/esm/showDiffPlugin.js +14 -24
- package/dist/esm/showDiffPluginType.js +1 -1
- package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +19 -9
- package/dist/esm/ui/ContributorTag/contributorTagController.js +28 -3
- package/dist/esm/ui/ContributorTag/contributorTagIcons.js +2 -2
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/standard.d.ts +0 -3
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +1 -3
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.styles.legacy.d.ts +2 -3
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +1 -3
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -3
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.styles.legacy.d.ts +2 -3
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -3
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +5 -8
- package/dist/types/pm-plugins/decorations/utils/createDeletedLineBreakWidget.d.ts +3 -5
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +4 -6
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +3 -4
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.legacy.d.ts +4 -4
- package/dist/types/pm-plugins/getDefaultDiffType.d.ts +2 -0
- package/dist/types/pm-plugins/getScrollableDecorations.d.ts +1 -2
- package/dist/types/pm-plugins/main.d.ts +0 -1
- package/dist/types/showDiffPluginType.d.ts +1 -3
- package/docs/smart-diff-design.md +13 -29
- package/package.json +5 -5
- package/dist/cjs/pm-plugins/isExtendedEnabled.js +0 -23
- package/dist/es2019/pm-plugins/isExtendedEnabled.js +0 -13
- package/dist/esm/pm-plugins/isExtendedEnabled.js +0 -17
- package/dist/types/pm-plugins/isExtendedEnabled.d.ts +0 -12
|
@@ -12,7 +12,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
12
12
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
13
13
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
|
-
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
16
15
|
import { buildAddedCellOverlayRoundedStyle, buildAddedCellOverlayStyle, buildDeletedCellOverlayRoundedStyle, buildDeletedCellOverlayStyle, buildDeletedRowStyle } from './colorSchemes/factory';
|
|
17
16
|
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
18
17
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
@@ -28,8 +27,7 @@ import { createRemovedLozenge } from './utils/wrapBlockNodeView';
|
|
|
28
27
|
var extractChangedRows = function extractChangedRows(_ref) {
|
|
29
28
|
var change = _ref.change,
|
|
30
29
|
originalDoc = _ref.originalDoc,
|
|
31
|
-
newDoc = _ref.newDoc
|
|
32
|
-
diffType = _ref.diffType;
|
|
30
|
+
newDoc = _ref.newDoc;
|
|
33
31
|
var changedRows = [];
|
|
34
32
|
|
|
35
33
|
// Find the table in the original document
|
|
@@ -67,7 +65,7 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
67
65
|
// Find which rows were changed by analyzing the change range
|
|
68
66
|
var changeStartInTable = change.fromA - tableOld.pos - 1;
|
|
69
67
|
var changeEndInTable = change.toA - tableOld.pos - 1;
|
|
70
|
-
var edgeAttrsByOffset =
|
|
68
|
+
var edgeAttrsByOffset = expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true) && isExperimentEnabled('platform_editor_table_diff_rounded_corners') ? getTableTopAndBottomCellEdgeAttrs(oldTableMap) : undefined;
|
|
71
69
|
var currentOffset = 0;
|
|
72
70
|
var rowIndex = 0;
|
|
73
71
|
tableOld.node.content.forEach(function (rowNode) {
|
|
@@ -76,7 +74,7 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
76
74
|
|
|
77
75
|
// Check if this row overlaps with the deletion range
|
|
78
76
|
var rowOverlapsChange = rowStart >= changeStartInTable && rowStart < changeEndInTable || rowEnd > changeStartInTable && rowEnd <= changeEndInTable || rowStart < changeStartInTable && rowEnd > changeEndInTable;
|
|
79
|
-
if (rowOverlapsChange && rowNode.type.name === 'tableRow'
|
|
77
|
+
if (rowOverlapsChange && rowNode.type.name === 'tableRow') {
|
|
80
78
|
var rowLocalId = rowNode.attrs.localId;
|
|
81
79
|
var isTableRowReplacement = rowLocalId && tableNew.node.children.some(function (candidateRow) {
|
|
82
80
|
return candidateRow.type.name === 'tableRow' && candidateRow.attrs.localId === rowLocalId;
|
|
@@ -141,32 +139,6 @@ var extractChangedRows = function extractChangedRows(_ref) {
|
|
|
141
139
|
return true;
|
|
142
140
|
});
|
|
143
141
|
};
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Checks if a table row is empty (contains no meaningful content)
|
|
147
|
-
*/
|
|
148
|
-
var isEmptyRow = function isEmptyRow(rowNode) {
|
|
149
|
-
var isEmpty = true;
|
|
150
|
-
rowNode.descendants(function (node) {
|
|
151
|
-
if (!isEmpty) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// If we find any inline content with size > 0, the row is not empty
|
|
156
|
-
if (node.isInline && node.nodeSize > 0) {
|
|
157
|
-
isEmpty = false;
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// If we find text content, the row is not empty
|
|
162
|
-
if (node.isText && node.text && node.text.trim() !== '') {
|
|
163
|
-
isEmpty = false;
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
return true;
|
|
167
|
-
});
|
|
168
|
-
return isEmpty;
|
|
169
|
-
};
|
|
170
142
|
/**
|
|
171
143
|
* Creates a DOM representation of a deleted table row
|
|
172
144
|
*/
|
|
@@ -177,7 +149,6 @@ var createChangedRowDOM = function createChangedRowDOM(_ref3) {
|
|
|
177
149
|
isTableRowReplacement = _ref3.isTableRowReplacement,
|
|
178
150
|
colorScheme = _ref3.colorScheme,
|
|
179
151
|
isInserted = _ref3.isInserted,
|
|
180
|
-
diffType = _ref3.diffType,
|
|
181
152
|
hasAnchoredRemovedLozenge = _ref3.hasAnchoredRemovedLozenge,
|
|
182
153
|
intl = _ref3.intl,
|
|
183
154
|
isActive = _ref3.isActive;
|
|
@@ -187,16 +158,15 @@ var createChangedRowDOM = function createChangedRowDOM(_ref3) {
|
|
|
187
158
|
}
|
|
188
159
|
var colors = colorSchemeRegistry[colorScheme !== null && colorScheme !== void 0 ? colorScheme : 'standard'];
|
|
189
160
|
var deletedTreatment = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? buildDeletedRowStyle(colors) : resolveDeletedRowStyleLegacy(getLegacyColorScheme(colorScheme));
|
|
190
|
-
var hostsRemovedLozenge = Boolean(intl) &&
|
|
161
|
+
var hostsRemovedLozenge = Boolean(intl) && !isInserted && !hasAnchoredRemovedLozenge;
|
|
191
162
|
|
|
192
163
|
// Inserted rows keep their natural styling; the row strikethrough is deletions only.
|
|
193
|
-
if (!
|
|
164
|
+
if (!isInserted) {
|
|
194
165
|
tr.setAttribute('style', deletedTreatment);
|
|
195
166
|
}
|
|
196
|
-
// Mirrors the strikethrough condition above:
|
|
197
|
-
// is ADDED content, so it must not claim the "deleted" testid — page models match that as
|
|
167
|
+
// Mirrors the strikethrough condition above: an `isInserted` row is ADDED content, so it must not claim the "deleted" testid — page models match that as
|
|
198
168
|
// removed content (same reasoning as `createTableCellContentWidgets`).
|
|
199
|
-
tr.setAttribute('data-testid',
|
|
169
|
+
tr.setAttribute('data-testid', isInserted && fg('platform_editor_ai_show_diff_patch_1') ? 'show-diff-changed-row' : 'show-diff-deleted-row');
|
|
200
170
|
if (fg('platform_editor_ai_show_diff_patch_1')) {
|
|
201
171
|
tr.style.setProperty('scroll-margin-top', scrollMarginTopValue);
|
|
202
172
|
}
|
|
@@ -209,17 +179,15 @@ var createChangedRowDOM = function createChangedRowDOM(_ref3) {
|
|
|
209
179
|
if (nodeView) {
|
|
210
180
|
if (nodeView instanceof HTMLElement) {
|
|
211
181
|
applyCellEdgeAttrs(nodeView, cellEdgeAttrs === null || cellEdgeAttrs === void 0 ? void 0 : cellEdgeAttrs[cellIndex]);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
nodeView.appendChild(overlay);
|
|
222
|
-
}
|
|
182
|
+
var overlay = document.createElement('span');
|
|
183
|
+
var isRoundedTable = isExperimentEnabled('platform_editor_table_diff_rounded_corners');
|
|
184
|
+
var overlayStyle = isExperimentEnabled('platform_editor_show_diff_color_scheme_refactor') ? isInserted ? isRoundedTable ? buildAddedCellOverlayRoundedStyle(colors) : buildAddedCellOverlayStyle(colors) : isRoundedTable ? buildDeletedCellOverlayRoundedStyle(colors) : buildDeletedCellOverlayStyle(colors) : resolveCellOverlayStyleLegacy({
|
|
185
|
+
colorScheme: getLegacyColorScheme(colorScheme),
|
|
186
|
+
isInserted: isInserted,
|
|
187
|
+
isRoundedTable: isRoundedTable
|
|
188
|
+
});
|
|
189
|
+
overlay.setAttribute('style', overlayStyle);
|
|
190
|
+
nodeView.appendChild(overlay);
|
|
223
191
|
}
|
|
224
192
|
tr.appendChild(nodeView);
|
|
225
193
|
} else {
|
|
@@ -274,8 +242,7 @@ var createAnchoredRemovedLozengeWidget = function createAnchoredRemovedLozengeWi
|
|
|
274
242
|
var expandDiffForChangedRows = function expandDiffForChangedRows(_ref5) {
|
|
275
243
|
var changes = _ref5.changes,
|
|
276
244
|
originalDoc = _ref5.originalDoc,
|
|
277
|
-
newDoc = _ref5.newDoc
|
|
278
|
-
diffType = _ref5.diffType;
|
|
245
|
+
newDoc = _ref5.newDoc;
|
|
279
246
|
var rowInfo = [];
|
|
280
247
|
var _iterator = _createForOfIteratorHelper(changes),
|
|
281
248
|
_step;
|
|
@@ -286,8 +253,7 @@ var expandDiffForChangedRows = function expandDiffForChangedRows(_ref5) {
|
|
|
286
253
|
var changedRows = extractChangedRows({
|
|
287
254
|
change: change,
|
|
288
255
|
originalDoc: originalDoc,
|
|
289
|
-
newDoc: newDoc
|
|
290
|
-
diffType: diffType
|
|
256
|
+
newDoc: newDoc
|
|
291
257
|
});
|
|
292
258
|
if (changedRows.length > 0) {
|
|
293
259
|
rowInfo.push.apply(rowInfo, _toConsumableArray(changedRows));
|
|
@@ -315,7 +281,6 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
315
281
|
_ref6$isInserted = _ref6.isInserted,
|
|
316
282
|
isInserted = _ref6$isInserted === void 0 ? false : _ref6$isInserted,
|
|
317
283
|
leftAnchorId = _ref6.leftAnchorId,
|
|
318
|
-
diffType = _ref6.diffType,
|
|
319
284
|
intl = _ref6.intl,
|
|
320
285
|
_ref6$showIndicators = _ref6.showIndicators,
|
|
321
286
|
showIndicators = _ref6$showIndicators === void 0 ? false : _ref6$showIndicators,
|
|
@@ -328,13 +293,12 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
328
293
|
return change.deleted.length > 0;
|
|
329
294
|
}),
|
|
330
295
|
originalDoc: originalDoc,
|
|
331
|
-
newDoc: newDoc
|
|
332
|
-
diffType: diffType
|
|
296
|
+
newDoc: newDoc
|
|
333
297
|
});
|
|
334
298
|
return changedRows.flatMap(function (changedRow) {
|
|
335
299
|
// Keep the ID stable while contributor tags are enabled so recalculation preserves their state.
|
|
336
300
|
var diffId = showContributorTags ? "widget-row-".concat(changedRow.fromA, "-").concat(changedRow.toA) : crypto.randomUUID();
|
|
337
|
-
var hasAnchoredRemovedLozenge = Boolean(intl) &&
|
|
301
|
+
var hasAnchoredRemovedLozenge = Boolean(intl) && !isInserted && supportsAnchorPositioning();
|
|
338
302
|
var rowDOM = createChangedRowDOM({
|
|
339
303
|
rowNode: changedRow.rowNode,
|
|
340
304
|
isTableRowReplacement: changedRow.isTableRowReplacement,
|
|
@@ -342,7 +306,6 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
342
306
|
nodeViewSerializer: nodeViewSerializer,
|
|
343
307
|
colorScheme: colorScheme,
|
|
344
308
|
isInserted: isInserted,
|
|
345
|
-
diffType: diffType,
|
|
346
309
|
hasAnchoredRemovedLozenge: hasAnchoredRemovedLozenge,
|
|
347
310
|
intl: intl,
|
|
348
311
|
isActive: isActive
|
|
@@ -360,7 +323,7 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
360
323
|
// is still created but can never resolve a position, so it silently does not render and the
|
|
361
324
|
// bar covers only the row being changed. `createNodeChangedDecorationWidget` sets the same
|
|
362
325
|
// property on its own widget DOM for non-table content; this path returns before reaching it.
|
|
363
|
-
if (showIndicators &&
|
|
326
|
+
if (showIndicators && fg('platform_editor_ai_show_diff_patch_1')) {
|
|
364
327
|
rowAnchorNames.push(buildAnchorDecorationKey({
|
|
365
328
|
diffId: diffId
|
|
366
329
|
}));
|
|
@@ -415,8 +378,7 @@ export var createChangedRowDecorationWidgets = function createChangedRowDecorati
|
|
|
415
378
|
diffId: diffId,
|
|
416
379
|
leftAnchorId: leftAnchorId,
|
|
417
380
|
isActive: isActive,
|
|
418
|
-
isInserted: isInserted
|
|
419
|
-
diffType: diffType
|
|
381
|
+
isInserted: isInserted
|
|
420
382
|
})));
|
|
421
383
|
decorations.push(rowWidget);
|
|
422
384
|
if (intl && removedLozengeAnchorName) {
|
|
@@ -7,7 +7,6 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
9
9
|
import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
|
|
10
|
-
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
11
10
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
12
11
|
import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineNodeCSSVariables, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
|
|
13
12
|
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
@@ -60,7 +59,7 @@ var getAtomicInlineNodeClassName = function getAtomicInlineNodeClassName(inlineN
|
|
|
60
59
|
return classNames.join(' ');
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
/** Inline style for inserted content
|
|
62
|
+
/** Inline style for inserted content. */
|
|
64
63
|
var getExtendedInsertStyle = function getExtendedInsertStyle(colors, isActive, hideAddedDiffsUnderline) {
|
|
65
64
|
if (colors.insertedInlineTreatment === 'underline') {
|
|
66
65
|
// hideAddedDiffsUnderline only targets the 'borderBottom' rule, so it does not apply here.
|
|
@@ -72,7 +71,7 @@ var getExtendedInsertStyle = function getExtendedInsertStyle(colors, isActive, h
|
|
|
72
71
|
return hideAddedDiffsUnderline ? buildInsertStyleExtendedNoUnderline(colors) : buildInsertStyleExtended(colors);
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
/** Inline style for deleted content
|
|
74
|
+
/** Inline style for deleted content. */
|
|
76
75
|
var getExtendedDeletedStyle = function getExtendedDeletedStyle(colors, isActive) {
|
|
77
76
|
if (colors.deletedInlineTreatment === 'strikethrough') {
|
|
78
77
|
// Identical in both states — the block decoration carries the active emphasis.
|
|
@@ -84,14 +83,10 @@ var getExtendedDeletedStyle = function getExtendedDeletedStyle(colors, isActive)
|
|
|
84
83
|
/** Registry-driven inline `style` for a changed-content decoration. */
|
|
85
84
|
var resolveInlineChangedStyleRefactored = function resolveInlineChangedStyleRefactored(_ref) {
|
|
86
85
|
var colors = _ref.colors,
|
|
87
|
-
diffType = _ref.diffType,
|
|
88
86
|
hideAddedDiffsUnderline = _ref.hideAddedDiffsUnderline,
|
|
89
87
|
isActive = _ref.isActive,
|
|
90
88
|
isInserted = _ref.isInserted;
|
|
91
|
-
|
|
92
|
-
return isInserted ? getExtendedInsertStyle(colors, isActive, hideAddedDiffsUnderline) : getExtendedDeletedStyle(colors, isActive);
|
|
93
|
-
}
|
|
94
|
-
return isActive ? buildInsertStyleActive(colors) : buildInsertStyle(colors);
|
|
89
|
+
return isInserted ? getExtendedInsertStyle(colors, isActive, hideAddedDiffsUnderline) : getExtendedDeletedStyle(colors, isActive);
|
|
95
90
|
};
|
|
96
91
|
|
|
97
92
|
/**
|
|
@@ -149,7 +144,6 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
149
144
|
_ref2$showIndicators = _ref2.showIndicators,
|
|
150
145
|
showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators,
|
|
151
146
|
doc = _ref2.doc,
|
|
152
|
-
diffType = _ref2.diffType,
|
|
153
147
|
_ref2$hideAddedDiffsU = _ref2.hideAddedDiffsUnderline,
|
|
154
148
|
hideAddedDiffsUnderline = _ref2$hideAddedDiffsU === void 0 ? false : _ref2$hideAddedDiffsU,
|
|
155
149
|
inlineNodeName = _ref2.inlineNodeName,
|
|
@@ -166,7 +160,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
166
160
|
|
|
167
161
|
// Match the rendered shape: whitespace text is eligible, while an empty paragraph is structural
|
|
168
162
|
// content with no tag host.
|
|
169
|
-
var canTagChange = showContributorTags && !!doc &&
|
|
163
|
+
var canTagChange = showContributorTags && !!doc && isContributorTagWidgetEnabled() && !isEmptyParagraphSlice(doc.slice(change.fromB, change.toB));
|
|
170
164
|
if (shouldHideDeleted) {
|
|
171
165
|
return [Decoration.inline(change.fromB, change.toB, {
|
|
172
166
|
style: displayNoneStyle
|
|
@@ -184,19 +178,17 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
184
178
|
var colors = getColorScheme(colorScheme);
|
|
185
179
|
|
|
186
180
|
// The reveal withholds the static highlight so the wipe has something to reveal, so it supplies
|
|
187
|
-
// the whole style rather than adding to the usual one.
|
|
188
|
-
|
|
189
|
-
var revealed = isExtendedEnabled(diffType) ? resolveRevealStyle({
|
|
181
|
+
// the whole style rather than adding to the usual one.
|
|
182
|
+
var revealed = resolveRevealStyle({
|
|
190
183
|
colorScheme: colorScheme,
|
|
191
184
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
192
185
|
isActive: isActive,
|
|
193
186
|
isInserted: isInserted,
|
|
194
187
|
reveal: reveal
|
|
195
|
-
})
|
|
188
|
+
});
|
|
196
189
|
var style = (_revealed$style = revealed === null || revealed === void 0 ? void 0 : revealed.style) !== null && _revealed$style !== void 0 ? _revealed$style : resolveInlineChangedStyle({
|
|
197
190
|
colors: colors,
|
|
198
191
|
colorScheme: colorScheme,
|
|
199
|
-
diffType: diffType,
|
|
200
192
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
201
193
|
isActive: isActive,
|
|
202
194
|
isInserted: isInserted
|
|
@@ -244,7 +236,7 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
244
236
|
isActive: isActive,
|
|
245
237
|
isInserted: isInserted
|
|
246
238
|
}))];
|
|
247
|
-
if (showIndicators && doc
|
|
239
|
+
if (showIndicators && doc) {
|
|
248
240
|
// For paragraphs, fromB/toB land on the outer block
|
|
249
241
|
// boundary. Adjust anchor widgets into inline content so the indicator
|
|
250
242
|
// bar doesn't extend into the preceding block's margin.
|
|
@@ -8,41 +8,26 @@
|
|
|
8
8
|
* remains unchanged. Delete the whole file at experiment cleanup (EDITOR-8281).
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import { deletedInlineContentStyleExtended, editingStyle, editingStyleActive, editingStyleActiveExtended, editingStyleActiveExtendedNoUnderline, editingStyleExtended, editingStyleExtendedNoUnderline, getStandardDeletedContentStyle, getStandardDeletedContentStyleActive } from './colorSchemes/standard';
|
|
11
|
+
import { deletedInlineContentStyleExtended, editingStyleActiveExtended, editingStyleActiveExtendedNoUnderline, editingStyleExtended, editingStyleExtendedNoUnderline, getStandardDeletedContentStyle, getStandardDeletedContentStyleActive } from './colorSchemes/standard';
|
|
13
12
|
import { getDeletedTraditionalInlineStyle, traditionalInsertStyle, traditionalInsertStyleActive } from './colorSchemes/traditional';
|
|
14
13
|
/**
|
|
15
14
|
* Pre-refactor inline `style` computation for `createInlineChangedDecoration`.
|
|
16
15
|
*/
|
|
17
16
|
export var resolveInlineChangedStyleLegacy = function resolveInlineChangedStyleLegacy(_ref) {
|
|
18
17
|
var colorScheme = _ref.colorScheme,
|
|
19
|
-
diffType = _ref.diffType,
|
|
20
18
|
hideAddedDiffsUnderline = _ref.hideAddedDiffsUnderline,
|
|
21
19
|
isActive = _ref.isActive,
|
|
22
20
|
isInserted = _ref.isInserted;
|
|
23
|
-
|
|
24
|
-
if (isExtendedEnabled(diffType)) {
|
|
25
|
-
if (isInserted) {
|
|
26
|
-
if (colorScheme === 'traditional') {
|
|
27
|
-
style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
28
|
-
} else {
|
|
29
|
-
style = isActive ? hideAddedDiffsUnderline ? editingStyleActiveExtendedNoUnderline : editingStyleActiveExtended : hideAddedDiffsUnderline ? editingStyleExtendedNoUnderline : editingStyleExtended;
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
if (colorScheme === 'traditional') {
|
|
33
|
-
style = getDeletedTraditionalInlineStyle(false);
|
|
34
|
-
} else {
|
|
35
|
-
style = (isActive ? getStandardDeletedContentStyleActive() : getStandardDeletedContentStyle()) + deletedInlineContentStyleExtended;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
21
|
+
if (isInserted) {
|
|
39
22
|
if (colorScheme === 'traditional') {
|
|
40
|
-
|
|
41
|
-
} else {
|
|
42
|
-
style = isActive ? editingStyleActive : editingStyle;
|
|
23
|
+
return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
43
24
|
}
|
|
25
|
+
return isActive ? hideAddedDiffsUnderline ? editingStyleActiveExtendedNoUnderline : editingStyleActiveExtended : hideAddedDiffsUnderline ? editingStyleExtendedNoUnderline : editingStyleExtended;
|
|
26
|
+
}
|
|
27
|
+
if (colorScheme === 'traditional') {
|
|
28
|
+
return getDeletedTraditionalInlineStyle(false);
|
|
44
29
|
}
|
|
45
|
-
return
|
|
30
|
+
return (isActive ? getStandardDeletedContentStyleActive() : getStandardDeletedContentStyle()) + deletedInlineContentStyleExtended;
|
|
46
31
|
};
|
|
47
32
|
|
|
48
33
|
/**
|
|
@@ -3,7 +3,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
|
-
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
7
6
|
import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
|
|
8
7
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
9
8
|
import { clampAnchorPosIntoCell, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
@@ -34,8 +33,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
34
33
|
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
35
34
|
colorScheme = _ref.colorScheme,
|
|
36
35
|
isInserted = _ref.isInserted,
|
|
37
|
-
leftAnchorId = _ref.leftAnchorId
|
|
38
|
-
diffType = _ref.diffType;
|
|
36
|
+
leftAnchorId = _ref.leftAnchorId;
|
|
39
37
|
// Collect the inner content position of each cell in the new document within
|
|
40
38
|
// the change range. Whole-cell replacement preserves cell count/order, so the
|
|
41
39
|
// nth new-doc cell corresponds to the nth cell in the slice.
|
|
@@ -63,7 +61,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
63
61
|
// so every block inside the cell is rendered.
|
|
64
62
|
cellNode.content.forEach(function (blockNode) {
|
|
65
63
|
var nodeView = nodeViewSerializer.tryCreateNodeView(blockNode);
|
|
66
|
-
var wrapper = createContentWrapper(colorScheme, false, isInserted
|
|
64
|
+
var wrapper = createContentWrapper(colorScheme, false, isInserted);
|
|
67
65
|
if (nodeView) {
|
|
68
66
|
wrapper.append(nodeView);
|
|
69
67
|
} else {
|
|
@@ -87,16 +85,14 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
87
85
|
|
|
88
86
|
// Skip findSafeInsertPos: it walks forward to a schema-valid cell-insert point
|
|
89
87
|
// and pushes the widget into the next cell. `targetPos` is the correct spot.
|
|
90
|
-
decorations.push(Decoration.widget(targetPos, dom, _objectSpread({}, buildDiffDecorationSpec(
|
|
88
|
+
decorations.push(Decoration.widget(targetPos, dom, _objectSpread({}, buildDiffDecorationSpec({
|
|
91
89
|
colorScheme: colorScheme,
|
|
92
90
|
decorationType: 'widget',
|
|
93
91
|
diffId: crypto.randomUUID(),
|
|
94
92
|
leftAnchorId: leftAnchorId,
|
|
95
93
|
isInserted: isInserted,
|
|
96
|
-
diffType: diffType
|
|
97
|
-
}, isExtendedEnabled(diffType) && {
|
|
98
94
|
side: -1
|
|
99
|
-
}))))
|
|
95
|
+
}))));
|
|
100
96
|
});
|
|
101
97
|
return decorations;
|
|
102
98
|
};
|
|
@@ -124,7 +120,6 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
124
120
|
showIndicators = _ref2$showIndicators === void 0 ? false : _ref2$showIndicators,
|
|
125
121
|
_ref2$placeBelow = _ref2.placeBelow,
|
|
126
122
|
placeBelow = _ref2$placeBelow === void 0 ? false : _ref2$placeBelow,
|
|
127
|
-
diffType = _ref2.diffType,
|
|
128
123
|
_ref2$hideAddedDiffsU = _ref2.hideAddedDiffsUnderline,
|
|
129
124
|
hideAddedDiffsUnderline = _ref2$hideAddedDiffsU === void 0 ? false : _ref2$hideAddedDiffsU,
|
|
130
125
|
reveal = _ref2.reveal,
|
|
@@ -156,7 +151,6 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
156
151
|
return [createDeletedLineBreakDecoration({
|
|
157
152
|
colorScheme: colorScheme,
|
|
158
153
|
count: deletedBlankLineCount,
|
|
159
|
-
diffType: diffType,
|
|
160
154
|
isActive: isActive,
|
|
161
155
|
pos: safeInsertPos,
|
|
162
156
|
reveal: reveal,
|
|
@@ -181,8 +175,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
181
175
|
nodeViewSerializer: nodeViewSerializer,
|
|
182
176
|
colorScheme: colorScheme,
|
|
183
177
|
isInserted: isInserted,
|
|
184
|
-
leftAnchorId: leftAnchorId
|
|
185
|
-
diffType: diffType
|
|
178
|
+
leftAnchorId: leftAnchorId
|
|
186
179
|
});
|
|
187
180
|
}
|
|
188
181
|
if (tableDiffMode.kind === 'none') {
|
|
@@ -199,7 +192,6 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
199
192
|
isActive: isActive,
|
|
200
193
|
isInserted: isInserted,
|
|
201
194
|
leftAnchorId: leftAnchorId,
|
|
202
|
-
diffType: diffType,
|
|
203
195
|
intl: intl,
|
|
204
196
|
// Needed for the row's own indicator anchor; this path returns before the
|
|
205
197
|
// `anchor-name` assignment further down.
|
|
@@ -226,8 +218,8 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
226
218
|
var isVisuallyFirstInParent = !placeBelow && $safeInsertPos.parentOffset === 0;
|
|
227
219
|
var isTopLevelInsert = $safeInsertPos.depth === 0;
|
|
228
220
|
var hasPreviousBlock = ((_$safeInsertPos$nodeB = $safeInsertPos.nodeBefore) === null || _$safeInsertPos$nodeB === void 0 ? void 0 : _$safeInsertPos$nodeB.isBlock) === true;
|
|
229
|
-
var isFirstDocHeadingReplacement =
|
|
230
|
-
if (
|
|
221
|
+
var isFirstDocHeadingReplacement = !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';
|
|
222
|
+
if (isTopLevelInsert && hasPreviousBlock && !isFirstDocHeadingReplacement) {
|
|
231
223
|
// Editor CSS removes the top margin from a block when it is its parent's first child.
|
|
232
224
|
// Keep the serialized block as a subsequent child so each block type retains its own margin.
|
|
233
225
|
dom.append(dom.ownerDocument.createElement('div'));
|
|
@@ -243,27 +235,23 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
243
235
|
// incorrectly applies because isNestedNode resolves to false (getPos returns 0).
|
|
244
236
|
// Observe DOM mutations and override the transform on .rich-media-item elements
|
|
245
237
|
// after React mounts to prevent the image from shifting outside its parent container.
|
|
246
|
-
var constrainMediaObserver
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
el.style.marginLeft = '0';
|
|
254
|
-
el.style.maxWidth = '100%';
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
if (richMediaItems.length > 0) {
|
|
258
|
-
var _constrainMediaObserv;
|
|
259
|
-
(_constrainMediaObserv = constrainMediaObserver) === null || _constrainMediaObserv === void 0 || _constrainMediaObserv.disconnect();
|
|
238
|
+
var constrainMediaObserver = new MutationObserver(function () {
|
|
239
|
+
var richMediaItems = dom.querySelectorAll('.rich-media-item');
|
|
240
|
+
richMediaItems.forEach(function (el) {
|
|
241
|
+
if (el instanceof HTMLElement) {
|
|
242
|
+
el.style.transform = 'none';
|
|
243
|
+
el.style.marginLeft = '0';
|
|
244
|
+
el.style.maxWidth = '100%';
|
|
260
245
|
}
|
|
261
246
|
});
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
247
|
+
if (richMediaItems.length > 0) {
|
|
248
|
+
constrainMediaObserver.disconnect();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
constrainMediaObserver.observe(dom, {
|
|
252
|
+
childList: true,
|
|
253
|
+
subtree: true
|
|
254
|
+
});
|
|
267
255
|
// Derived from the deleted range so it survives a recalculation — see the same reasoning in
|
|
268
256
|
// `createInlineChangedDecoration`.
|
|
269
257
|
var diffId = showContributorTags ? "widget-".concat(change.fromA, "-").concat(change.toA) : crypto.randomUUID();
|
|
@@ -316,14 +304,14 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
316
304
|
if (childNodeView) {
|
|
317
305
|
var lineBreak = document.createElement('br');
|
|
318
306
|
dom.append(lineBreak);
|
|
319
|
-
var wrapper = createContentWrapper(colorScheme, isActive, isInserted
|
|
307
|
+
var wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
320
308
|
wrapper.append(childNodeView);
|
|
321
309
|
dom.append(wrapper);
|
|
322
310
|
} else {
|
|
323
311
|
// Fallback to serializing the individual child node
|
|
324
312
|
var serializedChild = serializer.serializeNode(childNode);
|
|
325
313
|
if (serializedChild) {
|
|
326
|
-
var _wrapper = createContentWrapper(colorScheme, isActive, isInserted
|
|
314
|
+
var _wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
327
315
|
_wrapper.append(serializedChild);
|
|
328
316
|
dom.append(_wrapper);
|
|
329
317
|
}
|
|
@@ -370,7 +358,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
370
358
|
var nodeView = serializer.tryCreateNodeView(node);
|
|
371
359
|
if (nodeView) {
|
|
372
360
|
if (node.isInline) {
|
|
373
|
-
var wrapper = createContentWrapper(colorScheme, isActive, isInserted,
|
|
361
|
+
var wrapper = createContentWrapper(colorScheme, isActive, isInserted, reveal);
|
|
374
362
|
wrapper.append(nodeView);
|
|
375
363
|
dom.append(wrapper);
|
|
376
364
|
} else {
|
|
@@ -383,7 +371,6 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
383
371
|
intl: intl,
|
|
384
372
|
isActive: isActive,
|
|
385
373
|
isInserted: isInserted,
|
|
386
|
-
diffType: diffType,
|
|
387
374
|
hideAddedDiffsUnderline: hideAddedDiffsUnderline,
|
|
388
375
|
highlightInlineLeafNodes: shouldPreserveCompleteMultiInlineBlock
|
|
389
376
|
});
|
|
@@ -400,12 +387,11 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
400
387
|
colorScheme: colorScheme,
|
|
401
388
|
isActive: isActive,
|
|
402
389
|
isInserted: isInserted,
|
|
403
|
-
diffType: diffType,
|
|
404
390
|
reveal: reveal
|
|
405
391
|
});
|
|
406
392
|
dom.append(injectedNode);
|
|
407
393
|
} else {
|
|
408
|
-
var _wrapper2 = createContentWrapper(colorScheme, isActive, isInserted,
|
|
394
|
+
var _wrapper2 = createContentWrapper(colorScheme, isActive, isInserted, reveal);
|
|
409
395
|
_wrapper2.append(fallbackNode);
|
|
410
396
|
dom.append(_wrapper2);
|
|
411
397
|
}
|
|
@@ -474,7 +460,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
474
460
|
|
|
475
461
|
// Needed even when the indicator bar is off, because a contributor tag also anchors against the
|
|
476
462
|
// widget.
|
|
477
|
-
if (
|
|
463
|
+
if (showIndicators || showContributorTags) {
|
|
478
464
|
dom.style.setProperty('anchor-name', "--".concat(buildAnchorDecorationKey({
|
|
479
465
|
diffId: diffId
|
|
480
466
|
})));
|
|
@@ -531,7 +517,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
531
517
|
}
|
|
532
518
|
}
|
|
533
519
|
}
|
|
534
|
-
if (showIndicators
|
|
520
|
+
if (showIndicators) {
|
|
535
521
|
var leftAnchor = createLeftAnchorWidget({
|
|
536
522
|
doc: newDoc,
|
|
537
523
|
from: safeInsertPos,
|
|
@@ -548,7 +534,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
548
534
|
decorations.push(leftAnchor);
|
|
549
535
|
}
|
|
550
536
|
}
|
|
551
|
-
decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread(_objectSpread({}, buildDiffDecorationSpec(
|
|
537
|
+
decorations.push(Decoration.widget(safeInsertPos, dom, _objectSpread(_objectSpread({}, buildDiffDecorationSpec({
|
|
552
538
|
attributionKey: canTagWidget ? attributionKey : undefined,
|
|
553
539
|
colorScheme: colorScheme,
|
|
554
540
|
decorationType: 'widget',
|
|
@@ -556,20 +542,17 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
556
542
|
leftAnchorId: leftAnchorId,
|
|
557
543
|
isActive: isActive,
|
|
558
544
|
isInserted: isInserted,
|
|
559
|
-
diffType: diffType
|
|
560
|
-
}, isExtendedEnabled(diffType) && {
|
|
561
545
|
// placeBelow anchors at the end of the new content, so render on the
|
|
562
546
|
// trailing side (1); otherwise render before the new content (-1).
|
|
563
547
|
side: placeBelow ? 1 : -1
|
|
564
|
-
}))
|
|
548
|
+
})), {}, {
|
|
565
549
|
// Without an explicit mark set, prosemirror-view wraps the widget in the marks of the
|
|
566
550
|
// adjacent text in the NEW document. `dom` already carries the original marks, so a
|
|
567
551
|
// formatting change would render the deleted side wrapped in the very mark the edit
|
|
568
552
|
// introduced — unbolded text shown struck through but still bold.
|
|
569
553
|
marks: [],
|
|
570
554
|
destroy: function destroy() {
|
|
571
|
-
|
|
572
|
-
(_constrainMediaObserv2 = constrainMediaObserver) === null || _constrainMediaObserv2 === void 0 || _constrainMediaObserv2.disconnect();
|
|
555
|
+
constrainMediaObserver.disconnect();
|
|
573
556
|
unmountContributorTag(tagMount);
|
|
574
557
|
tagMount = undefined;
|
|
575
558
|
}
|
|
@@ -590,7 +573,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
590
573
|
// Away from the parent's start the node below keeps its own margin, and it is the block *inside*
|
|
591
574
|
// the widget that loses one — handled by `absorbFirstChildMarginReset` above, not here.
|
|
592
575
|
var nodeAfterWidget = $safeInsertPos.nodeAfter;
|
|
593
|
-
if (fg('platform_editor_ai_show_diff_patch_2') &&
|
|
576
|
+
if (fg('platform_editor_ai_show_diff_patch_2') && isVisuallyFirstInParent && nodeAfterWidget) {
|
|
594
577
|
var shapedSpacer = createNodeShapedMarginSpacer({
|
|
595
578
|
node: nodeAfterWidget,
|
|
596
579
|
serializer: serializer,
|
|
@@ -614,7 +597,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
614
597
|
}));
|
|
615
598
|
}
|
|
616
599
|
}
|
|
617
|
-
if (!fg('platform_editor_ai_show_diff_patch_2') && isDiffWidgetAtStartOfDoc && isSingleBlock && isPureDeletion
|
|
600
|
+
if (!fg('platform_editor_ai_show_diff_patch_2') && isDiffWidgetAtStartOfDoc && isSingleBlock && isPureDeletion) {
|
|
618
601
|
var followingNode = $safeInsertPos.nodeAfter;
|
|
619
602
|
var headingLevel = (followingNode === null || followingNode === void 0 ? void 0 : followingNode.type.name) === 'heading' ? followingNode.attrs.level : undefined;
|
|
620
603
|
if (isHeadingLevel(headingLevel)) {
|
|
@@ -637,8 +620,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
637
620
|
colorScheme: colorScheme,
|
|
638
621
|
decorationType: 'widget',
|
|
639
622
|
diffId: crypto.randomUUID(),
|
|
640
|
-
isInserted: isInserted
|
|
641
|
-
diffType: diffType
|
|
623
|
+
isInserted: isInserted
|
|
642
624
|
}))));
|
|
643
625
|
}
|
|
644
626
|
}
|
|
@@ -2,7 +2,6 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
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; }
|
|
4
4
|
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) { _defineProperty(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; }
|
|
5
|
-
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
6
5
|
/**
|
|
7
6
|
* Decoration families produced by the show-diff plugin.
|
|
8
7
|
* Each family owns its own key space and spec shape.
|
|
@@ -54,19 +53,14 @@ export var buildAnchorDecorationKey = function buildAnchorDecorationKey(_ref) {
|
|
|
54
53
|
};
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
|
-
* Builds a diff decoration key. The
|
|
58
|
-
*
|
|
59
|
-
* distinguishable.
|
|
56
|
+
* Builds a diff decoration key. The key includes the `diffId` so independently
|
|
57
|
+
* rendered decorations for the same type remain distinguishable.
|
|
60
58
|
*/
|
|
61
59
|
export var buildDiffDecorationKey = function buildDiffDecorationKey(_ref2) {
|
|
62
60
|
var decorationKeyPrefix = _ref2.decorationKeyPrefix,
|
|
63
61
|
isActive = _ref2.isActive,
|
|
64
|
-
diffId = _ref2.diffId
|
|
65
|
-
|
|
66
|
-
if (isExtendedEnabled(diffType)) {
|
|
67
|
-
return "".concat(decorationKeyPrefix, "-").concat(diffId, "-").concat(isActive ? 'active' : 'inactive');
|
|
68
|
-
}
|
|
69
|
-
return isActive !== undefined ? "".concat(decorationKeyPrefix, "-").concat(isActive ? 'active' : 'inactive') : decorationKeyPrefix;
|
|
62
|
+
diffId = _ref2.diffId;
|
|
63
|
+
return "".concat(decorationKeyPrefix, "-").concat(diffId, "-").concat(isActive ? 'active' : 'inactive');
|
|
70
64
|
};
|
|
71
65
|
export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
|
|
72
66
|
var attributionKey = _ref3.attributionKey,
|
|
@@ -77,8 +71,7 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
|
|
|
77
71
|
isInserted = _ref3.isInserted,
|
|
78
72
|
leftAnchorId = _ref3.leftAnchorId,
|
|
79
73
|
nodeName = _ref3.nodeName,
|
|
80
|
-
side = _ref3.side
|
|
81
|
-
diffType = _ref3.diffType;
|
|
74
|
+
side = _ref3.side;
|
|
82
75
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
83
76
|
decorationFamily: DecorationFamily.diff,
|
|
84
77
|
decorationType: decorationType,
|
|
@@ -86,8 +79,7 @@ export var buildDiffDecorationSpec = function buildDiffDecorationSpec(_ref3) {
|
|
|
86
79
|
key: buildDiffDecorationKey({
|
|
87
80
|
decorationKeyPrefix: DiffDecorationKey[decorationType],
|
|
88
81
|
diffId: diffId,
|
|
89
|
-
isActive: isActive
|
|
90
|
-
diffType: diffType
|
|
82
|
+
isActive: isActive
|
|
91
83
|
})
|
|
92
84
|
}, attributionKey ? {
|
|
93
85
|
attributionKey: attributionKey
|