diff --git a/src/filters/list.js b/src/filters/list.js index 4c23c73..87cf341 100644 --- a/src/filters/list.js +++ b/src/filters/list.js @@ -201,9 +201,15 @@ function getListItemData( element ) { const listStyle = element.getStyle( 'mso-list' ); if ( listStyle ) { - data.id = parseInt( listStyle.match( /(^|\s+)l(\d+)/i )[ 2 ] ); - data.order = parseInt( listStyle.match( /\s*lfo(\d+)/i )[ 1 ] ); - data.indent = parseInt( listStyle.match( /\s*level(\d+)/i )[ 1 ] ); + const idMatch = listStyle.match( /(^|\s+)l(\d+)/i ); + const orderMatch = listStyle.match( /\s*lfo(\d+)/i ); + const indentMatch = listStyle.match( /\s*level(\d+)/i ); + + if ( idMatch && orderMatch && indentMatch ) { + data.id = idMatch[ 2 ]; + data.order = orderMatch[ 1 ]; + data.indent = indentMatch[ 1 ]; + } } return data; diff --git a/tests/filters/list.js b/tests/filters/list.js index 6d41558..3a54e51 100644 --- a/tests/filters/list.js +++ b/tests/filters/list.js @@ -61,6 +61,17 @@ describe( 'PasteFromOffice - filters', () => { expect( stringify( view ) ).to.equal( '
  1. Item 1
' ); } ); + it( 'handles `mso-list: none` on paragraphs correctly', () => { + const html = '

not numbered

'; + const view = htmlDataProcessor.toView( html ); + + transformListItemLikeElementsIntoLists( view, '', new View() ); + + expect( view.childCount ).to.equal( 1 ); + expect( view.getChild( 0 ).name ).to.equal( 'ol' ); + expect( stringify( view ) ).to.equal( '
  1. not numbered
' ); + } ); + it( 'handles empty body correctly', () => { const view = htmlDataProcessor.toView( '' );