This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff 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 * l f o ( \d + ) / i ) [ 1 ] ) ;
206- data . indent = parseInt ( listStyle . match ( / \s * l e v e l ( \d + ) / i ) [ 1 ] ) ;
204+ const idMatch = listStyle . match ( / ( ^ | \s + ) l ( \d + ) / i ) ;
205+ const orderMatch = listStyle . match ( / \s * l f o ( \d + ) / i ) ;
206+ const indentMatch = listStyle . match ( / \s * l e v e l ( \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 ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments