浏览代码

Add punctuation initial quote unicode group support.

Maciej Gołaszewski 6 年之前
父节点
当前提交
8dfe29d390
共有 2 个文件被更改,包括 8 次插入3 次删除
  1. 2 2
      packages/ckeditor5-mention/src/mentionui.js
  2. 6 1
      packages/ckeditor5-mention/tests/mentionui.js

+ 2 - 2
packages/ckeditor5-mention/src/mentionui.js

@@ -543,10 +543,10 @@ function createRegExp( marker, minimumCharacters ) {
 	const numberOfCharacters = minimumCharacters == 0 ? '*' : `{${ minimumCharacters },}`;
 
 	if ( !env.isEdge ) {
-		// Unfortunately Edge does not throw on `/[\p{Ps}]/u` as it does on `/\p{Ps}/u (no square brackets in latter).
+		// Unfortunately Edge does not throw on `/[\p{Ps}\p{Pi}]/u` as it does on `/\p{Ps}\p{Pi}/u (no square brackets in latter).
 		try {
 			// Uses the ES2018 syntax. See ckeditor5-mention#44.
-			return new RegExp( buildPattern( '\\p{Ps}"\'', marker, numberOfCharacters ), 'u' );
+			return new RegExp( buildPattern( '\\p{Ps}\\p{Pi}"\'', marker, numberOfCharacters ), 'u' );
 		} catch ( error ) {
 			// It's OK we're fallback to non ES2018 RegExp later.
 		}

+ 6 - 1
packages/ckeditor5-mention/tests/mentionui.js

@@ -609,7 +609,12 @@ describe( 'MentionUI', () => {
 			}
 
 			// Excerpt of opening parenthesis type characters that tests ES2018 Unicode property escapes on supported environment.
-			for ( const character of [ '〈', '„', '﹛', '⦅', '{' ] ) {
+			for ( const character of [
+				// Belongs to Ps (Punctuation, Open) group:
+				'〈', '„', '﹛', '⦅', '{',
+				// Belongs to Pi (Punctuation, Initial quote) group:
+				'«', '‹', '⸌', ' ⸂', '⸠'
+			] ) {
 				testOpeningPunctuationCharacter( character, !supportsES2018Escapes );
 			}