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

Commit

Permalink
Merge pull request #80 from ckeditor/t/ckeditor5-list/115
Browse files Browse the repository at this point in the history
Other: Remove the `fixListIndentation()` filter in favor of improved list converters fix. See ckeditor/ckeditor5-list#115.
  • Loading branch information
Reinmar authored Oct 7, 2019
2 parents 47ce5df + bd95f5b commit d594038
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 210 deletions.
59 changes: 0 additions & 59 deletions src/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,65 +70,6 @@ export function unwrapParagraphInListItem( documentFragment, writer ) {
}
}

/**
* Fix structure of nested lists to follow HTML guidelines and normalize content in predictable way.
*
* 1. Move nested lists to have sure that list items are the only children of lists.
*
* before: after:
* OL OL
* |-> LI |-> LI
* |-> OL |-> OL
* |-> LI |-> LI
*
* 2. Remove additional indentation which cannot be recreated in HTML structure.
*
* before: after:
* OL OL
* |-> LI |-> LI
* |-> OL |-> OL
* |-> OL |-> LI
* | |-> OL |-> LI
* | |-> OL
* | |-> LI
* |-> LI
*
* before: after:
* OL OL
* |-> OL |-> LI
* |-> OL
* |-> OL
* |-> LI
*
* @param {module:engine/view/documentfragment~DocumentFragment} documentFragment
* @param {module:engine/view/upcastwriter~UpcastWriter} writer
*/
export function fixListIndentation( documentFragment, writer ) {
for ( const value of writer.createRangeIn( documentFragment ) ) {
const element = value.item;

// case 1: The previous sibling of a list is a list item.
if ( element.is( 'li' ) ) {
const next = element.nextSibling;

if ( next && isList( next ) ) {
writer.remove( next );
writer.insertChild( element.childCount, next, element );
}
}

// case 2: The list is the first child of another list.
if ( isList( element ) ) {
let firstChild = element.getChild( 0 );

while ( isList( firstChild ) ) {
writer.unwrapElement( firstChild );
firstChild = element.getChild( 0 );
}
}
}
}

// Finds all list-like elements in a given document fragment.
//
// @param {module:engine/view/documentfragment~DocumentFragment} documentFragment Document fragment
Expand Down
1 change: 0 additions & 1 deletion src/normalizers/googledocsnormalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default class GoogleDocsNormalizer {
const writer = new UpcastWriter();

removeBoldWrapper( data.content, writer );
fixListIndentation( data.content, writer );
unwrapParagraphInListItem( data.content, writer );
}
}
10 changes: 0 additions & 10 deletions tests/_data/paste-from-google-docs/lists/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
*/

import nestedOrderedList from './nested-ordered-lists/input.html';
import nestedOrderedListNormalized from './nested-ordered-lists/normalized.html';
import nestedOrderedListModel from './nested-ordered-lists/model.html';

import mixedList from './mixed-list/input.html';
import mixedListNormalized from './mixed-list/normalized.html';
import mixedListModel from './mixed-list/model.html';

import repeatedlyNestedList from './repeatedly-nested-list/input.html';
import repeatedlyNestedListNormalized from './repeatedly-nested-list/normalized.html';
import repeatedlyNestedListModel from './repeatedly-nested-list/model.html';

import partiallySelected from './partially-selected/input.html';
import partiallySelectedNormalized from './partially-selected/normalized.html';
import partiallySelectedModel from './partially-selected/model.html';

export const fixtures = {
Expand All @@ -26,12 +22,6 @@ export const fixtures = {
repeatedlyNestedList,
partiallySelected
},
normalized: {
nestedOrderedList: nestedOrderedListNormalized,
mixedList: mixedListNormalized,
repeatedlyNestedList: repeatedlyNestedListNormalized,
partiallySelected: partiallySelectedNormalized
},
model: {
nestedOrderedList: nestedOrderedListModel,
mixedList: mixedListModel,
Expand Down

This file was deleted.

Loading

0 comments on commit d594038

Please sign in to comment.