@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.
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/build/track-changes.js +1 -1
- package/package.json +3 -3
- package/src/augmentation.d.ts +40 -40
- package/src/commands/acceptsuggestioncommand.d.ts +24 -24
- package/src/commands/acceptsuggestioncommand.js +1 -1
- package/src/commands/discardsuggestioncommand.d.ts +24 -24
- package/src/commands/discardsuggestioncommand.js +1 -1
- package/src/commands/executeonallsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonallsuggestionscommand.js +1 -1
- package/src/commands/executeonselectedsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonselectedsuggestionscommand.js +1 -1
- package/src/commands/trackchangescommand.d.ts +26 -26
- package/src/commands/trackchangescommand.js +1 -1
- package/src/index.d.ts +16 -16
- package/src/integrations/aiassistant.d.ts +17 -0
- package/src/integrations/aiassistant.js +23 -0
- package/src/integrations/alignment.d.ts +17 -17
- package/src/integrations/alignment.js +1 -1
- package/src/integrations/basicstyles.d.ts +17 -17
- package/src/integrations/basicstyles.js +1 -1
- package/src/integrations/blockquote.d.ts +17 -17
- package/src/integrations/blockquote.js +1 -1
- package/src/integrations/ckbox.d.ts +17 -17
- package/src/integrations/ckbox.js +1 -1
- package/src/integrations/codeblock.d.ts +17 -17
- package/src/integrations/codeblock.js +1 -1
- package/src/integrations/comments.d.ts +14 -14
- package/src/integrations/comments.js +1 -1
- package/src/integrations/deletecommand.d.ts +17 -17
- package/src/integrations/deletecommand.js +1 -1
- package/src/integrations/documentlist.d.ts +17 -17
- package/src/integrations/documentlist.js +1 -1
- package/src/integrations/documentlistproperties.d.ts +29 -29
- package/src/integrations/documentlistproperties.js +1 -1
- package/src/integrations/entercommand.d.ts +16 -16
- package/src/integrations/entercommand.js +1 -1
- package/src/integrations/findandreplace.d.ts +21 -21
- package/src/integrations/findandreplace.js +1 -1
- package/src/integrations/font.d.ts +17 -17
- package/src/integrations/font.js +1 -1
- package/src/integrations/formatpainter.d.ts +17 -17
- package/src/integrations/formatpainter.js +1 -1
- package/src/integrations/heading.d.ts +17 -17
- package/src/integrations/heading.js +1 -1
- package/src/integrations/highlight.d.ts +17 -17
- package/src/integrations/highlight.js +1 -1
- package/src/integrations/horizontalline.d.ts +17 -17
- package/src/integrations/horizontalline.js +1 -1
- package/src/integrations/htmlembed.d.ts +17 -17
- package/src/integrations/htmlembed.js +1 -1
- package/src/integrations/image.d.ts +17 -17
- package/src/integrations/image.js +1 -1
- package/src/integrations/imagereplace.d.ts +23 -23
- package/src/integrations/imagereplace.js +1 -1
- package/src/integrations/importword.d.ts +18 -18
- package/src/integrations/importword.js +1 -1
- package/src/integrations/indent.d.ts +17 -17
- package/src/integrations/indent.js +1 -1
- package/src/integrations/inputcommand.d.ts +16 -16
- package/src/integrations/inputcommand.js +1 -1
- package/src/integrations/link.d.ts +17 -17
- package/src/integrations/link.js +1 -1
- package/src/integrations/list.d.ts +17 -17
- package/src/integrations/list.js +1 -1
- package/src/integrations/listproperties.d.ts +29 -29
- package/src/integrations/listproperties.js +1 -1
- package/src/integrations/mediaembed.d.ts +17 -17
- package/src/integrations/mediaembed.js +1 -1
- package/src/integrations/mention.d.ts +17 -17
- package/src/integrations/mention.js +1 -1
- package/src/integrations/pagebreak.d.ts +17 -17
- package/src/integrations/pagebreak.js +1 -1
- package/src/integrations/paragraph.d.ts +17 -17
- package/src/integrations/paragraph.js +1 -1
- package/src/integrations/removeformat.d.ts +17 -17
- package/src/integrations/removeformat.js +1 -1
- package/src/integrations/restrictededitingmode.d.ts +17 -17
- package/src/integrations/restrictededitingmode.js +1 -1
- package/src/integrations/shiftentercommand.d.ts +16 -16
- package/src/integrations/shiftentercommand.js +1 -1
- package/src/integrations/standardeditingmode.d.ts +17 -17
- package/src/integrations/standardeditingmode.js +1 -1
- package/src/integrations/style.d.ts +18 -18
- package/src/integrations/style.js +1 -1
- package/src/integrations/table.d.ts +42 -42
- package/src/integrations/table.js +1 -1
- package/src/integrations/tablecaption.d.ts +22 -22
- package/src/integrations/tablecaption.js +1 -1
- package/src/integrations/tableclipboard.d.ts +19 -19
- package/src/integrations/tableclipboard.js +1 -1
- package/src/integrations/tablecolumnresize.d.ts +26 -26
- package/src/integrations/tablecolumnresize.js +1 -1
- package/src/integrations/tableheadings.d.ts +22 -22
- package/src/integrations/tableheadings.js +1 -1
- package/src/integrations/tablemergesplit.d.ts +22 -22
- package/src/integrations/tablemergesplit.js +1 -1
- package/src/integrations/tableofcontents.d.ts +17 -17
- package/src/integrations/tableofcontents.js +1 -1
- package/src/integrations/tableproperties.d.ts +27 -27
- package/src/integrations/tableproperties.js +1 -1
- package/src/integrations/template.d.ts +17 -17
- package/src/integrations/template.js +1 -1
- package/src/integrations/title.d.ts +17 -17
- package/src/integrations/title.js +1 -1
- package/src/integrations/undo.d.ts +17 -17
- package/src/integrations/undo.js +1 -1
- package/src/integrations/utils.d.ts +21 -21
- package/src/integrations/utils.js +1 -1
- package/src/suggestion.d.ts +276 -276
- package/src/suggestion.js +1 -1
- package/src/suggestiondescriptionfactory.d.ts +163 -163
- package/src/suggestiondescriptionfactory.js +1 -1
- package/src/trackchanges.d.ts +244 -244
- package/src/trackchanges.js +1 -1
- package/src/trackchangesconfig.d.ts +75 -75
- package/src/trackchangesdata.d.ts +41 -41
- package/src/trackchangesdata.js +1 -1
- package/src/trackchangesediting.d.ts +468 -467
- package/src/trackchangesediting.js +1 -1
- package/src/trackchangesui.d.ts +38 -38
- package/src/trackchangesui.js +1 -1
- package/src/ui/suggestioncontroller.d.ts +37 -37
- package/src/ui/suggestioncontroller.js +1 -1
- package/src/ui/view/basesuggestionthreadview.d.ts +170 -170
- package/src/ui/view/basesuggestionthreadview.js +1 -1
- package/src/ui/view/suggestionthreadview.d.ts +182 -182
- package/src/ui/view/suggestionthreadview.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/src/utils/utils.d.ts +30 -30
- package/src/utils/utils.js +1 -1
- package/theme/icons/track-changes-accept.svg +1 -1
- package/theme/icons/track-changes-discard.svg +1 -1
- package/theme/icons/track-changes.svg +1 -1
package/src/suggestion.d.ts
CHANGED
|
@@ -1,276 +1,276 @@
|
|
|
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/suggestion
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Element, type Marker, type Model, type Range, type Item } from 'ckeditor5/src/engine';
|
|
10
|
-
import type { User } from 'ckeditor5-collaboration/src/collaboration-core';
|
|
11
|
-
import type { CommentThread } from '@ckeditor/ckeditor5-comments';
|
|
12
|
-
import type { FormatData } from './trackchangesediting';
|
|
13
|
-
declare const Suggestion_base: {
|
|
14
|
-
new (): import("ckeditor5/src/utils").Observable;
|
|
15
|
-
prototype: import("ckeditor5/src/utils").Observable; /**
|
|
16
|
-
* Previous suggestion in suggestions chain.
|
|
17
|
-
*
|
|
18
|
-
* Chained suggestions should be handled as one entity.
|
|
19
|
-
*
|
|
20
|
-
* @observable
|
|
21
|
-
*/
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Represents a singular suggestion that is tracked by track changes plugin.
|
|
25
|
-
*
|
|
26
|
-
* `Suggestion` instances are created and handled by {@link module:track-changes/trackchanges~TrackChanges track changes plugin}.
|
|
27
|
-
*/
|
|
28
|
-
export default class Suggestion extends Suggestion_base {
|
|
29
|
-
/**
|
|
30
|
-
* Suggestion ID.
|
|
31
|
-
*/
|
|
32
|
-
readonly id: string;
|
|
33
|
-
/**
|
|
34
|
-
* Suggestion type.
|
|
35
|
-
*/
|
|
36
|
-
type: SuggestionType;
|
|
37
|
-
/**
|
|
38
|
-
* Suggestion sub-type.
|
|
39
|
-
*
|
|
40
|
-
* This is an additional identifier for suggestions. Two suggestions of the same type may have different sub-types to differentiate
|
|
41
|
-
* suggestions behavior and handle interactions between suggestions.
|
|
42
|
-
*
|
|
43
|
-
* Sub-type is used for:
|
|
44
|
-
*
|
|
45
|
-
* * suggestions joining (only suggestions with the same sub-type can be joined),
|
|
46
|
-
* * suggestions custom callbacks (fired when adding, deleting and joining suggestions).
|
|
47
|
-
*/
|
|
48
|
-
subType: string | null;
|
|
49
|
-
/**
|
|
50
|
-
* The author of the change marked by the suggestion.
|
|
51
|
-
*/
|
|
52
|
-
author: User;
|
|
53
|
-
/**
|
|
54
|
-
* The user which saved the suggestion data in the database.
|
|
55
|
-
*
|
|
56
|
-
* Usually the same as author but may be different in some cases (e.g. when suggestion was added from an external source).
|
|
57
|
-
*/
|
|
58
|
-
creator: User;
|
|
59
|
-
/**
|
|
60
|
-
* The flag indicating whether the suggestion comes from an external source.
|
|
61
|
-
*/
|
|
62
|
-
isExternal: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Additional suggestion data.
|
|
65
|
-
*/
|
|
66
|
-
data: FormatData | null;
|
|
67
|
-
/**
|
|
68
|
-
* Date when the suggestion was saved in the database.
|
|
69
|
-
*/
|
|
70
|
-
createdAt: Date | null;
|
|
71
|
-
/**
|
|
72
|
-
* Date when the change marked by the suggestion was made.
|
|
73
|
-
*
|
|
74
|
-
* Usually the same as {@link #createdAt `createdAt`} but may be different in some cases
|
|
75
|
-
* (e.g. when suggestion was added from an external source).
|
|
76
|
-
*
|
|
77
|
-
* @observable
|
|
78
|
-
*/
|
|
79
|
-
authoredAt: Date | null;
|
|
80
|
-
/**
|
|
81
|
-
* Custom suggestion attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
|
|
82
|
-
*
|
|
83
|
-
* @observable
|
|
84
|
-
*/
|
|
85
|
-
attributes: {
|
|
86
|
-
[k: string]: unknown;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Previous suggestion in suggestions chain.
|
|
90
|
-
*
|
|
91
|
-
* Chained suggestions should be handled as one entity.
|
|
92
|
-
*
|
|
93
|
-
* @observable
|
|
94
|
-
*/
|
|
95
|
-
previous: Suggestion | null;
|
|
96
|
-
/**
|
|
97
|
-
* Next suggestion in suggestions chain.
|
|
98
|
-
*
|
|
99
|
-
* Chained suggestions should be handled as one entity.
|
|
100
|
-
*
|
|
101
|
-
* @observable
|
|
102
|
-
*/
|
|
103
|
-
next: Suggestion | null;
|
|
104
|
-
/**
|
|
105
|
-
* Comment thread model for comments added to this suggestion.
|
|
106
|
-
*
|
|
107
|
-
* @observable
|
|
108
|
-
*/
|
|
109
|
-
commentThread: CommentThread | null;
|
|
110
|
-
constructor(model: Model, options: SuggestionOptions);
|
|
111
|
-
/**
|
|
112
|
-
* The first (most-previous) suggestion in this suggestion chain.
|
|
113
|
-
*/
|
|
114
|
-
get head(): Suggestion;
|
|
115
|
-
/**
|
|
116
|
-
* Informs whether suggestion has at least one comment.
|
|
117
|
-
*/
|
|
118
|
-
get hasComments(): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Informs whether the suggestion is a multi-range suggestion or a single-range suggestion.
|
|
121
|
-
*
|
|
122
|
-
* This is evaluated basing on the marker name belonging to this suggestion.
|
|
123
|
-
* Even if only one marker belongs to the suggestion at a given time it can still be a multi range suggestion.
|
|
124
|
-
*/
|
|
125
|
-
get isMultiRange(): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Informs whether the suggestion is still in the editor content.
|
|
128
|
-
*
|
|
129
|
-
* Returns `true` if there is at least one marker suggestion in the editor content.
|
|
130
|
-
*/
|
|
131
|
-
get isInContent(): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Binds given marker name to this suggestion.
|
|
134
|
-
*/
|
|
135
|
-
addMarkerName(markerName: string): void;
|
|
136
|
-
/**
|
|
137
|
-
* Returns all names of markers belonging to this suggestion.
|
|
138
|
-
*/
|
|
139
|
-
getMarkerNames(): Array<string>;
|
|
140
|
-
/**
|
|
141
|
-
* Returns all markers belonging to this suggestion.
|
|
142
|
-
*/
|
|
143
|
-
getMarkers(): Array<Marker>;
|
|
144
|
-
/**
|
|
145
|
-
* Returns the first marker belonging to this suggestion, i.e the first marker that was added to this suggestion
|
|
146
|
-
* and not removed yet.
|
|
147
|
-
*
|
|
148
|
-
* This method is useful if you know that the suggestion has only one marker and want to process it.
|
|
149
|
-
*/
|
|
150
|
-
getFirstMarker(): Marker | null;
|
|
151
|
-
/**
|
|
152
|
-
* Removes all markers from the suggestion and the editor content.
|
|
153
|
-
*/
|
|
154
|
-
removeMarkers(): void;
|
|
155
|
-
/**
|
|
156
|
-
* Removes marker with the given name from the suggestion and the editor content.
|
|
157
|
-
*/
|
|
158
|
-
removeMarker(markerName: string): void;
|
|
159
|
-
/**
|
|
160
|
-
* Adds a new range to this suggestion. It is assumed that the suggestion is a multi-range suggestion.
|
|
161
|
-
*
|
|
162
|
-
* A marker name is generated from this suggestion's properties and a marker with that name is created and set to a given `range`.
|
|
163
|
-
*/
|
|
164
|
-
addRange(range: Range): void;
|
|
165
|
-
/**
|
|
166
|
-
* Checks if given `range` is intersecting with any of the ranges of markers belonging to this suggestion.
|
|
167
|
-
*/
|
|
168
|
-
isIntersectingWithRange(range: Range): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Returns all ranges of all markers belonging to this suggestion.
|
|
171
|
-
*/
|
|
172
|
-
getRanges(): Array<Range>;
|
|
173
|
-
/**
|
|
174
|
-
* Returns all {@link module:engine/model/item~Item model items} that are in this suggestion.
|
|
175
|
-
*/
|
|
176
|
-
getItems(): Array<Item>;
|
|
177
|
-
/**
|
|
178
|
-
* Returns the first range belonging to this suggestion, i.e. the range of the first marker that was added to
|
|
179
|
-
* this suggestion and not removed yet.
|
|
180
|
-
*
|
|
181
|
-
* This method is useful if you know that the suggestion has only one marker and want to process its range.
|
|
182
|
-
*/
|
|
183
|
-
getFirstRange(): Range | null;
|
|
184
|
-
/**
|
|
185
|
-
* Returns the model element contained in the suggestion.
|
|
186
|
-
*
|
|
187
|
-
* A {@link module:engine/model/element~Element model element} is considered as contained if there is exactly
|
|
188
|
-
* one range in the suggestion, and that range contains exactly one element.
|
|
189
|
-
*
|
|
190
|
-
* Returns `null` if there is no contained element.
|
|
191
|
-
*/
|
|
192
|
-
getContainedElement(): Element | null;
|
|
193
|
-
/**
|
|
194
|
-
* Accepts the suggestion.
|
|
195
|
-
*/
|
|
196
|
-
accept(): void;
|
|
197
|
-
/**
|
|
198
|
-
* Discards the suggestion.
|
|
199
|
-
*/
|
|
200
|
-
discard(): void;
|
|
201
|
-
/**
|
|
202
|
-
* Returns all suggestions that are in this suggestion chain.
|
|
203
|
-
*/
|
|
204
|
-
getAllAdjacentSuggestions(): Array<Suggestion>;
|
|
205
|
-
/**
|
|
206
|
-
* Adds suggestion attribute.
|
|
207
|
-
*
|
|
208
|
-
* Suggestion attributes are custom data that can be set and used by features
|
|
209
|
-
* built around suggestions. Use it to store your feature data with other suggestion data.
|
|
210
|
-
*
|
|
211
|
-
* ```ts
|
|
212
|
-
* suggestion.setAttribute( 'isImportant', true );
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* You can group multiple values in an object, using dot notation:
|
|
216
|
-
*
|
|
217
|
-
* ```ts
|
|
218
|
-
* suggestion.setAttribute( 'customData.type', 'image' );
|
|
219
|
-
* suggestion.setAttribute( 'customData.src', 'foo.jpg' );
|
|
220
|
-
* ```
|
|
221
|
-
*
|
|
222
|
-
* Attributes set on the suggestion can be accessed through `attribute` property:
|
|
223
|
-
*
|
|
224
|
-
* ```ts
|
|
225
|
-
* const isImportant = suggestion.attributes.isImportant;
|
|
226
|
-
* const type = suggestion.attributes.customData.type;
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* You can also observe `attributes` property or bind other properties to it:
|
|
230
|
-
*
|
|
231
|
-
* ```ts
|
|
232
|
-
* myObj.bind( 'customData' ).to( suggestion, 'attributes', attributes => attributes.customData );
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* Whenever `setAttribute()` or `removeAttribute()` is called, `attributes` property
|
|
236
|
-
* is re-set and observables are refreshed.
|
|
237
|
-
*/
|
|
238
|
-
setAttribute(name: string, value: unknown): void;
|
|
239
|
-
/**
|
|
240
|
-
* Removes suggestion attribute.
|
|
241
|
-
*
|
|
242
|
-
* See also {@link #setAttribute}
|
|
243
|
-
*/
|
|
244
|
-
removeAttribute(name: string): void;
|
|
245
|
-
toJSON(): SuggestionJSON;
|
|
246
|
-
/**
|
|
247
|
-
* Returns a random string that can be used as additional identifier for the marker name for suggestions that are multi range.
|
|
248
|
-
*/
|
|
249
|
-
static getMultiRangeId(): string;
|
|
250
|
-
}
|
|
251
|
-
export interface SuggestionOptions {
|
|
252
|
-
id: string;
|
|
253
|
-
type: SuggestionType;
|
|
254
|
-
subType: string | null;
|
|
255
|
-
attributes: {
|
|
256
|
-
[k: string]: unknown;
|
|
257
|
-
};
|
|
258
|
-
author: User;
|
|
259
|
-
creator: User;
|
|
260
|
-
onAccept: Function;
|
|
261
|
-
onDiscard: Function;
|
|
262
|
-
onAttributesChange: Function;
|
|
263
|
-
}
|
|
264
|
-
export interface SuggestionJSON {
|
|
265
|
-
id: string;
|
|
266
|
-
type: string;
|
|
267
|
-
authorId: string;
|
|
268
|
-
createdAt: Date | null;
|
|
269
|
-
hasComments?: boolean;
|
|
270
|
-
data?: FormatData | null;
|
|
271
|
-
attributes: {
|
|
272
|
-
[k: string]: unknown;
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
export type SuggestionType = 'insertion' | 'deletion' | 'formatInline' | 'formatBlock';
|
|
276
|
-
export {};
|
|
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/suggestion
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Element, type Marker, type Model, type Range, type Item } from 'ckeditor5/src/engine';
|
|
10
|
+
import type { User } from 'ckeditor5-collaboration/src/collaboration-core';
|
|
11
|
+
import type { CommentThread } from '@ckeditor/ckeditor5-comments';
|
|
12
|
+
import type { FormatData } from './trackchangesediting';
|
|
13
|
+
declare const Suggestion_base: {
|
|
14
|
+
new (): import("ckeditor5/src/utils").Observable;
|
|
15
|
+
prototype: import("ckeditor5/src/utils").Observable; /**
|
|
16
|
+
* Previous suggestion in suggestions chain.
|
|
17
|
+
*
|
|
18
|
+
* Chained suggestions should be handled as one entity.
|
|
19
|
+
*
|
|
20
|
+
* @observable
|
|
21
|
+
*/
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Represents a singular suggestion that is tracked by track changes plugin.
|
|
25
|
+
*
|
|
26
|
+
* `Suggestion` instances are created and handled by {@link module:track-changes/trackchanges~TrackChanges track changes plugin}.
|
|
27
|
+
*/
|
|
28
|
+
export default class Suggestion extends Suggestion_base {
|
|
29
|
+
/**
|
|
30
|
+
* Suggestion ID.
|
|
31
|
+
*/
|
|
32
|
+
readonly id: string;
|
|
33
|
+
/**
|
|
34
|
+
* Suggestion type.
|
|
35
|
+
*/
|
|
36
|
+
type: SuggestionType;
|
|
37
|
+
/**
|
|
38
|
+
* Suggestion sub-type.
|
|
39
|
+
*
|
|
40
|
+
* This is an additional identifier for suggestions. Two suggestions of the same type may have different sub-types to differentiate
|
|
41
|
+
* suggestions behavior and handle interactions between suggestions.
|
|
42
|
+
*
|
|
43
|
+
* Sub-type is used for:
|
|
44
|
+
*
|
|
45
|
+
* * suggestions joining (only suggestions with the same sub-type can be joined),
|
|
46
|
+
* * suggestions custom callbacks (fired when adding, deleting and joining suggestions).
|
|
47
|
+
*/
|
|
48
|
+
subType: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* The author of the change marked by the suggestion.
|
|
51
|
+
*/
|
|
52
|
+
author: User;
|
|
53
|
+
/**
|
|
54
|
+
* The user which saved the suggestion data in the database.
|
|
55
|
+
*
|
|
56
|
+
* Usually the same as author but may be different in some cases (e.g. when suggestion was added from an external source).
|
|
57
|
+
*/
|
|
58
|
+
creator: User;
|
|
59
|
+
/**
|
|
60
|
+
* The flag indicating whether the suggestion comes from an external source.
|
|
61
|
+
*/
|
|
62
|
+
isExternal: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Additional suggestion data.
|
|
65
|
+
*/
|
|
66
|
+
data: FormatData | null;
|
|
67
|
+
/**
|
|
68
|
+
* Date when the suggestion was saved in the database.
|
|
69
|
+
*/
|
|
70
|
+
createdAt: Date | null;
|
|
71
|
+
/**
|
|
72
|
+
* Date when the change marked by the suggestion was made.
|
|
73
|
+
*
|
|
74
|
+
* Usually the same as {@link #createdAt `createdAt`} but may be different in some cases
|
|
75
|
+
* (e.g. when suggestion was added from an external source).
|
|
76
|
+
*
|
|
77
|
+
* @observable
|
|
78
|
+
*/
|
|
79
|
+
authoredAt: Date | null;
|
|
80
|
+
/**
|
|
81
|
+
* Custom suggestion attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
|
|
82
|
+
*
|
|
83
|
+
* @observable
|
|
84
|
+
*/
|
|
85
|
+
attributes: {
|
|
86
|
+
[k: string]: unknown;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Previous suggestion in suggestions chain.
|
|
90
|
+
*
|
|
91
|
+
* Chained suggestions should be handled as one entity.
|
|
92
|
+
*
|
|
93
|
+
* @observable
|
|
94
|
+
*/
|
|
95
|
+
previous: Suggestion | null;
|
|
96
|
+
/**
|
|
97
|
+
* Next suggestion in suggestions chain.
|
|
98
|
+
*
|
|
99
|
+
* Chained suggestions should be handled as one entity.
|
|
100
|
+
*
|
|
101
|
+
* @observable
|
|
102
|
+
*/
|
|
103
|
+
next: Suggestion | null;
|
|
104
|
+
/**
|
|
105
|
+
* Comment thread model for comments added to this suggestion.
|
|
106
|
+
*
|
|
107
|
+
* @observable
|
|
108
|
+
*/
|
|
109
|
+
commentThread: CommentThread | null;
|
|
110
|
+
constructor(model: Model, options: SuggestionOptions);
|
|
111
|
+
/**
|
|
112
|
+
* The first (most-previous) suggestion in this suggestion chain.
|
|
113
|
+
*/
|
|
114
|
+
get head(): Suggestion;
|
|
115
|
+
/**
|
|
116
|
+
* Informs whether suggestion has at least one comment.
|
|
117
|
+
*/
|
|
118
|
+
get hasComments(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Informs whether the suggestion is a multi-range suggestion or a single-range suggestion.
|
|
121
|
+
*
|
|
122
|
+
* This is evaluated basing on the marker name belonging to this suggestion.
|
|
123
|
+
* Even if only one marker belongs to the suggestion at a given time it can still be a multi range suggestion.
|
|
124
|
+
*/
|
|
125
|
+
get isMultiRange(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Informs whether the suggestion is still in the editor content.
|
|
128
|
+
*
|
|
129
|
+
* Returns `true` if there is at least one marker suggestion in the editor content.
|
|
130
|
+
*/
|
|
131
|
+
get isInContent(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Binds given marker name to this suggestion.
|
|
134
|
+
*/
|
|
135
|
+
addMarkerName(markerName: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Returns all names of markers belonging to this suggestion.
|
|
138
|
+
*/
|
|
139
|
+
getMarkerNames(): Array<string>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns all markers belonging to this suggestion.
|
|
142
|
+
*/
|
|
143
|
+
getMarkers(): Array<Marker>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the first marker belonging to this suggestion, i.e the first marker that was added to this suggestion
|
|
146
|
+
* and not removed yet.
|
|
147
|
+
*
|
|
148
|
+
* This method is useful if you know that the suggestion has only one marker and want to process it.
|
|
149
|
+
*/
|
|
150
|
+
getFirstMarker(): Marker | null;
|
|
151
|
+
/**
|
|
152
|
+
* Removes all markers from the suggestion and the editor content.
|
|
153
|
+
*/
|
|
154
|
+
removeMarkers(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Removes marker with the given name from the suggestion and the editor content.
|
|
157
|
+
*/
|
|
158
|
+
removeMarker(markerName: string): void;
|
|
159
|
+
/**
|
|
160
|
+
* Adds a new range to this suggestion. It is assumed that the suggestion is a multi-range suggestion.
|
|
161
|
+
*
|
|
162
|
+
* A marker name is generated from this suggestion's properties and a marker with that name is created and set to a given `range`.
|
|
163
|
+
*/
|
|
164
|
+
addRange(range: Range): void;
|
|
165
|
+
/**
|
|
166
|
+
* Checks if given `range` is intersecting with any of the ranges of markers belonging to this suggestion.
|
|
167
|
+
*/
|
|
168
|
+
isIntersectingWithRange(range: Range): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Returns all ranges of all markers belonging to this suggestion.
|
|
171
|
+
*/
|
|
172
|
+
getRanges(): Array<Range>;
|
|
173
|
+
/**
|
|
174
|
+
* Returns all {@link module:engine/model/item~Item model items} that are in this suggestion.
|
|
175
|
+
*/
|
|
176
|
+
getItems(): Array<Item>;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the first range belonging to this suggestion, i.e. the range of the first marker that was added to
|
|
179
|
+
* this suggestion and not removed yet.
|
|
180
|
+
*
|
|
181
|
+
* This method is useful if you know that the suggestion has only one marker and want to process its range.
|
|
182
|
+
*/
|
|
183
|
+
getFirstRange(): Range | null;
|
|
184
|
+
/**
|
|
185
|
+
* Returns the model element contained in the suggestion.
|
|
186
|
+
*
|
|
187
|
+
* A {@link module:engine/model/element~Element model element} is considered as contained if there is exactly
|
|
188
|
+
* one range in the suggestion, and that range contains exactly one element.
|
|
189
|
+
*
|
|
190
|
+
* Returns `null` if there is no contained element.
|
|
191
|
+
*/
|
|
192
|
+
getContainedElement(): Element | null;
|
|
193
|
+
/**
|
|
194
|
+
* Accepts the suggestion.
|
|
195
|
+
*/
|
|
196
|
+
accept(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Discards the suggestion.
|
|
199
|
+
*/
|
|
200
|
+
discard(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Returns all suggestions that are in this suggestion chain.
|
|
203
|
+
*/
|
|
204
|
+
getAllAdjacentSuggestions(): Array<Suggestion>;
|
|
205
|
+
/**
|
|
206
|
+
* Adds suggestion attribute.
|
|
207
|
+
*
|
|
208
|
+
* Suggestion attributes are custom data that can be set and used by features
|
|
209
|
+
* built around suggestions. Use it to store your feature data with other suggestion data.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* suggestion.setAttribute( 'isImportant', true );
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* You can group multiple values in an object, using dot notation:
|
|
216
|
+
*
|
|
217
|
+
* ```ts
|
|
218
|
+
* suggestion.setAttribute( 'customData.type', 'image' );
|
|
219
|
+
* suggestion.setAttribute( 'customData.src', 'foo.jpg' );
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* Attributes set on the suggestion can be accessed through `attribute` property:
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* const isImportant = suggestion.attributes.isImportant;
|
|
226
|
+
* const type = suggestion.attributes.customData.type;
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* You can also observe `attributes` property or bind other properties to it:
|
|
230
|
+
*
|
|
231
|
+
* ```ts
|
|
232
|
+
* myObj.bind( 'customData' ).to( suggestion, 'attributes', attributes => attributes.customData );
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* Whenever `setAttribute()` or `removeAttribute()` is called, `attributes` property
|
|
236
|
+
* is re-set and observables are refreshed.
|
|
237
|
+
*/
|
|
238
|
+
setAttribute(name: string, value: unknown): void;
|
|
239
|
+
/**
|
|
240
|
+
* Removes suggestion attribute.
|
|
241
|
+
*
|
|
242
|
+
* See also {@link #setAttribute}
|
|
243
|
+
*/
|
|
244
|
+
removeAttribute(name: string): void;
|
|
245
|
+
toJSON(): SuggestionJSON;
|
|
246
|
+
/**
|
|
247
|
+
* Returns a random string that can be used as additional identifier for the marker name for suggestions that are multi range.
|
|
248
|
+
*/
|
|
249
|
+
static getMultiRangeId(): string;
|
|
250
|
+
}
|
|
251
|
+
export interface SuggestionOptions {
|
|
252
|
+
id: string;
|
|
253
|
+
type: SuggestionType;
|
|
254
|
+
subType: string | null;
|
|
255
|
+
attributes: {
|
|
256
|
+
[k: string]: unknown;
|
|
257
|
+
};
|
|
258
|
+
author: User;
|
|
259
|
+
creator: User;
|
|
260
|
+
onAccept: Function;
|
|
261
|
+
onDiscard: Function;
|
|
262
|
+
onAttributesChange: Function;
|
|
263
|
+
}
|
|
264
|
+
export interface SuggestionJSON {
|
|
265
|
+
id: string;
|
|
266
|
+
type: string;
|
|
267
|
+
authorId: string;
|
|
268
|
+
createdAt: Date | null;
|
|
269
|
+
hasComments?: boolean;
|
|
270
|
+
data?: FormatData | null;
|
|
271
|
+
attributes: {
|
|
272
|
+
[k: string]: unknown;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
export type SuggestionType = 'insertion' | 'deletion' | 'formatInline' | 'formatBlock';
|
|
276
|
+
export {};
|
package/src/suggestion.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x2fe3=['hasComments','isExternal','addMarkerName','commentThread','end','toJSON','suggestion:','getMarkers','attributes','_saved','start','authoredAt','getMarkerNames','delete','substr','data','createdAt','head','clear','accept','getRange','onAttributesChange','type','from','decorate','addRange','change','getRanges','removeMarker','reduce','_isDataLoaded','previous','markers','setAttribute','add','_onAttributesChange','next','_onAccept','subType','removeMarkers','nodeBefore','isInContent','size','discard','length','isIntersecting','getMultiRangeId','creator','_onDiscard','@external','get','_markerNames','removeAttribute','set','getFirstRange','_model','map','getItems','getFirstMarker','onDiscard','author'];(function(_0x26f5d3,_0x2fe393){const _0x4885cd=function(_0x368919){while(--_0x368919){_0x26f5d3['push'](_0x26f5d3['shift']());}};_0x4885cd(++_0x2fe393);}(_0x2fe3,0x107));const _0x4885=function(_0x26f5d3,_0x2fe393){_0x26f5d3=_0x26f5d3-0x0;let _0x4885cd=_0x2fe3[_0x26f5d3];return _0x4885cd;};import{Element as _0x257e7c}from'ckeditor5/src/engine';import{ObservableMixin as _0x284ad1,uid as _0x4ecbcc}from'ckeditor5/src/utils';import{cloneDeep as _0x53905a,isEqual as _0x74b05f,set as _0x1142c2,unset as _0x5580dd}from'lodash-es';export default class u extends _0x284ad1(){constructor(_0x43c8c2,_0x513ed7){super(),this[_0x4885('0xb')]=!0x1,this['id']=_0x513ed7['id'],this['type']=_0x513ed7[_0x4885('0x3')],this[_0x4885('0x13')]=_0x513ed7['subType']||null,this[_0x4885('0x29')]=_0x513ed7[_0x4885('0x29')],this['creator']=_0x513ed7[_0x4885('0x1c')]||_0x513ed7[_0x4885('0x29')],this[_0x4885('0x2b')]=Boolean(_0x513ed7[_0x4885('0x32')]&&_0x513ed7[_0x4885('0x32')][_0x4885('0x1e')]),this[_0x4885('0x39')]=null,this['_model']=_0x43c8c2,this[_0x4885('0x12')]=_0x513ed7['onAccept'],this['_onDiscard']=_0x513ed7[_0x4885('0x28')],this[_0x4885('0x10')]=_0x513ed7[_0x4885('0x2')],this[_0x4885('0x20')]=new Set(),this[_0x4885('0x3a')]=null,this[_0x4885('0x22')](_0x4885('0x35'),null),this[_0x4885('0x22')](_0x4885('0x32'),_0x513ed7['attributes']||{}),this[_0x4885('0x22')](_0x4885('0xc'),null),this[_0x4885('0x22')](_0x4885('0x11'),null),this[_0x4885('0x22')](_0x4885('0x2d'),null),this[_0x4885('0x22')](_0x4885('0x33'),!0x1),this[_0x4885('0x5')]('accept'),this[_0x4885('0x5')](_0x4885('0x18'));}get['head'](){let _0xdaeb14=this;for(;_0xdaeb14['previous'];)_0xdaeb14=_0xdaeb14[_0x4885('0xc')];return _0xdaeb14;}get[_0x4885('0x2a')](){return!!this[_0x4885('0x2d')]&&this[_0x4885('0x2d')][_0x4885('0x19')]>0x0;}get['isMultiRange'](){if(0x0==this[_0x4885('0x20')][_0x4885('0x17')])return!0x1;return 0x6==Array[_0x4885('0x4')](this[_0x4885('0x20')])[0x0]['split'](':')['length'];}get[_0x4885('0x16')](){return null!==this[_0x4885('0x27')]();}[_0x4885('0x2c')](_0x1bc994){this[_0x4885('0x20')][_0x4885('0xf')](_0x1bc994);}[_0x4885('0x36')](){return Array[_0x4885('0x4')](this[_0x4885('0x20')]);}[_0x4885('0x31')](){return this[_0x4885('0x36')]()[_0x4885('0x25')](_0x1ab597=>this[_0x4885('0x24')][_0x4885('0xd')][_0x4885('0x1f')](_0x1ab597))['filter'](_0xb33cc1=>_0xb33cc1);}['getFirstMarker'](){return this[_0x4885('0x31')]()[0x0]||null;}[_0x4885('0x14')](){this[_0x4885('0x24')][_0x4885('0x7')](_0x47e935=>{for(const _0x5bb3b9 of this[_0x4885('0x31')]())_0x47e935[_0x4885('0x9')](_0x5bb3b9);}),this[_0x4885('0x20')][_0x4885('0x3c')]();}[_0x4885('0x9')](_0x421a8a){this[_0x4885('0x24')][_0x4885('0x7')](_0x35d133=>{_0x35d133[_0x4885('0x9')](_0x421a8a);}),this[_0x4885('0x20')][_0x4885('0x37')](_0x421a8a);}[_0x4885('0x6')](_0x230ecb){const _0x19e827=_0x4885('0x30')+this[_0x4885('0x3')]+':'+this[_0x4885('0x13')]+':'+this['id']+':'+this[_0x4885('0x1c')]['id']+':'+u[_0x4885('0x1b')]();this[_0x4885('0x2c')](_0x19e827),this['_model']['change'](_0x3d6000=>{_0x3d6000['addMarker'](_0x19e827,{'range':_0x230ecb,'usingOperation':!0x0,'affectsData':!0x0});});}['isIntersectingWithRange'](_0x1a0ed0){for(const _0x797ee of this[_0x4885('0x8')]())if(_0x797ee[_0x4885('0x1a')](_0x1a0ed0))return!0x0;return!0x1;}[_0x4885('0x8')](){return this[_0x4885('0x31')]()[_0x4885('0x25')](_0x24803d=>_0x24803d[_0x4885('0x1')]());}[_0x4885('0x26')](){return this[_0x4885('0x8')]()[_0x4885('0xa')]((_0x1a9264,_0xb5b328)=>[..._0x1a9264,..._0xb5b328['getItems']()],[]);}[_0x4885('0x23')](){var _0x3582d1;return(null===(_0x3582d1=this['getFirstMarker']())||void 0x0===_0x3582d1?void 0x0:_0x3582d1[_0x4885('0x1')]())||null;}['getContainedElement'](){const _0x4992fb=this[_0x4885('0x8')]();if(0x1!=_0x4992fb['length'])return null;const _0x509631=_0x4992fb[0x0],_0x37faf4=_0x509631[_0x4885('0x34')]['nodeAfter'],_0x441b1b=_0x509631[_0x4885('0x2e')][_0x4885('0x15')];return _0x37faf4 instanceof _0x257e7c?_0x37faf4!=_0x441b1b?null:_0x37faf4:null;}[_0x4885('0x0')](){this[_0x4885('0x12')](this[_0x4885('0x8')](),this['data'],this[_0x4885('0x32')]),this[_0x4885('0x14')]();}[_0x4885('0x18')](){this[_0x4885('0x1d')](this['getRanges'](),this[_0x4885('0x39')],this[_0x4885('0x32')]),this['removeMarkers']();}['getAllAdjacentSuggestions'](){const _0x3fc832=[];let _0x16a4fb=this[_0x4885('0x3b')];for(;_0x16a4fb;)_0x3fc832['push'](_0x16a4fb),_0x16a4fb=_0x16a4fb['next'];return _0x3fc832;}[_0x4885('0xe')](_0x5e58a2,_0x122759){const _0x40a839=_0x53905a(this[_0x4885('0x32')]);_0x1142c2(_0x40a839,_0x5e58a2,_0x122759),_0x74b05f(_0x40a839,this[_0x4885('0x32')])||(this[_0x4885('0x32')]=_0x40a839,this[_0x4885('0x10')](_0x40a839));}[_0x4885('0x21')](_0x54dfbc){const _0xcd3631=_0x53905a(this[_0x4885('0x32')]);_0x5580dd(_0xcd3631,_0x54dfbc),_0x74b05f(_0xcd3631,this[_0x4885('0x32')])||(this['attributes']=_0xcd3631,this[_0x4885('0x10')](this[_0x4885('0x32')]));}[_0x4885('0x2f')](){return{'id':this['id'],'type':this[_0x4885('0x13')]?this[_0x4885('0x3')]+':'+this[_0x4885('0x13')]:this[_0x4885('0x3')],'authorId':this[_0x4885('0x1c')]['id'],'createdAt':this['createdAt'],'hasComments':this[_0x4885('0x2a')],'data':this['data'],'attributes':this[_0x4885('0x32')]};}static['getMultiRangeId'](){return _0x4ecbcc()[_0x4885('0x38')](0x1,0x5);}}
|