Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit bcc4e3b

Browse files
committed
Merge branch 'vladikoff-fix-numbered-list'
Fix: Ordered list will now be triggered by a numer and `.` or `)`. Closes #42. Thanks to @vladikoff!
2 parents f57ea99 + 60f718d commit bcc4e3b

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/autoformat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class Autoformat extends Plugin {
5454

5555
if ( commands.get( 'numberedList' ) ) {
5656
// eslint-disable-next-line no-new
57-
new BlockAutoformatEngine( this.editor, /^\d+[.|)]?\s$/, 'numberedList' );
57+
new BlockAutoformatEngine( this.editor, /^\d+[.|)]\s$/, 'numberedList' );
5858
}
5959
}
6060

tests/autoformat.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe( 'Autoformat', () => {
8282
} );
8383

8484
describe( 'Numbered list', () => {
85-
it( 'should replace digit with numbered list item', () => {
85+
it( 'should replace digit with numbered list item using the dot format', () => {
8686
setData( doc, '<paragraph>1.[]</paragraph>' );
8787
doc.enqueueChanges( () => {
8888
batch.insertText( ' ', doc.selection.getFirstPosition() );
@@ -91,6 +91,24 @@ describe( 'Autoformat', () => {
9191
expect( getData( doc ) ).to.equal( '<listItem indent="0" type="numbered">[]</listItem>' );
9292
} );
9393

94+
it( 'should replace digit with numbered list item using the parenthesis format', () => {
95+
setData( doc, '<paragraph>1)[]</paragraph>' );
96+
doc.enqueueChanges( () => {
97+
batch.insertText( ' ', doc.selection.getFirstPosition() );
98+
} );
99+
100+
expect( getData( doc ) ).to.equal( '<listItem indent="0" type="numbered">[]</listItem>' );
101+
} );
102+
103+
it( 'should not replace digit character when there is no . or ) in the format', () => {
104+
setData( doc, '<paragraph>1[]</paragraph>' );
105+
doc.enqueueChanges( () => {
106+
batch.insertText( ' ', doc.selection.getFirstPosition() );
107+
} );
108+
109+
expect( getData( doc ) ).to.equal( '<paragraph>1 []</paragraph>' );
110+
} );
111+
94112
it( 'should not replace digit character when inside numbered list item', () => {
95113
setData( doc, '<listItem indent="0" type="numbered">1.[]</listItem>' );
96114
doc.enqueueChanges( () => {

tests/manual/autoformat.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
1. Type `>` and press the space in an empty paragraph to replace it with a block quote.
88

9-
1. Type a number from the range **1-3** to replace an empty paragraph with a numbered list item.
9+
1. Type a number from the range **1-3** followed by a `.` and press space to replace an empty paragraph with a numbered list item.
10+
11+
1. Type a number from the range **1-3** followed by a `)` and press space to replace an empty paragraph with a numbered list item.
1012

1113
1. Type `*foobar*`/`_foobar_` to italicize `foobar`. `*`/`_` should be removed.
1214

0 commit comments

Comments
 (0)