@atlaskit/editor-plugin-show-diff 14.5.2 → 15.0.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 (74) hide show
  1. package/CHANGELOG.md +28 -6
  2. package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -9
  3. package/dist/cjs/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  4. package/dist/cjs/pm-plugins/decorations/colorSchemes/attributions.js +21 -4
  5. package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +6 -56
  6. package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +6 -20
  7. package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +4 -6
  8. package/dist/cjs/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  9. package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +14 -29
  10. package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  11. package/dist/cjs/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -25
  12. package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  13. package/dist/cjs/pm-plugins/main.js +4 -4
  14. package/dist/cjs/showDiffPlugin.js +4 -5
  15. package/dist/cjs/ui/ContributorTag/buildContributorTagDom.js +122 -0
  16. package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +140 -0
  17. package/dist/cjs/ui/ContributorTag/contributorTagController.js +500 -0
  18. package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +46 -0
  19. package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -5
  20. package/dist/es2019/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  21. package/dist/es2019/pm-plugins/decorations/colorSchemes/attributions.js +20 -3
  22. package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +6 -55
  23. package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +14 -26
  24. package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +4 -6
  25. package/dist/es2019/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  26. package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +16 -30
  27. package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  28. package/dist/es2019/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -17
  29. package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  30. package/dist/es2019/pm-plugins/main.js +4 -4
  31. package/dist/es2019/showDiffPlugin.js +4 -5
  32. package/dist/es2019/ui/ContributorTag/buildContributorTagDom.js +110 -0
  33. package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +136 -0
  34. package/dist/es2019/ui/ContributorTag/contributorTagController.js +403 -0
  35. package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +40 -0
  36. package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +3 -9
  37. package/dist/esm/pm-plugins/calculateDiff/smart/classifySmartChanges.js +1 -2
  38. package/dist/esm/pm-plugins/decorations/colorSchemes/attributions.js +21 -4
  39. package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +6 -57
  40. package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +7 -20
  41. package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +4 -6
  42. package/dist/esm/pm-plugins/decorations/createChangedRowDecorationWidgets.js +1 -2
  43. package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +15 -30
  44. package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +1 -2
  45. package/dist/esm/pm-plugins/decorations/utils/getAttrChangeRanges.js +2 -25
  46. package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeViewStyles.js +1 -2
  47. package/dist/esm/pm-plugins/main.js +4 -4
  48. package/dist/esm/showDiffPlugin.js +4 -5
  49. package/dist/esm/ui/ContributorTag/buildContributorTagDom.js +115 -0
  50. package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +135 -0
  51. package/dist/esm/ui/ContributorTag/contributorTagController.js +493 -0
  52. package/dist/esm/ui/ContributorTag/contributorTagIcons.js +40 -0
  53. package/dist/types/pm-plugins/decorations/colorSchemes/attributions.d.ts +3 -3
  54. package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +2 -2
  55. package/dist/types/pm-plugins/decorations/colorSchemes/schemes.d.ts +1 -1
  56. package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +13 -16
  57. package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +11 -9
  58. package/dist/types/pm-plugins/main.d.ts +1 -2
  59. package/dist/types/ui/ContributorTag/buildContributorTagDom.d.ts +25 -0
  60. package/dist/types/ui/ContributorTag/contributorAvatarRenderer.d.ts +22 -0
  61. package/dist/types/ui/ContributorTag/contributorTagController.d.ts +85 -0
  62. package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +12 -0
  63. package/package.json +9 -13
  64. package/dist/cjs/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  65. package/dist/cjs/ui/ContributorTag/ContributorTag.js +0 -383
  66. package/dist/cjs/ui/ContributorTag/ContributorTagWidget.js +0 -50
  67. package/dist/es2019/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  68. package/dist/es2019/ui/ContributorTag/ContributorTag.js +0 -312
  69. package/dist/es2019/ui/ContributorTag/ContributorTagWidget.js +0 -43
  70. package/dist/esm/ui/ContributorTag/ContributorTag.compiled.css +0 -29
  71. package/dist/esm/ui/ContributorTag/ContributorTag.js +0 -375
  72. package/dist/esm/ui/ContributorTag/ContributorTagWidget.js +0 -43
  73. package/dist/types/ui/ContributorTag/ContributorTag.d.ts +0 -37
  74. package/dist/types/ui/ContributorTag/ContributorTagWidget.d.ts +0 -22
