Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested lists pasted from Word should be displayed properly in Document Lists. #14758

Merged
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
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