@ckeditor/ckeditor5-utils 44.1.0 → 44.2.0-alpha.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/dist/index-content.css +2 -2
- package/dist/index-editor.css +2 -2
- package/dist/index.css +2 -2
- package/dist/index.js +194 -47
- package/dist/index.js.map +1 -1
- package/package.json +24 -4
- package/src/abortabledebounce.d.ts +1 -1
- package/src/abortabledebounce.js +1 -1
- package/src/areconnectedthroughproperties.d.ts +1 -1
- package/src/areconnectedthroughproperties.js +1 -1
- package/src/ckeditorerror.d.ts +1 -1
- package/src/ckeditorerror.js +1 -1
- package/src/collection.d.ts +1 -1
- package/src/collection.js +1 -1
- package/src/collectstylesheets.d.ts +13 -0
- package/src/collectstylesheets.js +52 -0
- package/src/comparearrays.d.ts +1 -1
- package/src/comparearrays.js +1 -1
- package/src/config.d.ts +1 -1
- package/src/config.js +1 -1
- package/src/count.d.ts +1 -1
- package/src/count.js +1 -1
- package/src/crc32.d.ts +1 -1
- package/src/crc32.js +1 -1
- package/src/delay.d.ts +1 -1
- package/src/delay.js +1 -1
- package/src/diff.d.ts +1 -1
- package/src/diff.js +1 -1
- package/src/difftochanges.d.ts +1 -1
- package/src/difftochanges.js +1 -1
- package/src/dom/createelement.d.ts +1 -1
- package/src/dom/createelement.js +1 -1
- package/src/dom/emittermixin.d.ts +1 -1
- package/src/dom/emittermixin.js +1 -1
- package/src/dom/findclosestscrollableancestor.d.ts +1 -1
- package/src/dom/findclosestscrollableancestor.js +1 -1
- package/src/dom/getancestors.d.ts +1 -1
- package/src/dom/getancestors.js +1 -1
- package/src/dom/getborderwidths.d.ts +1 -1
- package/src/dom/getborderwidths.js +1 -1
- package/src/dom/getcommonancestor.d.ts +1 -1
- package/src/dom/getcommonancestor.js +1 -1
- package/src/dom/getdatafromelement.d.ts +1 -1
- package/src/dom/getdatafromelement.js +1 -1
- package/src/dom/getpositionedancestor.d.ts +1 -1
- package/src/dom/getpositionedancestor.js +1 -1
- package/src/dom/getrangefrommouseevent.d.ts +1 -1
- package/src/dom/getrangefrommouseevent.js +1 -1
- package/src/dom/global.d.ts +1 -1
- package/src/dom/global.js +1 -1
- package/src/dom/indexof.d.ts +1 -1
- package/src/dom/indexof.js +1 -1
- package/src/dom/insertat.d.ts +1 -1
- package/src/dom/insertat.js +1 -1
- package/src/dom/iscomment.d.ts +1 -1
- package/src/dom/iscomment.js +1 -1
- package/src/dom/isnode.d.ts +1 -1
- package/src/dom/isnode.js +1 -1
- package/src/dom/isrange.d.ts +1 -1
- package/src/dom/isrange.js +1 -1
- package/src/dom/istext.d.ts +1 -1
- package/src/dom/istext.js +1 -1
- package/src/dom/isvalidattributename.d.ts +1 -1
- package/src/dom/isvalidattributename.js +1 -1
- package/src/dom/isvisible.d.ts +1 -1
- package/src/dom/isvisible.js +1 -1
- package/src/dom/iswindow.d.ts +1 -1
- package/src/dom/iswindow.js +1 -1
- package/src/dom/position.d.ts +1 -1
- package/src/dom/position.js +1 -1
- package/src/dom/rect.d.ts +1 -1
- package/src/dom/rect.js +1 -1
- package/src/dom/remove.d.ts +1 -1
- package/src/dom/remove.js +1 -1
- package/src/dom/resizeobserver.d.ts +1 -1
- package/src/dom/resizeobserver.js +1 -1
- package/src/dom/scroll.d.ts +1 -1
- package/src/dom/scroll.js +1 -1
- package/src/dom/setdatainelement.d.ts +1 -1
- package/src/dom/setdatainelement.js +1 -1
- package/src/dom/tounit.d.ts +1 -1
- package/src/dom/tounit.js +1 -1
- package/src/elementreplacer.d.ts +1 -1
- package/src/elementreplacer.js +1 -1
- package/src/emittermixin.d.ts +1 -1
- package/src/emittermixin.js +1 -1
- package/src/env.d.ts +1 -1
- package/src/env.js +1 -1
- package/src/eventinfo.d.ts +1 -1
- package/src/eventinfo.js +1 -1
- package/src/fastdiff.d.ts +1 -1
- package/src/fastdiff.js +1 -1
- package/src/first.d.ts +1 -1
- package/src/first.js +1 -1
- package/src/focustracker.d.ts +1 -1
- package/src/focustracker.js +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
- package/src/inserttopriorityarray.d.ts +1 -1
- package/src/inserttopriorityarray.js +1 -1
- package/src/isiterable.d.ts +1 -1
- package/src/isiterable.js +1 -1
- package/src/keyboard.d.ts +4 -3
- package/src/keyboard.js +8 -4
- package/src/keystrokehandler.d.ts +1 -1
- package/src/keystrokehandler.js +1 -1
- package/src/language.d.ts +1 -1
- package/src/language.js +1 -1
- package/src/locale.d.ts +1 -1
- package/src/locale.js +1 -1
- package/src/mapsequal.d.ts +1 -1
- package/src/mapsequal.js +1 -1
- package/src/mix.d.ts +1 -1
- package/src/mix.js +1 -1
- package/src/nth.d.ts +1 -1
- package/src/nth.js +1 -1
- package/src/objecttomap.d.ts +1 -1
- package/src/objecttomap.js +1 -1
- package/src/observablemixin.d.ts +1 -1
- package/src/observablemixin.js +1 -1
- package/src/parsebase64encodedobject.d.ts +1 -1
- package/src/parsebase64encodedobject.js +1 -1
- package/src/priorities.d.ts +1 -1
- package/src/priorities.js +1 -1
- package/src/retry.d.ts +1 -1
- package/src/retry.js +1 -1
- package/src/splicearray.d.ts +1 -1
- package/src/splicearray.js +1 -1
- package/src/spy.d.ts +1 -1
- package/src/spy.js +1 -1
- package/src/toarray.d.ts +1 -1
- package/src/toarray.js +1 -1
- package/src/tomap.d.ts +1 -1
- package/src/tomap.js +1 -1
- package/src/translation-service.d.ts +1 -1
- package/src/translation-service.js +1 -1
- package/src/uid.d.ts +1 -1
- package/src/uid.js +1 -1
- package/src/unicode.d.ts +1 -1
- package/src/unicode.js +1 -1
- package/src/version.d.ts +2 -2
- package/src/version.js +3 -3
- package/src/wait.d.ts +1 -1
- package/src/wait.js +1 -1
- package/dist/abortabledebounce.d.ts +0 -21
- package/dist/areconnectedthroughproperties.d.ts +0 -15
- package/dist/ckeditorerror.d.ts +0 -127
- package/dist/collection.d.ts +0 -437
- package/dist/comparearrays.d.ts +0 -34
- package/dist/config.d.ts +0 -167
- package/dist/count.d.ts +0 -22
- package/dist/crc32.d.ts +0 -30
- package/dist/delay.d.ts +0 -23
- package/dist/diff.d.ts +0 -35
- package/dist/difftochanges.d.ts +0 -63
- package/dist/dom/createelement.d.ts +0 -61
- package/dist/dom/emittermixin.d.ts +0 -146
- package/dist/dom/findclosestscrollableancestor.d.ts +0 -15
- package/dist/dom/getancestors.d.ts +0 -21
- package/dist/dom/getborderwidths.d.ts +0 -28
- package/dist/dom/getcommonancestor.d.ts +0 -16
- package/dist/dom/getdatafromelement.d.ts +0 -18
- package/dist/dom/getpositionedancestor.d.ts +0 -14
- package/dist/dom/getrangefrommouseevent.d.ts +0 -21
- package/dist/dom/global.d.ts +0 -36
- package/dist/dom/indexof.d.ts +0 -18
- package/dist/dom/insertat.d.ts +0 -19
- package/dist/dom/iscomment.d.ts +0 -15
- package/dist/dom/isnode.d.ts +0 -15
- package/dist/dom/isrange.d.ts +0 -15
- package/dist/dom/istext.d.ts +0 -15
- package/dist/dom/isvalidattributename.d.ts +0 -14
- package/dist/dom/isvisible.d.ts +0 -19
- package/dist/dom/iswindow.d.ts +0 -15
- package/dist/dom/position.d.ts +0 -215
- package/dist/dom/rect.d.ts +0 -199
- package/dist/dom/remove.d.ts +0 -17
- package/dist/dom/resizeobserver.d.ts +0 -78
- package/dist/dom/scroll.d.ts +0 -77
- package/dist/dom/setdatainelement.d.ts +0 -18
- package/dist/dom/tounit.d.ts +0 -26
- package/dist/elementreplacer.d.ts +0 -35
- package/dist/emittermixin.d.ts +0 -316
- package/dist/env.d.ts +0 -144
- package/dist/eventinfo.d.ts +0 -62
- package/dist/fastdiff.d.ts +0 -116
- package/dist/first.d.ts +0 -15
- package/dist/focustracker.d.ts +0 -144
- package/dist/index.d.ts +0 -70
- package/dist/inserttopriorityarray.d.ts +0 -34
- package/dist/isiterable.d.ts +0 -18
- package/dist/keyboard.d.ts +0 -130
- package/dist/keystrokehandler.d.ts +0 -101
- package/dist/language.d.ts +0 -21
- package/dist/locale.d.ts +0 -145
- package/dist/mapsequal.d.ts +0 -19
- package/dist/mix.d.ts +0 -89
- package/dist/nth.d.ts +0 -20
- package/dist/objecttomap.d.ts +0 -27
- package/dist/observablemixin.d.ts +0 -564
- package/dist/parsebase64encodedobject.d.ts +0 -15
- package/dist/priorities.d.ts +0 -37
- package/dist/retry.d.ts +0 -37
- package/dist/splicearray.d.ts +0 -31
- package/dist/spy.d.ts +0 -25
- package/dist/toarray.d.ts +0 -29
- package/dist/tomap.d.ts +0 -23
- package/dist/translation-service.d.ts +0 -178
- package/dist/uid.d.ts +0 -19
- package/dist/unicode.d.ts +0 -58
- package/dist/version.d.ts +0 -14
- package/dist/wait.d.ts +0 -20
package/dist/collection.d.ts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
declare const Collection_base: {
|
|
10
|
-
new (): import("./emittermixin.js").Emitter;
|
|
11
|
-
prototype: import("./emittermixin.js").Emitter;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Collections are ordered sets of objects. Items in the collection can be retrieved by their indexes
|
|
15
|
-
* in the collection (like in an array) or by their ids.
|
|
16
|
-
*
|
|
17
|
-
* If an object without an `id` property is being added to the collection, the `id` property will be generated
|
|
18
|
-
* automatically. Note that the automatically generated id is unique only within this single collection instance.
|
|
19
|
-
*
|
|
20
|
-
* By default an item in the collection is identified by its `id` property. The name of the identifier can be
|
|
21
|
-
* configured through the constructor of the collection.
|
|
22
|
-
*
|
|
23
|
-
* @typeParam T The type of the collection element.
|
|
24
|
-
*/
|
|
25
|
-
export default class Collection<T extends Record<string, any>> extends /* #__PURE__ */ Collection_base implements Iterable<T> {
|
|
26
|
-
/**
|
|
27
|
-
* The internal list of items in the collection.
|
|
28
|
-
*/
|
|
29
|
-
private readonly _items;
|
|
30
|
-
/**
|
|
31
|
-
* The internal map of items in the collection.
|
|
32
|
-
*/
|
|
33
|
-
private readonly _itemMap;
|
|
34
|
-
/**
|
|
35
|
-
* The name of the property which is considered to identify an item.
|
|
36
|
-
*/
|
|
37
|
-
private readonly _idProperty;
|
|
38
|
-
/**
|
|
39
|
-
* A collection instance this collection is bound to as a result
|
|
40
|
-
* of calling {@link #bindTo} method.
|
|
41
|
-
*/
|
|
42
|
-
private _bindToCollection?;
|
|
43
|
-
/**
|
|
44
|
-
* A helper mapping external items of a bound collection ({@link #bindTo})
|
|
45
|
-
* and actual items of this collection. It provides information
|
|
46
|
-
* necessary to properly remove items bound to another collection.
|
|
47
|
-
*
|
|
48
|
-
* See {@link #_bindToInternalToExternalMap}.
|
|
49
|
-
*/
|
|
50
|
-
private readonly _bindToExternalToInternalMap;
|
|
51
|
-
/**
|
|
52
|
-
* A helper mapping items of this collection to external items of a bound collection
|
|
53
|
-
* ({@link #bindTo}). It provides information necessary to manage the bindings, e.g.
|
|
54
|
-
* to avoid loops in two–way bindings.
|
|
55
|
-
*
|
|
56
|
-
* See {@link #_bindToExternalToInternalMap}.
|
|
57
|
-
*/
|
|
58
|
-
private readonly _bindToInternalToExternalMap;
|
|
59
|
-
/**
|
|
60
|
-
* Stores indexes of skipped items from bound external collection.
|
|
61
|
-
*/
|
|
62
|
-
private _skippedIndexesFromExternal;
|
|
63
|
-
/**
|
|
64
|
-
* Creates a new Collection instance.
|
|
65
|
-
*
|
|
66
|
-
* You can pass a configuration object as the argument of the constructor:
|
|
67
|
-
*
|
|
68
|
-
* ```ts
|
|
69
|
-
* const emptyCollection = new Collection<{ name: string }>( { idProperty: 'name' } );
|
|
70
|
-
* emptyCollection.add( { name: 'John' } );
|
|
71
|
-
* console.log( collection.get( 'John' ) ); // -> { name: 'John' }
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* The collection is empty by default. You can add new items using the {@link #add} method:
|
|
75
|
-
*
|
|
76
|
-
* ```ts
|
|
77
|
-
* const collection = new Collection<{ id: string }>();
|
|
78
|
-
*
|
|
79
|
-
* collection.add( { id: 'John' } );
|
|
80
|
-
* console.log( collection.get( 0 ) ); // -> { id: 'John' }
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* @label NO_ITEMS
|
|
84
|
-
* @param options The options object.
|
|
85
|
-
* @param options.idProperty The name of the property which is used to identify an item.
|
|
86
|
-
* Items that do not have such a property will be assigned one when added to the collection.
|
|
87
|
-
*/
|
|
88
|
-
constructor(options?: {
|
|
89
|
-
readonly idProperty?: string;
|
|
90
|
-
});
|
|
91
|
-
/**
|
|
92
|
-
* Creates a new Collection instance with specified initial items.
|
|
93
|
-
*
|
|
94
|
-
* ```ts
|
|
95
|
-
* const collection = new Collection<{ id: string }>( [ { id: 'John' }, { id: 'Mike' } ] );
|
|
96
|
-
*
|
|
97
|
-
* console.log( collection.get( 0 ) ); // -> { id: 'John' }
|
|
98
|
-
* console.log( collection.get( 1 ) ); // -> { id: 'Mike' }
|
|
99
|
-
* console.log( collection.get( 'Mike' ) ); // -> { id: 'Mike' }
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* You can always pass a configuration object as the last argument of the constructor:
|
|
103
|
-
*
|
|
104
|
-
* ```ts
|
|
105
|
-
* const nonEmptyCollection = new Collection<{ name: string }>( [ { name: 'John' } ], { idProperty: 'name' } );
|
|
106
|
-
* nonEmptyCollection.add( { name: 'George' } );
|
|
107
|
-
* console.log( collection.get( 'George' ) ); // -> { name: 'George' }
|
|
108
|
-
* console.log( collection.get( 'John' ) ); // -> { name: 'John' }
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @label INITIAL_ITEMS
|
|
112
|
-
* @param initialItems The initial items of the collection.
|
|
113
|
-
* @param options The options object.
|
|
114
|
-
* @param options.idProperty The name of the property which is used to identify an item.
|
|
115
|
-
* Items that do not have such a property will be assigned one when added to the collection.
|
|
116
|
-
*/
|
|
117
|
-
constructor(initialItems: Iterable<T>, options?: {
|
|
118
|
-
readonly idProperty?: string;
|
|
119
|
-
});
|
|
120
|
-
/**
|
|
121
|
-
* The number of items available in the collection.
|
|
122
|
-
*/
|
|
123
|
-
get length(): number;
|
|
124
|
-
/**
|
|
125
|
-
* Returns the first item from the collection or null when collection is empty.
|
|
126
|
-
*/
|
|
127
|
-
get first(): T | null;
|
|
128
|
-
/**
|
|
129
|
-
* Returns the last item from the collection or null when collection is empty.
|
|
130
|
-
*/
|
|
131
|
-
get last(): T | null;
|
|
132
|
-
/**
|
|
133
|
-
* Adds an item into the collection.
|
|
134
|
-
*
|
|
135
|
-
* If the item does not have an id, then it will be automatically generated and set on the item.
|
|
136
|
-
*
|
|
137
|
-
* @param item
|
|
138
|
-
* @param index The position of the item in the collection. The item
|
|
139
|
-
* is pushed to the collection when `index` not specified.
|
|
140
|
-
* @fires add
|
|
141
|
-
* @fires change
|
|
142
|
-
*/
|
|
143
|
-
add(item: T, index?: number): this;
|
|
144
|
-
/**
|
|
145
|
-
* Adds multiple items into the collection.
|
|
146
|
-
*
|
|
147
|
-
* Any item not containing an id will get an automatically generated one.
|
|
148
|
-
*
|
|
149
|
-
* @param items
|
|
150
|
-
* @param index The position of the insertion. Items will be appended if no `index` is specified.
|
|
151
|
-
* @fires add
|
|
152
|
-
* @fires change
|
|
153
|
-
*/
|
|
154
|
-
addMany(items: Iterable<T>, index?: number): this;
|
|
155
|
-
/**
|
|
156
|
-
* Gets an item by its ID or index.
|
|
157
|
-
*
|
|
158
|
-
* @param idOrIndex The item ID or index in the collection.
|
|
159
|
-
* @returns The requested item or `null` if such item does not exist.
|
|
160
|
-
*/
|
|
161
|
-
get(idOrIndex: string | number): T | null;
|
|
162
|
-
/**
|
|
163
|
-
* Returns a Boolean indicating whether the collection contains an item.
|
|
164
|
-
*
|
|
165
|
-
* @param itemOrId The item or its ID in the collection.
|
|
166
|
-
* @returns `true` if the collection contains the item, `false` otherwise.
|
|
167
|
-
*/
|
|
168
|
-
has(itemOrId: T | string): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Gets an index of an item in the collection.
|
|
171
|
-
* When an item is not defined in the collection, the index will equal -1.
|
|
172
|
-
*
|
|
173
|
-
* @param itemOrId The item or its ID in the collection.
|
|
174
|
-
* @returns The index of a given item.
|
|
175
|
-
*/
|
|
176
|
-
getIndex(itemOrId: T | string): number;
|
|
177
|
-
/**
|
|
178
|
-
* Removes an item from the collection.
|
|
179
|
-
*
|
|
180
|
-
* @param subject The item to remove, its ID or index in the collection.
|
|
181
|
-
* @returns The removed item.
|
|
182
|
-
* @fires remove
|
|
183
|
-
* @fires change
|
|
184
|
-
*/
|
|
185
|
-
remove(subject: T | number | string): T;
|
|
186
|
-
/**
|
|
187
|
-
* Executes the callback for each item in the collection and composes an array or values returned by this callback.
|
|
188
|
-
*
|
|
189
|
-
* @typeParam U The result type of the callback.
|
|
190
|
-
* @param callback
|
|
191
|
-
* @param ctx Context in which the `callback` will be called.
|
|
192
|
-
* @returns The result of mapping.
|
|
193
|
-
*/
|
|
194
|
-
map<U>(callback: (item: T, index: number) => U, ctx?: any): Array<U>;
|
|
195
|
-
/**
|
|
196
|
-
* Performs the specified action for each item in the collection.
|
|
197
|
-
*
|
|
198
|
-
* @param ctx Context in which the `callback` will be called.
|
|
199
|
-
*/
|
|
200
|
-
forEach(callback: (item: T, index: number) => unknown, ctx?: any): void;
|
|
201
|
-
/**
|
|
202
|
-
* Finds the first item in the collection for which the `callback` returns a true value.
|
|
203
|
-
*
|
|
204
|
-
* @param callback
|
|
205
|
-
* @param ctx Context in which the `callback` will be called.
|
|
206
|
-
* @returns The item for which `callback` returned a true value.
|
|
207
|
-
*/
|
|
208
|
-
find(callback: (item: T, index: number) => boolean, ctx?: any): T | undefined;
|
|
209
|
-
/**
|
|
210
|
-
* Returns an array with items for which the `callback` returned a true value.
|
|
211
|
-
*
|
|
212
|
-
* @param callback
|
|
213
|
-
* @param ctx Context in which the `callback` will be called.
|
|
214
|
-
* @returns The array with matching items.
|
|
215
|
-
*/
|
|
216
|
-
filter(callback: (item: T, index: number) => boolean, ctx?: any): Array<T>;
|
|
217
|
-
/**
|
|
218
|
-
* Removes all items from the collection and destroys the binding created using
|
|
219
|
-
* {@link #bindTo}.
|
|
220
|
-
*
|
|
221
|
-
* @fires remove
|
|
222
|
-
* @fires change
|
|
223
|
-
*/
|
|
224
|
-
clear(): void;
|
|
225
|
-
/**
|
|
226
|
-
* Binds and synchronizes the collection with another one.
|
|
227
|
-
*
|
|
228
|
-
* The binding can be a simple factory:
|
|
229
|
-
*
|
|
230
|
-
* ```ts
|
|
231
|
-
* class FactoryClass {
|
|
232
|
-
* public label: string;
|
|
233
|
-
*
|
|
234
|
-
* constructor( data: { label: string } ) {
|
|
235
|
-
* this.label = data.label;
|
|
236
|
-
* }
|
|
237
|
-
* }
|
|
238
|
-
*
|
|
239
|
-
* const source = new Collection<{ label: string }>( { idProperty: 'label' } );
|
|
240
|
-
* const target = new Collection<FactoryClass>();
|
|
241
|
-
*
|
|
242
|
-
* target.bindTo( source ).as( FactoryClass );
|
|
243
|
-
*
|
|
244
|
-
* source.add( { label: 'foo' } );
|
|
245
|
-
* source.add( { label: 'bar' } );
|
|
246
|
-
*
|
|
247
|
-
* console.log( target.length ); // 2
|
|
248
|
-
* console.log( target.get( 1 ).label ); // 'bar'
|
|
249
|
-
*
|
|
250
|
-
* source.remove( 0 );
|
|
251
|
-
* console.log( target.length ); // 1
|
|
252
|
-
* console.log( target.get( 0 ).label ); // 'bar'
|
|
253
|
-
* ```
|
|
254
|
-
*
|
|
255
|
-
* or the factory driven by a custom callback:
|
|
256
|
-
*
|
|
257
|
-
* ```ts
|
|
258
|
-
* class FooClass {
|
|
259
|
-
* public label: string;
|
|
260
|
-
*
|
|
261
|
-
* constructor( data: { label: string } ) {
|
|
262
|
-
* this.label = data.label;
|
|
263
|
-
* }
|
|
264
|
-
* }
|
|
265
|
-
*
|
|
266
|
-
* class BarClass {
|
|
267
|
-
* public label: string;
|
|
268
|
-
*
|
|
269
|
-
* constructor( data: { label: string } ) {
|
|
270
|
-
* this.label = data.label;
|
|
271
|
-
* }
|
|
272
|
-
* }
|
|
273
|
-
*
|
|
274
|
-
* const source = new Collection<{ label: string }>( { idProperty: 'label' } );
|
|
275
|
-
* const target = new Collection<FooClass | BarClass>();
|
|
276
|
-
*
|
|
277
|
-
* target.bindTo( source ).using( ( item ) => {
|
|
278
|
-
* if ( item.label == 'foo' ) {
|
|
279
|
-
* return new FooClass( item );
|
|
280
|
-
* } else {
|
|
281
|
-
* return new BarClass( item );
|
|
282
|
-
* }
|
|
283
|
-
* } );
|
|
284
|
-
*
|
|
285
|
-
* source.add( { label: 'foo' } );
|
|
286
|
-
* source.add( { label: 'bar' } );
|
|
287
|
-
*
|
|
288
|
-
* console.log( target.length ); // 2
|
|
289
|
-
* console.log( target.get( 0 ) instanceof FooClass ); // true
|
|
290
|
-
* console.log( target.get( 1 ) instanceof BarClass ); // true
|
|
291
|
-
* ```
|
|
292
|
-
*
|
|
293
|
-
* or the factory out of property name:
|
|
294
|
-
*
|
|
295
|
-
* ```ts
|
|
296
|
-
* const source = new Collection<{ nested: { value: string } }>();
|
|
297
|
-
* const target = new Collection<{ value: string }>();
|
|
298
|
-
*
|
|
299
|
-
* target.bindTo( source ).using( 'nested' );
|
|
300
|
-
*
|
|
301
|
-
* source.add( { nested: { value: 'foo' } } );
|
|
302
|
-
* source.add( { nested: { value: 'bar' } } );
|
|
303
|
-
*
|
|
304
|
-
* console.log( target.length ); // 2
|
|
305
|
-
* console.log( target.get( 0 ).value ); // 'foo'
|
|
306
|
-
* console.log( target.get( 1 ).value ); // 'bar'
|
|
307
|
-
* ```
|
|
308
|
-
*
|
|
309
|
-
* It's possible to skip specified items by returning null value:
|
|
310
|
-
*
|
|
311
|
-
* ```ts
|
|
312
|
-
* const source = new Collection<{ hidden: boolean }>();
|
|
313
|
-
* const target = new Collection<{ hidden: boolean }>();
|
|
314
|
-
*
|
|
315
|
-
* target.bindTo( source ).using( item => {
|
|
316
|
-
* if ( item.hidden ) {
|
|
317
|
-
* return null;
|
|
318
|
-
* }
|
|
319
|
-
*
|
|
320
|
-
* return item;
|
|
321
|
-
* } );
|
|
322
|
-
*
|
|
323
|
-
* source.add( { hidden: true } );
|
|
324
|
-
* source.add( { hidden: false } );
|
|
325
|
-
*
|
|
326
|
-
* console.log( source.length ); // 2
|
|
327
|
-
* console.log( target.length ); // 1
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* **Note**: {@link #clear} can be used to break the binding.
|
|
331
|
-
*
|
|
332
|
-
* @typeParam S The type of `externalCollection` element.
|
|
333
|
-
* @param externalCollection A collection to be bound.
|
|
334
|
-
* @returns The binding chain object.
|
|
335
|
-
*/
|
|
336
|
-
bindTo<S extends Record<string, any>>(externalCollection: Collection<S>): CollectionBindToChain<S, T>;
|
|
337
|
-
/**
|
|
338
|
-
* Finalizes and activates a binding initiated by {@link #bindTo}.
|
|
339
|
-
*
|
|
340
|
-
* @param factory A function which produces collection items.
|
|
341
|
-
*/
|
|
342
|
-
private _setUpBindToBinding;
|
|
343
|
-
/**
|
|
344
|
-
* Returns an unique id property for a given `item`.
|
|
345
|
-
*
|
|
346
|
-
* The method will generate new id and assign it to the `item` if it doesn't have any.
|
|
347
|
-
*
|
|
348
|
-
* @param item Item to be added.
|
|
349
|
-
*/
|
|
350
|
-
private _getItemIdBeforeAdding;
|
|
351
|
-
/**
|
|
352
|
-
* Core {@link #remove} method implementation shared in other functions.
|
|
353
|
-
*
|
|
354
|
-
* In contrast this method **does not** fire the {@link #event:change} event.
|
|
355
|
-
*
|
|
356
|
-
* @param subject The item to remove, its id or index in the collection.
|
|
357
|
-
* @returns Returns an array with the removed item and its index.
|
|
358
|
-
* @fires remove
|
|
359
|
-
*/
|
|
360
|
-
private _remove;
|
|
361
|
-
/**
|
|
362
|
-
* Iterable interface.
|
|
363
|
-
*/
|
|
364
|
-
[Symbol.iterator](): Iterator<T>;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Fired when an item is added to the collection.
|
|
368
|
-
*
|
|
369
|
-
* @eventName ~Collection#add
|
|
370
|
-
* @param item The added item.
|
|
371
|
-
* @param index An index where the addition occurred.
|
|
372
|
-
*/
|
|
373
|
-
export type CollectionAddEvent<T = any> = {
|
|
374
|
-
name: 'add';
|
|
375
|
-
args: [item: T, index: number];
|
|
376
|
-
};
|
|
377
|
-
/**
|
|
378
|
-
* Fired when the collection was changed due to adding or removing items.
|
|
379
|
-
*
|
|
380
|
-
* @eventName ~Collection#change
|
|
381
|
-
* @param data Changed items.
|
|
382
|
-
*/
|
|
383
|
-
export type CollectionChangeEvent<T = any> = {
|
|
384
|
-
name: 'change';
|
|
385
|
-
args: [data: CollectionChangeEventData<T>];
|
|
386
|
-
};
|
|
387
|
-
/**
|
|
388
|
-
* A structure describing the {@link ~Collection#event:change `Collection#change`} event.
|
|
389
|
-
*/
|
|
390
|
-
export type CollectionChangeEventData<T = any> = {
|
|
391
|
-
/**
|
|
392
|
-
* A list of added items.
|
|
393
|
-
*/
|
|
394
|
-
added: Iterable<T>;
|
|
395
|
-
/**
|
|
396
|
-
* A list of removed items.
|
|
397
|
-
*/
|
|
398
|
-
removed: Iterable<T>;
|
|
399
|
-
/**
|
|
400
|
-
* An index where the addition or removal occurred.
|
|
401
|
-
*/
|
|
402
|
-
index: number;
|
|
403
|
-
};
|
|
404
|
-
/**
|
|
405
|
-
* Fired when an item is removed from the collection.
|
|
406
|
-
*
|
|
407
|
-
* @eventName ~Collection#remove
|
|
408
|
-
* @param item The removed item.
|
|
409
|
-
* @param index Index from which item was removed.
|
|
410
|
-
*/
|
|
411
|
-
export type CollectionRemoveEvent<T = any> = {
|
|
412
|
-
name: 'remove';
|
|
413
|
-
args: [item: T, index: number];
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* An object returned by the {@link module:utils/collection~Collection#bindTo `bindTo()`} method
|
|
417
|
-
* providing functions that specify the type of the binding.
|
|
418
|
-
*
|
|
419
|
-
* See the {@link module:utils/collection~Collection#bindTo `bindTo()`} documentation for examples.
|
|
420
|
-
*/
|
|
421
|
-
export interface CollectionBindToChain<S, T> {
|
|
422
|
-
/**
|
|
423
|
-
* Creates the class factory binding in which items of the source collection are passed to
|
|
424
|
-
* the constructor of the specified class.
|
|
425
|
-
*
|
|
426
|
-
* @param Class The class constructor used to create instances in the factory.
|
|
427
|
-
*/
|
|
428
|
-
as(Class: new (item: S) => T): void;
|
|
429
|
-
/**
|
|
430
|
-
* Creates a callback or a property binding.
|
|
431
|
-
*
|
|
432
|
-
* @param callbackOrProperty When the function is passed, it should return
|
|
433
|
-
* the collection items. When the string is provided, the property value is used to create the bound collection items.
|
|
434
|
-
*/
|
|
435
|
-
using(callbackOrProperty: keyof S | ((item: S) => T | null)): void;
|
|
436
|
-
}
|
|
437
|
-
export {};
|
package/dist/comparearrays.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module utils/comparearrays
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Compares how given arrays relate to each other. One array can be: same as another array, prefix of another array
|
|
14
|
-
* or completely different. If arrays are different, first index at which they differ is returned. Otherwise,
|
|
15
|
-
* a flag specifying the relation is returned. Flags are negative numbers, so whenever a number >= 0 is returned
|
|
16
|
-
* it means that arrays differ.
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* compareArrays( [ 0, 2 ], [ 0, 2 ] ); // 'same'
|
|
20
|
-
* compareArrays( [ 0, 2 ], [ 0, 2, 1 ] ); // 'prefix'
|
|
21
|
-
* compareArrays( [ 0, 2 ], [ 0 ] ); // 'extension'
|
|
22
|
-
* compareArrays( [ 0, 2 ], [ 1, 2 ] ); // 0
|
|
23
|
-
* compareArrays( [ 0, 2 ], [ 0, 1 ] ); // 1
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param a Array that is compared.
|
|
27
|
-
* @param b Array to compare with.
|
|
28
|
-
* @returns How array `a` is related to `b`.
|
|
29
|
-
*/
|
|
30
|
-
export default function compareArrays(a: ReadonlyArray<unknown>, b: ReadonlyArray<unknown>): ArrayRelation | number;
|
|
31
|
-
/**
|
|
32
|
-
* Array relation.
|
|
33
|
-
*/
|
|
34
|
-
export type ArrayRelation = 'extension' | 'same' | 'prefix';
|
package/dist/config.d.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Handles a configuration dictionary.
|
|
11
|
-
*
|
|
12
|
-
* @typeParam Cfg A type of the configuration dictionary.
|
|
13
|
-
*/
|
|
14
|
-
export default class Config<Cfg> {
|
|
15
|
-
/**
|
|
16
|
-
* Store for the whole configuration.
|
|
17
|
-
*/
|
|
18
|
-
private readonly _config;
|
|
19
|
-
/**
|
|
20
|
-
* Creates an instance of the {@link ~Config} class.
|
|
21
|
-
*
|
|
22
|
-
* @param configurations The initial configurations to be set. Usually, provided by the user.
|
|
23
|
-
* @param defaultConfigurations The default configurations. Usually, provided by the system.
|
|
24
|
-
*/
|
|
25
|
-
constructor(configurations?: Partial<Cfg>, defaultConfigurations?: Partial<Cfg>);
|
|
26
|
-
/**
|
|
27
|
-
* Set configuration values.
|
|
28
|
-
*
|
|
29
|
-
* It also accepts setting a "deep configuration" by using dots in the name. For example, `'resize.width'` sets
|
|
30
|
-
* the value for the `width` configuration in the `resize` subset.
|
|
31
|
-
*
|
|
32
|
-
* ```ts
|
|
33
|
-
* config.set( 'resize.width', 500 );
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* It accepts both a name/value pair or an object, which properties and values will be used to set
|
|
37
|
-
* configurations. See {@link #set:CONFIG_OBJECT}.
|
|
38
|
-
*
|
|
39
|
-
* @label KEY_VALUE
|
|
40
|
-
* @param name The configuration name. Configuration names are case-sensitive.
|
|
41
|
-
* @param value The configuration value.
|
|
42
|
-
*/
|
|
43
|
-
set<K extends string>(name: K, value: GetSubConfig<Cfg, K>): void;
|
|
44
|
-
/**
|
|
45
|
-
* Set configuration values.
|
|
46
|
-
*
|
|
47
|
-
* It accepts an object, which properties and values will be used to set configurations.
|
|
48
|
-
*
|
|
49
|
-
* ```ts
|
|
50
|
-
* config.set( {
|
|
51
|
-
* width: 500
|
|
52
|
-
* toolbar: {
|
|
53
|
-
* collapsed: true
|
|
54
|
-
* }
|
|
55
|
-
* } );
|
|
56
|
-
*
|
|
57
|
-
* // Equivalent to:
|
|
58
|
-
* config.set( 'width', 500 );
|
|
59
|
-
* config.set( 'toolbar.collapsed', true );
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Passing an object as the value will amend the configuration, not replace it.
|
|
63
|
-
*
|
|
64
|
-
* ```ts
|
|
65
|
-
* config.set( 'toolbar', {
|
|
66
|
-
* collapsed: true,
|
|
67
|
-
* } );
|
|
68
|
-
*
|
|
69
|
-
* config.set( 'toolbar', {
|
|
70
|
-
* color: 'red',
|
|
71
|
-
* } );
|
|
72
|
-
*
|
|
73
|
-
* config.get( 'toolbar.collapsed' ); // true
|
|
74
|
-
* config.get( 'toolbar.color' ); // 'red'
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* It accepts both a name/value pair or an object, which properties and values will be used to set
|
|
78
|
-
* configurations. See {@link #set:KEY_VALUE}.
|
|
79
|
-
*
|
|
80
|
-
* @label CONFIG_OBJECT
|
|
81
|
-
* @param config The configuration object from which take properties as
|
|
82
|
-
* configuration entries. Configuration names are case-sensitive.
|
|
83
|
-
*/
|
|
84
|
-
set(config: Partial<Cfg>): void;
|
|
85
|
-
/**
|
|
86
|
-
* Does exactly the same as {@link #set:KEY_VALUE} with one exception – passed configuration extends
|
|
87
|
-
* existing one, but does not overwrite already defined values.
|
|
88
|
-
*
|
|
89
|
-
* This method is supposed to be called by plugin developers to setup plugin's configurations. It would be
|
|
90
|
-
* rarely used for other needs.
|
|
91
|
-
*
|
|
92
|
-
* @label KEY_VALUE
|
|
93
|
-
* @param name The configuration name. Configuration names are case-sensitive.
|
|
94
|
-
* @param value The configuration value.
|
|
95
|
-
*/
|
|
96
|
-
define<K extends string>(name: K, value: GetSubConfig<Cfg, K>): void;
|
|
97
|
-
/**
|
|
98
|
-
* Does exactly the same as {@link #set:CONFIG_OBJECT} with one exception – passed configuration extends
|
|
99
|
-
* existing one, but does not overwrite already defined values.
|
|
100
|
-
*
|
|
101
|
-
* This method is supposed to be called by plugin developers to setup plugin's configurations. It would be
|
|
102
|
-
* rarely used for other needs.
|
|
103
|
-
*
|
|
104
|
-
* @label CONFIG_OBJECT
|
|
105
|
-
* @param config The configuration object from which take properties as
|
|
106
|
-
* configuration entries. Configuration names are case-sensitive.
|
|
107
|
-
*/
|
|
108
|
-
define(config: Partial<Cfg>): void;
|
|
109
|
-
/**
|
|
110
|
-
* Gets the value for a configuration entry.
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* config.get( 'name' );
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* Deep configurations can be retrieved by separating each part with a dot.
|
|
117
|
-
*
|
|
118
|
-
* ```ts
|
|
119
|
-
* config.get( 'toolbar.collapsed' );
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* @param name The configuration name. Configuration names are case-sensitive.
|
|
123
|
-
* @returns The configuration value or `undefined` if the configuration entry was not found.
|
|
124
|
-
*/
|
|
125
|
-
get<K extends string>(name: K): GetSubConfig<Cfg, K> | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* Iterates over all top level configuration names.
|
|
128
|
-
*/
|
|
129
|
-
names(): Iterable<string>;
|
|
130
|
-
/**
|
|
131
|
-
* Saves passed configuration to the specified target (nested object).
|
|
132
|
-
*
|
|
133
|
-
* @param target Nested config object.
|
|
134
|
-
* @param name The configuration name or an object from which take properties as
|
|
135
|
-
* configuration entries. Configuration names are case-sensitive.
|
|
136
|
-
* @param value The configuration value. Used if a name is passed.
|
|
137
|
-
* @param isDefine Define if passed configuration should overwrite existing one.
|
|
138
|
-
*/
|
|
139
|
-
private _setToTarget;
|
|
140
|
-
/**
|
|
141
|
-
* Get specified configuration from specified source (nested object).
|
|
142
|
-
*
|
|
143
|
-
* @param source level of nested object.
|
|
144
|
-
* @param name The configuration name. Configuration names are case-sensitive.
|
|
145
|
-
* @returns The configuration value or `undefined` if the configuration entry was not found.
|
|
146
|
-
*/
|
|
147
|
-
private _getFromSource;
|
|
148
|
-
/**
|
|
149
|
-
* Iterates through passed object and calls {@link #_setToTarget} method with object key and value for each property.
|
|
150
|
-
*
|
|
151
|
-
* @param target Nested config object.
|
|
152
|
-
* @param configuration Configuration data set
|
|
153
|
-
* @param isDefine Defines if passed configuration is default configuration or not.
|
|
154
|
-
*/
|
|
155
|
-
private _setObjectToTarget;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* An utility type excluding primitive values and arrays from the union.
|
|
159
|
-
*/
|
|
160
|
-
export type OnlyObject<T> = Exclude<T, undefined | null | string | number | boolean | Array<any>>;
|
|
161
|
-
/**
|
|
162
|
-
* An utility type extracting configuration value from the given name.
|
|
163
|
-
*
|
|
164
|
-
* @typeParam T The type of a configuration dictionary.
|
|
165
|
-
* @typeParam K The literal type of configuration name (dot-separated path).
|
|
166
|
-
*/
|
|
167
|
-
export type GetSubConfig<T, K> = K extends keyof T ? T[K] : K extends `${infer K1}.${infer K2}` ? K1 extends keyof T ? GetSubConfig<OnlyObject<T[K1]>, K2> : unknown : unknown;
|
package/dist/count.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module utils/count
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Returns the number of items return by the iterator.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* count( [ 1, 2, 3, 4, 5 ] ); // 5;
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param iterable Any iterable.
|
|
20
|
-
* @returns Number of items returned by that iterable.
|
|
21
|
-
*/
|
|
22
|
-
export default function count(iterable: Iterable<unknown>): number;
|
package/dist/crc32.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Calculates CRC-32 checksum for a given inputData to verify the integrity of data.
|
|
11
|
-
*
|
|
12
|
-
* @param inputData Accepts a single value (string, number, boolean), an array of strings, or an array of all of the above types.
|
|
13
|
-
* Non-string values are converted to strings before calculating the checksum.
|
|
14
|
-
* The checksum calculation is based on the concatenated string representation of the input values:
|
|
15
|
-
* * `crc32('foo')` is equivalent to `crc32(['foo'])`
|
|
16
|
-
* * `crc32(123)` is equivalent to `crc32(['123'])`
|
|
17
|
-
* * `crc32(true)` is equivalent to `crc32(['true'])`
|
|
18
|
-
* * `crc32(['foo', 123, true])` produces the same result as `crc32('foo123true')`
|
|
19
|
-
* * Nested arrays of strings are flattened, so `crc32([['foo', 'bar'], 'baz'])` is equivalent to `crc32(['foobar', 'baz'])`
|
|
20
|
-
*
|
|
21
|
-
* @returns The CRC-32 checksum, returned as a hexadecimal string.
|
|
22
|
-
*/
|
|
23
|
-
export default function crc32(inputData: CRCData): string;
|
|
24
|
-
/**
|
|
25
|
-
* The input data for the CRC-32 checksum calculation.
|
|
26
|
-
* Can be a single value (string, number, boolean), an array of strings, or an array of all of the above types.
|
|
27
|
-
*/
|
|
28
|
-
export type CRCData = CRCValue | Array<CRCValue>;
|
|
29
|
-
type CRCValue = string | number | boolean | Array<string>;
|
|
30
|
-
export {};
|