@ckeditor/ckeditor5-track-changes 39.0.2 → 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.
Files changed (136) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +1 -1
  3. package/build/track-changes.js +1 -1
  4. package/package.json +3 -3
  5. package/src/augmentation.d.ts +40 -40
  6. package/src/commands/acceptsuggestioncommand.d.ts +24 -24
  7. package/src/commands/acceptsuggestioncommand.js +1 -1
  8. package/src/commands/discardsuggestioncommand.d.ts +24 -24
  9. package/src/commands/discardsuggestioncommand.js +1 -1
  10. package/src/commands/executeonallsuggestionscommand.d.ts +24 -24
  11. package/src/commands/executeonallsuggestionscommand.js +1 -1
  12. package/src/commands/executeonselectedsuggestionscommand.d.ts +24 -24
  13. package/src/commands/executeonselectedsuggestionscommand.js +1 -1
  14. package/src/commands/trackchangescommand.d.ts +26 -26
  15. package/src/commands/trackchangescommand.js +1 -1
  16. package/src/index.d.ts +16 -16
  17. package/src/integrations/aiassistant.d.ts +17 -0
  18. package/src/integrations/aiassistant.js +23 -0
  19. package/src/integrations/alignment.d.ts +17 -17
  20. package/src/integrations/alignment.js +1 -1
  21. package/src/integrations/basicstyles.d.ts +17 -17
  22. package/src/integrations/basicstyles.js +1 -1
  23. package/src/integrations/blockquote.d.ts +17 -17
  24. package/src/integrations/blockquote.js +1 -1
  25. package/src/integrations/ckbox.d.ts +17 -17
  26. package/src/integrations/ckbox.js +1 -1
  27. package/src/integrations/codeblock.d.ts +17 -17
  28. package/src/integrations/codeblock.js +1 -1
  29. package/src/integrations/comments.d.ts +14 -14
  30. package/src/integrations/comments.js +1 -1
  31. package/src/integrations/deletecommand.d.ts +17 -17
  32. package/src/integrations/deletecommand.js +1 -1
  33. package/src/integrations/documentlist.d.ts +17 -17
  34. package/src/integrations/documentlist.js +1 -1
  35. package/src/integrations/documentlistproperties.d.ts +29 -29
  36. package/src/integrations/documentlistproperties.js +1 -1
  37. package/src/integrations/entercommand.d.ts +16 -16
  38. package/src/integrations/entercommand.js +1 -1
  39. package/src/integrations/findandreplace.d.ts +21 -21
  40. package/src/integrations/findandreplace.js +1 -1
  41. package/src/integrations/font.d.ts +17 -17
  42. package/src/integrations/font.js +1 -1
  43. package/src/integrations/formatpainter.d.ts +17 -17
  44. package/src/integrations/formatpainter.js +1 -1
  45. package/src/integrations/heading.d.ts +17 -17
  46. package/src/integrations/heading.js +1 -1
  47. package/src/integrations/highlight.d.ts +17 -17
  48. package/src/integrations/highlight.js +1 -1
  49. package/src/integrations/horizontalline.d.ts +17 -17
  50. package/src/integrations/horizontalline.js +1 -1
  51. package/src/integrations/htmlembed.d.ts +17 -17
  52. package/src/integrations/htmlembed.js +1 -1
  53. package/src/integrations/image.d.ts +17 -17
  54. package/src/integrations/image.js +1 -1
  55. package/src/integrations/imagereplace.d.ts +23 -23
  56. package/src/integrations/imagereplace.js +1 -1
  57. package/src/integrations/importword.d.ts +18 -18
  58. package/src/integrations/importword.js +1 -1
  59. package/src/integrations/indent.d.ts +17 -17
  60. package/src/integrations/indent.js +1 -1
  61. package/src/integrations/inputcommand.d.ts +16 -16
  62. package/src/integrations/inputcommand.js +1 -1
  63. package/src/integrations/link.d.ts +17 -17
  64. package/src/integrations/link.js +1 -1
  65. package/src/integrations/list.d.ts +17 -17
  66. package/src/integrations/list.js +1 -1
  67. package/src/integrations/listproperties.d.ts +29 -29
  68. package/src/integrations/listproperties.js +1 -1
  69. package/src/integrations/mediaembed.d.ts +17 -17
  70. package/src/integrations/mediaembed.js +1 -1
  71. package/src/integrations/mention.d.ts +17 -17
  72. package/src/integrations/mention.js +1 -1
  73. package/src/integrations/pagebreak.d.ts +17 -17
  74. package/src/integrations/pagebreak.js +1 -1
  75. package/src/integrations/paragraph.d.ts +17 -17
  76. package/src/integrations/paragraph.js +1 -1
  77. package/src/integrations/removeformat.d.ts +17 -17
  78. package/src/integrations/removeformat.js +1 -1
  79. package/src/integrations/restrictededitingmode.d.ts +17 -17
  80. package/src/integrations/restrictededitingmode.js +1 -1
  81. package/src/integrations/shiftentercommand.d.ts +16 -16
  82. package/src/integrations/shiftentercommand.js +1 -1
  83. package/src/integrations/standardeditingmode.d.ts +17 -17
  84. package/src/integrations/standardeditingmode.js +1 -1
  85. package/src/integrations/style.d.ts +18 -18
  86. package/src/integrations/style.js +1 -1
  87. package/src/integrations/table.d.ts +42 -42
  88. package/src/integrations/table.js +1 -1
  89. package/src/integrations/tablecaption.d.ts +22 -22
  90. package/src/integrations/tablecaption.js +1 -1
  91. package/src/integrations/tableclipboard.d.ts +19 -19
  92. package/src/integrations/tableclipboard.js +1 -1
  93. package/src/integrations/tablecolumnresize.d.ts +26 -26
  94. package/src/integrations/tablecolumnresize.js +1 -1
  95. package/src/integrations/tableheadings.d.ts +22 -22
  96. package/src/integrations/tableheadings.js +1 -1
  97. package/src/integrations/tablemergesplit.d.ts +22 -22
  98. package/src/integrations/tablemergesplit.js +1 -1
  99. package/src/integrations/tableofcontents.d.ts +17 -17
  100. package/src/integrations/tableofcontents.js +1 -1
  101. package/src/integrations/tableproperties.d.ts +27 -27
  102. package/src/integrations/tableproperties.js +1 -1
  103. package/src/integrations/template.d.ts +17 -17
  104. package/src/integrations/template.js +1 -1
  105. package/src/integrations/title.d.ts +17 -17
  106. package/src/integrations/title.js +1 -1
  107. package/src/integrations/undo.d.ts +17 -17
  108. package/src/integrations/undo.js +1 -1
  109. package/src/integrations/utils.d.ts +21 -21
  110. package/src/integrations/utils.js +1 -1
  111. package/src/suggestion.d.ts +276 -276
  112. package/src/suggestion.js +1 -1
  113. package/src/suggestiondescriptionfactory.d.ts +163 -163
  114. package/src/suggestiondescriptionfactory.js +1 -1
  115. package/src/trackchanges.d.ts +244 -244
  116. package/src/trackchanges.js +1 -1
  117. package/src/trackchangesconfig.d.ts +75 -75
  118. package/src/trackchangesdata.d.ts +41 -41
  119. package/src/trackchangesdata.js +1 -1
  120. package/src/trackchangesediting.d.ts +468 -467
  121. package/src/trackchangesediting.js +1 -1
  122. package/src/trackchangesui.d.ts +38 -38
  123. package/src/trackchangesui.js +1 -1
  124. package/src/ui/suggestioncontroller.d.ts +37 -37
  125. package/src/ui/suggestioncontroller.js +1 -1
  126. package/src/ui/view/basesuggestionthreadview.d.ts +170 -170
  127. package/src/ui/view/basesuggestionthreadview.js +1 -1
  128. package/src/ui/view/suggestionthreadview.d.ts +182 -182
  129. package/src/ui/view/suggestionthreadview.js +1 -1
  130. package/src/utils/common-translations.d.ts +9 -9
  131. package/src/utils/common-translations.js +1 -1
  132. package/src/utils/utils.d.ts +30 -30
  133. package/src/utils/utils.js +1 -1
  134. package/theme/icons/track-changes-accept.svg +1 -1
  135. package/theme/icons/track-changes-discard.svg +1 -1
  136. package/theme/icons/track-changes.svg +1 -1
