@ckeditor/ckeditor5-utils 48.2.0-alpha.7 → 48.3.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/dist/abortabledebounce.d.ts +19 -13
- package/dist/areconnectedthroughproperties.d.ts +7 -7
- package/dist/ckeditorerror.d.ts +113 -113
- package/dist/collection.d.ts +419 -415
- package/dist/collectstylesheets.d.ts +9 -9
- package/dist/comparearrays.d.ts +25 -25
- package/dist/config.d.ts +159 -156
- package/dist/count.d.ts +14 -14
- package/dist/crc32.d.ts +19 -19
- package/dist/decodelicensekey.d.ts +7 -7
- package/dist/delay.d.ts +13 -13
- package/dist/diff.d.ts +32 -27
- package/dist/difftochanges.d.ts +47 -47
- package/dist/dom/createelement.d.ts +43 -43
- package/dist/dom/emittermixin.d.ts +144 -135
- package/dist/dom/findclosestscrollableancestor.d.ts +8 -8
- package/dist/dom/getancestors.d.ts +13 -13
- package/dist/dom/getborderwidths.d.ts +16 -16
- package/dist/dom/getcommonancestor.d.ts +9 -9
- package/dist/dom/getdatafromelement.d.ts +10 -10
- package/dist/dom/getpositionedancestor.d.ts +7 -7
- package/dist/dom/getrangefrommouseevent.d.ts +12 -12
- package/dist/dom/getvisualviewportoffset.d.ts +7 -7
- package/dist/dom/global.d.ts +24 -24
- package/dist/dom/indexof.d.ts +10 -10
- package/dist/dom/insertat.d.ts +11 -11
- package/dist/dom/iscomment.d.ts +7 -7
- package/dist/dom/isnode.d.ts +7 -7
- package/dist/dom/isrange.d.ts +7 -7
- package/dist/dom/istext.d.ts +7 -7
- package/dist/dom/isvalidattributename.d.ts +7 -7
- package/dist/dom/isvisible.d.ts +12 -12
- package/dist/dom/iswindow.d.ts +7 -7
- package/dist/dom/position.d.ts +200 -200
- package/dist/dom/rect.d.ts +194 -194
- package/dist/dom/remove.d.ts +9 -9
- package/dist/dom/resizeobserver.d.ts +70 -70
- package/dist/dom/scroll.d.ts +75 -72
- package/dist/dom/setdatainelement.d.ts +10 -10
- package/dist/dom/tounit.d.ts +16 -16
- package/dist/elementreplacer.d.ts +26 -26
- package/dist/emittermixin.d.ts +290 -280
- package/dist/env.d.ts +124 -124
- package/dist/eventinfo.d.ts +58 -55
- package/dist/fastdiff.d.ts +112 -109
- package/dist/first.d.ts +7 -7
- package/dist/focustracker.d.ts +133 -131
- package/dist/formathtml.d.ts +15 -15
- package/dist/index-content.css +1 -0
- package/dist/index-editor.css +1 -0
- package/dist/index.css +0 -2
- package/dist/index.d.ts +78 -77
- package/dist/index.js +5695 -6360
- package/dist/index.js.map +1 -1
- package/dist/inserttopriorityarray.d.ts +23 -23
- package/dist/isfeatureblockedbylicensekey.d.ts +10 -10
- package/dist/isiterable.d.ts +10 -10
- package/dist/keyboard.d.ts +107 -109
- package/dist/keystrokehandler.d.ts +90 -90
- package/dist/language.d.ts +12 -12
- package/dist/legacyerrors.d.ts +0 -4
- package/dist/locale.d.ts +122 -122
- package/dist/mapsequal.d.ts +11 -11
- package/dist/mix.d.ts +54 -53
- package/dist/nth.d.ts +12 -12
- package/dist/objecttomap.d.ts +18 -18
- package/dist/observablemixin.d.ts +621 -539
- package/dist/parsebase64encodedobject.d.ts +7 -7
- package/dist/parsedimensionwithunit.d.ts +40 -0
- package/dist/priorities.d.ts +24 -24
- package/dist/retry.d.ts +27 -27
- package/dist/splicearray.d.ts +22 -22
- package/dist/spy.d.ts +15 -15
- package/dist/toarray.d.ts +17 -17
- package/dist/tomap.d.ts +15 -15
- package/dist/translation-service.d.ts +157 -157
- package/dist/uid.d.ts +12 -12
- package/dist/unicode.d.ts +42 -42
- package/dist/version.d.ts +5 -5
- package/dist/wait.d.ts +11 -11
- package/package.json +2 -2
- package/dist/index.css.map +0 -1
package/dist/env.d.ts
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
* Safely returns `userAgent` from browser's navigator API in a lower case.
|
|
7
|
+
* If navigator API is not available it will return an empty string.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
11
|
export declare function getUserAgent(): string;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* A namespace containing environment and browser information.
|
|
14
|
+
*/
|
|
15
15
|
export interface EnvType {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Indicates that the application is running on Macintosh.
|
|
18
|
+
*/
|
|
19
|
+
readonly isMac: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that the application is running on Windows.
|
|
22
|
+
*/
|
|
23
|
+
readonly isWindows: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates that the application is running in Firefox (Gecko).
|
|
26
|
+
*/
|
|
27
|
+
readonly isGecko: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates that the application is running in Safari.
|
|
30
|
+
*/
|
|
31
|
+
readonly isSafari: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Indicates that the application is running in iOS.
|
|
34
|
+
*/
|
|
35
|
+
readonly isiOS: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates that the application is running on Android mobile device.
|
|
38
|
+
*/
|
|
39
|
+
readonly isAndroid: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates that the application is running in a browser using the Blink engine.
|
|
42
|
+
*/
|
|
43
|
+
readonly isBlink: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Indicates that the user agent has enabled a forced colors mode (e.g. Windows High Contrast mode).
|
|
46
|
+
*
|
|
47
|
+
* Note that the value of this property is evaluated each time it is accessed, and it may change over time, if the environment
|
|
48
|
+
* settings have changed.
|
|
49
|
+
*/
|
|
50
|
+
readonly isMediaForcedColors: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Indicates that "prefer reduced motion" browser setting is active.
|
|
53
|
+
*
|
|
54
|
+
* Note that the value of this property is evaluated each time it is accessed, and it may change over time, if the environment
|
|
55
|
+
* settings have changed.
|
|
56
|
+
*/
|
|
57
|
+
readonly isMotionReduced: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Environment features information.
|
|
60
|
+
*/
|
|
61
|
+
readonly features: EnvFeaturesType;
|
|
62
62
|
}
|
|
63
63
|
export interface EnvFeaturesType {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Indicates that the environment supports ES2018 Unicode property escapes — like `\p{P}` or `\p{L}`.
|
|
66
|
+
* More information about unicode properties might be found
|
|
67
|
+
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
68
|
+
*/
|
|
69
|
+
readonly isRegExpUnicodePropertySupported: boolean;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
* A namespace containing environment and browser information.
|
|
73
|
+
*/
|
|
74
74
|
export declare const env: EnvType;
|
|
75
75
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
* Checks if User Agent represented by the string is running on Macintosh.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
80
|
+
* @returns Whether User Agent is running on Macintosh or not.
|
|
81
|
+
*/
|
|
82
82
|
export declare function isMac(userAgent: string): boolean;
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
* Checks if User Agent represented by the string is running on Windows.
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
88
|
+
* @returns Whether User Agent is running on Windows or not.
|
|
89
|
+
*/
|
|
90
90
|
export declare function isWindows(userAgent: string): boolean;
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
* Checks if User Agent represented by the string is Firefox (Gecko).
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
95
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
96
|
+
* @returns Whether User Agent is Firefox or not.
|
|
97
|
+
*/
|
|
98
98
|
export declare function isGecko(userAgent: string): boolean;
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
* Checks if User Agent represented by the string is Safari.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
104
|
+
* @returns Whether User Agent is Safari or not.
|
|
105
|
+
*/
|
|
106
106
|
export declare function isSafari(userAgent: string): boolean;
|
|
107
107
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
* Checks if User Agent represented by the string is running in iOS.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
112
|
+
* @returns Whether User Agent is running in iOS or not.
|
|
113
|
+
*/
|
|
114
114
|
export declare function isiOS(userAgent: string): boolean;
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
* Checks if User Agent represented by the string is Android mobile device.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
120
|
+
* @returns Whether User Agent is Safari or not.
|
|
121
|
+
*/
|
|
122
122
|
export declare function isAndroid(userAgent: string): boolean;
|
|
123
123
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
* Checks if User Agent represented by the string is Blink engine.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
* @param userAgent **Lowercase** `navigator.userAgent` string.
|
|
128
|
+
* @returns Whether User Agent is Blink engine or not.
|
|
129
|
+
*/
|
|
130
130
|
export declare function isBlink(userAgent: string): boolean;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
* Checks if the current environment supports ES2018 Unicode properties like `\p{P}` or `\p{L}`.
|
|
133
|
+
* More information about unicode properties might be found
|
|
134
|
+
* [in Unicode Standard Annex #44](https://www.unicode.org/reports/tr44/#GC_Values_Table).
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
138
|
export declare function isRegExpUnicodePropertySupported(): boolean;
|
|
139
139
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
* Checks if the user agent has enabled a forced colors mode (e.g. Windows High Contrast mode).
|
|
141
|
+
*
|
|
142
|
+
* Returns `false` in environments where `window` global object is not available.
|
|
143
|
+
*
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
146
|
export declare function isMediaForcedColors(): boolean;
|
|
147
147
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
* Checks if the user enabled "prefers reduced motion" setting in browser.
|
|
149
|
+
*
|
|
150
|
+
* Returns `false` in environments where `window` global object is not available.
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
154
|
export declare function isMotionReduced(): boolean;
|
package/dist/eventinfo.d.ts
CHANGED
|
@@ -1,58 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare class EventInfo<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
6
|
+
* The event object passed to event callbacks. It is used to provide information about the event as well as a tool to
|
|
7
|
+
* manipulate it.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EventInfo<
|
|
10
|
+
TName extends string = string,
|
|
11
|
+
TReturn = unknown
|
|
12
|
+
> {
|
|
13
|
+
/**
|
|
14
|
+
* The object that fired the event.
|
|
15
|
+
*/
|
|
16
|
+
readonly source: object;
|
|
17
|
+
/**
|
|
18
|
+
* The event name.
|
|
19
|
+
*/
|
|
20
|
+
readonly name: TName;
|
|
21
|
+
/**
|
|
22
|
+
* Path this event has followed. See {@link module:utils/emittermixin~Emitter#delegate}.
|
|
23
|
+
*/
|
|
24
|
+
path: Array<object>;
|
|
25
|
+
/**
|
|
26
|
+
* Stops the event emitter to call further callbacks for this event interaction.
|
|
27
|
+
*/
|
|
28
|
+
readonly stop: {
|
|
29
|
+
(): void;
|
|
30
|
+
called?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Removes the current callback from future interactions of this event.
|
|
34
|
+
*/
|
|
35
|
+
readonly off: {
|
|
36
|
+
(): void;
|
|
37
|
+
called?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The value which will be returned by {@link module:utils/emittermixin~Emitter#fire}.
|
|
41
|
+
*
|
|
42
|
+
* It's `undefined` by default and can be changed by an event listener:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* dataController.fire( 'getSelectedContent', ( evt ) => {
|
|
46
|
+
* // This listener will make `dataController.fire( 'getSelectedContent' )`
|
|
47
|
+
* // always return an empty DocumentFragment.
|
|
48
|
+
* evt.return = new DocumentFragment();
|
|
49
|
+
*
|
|
50
|
+
* // Make sure no other listeners are executed.
|
|
51
|
+
* evt.stop();
|
|
52
|
+
* } );
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
return: TReturn | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @param source The emitter.
|
|
58
|
+
* @param name The event name.
|
|
59
|
+
*/
|
|
60
|
+
constructor(source: object, name: TName);
|
|
58
61
|
}
|
package/dist/fastdiff.d.ts
CHANGED
|
@@ -1,112 +1,115 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import type { DiffResult } from
|
|
9
|
-
import type { Change } from
|
|
6
|
+
* @module utils/fastdiff
|
|
7
|
+
*/
|
|
8
|
+
import type { DiffResult } from "./diff.js";
|
|
9
|
+
import type { Change } from "./difftochanges.js";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
export declare function fastDiff<
|
|
11
|
+
* Finds positions of the first and last change in the given string/array and generates a set of changes:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* fastDiff( '12a', '12xyza' );
|
|
15
|
+
* // [ { index: 2, type: 'insert', values: [ 'x', 'y', 'z' ] } ]
|
|
16
|
+
*
|
|
17
|
+
* fastDiff( '12a', '12aa' );
|
|
18
|
+
* // [ { index: 3, type: 'insert', values: [ 'a' ] } ]
|
|
19
|
+
*
|
|
20
|
+
* fastDiff( '12xyza', '12a' );
|
|
21
|
+
* // [ { index: 2, type: 'delete', howMany: 3 } ]
|
|
22
|
+
*
|
|
23
|
+
* fastDiff( [ '1', '2', 'a', 'a' ], [ '1', '2', 'a' ] );
|
|
24
|
+
* // [ { index: 3, type: 'delete', howMany: 1 } ]
|
|
25
|
+
*
|
|
26
|
+
* fastDiff( [ '1', '2', 'a', 'b', 'c', '3' ], [ '2', 'a', 'b' ] );
|
|
27
|
+
* // [ { index: 0, type: 'insert', values: [ '2', 'a', 'b' ] }, { index: 3, type: 'delete', howMany: 6 } ]
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Passed arrays can contain any type of data, however to compare them correctly custom comparator function
|
|
31
|
+
* should be passed as a third parameter:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* fastDiff( [ { value: 1 }, { value: 2 } ], [ { value: 1 }, { value: 3 } ], ( a, b ) => {
|
|
35
|
+
* return a.value === b.value;
|
|
36
|
+
* } );
|
|
37
|
+
* // [ { index: 1, type: 'insert', values: [ { value: 3 } ] }, { index: 2, type: 'delete', howMany: 1 } ]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The resulted set of changes can be applied to the input in order to transform it into the output, for example:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* let input = '12abc3';
|
|
44
|
+
* const output = '2ab';
|
|
45
|
+
* const changes = fastDiff( input, output );
|
|
46
|
+
*
|
|
47
|
+
* changes.forEach( change => {
|
|
48
|
+
* if ( change.type == 'insert' ) {
|
|
49
|
+
* input = input.substring( 0, change.index ) + change.values.join( '' ) + input.substring( change.index );
|
|
50
|
+
* } else if ( change.type == 'delete' ) {
|
|
51
|
+
* input = input.substring( 0, change.index ) + input.substring( change.index + change.howMany );
|
|
52
|
+
* }
|
|
53
|
+
* } );
|
|
54
|
+
*
|
|
55
|
+
* // input equals output now
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* or in case of arrays:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* let input = [ '1', '2', 'a', 'b', 'c', '3' ];
|
|
62
|
+
* const output = [ '2', 'a', 'b' ];
|
|
63
|
+
* const changes = fastDiff( input, output );
|
|
64
|
+
*
|
|
65
|
+
* changes.forEach( change => {
|
|
66
|
+
* if ( change.type == 'insert' ) {
|
|
67
|
+
* input = input.slice( 0, change.index ).concat( change.values, input.slice( change.index ) );
|
|
68
|
+
* } else if ( change.type == 'delete' ) {
|
|
69
|
+
* input = input.slice( 0, change.index ).concat( input.slice( change.index + change.howMany ) );
|
|
70
|
+
* }
|
|
71
|
+
* } );
|
|
72
|
+
*
|
|
73
|
+
* // input equals output now
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* By passing `true` as the fourth parameter (`atomicChanges`) the output of this function will become compatible with
|
|
77
|
+
* the {@link module:utils/diff~diff `diff()`} function:
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* fastDiff( '12a', '12xyza', undefined, true );
|
|
81
|
+
* // [ 'equal', 'equal', 'insert', 'insert', 'insert', 'equal' ]
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* The default output format of this function is compatible with the output format of
|
|
85
|
+
* {@link module:utils/difftochanges~diffToChanges `diffToChanges()`}. The `diffToChanges()` input format is, in turn,
|
|
86
|
+
* compatible with the output of {@link module:utils/diff~diff `diff()`}:
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* const a = '1234';
|
|
90
|
+
* const b = '12xyz34';
|
|
91
|
+
*
|
|
92
|
+
* // Both calls will return the same results (grouped changes format).
|
|
93
|
+
* fastDiff( a, b );
|
|
94
|
+
* diffToChanges( diff( a, b ) );
|
|
95
|
+
*
|
|
96
|
+
* // Again, both calls will return the same results (atomic changes format).
|
|
97
|
+
* fastDiff( a, b, undefined, true );
|
|
98
|
+
* diff( a, b );
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @typeParam T The type of array elements.
|
|
102
|
+
* @typeParam AtomicChanges The type of `atomicChanges` parameter (selects the result type).
|
|
103
|
+
* @param a Input array or string.
|
|
104
|
+
* @param b Input array or string.
|
|
105
|
+
* @param cmp Optional function used to compare array values, by default `===` (strict equal operator) is used.
|
|
106
|
+
* @param atomicChanges Whether an array of `inset|delete|equal` operations should
|
|
107
|
+
* be returned instead of changes set. This makes this function compatible with {@link module:utils/diff~diff `diff()`}.
|
|
108
|
+
* Defaults to `false`.
|
|
109
|
+
* @returns Array of changes. The elements are either {@link module:utils/diff~DiffResult} or {@link module:utils/difftochanges~Change},
|
|
110
|
+
* depending on `atomicChanges` parameter.
|
|
111
|
+
*/
|
|
112
|
+
export declare function fastDiff<
|
|
113
|
+
T,
|
|
114
|
+
AtomicChanges extends boolean = false
|
|
115
|
+
>(a: ArrayLike<T>, b: ArrayLike<T>, cmp?: (a: T, b: T) => boolean, atomicChanges?: AtomicChanges): Array<AtomicChanges extends true ? DiffResult : Change<T>>;
|
package/dist/first.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* @module utils/first
|
|
7
|
+
*/
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* Returns first item of the given `iterator`.
|
|
10
|
+
*/
|
|
11
11
|
export declare function first<T>(iterator: Iterator<T>): T | null;
|