@atlaskit/editor-plugin-show-diff 14.3.2 → 14.4.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 (77) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/afm-cc/tsconfig.json +18 -0
  3. package/afm-products/tsconfig.json +18 -0
  4. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +47 -26
  5. package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +61 -9
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +77 -20
  7. package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +10 -0
  8. package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +2 -0
  9. package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +52 -7
  10. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +172 -0
  11. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +37 -5
  12. package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +40 -7
  13. package/dist/cjs/pm-plugins/decorations/decorationKeys.js +31 -5
  14. package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +128 -0
  15. package/dist/cjs/pm-plugins/main.js +57 -6
  16. package/dist/cjs/pm-plugins/resolveDiffContributors.js +143 -0
  17. package/dist/cjs/showDiffPlugin.js +21 -6
  18. package/dist/cjs/ui/ContributorTag/ContributorTag.compiled.css +29 -0
  19. package/dist/cjs/ui/ContributorTag/ContributorTag.js +383 -0
  20. package/dist/cjs/ui/ContributorTag/ContributorTagWidget.js +50 -0
  21. package/dist/cjs/ui/ContributorTag/messages.js +24 -0
  22. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +48 -27
  23. package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +39 -0
  24. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +53 -11
  25. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +9 -0
  26. package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +2 -0
  27. package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +43 -1
  28. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +163 -0
  29. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +38 -5
  30. package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +38 -6
  31. package/dist/es2019/pm-plugins/decorations/decorationKeys.js +30 -2
  32. package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +101 -0
  33. package/dist/es2019/pm-plugins/main.js +52 -3
  34. package/dist/es2019/pm-plugins/resolveDiffContributors.js +128 -0
  35. package/dist/es2019/showDiffPlugin.js +20 -5
  36. package/dist/es2019/ui/ContributorTag/ContributorTag.compiled.css +29 -0
  37. package/dist/es2019/ui/ContributorTag/ContributorTag.js +312 -0
  38. package/dist/es2019/ui/ContributorTag/ContributorTagWidget.js +43 -0
  39. package/dist/es2019/ui/ContributorTag/messages.js +18 -0
  40. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +49 -28
  41. package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +60 -8
  42. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +77 -19
  43. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +9 -0
  44. package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +2 -0
  45. package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +51 -6
  46. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +166 -0
  47. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +37 -5
  48. package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +40 -7
  49. package/dist/esm/pm-plugins/decorations/decorationKeys.js +30 -5
  50. package/dist/esm/pm-plugins/decorations/extractContributorTags.js +122 -0
  51. package/dist/esm/pm-plugins/main.js +57 -6
  52. package/dist/esm/pm-plugins/resolveDiffContributors.js +137 -0
  53. package/dist/esm/showDiffPlugin.js +21 -6
  54. package/dist/esm/ui/ContributorTag/ContributorTag.compiled.css +29 -0
  55. package/dist/esm/ui/ContributorTag/ContributorTag.js +375 -0
  56. package/dist/esm/ui/ContributorTag/ContributorTagWidget.js +43 -0
  57. package/dist/esm/ui/ContributorTag/messages.js +18 -0
  58. package/dist/types/entry-points/show-diff-plugin-type.d.ts +1 -1
  59. package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +7 -1
  60. package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +10 -0
  61. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +24 -2
  62. package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +7 -1
  63. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +1 -2
  64. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +2 -1
  65. package/dist/types/pm-plugins/decorations/createAnchorDecorationWidgets.d.ts +14 -0
  66. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +55 -0
  67. package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +5 -1
  68. package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +5 -1
  69. package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +28 -3
  70. package/dist/types/pm-plugins/decorations/extractContributorTags.d.ts +9 -0
  71. package/dist/types/pm-plugins/main.d.ts +8 -2
  72. package/dist/types/pm-plugins/resolveDiffContributors.d.ts +7 -0
  73. package/dist/types/showDiffPluginType.d.ts +65 -2
  74. package/dist/types/ui/ContributorTag/ContributorTag.d.ts +37 -0
  75. package/dist/types/ui/ContributorTag/ContributorTagWidget.d.ts +22 -0
  76. package/dist/types/ui/ContributorTag/messages.d.ts +6 -0
  77. package/package.json +16 -7
