@atlaskit/editor-plugin-track-changes 2.1.0 → 2.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 +20 -0
- package/afm-cc/tsconfig.json +10 -1
- package/afm-jira/tsconfig.json +4 -34
- package/afm-post-office/tsconfig.json +12 -3
- package/afm-rovo-extension/tsconfig.json +36 -0
- package/afm-townsquare/tsconfig.json +36 -0
- package/dist/cjs/pm-plugins/main.js +60 -48
- package/dist/cjs/trackChangesPlugin.js +20 -4
- package/dist/cjs/ui/TrackChangesToolbarButton.js +35 -0
- package/dist/es2019/pm-plugins/main.js +41 -48
- package/dist/es2019/trackChangesPlugin.js +44 -28
- package/dist/es2019/ui/TrackChangesToolbarButton.js +30 -0
- package/dist/esm/pm-plugins/main.js +59 -47
- package/dist/esm/trackChangesPlugin.js +19 -4
- package/dist/esm/ui/TrackChangesToolbarButton.js +28 -0
- package/dist/types/pm-plugins/main.d.ts +10 -5
- package/dist/types/trackChangesPluginType.d.ts +4 -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 +7 -1
- package/dist/types-ts4.5/ui/TrackChangesToolbarButton.d.ts +8 -0
- package/package.json +7 -5
- package/afm-volt/tsconfig.json +0 -27
- 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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton } from '@atlaskit/button/new';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import HistoryIcon from '@atlaskit/icon-lab/core/history';
|
|
5
|
+
export const TrackChangesToolbarButton = ({
|
|
6
|
+
api
|
|
7
|
+
}) => {
|
|
8
|
+
var _api$trackChanges;
|
|
9
|
+
const {
|
|
10
|
+
isDisplayingChanges,
|
|
11
|
+
isShowDiffAvailable
|
|
12
|
+
} = useSharedPluginStateWithSelector(api, ['trackChanges'], states => {
|
|
13
|
+
var _states$trackChangesS, _states$trackChangesS2;
|
|
14
|
+
return {
|
|
15
|
+
isDisplayingChanges: (_states$trackChangesS = states.trackChangesState) === null || _states$trackChangesS === void 0 ? void 0 : _states$trackChangesS.isDisplayingChanges,
|
|
16
|
+
isShowDiffAvailable: (_states$trackChangesS2 = states.trackChangesState) === null || _states$trackChangesS2 === void 0 ? void 0 : _states$trackChangesS2.isShowDiffAvailable
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const handleClick = React.useCallback(() => {
|
|
20
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.trackChanges.commands.toggleChanges);
|
|
21
|
+
}, [api === null || api === void 0 ? void 0 : (_api$trackChanges = api.trackChanges) === null || _api$trackChanges === void 0 ? void 0 : _api$trackChanges.commands, api === null || api === void 0 ? void 0 : api.core.actions]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
23
|
+
icon: HistoryIcon,
|
|
24
|
+
label: "Track Changes",
|
|
25
|
+
appearance: "subtle",
|
|
26
|
+
isDisabled: !isShowDiffAvailable,
|
|
27
|
+
isSelected: isDisplayingChanges,
|
|
28
|
+
onClick: handleClick
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -1,31 +1,54 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
10
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
11
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
12
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
8
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import { createInlineChangedDecoration, createDeletedContentDecoration } from './decorations';
|
|
10
13
|
import { TOGGLE_TRACK_CHANGES_ACTION as ACTION } from './types';
|
|
11
14
|
export var trackChangesPluginKey = new PluginKey('trackChangesPlugin');
|
|
12
|
-
export var
|
|
15
|
+
export var InvertableStep = /*#__PURE__*/_createClass(function InvertableStep(step, inverted) {
|
|
16
|
+
_classCallCheck(this, InvertableStep);
|
|
17
|
+
this.step = step;
|
|
18
|
+
this.inverted = inverted;
|
|
19
|
+
});
|
|
20
|
+
var getBaselineFromSteps = function getBaselineFromSteps(doc, steps) {
|
|
21
|
+
var _iterator = _createForOfIteratorHelper(steps.slice().reverse()),
|
|
22
|
+
_step;
|
|
23
|
+
try {
|
|
24
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
25
|
+
var _step2 = _step.value;
|
|
26
|
+
var result = _step2.inverted.apply(doc);
|
|
27
|
+
if (result.failed === null && result.doc) {
|
|
28
|
+
doc = result.doc;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
35
|
+
}
|
|
36
|
+
return doc;
|
|
37
|
+
};
|
|
38
|
+
export var createTrackChangesPlugin = function createTrackChangesPlugin(api) {
|
|
13
39
|
// Mark the state to be reset on next time the document has a meaningful change
|
|
14
40
|
var resetBaseline = false;
|
|
15
41
|
return new SafePlugin({
|
|
16
42
|
key: trackChangesPluginKey,
|
|
17
43
|
state: {
|
|
18
|
-
init: function init(
|
|
19
|
-
var doc = _ref.doc;
|
|
44
|
+
init: function init() {
|
|
20
45
|
return {
|
|
21
|
-
|
|
46
|
+
steps: [],
|
|
22
47
|
shouldChangesBeDisplayed: false,
|
|
23
|
-
isShowDiffAvailable: false
|
|
24
|
-
baselineDoc: doc,
|
|
25
|
-
numOfChanges: 0
|
|
48
|
+
isShowDiffAvailable: false
|
|
26
49
|
};
|
|
27
50
|
},
|
|
28
|
-
apply: function apply(tr, state
|
|
51
|
+
apply: function apply(tr, state) {
|
|
29
52
|
var metadata = tr.getMeta(trackChangesPluginKey);
|
|
30
53
|
if (metadata && metadata.action === ACTION.TOGGLE_TRACK_CHANGES) {
|
|
31
54
|
resetBaseline = true;
|
|
@@ -40,53 +63,42 @@ export var createTrackChangesPlugin = function createTrackChangesPlugin() {
|
|
|
40
63
|
// If no document changes, return the old changeSet
|
|
41
64
|
return state;
|
|
42
65
|
}
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
tr.docs[0].content // The old document
|
|
48
|
-
) : state.changes.addSteps(tr.doc,
|
|
49
|
-
// The new document
|
|
50
|
-
tr.mapping.maps,
|
|
51
|
-
// The set of changes
|
|
52
|
-
tr.docs[0].content // The old document
|
|
53
|
-
);
|
|
54
|
-
var baselineDoc = resetBaseline ? tr.docs[0] : state.baselineDoc;
|
|
66
|
+
var newSteps = tr.steps.map(function (step, idx) {
|
|
67
|
+
return new InvertableStep(step, step.invert(tr.docs[idx]));
|
|
68
|
+
});
|
|
69
|
+
var steps = resetBaseline ? newSteps : [].concat(_toConsumableArray(state.steps), _toConsumableArray(newSteps));
|
|
55
70
|
resetBaseline = false;
|
|
56
71
|
|
|
57
72
|
// Create a new ChangeSet based on document changes
|
|
58
73
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
59
|
-
|
|
74
|
+
steps: steps,
|
|
60
75
|
shouldChangesBeDisplayed: false,
|
|
61
|
-
changes: changes,
|
|
62
76
|
isShowDiffAvailable: true
|
|
63
77
|
});
|
|
64
78
|
}
|
|
65
79
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
decorations.push(createDeletedContentDecoration({
|
|
82
|
-
change: change,
|
|
83
|
-
doc: pluginState === null || pluginState === void 0 ? void 0 : pluginState.baselineDoc,
|
|
84
|
-
tr: tr
|
|
80
|
+
view: function view() {
|
|
81
|
+
return {
|
|
82
|
+
update: function update(view, prevState) {
|
|
83
|
+
var _trackChangesPluginKe;
|
|
84
|
+
var prevShouldChangesBeDisplayed = (_trackChangesPluginKe = trackChangesPluginKey.getState(prevState)) === null || _trackChangesPluginKe === void 0 ? void 0 : _trackChangesPluginKe.shouldChangesBeDisplayed;
|
|
85
|
+
var currentPluginState = trackChangesPluginKey.getState(view.state);
|
|
86
|
+
var currentShouldChangesBeDisplayed = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.shouldChangesBeDisplayed;
|
|
87
|
+
if (prevShouldChangesBeDisplayed === false && currentShouldChangesBeDisplayed === true) {
|
|
88
|
+
var _currentPluginState$s, _api$core, _api$showDiff;
|
|
89
|
+
var steps = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.steps) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : [];
|
|
90
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 || (_api$showDiff = _api$showDiff.commands) === null || _api$showDiff === void 0 ? void 0 : _api$showDiff.showDiff({
|
|
91
|
+
originalDoc: getBaselineFromSteps(view.state.doc, steps),
|
|
92
|
+
steps: steps.map(function (s) {
|
|
93
|
+
return s.step;
|
|
94
|
+
})
|
|
85
95
|
}));
|
|
96
|
+
} else if (currentShouldChangesBeDisplayed === false && prevShouldChangesBeDisplayed === true) {
|
|
97
|
+
var _api$core2, _api$showDiff2;
|
|
98
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$showDiff2 = api.showDiff) === null || _api$showDiff2 === void 0 || (_api$showDiff2 = _api$showDiff2.commands) === null || _api$showDiff2 === void 0 ? void 0 : _api$showDiff2.hideDiff);
|
|
86
99
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
90
102
|
}
|
|
91
103
|
});
|
|
92
104
|
};
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { createTrackChangesPlugin, trackChangesPluginKey } from './pm-plugins/main';
|
|
2
3
|
import { TOGGLE_TRACK_CHANGES_ACTION as ACTION } from './pm-plugins/types';
|
|
3
|
-
|
|
4
|
+
import { TrackChangesToolbarButton } from './ui/TrackChangesToolbarButton';
|
|
5
|
+
export var trackChangesPlugin = function trackChangesPlugin(_ref) {
|
|
6
|
+
var _api$primaryToolbar;
|
|
7
|
+
var api = _ref.api;
|
|
8
|
+
var primaryToolbarComponent = function primaryToolbarComponent() {
|
|
9
|
+
return /*#__PURE__*/React.createElement(TrackChangesToolbarButton, {
|
|
10
|
+
api: api
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || (_api$primaryToolbar = _api$primaryToolbar.actions) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.registerComponent({
|
|
14
|
+
name: 'trackChanges',
|
|
15
|
+
component: primaryToolbarComponent
|
|
16
|
+
});
|
|
4
17
|
return {
|
|
5
18
|
name: 'trackChanges',
|
|
6
19
|
pmPlugins: function pmPlugins() {
|
|
7
20
|
return [{
|
|
8
21
|
name: 'trackChangesPlugin',
|
|
9
|
-
plugin:
|
|
22
|
+
plugin: function plugin() {
|
|
23
|
+
return createTrackChangesPlugin(api);
|
|
24
|
+
}
|
|
10
25
|
}];
|
|
11
26
|
},
|
|
12
27
|
commands: {
|
|
13
|
-
toggleChanges: function toggleChanges(
|
|
14
|
-
var tr =
|
|
28
|
+
toggleChanges: function toggleChanges(_ref2) {
|
|
29
|
+
var tr = _ref2.tr;
|
|
15
30
|
return tr.setMeta(trackChangesPluginKey, {
|
|
16
31
|
action: ACTION.TOGGLE_TRACK_CHANGES
|
|
17
32
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton } from '@atlaskit/button/new';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import HistoryIcon from '@atlaskit/icon-lab/core/history';
|
|
5
|
+
export var TrackChangesToolbarButton = function TrackChangesToolbarButton(_ref) {
|
|
6
|
+
var _api$trackChanges;
|
|
7
|
+
var api = _ref.api;
|
|
8
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['trackChanges'], function (states) {
|
|
9
|
+
var _states$trackChangesS, _states$trackChangesS2;
|
|
10
|
+
return {
|
|
11
|
+
isDisplayingChanges: (_states$trackChangesS = states.trackChangesState) === null || _states$trackChangesS === void 0 ? void 0 : _states$trackChangesS.isDisplayingChanges,
|
|
12
|
+
isShowDiffAvailable: (_states$trackChangesS2 = states.trackChangesState) === null || _states$trackChangesS2 === void 0 ? void 0 : _states$trackChangesS2.isShowDiffAvailable
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
isDisplayingChanges = _useSharedPluginState.isDisplayingChanges,
|
|
16
|
+
isShowDiffAvailable = _useSharedPluginState.isShowDiffAvailable;
|
|
17
|
+
var handleClick = React.useCallback(function () {
|
|
18
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.trackChanges.commands.toggleChanges);
|
|
19
|
+
}, [api === null || api === void 0 || (_api$trackChanges = api.trackChanges) === null || _api$trackChanges === void 0 ? void 0 : _api$trackChanges.commands, api === null || api === void 0 ? void 0 : api.core.actions]);
|
|
20
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
21
|
+
icon: HistoryIcon,
|
|
22
|
+
label: "Track Changes",
|
|
23
|
+
appearance: "subtle",
|
|
24
|
+
isDisabled: !isShowDiffAvailable,
|
|
25
|
+
isSelected: isDisplayingChanges,
|
|
26
|
+
onClick: handleClick
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { ChangeSet } from 'prosemirror-changeset';
|
|
2
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import type { TrackChangesPlugin } from '../trackChangesPluginType';
|
|
5
6
|
export declare const trackChangesPluginKey: PluginKey<TrackChangesPluginState>;
|
|
6
7
|
type TrackChangesPluginState = {
|
|
7
8
|
shouldChangesBeDisplayed: boolean;
|
|
8
9
|
isShowDiffAvailable: boolean;
|
|
9
|
-
|
|
10
|
-
changes: ChangeSet;
|
|
10
|
+
steps: InvertableStep[];
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare class InvertableStep {
|
|
13
|
+
readonly step: Step;
|
|
14
|
+
readonly inverted: Step;
|
|
15
|
+
constructor(step: Step, inverted: Step);
|
|
16
|
+
}
|
|
17
|
+
export declare const createTrackChangesPlugin: (api: ExtractInjectionAPI<TrackChangesPlugin> | undefined) => SafePlugin<TrackChangesPluginState>;
|
|
13
18
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { type PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
3
|
+
import type { ShowDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
|
|
2
4
|
export type TrackChangesPlugin = NextEditorPlugin<'trackChanges', {
|
|
3
5
|
commands: {
|
|
4
6
|
/**
|
|
@@ -6,6 +8,7 @@ export type TrackChangesPlugin = NextEditorPlugin<'trackChanges', {
|
|
|
6
8
|
*/
|
|
7
9
|
toggleChanges: EditorCommand;
|
|
8
10
|
};
|
|
11
|
+
dependencies: [OptionalPlugin<PrimaryToolbarPlugin>, ShowDiffPlugin];
|
|
9
12
|
sharedState: {
|
|
10
13
|
/**
|
|
11
14
|
* Whether the track changes feature is currently displaying changes.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { type TrackChangesPlugin } from '../trackChangesPluginType';
|
|
4
|
+
type TrackChangesToolbarButtonProps = {
|
|
5
|
+
api: ExtractInjectionAPI<TrackChangesPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const TrackChangesToolbarButton: ({ api }: TrackChangesToolbarButtonProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { ChangeSet } from 'prosemirror-changeset';
|
|
2
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type Step } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import type { TrackChangesPlugin } from '../trackChangesPluginType';
|
|
5
6
|
export declare const trackChangesPluginKey: PluginKey<TrackChangesPluginState>;
|
|
6
7
|
type TrackChangesPluginState = {
|
|
7
8
|
shouldChangesBeDisplayed: boolean;
|
|
8
9
|
isShowDiffAvailable: boolean;
|
|
9
|
-
|
|
10
|
-
changes: ChangeSet;
|
|
10
|
+
steps: InvertableStep[];
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare class InvertableStep {
|
|
13
|
+
readonly step: Step;
|
|
14
|
+
readonly inverted: Step;
|
|
15
|
+
constructor(step: Step, inverted: Step);
|
|
16
|
+
}
|
|
17
|
+
export declare const createTrackChangesPlugin: (api: ExtractInjectionAPI<TrackChangesPlugin> | undefined) => SafePlugin<TrackChangesPluginState>;
|
|
13
18
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { type PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
3
|
+
import type { ShowDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
|
|
2
4
|
export type TrackChangesPlugin = NextEditorPlugin<'trackChanges', {
|
|
3
5
|
commands: {
|
|
4
6
|
/**
|
|
@@ -6,6 +8,10 @@ export type TrackChangesPlugin = NextEditorPlugin<'trackChanges', {
|
|
|
6
8
|
*/
|
|
7
9
|
toggleChanges: EditorCommand;
|
|
8
10
|
};
|
|
11
|
+
dependencies: [
|
|
12
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
13
|
+
ShowDiffPlugin
|
|
14
|
+
];
|
|
9
15
|
sharedState: {
|
|
10
16
|
/**
|
|
11
17
|
* Whether the track changes feature is currently displaying changes.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { type TrackChangesPlugin } from '../trackChangesPluginType';
|
|
4
|
+
type TrackChangesToolbarButtonProps = {
|
|
5
|
+
api: ExtractInjectionAPI<TrackChangesPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const TrackChangesToolbarButton: ({ api }: TrackChangesToolbarButtonProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-track-changes",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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,15 @@
|
|
|
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/
|
|
36
|
-
"@babel/runtime": "^7.0.0"
|
|
37
|
-
"prosemirror-changeset": "^2.2.1"
|
|
38
|
+
"@atlaskit/icon-lab": "^5.2.0",
|
|
39
|
+
"@babel/runtime": "^7.0.0"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^107.
|
|
42
|
+
"@atlaskit/editor-common": "^107.13.0",
|
|
41
43
|
"react": "^18.2.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
package/afm-volt/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.volt.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../volt/tsDist/@atlaskit__editor-plugin-toolbar-lists-indentation/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*"
|
|
18
|
-
],
|
|
19
|
-
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../editor-common/tsconfig.app.json"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../design-system/tokens/tsconfig.app.json"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
@@ -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 {};
|