@atlaskit/editor-plugin-show-diff 10.0.1 → 10.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 +19 -0
- package/dist/cjs/pm-plugins/calculateDiff/calculateDiffDecorations.js +25 -8
- package/dist/cjs/pm-plugins/decorations/createAnchorDecorationWidgets.js +209 -0
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +17 -2
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +19 -3
- package/dist/cjs/pm-plugins/decorations/decorationKeys.js +81 -28
- package/dist/cjs/pm-plugins/getScrollableDecorations.js +32 -23
- package/dist/cjs/pm-plugins/main.js +8 -6
- package/dist/cjs/pm-plugins/scrollToDiff.js +5 -6
- package/dist/cjs/showDiffPlugin.js +12 -1
- package/dist/cjs/ui/IndicatorBar/IndicatorBar.compiled.css +9 -0
- package/dist/cjs/ui/IndicatorBar/IndicatorBar.js +33 -0
- package/dist/cjs/ui/IndicatorBar/IndicatorBarContentComponent.js +87 -0
- package/dist/es2019/pm-plugins/calculateDiff/calculateDiffDecorations.js +23 -8
- package/dist/es2019/pm-plugins/decorations/createAnchorDecorationWidgets.js +205 -0
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +14 -2
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +19 -4
- package/dist/es2019/pm-plugins/decorations/decorationKeys.js +64 -14
- package/dist/es2019/pm-plugins/getScrollableDecorations.js +31 -25
- package/dist/es2019/pm-plugins/main.js +8 -6
- package/dist/es2019/pm-plugins/scrollToDiff.js +6 -7
- package/dist/es2019/showDiffPlugin.js +12 -1
- package/dist/es2019/ui/IndicatorBar/IndicatorBar.compiled.css +9 -0
- package/dist/es2019/ui/IndicatorBar/IndicatorBar.js +24 -0
- package/dist/es2019/ui/IndicatorBar/IndicatorBarContentComponent.js +82 -0
- package/dist/esm/pm-plugins/calculateDiff/calculateDiffDecorations.js +25 -8
- package/dist/esm/pm-plugins/decorations/createAnchorDecorationWidgets.js +203 -0
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +16 -2
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +20 -4
- package/dist/esm/pm-plugins/decorations/decorationKeys.js +78 -27
- package/dist/esm/pm-plugins/getScrollableDecorations.js +33 -24
- package/dist/esm/pm-plugins/main.js +8 -6
- package/dist/esm/pm-plugins/scrollToDiff.js +6 -7
- package/dist/esm/showDiffPlugin.js +12 -1
- package/dist/esm/ui/IndicatorBar/IndicatorBar.compiled.css +9 -0
- package/dist/esm/ui/IndicatorBar/IndicatorBar.js +25 -0
- package/dist/esm/ui/IndicatorBar/IndicatorBarContentComponent.js +80 -0
- package/dist/types/pm-plugins/calculateDiff/calculateDiffDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/createAnchorDecorationWidgets.d.ts +38 -0
- package/dist/types/pm-plugins/decorations/createInlineChangedDecoration.d.ts +4 -1
- package/dist/types/pm-plugins/decorations/createNodeChangedDecorationWidget.d.ts +2 -1
- package/dist/types/pm-plugins/decorations/decorationKeys.d.ts +56 -17
- package/dist/types/pm-plugins/main.d.ts +1 -0
- package/dist/types/pm-plugins/scrollToDiff.d.ts +2 -2
- package/dist/types/showDiffPluginType.d.ts +8 -0
- package/dist/types/ui/IndicatorBar/IndicatorBar.d.ts +10 -0
- package/dist/types/ui/IndicatorBar/IndicatorBarContentComponent.d.ts +17 -0
- package/package.json +6 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko1rr0{border-radius:var(--ds-radius-full,9999px)}._17c61i8t{position-visibility:anchors-valid}
|
|
3
|
+
._18u0mgjw{margin-left:var(--ds-space-negative-200,-1pc)}
|
|
4
|
+
._19pk196n{margin-top:var(--ds-space-negative-075,-6px)}
|
|
5
|
+
._1bsb1l7b{width:3px}
|
|
6
|
+
._bfhkvbh5{background-color:var(--ds-border-information,#357de8)}
|
|
7
|
+
._kqswstnw{position:absolute}
|
|
8
|
+
._lcxvglyw{pointer-events:none}
|
|
9
|
+
._otyr196n{margin-bottom:var(--ds-space-negative-075,-6px)}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* IndicatorBar.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import "./IndicatorBar.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { AnchorDocMarginKey } from '../../pm-plugins/decorations/decorationKeys';
|
|
6
|
+
var barStyles = null;
|
|
7
|
+
export function IndicatorBar(_ref) {
|
|
8
|
+
var anchorTop = _ref.anchorTop,
|
|
9
|
+
anchorBottom = _ref.anchorBottom,
|
|
10
|
+
anchorLeft = _ref.anchorLeft,
|
|
11
|
+
anchorLeftFallback = _ref.anchorLeftFallback;
|
|
12
|
+
var leftAnchors = [anchorLeft, anchorLeftFallback, AnchorDocMarginKey].filter(Boolean).map(function (anchor) {
|
|
13
|
+
return "anchor(--".concat(anchor, " left)");
|
|
14
|
+
}).join(', ');
|
|
15
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
16
|
+
"data-testid": "diff-indicator-bar",
|
|
17
|
+
style: {
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
19
|
+
left: "min(".concat(leftAnchors, ")"),
|
|
20
|
+
top: "anchor(--".concat(anchorTop, " top)"),
|
|
21
|
+
bottom: "anchor(--".concat(anchorBottom, " bottom)")
|
|
22
|
+
},
|
|
23
|
+
className: ax(["_2rko1rr0 _kqswstnw _1bsb1l7b _bfhkvbh5 _lcxvglyw _18u0mgjw _17c61i8t _19pk196n _otyr196n"])
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* IndicatorBarContentComponent.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { buildAnchorDecorationKey, AnchorTypeKey } from '../../pm-plugins/decorations/decorationKeys';
|
|
6
|
+
import { IndicatorBar } from './IndicatorBar';
|
|
7
|
+
var renderIndicatorBar = function renderIndicatorBar(descriptor) {
|
|
8
|
+
switch (descriptor.type) {
|
|
9
|
+
case 'inline':
|
|
10
|
+
{
|
|
11
|
+
return /*#__PURE__*/React.createElement(IndicatorBar, {
|
|
12
|
+
key: descriptor.id,
|
|
13
|
+
anchorTop: buildAnchorDecorationKey({
|
|
14
|
+
diffId: descriptor.id,
|
|
15
|
+
anchorType: AnchorTypeKey.from
|
|
16
|
+
}),
|
|
17
|
+
anchorBottom: buildAnchorDecorationKey({
|
|
18
|
+
diffId: descriptor.id,
|
|
19
|
+
anchorType: AnchorTypeKey.to
|
|
20
|
+
}),
|
|
21
|
+
anchorLeft: buildAnchorDecorationKey({
|
|
22
|
+
diffId: descriptor.id,
|
|
23
|
+
anchorType: AnchorTypeKey.left
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
case 'widget':
|
|
28
|
+
{
|
|
29
|
+
return /*#__PURE__*/React.createElement(IndicatorBar, {
|
|
30
|
+
key: descriptor.id,
|
|
31
|
+
anchorTop: buildAnchorDecorationKey({
|
|
32
|
+
diffId: descriptor.id
|
|
33
|
+
}),
|
|
34
|
+
anchorBottom: buildAnchorDecorationKey({
|
|
35
|
+
diffId: descriptor.id
|
|
36
|
+
}),
|
|
37
|
+
anchorLeft: buildAnchorDecorationKey({
|
|
38
|
+
diffId: descriptor.id,
|
|
39
|
+
anchorType: AnchorTypeKey.left
|
|
40
|
+
}),
|
|
41
|
+
anchorLeftFallback: buildAnchorDecorationKey({
|
|
42
|
+
diffId: descriptor.id
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* TODO EDITOR-7711:
|
|
48
|
+
* Support IndicatorBar for block-changed type diffs.
|
|
49
|
+
*/
|
|
50
|
+
default:
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Renders IndicatorBar elements for each diff ID in the current plugin state.
|
|
57
|
+
*
|
|
58
|
+
* This is rendered as a contentComponent so that the IndicatorBar elements
|
|
59
|
+
* share the same DOM context as their CSS anchor spans, allowing the browser
|
|
60
|
+
* to resolve anchor-name references correctly.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
export var IndicatorBarContentComponent = function IndicatorBarContentComponent(_ref) {
|
|
64
|
+
var api = _ref.api;
|
|
65
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['showDiff'], function (state) {
|
|
66
|
+
var _state$showDiffState, _state$showDiffState2, _state$showDiffState3;
|
|
67
|
+
return {
|
|
68
|
+
showIndicators: (_state$showDiffState = state.showDiffState) === null || _state$showDiffState === void 0 ? void 0 : _state$showDiffState.showIndicators,
|
|
69
|
+
isDisplayingChanges: (_state$showDiffState2 = state.showDiffState) === null || _state$showDiffState2 === void 0 ? void 0 : _state$showDiffState2.isDisplayingChanges,
|
|
70
|
+
diffDescriptors: (_state$showDiffState3 = state.showDiffState) === null || _state$showDiffState3 === void 0 ? void 0 : _state$showDiffState3.diffDescriptors
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
showIndicators = _useSharedPluginState.showIndicators,
|
|
74
|
+
isDisplayingChanges = _useSharedPluginState.isDisplayingChanges,
|
|
75
|
+
diffDescriptors = _useSharedPluginState.diffDescriptors;
|
|
76
|
+
if (!showIndicators || !isDisplayingChanges || !(diffDescriptors !== null && diffDescriptors !== void 0 && diffDescriptors.length)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, diffDescriptors.map(renderIndicatorBar));
|
|
80
|
+
};
|
|
@@ -10,7 +10,7 @@ type CalculatedDiffs = {
|
|
|
10
10
|
decorations: DecorationSet;
|
|
11
11
|
diffDescriptors: DiffDescriptor[];
|
|
12
12
|
};
|
|
13
|
-
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, }: {
|
|
13
|
+
export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState, nodeViewSerializer, colorScheme, intl, activeIndexPos, api, hideDeletedDiffs, showIndicators, }: {
|
|
14
14
|
activeIndexPos?: {
|
|
15
15
|
from: number;
|
|
16
16
|
to: number;
|
|
@@ -21,6 +21,7 @@ export declare const calculateDiffDecorations: MemoizedFn<({ state, pluginState,
|
|
|
21
21
|
intl: IntlShape;
|
|
22
22
|
nodeViewSerializer: NodeViewSerializer;
|
|
23
23
|
pluginState: Omit<ShowDiffPluginState, 'decorations'>;
|
|
24
|
+
showIndicators?: boolean;
|
|
24
25
|
state: EditorState;
|
|
25
26
|
}) => CalculatedDiffs>;
|
|
26
27
|
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* Create a widget that marks the start of the doc margin.
|
|
5
|
+
* This is used to determine the position of the inline indicators
|
|
6
|
+
* when the inline content exceeds the doc margin.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createDocMarginAnchorWidget: () => Decoration;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an invisible left anchor widget for a diff inside a resizable block
|
|
11
|
+
* node (table, layout, expand), whose inline content can exceed the doc margin.
|
|
12
|
+
* Resolves the edge-case position from `doc`/`from`; returns `undefined` when
|
|
13
|
+
* the diff is not inside such a node and no left anchor is needed.
|
|
14
|
+
*
|
|
15
|
+
* The span is given an `anchor-name` (keyed by `diffId`) and positioned in the
|
|
16
|
+
* doc margin so the `IndicatorBar` can align its left edge against it via CSS
|
|
17
|
+
* anchor positioning. Shared by inline and node (widget) diff decorations.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createLeftAnchorWidget: ({ doc, from, diffId, }: {
|
|
20
|
+
diffId: string;
|
|
21
|
+
doc: PMNode;
|
|
22
|
+
from: number;
|
|
23
|
+
}) => Decoration | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Creates invisible anchor widgets for a single inline diff range so that the
|
|
26
|
+
* `IndicatorBar` can use CSS anchor positioning to align itself with the diff.
|
|
27
|
+
*
|
|
28
|
+
* - A `from` anchor is placed at the start of the range (top of the bar).
|
|
29
|
+
* - A `to` anchor is placed at the end of the range (bottom of the bar).
|
|
30
|
+
* - An optional `left` anchor is placed before the first textblock when the
|
|
31
|
+
* diff is inside a resizable block node (table, layout, expand).
|
|
32
|
+
*/
|
|
33
|
+
export declare const createInlineIndicatorAnchorWidgets: ({ doc, from, to, diffId, }: {
|
|
34
|
+
diffId: string;
|
|
35
|
+
doc: PMNode;
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
}) => Decoration[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import type { ColorScheme } from '../../showDiffPluginType';
|
|
3
4
|
/**
|
|
@@ -6,13 +7,15 @@ import type { ColorScheme } from '../../showDiffPluginType';
|
|
|
6
7
|
* @param change Changeset "change" containing information about the change content + range
|
|
7
8
|
* @returns Prosemirror inline decoration
|
|
8
9
|
*/
|
|
9
|
-
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, }: {
|
|
10
|
+
export declare const createInlineChangedDecoration: ({ change, colorScheme, isActive, isInserted, shouldHideDeleted, showIndicators, doc, }: {
|
|
10
11
|
change: {
|
|
11
12
|
fromB: number;
|
|
12
13
|
toB: number;
|
|
13
14
|
};
|
|
14
15
|
colorScheme?: ColorScheme;
|
|
16
|
+
doc?: PMNode;
|
|
15
17
|
isActive?: boolean;
|
|
16
18
|
isInserted?: boolean;
|
|
17
19
|
shouldHideDeleted?: boolean;
|
|
20
|
+
showIndicators?: boolean;
|
|
18
21
|
}) => Decoration[];
|
|
@@ -8,7 +8,7 @@ import type { NodeViewSerializer } from '../NodeViewSerializer';
|
|
|
8
8
|
* This function is used to create a decoration widget to show content
|
|
9
9
|
* that is not in the current document.
|
|
10
10
|
*/
|
|
11
|
-
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, }: {
|
|
11
|
+
export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeViewSerializer, colorScheme, newDoc, intl, activeIndexPos, isInserted, showIndicators, }: {
|
|
12
12
|
activeIndexPos?: {
|
|
13
13
|
from: number;
|
|
14
14
|
to: number;
|
|
@@ -20,4 +20,5 @@ export declare const createNodeChangedDecorationWidget: ({ change, doc, nodeView
|
|
|
20
20
|
isInserted?: boolean;
|
|
21
21
|
newDoc: PMNode;
|
|
22
22
|
nodeViewSerializer: NodeViewSerializer;
|
|
23
|
+
showIndicators?: boolean;
|
|
23
24
|
}) => Decoration[];
|
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import type { DiffDescriptor } from '../../showDiffPluginType';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* identified by this single prefix.
|
|
4
|
+
* Decoration families produced by the show-diff plugin.
|
|
5
|
+
* Each family owns its own key space and spec shape.
|
|
7
6
|
*/
|
|
8
|
-
declare const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export declare const DecorationFamily: {
|
|
8
|
+
readonly diff: "diff";
|
|
9
|
+
readonly anchor: "anchor";
|
|
10
|
+
};
|
|
11
|
+
type DecorationFamilyValue = (typeof DecorationFamily)[keyof typeof DecorationFamily];
|
|
12
|
+
type BaseDecorationSpec<TFamily extends DecorationFamilyValue> = {
|
|
13
|
+
decorationFamily: TFamily;
|
|
14
|
+
key: string;
|
|
15
|
+
side?: number;
|
|
16
|
+
};
|
|
17
|
+
export type DiffDecorationSpec = BaseDecorationSpec<typeof DecorationFamily.diff> & {
|
|
11
18
|
decorationType: DiffDescriptor['type'];
|
|
12
19
|
diffId: string;
|
|
13
|
-
key: string;
|
|
14
20
|
nodeName?: string;
|
|
15
|
-
side?: number;
|
|
16
21
|
};
|
|
22
|
+
export declare const AnchorTypeKey: {
|
|
23
|
+
readonly from: "from";
|
|
24
|
+
readonly to: "to";
|
|
25
|
+
readonly left: "left";
|
|
26
|
+
readonly docMargin: "doc-margin";
|
|
27
|
+
};
|
|
28
|
+
type InlineAnchorType = Exclude<(typeof AnchorTypeKey)[keyof typeof AnchorTypeKey], typeof AnchorTypeKey.docMargin>;
|
|
29
|
+
export type AnchorDecorationSpec = (BaseDecorationSpec<typeof DecorationFamily.anchor> & {
|
|
30
|
+
anchorType: typeof AnchorTypeKey.docMargin;
|
|
31
|
+
}) | (BaseDecorationSpec<typeof DecorationFamily.anchor> & {
|
|
32
|
+
anchorType: InlineAnchorType;
|
|
33
|
+
diffId: string;
|
|
34
|
+
});
|
|
35
|
+
export type ShowDiffDecorationSpec = DiffDecorationSpec | AnchorDecorationSpec;
|
|
17
36
|
/**
|
|
18
|
-
* The kinds
|
|
19
|
-
* leading segment of the generated key, so a decoration's kind can be
|
|
20
|
-
* with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
37
|
+
* The diff-decoration kinds produced by the show-diff plugin. Each value is
|
|
38
|
+
* the leading segment of the generated key, so a diff decoration's kind can be
|
|
39
|
+
* matched with `key?.startsWith(DiffDecorationKey.inline)` etc.
|
|
21
40
|
*/
|
|
22
41
|
export declare const DiffDecorationKey: Readonly<{
|
|
23
|
-
block: `${typeof
|
|
24
|
-
inline: `${typeof
|
|
25
|
-
widget: `${typeof
|
|
42
|
+
block: `${typeof DecorationFamily.diff}-block`;
|
|
43
|
+
inline: `${typeof DecorationFamily.diff}-inline`;
|
|
44
|
+
widget: `${typeof DecorationFamily.diff}-widget`;
|
|
26
45
|
}>;
|
|
46
|
+
export declare const AnchorDocMarginKey: `${typeof DecorationFamily.anchor}-${typeof AnchorTypeKey.docMargin}`;
|
|
47
|
+
export declare const buildAnchorDecorationKey: ({ diffId, anchorType, }: {
|
|
48
|
+
anchorType?: InlineAnchorType;
|
|
49
|
+
diffId: string;
|
|
50
|
+
}) => string;
|
|
27
51
|
/**
|
|
28
|
-
* Builds a decoration key
|
|
29
|
-
*
|
|
52
|
+
* Builds a diff decoration key. The extended experience includes the `diffId`
|
|
53
|
+
* in the key so independently rendered decorations for the same type remain
|
|
54
|
+
* distinguishable.
|
|
30
55
|
*/
|
|
31
56
|
export declare const buildDiffDecorationKey: ({ decorationKeyPrefix, isActive, diffId, }: {
|
|
32
57
|
decorationKeyPrefix: (typeof DiffDecorationKey)[DiffDescriptor["type"]];
|
|
@@ -40,5 +65,19 @@ export declare const buildDiffDecorationSpec: ({ decorationType, diffId, isActiv
|
|
|
40
65
|
nodeName?: string;
|
|
41
66
|
side?: number;
|
|
42
67
|
}) => DiffDecorationSpec;
|
|
68
|
+
export declare function buildAnchorDecorationSpec(args: {
|
|
69
|
+
anchorType: typeof AnchorTypeKey.docMargin;
|
|
70
|
+
side?: number;
|
|
71
|
+
}): AnchorDecorationSpec;
|
|
72
|
+
export declare function buildAnchorDecorationSpec(args: {
|
|
73
|
+
anchorType: InlineAnchorType;
|
|
74
|
+
diffId: string;
|
|
75
|
+
side?: number;
|
|
76
|
+
}): AnchorDecorationSpec;
|
|
77
|
+
export declare const isDiffDecorationSpec: (spec: unknown) => spec is DiffDecorationSpec;
|
|
78
|
+
export declare const isAnchorDecorationSpec: (spec: unknown) => spec is AnchorDecorationSpec;
|
|
79
|
+
export declare const isDiffDecoration: (decoration: Decoration) => decoration is Decoration & {
|
|
80
|
+
spec: DiffDecorationSpec;
|
|
81
|
+
};
|
|
43
82
|
export declare const extractDiffDescriptors: (decorations: DecorationSet) => DiffDescriptor[];
|
|
44
83
|
export {};
|
|
@@ -29,6 +29,7 @@ export type ShowDiffPluginState = {
|
|
|
29
29
|
* and then reset this flag.
|
|
30
30
|
*/
|
|
31
31
|
scrollIntoView?: boolean;
|
|
32
|
+
showIndicators?: boolean;
|
|
32
33
|
steps: ProseMirrorStep[];
|
|
33
34
|
};
|
|
34
35
|
export declare const createPlugin: (config: DiffParams | undefined, getIntl: () => IntlShape, api: ExtractInjectionAPI<ShowDiffPlugin> | undefined) => SafePlugin<ShowDiffPluginState>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import type { EditorView, Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
/**
|
|
3
3
|
* Schedules scrolling to the first diff decoration after the next frame.
|
|
4
4
|
* Unlike `scrollToActiveDecoration`, this does not require an active index —
|
|
@@ -6,7 +6,7 @@ import type { EditorView, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
*
|
|
7
7
|
* @returns A function that cancels the scheduled `requestAnimationFrame` if it has not run yet.
|
|
8
8
|
*/
|
|
9
|
-
export declare const scrollToFirstDecoration: (view: EditorView,
|
|
9
|
+
export declare const scrollToFirstDecoration: (view: EditorView, set: DecorationSet) => (() => void);
|
|
10
10
|
/**
|
|
11
11
|
* Schedules scrolling to the decoration at the given index after the next frame.
|
|
12
12
|
*
|
|
@@ -35,6 +35,10 @@ export type PMDiffParams = {
|
|
|
35
35
|
* after the diff is shown.
|
|
36
36
|
*/
|
|
37
37
|
scrollIntoView?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to show indicators at the doc margin for the diffs.
|
|
40
|
+
*/
|
|
41
|
+
showIndicators?: boolean;
|
|
38
42
|
/**
|
|
39
43
|
* Prosemirror steps. This is used to calculate and show the diff in the editor
|
|
40
44
|
*/
|
|
@@ -73,5 +77,9 @@ export type ShowDiffPlugin = NextEditorPlugin<'showDiff', {
|
|
|
73
77
|
* The number of changes being displayed
|
|
74
78
|
*/
|
|
75
79
|
numberOfChanges?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to show indicators at the doc margin for the diffs.
|
|
82
|
+
*/
|
|
83
|
+
showIndicators?: boolean;
|
|
76
84
|
};
|
|
77
85
|
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
export declare function IndicatorBar({ anchorTop, anchorBottom, anchorLeft, anchorLeftFallback, }: {
|
|
6
|
+
anchorBottom: string;
|
|
7
|
+
anchorLeft: string;
|
|
8
|
+
anchorLeftFallback?: string;
|
|
9
|
+
anchorTop: string;
|
|
10
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
* @jsxFrag React.Fragment
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { ShowDiffPlugin } from '../../showDiffPluginType';
|
|
8
|
+
/**
|
|
9
|
+
* Renders IndicatorBar elements for each diff ID in the current plugin state.
|
|
10
|
+
*
|
|
11
|
+
* This is rendered as a contentComponent so that the IndicatorBar elements
|
|
12
|
+
* share the same DOM context as their CSS anchor spans, allowing the browser
|
|
13
|
+
* to resolve anchor-name references correctly.
|
|
14
|
+
*/
|
|
15
|
+
export declare const IndicatorBarContentComponent: ({ api, }: {
|
|
16
|
+
api?: ExtractInjectionAPI<ShowDiffPlugin>;
|
|
17
|
+
}) => JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/adf-schema": "^55.
|
|
23
|
+
"@atlaskit/adf-schema": "^55.2.0",
|
|
24
24
|
"@atlaskit/custom-steps": "^1.0.0",
|
|
25
25
|
"@atlaskit/editor-plugin-analytics": "^12.0.0",
|
|
26
26
|
"@atlaskit/editor-plugin-expand": "^13.0.0",
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
29
29
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
30
30
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
31
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
31
|
+
"@atlaskit/tmp-editor-statsig": "^107.1.0",
|
|
32
32
|
"@atlaskit/tokens": "^14.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
|
+
"@compiled/react": "^0.20.0",
|
|
34
35
|
"lodash": "^4.17.21",
|
|
35
36
|
"memoize-one": "^6.0.0",
|
|
36
37
|
"prosemirror-changeset": "^2.3.1"
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@atlaskit/adf-utils": "^20.0.0",
|
|
40
41
|
"@atlaskit/button": "^24.0.0",
|
|
41
42
|
"@atlaskit/css": "^1.0.0",
|
|
42
|
-
"@atlaskit/editor-core": "^221.
|
|
43
|
+
"@atlaskit/editor-core": "^221.1.0",
|
|
43
44
|
"@atlaskit/editor-json-transformer": "^9.0.0",
|
|
44
45
|
"@atlaskit/form": "^16.0.0",
|
|
45
46
|
"@atlaskit/primitives": "^20.0.0",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"react-intl": "^6.6.2"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^116.
|
|
56
|
+
"@atlaskit/editor-common": "^116.3.0",
|
|
56
57
|
"react": "^18.2.0"
|
|
57
58
|
},
|
|
58
59
|
"techstack": {
|