瀏覽代碼

Changed regular expression to accept any kind of whitespace.

Maksymilian Barnaś 9 年之前
父節點
當前提交
b1b3bfabb5
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      packages/ckeditor5-autoformat/src/autoformat.js

+ 7 - 4
packages/ckeditor5-autoformat/src/autoformat.js

@@ -29,15 +29,16 @@ export default class Autoformat extends Feature {
 		const editor = this.editor;
 
 		if ( editor.commands.has( 'blockquote' ) ) {
-			new AutoformatEngine( editor, /^> $/, 'blockquote' );
+			new AutoformatEngine( editor, /^>\s$/, 'blockquote' );
 		}
 
 		if ( editor.commands.has( 'bulletedList' ) ) {
-			new AutoformatEngine( editor, /^[\*\-] $/, 'bulletedList' );
+			new AutoformatEngine( editor, /^[\*\-]\s$/, 'bulletedList' );
 		}
 
+		// TODO Should I start from custom number?
 		if ( editor.commands.has( 'numberedList' ) ) {
-			new AutoformatEngine( editor, /^\d+[\.|)]? $/, 'numberedList' ); // "1 A", "1. A", "123 A"
+			new AutoformatEngine( editor, /^\d+[\.|)]?\s$/, 'numberedList' ); // "1 A", "1. A", "123 A"
 		}
 
 		if ( editor.commands.has( 'heading' ) ) {
@@ -47,7 +48,9 @@ export default class Autoformat extends Feature {
 			// <p>## ^</p> -> <heading2>^</heading2> (two steps: executing heading command + removing the text prefix)
 			//
 			// After ctrl+z: <p>## ^</p> (so undo two steps)
-			new AutoformatEngine( editor, /^(#{1,3}) $/, ( batch, match, range ) => {
+			new AutoformatEngine( editor, /^(#{1,3})\s$/, ( context ) => {
+				const { batch, match, range } = context;
+
 				// TODO The heading command may be reconfigured in the future to support a different number
 				// of headings. That option must be exposed somehow, because we need to know here whether the replacement
 				// can be done or not.