@@ -1,467 +1,468 @@
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/trackchangesediting
7
- * @publicApi
8
- */
9
- import { Plugin, PendingActions, type Editor } from 'ckeditor5/src/core';
10
- import { type Element, type Range } from 'ckeditor5/src/engine';
11
- import { Users } from 'ckeditor5-collaboration/src/collaboration-core';
12
- import TrackChangesCommand from './commands/trackchangescommand';
13
- import Suggestion, { type SuggestionJSON } from './suggestion';
14
- import TrackChangesAlignment from './integrations/alignment';
15
- import TrackChangesBasicStyles from './integrations/basicstyles';
16
- import TrackChangesBlockQuote from './integrations/blockquote';
17
- import TrackChangesCKBox from './integrations/ckbox';
18
- import TrackChangesCodeBlock from './integrations/codeblock';
19
- import TrackChangesComments from './integrations/comments';
20
- import TrackChangesDeleteCommand from './integrations/deletecommand';
21
- import TrackChangesDocumentList from './integrations/documentlist';
22
- import TrackChangesEnterCommand from './integrations/entercommand';
23
- import TrackChangesFindAndReplace from './integrations/findandreplace';
24
- import TrackChangesFont from './integrations/font';
25
- import TrackChangesFormatPainter from './integrations/formatpainter';
26
- import TrackChangesHeading from './integrations/heading';
27
- import TrackChangesHighlight from './integrations/highlight';
28
- import TrackChangesHorizontalLine from './integrations/horizontalline';
29
- import TrackChangesHtmlEmbed from './integrations/htmlembed';
30
- import TrackChangesImage from './integrations/image';
31
- import TrackChangesImageReplace from './integrations/imagereplace';
32
- import TrackChangesImportWord from './integrations/importword';
33
- import TrackChangesIndent from './integrations/indent';
34
- import TrackChangesInputCommand from './integrations/inputcommand';
35
- import TrackChangesLink from './integrations/link';
36
- import TrackChangesList from './integrations/list';
37
- import TrackChangesListProperties from './integrations/listproperties';
38
- import TrackChangesMediaEmbed from './integrations/mediaembed';
39
- import TrackChangesMention from './integrations/mention';
40
- import TrackChangesPageBreak from './integrations/pagebreak';
41
- import TrackChangesParagraph from './integrations/paragraph';
42
- import TrackChangesRemoveFormat from './integrations/removeformat';
43
- import TrackChangesRestrictedEditingMode from './integrations/restrictededitingmode';
44
- import TrackChangesShiftEnterCommand from './integrations/shiftentercommand';
45
- import TrackChangesStandardEditingMode from './integrations/standardeditingmode';
46
- import TrackChangesStylesDropdown from './integrations/style';
47
- import TrackChangesTable from './integrations/table';
48
- import TrackChangesTableMergeSplit from './integrations/tablemergesplit';
49
- import TrackChangesTableHeadings from './integrations/tableheadings';
50
- import TrackChangesTableClipboard from './integrations/tableclipboard';
51
- import TrackChangesTableColumnResize from './integrations/tablecolumnresize';
52
- import TrackChangesTemplate from './integrations/template';
53
- import TrackChangesTableOfContents from './integrations/tableofcontents';
54
- import TrackChangesTitle from './integrations/title';
55
- import TrackChangesUndo from './integrations/undo';
56
- import TrackChangesTableCaption from './integrations/tablecaption';
57
- import TrackChangesDocumentListProperties from './integrations/documentlistproperties';
58
- import TrackChangesTableProperties from './integrations/tableproperties';
59
- import type { SuggestionData, TrackChangesAdapter } from './trackchanges';
60
- /**
61
- * Provides editing part of the {@link module:track-changes/trackchanges~TrackChanges track changes plugin}.
62
- */
63
- export default class TrackChangesEditing extends Plugin {
64
- /**
65
- * List of names of active (highlighted) markers.
66
- *
67
- * @observable
68
- */
69
- activeMarkers: Array<string>;
70
- /**
71
- * Reference to command that turns the track changes mode on and off.
72
- */
73
- trackChangesCommand: TrackChangesCommand;
74
- static get requires(): readonly ["CommentsRepository", typeof Users, typeof PendingActions, typeof TrackChangesAlignment, typeof TrackChangesBasicStyles, typeof TrackChangesBlockQuote, typeof TrackChangesCKBox, typeof TrackChangesCodeBlock, typeof TrackChangesComments, typeof TrackChangesDeleteCommand, typeof TrackChangesDocumentList, typeof TrackChangesDocumentListProperties, typeof TrackChangesEnterCommand, typeof TrackChangesFindAndReplace, typeof TrackChangesFont, typeof TrackChangesFormatPainter, typeof TrackChangesHeading, typeof TrackChangesHighlight, typeof TrackChangesHorizontalLine, typeof TrackChangesHtmlEmbed, typeof TrackChangesImage, typeof TrackChangesImageReplace, typeof TrackChangesImportWord, typeof TrackChangesIndent, typeof TrackChangesInputCommand, typeof TrackChangesLink, typeof TrackChangesList, typeof TrackChangesListProperties, typeof TrackChangesMediaEmbed, typeof TrackChangesMention, typeof TrackChangesPageBreak, typeof TrackChangesParagraph, typeof TrackChangesRemoveFormat, typeof TrackChangesRestrictedEditingMode, typeof TrackChangesShiftEnterCommand, typeof TrackChangesStandardEditingMode, typeof TrackChangesStylesDropdown, typeof TrackChangesTable, typeof TrackChangesTableMergeSplit, typeof TrackChangesTableHeadings, typeof TrackChangesTableCaption, typeof TrackChangesTableClipboard, typeof TrackChangesTableColumnResize, typeof TrackChangesTableOfContents, typeof TrackChangesTableProperties, typeof TrackChangesTemplate, typeof TrackChangesTitle, typeof TrackChangesUndo];
75
- static get pluginName(): "TrackChangesEditing";
76
- /**
77
- * @inheritDoc
78
- */
79
- constructor(editor: Editor);
80
- /**
81
- * @inheritDoc
82
- */
83
- init(): void;
84
- /**
85
- * An adapter object that should communicate with the data source to fetch or save the suggestion data.
86
- */
87
- set adapter(adapter: TrackChangesAdapter | null);
88
- get adapter(): TrackChangesAdapter | null;
89
- getSuggestions(options?: {
90
- skipNotAttached?: boolean;
91
- toJSON?: false;
92
- }): Array<Suggestion>;
93
- getSuggestions(options: {
94
- skipNotAttached?: boolean;
95
- toJSON: true;
96
- }): Array<SuggestionJSON>;
97
- getSuggestions(options: {
98
- skipNotAttached?: boolean;
99
- toJSON: boolean;
100
- }): Array<Suggestion> | Array<SuggestionJSON>;
101
- /**
102
- * Returns {@link module:track-changes/suggestion~Suggestion suggestion} for given `id`.
103
- */
104
- getSuggestion(id: string): Suggestion;
105
- /**
106
- * Checks if {@link module:track-changes/suggestion~Suggestion suggestion} of given `id` exist.
107
- */
108
- hasSuggestion(id: string): boolean;
109
- /**
110
- * Adds suggestion data.
111
- */
112
- addSuggestionData(data: SuggestionData): Suggestion;
113
- /**
114
- * Accept all adjacent suggestions.
115
- */
116
- acceptSuggestion(suggestion: Suggestion): void;
117
- /**
118
- * Discard all adjacent suggestions.
119
- */
120
- discardSuggestion(suggestion: Suggestion): void;
121
- /**
122
- * Enables command with given `commandName` in track changes mode.
123
- *
124
- * When a command gets enabled in track changes mode, its original `execute()` method is overwritten by provided `callback()`
125
- * function. The `callback()` should provide alternative logic to be executed instead.
126
- *
127
- * The `callback()` function is passed one or more parameters:
128
- *
129
- * * the first parameter is `executeCommand()`, a function that upon calling will fire the original `execute()` method,
130
- * * then, all the parameters passed to original `execute()` call are passed.
131
- *
132
- * Using those parameters it is possible to call the original command in the `callback()` (or skip it) and also do
133
- * something before and/or after that call.
134
- *
135
- * If `callback` is not set then the command will work the same both when track changes is on and off.
136
- *
137
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
138
- * features} guide to learn more about enabling your feature in the suggestion mode.
139
- */
140
- enableCommand(commandName: string, callback?: Function): void;
141
- /**
142
- * Temporarily disable track changes to accept or discard a suggestion without intercepting original calls.
143
- */
144
- forceDefaultExecution(callback: Function): unknown;
145
- /**
146
- * Marks a single-range insertion suggestion on the given `range`.
147
- *
148
- * It is expected that given `range` is a range on just-created content and does not intersect with any other suggestion ranges.
149
- *
150
- * ```ts
151
- * trackChangesPlugin.markInsertion( insertionRange );
152
- * trackChangesPlugin.markInsertion( insertionRange, 'customInsertion' );
153
- * ```
154
- *
155
- * This method should be used in `callback()` in
156
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
157
- * to inform the track changes plugin about a suggestion that happened.
158
- *
159
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
160
- * this method are bound with one undo step.
161
- *
162
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
163
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
164
- * the existing suggestion).
165
- *
166
- * See {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
167
- * features guide} to learn more about enabling your feature in the suggestion mode.
168
- *
169
- * @param range Range on content which got inserted.
170
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set,
171
- * suggestion will be a generic insertion suggestion. Only suggestions with the same sub type will be joined.
172
- * @param attributes Custom suggestion attributes.
173
- * @returns Suggestion created or expanded as a result of execution of this
174
- * method. Returns `null` if given `range` was collapsed (so no suggestion was created or expanded).
175
- */
176
- markInsertion(range: Range, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
177
- /**
178
- * Marks a multi-range insertion suggestion spanning over given `ranges`.
179
- *
180
- * It is expected that given `ranges` are ranges on just-created content and do not intersect with any other suggestion ranges.
181
- *
182
- * Each range of a multi-range insertion suggestion should contain exactly one element and should not be created on a text content.
183
- *
184
- * ```ts
185
- * trackChangesPlugin.markMultiRangeInsertion( insertionRanges );
186
- * trackChangesPlugin.markMultiRangeInsertion( insertionRanges, 'customInsertion' );
187
- * ```
188
- *
189
- * This method should be used in `callback()` in
190
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
191
- * to inform the track changes plugin about a suggestion that happened.
192
- *
193
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
194
- * this method are bound with one undo step.
195
- *
196
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
197
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
198
- * the existing suggestion).
199
- *
200
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
201
- * features} guide to learn more about enabling your feature in the suggestion mode.
202
- *
203
- * @param ranges Ranges which got inserted.
204
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. Only suggestions
205
- * with the same subtype will be joined.
206
- * @param attributes Custom suggestion attributes.
207
- * @returns {module:track-changes/suggestion~Suggestion} Suggestion created or expanded as a result of execution of this method.
208
- */
209
- markMultiRangeInsertion(ranges: Array<Range>, subType?: string, attributes?: Record<string, unknown>): Suggestion;
210
- /**
211
- * Marks an inline format suggestion on the given `range`.
212
- *
213
- * This type of format suggestion is suitable for formatting (attribute) changes on inline elements and text.
214
- * Changes like adding bold or setting a link use this type of format suggestion.
215
- *
216
- * Inline format suggestions are directly coupled with editor commands and represent a command execution on given `range`.
217
- *
218
- * ```ts
219
- * trackChangesPlugin.markInlineFormat( formattedRange, {
220
- * commandName: 'bold',
221
- * commandParams: [ { forceValue: true } ]
222
- * } );
223
- *
224
- * trackChangesPlugin.markInlineFormat( formattedRange, formatData, 'customSubType' );
225
- * ```
226
- *
227
- * This method should be used in `callback()` in
228
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
229
- * to inform the track changes plugin about a suggestion that happened.
230
- *
231
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
232
- * this method are bound with one undo step.
233
- *
234
- * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
235
- *
236
- * If an inline format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
237
- * and no suggestion is created. This supports partial intersections with insertion suggestions.
238
- *
239
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
240
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
241
- * the existing suggestion).
242
- *
243
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
244
- * features} guide to learn more about enabling your feature in the suggestion mode.
245
- *
246
- * @param range Range on which the change happened.
247
- * @param formatData Command parameters.
248
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
249
- * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
250
- * all inline format suggestions that perform the same changes have the same sub type (and can be properly handled).
251
- * @param attributes Custom suggestion attributes.
252
- */
253
- markInlineFormat(range: Range, formatData: FormatData, subType?: string | null, attributes?: Record<string, unknown>): null;
254
- /**
255
- * Marks a block format suggestion on the given `range`.
256
- *
257
- * Block format suggestions are directly coupled with editor commands and represent a command execution on the given range or element.
258
- *
259
- * This type of format suggestion is suitable for formatting (attribute) changes on block elements.
260
- * Changes like resizing image, applying block quote or changing header type use this type of format suggestion.
261
- *
262
- * Pass element if the suggestion should be marked exactly on that element. This is suitable if the command modifies exactly given
263
- * element (for example, changes an attribute of that element). If such element is split, an additional suggestion is
264
- * created for the new element:
265
- *
266
- * [<paragraph>Foobar]</paragraph> --> [<paragraph>Foo]</paragraph>[<paragraph>bar]</paragraph>
267
- *
268
- * Pass range for suggestions representing commands that can be executed on multiple blocks at once. This is suitable for commands
269
- * which modifies all the block elements found in given range (those commands usually operate on selection ranges). This creates
270
- * only one suggestion for the whole range and do not create additional suggestions if blocks in the range are split:
271
- *
272
- * [<paragraph>Foobar]</paragraph> --> [<paragraph>Foo</paragraph><paragraph>Bar]</paragraph>
273
- *
274
- * Example of marking block format suggestion on an element:
275
- *
276
- * ```ts
277
- * trackChangesPlugin.markBlockFormat( paragraphElement, {
278
- * commandName: 'heading',
279
- * commandParams: [ { value: 'heading1' } ],
280
- * formatGroupId: 'blockName'
281
- * } );
282
- * ```
283
- *
284
- * Example of marking block format suggestion on a range:
285
- *
286
- * ```ts
287
- * plugin.markBlockFormat( selectionRange, {
288
- * commandName: 'blockQuote',
289
- * commandParams: [ { forceValue: true } ]
290
- * } );
291
- * ```
292
- *
293
- * If you pass a range, it should start before the first element to change and end:
294
- *
295
- * * for blocks (like paragraph, list item, heading, etc.): at the end of the last element to change,
296
- * * for objects (like image, table, media embed, etc.): after the last element to change.
297
- *
298
- * ```xml
299
- * [<paragraph>Foo</paragraph><paragraph>Bar]</paragraph><paragraph>Xyz</paragraph>
300
- * [<paragraph>Foo</paragraph><imageBlock src="foo.jpg"></imageBlock>]<paragraph>Xyz</paragraph>
301
- * ```
302
- *
303
- * This method should be used in `callback()` in
304
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
305
- * to inform the track changes plugin about a suggestion that happened.
306
- *
307
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
308
- * this method are bound with one undo step.
309
- *
310
- * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
311
- *
312
- * If a block format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
313
- * and no suggestion is created. Note that this does not support partial intersections with insertion suggestions
314
- * (as opposed to inline format suggestions).
315
- *
316
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
317
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
318
- * the existing suggestion).
319
- *
320
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
321
- * features} guide to learn more about enabling your feature in the suggestion mode.
322
- *
323
- * @param elementOrRange Element or range on which the change happened.
324
- * @param formatData Command parameters and additional suggestion parameters.
325
- * @param affectedElements Elements (other than `elementOrRange`) that are
326
- * also affected by the command execution. This parameter is used when the effect of the command execution is larger than
327
- * `elementOrRange`. It is used when determining whether the change should be applied directly or if the suggestion should be created.
328
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
329
- * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
330
- * all block format suggestions that perform the same changes have the same sub types (and can be properly handled).
331
- * @param attributes Custom suggestion attributes.
332
- */
333
- markBlockFormat(elementOrRange: Element | Range, formatData: FormatData, affectedElements?: Array<Element>, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
334
- /**
335
- * Marks a multi-range block format suggestion on given `elements`.
336
- *
337
- * See {@link module:track-changes/trackchangesediting~TrackChangesEditing#markBlockFormat `TrackChangesEditing#markBlockFormat()`}
338
- * to learn more about block format suggestions. Note that this method can be used only on elements (not on ranges).
339
- *
340
- * This method is useful for creating a format suggestion on multiple elements which are not siblings, so one range cannot be used.
341
- *
342
- * This method should be used in `callback()` in
343
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
344
- * to inform the track changes plugin about a suggestion that happened.
345
- *
346
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
347
- * this method are bound with one undo step.
348
- *
349
- * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
350
- *
351
- * If a block format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
352
- * and no suggestion is created. Note that this does not support partial intersections with insertion suggestions
353
- * (as opposed to inline format suggestions).
354
- *
355
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
356
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
357
- * the existing suggestion).
358
- *
359
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
360
- * features} guide to learn more about enabling your feature in the suggestion mode.
361
- *
362
- * @param elementsOrRanges Elements or ranges
363
- * on which the change happened.
364
- * @param formatData Command parameters and additional suggestion parameters.
365
- * @param affectedElements Elements (other than `elementOrRange`) that are
366
- * also affected by the command execution. This parameter is used when the effect of the command execution is larger than
367
- * `elementOrRange`. It is used when determining whether the change should be applied directly or if the suggestion should be created.
368
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
369
- * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
370
- * all block format suggestions that perform the same changes have the same sub types (and can be properly handled).
371
- * @param attributes Custom suggestion attributes.
372
- */
373
- markMultiRangeBlockFormat(elementsOrRanges: Array<Element> | Array<Range>, formatData: FormatData, affectedElements?: Array<Element>, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
374
- /**
375
- * Marks a single-range deletion suggestion on given `range`.
376
- *
377
- * If the `range` to mark intersects with or contains insertion suggestions created by the local user,
378
- * those suggestions may be removed in a part or in the whole together with their content.
379
- *
380
- * ```ts
381
- * trackChangesPlugin.markDeletion( deletedRange );
382
- * trackChangesPlugin.markDeletion( deletedRange, 'customDeletion' );
383
- * ```
384
- *
385
- * This method should be used in `callback()` in
386
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
387
- * to inform the track changes plugin about a suggestion that happened.
388
- *
389
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
390
- * this method are bound with one undo step.
391
- *
392
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
393
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
394
- * the existing suggestion).
395
- *
396
- * See {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
397
- * features guide} to learn more about enabling your feature in the suggestion mode.
398
- *
399
- * @param range Range which should be marked as deletion suggestion.
400
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set,
401
- * suggestion will be a generic insertion suggestion. Only suggestions with the same sub type will be joined.
402
- * @param attributes Custom suggestion attributes.
403
- * @returns Suggestion created or expanded as a result of execution of this
404
- * method. Returns `null` if given `range` was collapsed or the deletion was in insertion (so no suggestion was created or expanded).
405
- */
406
- markDeletion(range: Range, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
407
- /**
408
- * Marks a multi-range deletion suggestion spanning over given `ranges`.
409
- *
410
- * Each range of a multi-range deletion suggestion should contain exactly one element and should not be created on a text content.
411
- *
412
- * If the `ranges` to mark contain or are contained in insertion suggestions created by the local user, those
413
- * insertion suggestions may be removed together with their content.
414
- *
415
- * ```ts
416
- * trackChangesPlugin.markMultiRangeDeletion( deletedRanges );
417
- * trackChangesPlugin.markMultiRangeDeletion( deletedRanges, 'customDeletion' );
418
- * ```
419
- *
420
- * This method should be used in `callback()` in
421
- * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
422
- * to inform the track changes plugin about a suggestion that happened.
423
- *
424
- * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
425
- * this method are bound with one undo step.
426
- *
427
- * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
428
- * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
429
- * the existing suggestion).
430
- *
431
- * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
432
- * features} guide to learn more about enabling your feature in the suggestion mode.
433
- *
434
- * @param ranges Ranges which should be marked as deletion suggestion.
435
- * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set.
436
- * Only suggestions with the same sub type will be joined.
437
- * @param attributes Custom suggestion attributes.
438
- * @returns Suggestion created or expanded as a result of execution of this method.
439
- */
440
- markMultiRangeDeletion(ranges: Array<Range>, subType?: string, attributes?: Record<string, unknown>): Suggestion | null;
441
- }
442
- /**
443
- * Command parameters and additional suggestion parameters. Passed value is also saved in
444
- * {@link module:track-changes/suggestion~Suggestion#data `Suggestion#data`} property.
445
- */
446
- export type FormatData = {
447
- /**
448
- * Name of the command to execute when the suggestion is accepted.
449
- */
450
- commandName: string;
451
- /**
452
- * Parameters with which the command should be executed.
453
- */
454
- commandParams: Array<any>;
455
- /**
456
- * Additional grouping parameter for suggestions. If a suggestion
457
- * would be set on an element which already has a different suggestion with the same `formatGroupId`, the new suggestion will overwrite
458
- * the old one (the old one will be removed). Defaults to `commandName` parameter, so different suggestions of the same command
459
- * overwrite each other. Using this parameter you might expand this behavior so that multiple commands overwrite each other.
460
- */
461
- formatGroupId?: string;
462
- /**
463
- * True when format suggestion uses ranges.
464
- */
465
- multipleBlocks?: boolean;
466
- [i: string]: unknown;
467
- };
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/trackchangesediting
7
+ * @publicApi
8
+ */
9
+ import { Plugin, PendingActions, type Editor } from 'ckeditor5/src/core';
10
+ import { type Element, type Range } from 'ckeditor5/src/engine';
11
+ import { Users } from 'ckeditor5-collaboration/src/collaboration-core';
12
+ import TrackChangesCommand from './commands/trackchangescommand';
13
+ import Suggestion, { type SuggestionJSON } from './suggestion';
14
+ import TrackChangesAIAssistant from './integrations/aiassistant';
15
+ import TrackChangesAlignment from './integrations/alignment';
16
+ import TrackChangesBasicStyles from './integrations/basicstyles';
17
+ import TrackChangesBlockQuote from './integrations/blockquote';
18
+ import TrackChangesCKBox from './integrations/ckbox';
19
+ import TrackChangesCodeBlock from './integrations/codeblock';
20
+ import TrackChangesComments from './integrations/comments';
21
+ import TrackChangesDeleteCommand from './integrations/deletecommand';
22
+ import TrackChangesDocumentList from './integrations/documentlist';
23
+ import TrackChangesEnterCommand from './integrations/entercommand';
24
+ import TrackChangesFindAndReplace from './integrations/findandreplace';
25
+ import TrackChangesFont from './integrations/font';
26
+ import TrackChangesFormatPainter from './integrations/formatpainter';
27
+ import TrackChangesHeading from './integrations/heading';
28
+ import TrackChangesHighlight from './integrations/highlight';
29
+ import TrackChangesHorizontalLine from './integrations/horizontalline';
30
+ import TrackChangesHtmlEmbed from './integrations/htmlembed';
31
+ import TrackChangesImage from './integrations/image';
32
+ import TrackChangesImageReplace from './integrations/imagereplace';
33
+ import TrackChangesImportWord from './integrations/importword';
34
+ import TrackChangesIndent from './integrations/indent';
35
+ import TrackChangesInputCommand from './integrations/inputcommand';
36
+ import TrackChangesLink from './integrations/link';
37
+ import TrackChangesList from './integrations/list';
38
+ import TrackChangesListProperties from './integrations/listproperties';
39
+ import TrackChangesMediaEmbed from './integrations/mediaembed';
40
+ import TrackChangesMention from './integrations/mention';
41
+ import TrackChangesPageBreak from './integrations/pagebreak';
42
+ import TrackChangesParagraph from './integrations/paragraph';
43
+ import TrackChangesRemoveFormat from './integrations/removeformat';
44
+ import TrackChangesRestrictedEditingMode from './integrations/restrictededitingmode';
45
+ import TrackChangesShiftEnterCommand from './integrations/shiftentercommand';
46
+ import TrackChangesStandardEditingMode from './integrations/standardeditingmode';
47
+ import TrackChangesStylesDropdown from './integrations/style';
48
+ import TrackChangesTable from './integrations/table';
49
+ import TrackChangesTableMergeSplit from './integrations/tablemergesplit';
50
+ import TrackChangesTableHeadings from './integrations/tableheadings';
51
+ import TrackChangesTableClipboard from './integrations/tableclipboard';
52
+ import TrackChangesTableColumnResize from './integrations/tablecolumnresize';
53
+ import TrackChangesTemplate from './integrations/template';
54
+ import TrackChangesTableOfContents from './integrations/tableofcontents';
55
+ import TrackChangesTitle from './integrations/title';
56
+ import TrackChangesUndo from './integrations/undo';
57
+ import TrackChangesTableCaption from './integrations/tablecaption';
58
+ import TrackChangesDocumentListProperties from './integrations/documentlistproperties';
59
+ import TrackChangesTableProperties from './integrations/tableproperties';
60
+ import type { SuggestionData, TrackChangesAdapter } from './trackchanges';
61
+ /**
62
+ * Provides editing part of the {@link module:track-changes/trackchanges~TrackChanges track changes plugin}.
63
+ */
64
+ export default class TrackChangesEditing extends Plugin {
65
+ /**
66
+ * List of names of active (highlighted) markers.
67
+ *
68
+ * @observable
69
+ */
70
+ activeMarkers: Array<string>;
71
+ /**
72
+ * Reference to command that turns the track changes mode on and off.
73
+ */
74
+ trackChangesCommand: TrackChangesCommand;
75
+ static get requires(): readonly ["CommentsRepository", typeof Users, typeof PendingActions, typeof TrackChangesAIAssistant, typeof TrackChangesAlignment, typeof TrackChangesBasicStyles, typeof TrackChangesBlockQuote, typeof TrackChangesCKBox, typeof TrackChangesCodeBlock, typeof TrackChangesComments, typeof TrackChangesDeleteCommand, typeof TrackChangesDocumentList, typeof TrackChangesDocumentListProperties, typeof TrackChangesEnterCommand, typeof TrackChangesFindAndReplace, typeof TrackChangesFont, typeof TrackChangesFormatPainter, typeof TrackChangesHeading, typeof TrackChangesHighlight, typeof TrackChangesHorizontalLine, typeof TrackChangesHtmlEmbed, typeof TrackChangesImage, typeof TrackChangesImageReplace, typeof TrackChangesImportWord, typeof TrackChangesIndent, typeof TrackChangesInputCommand, typeof TrackChangesLink, typeof TrackChangesList, typeof TrackChangesListProperties, typeof TrackChangesMediaEmbed, typeof TrackChangesMention, typeof TrackChangesPageBreak, typeof TrackChangesParagraph, typeof TrackChangesRemoveFormat, typeof TrackChangesRestrictedEditingMode, typeof TrackChangesShiftEnterCommand, typeof TrackChangesStandardEditingMode, typeof TrackChangesStylesDropdown, typeof TrackChangesTable, typeof TrackChangesTableMergeSplit, typeof TrackChangesTableHeadings, typeof TrackChangesTableCaption, typeof TrackChangesTableClipboard, typeof TrackChangesTableColumnResize, typeof TrackChangesTableOfContents, typeof TrackChangesTableProperties, typeof TrackChangesTemplate, typeof TrackChangesTitle, typeof TrackChangesUndo];
76
+ static get pluginName(): "TrackChangesEditing";
77
+ /**
78
+ * @inheritDoc
79
+ */
80
+ constructor(editor: Editor);
81
+ /**
82
+ * @inheritDoc
83
+ */
84
+ init(): void;
85
+ /**
86
+ * An adapter object that should communicate with the data source to fetch or save the suggestion data.
87
+ */
88
+ set adapter(adapter: TrackChangesAdapter | null);
89
+ get adapter(): TrackChangesAdapter | null;
90
+ getSuggestions(options?: {
91
+ skipNotAttached?: boolean;
92
+ toJSON?: false;
93
+ }): Array<Suggestion>;
94
+ getSuggestions(options: {
95
+ skipNotAttached?: boolean;
96
+ toJSON: true;
97
+ }): Array<SuggestionJSON>;
98
+ getSuggestions(options: {
99
+ skipNotAttached?: boolean;
100
+ toJSON: boolean;
101
+ }): Array<Suggestion> | Array<SuggestionJSON>;
102
+ /**
103
+ * Returns {@link module:track-changes/suggestion~Suggestion suggestion} for given `id`.
104
+ */
105
+ getSuggestion(id: string): Suggestion;
106
+ /**
107
+ * Checks if {@link module:track-changes/suggestion~Suggestion suggestion} of given `id` exist.
108
+ */
109
+ hasSuggestion(id: string): boolean;
110
+ /**
111
+ * Adds suggestion data.
112
+ */
113
+ addSuggestionData(data: SuggestionData): Suggestion;
114
+ /**
115
+ * Accept all adjacent suggestions.
116
+ */
117
+ acceptSuggestion(suggestion: Suggestion): void;
118
+ /**
119
+ * Discard all adjacent suggestions.
120
+ */
121
+ discardSuggestion(suggestion: Suggestion): void;
122
+ /**
123
+ * Enables command with given `commandName` in track changes mode.
124
+ *
125
+ * When a command gets enabled in track changes mode, its original `execute()` method is overwritten by provided `callback()`
126
+ * function. The `callback()` should provide alternative logic to be executed instead.
127
+ *
128
+ * The `callback()` function is passed one or more parameters:
129
+ *
130
+ * * the first parameter is `executeCommand()`, a function that upon calling will fire the original `execute()` method,
131
+ * * then, all the parameters passed to original `execute()` call are passed.
132
+ *
133
+ * Using those parameters it is possible to call the original command in the `callback()` (or skip it) and also do
134
+ * something before and/or after that call.
135
+ *
136
+ * If `callback` is not set then the command will work the same both when track changes is on and off.
137
+ *
138
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
139
+ * features} guide to learn more about enabling your feature in the suggestion mode.
140
+ */
141
+ enableCommand(commandName: string, callback?: Function): void;
142
+ /**
143
+ * Temporarily disable track changes to accept or discard a suggestion without intercepting original calls.
144
+ */
145
+ forceDefaultExecution(callback: Function): unknown;
146
+ /**
147
+ * Marks a single-range insertion suggestion on the given `range`.
148
+ *
149
+ * It is expected that given `range` is a range on just-created content and does not intersect with any other suggestion ranges.
150
+ *
151
+ * ```ts
152
+ * trackChangesPlugin.markInsertion( insertionRange );
153
+ * trackChangesPlugin.markInsertion( insertionRange, 'customInsertion' );
154
+ * ```
155
+ *
156
+ * This method should be used in `callback()` in
157
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
158
+ * to inform the track changes plugin about a suggestion that happened.
159
+ *
160
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
161
+ * this method are bound with one undo step.
162
+ *
163
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
164
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
165
+ * the existing suggestion).
166
+ *
167
+ * See {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
168
+ * features guide} to learn more about enabling your feature in the suggestion mode.
169
+ *
170
+ * @param range Range on content which got inserted.
171
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set,
172
+ * suggestion will be a generic insertion suggestion. Only suggestions with the same sub type will be joined.
173
+ * @param attributes Custom suggestion attributes.
174
+ * @returns Suggestion created or expanded as a result of execution of this
175
+ * method. Returns `null` if given `range` was collapsed (so no suggestion was created or expanded).
176
+ */
177
+ markInsertion(range: Range, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
178
+ /**
179
+ * Marks a multi-range insertion suggestion spanning over given `ranges`.
180
+ *
181
+ * It is expected that given `ranges` are ranges on just-created content and do not intersect with any other suggestion ranges.
182
+ *
183
+ * Each range of a multi-range insertion suggestion should contain exactly one element and should not be created on a text content.
184
+ *
185
+ * ```ts
186
+ * trackChangesPlugin.markMultiRangeInsertion( insertionRanges );
187
+ * trackChangesPlugin.markMultiRangeInsertion( insertionRanges, 'customInsertion' );
188
+ * ```
189
+ *
190
+ * This method should be used in `callback()` in
191
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
192
+ * to inform the track changes plugin about a suggestion that happened.
193
+ *
194
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
195
+ * this method are bound with one undo step.
196
+ *
197
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
198
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
199
+ * the existing suggestion).
200
+ *
201
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
202
+ * features} guide to learn more about enabling your feature in the suggestion mode.
203
+ *
204
+ * @param ranges Ranges which got inserted.
205
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. Only suggestions
206
+ * with the same subtype will be joined.
207
+ * @param attributes Custom suggestion attributes.
208
+ * @returns {module:track-changes/suggestion~Suggestion} Suggestion created or expanded as a result of execution of this method.
209
+ */
210
+ markMultiRangeInsertion(ranges: Array<Range>, subType?: string, attributes?: Record<string, unknown>): Suggestion;
211
+ /**
212
+ * Marks an inline format suggestion on the given `range`.
213
+ *
214
+ * This type of format suggestion is suitable for formatting (attribute) changes on inline elements and text.
215
+ * Changes like adding bold or setting a link use this type of format suggestion.
216
+ *
217
+ * Inline format suggestions are directly coupled with editor commands and represent a command execution on given `range`.
218
+ *
219
+ * ```ts
220
+ * trackChangesPlugin.markInlineFormat( formattedRange, {
221
+ * commandName: 'bold',
222
+ * commandParams: [ { forceValue: true } ]
223
+ * } );
224
+ *
225
+ * trackChangesPlugin.markInlineFormat( formattedRange, formatData, 'customSubType' );
226
+ * ```
227
+ *
228
+ * This method should be used in `callback()` in
229
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
230
+ * to inform the track changes plugin about a suggestion that happened.
231
+ *
232
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
233
+ * this method are bound with one undo step.
234
+ *
235
+ * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
236
+ *
237
+ * If an inline format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
238
+ * and no suggestion is created. This supports partial intersections with insertion suggestions.
239
+ *
240
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
241
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
242
+ * the existing suggestion).
243
+ *
244
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
245
+ * features} guide to learn more about enabling your feature in the suggestion mode.
246
+ *
247
+ * @param range Range on which the change happened.
248
+ * @param formatData Command parameters.
249
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
250
+ * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
251
+ * all inline format suggestions that perform the same changes have the same sub type (and can be properly handled).
252
+ * @param attributes Custom suggestion attributes.
253
+ */
254
+ markInlineFormat(range: Range, formatData: FormatData, subType?: string | null, attributes?: Record<string, unknown>): null;
255
+ /**
256
+ * Marks a block format suggestion on the given `range`.
257
+ *
258
+ * Block format suggestions are directly coupled with editor commands and represent a command execution on the given range or element.
259
+ *
260
+ * This type of format suggestion is suitable for formatting (attribute) changes on block elements.
261
+ * Changes like resizing image, applying block quote or changing header type use this type of format suggestion.
262
+ *
263
+ * Pass element if the suggestion should be marked exactly on that element. This is suitable if the command modifies exactly given
264
+ * element (for example, changes an attribute of that element). If such element is split, an additional suggestion is
265
+ * created for the new element:
266
+ *
267
+ * [<paragraph>Foobar]</paragraph> --> [<paragraph>Foo]</paragraph>[<paragraph>bar]</paragraph>
268
+ *
269
+ * Pass range for suggestions representing commands that can be executed on multiple blocks at once. This is suitable for commands
270
+ * which modifies all the block elements found in given range (those commands usually operate on selection ranges). This creates
271
+ * only one suggestion for the whole range and do not create additional suggestions if blocks in the range are split:
272
+ *
273
+ * [<paragraph>Foobar]</paragraph> --> [<paragraph>Foo</paragraph><paragraph>Bar]</paragraph>
274
+ *
275
+ * Example of marking block format suggestion on an element:
276
+ *
277
+ * ```ts
278
+ * trackChangesPlugin.markBlockFormat( paragraphElement, {
279
+ * commandName: 'heading',
280
+ * commandParams: [ { value: 'heading1' } ],
281
+ * formatGroupId: 'blockName'
282
+ * } );
283
+ * ```
284
+ *
285
+ * Example of marking block format suggestion on a range:
286
+ *
287
+ * ```ts
288
+ * plugin.markBlockFormat( selectionRange, {
289
+ * commandName: 'blockQuote',
290
+ * commandParams: [ { forceValue: true } ]
291
+ * } );
292
+ * ```
293
+ *
294
+ * If you pass a range, it should start before the first element to change and end:
295
+ *
296
+ * * for blocks (like paragraph, list item, heading, etc.): at the end of the last element to change,
297
+ * * for objects (like image, table, media embed, etc.): after the last element to change.
298
+ *
299
+ * ```xml
300
+ * [<paragraph>Foo</paragraph><paragraph>Bar]</paragraph><paragraph>Xyz</paragraph>
301
+ * [<paragraph>Foo</paragraph><imageBlock src="foo.jpg"></imageBlock>]<paragraph>Xyz</paragraph>
302
+ * ```
303
+ *
304
+ * This method should be used in `callback()` in
305
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
306
+ * to inform the track changes plugin about a suggestion that happened.
307
+ *
308
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
309
+ * this method are bound with one undo step.
310
+ *
311
+ * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
312
+ *
313
+ * If a block format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
314
+ * and no suggestion is created. Note that this does not support partial intersections with insertion suggestions
315
+ * (as opposed to inline format suggestions).
316
+ *
317
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
318
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
319
+ * the existing suggestion).
320
+ *
321
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
322
+ * features} guide to learn more about enabling your feature in the suggestion mode.
323
+ *
324
+ * @param elementOrRange Element or range on which the change happened.
325
+ * @param formatData Command parameters and additional suggestion parameters.
326
+ * @param affectedElements Elements (other than `elementOrRange`) that are
327
+ * also affected by the command execution. This parameter is used when the effect of the command execution is larger than
328
+ * `elementOrRange`. It is used when determining whether the change should be applied directly or if the suggestion should be created.
329
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
330
+ * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
331
+ * all block format suggestions that perform the same changes have the same sub types (and can be properly handled).
332
+ * @param attributes Custom suggestion attributes.
333
+ */
334
+ markBlockFormat(elementOrRange: Element | Range, formatData: FormatData, affectedElements?: Array<Element>, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
335
+ /**
336
+ * Marks a multi-range block format suggestion on given `elements`.
337
+ *
338
+ * See {@link module:track-changes/trackchangesediting~TrackChangesEditing#markBlockFormat `TrackChangesEditing#markBlockFormat()`}
339
+ * to learn more about block format suggestions. Note that this method can be used only on elements (not on ranges).
340
+ *
341
+ * This method is useful for creating a format suggestion on multiple elements which are not siblings, so one range cannot be used.
342
+ *
343
+ * This method should be used in `callback()` in
344
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
345
+ * to inform the track changes plugin about a suggestion that happened.
346
+ *
347
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
348
+ * this method are bound with one undo step.
349
+ *
350
+ * When a format suggestion is accepted the command is executed based on parameters passed in `formatData`.
351
+ *
352
+ * If a block format suggestion is marked inside the local user's insertion suggestion, the change is applied directly
353
+ * and no suggestion is created. Note that this does not support partial intersections with insertion suggestions
354
+ * (as opposed to inline format suggestions).
355
+ *
356
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
357
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
358
+ * the existing suggestion).
359
+ *
360
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
361
+ * features} guide to learn more about enabling your feature in the suggestion mode.
362
+ *
363
+ * @param elementsOrRanges Elements or ranges
364
+ * on which the change happened.
365
+ * @param formatData Command parameters and additional suggestion parameters.
366
+ * @param affectedElements Elements (other than `elementOrRange`) that are
367
+ * also affected by the command execution. This parameter is used when the effect of the command execution is larger than
368
+ * `elementOrRange`. It is used when determining whether the change should be applied directly or if the suggestion should be created.
369
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set
370
+ * (which is the default and recommended use) the sub type value is a string hash generated from `formatData`. This guarantees that
371
+ * all block format suggestions that perform the same changes have the same sub types (and can be properly handled).
372
+ * @param attributes Custom suggestion attributes.
373
+ */
374
+ markMultiRangeBlockFormat(elementsOrRanges: Array<Element> | Array<Range>, formatData: FormatData, affectedElements?: Array<Element>, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
375
+ /**
376
+ * Marks a single-range deletion suggestion on given `range`.
377
+ *
378
+ * If the `range` to mark intersects with or contains insertion suggestions created by the local user,
379
+ * those suggestions may be removed in a part or in the whole together with their content.
380
+ *
381
+ * ```ts
382
+ * trackChangesPlugin.markDeletion( deletedRange );
383
+ * trackChangesPlugin.markDeletion( deletedRange, 'customDeletion' );
384
+ * ```
385
+ *
386
+ * This method should be used in `callback()` in
387
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
388
+ * to inform the track changes plugin about a suggestion that happened.
389
+ *
390
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
391
+ * this method are bound with one undo step.
392
+ *
393
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
394
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
395
+ * the existing suggestion).
396
+ *
397
+ * See {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
398
+ * features guide} to learn more about enabling your feature in the suggestion mode.
399
+ *
400
+ * @param range Range which should be marked as deletion suggestion.
401
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set. If not set,
402
+ * suggestion will be a generic insertion suggestion. Only suggestions with the same sub type will be joined.
403
+ * @param attributes Custom suggestion attributes.
404
+ * @returns Suggestion created or expanded as a result of execution of this
405
+ * method. Returns `null` if given `range` was collapsed or the deletion was in insertion (so no suggestion was created or expanded).
406
+ */
407
+ markDeletion(range: Range, subType?: string | null, attributes?: Record<string, unknown>): Suggestion | null;
408
+ /**
409
+ * Marks a multi-range deletion suggestion spanning over given `ranges`.
410
+ *
411
+ * Each range of a multi-range deletion suggestion should contain exactly one element and should not be created on a text content.
412
+ *
413
+ * If the `ranges` to mark contain or are contained in insertion suggestions created by the local user, those
414
+ * insertion suggestions may be removed together with their content.
415
+ *
416
+ * ```ts
417
+ * trackChangesPlugin.markMultiRangeDeletion( deletedRanges );
418
+ * trackChangesPlugin.markMultiRangeDeletion( deletedRanges, 'customDeletion' );
419
+ * ```
420
+ *
421
+ * This method should be used in `callback()` in
422
+ * {@link module:track-changes/trackchangesediting~TrackChangesEditing#enableCommand `TrackChangesEditing#enableCommand`}
423
+ * to inform the track changes plugin about a suggestion that happened.
424
+ *
425
+ * Always call this method inside `model.change()` or `model.enqueueChange()` block to ensure that all operations performed by
426
+ * this method are bound with one undo step.
427
+ *
428
+ * If possible, the new suggestion will be joined with an existing suggestion (of the same type). This happens only if
429
+ * the suggestions are created by the same user and have similar attributes (i.e. passed `attributes` do not conflict with
430
+ * the existing suggestion).
431
+ *
432
+ * See the {@glink features/collaboration/track-changes/track-changes-custom-features Integrating track changes with custom
433
+ * features} guide to learn more about enabling your feature in the suggestion mode.
434
+ *
435
+ * @param ranges Ranges which should be marked as deletion suggestion.
436
+ * @param subType Suggestion {@link module:track-changes/suggestion~Suggestion#subType} to set.
437
+ * Only suggestions with the same sub type will be joined.
438
+ * @param attributes Custom suggestion attributes.
439
+ * @returns Suggestion created or expanded as a result of execution of this method.
440
+ */
441
+ markMultiRangeDeletion(ranges: Array<Range>, subType?: string, attributes?: Record<string, unknown>): Suggestion | null;
442
+ }
443
+ /**
444
+ * Command parameters and additional suggestion parameters. Passed value is also saved in
445
+ * {@link module:track-changes/suggestion~Suggestion#data `Suggestion#data`} property.
446
+ */
447
+ export type FormatData = {
448
+ /**
449
+ * Name of the command to execute when the suggestion is accepted.
450
+ */
451
+ commandName: string;
452
+ /**
453
+ * Parameters with which the command should be executed.
454
+ */
455
+ commandParams: Array<any>;
456
+ /**
457
+ * Additional grouping parameter for suggestions. If a suggestion
458
+ * would be set on an element which already has a different suggestion with the same `formatGroupId`, the new suggestion will overwrite
459
+ * the old one (the old one will be removed). Defaults to `commandName` parameter, so different suggestions of the same command
460
+ * overwrite each other. Using this parameter you might expand this behavior so that multiple commands overwrite each other.
461
+ */
462
+ formatGroupId?: string;
463
+ /**
464
+ * True when format suggestion uses ranges.
465
+ */
466
+ multipleBlocks?: boolean;
467
+ [i: string]: unknown;
468
+ };