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

Commit 2054e69

Browse files
authored
Merge pull request #91 from bendemboski/fix-mso-list-none
Fix: Fixed handling `mso-list:normal`. Closes ckeditor/ckeditor5#5712. Thanks @bendemboski!
2 parents 2cd7b0f + 3918e76 commit 2054e69

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/filters/list.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,15 @@ function getListItemData( element ) {
201201
const listStyle = element.getStyle( 'mso-list' );
202202

203203
if ( listStyle ) {
204-
data.id = parseInt( listStyle.match( /(^|\s+)l(\d+)/i )[ 2 ] );
205-
data.order = parseInt( listStyle.match( /\s*lfo(\d+)/i )[ 1 ] );
206-
data.indent = parseInt( listStyle.match( /\s*level(\d+)/i )[ 1 ] );
204+
const idMatch = listStyle.match( /(^|\s+)l(\d+)/i );
205+
const orderMatch = listStyle.match( /\s*lfo(\d+)/i );
206+
const indentMatch = listStyle.match( /\s*level(\d+)/i );
207+
208+
if ( idMatch && orderMatch && indentMatch ) {
209+
data.id = idMatch[ 2 ];
210+
data.order = orderMatch[ 1 ];
211+
data.indent = indentMatch[ 1 ];
212+
}
207213
}
208214

209215
return data;

tests/filters/list.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ describe( 'PasteFromOffice - filters', () => {
6161
expect( stringify( view ) ).to.equal( '<ol><li style="mso-list:">Item 1</li></ol>' );
6262
} );
6363

64+
it( 'handles `mso-list: none` on paragraphs correctly', () => {
65+
const html = '<p style="mso-list:none">not numbered<o:p></o:p></p>';
66+
const view = htmlDataProcessor.toView( html );
67+
68+
transformListItemLikeElementsIntoLists( view, '', new View() );
69+
70+
expect( view.childCount ).to.equal( 1 );
71+
expect( view.getChild( 0 ).name ).to.equal( 'ol' );
72+
expect( stringify( view ) ).to.equal( '<ol><li style="mso-list:none">not numbered<o:p></o:p></li></ol>' );
73+
} );
74+
6475
it( 'handles empty body correctly', () => {
6576
const view = htmlDataProcessor.toView( '' );
6677

0 commit comments

Comments
 (0)