@@ -2,6 +2,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import type { DiffType } from '../../showDiffPluginType';
4
4
  import type { ColorScheme } from './colorSchemes/types';
5
+ import { type ContributorTagMountContext } from './createContributorTagWidget';
5
6
  import type { InlineAttrChangeNodeName } from './utils/getAttrChangeRanges';
6
7
  export declare const getAtomicInlineChangedAttrs: (inlineNodeName: InlineAttrChangeNodeName, colorScheme: ColorScheme | undefined) => {
7
8
  className: string;
@@ -13,7 +14,8 @@ export declare const getAtomicInlineChangedAttrs: (inlineNodeName: InlineAttrCha
13
14
  * @param change Changeset "change" containing information about the change content + range
14
15
  * @returns Prosemirror inline decoration
15
16
  */
16
- export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, isAtomicInlineNode, shouldHideDeleted, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, hasDeletedWidget, isDeletedWidgetBelow, }: {
17
+ export declare const createInlineChangedDecoration: ({ attributionKey, change, colorScheme, isActive, isInserted, isAtomicInlineNode, shouldHideDeleted, showContributorTags, showIndicators, doc, diffType, hideAddedDiffsUnderline, inlineNodeName, hasDeletedWidget, isDeletedWidgetBelow, tagMountContext, }: {
18
+ attributionKey?: string;
17
19
  change: {
18
20
  fromB: number;
19
21
  toB: number;
@@ -29,5 +31,7 @@ export declare const createInlineChangedDecoration: ({ change, colorScheme, isAc
29
31
  isDeletedWidgetBelow?: boolean;
30
32
  isInserted?: boolean;
31
33
  shouldHideDeleted?: boolean;
34
+ showContributorTags?: boolean;
32
35
  showIndicators?: boolean;
36
+ tagMountContext?: ContributorTagMountContext;
33
37
  }) => Decoration[];
@@ -4,16 +4,18 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { DiffType } from '../../showDiffPluginType';
6
6
  import type { NodeViewSerializer } from '../NodeViewSerializer';
7
+ import { type ContributorTagMountContext } from './createContributorTagWidget';
7
8
  import type { ColorScheme } from './colorSchemes/types';
8
9
  /**
9
10
  * This function is used to create a decoration widget to show content
10
11
  * that is not in the current document.
11
12
  */
12
- export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, }: {
13
+ export declare const createNodeChangedDecorationWidget: ({ attributionKey, change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showContributorTags, showIndicators, placeBelow, diffType, hideAddedDiffsUnderline, tagMountContext, }: {
13
14
  activeIndexPos?: {
14
15
  from: number;
15
16
  to: number;
16
17
  };
18
+ attributionKey?: string;
17
19
  change: Pick<Change, 'fromA' | 'toA' | 'fromB' | 'deleted' | 'toB'>;
18
20
  colorScheme?: ColorScheme;
19
21
  diffType?: DiffType;
@@ -24,5 +26,7 @@ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeView
24
26
  newDoc: PMNode;
25
27
  nodeViewSerializer: NodeViewSerializer;
26
28
  placeBelow?: boolean;
29
+ showContributorTags?: boolean;
27
30
  showIndicators?: boolean;
31
+ tagMountContext?: ContributorTagMountContext;
28
32
  }) => Decoration[];
@@ -1,5 +1,6 @@
1
1
  import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
2
  import type { DiffDescriptor, DiffType } from '../../showDiffPluginType';
3
+ import type { ColorScheme } from './colorSchemes/types';
3
4
  /**
4
5
  * Decoration families produced by the show-diff plugin.
5
6
  * Each family owns its own key space and spec shape.
@@ -7,6 +8,7 @@ import type { DiffDescriptor, DiffType } from '../../showDiffPluginType';
7
8
  export declare const DecorationFamily: {
8
9
  readonly diff: 'diff';
9
10
  readonly anchor: 'anchor';
11
+ readonly contributorTag: 'contributor-tag';
10
12
  };
11
13
  type DecorationFamilyValue = (typeof DecorationFamily)[keyof typeof DecorationFamily];
12
14
  type BaseDecorationSpec<TFamily extends DecorationFamilyValue> = {
@@ -15,8 +17,20 @@ type BaseDecorationSpec<TFamily extends DecorationFamilyValue> = {
15
17
  side?: number;
16
18
  };
17
19
  export type DiffDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.diff> & {
20
+ attributionKey?: string;
21
+ colorScheme?: ColorScheme;
18
22
  decorationType: DiffDescriptor['type'];
19
23
  diffId: string;
24
+ /**
25
+ * The change currently stepped to. Needed on the spec because `activeIndex` indexes the filtered,
26
+ * re-sorted scrollable decorations, not `diffDescriptors`.
27
+ */
28
+ isActive?: boolean;
29
+ /**
30
+ * Carried rather than derived from `decorationType`, because an inverted diff swaps which side is
31
+ * the inserted one.
32
+ */
33
+ isInserted?: boolean;
20
34
  nodeName?: string;
21
35
  };
22
36
  export declare const AnchorTypeKey: {
@@ -25,14 +39,21 @@ export declare const AnchorTypeKey: {
25
39
  readonly left: 'left';
26
40
  readonly docMargin: 'doc-margin';
27
41
  };
28
- type InlineAnchorType = Exclude<(typeof AnchorTypeKey)[keyof typeof AnchorTypeKey], typeof AnchorTypeKey.docMargin>;
42
+ export type InlineAnchorType = Exclude<(typeof AnchorTypeKey)[keyof typeof AnchorTypeKey], typeof AnchorTypeKey.docMargin>;
29
43
  export type AnchorDecorationSpec = (BaseDecorationSpec<typeof DecorationFamily.anchor> & {
30
44
  anchorType: typeof AnchorTypeKey.docMargin;
31
45
  }) | (BaseDecorationSpec<typeof DecorationFamily.anchor> & {
32
46
  anchorType: InlineAnchorType;
33
47
  diffId: string;
34
48
  });
35
- export type ShowDiffDecorationSpec = DiffDecorationSpec | AnchorDecorationSpec;
49
+ /**
50
+ * The host widget one contributor tag renders into. Its own family, so the tag never reaches the
51
+ * consumers that read diff decorations — change counting, navigation and `getDeletedWidgets`.
52
+ */
53
+ export type ContributorTagDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.contributorTag> & {
54
+ diffId: string;
55
+ };
56
+ export type ShowDiffDecorationSpec = DiffDecorationSpec | AnchorDecorationSpec | ContributorTagDecorationSpec;
36
57
  /**
37
58
  * The diff-decoration kinds produced by the show-diff plugin. Each value is
38
59
  * the leading segment of the generated key, so a diff decoration's kind can be
@@ -59,11 +80,14 @@ export declare const buildDiffDecorationKey: ({ decorationKeyPrefix, isActive, d
59
80
  diffType?: DiffType;
60
81
  isActive?: boolean;
61
82
  }) => string;
62
- export declare const buildDiffDecorationSpec: ({ decorationType, diffId, isActive, nodeName, side, diffType, }: {
83
+ export declare const buildDiffDecorationSpec: ({ attributionKey, colorScheme, decorationType, diffId, isActive, isInserted, nodeName, side, diffType, }: {
84
+ attributionKey?: string;
85
+ colorScheme?: ColorScheme;
63
86
  decorationType: DiffDescriptor['type'];
64
87
  diffId: string;
65
88
  diffType?: DiffType;
66
89
  isActive?: boolean;
90
+ isInserted?: boolean;
67
91
  nodeName?: string;
68
92
  side?: number;
69
93
  }) => DiffDecorationSpec;
@@ -76,6 +100,7 @@ export declare function buildAnchorDecorationSpec(args: {
76
100
  diffId: string;
77
101
  side?: number;
78
102
  }): AnchorDecorationSpec;
103
+ export declare const buildContributorTagDecorationSpec: (diffId: string) => ContributorTagDecorationSpec;
79
104
  export declare const isDiffDecorationSpec: (spec: unknown) => spec is DiffDecorationSpec;
80
105
  export declare const isAnchorDecorationSpec: (spec: unknown) => spec is AnchorDecorationSpec;
81
106
  export declare const isDiffDecoration: (decoration: Decoration) => decoration is Decoration & {
@@ -0,0 +1,9 @@
1
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ import type { ContributorTagModel } from '../../showDiffPluginType';
3
+ import type { ResolvedDiffContributors } from './colorSchemes/attributions';
4
+ /**
5
+ * One model per diff decoration whose attribution resolves to a supplied contributor; anything
6
+ * unattributed, untaggable or unresolved is skipped. A replacement's two decorations are collapsed
7
+ * into the single inline tag — see `isSameChange`.
8
+ */
9
+ export declare const extractContributorTags: (decorations: DecorationSet, contributors: ResolvedDiffContributors | undefined) => ContributorTagModel[];
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl';
2
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
@@ -6,7 +7,8 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
7
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform-override';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
9
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
- import type { DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
10
+ import type { ContributorTagModel, DeletedDiffPlacement, DiffDescriptor, DiffParams, DiffStepAttribution, DiffType, InlineDeletedDiffPlacement, ShowDiffPlugin, SmartDiffThresholds } from '../showDiffPluginType';
11
+ import type { ResolvedDiffContributors } from './decorations/colorSchemes/attributions';
10
12
  export declare const showDiffPluginKey: PluginKey<ShowDiffPluginState>;
11
13
  export type ShowDiffPluginState = {
12
14
  activeIndex?: number;
@@ -14,6 +16,10 @@ export type ShowDiffPluginState = {
14
16
  from: number;
15
17
  to: number;
16
18
  };
19
+ /** Set via SHOW_DIFF meta, after `normalizeShowDiffParams` has keyed the public list. */
20
+ contributors?: ResolvedDiffContributors;
21
+ /** Resolved per calculation, never set via meta. */
22
+ contributorTags?: ContributorTagModel[];
17
23
  decorations: DecorationSet;
18
24
  /**
19
25
  * For the `smart` diffType, where node/paragraph-level deleted content is rendered relative to
@@ -52,4 +58,4 @@ export type ShowDiffPluginState = {
52
58
  stepAttributions?: Array<DiffStepAttribution | undefined>;
53
59
  steps: ProseMirrorStep[];
54
60
  };
55
- export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;
61
+ export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, portalProviderAPI?: PortalProviderAPI, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;
@@ -0,0 +1,7 @@
1
+ import type { DiffContributorProfile, DiffContributors, StepWithAttribution } from '../showDiffPluginType';
2
+ /**
3
+ * One contributor per distinct actor behind the attributed steps, resolved against the identities
4
+ * the consumer supplied. Returns `undefined` if any actor cannot be named: a half-credited diff
5
+ * reads as "nobody touched this", so the whole list is dropped and the plain diff renders instead.
6
+ */
7
+ export declare const resolveDiffContributors: <TStep>(stepsWithAttribution: Array<StepWithAttribution<TStep>>, profiles: readonly DiffContributorProfile[] | undefined) => DiffContributors | undefined;
@@ -6,7 +6,8 @@ import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
6
6
  import type { Node } from '@atlaskit/editor-prosemirror/model';
7
7
  import type { Step } from '@atlaskit/editor-prosemirror/transform-override';
8
8
  import type { SmartDiffThresholds as SmartDiffThresholdsInternal } from './pm-plugins/calculateDiff/smart/thresholds';
9
- export type ColorScheme = 'standard' | 'traditional';
9
+ import type { ColorScheme as ResolvedColorScheme, PublicColorScheme } from './pm-plugins/decorations/colorSchemes/types';
10
+ export type ColorScheme = PublicColorScheme;
10
11
  export type DiffType = 'inline' | 'block' | 'step' | 'smart';
11
12
  /**
12
13
  * Attribution for a ProseMirror step.
@@ -26,6 +27,53 @@ export type StepWithAttribution<TStep> = {
26
27
  step: TStep;
27
28
  stepAttribution?: DiffStepAttribution;
28
29
  };
30
+ /** A complete identity for one of the accounts named by a step attribution. */
31
+ export type DiffContributorProfile = {
32
+ /** Matched against the `userId` and `agentId` on step attributions. */
33
+ accountId: string;
34
+ avatarUrl?: string;
35
+ name: string;
36
+ };
37
+ type DiffContributorKind = 'user' | 'agent';
38
+ /** Agent presentation: `rovo`/`identified` use the agent's identity, `external` is generic. */
39
+ type DiffAgentKind = 'rovo' | 'identified' | 'external';
40
+ /**
41
+ * A contributor the plugin has resolved from a step attribution and a supplied profile. Internal:
42
+ * never re-exported from an entry point and not reachable from any public type. Same for
43
+ * `DiffContributors`.
44
+ */
45
+ export type DiffContributor = {
46
+ /** For `kind: 'agent'`, which presentation to use. Defaults to `'external'`. */
47
+ agentKind?: DiffAgentKind;
48
+ attribution: DiffStepAttribution;
49
+ avatarUrl?: string;
50
+ /** Attribution of the invoking user, so the pair renders as connected. */
51
+ connectedTo?: DiffStepAttribution;
52
+ kind: DiffContributorKind;
53
+ name: string;
54
+ };
55
+ /** Where two contributors share an identity, the last wins. */
56
+ export type DiffContributors = DiffContributor[];
57
+ /** A contributor stripped of its attributions, as a tag presents it. Internal. */
58
+ export type TagContributor = Omit<DiffContributor, 'attribution' | 'connectedTo'>;
59
+ /**
60
+ * Everything a contributor tag renders, resolved by the plugin so the tag UI does no lookups.
61
+ * Declared here rather than beside `extractContributorTags` so the shared state below can name it
62
+ * without importing back out of this file. Internal, like `TagContributor`.
63
+ */
64
+ export type ContributorTagModel = {
65
+ colorScheme?: ResolvedColorScheme;
66
+ connectedContributor?: TagContributor;
67
+ contributor: TagContributor;
68
+ diffId: string;
69
+ isActive?: boolean;
70
+ isInserted?: boolean;
71
+ /**
72
+ * Other decorations of the same change that this one tag captions, so hovering any of them
73
+ * reveals it. Set when a replacement's deleted-content widget is folded into its inline tag.
74
+ */
75
+ linkedDiffIds?: string[];
76
+ };
29
77
  /**
30
78
  * Where node/paragraph-level deleted content is rendered relative to the new (replacement)
31
79
  * content in the `smart` diffType:
@@ -118,11 +166,19 @@ export type PMDiffParams = {
118
166
  * by `userId`, with `agentId` used as a tie-breaker.
119
167
  */
120
168
  type PMDiffParamsWithAttribution = Omit<PMDiffParams, 'steps'> & {
169
+ /**
170
+ * Identities for the accounts named by the attributed steps. When supplied, and the contributor-tag
171
+ * gate is on, every attributed change the plugin can credit to one of them renders a tag.
172
+ * Complete entries only: a caller looking identities up (e.g. against a user directory) filters
173
+ * out the ones it could not resolve rather than passing partial entries through. Omitting an
174
+ * account is meaningful — a user the plugin cannot name drops every tag, while an agent falls
175
+ * back to its own presentation.
176
+ */
177
+ contributorProfiles?: readonly DiffContributorProfile[];
121
178
  steps?: never;
122
179
  stepsWithAttribution: Array<StepWithAttribution<Step>>;
123
180
  };
124
181
  export type ShowDiffParams = PMDiffParams | PMDiffParamsWithAttribution;
125
- export type ACTION = 'SHOW_DIFF' | 'HIDE_DIFF' | 'SCROLL_TO_NEXT' | 'SCROLL_TO_PREVIOUS';
126
182
  export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
127
183
  actions: {
128
184
  /**
@@ -149,6 +205,13 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
149
205
  * The index of the current diff being viewed.
150
206
  */
151
207
  activeIndex?: number;
208
+ /**
209
+ * The contributor tags to render for the diff currently being displayed. Resolved by the
210
+ * plugin and consumed by its own contributor-tag UI — `ContributorTagModel` and
211
+ * `TagContributor` are not exported from any entry point.
212
+ * Only set when `platform_editor_diff_plugin_extended` is on.
213
+ */
214
+ contributorTags?: ContributorTagModel[];
152
215
  /**
153
216
  * The diff descriptors of the diff decorations currently being displayed.
154
217
  * Only set when `platform_editor_diff_plugin_extended` is on.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import type { ColorScheme } from '../../pm-plugins/decorations/colorSchemes/types';
6
+ import type { TagContributor } from '../../showDiffPluginType';
7
+ type ContributorTagProps = {
8
+ colorScheme?: ColorScheme;
9
+ connectedContributor?: TagContributor;
10
+ contributor: TagContributor;
11
+ diffId: string;
12
+ /**
13
+ * This editor's own content root (`editorView.dom`), read through the plugin's captured view.
14
+ *
15
+ * Every DOM lookup the tag makes is scoped to it, rather than resolved by class name from a
16
+ * highlight element: `.ProseMirror` is not this package's to rename, and with nested editors the
17
+ * nearest one is not necessarily the editor whose plugin rendered this tag.
18
+ *
19
+ * A getter rather than the element itself because the view arrives with the ProseMirror view
20
+ * lifecycle, which the plugin does not re-render for: reading it inside the effect means it is
21
+ * always the current one.
22
+ */
23
+ getEditorRoot: () => HTMLElement | null;
24
+ isActive?: boolean;
25
+ isInserted?: boolean;
26
+ /**
27
+ * Other decorations of the same change this one tag captions — the deleted half of a replacement.
28
+ * Hovering any of them reveals the tag; only `diffId` is measured against.
29
+ */
30
+ linkedDiffIds?: string[];
31
+ };
32
+ /**
33
+ * A small tag naming who made one diff, rendered into the host widget its decoration places on the
34
+ * change's first character and positioned above it.
35
+ */
36
+ export declare function ContributorTag({ colorScheme, connectedContributor, contributor, diffId, getEditorRoot, isActive, isInserted, linkedDiffIds, }: ContributorTagProps): JSX.Element;
37
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
+ import type { ShowDiffPlugin } from '../../showDiffPluginType';
7
+ /**
8
+ * One contributor tag, mounted by its diff decoration into the host element that decoration draws
9
+ * (see `mountContributorTag`).
10
+ *
11
+ * The model is read from plugin state here rather than passed in, because ProseMirror skips `toDOM`
12
+ * for a widget it reuses: stepping to the next change republishes the tags without redrawing their
13
+ * hosts, so anything the tag needs to react to — `isActive` above all — has to arrive through a
14
+ * subscription of its own. Renders nothing when this diff has no tag, which is the case for the
15
+ * deleted half of a replacement: that half is folded into the inline tag.
16
+ */
17
+ export declare const ContributorTagWidget: ({ api, diffId, getEditorRoot, }: {
18
+ api?: ExtractInjectionAPI<ShowDiffPlugin>;
19
+ diffId: string;
20
+ /** This editor's own content root — see `ContributorTagProps.getEditorRoot`. */
21
+ getEditorRoot: () => HTMLElement | null;
22
+ }) => JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import { type MessageDescriptor } from 'react-intl';
2
+ export declare const contributorTagMessages: {
3
+ changedBy: MessageDescriptor;
4
+ changedByConnected: MessageDescriptor;
5
+ externalAgentName: MessageDescriptor;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "14.3.2",
3
+ "version": "14.4.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -20,33 +20,39 @@
20
20
  "sideEffects": false,
21
21
  "atlaskit:src": "src/index.ts",
22
22
  "dependencies": {
23
- "@atlaskit/adf-schema": "^57.2.0",
23
+ "@atlaskit/adf-schema": "^57.3.0",
24
+ "@atlaskit/avatar": "^28.0.0",
24
25
  "@atlaskit/custom-steps": "^1.1.0",
25
26
  "@atlaskit/editor-plugin-analytics": "^16.1.0",
26
27
  "@atlaskit/editor-plugin-user-intent": "^14.0.0",
27
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
28
29
  "@atlaskit/editor-shared-styles": "^4.1.0",
29
30
  "@atlaskit/editor-tables": "^3.1.0",
31
+ "@atlaskit/icon-lab": "^7.8.0",
32
+ "@atlaskit/logo": "^21.6.0",
30
33
  "@atlaskit/platform-feature-experiments": "^0.3.0",
31
34
  "@atlaskit/platform-feature-flags": "^2.2.0",
35
+ "@atlaskit/primitives": "^22.5.0",
32
36
  "@atlaskit/tmp-editor-statsig": "^174.0.0",
33
37
  "@atlaskit/tokens": "^16.11.0",
38
+ "@atlaskit/tooltip": "^24.3.0",
39
+ "@atlaskit/visually-hidden": "^4.4.0",
34
40
  "@babel/runtime": "^7.0.0",
35
41
  "@compiled/react": "^1.0.2",
42
+ "bind-event-listener": "^3.0.0",
36
43
  "lodash": "^4.17.21",
37
44
  "memoize-one": "^6.0.0",
38
45
  "prosemirror-changeset": "^2.3.1"
39
46
  },
40
47
  "devDependencies": {
41
- "@atlaskit/adf-utils": "^20.8.0",
48
+ "@atlaskit/adf-utils": "^20.9.0",
42
49
  "@atlaskit/button": "^25.3.0",
43
50
  "@atlaskit/css": "^1.1.0",
44
51
  "@atlaskit/dropdown-menu": "^18.3.0",
45
- "@atlaskit/editor-core": "^226.3.0",
52
+ "@atlaskit/editor-core": "^226.4.0",
46
53
  "@atlaskit/editor-json-transformer": "^9.8.0",
47
54
  "@atlaskit/editor-plugins": "^16.1.0",
48
55
  "@atlaskit/form": "^17.2.0",
49
- "@atlaskit/primitives": "^22.5.0",
50
56
  "@atlaskit/section-message": "^10.2.0",
51
57
  "@atlaskit/textarea": "^10.2.0",
52
58
  "@atlaskit/textfield": "^10.2.0",
@@ -57,11 +63,14 @@
57
63
  "@atlassian/editor-plugin-ai": "^70.2.0",
58
64
  "@atlassian/structured-docs-types": "workspace:^",
59
65
  "react": "^19.2.0",
66
+ "react-dom": "^19.2.0",
60
67
  "react-intl": "^7.0.0"
61
68
  },
62
69
  "peerDependencies": {
63
- "@atlaskit/editor-common": "^120.12.0",
64
- "react": "^18.2.0 || ^19.2.0"
70
+ "@atlaskit/editor-common": "^120.13.0",
71
+ "react": "^18.2.0 || ^19.2.0",
72
+ "react-dom": "^18.2.0 || ^19.2.0",
73
+ "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
65
74
  },
66
75
  "platform-feature-flags": {
67
76
  "platform_editor_ai_show_diff_patch_1": {