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