Skip to content

Commit

Permalink
Merge pull request #14758 from ckeditor/ck/12466-document-list-pasted…
Browse files Browse the repository at this point in the history
…-from-word-displayed-incorrectly

Fix (indent): Nested lists pasted from Word should be displayed properly in Document Lists. Closes #12466.
  • Loading branch information
niegowski authored Aug 16, 2023
2 parents 9ff729c + 5ac2b50 commit a8b1e91
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/ckeditor5-indent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"devDependencies": {
"@ckeditor/ckeditor5-core": "39.0.1",
"@ckeditor/ckeditor5-dev-utils": "^38.0.0",
"@ckeditor/ckeditor5-list": "39.0.1",
"@ckeditor/ckeditor5-editor-classic": "39.0.1",
"@ckeditor/ckeditor5-engine": "39.0.1",
"@ckeditor/ckeditor5-heading": "39.0.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/ckeditor5-indent/src/indentblock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ export default class IndentBlock extends Plugin {
},
model: {
key: 'blockIndent',
value: ( viewElement: ViewElement ) => viewElement.getStyle( marginProperty )
value: ( viewElement: ViewElement ) => {
// Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.
if ( !viewElement.is( 'element', 'li' ) ) {
return viewElement.getStyle( marginProperty );
}
}
}
} );

Expand Down
25 changes: 25 additions & 0 deletions packages/ckeditor5-indent/tests/indentblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting';
import DocumentListEditing from '@ckeditor/ckeditor5-list/src/documentlist/documentlistediting';

import IndentEditing from '../src/indentediting';
import IndentBlock from '../src/indentblock';
Expand Down Expand Up @@ -158,6 +159,30 @@ describe( 'IndentBlock', () => {
expect( getViewData( editor.editing.view, { withoutSelection: true } ) )
.to.equal( '<p style="margin-left:42em">foo</p>' );
} );

describe( 'integration with List', () => {
beforeEach( () => {
return VirtualTestEditor
.create( {
plugins: [ Paragraph, DocumentListEditing, IndentEditing, IndentBlock ]
} )
.then( newEditor => {
editor = newEditor;
model = editor.model;
doc = model.document;
} );
} );

// Block elements in Document Lists should not be indented. See https://github.com/ckeditor/ckeditor5/issues/12466.
it( 'should not convert margin-left to indent attribute for a list item', () => {
editor.setData( '<ul><li style="margin-left:72.0pt">foo</li></ul>' );

const paragraph = doc.getRoot().getChild( 0 );

expect( paragraph.hasAttribute( 'blockIndent' ) ).to.be.false;
expect( editor.getData() ).to.equal( '<ul><li>foo</li></ul>' );
} );
} );
} );

describe( 'right–to–left content', () => {
Expand Down

0 comments on commit a8b1e91

Please sign in to comment.