@atlaskit/editor-plugin-show-diff 10.1.23 → 10.2.0
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 +37 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/cjs/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -2
- package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +841 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/helpers.js +135 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/segmentText.js +331 -0
- package/dist/cjs/pm-plugins/calculateDiff/smart/thresholds.js +46 -0
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +8 -5
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/cjs/pm-plugins/isExtendedEnabled.js +20 -0
- package/dist/cjs/pm-plugins/main.js +21 -16
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -29
- package/dist/es2019/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
- package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +689 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/helpers.js +106 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/segmentText.js +283 -0
- package/dist/es2019/pm-plugins/calculateDiff/smart/thresholds.js +45 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +31 -16
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +9 -5
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -34
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/es2019/pm-plugins/isExtendedEnabled.js +12 -0
- package/dist/es2019/pm-plugins/main.js +21 -16
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/esm/pm-plugins/calculateDiff/groupChangesByBlock.js +4 -3
- package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +834 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/helpers.js +128 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/segmentText.js +325 -0
- package/dist/esm/pm-plugins/calculateDiff/smart/thresholds.js +39 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +24 -18
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +18 -12
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +6 -5
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +30 -17
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +9 -5
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +52 -30
- package/dist/esm/pm-plugins/getScrollableDecorations.js +6 -6
- package/dist/esm/pm-plugins/isExtendedEnabled.js +14 -0
- package/dist/esm/pm-plugins/main.js +21 -16
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +3 -1
- package/dist/types/pm-plugins/calculateDiff/groupChangesByBlock.d.ts +9 -0
- package/dist/types/pm-plugins/calculateDiff/smart/classifySmartChanges.d.ts +26 -0
- package/dist/types/pm-plugins/calculateDiff/smart/helpers.d.ts +44 -0
- package/dist/types/pm-plugins/calculateDiff/smart/segmentText.d.ts +32 -0
- package/dist/types/pm-plugins/calculateDiff/smart/thresholds.d.ts +44 -0
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +3 -2
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +4 -2
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +5 -3
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +6 -4
- package/dist/types/pm-plugins/getScrollableDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/isExtendedEnabled.d.ts +11 -0
- package/dist/types/pm-plugins/main.d.ts +11 -1
- package/dist/types/showDiffPluginType.d.ts +20 -1
- package/docs/smart-diff-design.md +240 -0
- package/package.json +7 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import {
|
|
3
|
+
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
4
4
|
import { editingStyle, editingStyleExtended, editingStyleActive, editingStyleActiveExtended, deletedContentStyle, deletedContentStyleActive, deletedInlineContentStyleExtended } from './colorSchemes/standard';
|
|
5
5
|
import { traditionalInsertStyle, traditionalInsertStyleActive, getDeletedTraditionalInlineStyle } from './colorSchemes/traditional';
|
|
6
6
|
import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
@@ -22,7 +22,8 @@ export const createInlineChangedDecoration = ({
|
|
|
22
22
|
isInserted = true,
|
|
23
23
|
shouldHideDeleted = false,
|
|
24
24
|
showIndicators = false,
|
|
25
|
-
doc
|
|
25
|
+
doc,
|
|
26
|
+
diffType
|
|
26
27
|
}) => {
|
|
27
28
|
const diffId = crypto.randomUUID();
|
|
28
29
|
if (shouldHideDeleted) {
|
|
@@ -35,7 +36,7 @@ export const createInlineChangedDecoration = ({
|
|
|
35
36
|
}))];
|
|
36
37
|
}
|
|
37
38
|
let style;
|
|
38
|
-
if (
|
|
39
|
+
if (isExtendedEnabled(diffType)) {
|
|
39
40
|
if (isInserted) {
|
|
40
41
|
if (colorScheme === 'traditional') {
|
|
41
42
|
style = isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
@@ -50,7 +51,7 @@ export const createInlineChangedDecoration = ({
|
|
|
50
51
|
/**
|
|
51
52
|
* Merge into existing styles when cleaning up
|
|
52
53
|
*/
|
|
53
|
-
if (
|
|
54
|
+
if (isExtendedEnabled(diffType)) {
|
|
54
55
|
style += deletedInlineContentStyleExtended;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -70,7 +71,7 @@ export const createInlineChangedDecoration = ({
|
|
|
70
71
|
diffId,
|
|
71
72
|
isActive
|
|
72
73
|
}))];
|
|
73
|
-
if (showIndicators && doc &&
|
|
74
|
+
if (showIndicators && doc && isExtendedEnabled(diffType)) {
|
|
74
75
|
decorations.push(...createInlineIndicatorAnchorWidgets({
|
|
75
76
|
doc,
|
|
76
77
|
from: change.fromB,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import {
|
|
2
|
+
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
3
3
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
4
4
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
5
5
|
import { buildDiffDecorationSpec, buildAnchorDecorationKey } from './decorationKeys';
|
|
@@ -20,14 +20,22 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
20
20
|
activeIndexPos,
|
|
21
21
|
// This is false by default as this is generally used to show deleted content
|
|
22
22
|
isInserted = false,
|
|
23
|
-
showIndicators = false
|
|
23
|
+
showIndicators = false,
|
|
24
|
+
// When true, render the deleted content *after* (below) the new content instead of
|
|
25
|
+
// before it. Used for `smart` node-level changes so the deleted node appears beneath
|
|
26
|
+
// its replacement (gray + strikethrough).
|
|
27
|
+
placeBelow = false,
|
|
28
|
+
diffType
|
|
24
29
|
}) => {
|
|
25
30
|
var _slice$content, _slice$content2, _slice$content2$first, _slice$content3, _slice$content3$first, _slice$content$firstC;
|
|
26
31
|
const slice = doc.slice(change.fromA, change.toA);
|
|
27
32
|
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;
|
|
28
33
|
// Widget decoration used for deletions as the content is not in the document
|
|
29
34
|
// and we want to display the deleted content with a style.
|
|
30
|
-
|
|
35
|
+
// For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
|
|
36
|
+
// node renders beneath its replacement; otherwise anchor at the start (change.fromB).
|
|
37
|
+
const anchorPos = placeBelow ? change.toB : change.fromB;
|
|
38
|
+
const safeInsertPos = findSafeInsertPos(newDoc, anchorPos, slice);
|
|
31
39
|
const isActive = activeIndexPos && safeInsertPos === activeIndexPos.from && safeInsertPos === activeIndexPos.to;
|
|
32
40
|
if (slice.content.content.length === 0 || shouldSkipDeletedEmptyParagraphDecoration) {
|
|
33
41
|
return [];
|
|
@@ -44,7 +52,8 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
44
52
|
newDoc,
|
|
45
53
|
nodeViewSerializer,
|
|
46
54
|
colorScheme,
|
|
47
|
-
isInserted
|
|
55
|
+
isInserted,
|
|
56
|
+
diffType
|
|
48
57
|
});
|
|
49
58
|
}
|
|
50
59
|
const serializer = nodeViewSerializer;
|
|
@@ -57,7 +66,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
57
66
|
// Observe DOM mutations and override the transform on .rich-media-item elements
|
|
58
67
|
// after React mounts to prevent the image from shifting outside its parent container.
|
|
59
68
|
let constrainMediaObserver;
|
|
60
|
-
if (
|
|
69
|
+
if (isExtendedEnabled(diffType)) {
|
|
61
70
|
constrainMediaObserver = new MutationObserver(() => {
|
|
62
71
|
const richMediaItems = dom.querySelectorAll('.rich-media-item');
|
|
63
72
|
richMediaItems.forEach(el => {
|
|
@@ -94,14 +103,14 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
94
103
|
if (childNodeView) {
|
|
95
104
|
const lineBreak = document.createElement('br');
|
|
96
105
|
dom.append(lineBreak);
|
|
97
|
-
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
106
|
+
const wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
|
|
98
107
|
wrapper.append(childNodeView);
|
|
99
108
|
dom.append(wrapper);
|
|
100
109
|
} else {
|
|
101
110
|
// Fallback to serializing the individual child node
|
|
102
111
|
const serializedChild = serializer.serializeNode(childNode);
|
|
103
112
|
if (serializedChild) {
|
|
104
|
-
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
113
|
+
const wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
|
|
105
114
|
wrapper.append(serializedChild);
|
|
106
115
|
dom.append(wrapper);
|
|
107
116
|
}
|
|
@@ -142,7 +151,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
142
151
|
const nodeView = serializer.tryCreateNodeView(node);
|
|
143
152
|
if (nodeView) {
|
|
144
153
|
if (node.isInline) {
|
|
145
|
-
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
154
|
+
const wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
|
|
146
155
|
wrapper.append(nodeView);
|
|
147
156
|
dom.append(wrapper);
|
|
148
157
|
} else {
|
|
@@ -154,7 +163,8 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
154
163
|
colorScheme,
|
|
155
164
|
intl,
|
|
156
165
|
isActive,
|
|
157
|
-
isInserted
|
|
166
|
+
isInserted,
|
|
167
|
+
diffType
|
|
158
168
|
});
|
|
159
169
|
}
|
|
160
170
|
} else if (nodeViewSerializer.getFilteredNodeViewBlocklist(['paragraph', 'tableRow']).has(node.type.name)) {
|
|
@@ -168,11 +178,12 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
168
178
|
node: fallbackNode,
|
|
169
179
|
colorScheme,
|
|
170
180
|
isActive,
|
|
171
|
-
isInserted
|
|
181
|
+
isInserted,
|
|
182
|
+
diffType
|
|
172
183
|
});
|
|
173
184
|
dom.append(injectedNode);
|
|
174
185
|
} else {
|
|
175
|
-
const wrapper = createContentWrapper(colorScheme, isActive, isInserted);
|
|
186
|
+
const wrapper = createContentWrapper(colorScheme, isActive, isInserted, diffType);
|
|
176
187
|
wrapper.append(fallbackNode);
|
|
177
188
|
dom.append(wrapper);
|
|
178
189
|
}
|
|
@@ -180,7 +191,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
180
191
|
}
|
|
181
192
|
});
|
|
182
193
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
183
|
-
if (showIndicators &&
|
|
194
|
+
if (showIndicators && isExtendedEnabled(diffType)) {
|
|
184
195
|
const leftAnchor = createLeftAnchorWidget({
|
|
185
196
|
doc: newDoc,
|
|
186
197
|
from: safeInsertPos,
|
|
@@ -198,8 +209,11 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
198
209
|
decorationType: 'widget',
|
|
199
210
|
diffId,
|
|
200
211
|
isActive,
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
diffType,
|
|
213
|
+
...(isExtendedEnabled(diffType) && {
|
|
214
|
+
// placeBelow anchors at the end of the new content, so render on the
|
|
215
|
+
// trailing side (1); otherwise render before the new content (-1).
|
|
216
|
+
side: placeBelow ? 1 : -1
|
|
203
217
|
})
|
|
204
218
|
}),
|
|
205
219
|
destroy: () => {
|
|
@@ -223,7 +237,7 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
223
237
|
const isSingleBlock = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.isBlock);
|
|
224
238
|
const resolvedPos = newDoc.resolve(change.fromB);
|
|
225
239
|
const isFirstDocChild = resolvedPos.depth === 0 && resolvedPos.index(0) === 0;
|
|
226
|
-
if (isFirstDocChild && isSingleBlock && isPureDeletion &&
|
|
240
|
+
if (isFirstDocChild && isSingleBlock && isPureDeletion && isExtendedEnabled(diffType)) {
|
|
227
241
|
const emptyWidgetSpan = document.createElement('span');
|
|
228
242
|
emptyWidgetSpan.style.display = 'block';
|
|
229
243
|
// Use a design token for the margin to keep spacing consistent with the design system
|
|
@@ -231,7 +245,8 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
231
245
|
const widget = Decoration.widget(safeInsertPos, emptyWidgetSpan, {
|
|
232
246
|
...buildDiffDecorationSpec({
|
|
233
247
|
decorationType: 'widget',
|
|
234
|
-
diffId: crypto.randomUUID()
|
|
248
|
+
diffId: crypto.randomUUID(),
|
|
249
|
+
diffType
|
|
235
250
|
})
|
|
236
251
|
});
|
|
237
252
|
decorations.push(widget);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Decoration families produced by the show-diff plugin.
|
|
4
5
|
* Each family owns its own key space and spec shape.
|
|
@@ -39,9 +40,10 @@ export const buildAnchorDecorationKey = ({
|
|
|
39
40
|
export const buildDiffDecorationKey = ({
|
|
40
41
|
decorationKeyPrefix,
|
|
41
42
|
isActive,
|
|
42
|
-
diffId
|
|
43
|
+
diffId,
|
|
44
|
+
diffType
|
|
43
45
|
}) => {
|
|
44
|
-
if (
|
|
46
|
+
if (isExtendedEnabled(diffType)) {
|
|
45
47
|
return `${decorationKeyPrefix}-${diffId}-${isActive ? 'active' : 'inactive'}`;
|
|
46
48
|
}
|
|
47
49
|
return isActive !== undefined ? `${decorationKeyPrefix}-${isActive ? 'active' : 'inactive'}` : decorationKeyPrefix;
|
|
@@ -51,7 +53,8 @@ export const buildDiffDecorationSpec = ({
|
|
|
51
53
|
diffId,
|
|
52
54
|
isActive,
|
|
53
55
|
nodeName,
|
|
54
|
-
side
|
|
56
|
+
side,
|
|
57
|
+
diffType
|
|
55
58
|
}) => ({
|
|
56
59
|
decorationFamily: DecorationFamily.diff,
|
|
57
60
|
decorationType,
|
|
@@ -59,7 +62,8 @@ export const buildDiffDecorationSpec = ({
|
|
|
59
62
|
key: buildDiffDecorationKey({
|
|
60
63
|
decorationKeyPrefix: DiffDecorationKey[decorationType],
|
|
61
64
|
diffId,
|
|
62
|
-
isActive
|
|
65
|
+
isActive,
|
|
66
|
+
diffType
|
|
63
67
|
}),
|
|
64
68
|
...(nodeName ? {
|
|
65
69
|
nodeName
|
|
@@ -2,6 +2,7 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
2
2
|
import { trackChangesMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { isExtendedEnabled } from '../../isExtendedEnabled';
|
|
5
6
|
import { deletedBlockOutline, deletedBlockOutlineActive, deletedBlockOutlineRounded, deletedBlockOutlineRoundedActive, deletedContentStyle, deletedContentStyleActive, deletedContentStyleNew, deletedContentStyleUnbounded, deletedInlineContentStyleExtended, deletedStyleQuoteNodeWithLozenge, deletedStyleQuoteNodeWithLozengeActive, editingContentStyleInBlockExtended, editingStyleExtended, editingStyleActiveExtended, editingStyleNode, addedCellOverlayStyle, deletedCellOverlayStyle } from '../colorSchemes/standard';
|
|
6
7
|
import { deletedTraditionalBlockOutlineActive, deletedTraditionalBlockOutlineNew, deletedTraditionalBlockOutlineRoundedActive, deletedTraditionalBlockOutlineRoundedNew, deletedTraditionalContentStyleUnbounded, deletedTraditionalContentStyleUnboundedActive, getDeletedTraditionalInlineStyle, deletedTraditionalStyleQuoteNode, deletedTraditionalStyleQuoteNodeActive, traditionalInsertStyle, traditionalInsertStyleActive, traditionalStyleNodeActive, traditionalStyleNodeNew, traditionalAddedCellOverlayStyleNew, deletedTraditionalCellOverlayStyle } from '../colorSchemes/traditional';
|
|
7
8
|
const lozengeStyle = convertToInlineCss({
|
|
@@ -52,8 +53,8 @@ const lozengeStyleActiveTraditional = convertToInlineCss({
|
|
|
52
53
|
whiteSpace: 'nowrap',
|
|
53
54
|
color: "var(--ds-text-warning-inverse, #292A2E)"
|
|
54
55
|
});
|
|
55
|
-
const getChangedContentStyle = (colorScheme, isActive = false, isInserted = false) => {
|
|
56
|
-
if (
|
|
56
|
+
const getChangedContentStyle = (colorScheme, isActive = false, isInserted = false, diffType) => {
|
|
57
|
+
if (isExtendedEnabled(diffType) && isInserted) {
|
|
57
58
|
if (colorScheme === 'traditional') {
|
|
58
59
|
return isActive ? traditionalInsertStyleActive : traditionalInsertStyle;
|
|
59
60
|
}
|
|
@@ -67,9 +68,9 @@ const getChangedContentStyle = (colorScheme, isActive = false, isInserted = fals
|
|
|
67
68
|
}
|
|
68
69
|
return expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? deletedContentStyleNew : deletedContentStyle;
|
|
69
70
|
};
|
|
70
|
-
const getChangedNodeStyle = (nodeName, colorScheme, isInserted = false, isActive = false) => {
|
|
71
|
+
const getChangedNodeStyle = (nodeName, colorScheme, isInserted = false, isActive = false, diffType) => {
|
|
71
72
|
const isTraditional = colorScheme === 'traditional';
|
|
72
|
-
if (
|
|
73
|
+
if (isExtendedEnabled(diffType) && isInserted) {
|
|
73
74
|
if (isMultiContainerBlockNode(nodeName)) {
|
|
74
75
|
return editingContentStyleInBlockExtended;
|
|
75
76
|
}
|
|
@@ -217,12 +218,13 @@ const applyStylesToElement = ({
|
|
|
217
218
|
targetNode,
|
|
218
219
|
colorScheme,
|
|
219
220
|
isActive,
|
|
220
|
-
isInserted
|
|
221
|
+
isInserted,
|
|
222
|
+
diffType
|
|
221
223
|
}) => {
|
|
222
224
|
const currentStyle = element.getAttribute('style') || '';
|
|
223
|
-
const contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
225
|
+
const contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
224
226
|
const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
225
|
-
const nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
|
|
227
|
+
const nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
|
|
226
228
|
element.setAttribute('style', `${currentStyle}${contentStyle}${nodeSpecificStyle}`);
|
|
227
229
|
};
|
|
228
230
|
const applyMultiContainerLikeStyles = ({
|
|
@@ -230,11 +232,12 @@ const applyMultiContainerLikeStyles = ({
|
|
|
230
232
|
targetNode,
|
|
231
233
|
colorScheme,
|
|
232
234
|
isActive,
|
|
233
|
-
isInserted
|
|
235
|
+
isInserted,
|
|
236
|
+
diffType
|
|
234
237
|
}) => {
|
|
235
238
|
const currentStyle = element.getAttribute('style') || '';
|
|
236
239
|
const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
237
|
-
const nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive) || '';
|
|
240
|
+
const nodeSpecificStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType) || '';
|
|
238
241
|
if (targetNode.type.name === 'decisionList') {
|
|
239
242
|
element.querySelectorAll('li').forEach(listItem => {
|
|
240
243
|
const currentListItemStyle = listItem.getAttribute('style') || '';
|
|
@@ -258,10 +261,15 @@ const applyTextLikeBlockNodeStyles = ({
|
|
|
258
261
|
targetNode,
|
|
259
262
|
colorScheme,
|
|
260
263
|
isActive,
|
|
261
|
-
isInserted
|
|
264
|
+
isInserted,
|
|
265
|
+
diffType
|
|
262
266
|
}) => {
|
|
263
|
-
|
|
264
|
-
const
|
|
267
|
+
const currentStyle = element.getAttribute('style') || '';
|
|
268
|
+
const nodeSpecificStyle = getChangedNodeStyle(targetNode.type.name, colorScheme, isInserted, isActive, diffType) || '';
|
|
269
|
+
if (nodeSpecificStyle) {
|
|
270
|
+
element.setAttribute('style', `${currentStyle}${nodeSpecificStyle}`);
|
|
271
|
+
}
|
|
272
|
+
const contentStyle = getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
265
273
|
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
266
274
|
const textNodesToWrap = [];
|
|
267
275
|
let currentNode = walker.nextNode();
|
|
@@ -287,17 +295,18 @@ const createBlockNodeContentWrapper = ({
|
|
|
287
295
|
targetNode,
|
|
288
296
|
colorScheme,
|
|
289
297
|
isActive,
|
|
290
|
-
isInserted
|
|
298
|
+
isInserted,
|
|
299
|
+
diffType
|
|
291
300
|
}) => {
|
|
292
301
|
const contentWrapper = document.createElement('div');
|
|
293
302
|
const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
294
|
-
const nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive);
|
|
303
|
+
const nodeStyle = getChangedNodeStyle(targetNodeName, colorScheme, isInserted, isActive, diffType);
|
|
295
304
|
|
|
296
305
|
// When the extended experiment is enabled and the content is inserted,
|
|
297
306
|
// block widget nodes that already have dedicated node-level styling (e.g. boxShadow outline)
|
|
298
307
|
// should not also get the inline content style (borderBottom underline) on their container.
|
|
299
|
-
const shouldSkipContentStyle =
|
|
300
|
-
const contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted);
|
|
308
|
+
const shouldSkipContentStyle = isExtendedEnabled(diffType) && isInserted && nodeStyle !== undefined;
|
|
309
|
+
const contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, diffType);
|
|
301
310
|
contentWrapper.setAttribute('style', `${contentStyle}${nodeStyle || ''}`);
|
|
302
311
|
contentWrapper.append(nodeView);
|
|
303
312
|
return contentWrapper;
|
|
@@ -409,11 +418,12 @@ const wrapBlockNode = ({
|
|
|
409
418
|
colorScheme,
|
|
410
419
|
intl,
|
|
411
420
|
isActive = false,
|
|
412
|
-
isInserted = false
|
|
421
|
+
isInserted = false,
|
|
422
|
+
diffType
|
|
413
423
|
}) => {
|
|
414
424
|
const blockWrapper = createBlockNodeWrapper();
|
|
415
425
|
const targetNodeName = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? getBaseNodeTypeName(targetNode.type) : targetNode.type.name;
|
|
416
|
-
if (shouldShowRemovedLozenge(targetNodeName) && (!
|
|
426
|
+
if (shouldShowRemovedLozenge(targetNodeName) && (!isExtendedEnabled(diffType) || !isInserted)) {
|
|
417
427
|
const lozenge = createRemovedLozenge(intl, isActive, colorScheme);
|
|
418
428
|
if (handleEmbedCardWithLozenge({
|
|
419
429
|
dom,
|
|
@@ -442,7 +452,8 @@ const wrapBlockNode = ({
|
|
|
442
452
|
targetNode,
|
|
443
453
|
colorScheme,
|
|
444
454
|
isActive,
|
|
445
|
-
isInserted
|
|
455
|
+
isInserted,
|
|
456
|
+
diffType
|
|
446
457
|
});
|
|
447
458
|
blockWrapper.append(contentWrapper);
|
|
448
459
|
if (nodeView instanceof HTMLElement && shouldAddShowDiffDeletedNodeClass(targetNode.type.name)) {
|
|
@@ -473,9 +484,10 @@ export const wrapBlockNodeView = ({
|
|
|
473
484
|
colorScheme,
|
|
474
485
|
intl,
|
|
475
486
|
isActive = false,
|
|
476
|
-
isInserted = false
|
|
487
|
+
isInserted = false,
|
|
488
|
+
diffType
|
|
477
489
|
}) => {
|
|
478
|
-
if (
|
|
490
|
+
if (isExtendedEnabled(diffType)) {
|
|
479
491
|
if (nodeView instanceof HTMLElement) {
|
|
480
492
|
if (isInserted && isMultiContainerBlockNode(targetNode.type.name)) {
|
|
481
493
|
applyMultiContainerLikeStyles({
|
|
@@ -483,7 +495,8 @@ export const wrapBlockNodeView = ({
|
|
|
483
495
|
targetNode,
|
|
484
496
|
colorScheme,
|
|
485
497
|
isActive,
|
|
486
|
-
isInserted
|
|
498
|
+
isInserted,
|
|
499
|
+
diffType
|
|
487
500
|
});
|
|
488
501
|
dom.append(nodeView);
|
|
489
502
|
return;
|
|
@@ -494,7 +507,8 @@ export const wrapBlockNodeView = ({
|
|
|
494
507
|
targetNode,
|
|
495
508
|
colorScheme,
|
|
496
509
|
isActive,
|
|
497
|
-
isInserted
|
|
510
|
+
isInserted,
|
|
511
|
+
diffType
|
|
498
512
|
});
|
|
499
513
|
dom.append(nodeView);
|
|
500
514
|
return;
|
|
@@ -516,7 +530,8 @@ export const wrapBlockNodeView = ({
|
|
|
516
530
|
colorScheme,
|
|
517
531
|
intl,
|
|
518
532
|
isActive,
|
|
519
|
-
isInserted
|
|
533
|
+
isInserted,
|
|
534
|
+
diffType
|
|
520
535
|
});
|
|
521
536
|
return;
|
|
522
537
|
} else {
|
|
@@ -527,7 +542,8 @@ export const wrapBlockNodeView = ({
|
|
|
527
542
|
targetNode,
|
|
528
543
|
colorScheme,
|
|
529
544
|
isActive,
|
|
530
|
-
isInserted
|
|
545
|
+
isInserted,
|
|
546
|
+
diffType
|
|
531
547
|
});
|
|
532
548
|
dom.append(nodeView);
|
|
533
549
|
} else {
|
|
@@ -538,7 +554,8 @@ export const wrapBlockNodeView = ({
|
|
|
538
554
|
colorScheme,
|
|
539
555
|
intl,
|
|
540
556
|
isActive,
|
|
541
|
-
isInserted
|
|
557
|
+
isInserted,
|
|
558
|
+
diffType
|
|
542
559
|
});
|
|
543
560
|
}
|
|
544
561
|
}
|
|
@@ -558,11 +575,11 @@ const getInsertedContentStyle = (colorScheme, isActive = false) => {
|
|
|
558
575
|
}
|
|
559
576
|
return editingStyleExtended;
|
|
560
577
|
};
|
|
561
|
-
const getDeletedContentStyle = (colorScheme, isActive = false) => {
|
|
578
|
+
const getDeletedContentStyle = (colorScheme, isActive = false, diffType) => {
|
|
562
579
|
if (colorScheme === 'traditional') {
|
|
563
580
|
return getDeletedTraditionalInlineStyle(isActive);
|
|
564
581
|
}
|
|
565
|
-
if (
|
|
582
|
+
if (isExtendedEnabled(diffType)) {
|
|
566
583
|
return (isActive ? deletedContentStyleActive : deletedContentStyleNew) + deletedInlineContentStyleExtended;
|
|
567
584
|
}
|
|
568
585
|
return isActive ? deletedContentStyleActive : deletedContentStyleNew;
|
|
@@ -577,10 +594,11 @@ export const injectInnerWrapper = ({
|
|
|
577
594
|
node,
|
|
578
595
|
colorScheme,
|
|
579
596
|
isActive,
|
|
580
|
-
isInserted
|
|
597
|
+
isInserted,
|
|
598
|
+
diffType
|
|
581
599
|
}) => {
|
|
582
600
|
const wrapper = document.createElement('span');
|
|
583
|
-
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive));
|
|
601
|
+
wrapper.setAttribute('style', isInserted ? getInsertedContentStyle(colorScheme, isActive) : getDeletedContentStyle(colorScheme, isActive, diffType));
|
|
584
602
|
[...node.childNodes].forEach(child => {
|
|
585
603
|
const removedChild = node.removeChild(child);
|
|
586
604
|
wrapper.append(removedChild);
|
|
@@ -592,23 +610,23 @@ export const injectInnerWrapper = ({
|
|
|
592
610
|
/**
|
|
593
611
|
* Creates a styled span wrapper for inline content within a change decoration.
|
|
594
612
|
*/
|
|
595
|
-
export const createContentWrapper = (colorScheme, isActive = false, isInserted = false) => {
|
|
613
|
+
export const createContentWrapper = (colorScheme, isActive = false, isInserted = false, diffType) => {
|
|
596
614
|
const wrapper = document.createElement('span');
|
|
597
615
|
const baseStyle = convertToInlineCss({
|
|
598
616
|
position: 'relative',
|
|
599
617
|
width: 'fit-content'
|
|
600
618
|
});
|
|
601
|
-
if (
|
|
619
|
+
if (isExtendedEnabled(diffType)) {
|
|
602
620
|
if (isInserted) {
|
|
603
621
|
wrapper.setAttribute('style', `${baseStyle}${getInsertedContentStyle(colorScheme, isActive)}`);
|
|
604
622
|
} else {
|
|
605
|
-
wrapper.setAttribute('style', `${baseStyle}${getDeletedContentStyle(colorScheme, isActive)}`);
|
|
623
|
+
wrapper.setAttribute('style', `${baseStyle}${getDeletedContentStyle(colorScheme, isActive, diffType)}`);
|
|
606
624
|
const strikethrough = document.createElement('span');
|
|
607
625
|
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
608
626
|
wrapper.append(strikethrough);
|
|
609
627
|
}
|
|
610
628
|
} else {
|
|
611
|
-
wrapper.setAttribute('style', `${baseStyle}${getDeletedContentStyle(colorScheme, isActive)}`);
|
|
629
|
+
wrapper.setAttribute('style', `${baseStyle}${getDeletedContentStyle(colorScheme, isActive, diffType)}`);
|
|
612
630
|
const strikethrough = document.createElement('span');
|
|
613
631
|
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colorScheme, isActive));
|
|
614
632
|
wrapper.append(strikethrough);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
1
|
import { DiffDecorationKey, isDiffDecoration, isDiffDecorationSpec } from './decorations/decorationKeys';
|
|
2
|
+
import { isExtendedEnabled } from './isExtendedEnabled';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* True if `fragment` contains at least one inline node (text, hardBreak, emoji, mention, etc.).
|
|
@@ -60,24 +60,24 @@ function specHasDiffKeyPrefix(spec, keyPrefix) {
|
|
|
60
60
|
* @param doc - Current document; when set, diff-inline ranges are validated against this doc
|
|
61
61
|
* @returns Array of scrollable decorations, sorted and deduplicated
|
|
62
62
|
*/
|
|
63
|
-
export const getScrollableDecorations = (set, doc) => {
|
|
63
|
+
export const getScrollableDecorations = (set, doc, diffType) => {
|
|
64
64
|
if (!set) {
|
|
65
65
|
return [];
|
|
66
66
|
}
|
|
67
67
|
const isBlockDecoration = decoration => {
|
|
68
68
|
var _decoration$spec$key$, _decoration$spec, _decoration$spec$key;
|
|
69
|
-
return
|
|
69
|
+
return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'block' : (_decoration$spec$key$ = (_decoration$spec = decoration.spec) === null || _decoration$spec === void 0 ? void 0 : (_decoration$spec$key = _decoration$spec.key) === null || _decoration$spec$key === void 0 ? void 0 : _decoration$spec$key.startsWith(DiffDecorationKey.block)) !== null && _decoration$spec$key$ !== void 0 ? _decoration$spec$key$ : false;
|
|
70
70
|
};
|
|
71
71
|
const isInlineDecoration = decoration => {
|
|
72
72
|
var _decoration$spec$key$2, _decoration$spec2, _decoration$spec2$key;
|
|
73
|
-
return
|
|
73
|
+
return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'inline' : (_decoration$spec$key$2 = (_decoration$spec2 = decoration.spec) === null || _decoration$spec2 === void 0 ? void 0 : (_decoration$spec2$key = _decoration$spec2.key) === null || _decoration$spec2$key === void 0 ? void 0 : _decoration$spec2$key.startsWith(DiffDecorationKey.inline)) !== null && _decoration$spec$key$2 !== void 0 ? _decoration$spec$key$2 : false;
|
|
74
74
|
};
|
|
75
75
|
const isWidgetDecoration = decoration => {
|
|
76
76
|
var _decoration$spec$key$3, _decoration$spec3, _decoration$spec3$key;
|
|
77
|
-
return
|
|
77
|
+
return isExtendedEnabled(diffType) ? isDiffDecoration(decoration) && decoration.spec.decorationType === 'widget' : (_decoration$spec$key$3 = (_decoration$spec3 = decoration.spec) === null || _decoration$spec3 === void 0 ? void 0 : (_decoration$spec3$key = _decoration$spec3.key) === null || _decoration$spec3$key === void 0 ? void 0 : _decoration$spec3$key.startsWith(DiffDecorationKey.widget)) !== null && _decoration$spec$key$3 !== void 0 ? _decoration$spec$key$3 : false;
|
|
78
78
|
};
|
|
79
79
|
const seenBlockKeys = new Set();
|
|
80
|
-
const allDecorations =
|
|
80
|
+
const allDecorations = isExtendedEnabled(diffType) ? set.find(undefined, undefined, isDiffDecorationSpec) : set.find(undefined, undefined, spec => specHasDiffKeyPrefix(spec, DiffDecorationKey.inline) || specHasDiffKeyPrefix(spec, DiffDecorationKey.widget) || specHasDiffKeyPrefix(spec, DiffDecorationKey.block));
|
|
81
81
|
|
|
82
82
|
// First pass: filter out listItem blocks and deduplicates blocks
|
|
83
83
|
const filtered = allDecorations.filter(dec => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
+
/**
|
|
4
|
+
* The "extended" diff pipeline is normally gated by `platform_editor_diff_plugin_extended`.
|
|
5
|
+
* The `smart` diff type REQUIRES the extended pipeline, so whenever `smart` is active (and its
|
|
6
|
+
* own gate `platform_editor_ai_smart_diff` is on) the extended pipeline is force-enabled,
|
|
7
|
+
* independent of the extended gate. For all other diff types the extended gate alone decides.
|
|
8
|
+
*
|
|
9
|
+
* Pass the active `diffType` so callers deep in the decoration layer render the extended shape
|
|
10
|
+
* when `smart` is active even if `platform_editor_diff_plugin_extended` is off.
|
|
11
|
+
*/
|
|
12
|
+
export const isExtendedEnabled = diffType => expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || diffType === 'smart' && fg('platform_editor_ai_smart_diff');
|
|
@@ -3,10 +3,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
6
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
8
7
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
9
8
|
import { getScrollableDecorations } from './getScrollableDecorations';
|
|
9
|
+
import { isExtendedEnabled } from './isExtendedEnabled';
|
|
10
10
|
import { NodeViewSerializer } from './NodeViewSerializer';
|
|
11
11
|
import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
|
|
12
12
|
export const showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
@@ -28,7 +28,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
28
28
|
originalDoc: undefined,
|
|
29
29
|
decorations: DecorationSet.empty,
|
|
30
30
|
isDisplayingChanges: false,
|
|
31
|
-
...(
|
|
31
|
+
...(isExtendedEnabled() ? {
|
|
32
32
|
isInverted: false,
|
|
33
33
|
diffType: 'inline',
|
|
34
34
|
hideDeletedDiffs: false,
|
|
@@ -42,7 +42,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
42
42
|
let newPluginState = currentPluginState;
|
|
43
43
|
if (meta) {
|
|
44
44
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
45
|
-
var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4;
|
|
45
|
+
var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8;
|
|
46
46
|
// Update the plugin state with the new metadata
|
|
47
47
|
newPluginState = {
|
|
48
48
|
...currentPluginState,
|
|
@@ -62,16 +62,18 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
62
62
|
intl: getIntl(),
|
|
63
63
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
64
64
|
api,
|
|
65
|
-
...(
|
|
66
|
-
isInverted: (
|
|
67
|
-
diffType: (
|
|
68
|
-
hideDeletedDiffs: (
|
|
69
|
-
showIndicators: (
|
|
65
|
+
...(isExtendedEnabled((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
|
|
66
|
+
isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
|
|
67
|
+
diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
|
|
68
|
+
hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
|
|
69
|
+
showIndicators: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.showIndicators,
|
|
70
|
+
smartThresholds: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.smartThresholds,
|
|
71
|
+
deletedDiffPlacement: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.deletedDiffPlacement
|
|
70
72
|
} : {})
|
|
71
73
|
});
|
|
72
74
|
// Update the decorations and their ids
|
|
73
75
|
newPluginState.decorations = decorations;
|
|
74
|
-
if (
|
|
76
|
+
if (isExtendedEnabled((_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.diffType)) {
|
|
75
77
|
newPluginState.diffDescriptors = diffDescriptors;
|
|
76
78
|
}
|
|
77
79
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
@@ -85,7 +87,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
85
87
|
* Reset isInverted & diffType state when hiding diffs
|
|
86
88
|
* Otherwise this should persist for the diff-showing session
|
|
87
89
|
*/
|
|
88
|
-
...(
|
|
90
|
+
...(isExtendedEnabled(currentPluginState.diffType) ? {
|
|
89
91
|
isInverted: false,
|
|
90
92
|
diffType: 'inline',
|
|
91
93
|
hideDeletedDiffs: false,
|
|
@@ -93,8 +95,9 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
93
95
|
} : {})
|
|
94
96
|
};
|
|
95
97
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_NEXT' || (meta === null || meta === void 0 ? void 0 : meta.action) === 'SCROLL_TO_PREVIOUS') {
|
|
98
|
+
var _newPluginState9;
|
|
96
99
|
// Update the active index in plugin state and recalculate decorations
|
|
97
|
-
const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc);
|
|
100
|
+
const decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType);
|
|
98
101
|
if (decorations.length > 0) {
|
|
99
102
|
var _currentPluginState$a;
|
|
100
103
|
// Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
|
|
@@ -132,15 +135,17 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
132
135
|
intl: getIntl(),
|
|
133
136
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
134
137
|
api,
|
|
135
|
-
...(
|
|
138
|
+
...(isExtendedEnabled(newPluginState.diffType) ? {
|
|
136
139
|
isInverted: newPluginState.isInverted,
|
|
137
140
|
diffType: newPluginState.diffType,
|
|
138
141
|
hideDeletedDiffs: newPluginState.hideDeletedDiffs,
|
|
139
|
-
showIndicators: newPluginState.showIndicators
|
|
142
|
+
showIndicators: newPluginState.showIndicators,
|
|
143
|
+
smartThresholds: newPluginState.smartThresholds,
|
|
144
|
+
deletedDiffPlacement: newPluginState.deletedDiffPlacement
|
|
140
145
|
} : {})
|
|
141
146
|
});
|
|
142
147
|
newPluginState.decorations = updatedDecorations;
|
|
143
|
-
if (
|
|
148
|
+
if (isExtendedEnabled(newPluginState.diffType)) {
|
|
144
149
|
newPluginState.diffDescriptors = updatedDiffDescriptors;
|
|
145
150
|
}
|
|
146
151
|
}
|
|
@@ -176,7 +181,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
176
181
|
const pluginState = showDiffPluginKey.getState(view.state);
|
|
177
182
|
|
|
178
183
|
// Scroll to the first decoration when scrollIntoView was requested
|
|
179
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView &&
|
|
184
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
|
|
180
185
|
var _cancelPendingScrollT;
|
|
181
186
|
(_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 ? void 0 : _cancelPendingScrollT();
|
|
182
187
|
cancelPendingScrollToDecoration = scrollToFirstDecoration(view, pluginState.decorations);
|
|
@@ -193,7 +198,7 @@ export const createPlugin = (config, getIntl, api) => {
|
|
|
193
198
|
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
194
199
|
var _cancelPendingScrollT2, _api$expand, _api$expand$commands;
|
|
195
200
|
(_cancelPendingScrollT2 = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT2 === void 0 ? void 0 : _cancelPendingScrollT2();
|
|
196
|
-
const scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc);
|
|
201
|
+
const scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType);
|
|
197
202
|
const activeDecoration = scrollableDecorations[pluginState.activeIndex];
|
|
198
203
|
if (activeDecoration && api !== null && api !== void 0 && (_api$expand = api.expand) !== null && _api$expand !== void 0 && (_api$expand$commands = _api$expand.commands) !== null && _api$expand$commands !== void 0 && _api$expand$commands.toggleExpandRange) {
|
|
199
204
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|