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