@ckeditor/ckeditor5-utils 32.0.0 → 34.1.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 +2 -2
- package/README.md +2 -1
- package/package.json +5 -5
- package/src/ckeditorerror.js +1 -2
- package/src/dom/iscomment.js +1 -1
- package/src/dom/isvisible.js +1 -1
- package/src/emittermixin.js +2 -15
- package/src/index.js +1 -0
- package/src/inserttopriorityarray.js +42 -0
- package/src/unicode.js +37 -0
- package/src/version.js +5 -5
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 utilities** – https://github.com/ckeditor/ckeditor5-utils <br>
|
|
5
|
-
Copyright (c) 2003-2022, [CKSource
|
|
5
|
+
Copyright (c) 2003-2022, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
|
@@ -18,4 +18,4 @@ The following libraries are included in CKEditor under the [MIT license](https:/
|
|
|
18
18
|
Trademarks
|
|
19
19
|
----------
|
|
20
20
|
|
|
21
|
-
**CKEditor** is a trademark of [CKSource
|
|
21
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@ CKEditor 5 utilities
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-utils)
|
|
5
5
|
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
|
-
[](https://travis-ci.com/ckeditor/ckeditor5)
|
|
6
|
+
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
+

|
|
7
8
|
|
|
8
9
|
Various utilities used by CKEditor 5 and its features. This is a sort of CKEditor 5's standard library.
|
|
9
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "34.1.0",
|
|
4
4
|
"description": "Miscellaneous utilities used by CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"lodash-es": "^4.17.15"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@ckeditor/ckeditor5-build-classic": "^
|
|
18
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
|
20
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
17
|
+
"@ckeditor/ckeditor5-build-classic": "^34.1.0",
|
|
18
|
+
"@ckeditor/ckeditor5-editor-classic": "^34.1.0",
|
|
19
|
+
"@ckeditor/ckeditor5-core": "^34.1.0",
|
|
20
|
+
"@ckeditor/ckeditor5-engine": "^34.1.0"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=14.0.0",
|
package/src/ckeditorerror.js
CHANGED
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* URL to the documentation with error codes.
|
|
14
14
|
*/
|
|
15
|
-
export const DOCUMENTATION_URL =
|
|
16
|
-
'https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html';
|
|
15
|
+
export const DOCUMENTATION_URL = 'https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* The CKEditor error class.
|
package/src/dom/iscomment.js
CHANGED
package/src/dom/isvisible.js
CHANGED
package/src/emittermixin.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import EventInfo from './eventinfo';
|
|
11
11
|
import uid from './uid';
|
|
12
12
|
import priorities from './priorities';
|
|
13
|
+
import insertToPriorityArray from './inserttopriorityarray';
|
|
13
14
|
|
|
14
15
|
// To check if component is loaded more than once.
|
|
15
16
|
import './version';
|
|
@@ -298,21 +299,7 @@ const EmitterMixin = {
|
|
|
298
299
|
// Add the callback to all callbacks list.
|
|
299
300
|
for ( const callbacks of lists ) {
|
|
300
301
|
// Add the callback to the list in the right priority position.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
for ( let i = 0; i < callbacks.length; i++ ) {
|
|
304
|
-
if ( callbacks[ i ].priority < priority ) {
|
|
305
|
-
callbacks.splice( i, 0, callbackDefinition );
|
|
306
|
-
added = true;
|
|
307
|
-
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Add at the end, if right place was not found.
|
|
313
|
-
if ( !added ) {
|
|
314
|
-
callbacks.push( callbackDefinition );
|
|
315
|
-
}
|
|
302
|
+
insertToPriorityArray( callbacks, callbackDefinition );
|
|
316
303
|
}
|
|
317
304
|
},
|
|
318
305
|
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export { default as ResizeObserver } from './dom/resizeobserver';
|
|
|
27
27
|
export { default as setDataInElement } from './dom/setdatainelement';
|
|
28
28
|
export { default as toUnit } from './dom/tounit';
|
|
29
29
|
export { default as isVisible } from './dom/isvisible';
|
|
30
|
+
export * from './dom/scroll';
|
|
30
31
|
|
|
31
32
|
export * from './keyboard';
|
|
32
33
|
export * from './language';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, 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
|
+
import priorities from './priorities';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @module utils/inserttopriorityarray
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The priority object descriptor.
|
|
14
|
+
*
|
|
15
|
+
* const objectWithPriority = {
|
|
16
|
+
* priority: 'high'
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* @typedef {Object} module:utils/inserttopriorityarray~ObjectWithPriority
|
|
20
|
+
*
|
|
21
|
+
* @property {module:utils/priorities~PriorityString|Number} priority Priority of the object.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Inserts any object with priority at correct index by priority so registered objects are always sorted from highest to lowest priority.
|
|
26
|
+
*
|
|
27
|
+
* @param {Array.<module:utils/inserttopriorityarray~ObjectWithPriority>} objects Array of objects with priority to insert object to.
|
|
28
|
+
* @param {module:utils/inserttopriorityarray~ObjectWithPriority} objectToInsert Object with `priority` property.
|
|
29
|
+
*/
|
|
30
|
+
export default function insertToPriorityArray( objects, objectToInsert ) {
|
|
31
|
+
const priority = priorities.get( objectToInsert.priority );
|
|
32
|
+
|
|
33
|
+
for ( let i = 0; i < objects.length; i++ ) {
|
|
34
|
+
if ( priorities.get( objects[ i ].priority ) < priority ) {
|
|
35
|
+
objects.splice( i, 0, objectToInsert );
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
objects.push( objectToInsert );
|
|
42
|
+
}
|
package/src/unicode.js
CHANGED
|
@@ -67,3 +67,40 @@ export function isInsideSurrogatePair( string, offset ) {
|
|
|
67
67
|
export function isInsideCombinedSymbol( string, offset ) {
|
|
68
68
|
return isCombiningMark( string.charAt( offset ) );
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
const EMOJI_PATTERN = buildEmojiRegexp();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks whether given offset in a string is inside multi-character emoji sequence.
|
|
75
|
+
*
|
|
76
|
+
* @param {String} string String to check.
|
|
77
|
+
* @param {Number} offset Offset to check.
|
|
78
|
+
* @returns {Boolean}
|
|
79
|
+
*/
|
|
80
|
+
export function isInsideEmojiSequence( string, offset ) {
|
|
81
|
+
const matches = String( string ).matchAll( EMOJI_PATTERN );
|
|
82
|
+
|
|
83
|
+
return Array.from( matches ).some( match => match.index < offset && offset < match.index + match[ 0 ].length );
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function buildEmojiRegexp() {
|
|
87
|
+
const parts = [
|
|
88
|
+
// Emoji Tag Sequence (ETS)
|
|
89
|
+
/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,
|
|
90
|
+
|
|
91
|
+
// Emoji Keycap Sequence
|
|
92
|
+
/\p{Emoji}\u{FE0F}?\u{20E3}/u,
|
|
93
|
+
|
|
94
|
+
// Emoji Presentation Sequence
|
|
95
|
+
/\p{Emoji}\u{FE0F}/u,
|
|
96
|
+
|
|
97
|
+
// Single-Character Emoji / Emoji Modifier Sequence
|
|
98
|
+
/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
const flagSequence = /\p{Regional_Indicator}{2}/u.source;
|
|
102
|
+
const emoji = '(?:' + parts.map( part => part.source ).join( '|' ) + ')';
|
|
103
|
+
const sequence = `${ flagSequence }|${ emoji }(?:\u{200D}${ emoji })*`;
|
|
104
|
+
|
|
105
|
+
return new RegExp( sequence, 'ug' );
|
|
106
|
+
}
|
package/src/version.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import CKEditorError from './ckeditorerror';
|
|
13
13
|
|
|
14
|
-
const version = '
|
|
14
|
+
const version = '34.1.0';
|
|
15
15
|
|
|
16
16
|
export default version;
|
|
17
17
|
|
|
@@ -49,14 +49,14 @@ if ( windowOrGlobal.CKEDITOR_VERSION ) {
|
|
|
49
49
|
* Adding plugins to a build is done by taking the source version of this build (so, before it was built with webpack)
|
|
50
50
|
* and adding plugins there. In this situation, webpack will know that it only needs to load each plugin once.
|
|
51
51
|
*
|
|
52
|
-
* Read more in the {@glink
|
|
52
|
+
* Read more in the {@glink installation/getting-started/installing-plugins "Installing plugins"} guide.
|
|
53
53
|
*
|
|
54
54
|
* # Confused an editor build with an editor implementation
|
|
55
55
|
*
|
|
56
56
|
* This scenario is very similar to the previous one, but has a different origin.
|
|
57
57
|
*
|
|
58
58
|
* Let's assume that you wanted to use CKEditor 5 from source, as explained in the
|
|
59
|
-
* {@glink
|
|
59
|
+
* {@glink installation/advanced/alternative-setups/integrating-from-source "Building from source"} section
|
|
60
60
|
* or in the {@glink framework/guides/quick-start "Quick start"} guide of CKEditor 5 Framework.
|
|
61
61
|
*
|
|
62
62
|
* The correct way to do so is to import an editor and plugins and run them together like this:
|
|
@@ -98,7 +98,7 @@ if ( windowOrGlobal.CKEDITOR_VERSION ) {
|
|
|
98
98
|
* Check your web page for duplicated `<script>` elements or make sure your page builder/bundler includes CKEditor only once.
|
|
99
99
|
*
|
|
100
100
|
* If you want to use two different types of editors at once, see the
|
|
101
|
-
* {@glink
|
|
101
|
+
* {@glink installation/advanced/using-two-editors "Using two different editors"}
|
|
102
102
|
* section.
|
|
103
103
|
*
|
|
104
104
|
* # Using outdated packages
|
|
@@ -124,7 +124,7 @@ if ( windowOrGlobal.CKEDITOR_VERSION ) {
|
|
|
124
124
|
* **Note:** All official CKEditor 5 packages (excluding integrations and `ckeditor5-dev-*` packages) are released in the
|
|
125
125
|
* same major version. This is — in the `x.y.z`, the `x` is the same for all packages. This is the simplest way to check
|
|
126
126
|
* whether you use packages coming from the same CKEditor 5 version. You can read more about versioning in the
|
|
127
|
-
* {@glink
|
|
127
|
+
* {@glink support/versioning-policy Versioning policy} guide.
|
|
128
128
|
*
|
|
129
129
|
* # Packages were duplicated in `node_modules`
|
|
130
130
|
*
|