@atlaskit/editor-plugin-show-diff 14.0.4 → 14.1.1
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 +18 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +215 -103
- package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +20 -9
- package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +89 -0
- package/dist/cjs/pm-plugins/calculateDiff/simplifySteps.js +81 -4
- package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +68 -0
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +26 -2
- package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +5 -1
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +7 -2
- package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +2 -2
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
- package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +59 -30
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -10
- package/dist/cjs/pm-plugins/main.js +1 -0
- package/dist/cjs/showDiffPlugin.js +36 -14
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +130 -22
- package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +17 -9
- package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +64 -0
- package/dist/es2019/pm-plugins/calculateDiff/simplifySteps.js +64 -1
- package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +37 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +19 -2
- package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +1 -0
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +6 -3
- package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -3
- package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +55 -30
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +12 -9
- package/dist/es2019/pm-plugins/main.js +1 -0
- package/dist/es2019/showDiffPlugin.js +23 -1
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +216 -104
- package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +20 -9
- package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +82 -0
- package/dist/esm/pm-plugins/calculateDiff/simplifySteps.js +79 -5
- package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +61 -0
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +24 -1
- package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +1 -0
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +8 -3
- package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
- package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +59 -30
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -9
- package/dist/esm/pm-plugins/main.js +1 -0
- package/dist/esm/showDiffPlugin.js +36 -14
- package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
- package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +2 -1
- package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +7 -0
- package/dist/types/pm-plugins/calculateDiff/simplifySteps.d.ts +10 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +12 -0
- package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +5 -3
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +6 -1
- package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/getAttrChangeRanges.d.ts +12 -2
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +3 -1
- package/dist/types/showDiffPluginType.d.ts +29 -1
- package/package.json +10 -7
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
var _excluded = ["stepsWithAttribution"];
|
|
2
4
|
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; }
|
|
3
5
|
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
6
|
import React from 'react';
|
|
@@ -7,9 +9,28 @@ import { getDeletedWidgets as _getDeletedWidgets } from './pm-plugins/getDeleted
|
|
|
7
9
|
import { getScrollableDecorations } from './pm-plugins/getScrollableDecorations';
|
|
8
10
|
import { createPlugin, showDiffPluginKey } from './pm-plugins/main';
|
|
9
11
|
import { IndicatorBarContentComponent } from './ui/IndicatorBar/IndicatorBarContentComponent';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
var normalizeShowDiffParams = function normalizeShowDiffParams(params) {
|
|
13
|
+
if (!params || !('stepsWithAttribution' in params)) {
|
|
14
|
+
return params ? _objectSpread(_objectSpread({}, params), {}, {
|
|
15
|
+
stepAttributions: []
|
|
16
|
+
}) : params;
|
|
17
|
+
}
|
|
18
|
+
var stepsWithAttribution = params.stepsWithAttribution,
|
|
19
|
+
rest = _objectWithoutProperties(params, _excluded);
|
|
20
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
21
|
+
steps: stepsWithAttribution.map(function (_ref) {
|
|
22
|
+
var step = _ref.step;
|
|
23
|
+
return step;
|
|
24
|
+
}),
|
|
25
|
+
stepAttributions: stepsWithAttribution.map(function (_ref2) {
|
|
26
|
+
var stepAttribution = _ref2.stepAttribution;
|
|
27
|
+
return stepAttribution;
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export var showDiffPlugin = function showDiffPlugin(_ref3) {
|
|
32
|
+
var api = _ref3.api,
|
|
33
|
+
config = _ref3.config;
|
|
13
34
|
// Captured from the plugin's view lifecycle (see `createPlugin`) so read-only actions can access
|
|
14
35
|
// the current state without exposing the plugin key to consumers.
|
|
15
36
|
var editorView;
|
|
@@ -25,21 +46,21 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
25
46
|
},
|
|
26
47
|
commands: {
|
|
27
48
|
showDiff: function showDiff(params) {
|
|
28
|
-
return function (
|
|
29
|
-
var tr =
|
|
49
|
+
return function (_ref4) {
|
|
50
|
+
var tr = _ref4.tr;
|
|
30
51
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
31
52
|
var _api$userIntent;
|
|
32
53
|
api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('viewingDiff')({
|
|
33
54
|
tr: tr
|
|
34
55
|
});
|
|
35
56
|
}
|
|
36
|
-
return tr.setMeta(showDiffPluginKey, _objectSpread(_objectSpread({}, params), {}, {
|
|
57
|
+
return tr.setMeta(showDiffPluginKey, _objectSpread(_objectSpread({}, normalizeShowDiffParams(params)), {}, {
|
|
37
58
|
action: 'SHOW_DIFF'
|
|
38
59
|
}));
|
|
39
60
|
};
|
|
40
61
|
},
|
|
41
|
-
hideDiff: function hideDiff(
|
|
42
|
-
var tr =
|
|
62
|
+
hideDiff: function hideDiff(_ref5) {
|
|
63
|
+
var tr = _ref5.tr;
|
|
43
64
|
if (expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true)) {
|
|
44
65
|
var _api$userIntent2;
|
|
45
66
|
api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || _api$userIntent2.commands.setCurrentUserIntent('default')({
|
|
@@ -48,17 +69,18 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
48
69
|
}
|
|
49
70
|
return tr.setMeta(showDiffPluginKey, {
|
|
50
71
|
steps: [],
|
|
72
|
+
stepAttributions: [],
|
|
51
73
|
action: 'HIDE_DIFF'
|
|
52
74
|
});
|
|
53
75
|
},
|
|
54
|
-
scrollToNext: function scrollToNext(
|
|
55
|
-
var tr =
|
|
76
|
+
scrollToNext: function scrollToNext(_ref6) {
|
|
77
|
+
var tr = _ref6.tr;
|
|
56
78
|
return tr.setMeta(showDiffPluginKey, {
|
|
57
79
|
action: 'SCROLL_TO_NEXT'
|
|
58
80
|
});
|
|
59
81
|
},
|
|
60
|
-
scrollToPrevious: function scrollToPrevious(
|
|
61
|
-
var tr =
|
|
82
|
+
scrollToPrevious: function scrollToPrevious(_ref7) {
|
|
83
|
+
var tr = _ref7.tr;
|
|
62
84
|
return tr.setMeta(showDiffPluginKey, {
|
|
63
85
|
action: 'SCROLL_TO_PREVIOUS'
|
|
64
86
|
});
|
|
@@ -67,8 +89,8 @@ export var showDiffPlugin = function showDiffPlugin(_ref) {
|
|
|
67
89
|
pmPlugins: function pmPlugins() {
|
|
68
90
|
return [{
|
|
69
91
|
name: 'showDiffPlugin',
|
|
70
|
-
plugin: function plugin(
|
|
71
|
-
var getIntl =
|
|
92
|
+
plugin: function plugin(_ref8) {
|
|
93
|
+
var getIntl = _ref8.getIntl;
|
|
72
94
|
return createPlugin(config, getIntl, api, setEditorView);
|
|
73
95
|
}
|
|
74
96
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { DeletedDiffPlacement, DeletedDiffWidget, DiffParams, DiffType, PMDiffParams, ShowDiffPlugin, SmartDiffThresholds, } from '../showDiffPluginType';
|
|
1
|
+
export type { DeletedDiffPlacement, DeletedDiffWidget, DiffParams, DiffStepAttribution, DiffType, PMDiffParams, ShowDiffPlugin, SmartDiffThresholds, StepWithAttribution, } from '../showDiffPluginType';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Change } from 'prosemirror-changeset';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Step } from '@atlaskit/editor-prosemirror/transform-override';
|
|
4
|
-
|
|
4
|
+
import type { DiffStepAttribution } from '../../showDiffPluginType';
|
|
5
|
+
export declare const diffBySteps: (originalDoc: PMNode, steps: Step[], stepAttributions?: Array<DiffStepAttribution | undefined>) => Change[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Simplifies and optimizes consecutive changes without crossing an attribution boundary.
|
|
5
|
+
* A change which already contains more than one identity is deliberately kept isolated.
|
|
6
|
+
*/
|
|
7
|
+
export declare const simplifyChangesWithAttribution: (changes: readonly Change[], doc: PMNode) => Change[];
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
|
|
3
|
+
import type { DiffStepAttribution, StepWithAttribution } from '../../showDiffPluginType';
|
|
4
|
+
type ProseMirrorStepWithAttribution = StepWithAttribution<ProseMirrorStep>;
|
|
3
5
|
export declare function simplifySteps(steps: ProseMirrorStep[], originalDoc: PMNode): ProseMirrorStep[];
|
|
6
|
+
/**
|
|
7
|
+
* Attribution-preserving variant of `simplifySteps`.
|
|
8
|
+
*
|
|
9
|
+
* Steps may only merge when they have the same effective actor identity. Keeping the attribution
|
|
10
|
+
* coupled to the step also ensures filtering a no-op/analytics step cannot shift array indexes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function simplifyStepsWithAttribution(steps: ProseMirrorStep[], stepAttributions: Array<DiffStepAttribution | undefined>, originalDoc: PMNode): ProseMirrorStepWithAttribution[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Change } from 'prosemirror-changeset';
|
|
2
|
+
import type { ColorScheme as PublicColorScheme, DiffStepAttribution } from '../../../showDiffPluginType';
|
|
3
|
+
import type { ColorScheme, DiffAccentColor } from './types';
|
|
4
|
+
export type DiffAttributionSpanData = DiffStepAttribution & {
|
|
5
|
+
stepIndex: number;
|
|
6
|
+
};
|
|
7
|
+
/** `userId` is primary; `agentId`, or `agentType` as its fallback, separates shared users. */
|
|
8
|
+
export declare const getAttributionKey: (attribution: DiffStepAttribution | undefined) => string | undefined;
|
|
9
|
+
export declare const areAttributionColorGatesEnabled: () => boolean;
|
|
10
|
+
export declare const isAttributionColoringEnabled: (stepAttributions: Array<DiffStepAttribution | undefined> | undefined) => boolean;
|
|
11
|
+
export declare const createAttributionColorMap: (stepAttributions: Array<DiffStepAttribution | undefined>) => Map<string, DiffAccentColor>;
|
|
12
|
+
export declare const getColorSchemeForChange: (change: Change, attributedChanges: Change[], attributionColors: Map<string, DiffAccentColor>, fallback: PublicColorScheme | undefined) => ColorScheme | undefined;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { ColorScheme } from '../../../showDiffPluginType';
|
|
2
|
-
import type { DiffColorScheme } from './types';
|
|
1
|
+
import type { ColorScheme as PublicColorScheme } from '../../../showDiffPluginType';
|
|
2
|
+
import type { ColorScheme, DiffColorScheme } from './types';
|
|
3
3
|
/** Green insertions, red deletions. */
|
|
4
4
|
export declare const traditionalScheme: DiffColorScheme;
|
|
5
5
|
/** Purple insertions, gray deletions (red on active). */
|
|
6
6
|
export declare const standardScheme: DiffColorScheme;
|
|
7
|
-
/** Maps
|
|
7
|
+
/** Maps public schemes and attribution-only accents to their data objects. */
|
|
8
8
|
export declare const colorSchemeRegistry: Record<ColorScheme, DiffColorScheme>;
|
|
9
|
+
/** Attribution accents are impossible in the refactor-off cohort; fall back defensively. */
|
|
10
|
+
export declare const getLegacyColorScheme: (colorScheme: ColorScheme | undefined) => PublicColorScheme | undefined;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { ColorScheme as PublicColorScheme } from '../../../showDiffPluginType';
|
|
2
|
+
/** Attribution-only accents selected by the plugin, never by consumers. */
|
|
3
|
+
export type DiffAccentColor = 'blue' | 'green' | 'magenta' | 'orange' | 'purple' | 'teal';
|
|
4
|
+
/** A public scheme or an attribution accent resolved internally for one change. */
|
|
5
|
+
export type ColorScheme = PublicColorScheme | DiffAccentColor;
|
|
1
6
|
/**
|
|
2
7
|
* ADS accent colours for which every token path used by `factory.ts` exists. Closed set, so
|
|
3
8
|
* interpolating a colour name into a token path is compile-time safe.
|
|
4
9
|
*/
|
|
5
|
-
export type AdsAccentColor =
|
|
10
|
+
export type AdsAccentColor = DiffAccentColor | 'red' | 'yellow' | 'gray';
|
|
6
11
|
/**
|
|
7
12
|
* A show-diff colour scheme. Colour fields are accent names that `factory.ts` expands into token
|
|
8
13
|
* paths; the rest encode structural differences no colour can express. Ring widths, padding,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DiffType } from '../../showDiffPluginType';
|
|
4
|
+
import type { ColorScheme } from './colorSchemes/types';
|
|
4
5
|
/**
|
|
5
6
|
* Node decoration used for block-level insertions. When isActive, uses emphasised (pressed) styling.
|
|
6
7
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
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 {
|
|
4
|
+
import type { DiffType } from '../../showDiffPluginType';
|
|
5
5
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
6
|
+
import type { ColorScheme } from './colorSchemes/types';
|
|
6
7
|
type SimpleChange = Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted'>;
|
|
7
8
|
/**
|
|
8
9
|
* Main function to handle deleted rows - computes diff and creates decorations
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DiffType } from '../../showDiffPluginType';
|
|
4
|
+
import type { ColorScheme } from './colorSchemes/types';
|
|
4
5
|
import type { InlineAttrChangeNodeName } from './utils/getAttrChangeRanges';
|
|
5
6
|
/**
|
|
6
7
|
* Inline decoration used for insertions as the content already exists in the document
|
|
@@ -2,8 +2,9 @@ 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 {
|
|
5
|
+
import type { DiffType } from '../../showDiffPluginType';
|
|
6
6
|
import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
7
|
+
import type { ColorScheme } from './colorSchemes/types';
|
|
7
8
|
/**
|
|
8
9
|
* This function is used to create a decoration widget to show content
|
|
9
10
|
* that is not in the current document.
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
1
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
|
|
4
|
+
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
5
|
export type InlineAttrChangeNodeName = 'date' | 'emoji' | 'mention' | 'status';
|
|
6
|
+
type AttrChangeStep = AttrStep | SetAttrsStep;
|
|
7
|
+
export type AttrStepContext = {
|
|
8
|
+
afterNode: PMNode | null;
|
|
9
|
+
beforeNode: PMNode | null;
|
|
10
|
+
finalPos: number;
|
|
11
|
+
originalPos?: number;
|
|
12
|
+
step: AttrChangeStep;
|
|
13
|
+
};
|
|
4
14
|
type StepRange = {
|
|
5
15
|
/**
|
|
6
16
|
* Position of the original (before) node in the original doc.
|
|
@@ -16,7 +26,7 @@ type StepRange = {
|
|
|
16
26
|
toA?: number;
|
|
17
27
|
toB: number;
|
|
18
28
|
};
|
|
19
|
-
export declare const getAttrChangeRanges: (doc: PMNode,
|
|
29
|
+
export declare const getAttrChangeRanges: (doc: PMNode, attrStepContexts: AttrStepContext[], originalDoc: PMNode) => StepRange[];
|
|
20
30
|
/**
|
|
21
31
|
* Check if the step was a valid attr change and affected the doc
|
|
22
32
|
*
|
|
@@ -25,5 +35,5 @@ export declare const getAttrChangeRanges: (doc: PMNode, steps: ProseMirrorStep[]
|
|
|
25
35
|
* @param afterDoc Doc after the step
|
|
26
36
|
* @returns Boolean if the change should show a decoration
|
|
27
37
|
*/
|
|
28
|
-
export declare const stepIsValidAttrChange: (step: ProseMirrorStep, beforeDoc: PMNode, afterDoc: PMNode) =>
|
|
38
|
+
export declare const stepIsValidAttrChange: (step: ProseMirrorStep, beforeDoc: PMNode, afterDoc: PMNode) => step is AttrChangeStep;
|
|
29
39
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DiffType } from '../../../showDiffPluginType';
|
|
4
|
+
import type { ColorScheme } from '../colorSchemes/types';
|
|
4
5
|
/**
|
|
5
6
|
* Handles all block node rendering with appropriate deleted styling.
|
|
6
7
|
* For heading nodes, applies styles directly to preserve natural margins.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DiffType } from '../../../showDiffPluginType';
|
|
2
|
+
import type { ColorScheme } from '../colorSchemes/types';
|
|
2
3
|
/**
|
|
3
4
|
* Node-name classification shared by the style resolvers below and by the routing in
|
|
4
5
|
* `wrapBlockNodeView.ts`.
|
|
@@ -6,7 +6,7 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
6
6
|
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
|
|
9
|
+
import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
|
|
10
10
|
export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
|
|
11
11
|
export type ShowDiffPluginState = {
|
|
12
12
|
activeIndex?: number;
|
|
@@ -48,6 +48,8 @@ export type ShowDiffPluginState = {
|
|
|
48
48
|
* meta. Only relevant when `diffType === 'smart'`.
|
|
49
49
|
*/
|
|
50
50
|
smartThresholds?: Partial<SmartDiffThresholds>;
|
|
51
|
+
/** Internal attribution derived from the public attributed-step input. */
|
|
52
|
+
stepAttributions?: Array<DiffStepAttribution | undefined>;
|
|
51
53
|
steps: ProseMirrorStep[];
|
|
52
54
|
};
|
|
53
55
|
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;
|
|
@@ -8,6 +8,24 @@ import type { Step } from '@atlaskit/editor-prosemirror/transform-override';
|
|
|
8
8
|
import type { SmartDiffThresholds as SmartDiffThresholdsInternal } from './pm-plugins/calculateDiff/smart/thresholds';
|
|
9
9
|
export type ColorScheme = 'standard' | 'traditional';
|
|
10
10
|
export type DiffType = 'inline' | 'block' | 'step' | 'smart';
|
|
11
|
+
/**
|
|
12
|
+
* Attribution for a ProseMirror step.
|
|
13
|
+
*
|
|
14
|
+
* `userId` is the primary actor identity. `agentId` distinguishes multiple agents (or an agent
|
|
15
|
+
* from its user) when they share that user ID, with `agentType` used as a fallback when `agentId`
|
|
16
|
+
* is empty. `wasOffline` preserves additional provenance without affecting identity.
|
|
17
|
+
*/
|
|
18
|
+
export type DiffStepAttribution = {
|
|
19
|
+
agentId?: string;
|
|
20
|
+
agentType?: string;
|
|
21
|
+
userId?: string;
|
|
22
|
+
wasOffline?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** Keeps a step and its attribution coupled through mapping and filtering. */
|
|
25
|
+
export type StepWithAttribution<TStep> = {
|
|
26
|
+
step: TStep;
|
|
27
|
+
stepAttribution?: DiffStepAttribution;
|
|
28
|
+
};
|
|
11
29
|
/**
|
|
12
30
|
* Where node/paragraph-level deleted content is rendered relative to the new (replacement)
|
|
13
31
|
* content in the `smart` diffType:
|
|
@@ -95,6 +113,15 @@ export type PMDiffParams = {
|
|
|
95
113
|
*/
|
|
96
114
|
steps: Step[];
|
|
97
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* Attributed alternative to `PMDiffParams`. When agent colouring is enabled, changes are grouped
|
|
118
|
+
* by `userId`, with `agentId` used as a tie-breaker.
|
|
119
|
+
*/
|
|
120
|
+
type PMDiffParamsWithAttribution = Omit<PMDiffParams, 'steps'> & {
|
|
121
|
+
steps?: never;
|
|
122
|
+
stepsWithAttribution: Array<StepWithAttribution<Step>>;
|
|
123
|
+
};
|
|
124
|
+
export type ShowDiffParams = PMDiffParams | PMDiffParamsWithAttribution;
|
|
98
125
|
export type ACTION = 'SHOW_DIFF' | 'HIDE_DIFF' | 'SCROLL_TO_NEXT' | 'SCROLL_TO_PREVIOUS';
|
|
99
126
|
export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
100
127
|
actions: {
|
|
@@ -113,7 +140,7 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
113
140
|
hideDiff: EditorCommand;
|
|
114
141
|
scrollToNext: EditorCommand;
|
|
115
142
|
scrollToPrevious: EditorCommand;
|
|
116
|
-
showDiff: (config:
|
|
143
|
+
showDiff: (config: ShowDiffParams) => EditorCommand;
|
|
117
144
|
};
|
|
118
145
|
dependencies: [OptionalPlugin<AnalyticsPlugin>, OptionalPlugin<UserIntentPlugin>];
|
|
119
146
|
pluginConfiguration: DiffParams | undefined;
|
|
@@ -142,3 +169,4 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
142
169
|
showIndicators?: boolean;
|
|
143
170
|
};
|
|
144
171
|
}>;
|
|
172
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.1",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/adf-schema": "^57.
|
|
23
|
+
"@atlaskit/adf-schema": "^57.2.0",
|
|
24
24
|
"@atlaskit/custom-steps": "^1.0.0",
|
|
25
25
|
"@atlaskit/editor-plugin-analytics": "^16.0.0",
|
|
26
26
|
"@atlaskit/editor-plugin-user-intent": "^14.0.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
29
29
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^163.0.0",
|
|
32
32
|
"@atlaskit/tokens": "^16.8.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@compiled/react": "^1.0.2",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@atlaskit/adf-utils": "^20.7.0",
|
|
41
41
|
"@atlaskit/button": "^25.2.0",
|
|
42
|
-
"@atlaskit/css": "^1.
|
|
42
|
+
"@atlaskit/css": "^1.1.0",
|
|
43
43
|
"@atlaskit/dropdown-menu": "^18.2.0",
|
|
44
|
-
"@atlaskit/editor-core": "^226.
|
|
44
|
+
"@atlaskit/editor-core": "^226.1.0",
|
|
45
45
|
"@atlaskit/editor-json-transformer": "^9.6.0",
|
|
46
46
|
"@atlaskit/editor-plugins": "^16.1.0",
|
|
47
47
|
"@atlaskit/form": "^17.1.0",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"@atlassian/confluence-presets": "workspace:^",
|
|
54
54
|
"@atlassian/content-reconciliation": "^0.1.3506",
|
|
55
55
|
"@atlassian/editor-ai-injected-editors": "^30.0.0",
|
|
56
|
-
"@atlassian/editor-plugin-ai": "^70.
|
|
56
|
+
"@atlassian/editor-plugin-ai": "^70.1.0",
|
|
57
57
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
58
58
|
"react": "^19.2.0",
|
|
59
59
|
"react-intl": "^7.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@atlaskit/editor-common": "^120.
|
|
62
|
+
"@atlaskit/editor-common": "^120.3.0",
|
|
63
63
|
"react": "^18.2.0 || ^19.2.0"
|
|
64
64
|
},
|
|
65
65
|
"techstack": {
|
|
@@ -104,6 +104,9 @@
|
|
|
104
104
|
},
|
|
105
105
|
"confluence_ncs_step_diffing_version_history": {
|
|
106
106
|
"type": "boolean"
|
|
107
|
+
},
|
|
108
|
+
"platform_editor_reduce_diff_attr_sensitivity": {
|
|
109
|
+
"type": "boolean"
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
}
|