@ckeditor/ckeditor5-utils 32.0.0 → 33.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/dom/iscomment.js +1 -1
- package/src/dom/isvisible.js +1 -1
- package/src/unicode.js +37 -0
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "33.0.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": "^33.0.0",
|
|
18
|
+
"@ckeditor/ckeditor5-editor-classic": "^33.0.0",
|
|
19
|
+
"@ckeditor/ckeditor5-core": "^33.0.0",
|
|
20
|
+
"@ckeditor/ckeditor5-engine": "^33.0.0"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=14.0.0",
|
package/src/dom/iscomment.js
CHANGED
package/src/dom/isvisible.js
CHANGED
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
|
+
}
|