Răsfoiți Sursa

Return the normalized transformation in testCallback

panr 6 ani în urmă
părinte
comite
b0e4e704bf

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

@@ -167,7 +167,10 @@ export default class TextTransformation extends Plugin {
 				const match = from.test( text );
 
 				if ( match ) {
-					return { match, transformation };
+					return {
+						match,
+						normalizedTransformation
+					};
 				}
 			}
 		};
@@ -177,8 +180,8 @@ export default class TextTransformation extends Plugin {
 				return;
 			}
 
-			const from = normalizeFrom( data.transformation.from );
-			const to = normalizeTo( data.transformation.to );
+			const from = data.normalizedTransformation.from;
+			const to = data.normalizedTransformation.to;
 
 			const matches = from.exec( data.text );
 			const replaces = to( matches.slice( 1 ) );

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

@@ -133,10 +133,10 @@ export default class TextWatcher {
 		this.hasMatch = textHasMatch;
 
 		if ( textHasMatch ) {
-			// If text matches, get the transformation from the match and then pass it to the
+			// If text matches, get the normalized transformation from the match and then pass it to the
 			// event data object.
-			const transformation = textHasMatch.transformation;
-			const eventData = Object.assign( data, { transformation, text, range } );
+			const normalizedTransformation = textHasMatch.normalizedTransformation;
+			const eventData = Object.assign( data, { normalizedTransformation, text, range } );
 
 			/**
 			 * Fired whenever the text watcher found a match for data changes.