@atlaskit/editor-plugin-show-diff 14.0.4 → 14.1.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 +9 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +172 -97
- 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/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 +90 -19
- 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/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 +173 -98
- 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/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/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 +3 -3
|
@@ -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,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.0
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.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": {
|