@atlaskit/editor-plugin-show-diff 1.0.1 → 2.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 +14 -0
- package/dist/cjs/pm-plugins/calculateDiffDecorations.js +6 -4
- package/dist/cjs/pm-plugins/decorations.js +36 -6
- package/dist/cjs/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/calculateDiffDecorations.js +6 -4
- package/dist/es2019/pm-plugins/decorations.js +32 -6
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/calculateDiffDecorations.js +6 -4
- package/dist/esm/pm-plugins/decorations.js +36 -6
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/types/pm-plugins/calculateDiffDecorations.d.ts +2 -1
- package/dist/types/pm-plugins/decorations.d.ts +3 -2
- package/dist/types/showDiffPluginType.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/calculateDiffDecorations.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +3 -2
- package/dist/types-ts4.5/showDiffPluginType.d.ts +6 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5eadb7f870272`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5eadb7f870272) -
|
|
8
|
+
[ux] Adds a new plugin configuration to adjust the styling scheme for diffs. By default it will
|
|
9
|
+
use standard, but traditional (for green + red) is also available.
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 1.0.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -15,7 +15,8 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
15
15
|
var calculateDiffDecorations = exports.calculateDiffDecorations = function calculateDiffDecorations(_ref) {
|
|
16
16
|
var state = _ref.state,
|
|
17
17
|
pluginState = _ref.pluginState,
|
|
18
|
-
nodeViewSerializer = _ref.nodeViewSerializer
|
|
18
|
+
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
19
|
+
colourScheme = _ref.colourScheme;
|
|
19
20
|
var originalDoc = pluginState.originalDoc,
|
|
20
21
|
steps = pluginState.steps;
|
|
21
22
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
@@ -49,13 +50,14 @@ var calculateDiffDecorations = exports.calculateDiffDecorations = function calcu
|
|
|
49
50
|
var decorations = [];
|
|
50
51
|
changes.forEach(function (change) {
|
|
51
52
|
if (change.inserted.length > 0) {
|
|
52
|
-
decorations.push((0, _decorations.createInlineChangedDecoration)(change));
|
|
53
|
+
decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme));
|
|
53
54
|
}
|
|
54
55
|
if (change.deleted.length > 0) {
|
|
55
56
|
var decoration = (0, _decorations.createDeletedContentDecoration)({
|
|
56
57
|
change: change,
|
|
57
58
|
doc: originalDoc,
|
|
58
|
-
nodeViewSerializer: nodeViewSerializer
|
|
59
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
60
|
+
colourScheme: colourScheme
|
|
59
61
|
});
|
|
60
62
|
if (decoration) {
|
|
61
63
|
decorations.push(decoration);
|
|
@@ -63,7 +65,7 @@ var calculateDiffDecorations = exports.calculateDiffDecorations = function calcu
|
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
(0, _markDecorations.getMarkChangeRanges)(steps).forEach(function (change) {
|
|
66
|
-
decorations.push((0, _decorations.createInlineChangedDecoration)(change));
|
|
68
|
+
decorations.push((0, _decorations.createInlineChangedDecoration)(change, colourScheme));
|
|
67
69
|
});
|
|
68
70
|
return _view.DecorationSet.empty.add(tr.doc, decorations);
|
|
69
71
|
};
|
|
@@ -6,22 +6,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createInlineChangedDecoration = exports.createDeletedContentDecoration = void 0;
|
|
7
7
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
|
-
var
|
|
9
|
+
var editingStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
10
10
|
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
11
11
|
textDecoration: 'underline',
|
|
12
12
|
textDecorationStyle: 'dotted',
|
|
13
13
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
14
14
|
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
15
15
|
});
|
|
16
|
+
var traditionalInsertStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
17
|
+
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
18
|
+
textDecoration: 'underline',
|
|
19
|
+
textDecorationStyle: 'solid',
|
|
20
|
+
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
21
|
+
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
22
|
+
});
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* Inline decoration used for insertions as the content already exists in the document
|
|
18
26
|
*
|
|
19
27
|
* @param change Changeset "change" containing information about the change content + range
|
|
20
28
|
* @returns Prosemirror inline decoration
|
|
21
29
|
*/
|
|
22
|
-
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change) {
|
|
30
|
+
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change, colourScheme) {
|
|
23
31
|
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
24
|
-
style:
|
|
32
|
+
style: colourScheme === 'traditional' ? traditionalInsertStyle : editingStyle,
|
|
25
33
|
'data-testid': 'show-diff-changed-decoration'
|
|
26
34
|
}, {});
|
|
27
35
|
};
|
|
@@ -40,10 +48,32 @@ var deletedContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
|
40
48
|
pointerEvents: 'none',
|
|
41
49
|
zIndex: 1
|
|
42
50
|
});
|
|
51
|
+
var deletedTraditionalContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
52
|
+
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
53
|
+
textDecoration: 'line-through',
|
|
54
|
+
position: 'relative',
|
|
55
|
+
opacity: 1
|
|
56
|
+
});
|
|
57
|
+
var deletedTraditionalContentStyleUnbounded = (0, _lazyNodeView.convertToInlineCss)({
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: '50%',
|
|
60
|
+
width: '100%',
|
|
61
|
+
display: 'inline-block',
|
|
62
|
+
borderTop: "1px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
63
|
+
pointerEvents: 'none',
|
|
64
|
+
zIndex: 1
|
|
65
|
+
});
|
|
66
|
+
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
|
|
67
|
+
return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
68
|
+
};
|
|
69
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
|
|
70
|
+
return colourScheme === 'traditional' ? deletedTraditionalContentStyle : deletedContentStyle;
|
|
71
|
+
};
|
|
43
72
|
var createDeletedContentDecoration = exports.createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
44
73
|
var change = _ref.change,
|
|
45
74
|
doc = _ref.doc,
|
|
46
|
-
nodeViewSerializer = _ref.nodeViewSerializer
|
|
75
|
+
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
76
|
+
colourScheme = _ref.colourScheme;
|
|
47
77
|
var slice = doc.slice(change.fromA, change.toA);
|
|
48
78
|
if (slice.content.content.length === 0) {
|
|
49
79
|
return;
|
|
@@ -60,7 +90,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
60
90
|
|
|
61
91
|
// For non-table content, use the existing span wrapper approach
|
|
62
92
|
var dom = document.createElement('span');
|
|
63
|
-
dom.setAttribute('style',
|
|
93
|
+
dom.setAttribute('style', getDeletedContentStyle(colourScheme));
|
|
64
94
|
|
|
65
95
|
/*
|
|
66
96
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -75,7 +105,7 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
75
105
|
wrapper.style.position = 'relative';
|
|
76
106
|
wrapper.style.width = 'fit-content';
|
|
77
107
|
var strikethrough = document.createElement('span');
|
|
78
|
-
strikethrough.setAttribute('style',
|
|
108
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
|
|
79
109
|
wrapper.append(strikethrough);
|
|
80
110
|
return wrapper;
|
|
81
111
|
};
|
|
@@ -48,7 +48,8 @@ var createPlugin = exports.createPlugin = function createPlugin(config) {
|
|
|
48
48
|
var decorations = (0, _calculateDiffDecorations.calculateDiffDecorations)({
|
|
49
49
|
state: newState,
|
|
50
50
|
pluginState: newPluginState,
|
|
51
|
-
nodeViewSerializer: nodeViewSerializer
|
|
51
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
52
|
+
colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme
|
|
52
53
|
});
|
|
53
54
|
// Update the decorations
|
|
54
55
|
newPluginState.decorations = decorations;
|
|
@@ -6,7 +6,8 @@ import { getMarkChangeRanges } from './markDecorations';
|
|
|
6
6
|
export const calculateDiffDecorations = ({
|
|
7
7
|
state,
|
|
8
8
|
pluginState,
|
|
9
|
-
nodeViewSerializer
|
|
9
|
+
nodeViewSerializer,
|
|
10
|
+
colourScheme
|
|
10
11
|
}) => {
|
|
11
12
|
const {
|
|
12
13
|
originalDoc,
|
|
@@ -36,13 +37,14 @@ export const calculateDiffDecorations = ({
|
|
|
36
37
|
const decorations = [];
|
|
37
38
|
changes.forEach(change => {
|
|
38
39
|
if (change.inserted.length > 0) {
|
|
39
|
-
decorations.push(createInlineChangedDecoration(change));
|
|
40
|
+
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
40
41
|
}
|
|
41
42
|
if (change.deleted.length > 0) {
|
|
42
43
|
const decoration = createDeletedContentDecoration({
|
|
43
44
|
change,
|
|
44
45
|
doc: originalDoc,
|
|
45
|
-
nodeViewSerializer
|
|
46
|
+
nodeViewSerializer,
|
|
47
|
+
colourScheme
|
|
46
48
|
});
|
|
47
49
|
if (decoration) {
|
|
48
50
|
decorations.push(decoration);
|
|
@@ -50,7 +52,7 @@ export const calculateDiffDecorations = ({
|
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
getMarkChangeRanges(steps).forEach(change => {
|
|
53
|
-
decorations.push(createInlineChangedDecoration(change));
|
|
55
|
+
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
54
56
|
});
|
|
55
57
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
56
58
|
};
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
const
|
|
3
|
+
const editingStyle = convertToInlineCss({
|
|
4
4
|
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
5
5
|
textDecoration: 'underline',
|
|
6
6
|
textDecorationStyle: 'dotted',
|
|
7
7
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
8
8
|
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
9
9
|
});
|
|
10
|
+
const traditionalInsertStyle = convertToInlineCss({
|
|
11
|
+
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
12
|
+
textDecoration: 'underline',
|
|
13
|
+
textDecorationStyle: 'solid',
|
|
14
|
+
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
15
|
+
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
16
|
+
});
|
|
17
|
+
|
|
10
18
|
/**
|
|
11
19
|
* Inline decoration used for insertions as the content already exists in the document
|
|
12
20
|
*
|
|
13
21
|
* @param change Changeset "change" containing information about the change content + range
|
|
14
22
|
* @returns Prosemirror inline decoration
|
|
15
23
|
*/
|
|
16
|
-
export const createInlineChangedDecoration = change => Decoration.inline(change.fromB, change.toB, {
|
|
17
|
-
style,
|
|
24
|
+
export const createInlineChangedDecoration = (change, colourScheme) => Decoration.inline(change.fromB, change.toB, {
|
|
25
|
+
style: colourScheme === 'traditional' ? traditionalInsertStyle : editingStyle,
|
|
18
26
|
'data-testid': 'show-diff-changed-decoration'
|
|
19
27
|
}, {});
|
|
20
28
|
const deletedContentStyle = convertToInlineCss({
|
|
@@ -32,10 +40,28 @@ const deletedContentStyleUnbounded = convertToInlineCss({
|
|
|
32
40
|
pointerEvents: 'none',
|
|
33
41
|
zIndex: 1
|
|
34
42
|
});
|
|
43
|
+
const deletedTraditionalContentStyle = convertToInlineCss({
|
|
44
|
+
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
45
|
+
textDecoration: 'line-through',
|
|
46
|
+
position: 'relative',
|
|
47
|
+
opacity: 1
|
|
48
|
+
});
|
|
49
|
+
const deletedTraditionalContentStyleUnbounded = convertToInlineCss({
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
top: '50%',
|
|
52
|
+
width: '100%',
|
|
53
|
+
display: 'inline-block',
|
|
54
|
+
borderTop: `1px solid ${"var(--ds-border-accent-red, #E2483D)"}`,
|
|
55
|
+
pointerEvents: 'none',
|
|
56
|
+
zIndex: 1
|
|
57
|
+
});
|
|
58
|
+
const getDeletedContentStyleUnbounded = colourScheme => colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
59
|
+
const getDeletedContentStyle = colourScheme => colourScheme === 'traditional' ? deletedTraditionalContentStyle : deletedContentStyle;
|
|
35
60
|
export const createDeletedContentDecoration = ({
|
|
36
61
|
change,
|
|
37
62
|
doc,
|
|
38
|
-
nodeViewSerializer
|
|
63
|
+
nodeViewSerializer,
|
|
64
|
+
colourScheme
|
|
39
65
|
}) => {
|
|
40
66
|
const slice = doc.slice(change.fromA, change.toA);
|
|
41
67
|
if (slice.content.content.length === 0) {
|
|
@@ -49,7 +75,7 @@ export const createDeletedContentDecoration = ({
|
|
|
49
75
|
|
|
50
76
|
// For non-table content, use the existing span wrapper approach
|
|
51
77
|
const dom = document.createElement('span');
|
|
52
|
-
dom.setAttribute('style',
|
|
78
|
+
dom.setAttribute('style', getDeletedContentStyle(colourScheme));
|
|
53
79
|
|
|
54
80
|
/*
|
|
55
81
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -64,7 +90,7 @@ export const createDeletedContentDecoration = ({
|
|
|
64
90
|
wrapper.style.position = 'relative';
|
|
65
91
|
wrapper.style.width = 'fit-content';
|
|
66
92
|
const strikethrough = document.createElement('span');
|
|
67
|
-
strikethrough.setAttribute('style',
|
|
93
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
|
|
68
94
|
wrapper.append(strikethrough);
|
|
69
95
|
return wrapper;
|
|
70
96
|
};
|
|
@@ -40,7 +40,8 @@ export const createPlugin = config => {
|
|
|
40
40
|
const decorations = calculateDiffDecorations({
|
|
41
41
|
state: newState,
|
|
42
42
|
pluginState: newPluginState,
|
|
43
|
-
nodeViewSerializer
|
|
43
|
+
nodeViewSerializer,
|
|
44
|
+
colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme
|
|
44
45
|
});
|
|
45
46
|
// Update the decorations
|
|
46
47
|
newPluginState.decorations = decorations;
|
|
@@ -9,7 +9,8 @@ import { getMarkChangeRanges } from './markDecorations';
|
|
|
9
9
|
export var calculateDiffDecorations = function calculateDiffDecorations(_ref) {
|
|
10
10
|
var state = _ref.state,
|
|
11
11
|
pluginState = _ref.pluginState,
|
|
12
|
-
nodeViewSerializer = _ref.nodeViewSerializer
|
|
12
|
+
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
13
|
+
colourScheme = _ref.colourScheme;
|
|
13
14
|
var originalDoc = pluginState.originalDoc,
|
|
14
15
|
steps = pluginState.steps;
|
|
15
16
|
if (!originalDoc || !pluginState.isDisplayingChanges) {
|
|
@@ -43,13 +44,14 @@ export var calculateDiffDecorations = function calculateDiffDecorations(_ref) {
|
|
|
43
44
|
var decorations = [];
|
|
44
45
|
changes.forEach(function (change) {
|
|
45
46
|
if (change.inserted.length > 0) {
|
|
46
|
-
decorations.push(createInlineChangedDecoration(change));
|
|
47
|
+
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
47
48
|
}
|
|
48
49
|
if (change.deleted.length > 0) {
|
|
49
50
|
var decoration = createDeletedContentDecoration({
|
|
50
51
|
change: change,
|
|
51
52
|
doc: originalDoc,
|
|
52
|
-
nodeViewSerializer: nodeViewSerializer
|
|
53
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
54
|
+
colourScheme: colourScheme
|
|
53
55
|
});
|
|
54
56
|
if (decoration) {
|
|
55
57
|
decorations.push(decoration);
|
|
@@ -57,7 +59,7 @@ export var calculateDiffDecorations = function calculateDiffDecorations(_ref) {
|
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
61
|
getMarkChangeRanges(steps).forEach(function (change) {
|
|
60
|
-
decorations.push(createInlineChangedDecoration(change));
|
|
62
|
+
decorations.push(createInlineChangedDecoration(change, colourScheme));
|
|
61
63
|
});
|
|
62
64
|
return DecorationSet.empty.add(tr.doc, decorations);
|
|
63
65
|
};
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
var
|
|
3
|
+
var editingStyle = convertToInlineCss({
|
|
4
4
|
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
5
5
|
textDecoration: 'underline',
|
|
6
6
|
textDecorationStyle: 'dotted',
|
|
7
7
|
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
8
8
|
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
9
9
|
});
|
|
10
|
+
var traditionalInsertStyle = convertToInlineCss({
|
|
11
|
+
background: "var(--ds-background-accent-green-subtlest, #DCFFF1)",
|
|
12
|
+
textDecoration: 'underline',
|
|
13
|
+
textDecorationStyle: 'solid',
|
|
14
|
+
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
15
|
+
textDecorationColor: "var(--ds-border-accent-green, #22A06B)"
|
|
16
|
+
});
|
|
17
|
+
|
|
10
18
|
/**
|
|
11
19
|
* Inline decoration used for insertions as the content already exists in the document
|
|
12
20
|
*
|
|
13
21
|
* @param change Changeset "change" containing information about the change content + range
|
|
14
22
|
* @returns Prosemirror inline decoration
|
|
15
23
|
*/
|
|
16
|
-
export var createInlineChangedDecoration = function createInlineChangedDecoration(change) {
|
|
24
|
+
export var createInlineChangedDecoration = function createInlineChangedDecoration(change, colourScheme) {
|
|
17
25
|
return Decoration.inline(change.fromB, change.toB, {
|
|
18
|
-
style:
|
|
26
|
+
style: colourScheme === 'traditional' ? traditionalInsertStyle : editingStyle,
|
|
19
27
|
'data-testid': 'show-diff-changed-decoration'
|
|
20
28
|
}, {});
|
|
21
29
|
};
|
|
@@ -34,10 +42,32 @@ var deletedContentStyleUnbounded = convertToInlineCss({
|
|
|
34
42
|
pointerEvents: 'none',
|
|
35
43
|
zIndex: 1
|
|
36
44
|
});
|
|
45
|
+
var deletedTraditionalContentStyle = convertToInlineCss({
|
|
46
|
+
textDecorationColor: "var(--ds-border-accent-red, #E2483D)",
|
|
47
|
+
textDecoration: 'line-through',
|
|
48
|
+
position: 'relative',
|
|
49
|
+
opacity: 1
|
|
50
|
+
});
|
|
51
|
+
var deletedTraditionalContentStyleUnbounded = convertToInlineCss({
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
top: '50%',
|
|
54
|
+
width: '100%',
|
|
55
|
+
display: 'inline-block',
|
|
56
|
+
borderTop: "1px solid ".concat("var(--ds-border-accent-red, #E2483D)"),
|
|
57
|
+
pointerEvents: 'none',
|
|
58
|
+
zIndex: 1
|
|
59
|
+
});
|
|
60
|
+
var getDeletedContentStyleUnbounded = function getDeletedContentStyleUnbounded(colourScheme) {
|
|
61
|
+
return colourScheme === 'traditional' ? deletedTraditionalContentStyleUnbounded : deletedContentStyleUnbounded;
|
|
62
|
+
};
|
|
63
|
+
var getDeletedContentStyle = function getDeletedContentStyle(colourScheme) {
|
|
64
|
+
return colourScheme === 'traditional' ? deletedTraditionalContentStyle : deletedContentStyle;
|
|
65
|
+
};
|
|
37
66
|
export var createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
38
67
|
var change = _ref.change,
|
|
39
68
|
doc = _ref.doc,
|
|
40
|
-
nodeViewSerializer = _ref.nodeViewSerializer
|
|
69
|
+
nodeViewSerializer = _ref.nodeViewSerializer,
|
|
70
|
+
colourScheme = _ref.colourScheme;
|
|
41
71
|
var slice = doc.slice(change.fromA, change.toA);
|
|
42
72
|
if (slice.content.content.length === 0) {
|
|
43
73
|
return;
|
|
@@ -54,7 +84,7 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
54
84
|
|
|
55
85
|
// For non-table content, use the existing span wrapper approach
|
|
56
86
|
var dom = document.createElement('span');
|
|
57
|
-
dom.setAttribute('style',
|
|
87
|
+
dom.setAttribute('style', getDeletedContentStyle(colourScheme));
|
|
58
88
|
|
|
59
89
|
/*
|
|
60
90
|
* The thinking is we separate out the fragment we got from doc.slice
|
|
@@ -69,7 +99,7 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
69
99
|
wrapper.style.position = 'relative';
|
|
70
100
|
wrapper.style.width = 'fit-content';
|
|
71
101
|
var strikethrough = document.createElement('span');
|
|
72
|
-
strikethrough.setAttribute('style',
|
|
102
|
+
strikethrough.setAttribute('style', getDeletedContentStyleUnbounded(colourScheme));
|
|
73
103
|
wrapper.append(strikethrough);
|
|
74
104
|
return wrapper;
|
|
75
105
|
};
|
|
@@ -41,7 +41,8 @@ export var createPlugin = function createPlugin(config) {
|
|
|
41
41
|
var decorations = calculateDiffDecorations({
|
|
42
42
|
state: newState,
|
|
43
43
|
pluginState: newPluginState,
|
|
44
|
-
nodeViewSerializer: nodeViewSerializer
|
|
44
|
+
nodeViewSerializer: nodeViewSerializer,
|
|
45
|
+
colourScheme: config === null || config === void 0 ? void 0 : config.colourScheme
|
|
45
46
|
});
|
|
46
47
|
// Update the decorations
|
|
47
48
|
newPluginState.decorations = decorations;
|
|
@@ -3,7 +3,8 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { ShowDiffPluginState } from './main';
|
|
5
5
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
6
|
-
export declare const calculateDiffDecorations: ({ state, pluginState, nodeViewSerializer, }: {
|
|
6
|
+
export declare const calculateDiffDecorations: ({ state, pluginState, nodeViewSerializer, colourScheme, }: {
|
|
7
|
+
colourScheme?: "standard" | "traditional";
|
|
7
8
|
nodeViewSerializer: NodeViewSerializer;
|
|
8
9
|
pluginState: Omit<ShowDiffPluginState, "decorations">;
|
|
9
10
|
state: EditorState;
|
|
@@ -11,11 +11,12 @@ import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
11
11
|
export declare const createInlineChangedDecoration: (change: {
|
|
12
12
|
fromB: number;
|
|
13
13
|
toB: number;
|
|
14
|
-
}) => Decoration;
|
|
14
|
+
}, colourScheme?: "standard" | "traditional") => Decoration;
|
|
15
15
|
interface DeletedContentDecorationProps {
|
|
16
16
|
change: Change;
|
|
17
|
+
colourScheme?: 'standard' | 'traditional';
|
|
17
18
|
doc: PMNode;
|
|
18
19
|
nodeViewSerializer: NodeViewSerializer;
|
|
19
20
|
}
|
|
20
|
-
export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, }: DeletedContentDecorationProps) => Decoration | undefined;
|
|
21
|
+
export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colourScheme, }: DeletedContentDecorationProps) => Decoration | undefined;
|
|
21
22
|
export {};
|
|
@@ -4,6 +4,12 @@ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
|
4
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
export type DiffParams = {
|
|
7
|
+
/**
|
|
8
|
+
* Color scheme to use for displaying diffs.
|
|
9
|
+
* 'standard' (default) uses purple for highlighting changes
|
|
10
|
+
* 'traditional' uses green for additions and red for deletions
|
|
11
|
+
*/
|
|
12
|
+
colourScheme?: 'standard' | 'traditional';
|
|
7
13
|
originalDoc: JSONDocNode;
|
|
8
14
|
/**
|
|
9
15
|
* Prosemirror steps. This is used to calculate and show the diff in the editor
|
|
@@ -3,7 +3,8 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { ShowDiffPluginState } from './main';
|
|
5
5
|
import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
6
|
-
export declare const calculateDiffDecorations: ({ state, pluginState, nodeViewSerializer, }: {
|
|
6
|
+
export declare const calculateDiffDecorations: ({ state, pluginState, nodeViewSerializer, colourScheme, }: {
|
|
7
|
+
colourScheme?: "standard" | "traditional";
|
|
7
8
|
nodeViewSerializer: NodeViewSerializer;
|
|
8
9
|
pluginState: Omit<ShowDiffPluginState, "decorations">;
|
|
9
10
|
state: EditorState;
|
|
@@ -11,11 +11,12 @@ import type { NodeViewSerializer } from './NodeViewSerializer';
|
|
|
11
11
|
export declare const createInlineChangedDecoration: (change: {
|
|
12
12
|
fromB: number;
|
|
13
13
|
toB: number;
|
|
14
|
-
}) => Decoration;
|
|
14
|
+
}, colourScheme?: "standard" | "traditional") => Decoration;
|
|
15
15
|
interface DeletedContentDecorationProps {
|
|
16
16
|
change: Change;
|
|
17
|
+
colourScheme?: 'standard' | 'traditional';
|
|
17
18
|
doc: PMNode;
|
|
18
19
|
nodeViewSerializer: NodeViewSerializer;
|
|
19
20
|
}
|
|
20
|
-
export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, }: DeletedContentDecorationProps) => Decoration | undefined;
|
|
21
|
+
export declare const createDeletedContentDecoration: ({ change, doc, nodeViewSerializer, colourScheme, }: DeletedContentDecorationProps) => Decoration | undefined;
|
|
21
22
|
export {};
|
|
@@ -4,6 +4,12 @@ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
|
4
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
export type DiffParams = {
|
|
7
|
+
/**
|
|
8
|
+
* Color scheme to use for displaying diffs.
|
|
9
|
+
* 'standard' (default) uses purple for highlighting changes
|
|
10
|
+
* 'traditional' uses green for additions and red for deletions
|
|
11
|
+
*/
|
|
12
|
+
colourScheme?: 'standard' | 'traditional';
|
|
7
13
|
originalDoc: JSONDocNode;
|
|
8
14
|
/**
|
|
9
15
|
* Prosemirror steps. This is used to calculate and show the diff in the editor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
32
|
-
"@atlaskit/tokens": "^6.
|
|
32
|
+
"@atlaskit/tokens": "^6.3.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"prosemirror-changeset": "^2.2.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
37
|
+
"@atlaskit/editor-common": "^109.6.0",
|
|
38
38
|
"react": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"techstack": {
|