@@ -1,4 +1,4 @@
1
- import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
1
+ import type { IntlShape } from 'react-intl';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
@@ -6,24 +6,26 @@ import type { ShowDiffPlugin } from '../../showDiffPluginType';
6
6
  /** Marks the host element of one tag, so a tag can be found in the document by its own diff. */
7
7
  export declare const CONTRIBUTOR_TAG_HOST_ATTRIBUTE = "data-contributor-tag-host";
8
8
  /**
9
- * Everything a tag needs to mount itself into the document, plumbed down from the plugin. Absent in
9
+ * Everything a tag needs to draw itself into the document, plumbed down from the plugin. Absent in
10
10
  * unit tests that build decorations directly: the hosts are still emitted, they just stay empty.
11
11
  */
12
12
  export type ContributorTagMountContext = {
13
13
  api?: ExtractInjectionAPI<ShowDiffPlugin>;
14
- /** This editor's own content root — see `ContributorTagProps.getEditorRoot`. */
14
+ /** This editor's own content root — see `ContributorTagControllerOptions.getEditorRoot`. */
15
15
  getEditorRoot: () => HTMLElement | null;
16
- portalProviderAPI: PortalProviderAPI;
16
+ getIntl: () => IntlShape;
17
17
  };
18
18
  /** A mounted tag, so whoever emitted the host can take it down again. */
19
19
  export type ContributorTagMount = {
20
- key: string;
21
- portalProviderAPI: PortalProviderAPI;
20
+ destroy: () => void;
22
21
  };
23
22
  /**
24
- * Renders the tag into `host` through the editor's portal provider, the way the rest of the editor
25
- * mounts React into decorations. The tag resolves its own model from plugin state, so a redraw of
26
- * the host re-parents the tag instead of stranding it, and `isActive` changes arrive as a re-render.
23
+ * Draws the tag into `host`. The tag resolves its own model from plugin state, so a redraw of the
24
+ * host re-parents the tag instead of stranding it, and `isActive` changes arrive as an update.
25
+ *
26
+ * Each mount owns its own controller and DOM, so when ProseMirror draws a replacement widget before
27
+ * destroying the one it replaces, the outgoing `destroy` cannot take the incoming tag down with it
28
+ * (EDITOR-8702).
27
29
  */
