@atlaskit/editor-plugin-track-changes 2.1.1 → 2.3.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 +24 -0
- package/README.md +88 -0
- package/afm-cc/tsconfig.json +16 -2
- package/afm-jira/tsconfig.json +16 -2
- package/afm-post-office/tsconfig.json +41 -0
- package/afm-rovo-extension/tsconfig.json +41 -0
- package/afm-townsquare/tsconfig.json +41 -0
- package/build/tsconfig.json +20 -15
- package/dist/cjs/pm-plugins/main.js +60 -48
- package/dist/cjs/trackChangesPlugin.js +23 -4
- package/dist/cjs/ui/TrackChangesToolbarButton.js +39 -0
- package/dist/es2019/pm-plugins/main.js +41 -48
- package/dist/es2019/trackChangesPlugin.js +47 -28
- package/dist/es2019/ui/TrackChangesToolbarButton.js +35 -0
- package/dist/esm/pm-plugins/main.js +59 -47
- package/dist/esm/trackChangesPlugin.js +22 -4
- package/dist/esm/ui/TrackChangesToolbarButton.js +32 -0
- package/dist/types/pm-plugins/main.d.ts +10 -5
- package/dist/types/trackChangesPluginType.d.ts +20 -1
- package/dist/types/ui/TrackChangesToolbarButton.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +10 -5
- package/dist/types-ts4.5/trackChangesPluginType.d.ts +20 -1
- package/dist/types-ts4.5/ui/TrackChangesToolbarButton.d.ts +8 -0
- package/docs/0-intro.tsx +44 -7
- package/package.json +7 -4
- package/tsconfig.json +16 -10
- package/dist/cjs/pm-plugins/decorations.js +0 -55
- package/dist/es2019/pm-plugins/decorations.js +0 -48
- package/dist/esm/pm-plugins/decorations.js +0 -49
- package/dist/types/pm-plugins/decorations.d.ts +0 -26
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -26
package/docs/0-intro.tsx
CHANGED
|
@@ -30,11 +30,47 @@ The \`dependencies\`, \`configuration\`, \`state\`, \`actions\`, and \`commands\
|
|
|
30
30
|
below:
|
|
31
31
|
|
|
32
32
|
${code`
|
|
33
|
-
type TrackChangesPlugin = NextEditorPlugin<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
type TrackChangesPlugin = NextEditorPlugin<
|
|
34
|
+
'trackChanges',
|
|
35
|
+
{
|
|
36
|
+
commands: {
|
|
37
|
+
/**
|
|
38
|
+
* Toggles the displaying of changes in the editor.
|
|
39
|
+
*/
|
|
40
|
+
toggleChanges: EditorCommand;
|
|
41
|
+
};
|
|
42
|
+
dependencies: [
|
|
43
|
+
/**
|
|
44
|
+
* Primary toolbar plugin for registering the track changes button.
|
|
45
|
+
*/
|
|
46
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
47
|
+
/**
|
|
48
|
+
* Show diff plugin for showing the changes in a diff view.
|
|
49
|
+
*/
|
|
50
|
+
ShowDiffPlugin,
|
|
51
|
+
];
|
|
52
|
+
pluginConfiguration?: {
|
|
53
|
+
/**
|
|
54
|
+
* Whether the track changes button should be shown on the toolbar.
|
|
55
|
+
* Defaults to false.
|
|
56
|
+
*/
|
|
57
|
+
showOnToolbar?: boolean;
|
|
58
|
+
};
|
|
59
|
+
sharedState: {
|
|
60
|
+
/**
|
|
61
|
+
* Whether the track changes feature is currently displaying changes.
|
|
62
|
+
* Defaults to false.
|
|
63
|
+
*/
|
|
64
|
+
isDisplayingChanges: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* If there are changes in the document that determine if track changes button
|
|
67
|
+
* should be enabled.
|
|
68
|
+
* This will only be false initially before any changes in the session.
|
|
69
|
+
*/
|
|
70
|
+
isShowDiffAvailable: boolean;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
>;
|
|
38
74
|
`}
|
|
39
75
|
|
|
40
76
|
### Example Usage
|
|
@@ -51,7 +87,8 @@ import { basePlugin } from '@atlaskit/editor-plugins/base';
|
|
|
51
87
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
52
88
|
import { token } from '@atlaskit/tokens';
|
|
53
89
|
|
|
54
|
-
import {
|
|
90
|
+
import { showDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
|
|
91
|
+
import { trackChangesPlugin } from '@atlaskit/editor-plugin-track-changes';
|
|
55
92
|
|
|
56
93
|
const styles = cssMap({
|
|
57
94
|
aboveEditor: {
|
|
@@ -69,7 +106,7 @@ const styles = cssMap({
|
|
|
69
106
|
function Editor() {
|
|
70
107
|
const { preset, editorApi } = usePreset(
|
|
71
108
|
(builder) =>
|
|
72
|
-
builder.add(basePlugin).add(trackChangesPlugin),
|
|
109
|
+
builder.add(basePlugin).add(showDiffPlugin).add(trackChangesPlugin),
|
|
73
110
|
[],
|
|
74
111
|
);
|
|
75
112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-track-changes",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,16 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@atlaskit/button": "^23.3.0",
|
|
35
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
|
|
36
|
+
"@atlaskit/editor-plugin-show-diff": "0.0.0",
|
|
34
37
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
35
|
-
"@atlaskit/
|
|
38
|
+
"@atlaskit/icon-lab": "^5.2.0",
|
|
36
39
|
"@babel/runtime": "^7.0.0",
|
|
37
|
-
"
|
|
40
|
+
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
38
41
|
},
|
|
39
42
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^107.
|
|
43
|
+
"@atlaskit/editor-common": "^107.14.0",
|
|
41
44
|
"react": "^18.2.0"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"extends": "../../../tsconfig.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"examples/**/*.ts",
|
|
5
|
+
"examples/**/*.tsx",
|
|
6
|
+
"example-helpers/**/*.ts",
|
|
7
|
+
"example-helpers/**/*.tsx",
|
|
8
|
+
"src/**/*.ts",
|
|
9
|
+
"src/**/*.tsx",
|
|
10
|
+
"**/stories.ts",
|
|
11
|
+
"**/stories.tsx",
|
|
12
|
+
"**/stories/*.ts",
|
|
13
|
+
"**/stories/*.tsx",
|
|
14
|
+
"**/stories/**/*.ts",
|
|
15
|
+
"**/stories/**/*.tsx"
|
|
16
|
+
],
|
|
17
|
+
"compilerOptions": {}
|
|
12
18
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createInlineChangedDecoration = exports.createDeletedContentDecoration = void 0;
|
|
7
|
-
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
8
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
-
var style = (0, _lazyNodeView.convertToInlineCss)({
|
|
11
|
-
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
12
|
-
textDecoration: 'underline',
|
|
13
|
-
textDecorationStyle: 'dotted',
|
|
14
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
15
|
-
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
20
|
-
*
|
|
21
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
22
|
-
* @returns Prosemirror inline decoration
|
|
23
|
-
*/
|
|
24
|
-
var createInlineChangedDecoration = exports.createInlineChangedDecoration = function createInlineChangedDecoration(change) {
|
|
25
|
-
return _view.Decoration.inline(change.fromB, change.toB, {
|
|
26
|
-
style: style
|
|
27
|
-
}, {});
|
|
28
|
-
};
|
|
29
|
-
var deletedContentStyle = (0, _lazyNodeView.convertToInlineCss)({
|
|
30
|
-
color: "var(--ds-text-accent-gray, #44546F)",
|
|
31
|
-
textDecoration: 'line-through'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Creates a widget to represent the deleted content in the editor
|
|
36
|
-
*
|
|
37
|
-
* @param props.change Changeset "change" containing information about the change content + range
|
|
38
|
-
* @param props.doc Baseline doc to compare against
|
|
39
|
-
* @param props.tr The relevant transaction this decoration is being created against
|
|
40
|
-
* @returns Prosemirror widget decoration
|
|
41
|
-
*/
|
|
42
|
-
var createDeletedContentDecoration = exports.createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
43
|
-
var change = _ref.change,
|
|
44
|
-
doc = _ref.doc,
|
|
45
|
-
tr = _ref.tr;
|
|
46
|
-
var dom = document.createElement('span');
|
|
47
|
-
dom.setAttribute('style', deletedContentStyle);
|
|
48
|
-
dom.appendChild(_model.DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
|
|
49
|
-
|
|
50
|
-
// Widget decoration used for deletions as the content is not in the document
|
|
51
|
-
// and we want to display the deleted content with a style.
|
|
52
|
-
return _view.Decoration.widget(change.fromB, dom, {
|
|
53
|
-
marks: []
|
|
54
|
-
});
|
|
55
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
const style = convertToInlineCss({
|
|
5
|
-
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
6
|
-
textDecoration: 'underline',
|
|
7
|
-
textDecorationStyle: 'dotted',
|
|
8
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
9
|
-
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
14
|
-
*
|
|
15
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
16
|
-
* @returns Prosemirror inline decoration
|
|
17
|
-
*/
|
|
18
|
-
export const createInlineChangedDecoration = change => Decoration.inline(change.fromB, change.toB, {
|
|
19
|
-
style
|
|
20
|
-
}, {});
|
|
21
|
-
const deletedContentStyle = convertToInlineCss({
|
|
22
|
-
color: "var(--ds-text-accent-gray, #44546F)",
|
|
23
|
-
textDecoration: 'line-through'
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Creates a widget to represent the deleted content in the editor
|
|
28
|
-
*
|
|
29
|
-
* @param props.change Changeset "change" containing information about the change content + range
|
|
30
|
-
* @param props.doc Baseline doc to compare against
|
|
31
|
-
* @param props.tr The relevant transaction this decoration is being created against
|
|
32
|
-
* @returns Prosemirror widget decoration
|
|
33
|
-
*/
|
|
34
|
-
export const createDeletedContentDecoration = ({
|
|
35
|
-
change,
|
|
36
|
-
doc,
|
|
37
|
-
tr
|
|
38
|
-
}) => {
|
|
39
|
-
const dom = document.createElement('span');
|
|
40
|
-
dom.setAttribute('style', deletedContentStyle);
|
|
41
|
-
dom.appendChild(DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
|
|
42
|
-
|
|
43
|
-
// Widget decoration used for deletions as the content is not in the document
|
|
44
|
-
// and we want to display the deleted content with a style.
|
|
45
|
-
return Decoration.widget(change.fromB, dom, {
|
|
46
|
-
marks: []
|
|
47
|
-
});
|
|
48
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
var style = convertToInlineCss({
|
|
5
|
-
background: "var(--ds-background-accent-purple-subtlest, #F3F0FF)",
|
|
6
|
-
textDecoration: 'underline',
|
|
7
|
-
textDecorationStyle: 'dotted',
|
|
8
|
-
textDecorationThickness: "var(--ds-space-025, 2px)",
|
|
9
|
-
textDecorationColor: "var(--ds-border-accent-purple, #8270DB)"
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
14
|
-
*
|
|
15
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
16
|
-
* @returns Prosemirror inline decoration
|
|
17
|
-
*/
|
|
18
|
-
export var createInlineChangedDecoration = function createInlineChangedDecoration(change) {
|
|
19
|
-
return Decoration.inline(change.fromB, change.toB, {
|
|
20
|
-
style: style
|
|
21
|
-
}, {});
|
|
22
|
-
};
|
|
23
|
-
var deletedContentStyle = convertToInlineCss({
|
|
24
|
-
color: "var(--ds-text-accent-gray, #44546F)",
|
|
25
|
-
textDecoration: 'line-through'
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Creates a widget to represent the deleted content in the editor
|
|
30
|
-
*
|
|
31
|
-
* @param props.change Changeset "change" containing information about the change content + range
|
|
32
|
-
* @param props.doc Baseline doc to compare against
|
|
33
|
-
* @param props.tr The relevant transaction this decoration is being created against
|
|
34
|
-
* @returns Prosemirror widget decoration
|
|
35
|
-
*/
|
|
36
|
-
export var createDeletedContentDecoration = function createDeletedContentDecoration(_ref) {
|
|
37
|
-
var change = _ref.change,
|
|
38
|
-
doc = _ref.doc,
|
|
39
|
-
tr = _ref.tr;
|
|
40
|
-
var dom = document.createElement('span');
|
|
41
|
-
dom.setAttribute('style', deletedContentStyle);
|
|
42
|
-
dom.appendChild(DOMSerializer.fromSchema(tr.doc.type.schema).serializeFragment(doc.slice(change.fromA, change.toA).content));
|
|
43
|
-
|
|
44
|
-
// Widget decoration used for deletions as the content is not in the document
|
|
45
|
-
// and we want to display the deleted content with a style.
|
|
46
|
-
return Decoration.widget(change.fromB, dom, {
|
|
47
|
-
marks: []
|
|
48
|
-
});
|
|
49
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Change } from 'prosemirror-changeset';
|
|
2
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
/**
|
|
6
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
7
|
-
*
|
|
8
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
9
|
-
* @returns Prosemirror inline decoration
|
|
10
|
-
*/
|
|
11
|
-
export declare const createInlineChangedDecoration: (change: Change) => Decoration;
|
|
12
|
-
interface DeletedContentDecorationProps {
|
|
13
|
-
change: Change;
|
|
14
|
-
doc: PMNode;
|
|
15
|
-
tr: Transaction;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates a widget to represent the deleted content in the editor
|
|
19
|
-
*
|
|
20
|
-
* @param props.change Changeset "change" containing information about the change content + range
|
|
21
|
-
* @param props.doc Baseline doc to compare against
|
|
22
|
-
* @param props.tr The relevant transaction this decoration is being created against
|
|
23
|
-
* @returns Prosemirror widget decoration
|
|
24
|
-
*/
|
|
25
|
-
export declare const createDeletedContentDecoration: ({ change, doc, tr, }: DeletedContentDecorationProps) => Decoration;
|
|
26
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Change } from 'prosemirror-changeset';
|
|
2
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
/**
|
|
6
|
-
* Inline decoration used for insertions as the content already exists in the document
|
|
7
|
-
*
|
|
8
|
-
* @param change Changeset "change" containing information about the change content + range
|
|
9
|
-
* @returns Prosemirror inline decoration
|
|
10
|
-
*/
|
|
11
|
-
export declare const createInlineChangedDecoration: (change: Change) => Decoration;
|
|
12
|
-
interface DeletedContentDecorationProps {
|
|
13
|
-
change: Change;
|
|
14
|
-
doc: PMNode;
|
|
15
|
-
tr: Transaction;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates a widget to represent the deleted content in the editor
|
|
19
|
-
*
|
|
20
|
-
* @param props.change Changeset "change" containing information about the change content + range
|
|
21
|
-
* @param props.doc Baseline doc to compare against
|
|
22
|
-
* @param props.tr The relevant transaction this decoration is being created against
|
|
23
|
-
* @returns Prosemirror widget decoration
|
|
24
|
-
*/
|
|
25
|
-
export declare const createDeletedContentDecoration: ({ change, doc, tr, }: DeletedContentDecorationProps) => Decoration;
|
|
26
|
-
export {};
|