8
0
Просмотр исходного кода

Merge pull request #69 from ckeditor/t/60

Other: Any digit followed by a dot won't trigger the numbered list. Now, only `1` is supported by the `Autoformat` plugin. Closes #60.
Piotrek Koszuliński 6 лет назад
Родитель
Сommit
2582b04f83

+ 1 - 1
packages/ckeditor5-autoformat/src/autoformat.js

@@ -56,7 +56,7 @@ export default class Autoformat extends Plugin {
 
 		if ( commands.get( 'numberedList' ) ) {
 			// eslint-disable-next-line no-new
-			new BlockAutoformatEditing( this.editor, /^\d+[.|)]\s$/, 'numberedList' );
+			new BlockAutoformatEditing( this.editor, /^1[.|)]\s$/, 'numberedList' );
 		}
 	}
 

+ 9 - 0
packages/ckeditor5-autoformat/tests/autoformat.js

@@ -117,6 +117,15 @@ describe( 'Autoformat', () => {
 
 			expect( getData( model ) ).to.equal( '<listItem listIndent="0" listType="numbered">1. []</listItem>' );
 		} );
+
+		it( 'should not replace digit with numbered list item when digit is different than "1"', () => {
+			setData( model, '<paragraph>3.[]</paragraph>' );
+			model.change( writer => {
+				writer.insertText( ' ', doc.selection.getFirstPosition() );
+			} );
+
+			expect( getData( model ) ).to.equal( '<paragraph>3. []</paragraph>' );
+		} );
 	} );
 
 	describe( 'Heading', () => {