Skip to content

Commit

Permalink
Merge pull request #13771 from ckeditor/ck/13711-fix-handling-for-rtl…
Browse files Browse the repository at this point in the history
…-lists-in-paste-from-office-plugin

Fix (paste-from-office): Fix handling of bold text in RTL lists pasted from MS Word. Closes #13711.
  • Loading branch information
arkflpc authored Mar 28, 2023
2 parents b90fc8a + 4977f17 commit 3abb8df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ckeditor5-paste-from-office/src/filters/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ function findListMarkerNode( element: ViewElement ): ViewText | null {
continue;
}

const textNodeOrElement = childNode.getChild( 0 )!;
const textNodeOrElement = childNode.getChild( 0 );

if ( !textNodeOrElement ) {
continue;
}

// If already found the marker element, use it.
if ( textNodeOrElement.is( '$text' ) ) {
Expand Down
22 changes: 22 additions & 0 deletions packages/ckeditor5-paste-from-office/tests/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ describe( 'PasteFromOffice - filters', () => {
expect( stringify( view ) ).to.equal( '' );
} );

it( 'handles RTL lists with bold item - #13711', () => {
const html = '<p dir=RTL style="mso-list:l0 level1 lfo1">' +
'<span dir=RTL></span>' +
'<b><span dir=LTR>Foo<o:p></o:p></span></b>' +
'</p>';

const view = htmlDataProcessor.toView( html );

transformListItemLikeElementsIntoLists( view, '@list l0:level1 { mso-level-number-format: bullet; }' );

expect( view.childCount ).to.equal( 1 );
expect( view.getChild( 0 ).name ).to.equal( 'ul' );
expect( stringify( view ) ).to.equal(
'<ul>' +
'<li dir="RTL" style="mso-list:l0 level1 lfo1">' +
'<span dir="RTL"></span>' +
'<b><span dir="LTR">Foo<o:p></o:p></span></b>' +
'</li>' +
'</ul>'
);
} );

describe( 'nesting', () => {
const level1 = 'style="mso-list:l0 level1 lfo0"';
const level2 = 'style="mso-list:l0 level2 lfo0"';
Expand Down

0 comments on commit 3abb8df

Please sign in to comment.