28
30
  export declare const mountContributorTag: ({ diffId, host, mountContext, }: {
29
31
  diffId: string;
@@ -1,5 +1,4 @@
1
1
  import type { IntlShape } from 'react-intl';
2
- import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
@@ -58,4 +57,4 @@ export type ShowDiffPluginState = {
58
57
  stepAttributions?: Array<DiffStepAttribution | undefined>;
59
58
  steps: ProseMirrorStep[];
60
59
  };
61
- export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, portalProviderAPI?: PortalProviderAPI, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;
60
+ export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined, onEditorView?: (editorView: EditorView | undefined) => void) => SafePlugin<ShowDiffPluginState>;
@@ -0,0 +1,25 @@
1
+ export declare const CONTRIBUTOR_TAG_TESTID = "diff-contributor-tag";
2
+ export declare const CONTRIBUTOR_TAG_NAME_TESTID = "diff-contributor-tag-name";
3
+ /**
4
+ * Floor for the tag width (~one 16px avatar plus padding), so the highlight-width clamp cannot
5
+ * collapse the box on a very short highlight.
6
+ */
7
+ export declare const MIN_TAG_WIDTH = "28px";
8
+ export type ContributorTagDom = {
9
+ avatars: HTMLSpanElement;
10
+ name: HTMLSpanElement;
11
+ root: HTMLSpanElement;
12
+ /**
13
+ * Announced after the name, which is the order design requires. `VanillaTooltip` appends its
14
+ * popover to the tag as well, so this is the last *content* child rather than the last node.
15
+ */
16
+ srLabel: HTMLSpanElement;
17
+ tag: HTMLSpanElement;
18
+ };
19
+ /**
20
+ * The tag's markup, with no model applied — see `ContributorTagController`.
21
+ *
22
+ * Built element by element rather than through `DOMSerializer.renderSpec`, which returns `Node` and
23
+ * would need a cast per reference below.
24
+ */
25
+ export declare const buildContributorTagDom: (doc: Document) => ContributorTagDom;
@@ -0,0 +1,22 @@
1
+ import type { TagContributor } from '../../showDiffPluginType';
2
+ export type ContributorAvatar = {
3
+ destroy: () => void;
4
+ element: HTMLElement;
5
+ /** Repainted when the tag's accent changes, so a state change does not refetch the image. */
6
+ setRingColor: (ringColor: string) => void;
7
+ };
8
+ /**
9
+ * One 16px avatar for a contributor: a circle for a person, a hexagon for an agent.
10
+ *
11
+ * Mirrors `mentionAvatarRenderer` — a bare `<img>` with a glyph fallback bound to `error`, and the
12
+ * hexagon cut with `clip-path`. The ring `@atlaskit/avatar` drew from `borderColor` is a
13
+ * `box-shadow` on the circle and a second clipped hexagon behind the agent, since `box-shadow` is
14
+ * cut away by `clip-path`.
15
+ */
16
+ export declare const contributorAvatarRenderer: ({ contributor, doc, ringColor, stackIndex, }: {
17
+ contributor: TagContributor;
18
+ doc: Document;
19
+ ringColor: string;
20
+ /** Paints the leading avatar of a connected pair over the one it overlaps. */
21
+ stackIndex?: number;
22
+ }) => ContributorAvatar;
@@ -0,0 +1,85 @@
1
+ import type { IntlShape } from 'react-intl';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ShowDiffPlugin } from '../../showDiffPluginType';
4
+ export type ContributorTagControllerOptions = {
5
+ api?: ExtractInjectionAPI<ShowDiffPlugin>;
6
+ diffId: string;
7
+ /**
8
+ * This editor's own content root (`editorView.dom`), read through the plugin's captured view.
9
+ *
10
+ * Every DOM lookup the tag makes is scoped to it, rather than resolved by class name from a
11
+ * highlight element: `.ProseMirror` is not this package's to rename, and with nested editors the
12
+ * nearest one is not necessarily the editor whose plugin rendered this tag.
13
+ */
14
+ getEditorRoot: () => HTMLElement | null;
15
+ /**
16
+ * Read when a model is applied rather than subscribed to, so a locale swap mid-diff would not
17
+ * re-label a tag already on screen. Locales do not hot-swap while a diff is open.
18
+ */
19
+ getIntl: () => IntlShape;
20
+ };
21
+ /**
22
+ * A small tag naming who made one diff, drawn into the host element its decoration places on the
23
+ * change's first character and positioned above it.
24
+ *
25
+ * The model is resolved from plugin state here rather than passed in, because ProseMirror skips
26
+ * `toDOM` for a widget it reuses: stepping to the next change republishes the tags without redrawing
27
+ * their hosts, so anything the tag reacts to — `isActive` above all — has to arrive through a
28
+ * subscription of its own (EDITOR-8702). Draws nothing when this diff has no tag, which is the case
29
+ * for the deleted half of a replacement: that half is folded into the inline tag.
30
+ */
31
+ export declare class ContributorTagController {
32
+ private options;
33
+ private avatars;
34
+ /** Guards a deferred bind that a later model change has already superseded. */
35
+ private bindToken;
36
+ private boundSelector;
37
+ private dom;
38
+ private fullLabel;
39
+ private host;
40
+ private isDestroyed;
41
+ private isHighlightHovered;
42
+ private isHoveredOrFocused;
43
+ private maxWidthPx;
44
+ private model;
45
+ private resizeObserver;
46
+ private tooltip;
47
+ private tooltipContent;
48
+ private unbindHighlights;
49
+ private unbindTag;
50
+ private unsubscribe;
51
+ constructor(options: ContributorTagControllerOptions);
52
+ mount(host: HTMLElement): void;
53
+ destroy(): void;
54
+ private findModel;
55
+ private applyModel;
56
+ /** Takes the tag's DOM down, keeping the subscription so a republished model redraws it. */
57
+ private teardownTag;
58
+ private bindTag;
59
+ private renderAvatars;
60
+ private renderLabels;
61
+ private accentOf;
62
+ private applyAccent;
63
+ /** Width clamp and visibility — the two things that are not carried by the model alone. */
64
+ private applyStyles;
65
+ /**
66
+ * The full label is always the tooltip, whether or not the name it draws is clipped: the tag is
67
+ * never wider than the highlight, so a name that fits at one width is ellipsised at the next, and
68
+ * a connected pair spells out a contributor the tag does not show at any width.
69
+ *
70
+ * `VanillaTooltip` has no "set new content" call, so it is rebuilt when the label changes — the
71
+ * shape of `syncVanillaDisabledTooltip` in `mentionNodeView`.
72
+ */
73
+ private syncTooltip;
74
+ /**
75
+ * Observes the highlight this tag describes, for what CSS here cannot see: its hover state (the
76
+ * highlight is a ProseMirror decoration in a different DOM subtree, so listeners are bound
77
+ * imperatively via `data-diff-id`) and the width the tag is clamped to.
78
+ *
79
+ * Deliberately not routed through plugin state: a transaction per pointer move would re-run the
80
+ * memoised decoration calculation.
81
+ */
82
+ private syncHighlightBindings;
83
+ private bindHighlightState;
84
+ private unbindHighlightState;
85
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The icons a contributor tag can draw, as inline SVG.
3
+ *
4
+ * Neither `@atlaskit/icon`, `@atlaskit/icon-lab` nor `@atlaskit/logo` exposes a raw-SVG entry
5
+ * point, so the markup is copied here rather than kept as a React island for three glyphs. Keep in
6
+ * sync with the sources named on each constant.
7
+ *
8
+ * The Rovo hex is the `brand` appearance, whose `--rovo-*-color` variables resolve to `initial` in
9
+ * both themes — the fallbacks below are the rendered colours, so no theme observer is needed.
10
+ */
11
+ export type ContributorTagIcon = 'aiBot' | 'person' | 'rovoHex';
12
+ export declare const getContributorTagIcon: (icon: ContributorTagIcon, doc: Document) => DocumentFragment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "14.5.2",
3
+ "version": "15.0.0",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -20,23 +20,19 @@
20
20
  "sideEffects": false,
21
21
  "atlaskit:src": "src/index.ts",
22
22
  "dependencies": {
23
- "@atlaskit/adf-schema": "^57.3.0",
23
+ "@atlaskit/adf-schema": "^57.4.0",
24
24
  "@atlaskit/avatar": "^28.0.0",
25
25
  "@atlaskit/custom-steps": "^1.1.0",
26
- "@atlaskit/editor-plugin-analytics": "^16.1.0",
27
- "@atlaskit/editor-plugin-user-intent": "^14.0.0",
26
+ "@atlaskit/editor-plugin-analytics": "^17.0.0",
27
+ "@atlaskit/editor-plugin-user-intent": "^15.0.0",
28
28
  "@atlaskit/editor-prosemirror": "^8.0.0",
29
29
  "@atlaskit/editor-shared-styles": "^4.1.0",
30
30
  "@atlaskit/editor-tables": "^3.1.0",
31
- "@atlaskit/icon-lab": "^7.8.0",
32
- "@atlaskit/logo": "^21.6.0",
33
31
  "@atlaskit/platform-feature-experiments": "^0.3.0",
34
32
  "@atlaskit/platform-feature-flags": "^2.2.0",
35
33
  "@atlaskit/primitives": "^22.5.0",
36
- "@atlaskit/tmp-editor-statsig": "^178.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^179.0.0",
37
35
  "@atlaskit/tokens": "^16.11.0",
38
- "@atlaskit/tooltip": "^24.3.0",
39
- "@atlaskit/visually-hidden": "^4.4.0",
40
36
  "@babel/runtime": "^7.0.0",
41
37
  "@compiled/react": "^1.0.2",
42
38
  "bind-event-listener": "^3.0.0",
@@ -49,7 +45,7 @@
49
45
  "@atlaskit/button": "^25.3.0",
50
46
  "@atlaskit/css": "^1.1.0",
51
47
  "@atlaskit/dropdown-menu": "^18.3.0",
52
- "@atlaskit/editor-core": "^226.6.0",
48
+ "@atlaskit/editor-core": "^227.0.0",
53
49
  "@atlaskit/editor-json-transformer": "^9.8.0",
54
50
  "@atlaskit/editor-plugins": "^16.1.0",
55
51
  "@atlaskit/form": "^17.2.0",
@@ -59,15 +55,15 @@
59
55
  "@atlaskit/util-data-test": "^19.1.0",
60
56
  "@atlassian/confluence-presets": "workspace:^",
61
57
  "@atlassian/content-reconciliation": "^0.1.3506",
62
- "@atlassian/editor-ai-injected-editors": "^30.0.0",
63
- "@atlassian/editor-plugin-ai": "^70.2.0",
58
+ "@atlassian/editor-ai-injected-editors": "^31.0.0",
59
+ "@atlassian/editor-plugin-ai": "^71.0.0",
64
60
  "@atlassian/structured-docs-types": "workspace:^",
65
61
  "react": "^19.2.0",
66
62
  "react-dom": "^19.2.0",
67
63
  "react-intl": "^7.0.0"
68
64
  },
69
65
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^120.16.0",
66
+ "@atlaskit/editor-common": "^121.0.0",
71
67
  "react": "^18.2.0 || ^19.2.0",
72
68
  "react-dom": "^18.2.0 || ^19.2.0",
73
69
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -1,29 +0,0 @@
1
- ._11c8wadc{font:var(--ds-font-body-small,normal 400 9pt/1pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
2
- ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
3
- ._zulp1b66{gap:var(--ds-space-050,4px)}
4
- ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
5
- ._1rjcv77o{padding-block:var(--ds-space-025,2px)}
6
- ._12l2r5cr{margin-inline-end:var(--ds-space-negative-050,-4px)}
7
- ._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
8
- ._18m915vq{overflow-y:hidden}
9
- ._1bto1l2s{text-overflow:ellipsis}
10
- ._1doc1dm9{border-bottom-width:var(--ds-border-width-selected,2px)}
11
- ._1e02idpf{inset-inline-start:0}
12
- ._1e0c116y{display:inline-flex}
13
- ._1e0c1ule{display:block}
14
- ._1il9nqa1{border-bottom-style:solid}
15
- ._1o9zidpf{flex-shrink:0}
16
- ._1pbykb7n{z-index:1}
17
- ._1reo15vq{overflow-x:hidden}
18
- ._1ul9idpf{min-width:0}
19
- ._4cvr1h6o{align-items:center}
20
- ._94n51osq{bottom:100%}
21
- ._kqswstnw{position:absolute}
22
- ._lcxv1wug{pointer-events:auto}
23
- ._lcxvglyw{pointer-events:none}
24
- ._o5721q9c{white-space:nowrap}
25
- ._p12f1osq{max-width:100%}
26
- ._tzy4idpf{opacity:0}
27
- ._tzy4kb7n{opacity:1}
28
- ._uiztglyw{-webkit-user-select:none;-ms-user-select:none;user-select:none}
29
- ._vchhusvi{box-sizing:border-box}