@ckeditor/ckeditor5-track-changes 39.0.1 → 40.0.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 +2 -2
- package/LICENSE.md +6 -6
- package/README.md +14 -14
- package/build/track-changes.js +1 -1
- package/lang/translations/ar.po +1 -0
- package/lang/translations/az.po +1 -0
- package/lang/translations/bg.po +1 -0
- package/lang/translations/bn.po +1 -0
- package/lang/translations/ca.po +1 -0
- package/lang/translations/cs.po +1 -0
- package/lang/translations/da.po +1 -0
- package/lang/translations/de.po +1 -0
- package/lang/translations/el.po +1 -0
- package/lang/translations/en-au.po +1 -0
- package/lang/translations/en.po +1 -0
- package/lang/translations/es.po +1 -0
- package/lang/translations/et.po +1 -0
- package/lang/translations/fi.po +1 -0
- package/lang/translations/fr.po +1 -0
- package/lang/translations/gl.po +1 -0
- package/lang/translations/he.po +1 -0
- package/lang/translations/hi.po +1 -0
- package/lang/translations/hr.po +1 -0
- package/lang/translations/hu.po +1 -0
- package/lang/translations/id.po +1 -0
- package/lang/translations/it.po +1 -0
- package/lang/translations/ja.po +1 -0
- package/lang/translations/ko.po +1 -0
- package/lang/translations/lt.po +1 -0
- package/lang/translations/lv.po +1 -0
- package/lang/translations/ms.po +1 -0
- package/lang/translations/nl.po +1 -0
- package/lang/translations/no.po +1 -0
- package/lang/translations/pl.po +1 -0
- package/lang/translations/pt-br.po +1 -0
- package/lang/translations/pt.po +1 -0
- package/lang/translations/ro.po +1 -0
- package/lang/translations/ru.po +1 -0
- package/lang/translations/sk.po +1 -0
- package/lang/translations/sq.po +1 -0
- package/lang/translations/sr-latn.po +1 -0
- package/lang/translations/sr.po +1 -0
- package/lang/translations/sv.po +1 -0
- package/lang/translations/th.po +1 -0
- package/lang/translations/tk.po +1 -0
- package/lang/translations/tr.po +1 -0
- package/lang/translations/tt.po +1 -0
- package/lang/translations/uk.po +1 -0
- package/lang/translations/ur.po +1 -0
- package/lang/translations/vi.po +1 -0
- package/lang/translations/zh-cn.po +1 -0
- package/lang/translations/zh.po +1 -0
- package/package.json +3 -7
- package/src/augmentation.d.ts +40 -40
- package/src/commands/acceptsuggestioncommand.d.ts +24 -24
- package/src/commands/acceptsuggestioncommand.js +1 -1
- package/src/commands/discardsuggestioncommand.d.ts +24 -24
- package/src/commands/discardsuggestioncommand.js +1 -1
- package/src/commands/executeonallsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonallsuggestionscommand.js +1 -1
- package/src/commands/executeonselectedsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonselectedsuggestionscommand.js +1 -1
- package/src/commands/trackchangescommand.d.ts +26 -26
- package/src/commands/trackchangescommand.js +1 -1
- package/src/index.d.ts +16 -16
- package/src/integrations/aiassistant.d.ts +17 -0
- package/src/integrations/aiassistant.js +23 -0
- package/src/integrations/alignment.d.ts +17 -17
- package/src/integrations/alignment.js +1 -1
- package/src/integrations/basicstyles.d.ts +17 -17
- package/src/integrations/basicstyles.js +1 -1
- package/src/integrations/blockquote.d.ts +17 -17
- package/src/integrations/blockquote.js +1 -1
- package/src/integrations/ckbox.d.ts +17 -17
- package/src/integrations/ckbox.js +1 -1
- package/src/integrations/codeblock.d.ts +17 -17
- package/src/integrations/codeblock.js +1 -1
- package/src/integrations/comments.d.ts +14 -14
- package/src/integrations/comments.js +1 -1
- package/src/integrations/deletecommand.d.ts +17 -17
- package/src/integrations/deletecommand.js +1 -1
- package/src/integrations/documentlist.d.ts +17 -17
- package/src/integrations/documentlist.js +1 -1
- package/src/integrations/documentlistproperties.d.ts +29 -29
- package/src/integrations/documentlistproperties.js +1 -1
- package/src/integrations/entercommand.d.ts +16 -16
- package/src/integrations/entercommand.js +1 -1
- package/src/integrations/findandreplace.d.ts +21 -21
- package/src/integrations/findandreplace.js +1 -1
- package/src/integrations/font.d.ts +17 -17
- package/src/integrations/font.js +1 -1
- package/src/integrations/formatpainter.d.ts +17 -17
- package/src/integrations/formatpainter.js +1 -1
- package/src/integrations/heading.d.ts +17 -17
- package/src/integrations/heading.js +1 -1
- package/src/integrations/highlight.d.ts +17 -17
- package/src/integrations/highlight.js +1 -1
- package/src/integrations/horizontalline.d.ts +17 -17
- package/src/integrations/horizontalline.js +1 -1
- package/src/integrations/htmlembed.d.ts +17 -17
- package/src/integrations/htmlembed.js +1 -1
- package/src/integrations/image.d.ts +17 -17
- package/src/integrations/image.js +1 -1
- package/src/integrations/imagereplace.d.ts +23 -23
- package/src/integrations/imagereplace.js +1 -1
- package/src/integrations/importword.d.ts +18 -18
- package/src/integrations/importword.js +1 -1
- package/src/integrations/indent.d.ts +17 -17
- package/src/integrations/indent.js +1 -1
- package/src/integrations/inputcommand.d.ts +16 -16
- package/src/integrations/inputcommand.js +1 -1
- package/src/integrations/link.d.ts +17 -17
- package/src/integrations/link.js +1 -1
- package/src/integrations/list.d.ts +17 -17
- package/src/integrations/list.js +1 -1
- package/src/integrations/listproperties.d.ts +29 -29
- package/src/integrations/listproperties.js +1 -1
- package/src/integrations/mediaembed.d.ts +17 -17
- package/src/integrations/mediaembed.js +1 -1
- package/src/integrations/mention.d.ts +17 -17
- package/src/integrations/mention.js +1 -1
- package/src/integrations/pagebreak.d.ts +17 -17
- package/src/integrations/pagebreak.js +1 -1
- package/src/integrations/paragraph.d.ts +17 -17
- package/src/integrations/paragraph.js +1 -1
- package/src/integrations/removeformat.d.ts +17 -17
- package/src/integrations/removeformat.js +1 -1
- package/src/integrations/restrictededitingmode.d.ts +17 -17
- package/src/integrations/restrictededitingmode.js +1 -1
- package/src/integrations/shiftentercommand.d.ts +16 -16
- package/src/integrations/shiftentercommand.js +1 -1
- package/src/integrations/standardeditingmode.d.ts +17 -17
- package/src/integrations/standardeditingmode.js +1 -1
- package/src/integrations/style.d.ts +18 -18
- package/src/integrations/style.js +1 -1
- package/src/integrations/table.d.ts +42 -42
- package/src/integrations/table.js +1 -1
- package/src/integrations/tablecaption.d.ts +22 -22
- package/src/integrations/tablecaption.js +1 -1
- package/src/integrations/tableclipboard.d.ts +19 -19
- package/src/integrations/tableclipboard.js +1 -1
- package/src/integrations/tablecolumnresize.d.ts +26 -26
- package/src/integrations/tablecolumnresize.js +1 -1
- package/src/integrations/tableheadings.d.ts +22 -22
- package/src/integrations/tableheadings.js +1 -1
- package/src/integrations/tablemergesplit.d.ts +22 -22
- package/src/integrations/tablemergesplit.js +1 -1
- package/src/integrations/tableofcontents.d.ts +17 -17
- package/src/integrations/tableofcontents.js +1 -1
- package/src/integrations/tableproperties.d.ts +27 -27
- package/src/integrations/tableproperties.js +1 -1
- package/src/integrations/template.d.ts +17 -17
- package/src/integrations/template.js +1 -1
- package/src/integrations/title.d.ts +17 -17
- package/src/integrations/title.js +1 -1
- package/src/integrations/undo.d.ts +17 -17
- package/src/integrations/undo.js +1 -1
- package/src/integrations/utils.d.ts +21 -21
- package/src/integrations/utils.js +1 -1
- package/src/suggestion.d.ts +276 -276
- package/src/suggestion.js +1 -1
- package/src/suggestiondescriptionfactory.d.ts +163 -163
- package/src/suggestiondescriptionfactory.js +1 -1
- package/src/trackchanges.d.ts +244 -244
- package/src/trackchanges.js +1 -1
- package/src/trackchangesconfig.d.ts +75 -75
- package/src/trackchangesdata.d.ts +41 -41
- package/src/trackchangesdata.js +1 -1
- package/src/trackchangesediting.d.ts +468 -439
- package/src/trackchangesediting.js +1 -1
- package/src/trackchangesui.d.ts +38 -38
- package/src/trackchangesui.js +1 -1
- package/src/ui/suggestioncontroller.d.ts +37 -37
- package/src/ui/suggestioncontroller.js +1 -1
- package/src/ui/view/basesuggestionthreadview.d.ts +170 -170
- package/src/ui/view/basesuggestionthreadview.js +1 -1
- package/src/ui/view/suggestionthreadview.d.ts +182 -182
- package/src/ui/view/suggestionthreadview.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/src/utils/utils.d.ts +30 -30
- package/src/utils/utils.js +1 -1
- package/theme/icons/track-changes-accept.svg +1 -1
- package/theme/icons/track-changes-discard.svg +1 -1
- package/theme/icons/track-changes.svg +1 -1
package/src/trackchanges.d.ts
CHANGED
|
@@ -1,244 +1,244 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module track-changes/trackchanges
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import TrackChangesUI from './trackchangesui';
|
|
11
|
-
import TrackChangesEditing from './trackchangesediting';
|
|
12
|
-
import 'ckeditor5-collaboration/src/collaboration-core';
|
|
13
|
-
import type { default as Suggestion, SuggestionJSON } from './suggestion';
|
|
14
|
-
import type SuggestionThreadView from './ui/view/suggestionthreadview';
|
|
15
|
-
/**
|
|
16
|
-
* A plugin that provides track changes mode for the editor. In track changes mode, all insertions are visually marked and all deletions
|
|
17
|
-
* are not deleted but also visually marked. Unsupported commands are disabled when the editor is in the track changes mode.
|
|
18
|
-
*
|
|
19
|
-
* To learn how to integrate the track changes feature with your editor, refer to the
|
|
20
|
-
* {@glink features/collaboration/track-changes/track-changes-integration Track changes integration} guide.
|
|
21
|
-
*
|
|
22
|
-
* Basic API:
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* // Get the track changes plugin:
|
|
26
|
-
* const trackChangesPlugin = editor.plugins.get( 'TrackChanges' );
|
|
27
|
-
*
|
|
28
|
-
* // Add a suggestion:
|
|
29
|
-
* trackChangesPlugin.addSuggestion( suggestionData );
|
|
30
|
-
*
|
|
31
|
-
* // Get all suggestions:
|
|
32
|
-
* trackChangesPlugin.getSuggestions();
|
|
33
|
-
*
|
|
34
|
-
* // Set the adapter:
|
|
35
|
-
* trackChangesPlugin.adapter = {
|
|
36
|
-
* // ...
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* The plugin registers several commands:
|
|
41
|
-
*
|
|
42
|
-
* * `trackChanges` – Toggles the track changes mode in the editor.
|
|
43
|
-
* * `acceptSuggestion` – Accepts a suggestion with the specified ID.
|
|
44
|
-
* * `discardSuggestion` – Discards a suggestion with the specified ID.
|
|
45
|
-
* * `acceptAllSuggestions` – Accepts all suggestions.
|
|
46
|
-
* * `discardAllSuggestions` – Discards all suggestions.
|
|
47
|
-
* * `acceptSelectedSuggestions` – Accepts all suggestions in the current selection.
|
|
48
|
-
* * `discardSelectedSuggestions` – Discards all suggestions in the current selection.
|
|
49
|
-
*
|
|
50
|
-
* Examples:
|
|
51
|
-
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* editor.execute( 'trackChanges' );
|
|
54
|
-
* editor.execute( 'acceptSuggestion', 'suggestion-1' );
|
|
55
|
-
* editor.execute( 'discardSuggestion', 'suggestion-1' );
|
|
56
|
-
* editor.execute( 'acceptAllSuggestions' );
|
|
57
|
-
* editor.execute( 'discardAllSuggestions' );
|
|
58
|
-
* editor.execute( 'acceptSelectedSuggestions' );
|
|
59
|
-
* editor.execute( 'discardSelectedSuggestions' )
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Note that there is no command to add a suggestion. This is because suggestions
|
|
63
|
-
* are added automatically when editing commands are executed while the editor is in track
|
|
64
|
-
* changes mode. For instance:
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* // Turn on the track changes mode:
|
|
68
|
-
* editor.execute( 'trackChanges' );
|
|
69
|
-
*
|
|
70
|
-
* // Insert some text. It will be automatically inserted as a suggestion:
|
|
71
|
-
* editor.execute( 'input', { text: 'foo' } );
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export default class TrackChanges extends Plugin {
|
|
75
|
-
static get requires(): readonly [typeof TrackChangesEditing, typeof TrackChangesUI, "Comments"];
|
|
76
|
-
static get pluginName(): "TrackChanges";
|
|
77
|
-
/**
|
|
78
|
-
* An adapter object that should communicate with the data source to fetch or save the suggestion data.
|
|
79
|
-
*
|
|
80
|
-
* This is a shorthand to {@link module:track-changes/trackchangesediting~TrackChangesEditing#adapter `TrackChangesEditing#adapter`}.
|
|
81
|
-
*/
|
|
82
|
-
set adapter(adapter: TrackChangesAdapter | null);
|
|
83
|
-
get adapter(): TrackChangesAdapter | null;
|
|
84
|
-
/**
|
|
85
|
-
* Adds suggestion data.
|
|
86
|
-
*
|
|
87
|
-
* Use this method to load the suggestion data during the editor initialization if you do not use the adapter integration.
|
|
88
|
-
*/
|
|
89
|
-
addSuggestion(suggestionData: SuggestionData): Suggestion;
|
|
90
|
-
getSuggestions(options: {
|
|
91
|
-
skipNotAttached?: boolean;
|
|
92
|
-
toJSON: true;
|
|
93
|
-
}): Array<SuggestionJSON>;
|
|
94
|
-
getSuggestions(options?: {
|
|
95
|
-
skipNotAttached?: boolean;
|
|
96
|
-
toJSON?: false;
|
|
97
|
-
}): Array<Suggestion>;
|
|
98
|
-
getSuggestions(options: {
|
|
99
|
-
skipNotAttached?: boolean;
|
|
100
|
-
toJSON: boolean;
|
|
101
|
-
}): Array<Suggestion> | Array<SuggestionJSON>;
|
|
102
|
-
/**
|
|
103
|
-
* Returns the suggestion instance for a given ID.
|
|
104
|
-
*/
|
|
105
|
-
getSuggestion(id: string): Suggestion;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* The configuration of the track changes feature.
|
|
109
|
-
*
|
|
110
|
-
* Example:
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* ClassicEditor
|
|
114
|
-
* .create( {
|
|
115
|
-
* // Track changes feature configuration.
|
|
116
|
-
* trackChanges: {
|
|
117
|
-
* // Do not allow users to comment suggestions (default is `false`).
|
|
118
|
-
* disableComments: true,
|
|
119
|
-
* // Do not track styling and formatting changes (default is `default`).
|
|
120
|
-
* trackFormatChanges: 'never',
|
|
121
|
-
* // Merges suggestion changes inside a block. (default is `true`).
|
|
122
|
-
* mergeNestedSuggestions: true
|
|
123
|
-
* }
|
|
124
|
-
* } )
|
|
125
|
-
* .then( ... )
|
|
126
|
-
* .catch( ... );
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
130
|
-
*/
|
|
131
|
-
export interface TrackChangesConfig {
|
|
132
|
-
/**
|
|
133
|
-
* A property that specifies if the comments for suggestions are enabled or disabled.
|
|
134
|
-
* When the option is set to `true`, the comment thread UI for suggestions will be hidden
|
|
135
|
-
* and commenting suggestions will be disabled.
|
|
136
|
-
*
|
|
137
|
-
* Suggestion thread views will be marked with the additional `ck-suggestion--disabled-comments` class when the suggestion comments
|
|
138
|
-
* are disabled.
|
|
139
|
-
*/
|
|
140
|
-
disableComments: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* A property that specifies whether format changes should be tracked.
|
|
143
|
-
*
|
|
144
|
-
* Format changes are all changes other than insertions and deletions, including: styling, structure, widgets properties, etc.
|
|
145
|
-
*
|
|
146
|
-
* Possible values are:
|
|
147
|
-
*
|
|
148
|
-
* * `'always'` - all changes are going to be tracked independently (without merging).
|
|
149
|
-
* * `'default'` - format changes made inside your own insertion suggestion will be merged with it.
|
|
150
|
-
* * `'never'` - format changes will not be tracked.
|
|
151
|
-
*
|
|
152
|
-
* Defaults to `'default'`.
|
|
153
|
-
*/
|
|
154
|
-
trackFormatChanges: 'never' | 'default' | 'always';
|
|
155
|
-
/**
|
|
156
|
-
* Specifies whether suggestions on an object (e.g. image, table) should be automatically merged
|
|
157
|
-
* with suggestions inside the object (e.g. image caption, table cell).
|
|
158
|
-
*
|
|
159
|
-
* For example, when set to `true`, creating a table and writing some text inside the table will result in one suggestion.
|
|
160
|
-
* When set to `false`, it will be two separate suggestions, one for the inserted table and one for the inserted text.
|
|
161
|
-
*
|
|
162
|
-
* Keep in mind that only suggestions from the same author and of the same type are merged this way.
|
|
163
|
-
*/
|
|
164
|
-
mergeNestedSuggestions: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* A view class to be used to create suggestion thread views.
|
|
167
|
-
*
|
|
168
|
-
* {@link module:track-changes/ui/view/suggestionthreadview~SuggestionThreadView} is used by default
|
|
169
|
-
* when this property is not set.
|
|
170
|
-
*/
|
|
171
|
-
SuggestionThreadView?: typeof SuggestionThreadView;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Track changes adapter.
|
|
175
|
-
*
|
|
176
|
-
* The track changes adapter is an object that communicates asynchronously with the data source to fetch or save the suggestion data.
|
|
177
|
-
* It is used internally by the track changes feature whenever a suggestion is loaded, created or deleted.
|
|
178
|
-
*
|
|
179
|
-
* The adapter is optional. You might need to provide it if you are {@glink features/collaboration/track-changes/track-changes-integration}
|
|
180
|
-
* using the track changes feature without real-time collaboration.
|
|
181
|
-
*
|
|
182
|
-
* To set the adapter, overwrite {@link module:track-changes/trackchanges~TrackChanges#adapter the `TrackChanges#adapter` property}.
|
|
183
|
-
*/
|
|
184
|
-
export interface TrackChangesAdapter {
|
|
185
|
-
/**
|
|
186
|
-
* Called each time the suggestion data is needed.
|
|
187
|
-
*
|
|
188
|
-
* The method should return a promise that resolves with the suggestion data object.
|
|
189
|
-
*
|
|
190
|
-
* @param id The ID of the suggestion to get.
|
|
191
|
-
*/
|
|
192
|
-
getSuggestion(id: string): Promise<SuggestionData>;
|
|
193
|
-
/**
|
|
194
|
-
* Called each time a new suggestion is created.
|
|
195
|
-
*
|
|
196
|
-
* The method should save the suggestion data in the database
|
|
197
|
-
* and return a promise that should be resolved when the save is
|
|
198
|
-
* completed.
|
|
199
|
-
*
|
|
200
|
-
* If the promise resolves with an object with the `createdAt` property,
|
|
201
|
-
* this suggestion property will be updated in the suggestion in the editor.
|
|
202
|
-
* This lets you update the suggestion data with server-side information.
|
|
203
|
-
*
|
|
204
|
-
* The `suggestionData` object does not expect the `authorId` property.
|
|
205
|
-
* For security reasons, the author of the suggestion should be set
|
|
206
|
-
* on the server side.
|
|
207
|
-
*
|
|
208
|
-
* If `suggestionData.originalSuggestionId` is set, the new suggestion should
|
|
209
|
-
* have the `authorId` property set to the same as the suggestion with
|
|
210
|
-
* `originalSuggestionId`. This happens when one user splits
|
|
211
|
-
* another user's suggestion, creating a new suggestion as a result. See
|
|
212
|
-
* {@glink features/collaboration/track-changes/track-changes-integration#implementation Track changes integration} guide.
|
|
213
|
-
*
|
|
214
|
-
* **Note:** Failure to properly handle this property will result in editor crash in some scenarios.
|
|
215
|
-
*
|
|
216
|
-
* In any other case, use the current (local) user to set `authorId`.
|
|
217
|
-
*
|
|
218
|
-
* The `suggestionData` object does not expect the `createdAt` property either.
|
|
219
|
-
* You should use the server-side time generator to ensure that all users
|
|
220
|
-
* see the same date.
|
|
221
|
-
*
|
|
222
|
-
* It is recommended to stringify `suggestionData.attributes` value to JSON and save it as a string in your database,
|
|
223
|
-
* and then to parse the strings when loading suggestions.
|
|
224
|
-
*/
|
|
225
|
-
addSuggestion(suggestionData: AddSuggestionInput): Promise<SuggestionData>;
|
|
226
|
-
/**
|
|
227
|
-
* Called each time the suggestion properties change.
|
|
228
|
-
*
|
|
229
|
-
* The method should update the suggestion properties in the database
|
|
230
|
-
* and return a promise that should be resolved when the save is
|
|
231
|
-
* completed.
|
|
232
|
-
*
|
|
233
|
-
* Keep in mind that the `data` parameter only contains those
|
|
234
|
-
* properties of a suggestion which changed.
|
|
235
|
-
*/
|
|
236
|
-
updateSuggestion(id: string, suggestionData: UpdateSuggestionInput): Promise<void>;
|
|
237
|
-
}
|
|
238
|
-
export type SuggestionData = SuggestionJSON & {
|
|
239
|
-
originalSuggestionId?: string | null;
|
|
240
|
-
};
|
|
241
|
-
export type AddSuggestionInput = Omit<SuggestionData, 'authorId' | 'createdAt'>;
|
|
242
|
-
export type UpdateSuggestionInput = Partial<Pick<SuggestionJSON, 'hasComments' | 'attributes'>> & {
|
|
243
|
-
state?: 'open' | 'accepted' | 'rejected';
|
|
244
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module track-changes/trackchanges
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
+
import TrackChangesUI from './trackchangesui';
|
|
11
|
+
import TrackChangesEditing from './trackchangesediting';
|
|
12
|
+
import 'ckeditor5-collaboration/src/collaboration-core';
|
|
13
|
+
import type { default as Suggestion, SuggestionJSON } from './suggestion';
|
|
14
|
+
import type SuggestionThreadView from './ui/view/suggestionthreadview';
|
|
15
|
+
/**
|
|
16
|
+
* A plugin that provides track changes mode for the editor. In track changes mode, all insertions are visually marked and all deletions
|
|
17
|
+
* are not deleted but also visually marked. Unsupported commands are disabled when the editor is in the track changes mode.
|
|
18
|
+
*
|
|
19
|
+
* To learn how to integrate the track changes feature with your editor, refer to the
|
|
20
|
+
* {@glink features/collaboration/track-changes/track-changes-integration Track changes integration} guide.
|
|
21
|
+
*
|
|
22
|
+
* Basic API:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* // Get the track changes plugin:
|
|
26
|
+
* const trackChangesPlugin = editor.plugins.get( 'TrackChanges' );
|
|
27
|
+
*
|
|
28
|
+
* // Add a suggestion:
|
|
29
|
+
* trackChangesPlugin.addSuggestion( suggestionData );
|
|
30
|
+
*
|
|
31
|
+
* // Get all suggestions:
|
|
32
|
+
* trackChangesPlugin.getSuggestions();
|
|
33
|
+
*
|
|
34
|
+
* // Set the adapter:
|
|
35
|
+
* trackChangesPlugin.adapter = {
|
|
36
|
+
* // ...
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The plugin registers several commands:
|
|
41
|
+
*
|
|
42
|
+
* * `trackChanges` – Toggles the track changes mode in the editor.
|
|
43
|
+
* * `acceptSuggestion` – Accepts a suggestion with the specified ID.
|
|
44
|
+
* * `discardSuggestion` – Discards a suggestion with the specified ID.
|
|
45
|
+
* * `acceptAllSuggestions` – Accepts all suggestions.
|
|
46
|
+
* * `discardAllSuggestions` – Discards all suggestions.
|
|
47
|
+
* * `acceptSelectedSuggestions` – Accepts all suggestions in the current selection.
|
|
48
|
+
* * `discardSelectedSuggestions` – Discards all suggestions in the current selection.
|
|
49
|
+
*
|
|
50
|
+
* Examples:
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* editor.execute( 'trackChanges' );
|
|
54
|
+
* editor.execute( 'acceptSuggestion', 'suggestion-1' );
|
|
55
|
+
* editor.execute( 'discardSuggestion', 'suggestion-1' );
|
|
56
|
+
* editor.execute( 'acceptAllSuggestions' );
|
|
57
|
+
* editor.execute( 'discardAllSuggestions' );
|
|
58
|
+
* editor.execute( 'acceptSelectedSuggestions' );
|
|
59
|
+
* editor.execute( 'discardSelectedSuggestions' )
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* Note that there is no command to add a suggestion. This is because suggestions
|
|
63
|
+
* are added automatically when editing commands are executed while the editor is in track
|
|
64
|
+
* changes mode. For instance:
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* // Turn on the track changes mode:
|
|
68
|
+
* editor.execute( 'trackChanges' );
|
|
69
|
+
*
|
|
70
|
+
* // Insert some text. It will be automatically inserted as a suggestion:
|
|
71
|
+
* editor.execute( 'input', { text: 'foo' } );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export default class TrackChanges extends Plugin {
|
|
75
|
+
static get requires(): readonly [typeof TrackChangesEditing, typeof TrackChangesUI, "Comments"];
|
|
76
|
+
static get pluginName(): "TrackChanges";
|
|
77
|
+
/**
|
|
78
|
+
* An adapter object that should communicate with the data source to fetch or save the suggestion data.
|
|
79
|
+
*
|
|
80
|
+
* This is a shorthand to {@link module:track-changes/trackchangesediting~TrackChangesEditing#adapter `TrackChangesEditing#adapter`}.
|
|
81
|
+
*/
|
|
82
|
+
set adapter(adapter: TrackChangesAdapter | null);
|
|
83
|
+
get adapter(): TrackChangesAdapter | null;
|
|
84
|
+
/**
|
|
85
|
+
* Adds suggestion data.
|
|
86
|
+
*
|
|
87
|
+
* Use this method to load the suggestion data during the editor initialization if you do not use the adapter integration.
|
|
88
|
+
*/
|
|
89
|
+
addSuggestion(suggestionData: SuggestionData): Suggestion;
|
|
90
|
+
getSuggestions(options: {
|
|
91
|
+
skipNotAttached?: boolean;
|
|
92
|
+
toJSON: true;
|
|
93
|
+
}): Array<SuggestionJSON>;
|
|
94
|
+
getSuggestions(options?: {
|
|
95
|
+
skipNotAttached?: boolean;
|
|
96
|
+
toJSON?: false;
|
|
97
|
+
}): Array<Suggestion>;
|
|
98
|
+
getSuggestions(options: {
|
|
99
|
+
skipNotAttached?: boolean;
|
|
100
|
+
toJSON: boolean;
|
|
101
|
+
}): Array<Suggestion> | Array<SuggestionJSON>;
|
|
102
|
+
/**
|
|
103
|
+
* Returns the suggestion instance for a given ID.
|
|
104
|
+
*/
|
|
105
|
+
getSuggestion(id: string): Suggestion;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The configuration of the track changes feature.
|
|
109
|
+
*
|
|
110
|
+
* Example:
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* ClassicEditor
|
|
114
|
+
* .create( {
|
|
115
|
+
* // Track changes feature configuration.
|
|
116
|
+
* trackChanges: {
|
|
117
|
+
* // Do not allow users to comment suggestions (default is `false`).
|
|
118
|
+
* disableComments: true,
|
|
119
|
+
* // Do not track styling and formatting changes (default is `default`).
|
|
120
|
+
* trackFormatChanges: 'never',
|
|
121
|
+
* // Merges suggestion changes inside a block. (default is `true`).
|
|
122
|
+
* mergeNestedSuggestions: true
|
|
123
|
+
* }
|
|
124
|
+
* } )
|
|
125
|
+
* .then( ... )
|
|
126
|
+
* .catch( ... );
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
130
|
+
*/
|
|
131
|
+
export interface TrackChangesConfig {
|
|
132
|
+
/**
|
|
133
|
+
* A property that specifies if the comments for suggestions are enabled or disabled.
|
|
134
|
+
* When the option is set to `true`, the comment thread UI for suggestions will be hidden
|
|
135
|
+
* and commenting suggestions will be disabled.
|
|
136
|
+
*
|
|
137
|
+
* Suggestion thread views will be marked with the additional `ck-suggestion--disabled-comments` class when the suggestion comments
|
|
138
|
+
* are disabled.
|
|
139
|
+
*/
|
|
140
|
+
disableComments: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* A property that specifies whether format changes should be tracked.
|
|
143
|
+
*
|
|
144
|
+
* Format changes are all changes other than insertions and deletions, including: styling, structure, widgets properties, etc.
|
|
145
|
+
*
|
|
146
|
+
* Possible values are:
|
|
147
|
+
*
|
|
148
|
+
* * `'always'` - all changes are going to be tracked independently (without merging).
|
|
149
|
+
* * `'default'` - format changes made inside your own insertion suggestion will be merged with it.
|
|
150
|
+
* * `'never'` - format changes will not be tracked.
|
|
151
|
+
*
|
|
152
|
+
* Defaults to `'default'`.
|
|
153
|
+
*/
|
|
154
|
+
trackFormatChanges: 'never' | 'default' | 'always';
|
|
155
|
+
/**
|
|
156
|
+
* Specifies whether suggestions on an object (e.g. image, table) should be automatically merged
|
|
157
|
+
* with suggestions inside the object (e.g. image caption, table cell).
|
|
158
|
+
*
|
|
159
|
+
* For example, when set to `true`, creating a table and writing some text inside the table will result in one suggestion.
|
|
160
|
+
* When set to `false`, it will be two separate suggestions, one for the inserted table and one for the inserted text.
|
|
161
|
+
*
|
|
162
|
+
* Keep in mind that only suggestions from the same author and of the same type are merged this way.
|
|
163
|
+
*/
|
|
164
|
+
mergeNestedSuggestions: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* A view class to be used to create suggestion thread views.
|
|
167
|
+
*
|
|
168
|
+
* {@link module:track-changes/ui/view/suggestionthreadview~SuggestionThreadView} is used by default
|
|
169
|
+
* when this property is not set.
|
|
170
|
+
*/
|
|
171
|
+
SuggestionThreadView?: typeof SuggestionThreadView;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Track changes adapter.
|
|
175
|
+
*
|
|
176
|
+
* The track changes adapter is an object that communicates asynchronously with the data source to fetch or save the suggestion data.
|
|
177
|
+
* It is used internally by the track changes feature whenever a suggestion is loaded, created or deleted.
|
|
178
|
+
*
|
|
179
|
+
* The adapter is optional. You might need to provide it if you are {@glink features/collaboration/track-changes/track-changes-integration}
|
|
180
|
+
* using the track changes feature without real-time collaboration.
|
|
181
|
+
*
|
|
182
|
+
* To set the adapter, overwrite {@link module:track-changes/trackchanges~TrackChanges#adapter the `TrackChanges#adapter` property}.
|
|
183
|
+
*/
|
|
184
|
+
export interface TrackChangesAdapter {
|
|
185
|
+
/**
|
|
186
|
+
* Called each time the suggestion data is needed.
|
|
187
|
+
*
|
|
188
|
+
* The method should return a promise that resolves with the suggestion data object.
|
|
189
|
+
*
|
|
190
|
+
* @param id The ID of the suggestion to get.
|
|
191
|
+
*/
|
|
192
|
+
getSuggestion(id: string): Promise<SuggestionData>;
|
|
193
|
+
/**
|
|
194
|
+
* Called each time a new suggestion is created.
|
|
195
|
+
*
|
|
196
|
+
* The method should save the suggestion data in the database
|
|
197
|
+
* and return a promise that should be resolved when the save is
|
|
198
|
+
* completed.
|
|
199
|
+
*
|
|
200
|
+
* If the promise resolves with an object with the `createdAt` property,
|
|
201
|
+
* this suggestion property will be updated in the suggestion in the editor.
|
|
202
|
+
* This lets you update the suggestion data with server-side information.
|
|
203
|
+
*
|
|
204
|
+
* The `suggestionData` object does not expect the `authorId` property.
|
|
205
|
+
* For security reasons, the author of the suggestion should be set
|
|
206
|
+
* on the server side.
|
|
207
|
+
*
|
|
208
|
+
* If `suggestionData.originalSuggestionId` is set, the new suggestion should
|
|
209
|
+
* have the `authorId` property set to the same as the suggestion with
|
|
210
|
+
* `originalSuggestionId`. This happens when one user splits
|
|
211
|
+
* another user's suggestion, creating a new suggestion as a result. See
|
|
212
|
+
* {@glink features/collaboration/track-changes/track-changes-integration#implementation Track changes integration} guide.
|
|
213
|
+
*
|
|
214
|
+
* **Note:** Failure to properly handle this property will result in editor crash in some scenarios.
|
|
215
|
+
*
|
|
216
|
+
* In any other case, use the current (local) user to set `authorId`.
|
|
217
|
+
*
|
|
218
|
+
* The `suggestionData` object does not expect the `createdAt` property either.
|
|
219
|
+
* You should use the server-side time generator to ensure that all users
|
|
220
|
+
* see the same date.
|
|
221
|
+
*
|
|
222
|
+
* It is recommended to stringify `suggestionData.attributes` value to JSON and save it as a string in your database,
|
|
223
|
+
* and then to parse the strings when loading suggestions.
|
|
224
|
+
*/
|
|
225
|
+
addSuggestion(suggestionData: AddSuggestionInput): Promise<SuggestionData>;
|
|
226
|
+
/**
|
|
227
|
+
* Called each time the suggestion properties change.
|
|
228
|
+
*
|
|
229
|
+
* The method should update the suggestion properties in the database
|
|
230
|
+
* and return a promise that should be resolved when the save is
|
|
231
|
+
* completed.
|
|
232
|
+
*
|
|
233
|
+
* Keep in mind that the `data` parameter only contains those
|
|
234
|
+
* properties of a suggestion which changed.
|
|
235
|
+
*/
|
|
236
|
+
updateSuggestion(id: string, suggestionData: UpdateSuggestionInput): Promise<void>;
|
|
237
|
+
}
|
|
238
|
+
export type SuggestionData = SuggestionJSON & {
|
|
239
|
+
originalSuggestionId?: string | null;
|
|
240
|
+
};
|
|
241
|
+
export type AddSuggestionInput = Omit<SuggestionData, 'authorId' | 'createdAt'>;
|
|
242
|
+
export type UpdateSuggestionInput = Partial<Pick<SuggestionJSON, 'hasComments' | 'attributes'>> & {
|
|
243
|
+
state?: 'open' | 'accepted' | 'rejected';
|
|
244
|
+
};
|
package/src/trackchanges.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
var
|
|
23
|
+
var _0x12bf=['plugins','adapter','TrackChanges','addSuggestion','get','pluginName','Comments','getSuggestions','addSuggestionData','editor','getSuggestion'];(function(_0x3f2f9d,_0x12bfb0){var _0x161a13=function(_0x369cc1){while(--_0x369cc1){_0x3f2f9d['push'](_0x3f2f9d['shift']());}};_0x161a13(++_0x12bfb0);}(_0x12bf,0x16d));var _0x161a=function(_0x3f2f9d,_0x12bfb0){_0x3f2f9d=_0x3f2f9d-0x0;var _0x161a13=_0x12bf[_0x3f2f9d];return _0x161a13;};import{Plugin as _0xe9c300}from'ckeditor5/src/core';import _0x289221 from'./trackchangesui';import _0x3d300f from'./trackchangesediting';import'ckeditor5-collaboration/src/collaboration-core';export default class k extends _0xe9c300{static get['requires'](){return[_0x3d300f,_0x289221,_0x161a('0x4')];}static get[_0x161a('0x3')](){return _0x161a('0x0');}set['adapter'](_0x2427ba){this[_0x161a('0x7')][_0x161a('0x9')]['get'](_0x3d300f)[_0x161a('0xa')]=_0x2427ba;}get[_0x161a('0xa')](){return this[_0x161a('0x7')][_0x161a('0x9')][_0x161a('0x2')](_0x3d300f)[_0x161a('0xa')];}[_0x161a('0x1')](_0x30292d){return this[_0x161a('0x7')][_0x161a('0x9')][_0x161a('0x2')](_0x3d300f)[_0x161a('0x6')](_0x30292d);}[_0x161a('0x5')]({skipNotAttached:_0x549aca=!0x1,toJSON:_0x441144=!0x1}={}){return this[_0x161a('0x7')][_0x161a('0x9')][_0x161a('0x2')](_0x3d300f)['getSuggestions']({'skipNotAttached':_0x549aca,'toJSON':_0x441144});}[_0x161a('0x8')](_0x1dd5f2){return this[_0x161a('0x7')][_0x161a('0x9')]['get'](_0x3d300f)[_0x161a('0x8')](_0x1dd5f2);}}
|