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

Fix handling mso-list:normal. Closes ckeditor/ckeditor5#5712 #91

Merged
merged 1 commit into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions tests/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ describe( 'PasteFromOffice - filters', () => {
expect( stringify( view ) ).to.equal( '<ol><li style="mso-list:">Item 1</li></ol>' );
} );

it( 'handles `mso-list: none` on paragraphs correctly', () => {
const html = '<p style="mso-list:none">not numbered<o:p></o:p></p>';
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( '<ol><li style="mso-list:none">not numbered<o:p></o:p></li></ol>' );
} );

it( 'handles empty body correctly', () => {
const view = htmlDataProcessor.toView( '' );

Expand Down