8
0
Maciej Gołaszewski 6 лет назад
Родитель
Сommit
b47ef5f7b2

+ 3 - 3
packages/ckeditor5-typing/src/texttransformation.js

@@ -28,9 +28,9 @@ const DEFAULT_TRANSFORMATIONS = [
 
 
 	// Quotations:
 	// Quotations:
 	// English primary.
 	// English primary.
-	{ from: buildQuotesRegExp( '"' ), to: '$1”' },
+	{ from: buildQuotesRegExp( '"' ), to: '$1“$2”' },
 	// English secondary.
 	// English secondary.
-	{ from: buildQuotesRegExp( '\'' ), to: '$1’' }
+	{ from: buildQuotesRegExp( '\'' ), to: '$1‘$2’' }
 ];
 ];
 
 
 /**
 /**
@@ -103,7 +103,7 @@ export default class TextTransformation extends Plugin {
 // @param {String} quoteCharacter a character to creat a pattern for.
 // @param {String} quoteCharacter a character to creat a pattern for.
 // @returns {String}
 // @returns {String}
 function buildQuotesRegExp( quoteCharacter ) {
 function buildQuotesRegExp( quoteCharacter ) {
-	return new RegExp( `${ quoteCharacter }([^${ quoteCharacter }]+)${ quoteCharacter }$` );
+	return new RegExp( `(^|\\s)${ quoteCharacter }([^${ quoteCharacter }]+)${ quoteCharacter }$` );
 }
 }
 
 
 /**
 /**

+ 3 - 2
packages/ckeditor5-typing/tests/texttransformation.js

@@ -71,12 +71,13 @@ describe( 'Text transformation feature', () => {
 		describe( 'quotations', () => {
 		describe( 'quotations', () => {
 			describe( 'english US', () => {
 			describe( 'english US', () => {
 				describe( 'primary', () => {
 				describe( 'primary', () => {
-					testTransformation( '"Foo 1992 — bar(1) baz: xyz."', '“Foo 1992 — bar(1) baz: xyz.”' );
+					testTransformation( ' "Foo 1992 — bar(1) baz: xyz."', ' “Foo 1992 — bar(1) baz: xyz.”' );
 					testTransformation( '\' foo "bar"', '\' foo “bar”' );
 					testTransformation( '\' foo "bar"', '\' foo “bar”' );
+					testTransformation( 'Foo "Bar bar\'s it\'s a baz"', 'Foo “Bar bar\'s it\'s a baz”' );
 				} );
 				} );
 
 
 				describe( 'secondary', () => {
 				describe( 'secondary', () => {
-					testTransformation( '\'Foo 1992 — bar(1) baz: xyz.\'', '‘Foo 1992 — bar(1) baz: xyz.’' );
+					testTransformation( ' \'Foo 1992 — bar(1) baz: xyz.\'', ' ‘Foo 1992 — bar(1) baz: xyz.’' );
 					testTransformation( '" foo \'bar\'', '" foo ‘bar’' );
 					testTransformation( '" foo \'bar\'', '" foo ‘bar’' );
 				} );
 				} );
 			} );
 			} );