@atlaskit/editor-plugin-show-diff 16.1.0 → 16.2.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 +33 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +67 -22
- package/dist/cjs/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +242 -26
- package/dist/cjs/pm-plugins/decorations/colorSchemes/factory.js +71 -37
- package/dist/cjs/pm-plugins/decorations/colorSchemes/schemes.js +5 -1
- package/dist/cjs/pm-plugins/decorations/colorSchemes/types.js +0 -2
- package/dist/cjs/pm-plugins/decorations/createBlockChangedDecoration.js +21 -14
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +83 -3
- package/dist/cjs/pm-plugins/decorations/extractContributorTags.js +123 -43
- package/dist/cjs/pm-plugins/decorations/revealStyles.js +5 -1
- package/dist/cjs/pm-plugins/decorations/utils/absorbFirstChildMarginReset.js +33 -0
- package/dist/cjs/pm-plugins/decorations/utils/createMarginAbsorber.js +43 -0
- package/dist/cjs/pm-plugins/decorations/utils/createNodeShapedMarginSpacer.js +76 -0
- package/dist/cjs/pm-plugins/decorations/utils/safeResolve.js +24 -0
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +48 -19
- package/dist/cjs/pm-plugins/utils/baseNodeName.js +25 -0
- package/dist/cjs/pm-plugins/utils/taggableBlockNodes.js +37 -0
- package/dist/cjs/ui/ContributorTag/contributorTagController.js +4 -4
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +39 -2
- package/dist/es2019/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +196 -10
- package/dist/es2019/pm-plugins/decorations/colorSchemes/factory.js +51 -19
- package/dist/es2019/pm-plugins/decorations/colorSchemes/schemes.js +3 -0
- package/dist/es2019/pm-plugins/decorations/colorSchemes/types.js +0 -2
- package/dist/es2019/pm-plugins/decorations/createBlockChangedDecoration.js +23 -14
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +83 -3
- package/dist/es2019/pm-plugins/decorations/extractContributorTags.js +60 -7
- package/dist/es2019/pm-plugins/decorations/revealStyles.js +5 -1
- package/dist/es2019/pm-plugins/decorations/utils/absorbFirstChildMarginReset.js +29 -0
- package/dist/es2019/pm-plugins/decorations/utils/createMarginAbsorber.js +39 -0
- package/dist/es2019/pm-plugins/decorations/utils/createNodeShapedMarginSpacer.js +69 -0
- package/dist/es2019/pm-plugins/decorations/utils/safeResolve.js +18 -0
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +44 -19
- package/dist/es2019/pm-plugins/utils/baseNodeName.js +18 -0
- package/dist/es2019/pm-plugins/utils/taggableBlockNodes.js +28 -0
- package/dist/es2019/ui/ContributorTag/contributorTagController.js +4 -4
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +67 -22
- package/dist/esm/pm-plugins/calculateDiff/simplifyChangesWithAttribution.js +243 -26
- package/dist/esm/pm-plugins/decorations/colorSchemes/factory.js +71 -37
- package/dist/esm/pm-plugins/decorations/colorSchemes/schemes.js +5 -1
- package/dist/esm/pm-plugins/decorations/colorSchemes/types.js +0 -2
- package/dist/esm/pm-plugins/decorations/createBlockChangedDecoration.js +21 -14
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +83 -3
- package/dist/esm/pm-plugins/decorations/extractContributorTags.js +123 -43
- package/dist/esm/pm-plugins/decorations/revealStyles.js +5 -1
- package/dist/esm/pm-plugins/decorations/utils/absorbFirstChildMarginReset.js +28 -0
- package/dist/esm/pm-plugins/decorations/utils/createMarginAbsorber.js +37 -0
- package/dist/esm/pm-plugins/decorations/utils/createNodeShapedMarginSpacer.js +70 -0
- package/dist/esm/pm-plugins/decorations/utils/safeResolve.js +18 -0
- package/dist/esm/pm-plugins/getScrollableDecorations.js +48 -19
- package/dist/esm/pm-plugins/utils/baseNodeName.js +20 -0
- package/dist/esm/pm-plugins/utils/taggableBlockNodes.js +32 -0
- package/dist/esm/ui/ContributorTag/contributorTagController.js +4 -4
- package/dist/types/pm-plugins/calculateDiff/simplifyChangesWithAttribution.d.ts +20 -1
- package/dist/types/pm-plugins/decorations/colorSchemes/factory.d.ts +4 -11
- package/dist/types/pm-plugins/decorations/colorSchemes/types.d.ts +9 -8
- package/dist/types/pm-plugins/decorations/utils/absorbFirstChildMarginReset.d.ts +23 -0
- package/dist/types/pm-plugins/decorations/utils/createMarginAbsorber.d.ts +23 -0
- package/dist/types/pm-plugins/decorations/utils/createNodeShapedMarginSpacer.d.ts +26 -0
- package/dist/types/pm-plugins/decorations/utils/safeResolve.d.ts +13 -0
- package/dist/types/pm-plugins/getScrollableDecorations.d.ts +2 -2
- package/dist/types/pm-plugins/utils/baseNodeName.d.ts +16 -0
- package/dist/types/pm-plugins/utils/taggableBlockNodes.d.ts +14 -0
- package/package.json +14 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { AgentBrandColorScheme } from '@atlaskit/agent-color/agent-presence-color-types';
|
|
1
2
|
/** Schemes consumers may explicitly request through the show-diff API. */
|
|
2
3
|
export type PublicColorScheme = 'standard' | 'traditional';
|
|
3
4
|
/** Attribution-only participant slots selected by the plugin, never by consumers. */
|
|
4
5
|
export declare const PARTICIPANT_COLOR_SCHEMES: readonly ['red', 'blue', 'green', 'yellow', 'purple', 'magenta', 'teal', 'orange', 'lime', 'gray'];
|
|
5
6
|
/** ADS accent hues used by the public and participant colour schemes. */
|
|
6
7
|
export type AdsAccentColor = (typeof PARTICIPANT_COLOR_SCHEMES)[number];
|
|
7
|
-
|
|
8
|
-
export type ColorScheme = PublicColorScheme |
|
|
8
|
+
export type AccentColor = AdsAccentColor | AgentBrandColorScheme;
|
|
9
|
+
export type ColorScheme = PublicColorScheme | AccentColor;
|
|
9
10
|
/**
|
|
10
11
|
* A show-diff colour scheme. Colour fields are ADS hues that `factory.ts` expands into token paths;
|
|
11
12
|
* the rest encode structural differences no colour can express. Ring widths, padding, radius and
|
|
@@ -15,15 +16,15 @@ export type DiffColorScheme = {
|
|
|
15
16
|
/** Stacking order of the square added-cell overlay. The rounded variant is always 2. */
|
|
16
17
|
addedCellOverlayZIndex: 1 | 2;
|
|
17
18
|
/** Deleted inline content, active/focused state. */
|
|
18
|
-
deleteActiveColor:
|
|
19
|
+
deleteActiveColor: AccentColor;
|
|
19
20
|
/** Deleted inline content. */
|
|
20
|
-
deleteColor:
|
|
21
|
+
deleteColor: AccentColor;
|
|
21
22
|
/** Active deleted-block ring: pale `background.accent.*.subtler.pressed` vs saturated `border.accent.*`. */
|
|
22
23
|
deletedBlockOutlineActiveEmphasis: 'background' | 'border';
|
|
23
24
|
/** Deleted cell outline: `color.border.disabled` hairline vs opaque accent border. */
|
|
24
25
|
deletedCellBorderProminence: 'subtle' | 'accent';
|
|
25
26
|
/** Deleted cell overlays. Gray in both current schemes. */
|
|
26
|
-
deletedCellColor:
|
|
27
|
+
deletedCellColor: AccentColor;
|
|
27
28
|
/** Opacity of the deleted cell overlay background. Counterpart to `insertedCellOpacity`. */
|
|
28
29
|
deletedCellOpacity: number;
|
|
29
30
|
/**
|
|
@@ -62,11 +63,11 @@ export type DiffColorScheme = {
|
|
|
62
63
|
/** Deleted row de-emphasis: tint the line-through, or tint the row text. Both read `deleteColor`. */
|
|
63
64
|
deletedRowTreatment: 'strikeColor' | 'textTint';
|
|
64
65
|
/** Optional text and strikethrough hue, independent of deletion borders. */
|
|
65
|
-
deleteTextColor?:
|
|
66
|
+
deleteTextColor?: AccentColor;
|
|
66
67
|
/** Inserted content, active/focused state. */
|
|
67
|
-
insertActiveColor:
|
|
68
|
+
insertActiveColor: AccentColor;
|
|
68
69
|
/** Inserted content, default state. */
|
|
69
|
-
insertColor:
|
|
70
|
+
insertColor: AccentColor;
|
|
70
71
|
/** Opacity of the inserted cell overlay background. */
|
|
71
72
|
insertedCellOpacity: number;
|
|
72
73
|
/** Bottom border tone for inserted text highlights. Defaults to accent. */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a block node rendered inside a diff widget from losing its own top margin.
|
|
3
|
+
*
|
|
4
|
+
* The editor's leading-block margin reset is written against the parent element, not the document
|
|
5
|
+
* position, so it fires wherever a text block is a first child — including inside the widget's own
|
|
6
|
+
* `span`, which is what a whole-block deletion renders into. The widget then has no margin of its
|
|
7
|
+
* own, and the block sits flush against whatever is above it, regardless of where in the document
|
|
8
|
+
* the widget landed.
|
|
9
|
+
*
|
|
10
|
+
* The margin is not re-supplied; it is never taken away. Prepending an element the reset does not
|
|
11
|
+
* select moves the real block off the leading position, so the ordinary `.ProseMirror p`,
|
|
12
|
+
* `.ProseMirror h2` and similar rules go on applying to it untouched. That is why this needs no
|
|
13
|
+
* knowledge of which margin the block should have — unlike `createNodeShapedMarginSpacer`, which
|
|
14
|
+
* replicates a margin that has already been zeroed and cannot be read back.
|
|
15
|
+
*
|
|
16
|
+
* Unconditional, because the absorber generates no box: it costs nothing in a widget holding
|
|
17
|
+
* inline content, which the reset was never going to match anyway. Deciding here instead would mean
|
|
18
|
+
* restating the reset's selector list, and a copy of another package's CSS drifts silently.
|
|
19
|
+
*/
|
|
20
|
+
export declare const absorbFirstChildMarginReset: ({ dom, testId, }: {
|
|
21
|
+
dom: HTMLElement;
|
|
22
|
+
testId: string;
|
|
23
|
+
}) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An empty, invisible element whose only job is to occupy a position in the DOM.
|
|
3
|
+
*
|
|
4
|
+
* At the top of the document `firstBlockNodeStyles` zeroes the top margin of whatever element
|
|
5
|
+
* follows a leading `.ProseMirror-widget`, and it does so with `!important` — which no inline style
|
|
6
|
+
* can outrank. This takes that hit so the shaped spacer after it, one position further along, keeps
|
|
7
|
+
* the margin it is there to supply.
|
|
8
|
+
*
|
|
9
|
+
* It contributes no height (no content, border or padding) and margins collapse through it, so it
|
|
10
|
+
* cannot affect layout beyond the selector it absorbs.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createMarginAbsorber: ({ testId }: {
|
|
13
|
+
testId: string;
|
|
14
|
+
}) => HTMLElement;
|
|
15
|
+
/**
|
|
16
|
+
* An absorber that occupies a DOM position without generating a box.
|
|
17
|
+
*
|
|
18
|
+
* Not interchangeable with `createMarginAbsorber`: a rule that selects the *rendered* sibling of a
|
|
19
|
+
* leading widget needs an element that generates a box, and this one does not.
|
|
20
|
+
*/
|
|
21
|
+
export declare const createBoxlessMarginAbsorber: ({ testId }: {
|
|
22
|
+
testId: string;
|
|
23
|
+
}) => HTMLElement;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { NodeViewSerializer } from '../../NodeViewSerializer';
|
|
3
|
+
/**
|
|
4
|
+
* An invisible element shaped like `node`, used to supply the top margin `node` no longer gets.
|
|
5
|
+
*
|
|
6
|
+
* A node at the start of its parent has its top margin reset, so a diff widget rendered above it
|
|
7
|
+
* sits flush against it. The reset cannot simply be taken off the node: the container variants skip
|
|
8
|
+
* widgets when counting — `nth-child(1 of :not(style, .ProseMirror-gapcursor, .ProseMirror-widget,
|
|
9
|
+
* span))` in layout columns, expands, sync blocks and table cells — so no amount of extra elements
|
|
10
|
+
* moves the match. That exclusion is what makes this work instead: the spacer is a
|
|
11
|
+
* `.ProseMirror-widget`, so it is never the counted first child and keeps its own margin, while the
|
|
12
|
+
* real node goes on taking the reset.
|
|
13
|
+
*
|
|
14
|
+
* The margin is not measured. Reading it off the real node is impossible — by then the reset has
|
|
15
|
+
* set it to `0`, and both `firstBlockNodeStyles` (`!important`) and block controls' `firstNodeDec`
|
|
16
|
+
* (an inline style) make it unrecoverable. Instead the spacer carries the node's own tag, classes
|
|
17
|
+
* and attributes, so the same rules that would have given the node its margin match the spacer
|
|
18
|
+
* (`.ProseMirror p`, `.ProseMirror h2`, the root-list rule, and so on).
|
|
19
|
+
*
|
|
20
|
+
* Returns `null` when the node is not safely shapeable or serialization fails.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createNodeShapedMarginSpacer: ({ node, serializer, testId, }: {
|
|
23
|
+
node: PMNode;
|
|
24
|
+
serializer: NodeViewSerializer;
|
|
25
|
+
testId: string;
|
|
26
|
+
}) => HTMLElement | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a document position, or returns `null` if it cannot be resolved.
|
|
4
|
+
*
|
|
5
|
+
* `Node.resolve` throws a `RangeError` for a position outside the document. Diff decorations are
|
|
6
|
+
* built from change ranges computed against a document that may since have moved on, so a position
|
|
7
|
+
* arriving out of range is a normal outcome rather than a defect — but an exception escaping here
|
|
8
|
+
* takes down the whole decoration set, leaving the diff unrendered.
|
|
9
|
+
*
|
|
10
|
+
* Callers are expected to treat `null` as "cannot tell" and fall back to behaviour that does not
|
|
11
|
+
* need the resolved position.
|
|
12
|
+
*/
|
|
13
|
+
export declare const safeResolve: (doc: PMNode, pos: number) => ResolvedPos | null;
|
|
@@ -18,8 +18,8 @@ export declare function isInlineDiffDecorationRenderableInDoc(doc: PMNode, from:
|
|
|
18
18
|
* 4. When `doc` is passed: excludes diff-inline decorations whose range has no inline content
|
|
19
19
|
* (invalid positions, or block-only slices with no text/atoms — e.g. empty blocks)
|
|
20
20
|
* 5. When `confluence_ncs_step_diffing_version_history` is enabled, groups overlapping or
|
|
21
|
-
* directly touching ranges across decoration types into one result, using the
|
|
22
|
-
* grouped ranges
|
|
21
|
+
* directly touching ranges across decoration types into one result per contributor, using the
|
|
22
|
+
* union of all grouped ranges
|
|
23
23
|
* (zero-width widgets can join a group without extending it). Under
|
|
24
24
|
* `platform_editor_ai_show_diff_patch_1`, a group that starts with content painting above
|
|
25
25
|
* the content that replaced it — reports that widget as its `scrollTarget` spec,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A node type's base name, with a schema variant's suffix stripped: `panel`, `panel_c1` and
|
|
3
|
+
* `panel_c1_root_only` all resolve to `panel`.
|
|
4
|
+
*
|
|
5
|
+
* Package-local rather than `getBaseNodeTypeName` from editor-common, which enumerates the variants
|
|
6
|
+
* it happens to know (`panel_c1` alone) and is shared with features outside this one. Derived
|
|
7
|
+
* instead of listed, so a variant added later needs no change here: the schema generator names a
|
|
8
|
+
* variant `<type>_<variant>`, and every other node name in the ADF schema is camelCase, so the
|
|
9
|
+
* first `_` is the boundary.
|
|
10
|
+
*
|
|
11
|
+
* Gated, so the diff behaves exactly as before for anyone outside the rollout.
|
|
12
|
+
*
|
|
13
|
+
* For taggability only — this gate is weaker than the ones attribution needs, so resolving a variant
|
|
14
|
+
* in the styling decisions would move the legacy diff for readers who see no tags.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolveBaseNodeName: (name: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Whether this node hosts a contributor tag of its own. Navigation grouping does not consult this:
|
|
4
|
+
* a run of these one contributor inserted is a single stop, tagged on the leading block.
|
|
5
|
+
*
|
|
6
|
+
* Resolved through `resolveBaseNodeName` so a schema variant counts as the type it is a variant of:
|
|
7
|
+
* `panel_c1` is the panel the table-in-panel schema inserts, and matching on `type.name` left it
|
|
8
|
+
* untagged (EDITOR-8932).
|
|
9
|
+
*
|
|
10
|
+
* By name, because the decoration spec carries `nodeName` rather than the type it came from.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isTaggableBlockNodeName: (name: string | undefined) => boolean;
|
|
13
|
+
/** As above, from the node type itself. */
|
|
14
|
+
export declare const isTaggableBlockNode: (nodeType: NodeType) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
+
"website": {
|
|
12
|
+
"tags": [
|
|
13
|
+
"platform-labs"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
11
16
|
"team": "Editor: Lego",
|
|
12
17
|
"releaseModel": "continuous",
|
|
13
18
|
"singleton": true
|
|
@@ -21,6 +26,7 @@
|
|
|
21
26
|
"atlaskit:src": "src/index.ts",
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"@atlaskit/adf-schema": "^57.5.0",
|
|
29
|
+
"@atlaskit/agent-color": "^0.2.0",
|
|
24
30
|
"@atlaskit/avatar": "^28.0.0",
|
|
25
31
|
"@atlaskit/custom-steps": "^1.1.0",
|
|
26
32
|
"@atlaskit/editor-plugin-accessibility-utils": "^18.0.0",
|
|
@@ -33,8 +39,8 @@
|
|
|
33
39
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
34
40
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
35
41
|
"@atlaskit/primitives": "^22.5.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
37
|
-
"@atlaskit/tokens": "^
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^199.0.0",
|
|
43
|
+
"@atlaskit/tokens": "^18.1.0",
|
|
38
44
|
"@babel/runtime": "^7.0.0",
|
|
39
45
|
"@compiled/react": "^1.0.2",
|
|
40
46
|
"bind-event-listener": "^3.0.0",
|
|
@@ -58,14 +64,14 @@
|
|
|
58
64
|
"@atlassian/confluence-presets": "workspace:^",
|
|
59
65
|
"@atlassian/content-reconciliation": "^0.1.3506",
|
|
60
66
|
"@atlassian/editor-ai-injected-editors": "^32.0.0",
|
|
61
|
-
"@atlassian/editor-plugin-ai": "^72.
|
|
67
|
+
"@atlassian/editor-plugin-ai": "^72.4.0",
|
|
62
68
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
63
69
|
"react": "^19.2.0",
|
|
64
70
|
"react-dom": "^19.2.0",
|
|
65
71
|
"react-intl": "^7.0.0"
|
|
66
72
|
},
|
|
67
73
|
"peerDependencies": {
|
|
68
|
-
"@atlaskit/editor-common": "^122.
|
|
74
|
+
"@atlaskit/editor-common": "^122.12.0",
|
|
69
75
|
"react": "^18.2.0 || ^19.2.0",
|
|
70
76
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
71
77
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -80,6 +86,9 @@
|
|
|
80
86
|
"platform_editor_ai_show_diff_patch_1": {
|
|
81
87
|
"type": "boolean"
|
|
82
88
|
},
|
|
89
|
+
"platform_editor_ai_show_diff_patch_2": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
},
|
|
83
92
|
"platform_editor_ai_smart_diff": {
|
|
84
93
|
"type": "boolean"
|
|
85
94
|
},
|