@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-utils",
3
- "version": "32.0.0",
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": "^32.0.0",
18
- "@ckeditor/ckeditor5-editor-classic": "^32.0.0",
19
- "@ckeditor/ckeditor5-core": "^32.0.0",
20
- "@ckeditor/ckeditor5-engine": "^32.0.0"
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",
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  /**
13
- * Checks if the object is a native DOM Comment node.
13
+ * Checks whether the object is a native DOM Comment node.
14
14
  *
15
15
  * @param {*} obj
16
16
  * @returns {Boolean}
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  /**
11
- * Checks if the element is visible to the user in DOM:
11
+ * Checks whether the element is visible to the user in DOM:
12
12
  *
13
13
  * * connected to the root of the document,
14
14
  * * has no `display: none`,
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 = '32.0.0';
14
+ const version = '33.0.0';
15
15
 
16
16
  export default version;
17
17