@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +172 -97
  3. package/dist/cjs/pm-plugins/calculateDiff/diffBySteps.js +20 -9
  4. package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +89 -0
  5. package/dist/cjs/pm-plugins/calculateDiff/simplifySteps.js +81 -4
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +68 -0
  7. package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +26 -2
  8. package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +5 -1
  9. package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +7 -2
  10. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +2 -2
  11. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -2
  12. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -10
  13. package/dist/cjs/pm-plugins/main.js +1 -0
  14. package/dist/cjs/showDiffPlugin.js +36 -14
  15. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +90 -19
  16. package/dist/es2019/pm-plugins/calculateDiff/diffBySteps.js +17 -9
  17. package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +64 -0
  18. package/dist/es2019/pm-plugins/calculateDiff/simplifySteps.js +64 -1
  19. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +37 -0
  20. package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +19 -2
  21. package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +1 -0
  22. package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +6 -3
  23. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
  24. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +6 -3
  25. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +12 -9
  26. package/dist/es2019/pm-plugins/main.js +1 -0
  27. package/dist/es2019/showDiffPlugin.js +23 -1
  28. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +173 -98
  29. package/dist/esm/pm-plugins/calculateDiff/diffBySteps.js +20 -9
  30. package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +82 -0
  31. package/dist/esm/pm-plugins/calculateDiff/simplifySteps.js +79 -5
  32. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +61 -0
  33. package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +24 -1
  34. package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +1 -0
  35. package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +8 -3
  36. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +3 -3
  37. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +5 -3
  38. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +14 -9
  39. package/dist/esm/pm-plugins/main.js +1 -0
  40. package/dist/esm/showDiffPlugin.js +36 -14
  41. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  42. package/dist/types/pm-plugins/calculateDiff/diffBySteps.d.ts +2 -1
  43. package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +7 -0
  44. package/dist/types/pm-plugins/calculateDiff/simplifySteps.d.ts +10 -0
  45. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +12 -0
  46. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +5 -3
  47. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +6 -1
  48. package/dist/types/pm-plugins/decorations/createBlockChangedDecoration.d.ts +2 -1
  49. package/dist/types/pm-plugins/decorations/createChangedRowDecorationWidgets.d.ts +2 -1
  50. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +2 -1
  51. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
  52. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeView.d.ts +2 -1
  53. package/dist/types/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.d.ts +2 -1
  54. package/dist/types/pm-plugins/main.d.ts +3 -1
  55. package/dist/types/showDiffPluginType.d.ts +29 -1
  56. 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 { ColorScheme, DiffType } from '../../showDiffPluginType';
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 { ColorScheme, DiffType } from '../../../showDiffPluginType';
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 { ColorScheme, DiffType } from '../../../showDiffPluginType';
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: PMDiffParams) => EditorCommand;
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.4",
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.0.0",
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.2.0",
62
+ "@atlaskit/editor-common": "^120.3.0",
63
63
  "react": "^18.2.0 || ^19.2.0"
64
64
  },
65
65
  "techstack": {