@atlaskit/editor-plugin-show-diff 10.1.23 → 10.3.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 +63 -0
- package/calculate-diff/package.json +8 -0
- package/dist/cjs/entry-points/calculate-diff.js +12 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/cjs/pm-plugins/calculateDiff/computeDiffChanges.js +112 -0
- 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/entry-points/calculate-diff.js +2 -0
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +119 -29
- package/dist/es2019/pm-plugins/calculateDiff/computeDiffChanges.js +94 -0
- 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/entry-points/calculate-diff.js +2 -0
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +132 -31
- package/dist/esm/pm-plugins/calculateDiff/computeDiffChanges.js +107 -0
- 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/calculate-diff.d.ts +2 -0
- 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/computeDiffChanges.d.ts +46 -0
- 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 +8 -3
|
@@ -6,10 +6,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
9
|
import { calculateDiffDecorations } from './calculateDiff/calculateDiffDecorations';
|
|
11
10
|
import { enforceCustomStepRegisters } from './enforceCustomStepRegisters';
|
|
12
11
|
import { getScrollableDecorations } from './getScrollableDecorations';
|
|
12
|
+
import { isExtendedEnabled } from './isExtendedEnabled';
|
|
13
13
|
import { NodeViewSerializer } from './NodeViewSerializer';
|
|
14
14
|
import { scrollToActiveDecoration, scrollToFirstDecoration } from './scrollToDiff';
|
|
15
15
|
export var showDiffPluginKey = new PluginKey('showDiffPlugin');
|
|
@@ -31,7 +31,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
31
31
|
originalDoc: undefined,
|
|
32
32
|
decorations: DecorationSet.empty,
|
|
33
33
|
isDisplayingChanges: false
|
|
34
|
-
},
|
|
34
|
+
}, isExtendedEnabled() ? {
|
|
35
35
|
isInverted: false,
|
|
36
36
|
diffType: 'inline',
|
|
37
37
|
hideDeletedDiffs: false,
|
|
@@ -44,7 +44,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
44
44
|
var newPluginState = currentPluginState;
|
|
45
45
|
if (meta) {
|
|
46
46
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
47
|
-
var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4;
|
|
47
|
+
var _newPluginState, _newPluginState2, _newPluginState3, _newPluginState4, _newPluginState5, _newPluginState6, _newPluginState7, _newPluginState8;
|
|
48
48
|
// Update the plugin state with the new metadata
|
|
49
49
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
50
50
|
isDisplayingChanges: true,
|
|
@@ -59,17 +59,19 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
59
59
|
intl: getIntl(),
|
|
60
60
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
61
61
|
api: api
|
|
62
|
-
},
|
|
63
|
-
isInverted: (
|
|
64
|
-
diffType: (
|
|
65
|
-
hideDeletedDiffs: (
|
|
66
|
-
showIndicators: (
|
|
62
|
+
}, isExtendedEnabled((_newPluginState = newPluginState) === null || _newPluginState === void 0 ? void 0 : _newPluginState.diffType) ? {
|
|
63
|
+
isInverted: (_newPluginState2 = newPluginState) === null || _newPluginState2 === void 0 ? void 0 : _newPluginState2.isInverted,
|
|
64
|
+
diffType: (_newPluginState3 = newPluginState) === null || _newPluginState3 === void 0 ? void 0 : _newPluginState3.diffType,
|
|
65
|
+
hideDeletedDiffs: (_newPluginState4 = newPluginState) === null || _newPluginState4 === void 0 ? void 0 : _newPluginState4.hideDeletedDiffs,
|
|
66
|
+
showIndicators: (_newPluginState5 = newPluginState) === null || _newPluginState5 === void 0 ? void 0 : _newPluginState5.showIndicators,
|
|
67
|
+
smartThresholds: (_newPluginState6 = newPluginState) === null || _newPluginState6 === void 0 ? void 0 : _newPluginState6.smartThresholds,
|
|
68
|
+
deletedDiffPlacement: (_newPluginState7 = newPluginState) === null || _newPluginState7 === void 0 ? void 0 : _newPluginState7.deletedDiffPlacement
|
|
67
69
|
} : {})),
|
|
68
70
|
decorations = _calculateDiffDecorat.decorations,
|
|
69
71
|
diffDescriptors = _calculateDiffDecorat.diffDescriptors;
|
|
70
72
|
// Update the decorations and their ids
|
|
71
73
|
newPluginState.decorations = decorations;
|
|
72
|
-
if (
|
|
74
|
+
if (isExtendedEnabled((_newPluginState8 = newPluginState) === null || _newPluginState8 === void 0 ? void 0 : _newPluginState8.diffType)) {
|
|
73
75
|
newPluginState.diffDescriptors = diffDescriptors;
|
|
74
76
|
}
|
|
75
77
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
@@ -77,15 +79,16 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
77
79
|
decorations: DecorationSet.empty,
|
|
78
80
|
isDisplayingChanges: false,
|
|
79
81
|
activeIndex: undefined
|
|
80
|
-
},
|
|
82
|
+
}, isExtendedEnabled(currentPluginState.diffType) ? {
|
|
81
83
|
isInverted: false,
|
|
82
84
|
diffType: 'inline',
|
|
83
85
|
hideDeletedDiffs: false,
|
|
84
86
|
diffDescriptors: []
|
|
85
87
|
} : {});
|
|
86
88
|
} 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') {
|
|
89
|
+
var _newPluginState9;
|
|
87
90
|
// Update the active index in plugin state and recalculate decorations
|
|
88
|
-
var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc);
|
|
91
|
+
var _decorations = getScrollableDecorations(currentPluginState.decorations, newState.doc, (_newPluginState9 = newPluginState) === null || _newPluginState9 === void 0 ? void 0 : _newPluginState9.diffType);
|
|
89
92
|
if (_decorations.length > 0) {
|
|
90
93
|
var _currentPluginState$a;
|
|
91
94
|
// Initialize to -1 if undefined so that the first "next" scroll takes us to index 0 (first change).
|
|
@@ -119,16 +122,18 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
119
122
|
intl: getIntl(),
|
|
120
123
|
activeIndexPos: newPluginState.activeIndexPos,
|
|
121
124
|
api: api
|
|
122
|
-
},
|
|
125
|
+
}, isExtendedEnabled(newPluginState.diffType) ? {
|
|
123
126
|
isInverted: newPluginState.isInverted,
|
|
124
127
|
diffType: newPluginState.diffType,
|
|
125
128
|
hideDeletedDiffs: newPluginState.hideDeletedDiffs,
|
|
126
|
-
showIndicators: newPluginState.showIndicators
|
|
129
|
+
showIndicators: newPluginState.showIndicators,
|
|
130
|
+
smartThresholds: newPluginState.smartThresholds,
|
|
131
|
+
deletedDiffPlacement: newPluginState.deletedDiffPlacement
|
|
127
132
|
} : {})),
|
|
128
133
|
updatedDecorations = _calculateDiffDecorat2.decorations,
|
|
129
134
|
updatedDiffDescriptors = _calculateDiffDecorat2.diffDescriptors;
|
|
130
135
|
newPluginState.decorations = updatedDecorations;
|
|
131
|
-
if (
|
|
136
|
+
if (isExtendedEnabled(newPluginState.diffType)) {
|
|
132
137
|
newPluginState.diffDescriptors = updatedDiffDescriptors;
|
|
133
138
|
}
|
|
134
139
|
}
|
|
@@ -162,7 +167,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
162
167
|
var pluginState = showDiffPluginKey.getState(view.state);
|
|
163
168
|
|
|
164
169
|
// Scroll to the first decoration when scrollIntoView was requested
|
|
165
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView &&
|
|
170
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.scrollIntoView && isExtendedEnabled(pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType)) {
|
|
166
171
|
var _cancelPendingScrollT;
|
|
167
172
|
(_cancelPendingScrollT = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT === void 0 || _cancelPendingScrollT();
|
|
168
173
|
cancelPendingScrollToDecoration = scrollToFirstDecoration(view, pluginState.decorations);
|
|
@@ -179,7 +184,7 @@ export var createPlugin = function createPlugin(config, getIntl, api) {
|
|
|
179
184
|
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.activeIndex) !== undefined && activeIndexChanged) {
|
|
180
185
|
var _cancelPendingScrollT2, _api$expand;
|
|
181
186
|
(_cancelPendingScrollT2 = cancelPendingScrollToDecoration) === null || _cancelPendingScrollT2 === void 0 || _cancelPendingScrollT2();
|
|
182
|
-
var scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc);
|
|
187
|
+
var scrollableDecorations = getScrollableDecorations(pluginState.decorations, view.state.doc, pluginState === null || pluginState === void 0 ? void 0 : pluginState.diffType);
|
|
183
188
|
var activeDecoration = scrollableDecorations[pluginState.activeIndex];
|
|
184
189
|
if (activeDecoration && api !== null && api !== void 0 && (_api$expand = api.expand) !== null && _api$expand !== void 0 && (_api$expand = _api$expand.commands) !== null && _api$expand !== void 0 && _api$expand.toggleExpandRange) {
|
|
185
190
|
api === null || api === void 0 || api.core.actions.execute(api.expand.commands.toggleExpandRange(activeDecoration.from, activeDecoration.to, true));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { DiffParams, PMDiffParams, ShowDiffPlugin } from '../showDiffPluginType';
|
|
1
|
+
export type { DeletedDiffPlacement, DiffParams, DiffType, PMDiffParams, ShowDiffPlugin, SmartDiffThresholds, } from '../showDiffPluginType';
|
|
@@ -3,7 +3,7 @@ import type { IntlShape } from 'react-intl';
|
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { ColorScheme, DiffDescriptor, ShowDiffPlugin } from '../../showDiffPluginType';
|
|
6
|
+
import type { ColorScheme, DeletedDiffPlacement, DiffDescriptor, ShowDiffPlugin, SmartDiffThresholds } from '../../showDiffPluginType';
|
|
7
7
|
import type { ShowDiffPluginState } from '../main';
|
|
8
8
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
9
9
|
type CalculatedDiffs = {
|
|
@@ -17,11 +17,13 @@ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState,
|
|
|
17
17
|
};
|
|
18
18
|
api: ExtractInjectionAPI<ShowDiffPlugin> | undefined;
|
|
19
19
|
colorScheme?: ColorScheme;
|
|
20
|
+
deletedDiffPlacement?: DeletedDiffPlacement;
|
|
20
21
|
hideDeletedDiffs?: boolean;
|
|
21
22
|
intl: IntlShape;
|
|
22
23
|
nodeViewSerializer: NodeViewSerializer;
|
|
23
24
|
pluginState: Omit<ShowDiffPluginState, 'decorations'>;
|
|
24
25
|
showIndicators?: boolean;
|
|
26
|
+
smartThresholds?: Partial<SmartDiffThresholds>;
|
|
25
27
|
state: EditorState;
|
|
26
28
|
}) => CalculatedDiffs>;
|
|
27
29
|
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic, editor-state-free diff-change computation.
|
|
3
|
+
*
|
|
4
|
+
* Turns an `originalDoc` + forward `steps` into the classified `Change[]` for the
|
|
5
|
+
* requested `diffType`, plus the reconstructed new document — the same classifier
|
|
6
|
+
* the diff overlay uses (`calculateDiffDecorations` → `getChanges`), exposed as a
|
|
7
|
+
* reusable utility (e.g. to derive reviewable segments without rendering
|
|
8
|
+
* decorations). It runs the requested `diffType` DIRECTLY and does NOT apply the
|
|
9
|
+
* overlay's `platform_editor_ai_smart_diff` gate, so a `smart` result here can
|
|
10
|
+
* differ from what the overlay draws when that gate is off (the overlay falls back
|
|
11
|
+
* to inline); callers that need overlay parity must account for that gate.
|
|
12
|
+
*
|
|
13
|
+
* Pure: no `EditorState`, no transactions, no React. The new document is
|
|
14
|
+
* reconstructed by applying the (simplified) steps to `originalDoc`.
|
|
15
|
+
*/
|
|
16
|
+
import { type Change } from 'prosemirror-changeset';
|
|
17
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
18
|
+
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
19
|
+
import type { DiffType, SmartDiffThresholds } from '../../showDiffPluginType';
|
|
20
|
+
export type ComputeDiffChangesParams = {
|
|
21
|
+
/**
|
|
22
|
+
* Which classification to run. Defaults to `smart` — the density-aware model.
|
|
23
|
+
* The other types are supported for parity with the diff overlay's
|
|
24
|
+
* `getChanges`.
|
|
25
|
+
*/
|
|
26
|
+
diffType?: DiffType;
|
|
27
|
+
/** BCP-47 locale for `smart` sentence/word segmentation. Defaults to `en`. */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** The pre-edit document (the diff's left/original side). */
|
|
30
|
+
originalDoc: PMNode;
|
|
31
|
+
/** Optional overrides for the `smart` density thresholds. Ignored otherwise. */
|
|
32
|
+
smartThresholds?: Partial<SmartDiffThresholds>;
|
|
33
|
+
/** Forward `original → new` steps (the standard non-inverted contract). */
|
|
34
|
+
steps: ProseMirrorStep[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Apply the (simplified) steps to `originalDoc` to reconstruct the new doc, and
|
|
38
|
+
* compute the classified `Change[]` for the requested `diffType`. Mirrors the
|
|
39
|
+
* body of `calculateDiffDecorations` → `getChanges` so callers stay in lock-step
|
|
40
|
+
* with the rendered diff. Returns an empty change list (and `originalDoc` as the
|
|
41
|
+
* new doc) when there are no steps.
|
|
42
|
+
*/
|
|
43
|
+
export declare const computeDiffChanges: ({ originalDoc, steps, diffType, locale, smartThresholds, }: ComputeDiffChangesParams) => {
|
|
44
|
+
changes: Change[];
|
|
45
|
+
newDoc: PMNode;
|
|
46
|
+
};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { Change } from 'prosemirror-changeset';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the position range (outer bounds) of the top-level block (direct child of doc) that
|
|
5
|
+
* contains the range [from, to]. Shared with the `smart` diff type so its block grouping is
|
|
6
|
+
* identical to the `block` diff type by construction.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTopLevelBlockAt(doc: PMNode, from: number, to: number): {
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* Groups all changes that fall within the same top-level block (direct child of doc)
|
|
5
14
|
* and merges them into a single change spanning the full block in both old and new doc.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { type SmartDiffThresholds } from './thresholds';
|
|
4
|
+
export type ClassifySmartChangesArgs = {
|
|
5
|
+
changes: Change[];
|
|
6
|
+
locale: string;
|
|
7
|
+
newDoc: PMNode;
|
|
8
|
+
originalDoc: PMNode;
|
|
9
|
+
thresholds?: Partial<SmartDiffThresholds>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Block-first `smart` classifier.
|
|
13
|
+
*
|
|
14
|
+
* Groups changes by the top-level block they touch — like the `block` diff type — then
|
|
15
|
+
* classifies WITHIN each block group:
|
|
16
|
+
*
|
|
17
|
+
* 1. structural / node-type change (blockA.type !== blockB.type) → whole block
|
|
18
|
+
* 2. text-bearing block (paragraph/heading) → sentence / paragraph / inline
|
|
19
|
+
* 3. container block (list/table/layout/panel/...) → recurse into children,
|
|
20
|
+
* promoting the whole container when changed-child density ≥ node.ratio (with the
|
|
21
|
+
* rigid-child escalation: cell → row → table, column → section, item → list).
|
|
22
|
+
*
|
|
23
|
+
* Grouping on real top-level block boundaries prevents the "empty structural shell" family
|
|
24
|
+
* of bugs (e.g. bulletList → table rendering empty bullets).
|
|
25
|
+
*/
|
|
26
|
+
export declare const classifySmartChanges: ({ changes, originalDoc, newDoc, locale, thresholds: overrides, }: ClassifySmartChangesArgs) => Change[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
/**
|
|
3
|
+
* The granularity level a `smart` change was promoted to. Stored on span `data` so the
|
|
4
|
+
* decoration pipeline can render each level differently (e.g. node-level deletions shown
|
|
5
|
+
* below the new content). `null` for non-promoted (inline) changes.
|
|
6
|
+
*/
|
|
7
|
+
export type SmartChangeLevel = 'sentence' | 'paragraph' | 'node';
|
|
8
|
+
/** Span `data` payload carried by promoted `smart` changes. */
|
|
9
|
+
export type SmartSpanData = {
|
|
10
|
+
smartLevel: SmartChangeLevel;
|
|
11
|
+
} | null;
|
|
12
|
+
/**
|
|
13
|
+
* Build the `deleted`/`inserted` span arrays a `Change` needs. A length of 0 yields an
|
|
14
|
+
* empty array (no change on that side).
|
|
15
|
+
*/
|
|
16
|
+
export declare const createSpans: (length: number, data?: SmartSpanData) => Change["inserted"];
|
|
17
|
+
/**
|
|
18
|
+
* Build a promoted `Change` spanning `[fromA,toA)` in the original doc and `[fromB,toB)`
|
|
19
|
+
* in the new doc, with both sides marked changed (mirrors `groupChangesByBlock` so the
|
|
20
|
+
* decoration pipeline renders both the inserted-block decoration and the deleted-node
|
|
21
|
+
* widget).
|
|
22
|
+
*
|
|
23
|
+
* `level` tags the change's spans so downstream decoration logic can treat node-level
|
|
24
|
+
* promotions specially (see `smartChangeLevel`).
|
|
25
|
+
*/
|
|
26
|
+
export declare const makePromotedChange: (fromA: number, toA: number, fromB: number, toB: number, level?: SmartChangeLevel) => Change;
|
|
27
|
+
/**
|
|
28
|
+
* Read the `smartLevel` tag off a change's spans, if present. Returns `undefined` for
|
|
29
|
+
* changes not produced by the `smart` classifier (e.g. inline/block/step diff types).
|
|
30
|
+
*/
|
|
31
|
+
export declare const smartChangeLevel: (change: Pick<Change, "inserted" | "deleted">) => SmartChangeLevel | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Coalesce changes that overlap in new-doc (B) coordinates.
|
|
34
|
+
*
|
|
35
|
+
* Merging two changes takes the UNION of their A (original-doc) ranges. That is only safe when
|
|
36
|
+
* their A ranges actually touch/overlap — OR when at least one is a pure insertion (empty A).
|
|
37
|
+
* Otherwise, merging a deletion at A[110,152] with a later edit at A[162,168] would fabricate an
|
|
38
|
+
* A span [110,168] covering the untouched gap, which then overlaps a *different* change's A range
|
|
39
|
+
* (making the same original content appear deleted twice). So we require B-overlap AND
|
|
40
|
+
* (A-overlap OR a pure insertion) before coalescing.
|
|
41
|
+
*/
|
|
42
|
+
export declare const mergeOverlappingByNewDocRange: (changes: Change[]) => Change[];
|
|
43
|
+
/** True when two half-open ranges overlap. */
|
|
44
|
+
export declare const rangesOverlap: (aFrom: number, aTo: number, bFrom: number, bTo: number) => boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* A half-open offset span `[from, to)` measured in *content offsets* relative to the
|
|
4
|
+
* start of a textblock (i.e. the same coordinate space as `buildCharsByOffset`).
|
|
5
|
+
*/
|
|
6
|
+
export type OffsetSpan = {
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Build a per-content-offset view of a textblock's characters.
|
|
12
|
+
*
|
|
13
|
+
* `chars[i]` is the character at content offset `i`, or `null` when that offset lies
|
|
14
|
+
* inside a non-text inline node (mention, date, emoji, hardBreak, …). A `null` acts as an
|
|
15
|
+
* *opaque single token*: it counts as one word and never terminates a sentence.
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildCharsByOffset: (parent: PMNode) => Array<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Segment a textblock char-view into sentence spans (content-offset coordinates).
|
|
20
|
+
* Uses Intl.Segmenter when available, otherwise a conservative regex fallback.
|
|
21
|
+
*/
|
|
22
|
+
export declare const segmentSentences: (chars: Array<string | null>, locale: string) => OffsetSpan[];
|
|
23
|
+
/**
|
|
24
|
+
* Count word-like tokens within a content-offset range of the char-view.
|
|
25
|
+
* Each opaque inline token (`null`) counts as exactly one word.
|
|
26
|
+
*/
|
|
27
|
+
export declare const countWords: (chars: Array<string | null>, span: OffsetSpan, locale: string) => number;
|
|
28
|
+
/**
|
|
29
|
+
* Return the word-token spans (content-offset coordinates) within a range. Used to decide
|
|
30
|
+
* which words a change overlaps. Each opaque inline token is its own span.
|
|
31
|
+
*/
|
|
32
|
+
export declare const segmentWordSpans: (chars: Array<string | null>, span: OffsetSpan, locale: string) => OffsetSpan[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable thresholds for the `smart` diffType.
|
|
3
|
+
*
|
|
4
|
+
* See docs/smart-diff-design.md §3 and §6 for the exact semantics of each level.
|
|
5
|
+
*/
|
|
6
|
+
export type SmartDiffThresholds = {
|
|
7
|
+
/**
|
|
8
|
+
* Node/container level. Unit = direct children.
|
|
9
|
+
* - `ratio`: promote to node-level when
|
|
10
|
+
* `changedChildren / max(childrenOld, childrenNew) >= ratio`.
|
|
11
|
+
* - `textBearingRatio`: alternatively promote when the fraction of text-bearing
|
|
12
|
+
* children (paragraph/heading) that were themselves promoted to paragraph-level
|
|
13
|
+
* is `>= textBearingRatio`.
|
|
14
|
+
*/
|
|
15
|
+
node: {
|
|
16
|
+
ratio: number;
|
|
17
|
+
textBearingRatio: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Paragraph/textblock level. Unit = sentences.
|
|
21
|
+
* Promote when `sentencesChanged >= minChanged` AND
|
|
22
|
+
* `sentencesChanged / max(sentencesOld, sentencesNew) >= ratio`.
|
|
23
|
+
*/
|
|
24
|
+
paragraph: {
|
|
25
|
+
minChanged: number;
|
|
26
|
+
ratio: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Sentence level. Unit = words (inline non-text nodes count as one word).
|
|
30
|
+
* Promote when `wordsChanged >= minChanged` AND
|
|
31
|
+
* `wordsChanged / max(wordsOld, wordsNew) >= ratio`.
|
|
32
|
+
*/
|
|
33
|
+
sentence: {
|
|
34
|
+
minChanged: number;
|
|
35
|
+
ratio: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const DEFAULT_SMART_THRESHOLDS: SmartDiffThresholds;
|
|
39
|
+
/**
|
|
40
|
+
* Merge caller overrides onto the defaults. Overrides are shallow-merged per level so a
|
|
41
|
+
* caller can tune a single field (e.g. only `sentence.ratio`) without re-specifying the
|
|
42
|
+
* rest.
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveThresholds: (overrides?: Partial<SmartDiffThresholds>) => SmartDiffThresholds;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
import type { ColorScheme, DiffType } from '../../showDiffPluginType';
|
|
4
4
|
/**
|
|
5
5
|
* Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
|
|
6
6
|
*
|
|
@@ -9,13 +9,14 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
9
9
|
* @param isActive Whether this node is part of the currently active/focused change
|
|
10
10
|
* @returns Prosemirror node decoration or undefined
|
|
11
11
|
*/
|
|
12
|
-
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, showIndicators, doc, }: {
|
|
12
|
+
export declare const createBlockChangedDecoration: ({ change, colorScheme, isInserted, isActive, shouldHideDeleted, showIndicators, doc, diffType, }: {
|
|
13
13
|
change: {
|
|
14
14
|
from: number;
|
|
15
15
|
name: string;
|
|
16
16
|
to: number;
|
|
17
17
|
};
|
|
18
18
|
colorScheme?: ColorScheme;
|
|
19
|
+
diffType?: DiffType;
|
|
19
20
|
doc?: PMNode;
|
|
20
21
|
isActive?: boolean;
|
|
21
22
|
isInserted?: boolean;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { Change } from 'prosemirror-changeset';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import type { ColorScheme } from '../../showDiffPluginType';
|
|
4
|
+
import type { ColorScheme, DiffType } from '../../showDiffPluginType';
|
|
5
5
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
6
6
|
type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
7
7
|
/**
|
|
8
8
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
9
9
|
*/
|
|
10
|
-
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isInserted, }: {
|
|
10
|
+
export declare const createChangedRowDecorationWidgets: ({ changes, originalDoc, newDoc, nodeViewSerializer, colorScheme, isInserted, diffType, }: {
|
|
11
11
|
changes: SimpleChange[];
|
|
12
12
|
colorScheme?: ColorScheme;
|
|
13
|
+
diffType?: DiffType;
|
|
13
14
|
isInserted?: boolean;
|
|
14
15
|
newDoc: PMNode;
|
|
15
16
|
nodeViewSerializer: NodeViewSerializer;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
|
+
import type { ColorScheme, DiffType } from '../../showDiffPluginType';
|
|
4
4
|
/**
|
|
5
5
|
* Inline decoration used for insertions as the content already exists in the document
|
|
6
6
|
*
|
|
7
7
|
* @param change Changeset "change" containing information about the change content + range
|
|
8
8
|
* @returns Prosemirror inline decoration
|
|
9
9
|
*/
|
|
10
|
-
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, showIndicators, doc, }: {
|
|
10
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, showIndicators, doc, diffType, }: {
|
|
11
11
|
change: {
|
|
12
12
|
fromB: number;
|
|
13
13
|
toB: number;
|
|
14
14
|
};
|
|
15
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
diffType?: DiffType;
|
|
16
17
|
doc?: PMNode;
|
|
17
18
|
isActive?: boolean;
|
|
18
19
|
isInserted?: boolean;
|
|
@@ -2,23 +2,25 @@ import type { Change } from 'prosemirror-changeset';
|
|
|
2
2
|
import type { IntlShape } from 'react-intl';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { ColorScheme } from '../../showDiffPluginType';
|
|
5
|
+
import type { ColorScheme, DiffType } from '../../showDiffPluginType';
|
|
6
6
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
7
7
|
/**
|
|
8
8
|
* This function is used to create a decoration widget to show content
|
|
9
9
|
* that is not in the current document.
|
|
10
10
|
*/
|
|
11
|
-
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, }: {
|
|
11
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, placeBelow, diffType, }: {
|
|
12
12
|
activeIndexPos?: {
|
|
13
13
|
from: number;
|
|
14
14
|
to: number;
|
|
15
15
|
};
|
|
16
16
|
change: Pick<Change, "fromA" | "toA" | "fromB" | "deleted" | "toB">;
|
|
17
17
|
colorScheme?: ColorScheme;
|
|
18
|
+
diffType?: DiffType;
|
|
18
19
|
doc: PMNode;
|
|
19
20
|
intl: IntlShape;
|
|
20
21
|
isInserted?: boolean;
|
|
21
22
|
newDoc: PMNode;
|
|
22
23
|
nodeViewSerializer: NodeViewSerializer;
|
|
24
|
+
placeBelow?: boolean;
|
|
23
25
|
showIndicators?: boolean;
|
|
24
26
|
}) => Decoration[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { DiffDescriptor } from '../../showDiffPluginType';
|
|
2
|
+
import type { DiffDescriptor, DiffType } from '../../showDiffPluginType';
|
|
3
3
|
/**
|
|
4
4
|
* Decoration families produced by the show-diff plugin.
|
|
5
5
|
* Each family owns its own key space and spec shape.
|
|
@@ -53,14 +53,16 @@ export declare const buildAnchorDecorationKey: ({ diffId, anchorType, }: {
|
|
|
53
53
|
* in the key so independently rendered decorations for the same type remain
|
|
54
54
|
* distinguishable.
|
|
55
55
|
*/
|
|
56
|
-
export declare const buildDiffDecorationKey: ({ decorationKeyPrefix, isActive, diffId, }: {
|
|
56
|
+
export declare const buildDiffDecorationKey: ({ decorationKeyPrefix, isActive, diffId, diffType, }: {
|
|
57
57
|
decorationKeyPrefix: (typeof DiffDecorationKey)[DiffDescriptor["type"]];
|
|
58
58
|
diffId?: string;
|
|
59
|
+
diffType?: DiffType;
|
|
59
60
|
isActive?: boolean;
|
|
60
61
|
}) => string;
|
|
61
|
-
export declare const buildDiffDecorationSpec: ({ decorationType, diffId, isActive, nodeName, side, }: {
|
|
62
|
+
export declare const buildDiffDecorationSpec: ({ decorationType, diffId, isActive, nodeName, side, diffType, }: {
|
|
62
63
|
decorationType: DiffDescriptor["type"];
|
|
63
64
|
diffId: string;
|
|
65
|
+
diffType?: DiffType;
|
|
64
66
|
isActive?: boolean;
|
|
65
67
|
nodeName?: string;
|
|
66
68
|
side?: number;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { ColorScheme } from '../../../showDiffPluginType';
|
|
3
|
+
import type { ColorScheme, DiffType } from '../../../showDiffPluginType';
|
|
4
4
|
/**
|
|
5
5
|
* Handles all block node rendering with appropriate deleted styling.
|
|
6
6
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
7
7
|
* For other block nodes, uses wrapper approach with optional lozenge.
|
|
8
8
|
*/
|
|
9
|
-
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, }: {
|
|
9
|
+
export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorScheme, intl, isActive, isInserted, diffType, }: {
|
|
10
10
|
colorScheme?: ColorScheme;
|
|
11
|
+
diffType?: DiffType;
|
|
11
12
|
dom: HTMLElement;
|
|
12
13
|
intl: IntlShape;
|
|
13
14
|
isActive?: boolean;
|
|
@@ -20,8 +21,9 @@ export declare const wrapBlockNodeView: ({ dom, nodeView, targetNode, colorSchem
|
|
|
20
21
|
* CSS backgrounds don't work when applied to a wrapper around a paragraph, so
|
|
21
22
|
* the wrapper needs to be injected inside the node around the child content.
|
|
22
23
|
*/
|
|
23
|
-
export declare const injectInnerWrapper: ({ node, colorScheme, isActive, isInserted, }: {
|
|
24
|
+
export declare const injectInnerWrapper: ({ node, colorScheme, isActive, isInserted, diffType, }: {
|
|
24
25
|
colorScheme?: ColorScheme;
|
|
26
|
+
diffType?: DiffType;
|
|
25
27
|
isActive?: boolean;
|
|
26
28
|
isInserted?: boolean;
|
|
27
29
|
node: HTMLElement;
|
|
@@ -29,4 +31,4 @@ export declare const injectInnerWrapper: ({ node, colorScheme, isActive, isInser
|
|
|
29
31
|
/**
|
|
30
32
|
* Creates a styled span wrapper for inline content within a change decoration.
|
|
31
33
|
*/
|
|
32
|
-
export declare const createContentWrapper: (colorScheme?: ColorScheme, isActive?: boolean, isInserted?: boolean) => HTMLElement;
|
|
34
|
+
export declare const createContentWrapper: (colorScheme?: ColorScheme, isActive?: boolean, isInserted?: boolean, diffType?: DiffType) => HTMLElement;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { DiffType } from '../showDiffPluginType';
|
|
3
4
|
/**
|
|
4
5
|
* Returns true when an inline decoration's [from, to) range can actually show in the document:
|
|
5
6
|
* positions are valid, and the slice contains at least one inline node ProseMirror would paint
|
|
@@ -24,4 +25,4 @@ export declare function isInlineDiffDecorationRenderableInDoc(doc: PMNode, from:
|
|
|
24
25
|
* @param doc - Current document; when set, diff-inline ranges are validated against this doc
|
|
25
26
|
* @returns Array of scrollable decorations, sorted and deduplicated
|
|
26
27
|
*/
|
|
27
|
-
export declare const getScrollableDecorations: (set: DecorationSet | undefined, doc?: PMNode) => Decoration[];
|
|
28
|
+
export declare const getScrollableDecorations: (set: DecorationSet | undefined, doc?: PMNode, diffType?: DiffType) => Decoration[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DiffType } from '../showDiffPluginType';
|
|
2
|
+
/**
|
|
3
|
+
* The "extended" diff pipeline is normally gated by `platform_editor_diff_plugin_extended`.
|
|
4
|
+
* The `smart` diff type REQUIRES the extended pipeline, so whenever `smart` is active (and its
|
|
5
|
+
* own gate `platform_editor_ai_smart_diff` is on) the extended pipeline is force-enabled,
|
|
6
|
+
* independent of the extended gate. For all other diff types the extended gate alone decides.
|
|
7
|
+
*
|
|
8
|
+
* Pass the active `diffType` so callers deep in the decoration layer render the extended shape
|
|
9
|
+
* when `smart` is active even if `platform_editor_diff_plugin_extended` is off.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isExtendedEnabled: (diffType?: DiffType) => boolean;
|
|
@@ -5,7 +5,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
7
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import type { DiffDescriptor, DiffParams, DiffType, ShowDiffPlugin } from '../showDiffPluginType';
|
|
8
|
+
import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffType, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
|
|
9
9
|
export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
|
|
10
10
|
export type ShowDiffPluginState = {
|
|
11
11
|
activeIndex?: number;
|
|
@@ -14,6 +14,11 @@ export type ShowDiffPluginState = {
|
|
|
14
14
|
to: number;
|
|
15
15
|
};
|
|
16
16
|
decorations: DecorationSet;
|
|
17
|
+
/**
|
|
18
|
+
* For the `smart` diffType, where node/paragraph-level deleted content is rendered relative to
|
|
19
|
+
* the new content. Set via SHOW_DIFF meta. Defaults to `'top'`.
|
|
20
|
+
*/
|
|
21
|
+
deletedDiffPlacement?: DeletedDiffPlacement;
|
|
17
22
|
/**
|
|
18
23
|
* The diff descriptors of the diff decorations currently being displayed.
|
|
19
24
|
* Only set when `platform_editor_diff_plugin_extended` is on.
|
|
@@ -30,6 +35,11 @@ export type ShowDiffPluginState = {
|
|
|
30
35
|
*/
|
|
31
36
|
scrollIntoView?: boolean;
|
|
32
37
|
showIndicators?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional overrides for the `smart` diffType density thresholds. Set via SHOW_DIFF
|
|
40
|
+
* meta. Only relevant when `diffType === 'smart'`.
|
|
41
|
+
*/
|
|
42
|
+
smartThresholds?: Partial<SmartDiffThresholds>;
|
|
33
43
|
steps: ProseMirrorStep[];
|
|
34
44
|
};
|
|
35
45
|
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
|
|
@@ -6,8 +6,17 @@ import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
|
|
|
6
6
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
7
7
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
9
|
+
import type { SmartDiffThresholds as SmartDiffThresholdsInternal } from './pm-plugins/calculateDiff/smart/thresholds';
|
|
9
10
|
export type ColorScheme = 'standard' | 'traditional';
|
|
10
|
-
export type DiffType = 'inline' | 'block' | 'step';
|
|
11
|
+
export type DiffType = 'inline' | 'block' | 'step' | 'smart';
|
|
12
|
+
/**
|
|
13
|
+
* Where node/paragraph-level deleted content is rendered relative to the new (replacement)
|
|
14
|
+
* content in the `smart` diffType:
|
|
15
|
+
* - `'top'` (default): the deleted content is anchored above the new content.
|
|
16
|
+
* - `'bottom'`: the deleted content is anchored below the new content.
|
|
17
|
+
*/
|
|
18
|
+
export type DeletedDiffPlacement = 'top' | 'bottom';
|
|
19
|
+
export type SmartDiffThresholds = SmartDiffThresholdsInternal;
|
|
11
20
|
export type DiffDescriptor = {
|
|
12
21
|
id: string;
|
|
13
22
|
type: 'inline' | 'block' | 'widget';
|
|
@@ -26,10 +35,20 @@ export type DiffParams = {
|
|
|
26
35
|
steps: StepJson[];
|
|
27
36
|
};
|
|
28
37
|
export type PMDiffParams = {
|
|
38
|
+
/**
|
|
39
|
+
* For the `smart` diffType, where node/paragraph-level deleted content is rendered relative to
|
|
40
|
+
* the new content. Defaults to `'top'`. Ignored for other diff types.
|
|
41
|
+
*/
|
|
42
|
+
deletedDiffPlacement?: DeletedDiffPlacement;
|
|
29
43
|
diffType?: DiffType;
|
|
30
44
|
hideDeletedDiffs?: boolean;
|
|
31
45
|
isInverted?: boolean;
|
|
32
46
|
originalDoc: Node;
|
|
47
|
+
/**
|
|
48
|
+
* Optional overrides for the `smart` diffType density thresholds. Ignored for other
|
|
49
|
+
* diff types. Partial — omitted fields fall back to defaults.
|
|
50
|
+
*/
|
|
51
|
+
smartThresholds?: Partial<SmartDiffThresholds>;
|
|
33
52
|
/**
|
|
34
53
|
* When true, the editor will scroll to bring the first diff decoration into view
|
|
35
54
|
* after the diff is shown.
|