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 #46 from ckeditor/t/43
Browse files Browse the repository at this point in the history
Fix: Correct lists ordering for separate list items with the same `mso-list id`. Closes #43.
  • Loading branch information
Reinmar authored Feb 6, 2019
2 parents cadb41e + 25ca414 commit 4ebc363
Show file tree
Hide file tree
Showing 9 changed files with 2,944 additions and 8 deletions.
21 changes: 19 additions & 2 deletions src/filters/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function transformElementIntoListItem( element, writer ) {
//
// where:
//
// * `l1` is a list id (all elements with the same id belongs to the same list),
// * `l1` is a list id (however it does not mean this is a continuous list - see #43),
// * `level1` is a list item indentation level,
// * `lfo1` is a list insertion order in a document.
//
Expand Down Expand Up @@ -210,6 +210,23 @@ function removeBulletElement( element, writer ) {
}
}

// Whether previous and current item belongs to the same list. It is determined based on `item.id`
// (extracted from `mso-list` style, see #getListItemData) and previous sibling of the current item.
//
// @param {Object} previousItem
// @param {Object} currentItem
// @returns {Boolean}
function isNewListNeeded( previousItem, currentItem ) {
return previousItem.id !== currentItem.id;
if ( previousItem.id !== currentItem.id ) {
return true;
}

const previousSibling = currentItem.element.previousSibling;

if ( !previousSibling ) {
return true;
}

// Even with the same id the list does not have to by continuous one (#43).
return !previousSibling.is( 'element', 'ul' ) && !previousSibling.is( 'element', 'ol' );
}
24 changes: 18 additions & 6 deletions tests/_data/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import manyOneItem from './many-one-item/input.word2016.html';
import heading1 from './heading1/input.word2016.html';
import heading3Styled from './heading3-styled/input.word2016.html';
import heading7 from './heading7/input.word2016.html';
import resumeTemplate from './resume-template/input.word2016.html';

import simpleNormalized from './simple/normalized.word2016.html';
import styledNormalized from './styled/normalized.word2016.html';
Expand All @@ -21,6 +22,7 @@ import manyOneItemNormalized from './many-one-item/normalized.word2016.html';
import heading1Normalized from './heading1/normalized.word2016.html';
import heading3StyledNormalized from './heading3-styled/normalized.word2016.html';
import heading7Normalized from './heading7/normalized.word2016.html';
import resumeTemplateNormalized from './resume-template/normalized.word2016.html';

import simpleModel from './simple/model.word2016.html';
import styledModel from './styled/model.word2016.html';
Expand All @@ -30,6 +32,7 @@ import manyOneItemModel from './many-one-item/model.word2016.html';
import heading1Model from './heading1/model.word2016.html';
import heading3StyledModel from './heading3-styled/model.word2016.html';
import heading7Model from './heading7/model.word2016.html';
import resumeTemplateModel from './resume-template/model.word2016.html';

export const fixtures = {
input: {
Expand All @@ -40,7 +43,8 @@ export const fixtures = {
manyOneItem,
heading1,
heading3Styled,
heading7
heading7,
resumeTemplate
},
normalized: {
simple: simpleNormalized,
Expand All @@ -50,7 +54,8 @@ export const fixtures = {
manyOneItem: manyOneItemNormalized,
heading1: heading1Normalized,
heading3Styled: heading3StyledNormalized,
heading7: heading7Normalized
heading7: heading7Normalized,
resumeTemplate: resumeTemplateNormalized
},
model: {
simple: simpleModel,
Expand All @@ -60,7 +65,8 @@ export const fixtures = {
manyOneItem: manyOneItemModel,
heading1: heading1Model,
heading3Styled: heading3StyledModel,
heading7: heading7Model
heading7: heading7Model,
resumeTemplate: resumeTemplateModel
}
};

Expand All @@ -73,6 +79,7 @@ import manyOneItemSafari from './many-one-item/input.safari.word2016.html';
import heading1Safari from './heading1/input.safari.word2016.html';
import heading3StyledSafari from './heading3-styled/input.safari.word2016.html';
import heading7Safari from './heading7/input.safari.word2016.html';
import resumeTemplateSafari from './resume-template/input.safari.word2016.html';

import simpleNormalizedSafari from './simple/normalized.safari.word2016.html';
import styledNormalizedSafari from './styled/normalized.safari.word2016.html';
Expand All @@ -82,8 +89,10 @@ import manyOneItemNormalizedSafari from './many-one-item/normalized.safari.word2
import heading1NormalizedSafari from './heading1/normalized.safari.word2016.html';
import heading3StyledNormalizedSafari from './heading3-styled/normalized.safari.word2016.html';
import heading7NormalizedSafari from './heading7/normalized.safari.word2016.html';
import resumeTemplateNormalizedSafari from './resume-template/normalized.safari.word2016.html';

import styledSafariModel from './styled/model.safari.word2016.html';
import resumeTemplateSafariModel from './resume-template/model.safari.word2016.html';

export const browserFixtures = {
safari: {
Expand All @@ -95,7 +104,8 @@ export const browserFixtures = {
manyOneItem: manyOneItemSafari,
heading1: heading1Safari,
heading3Styled: heading3StyledSafari,
heading7: heading7Safari
heading7: heading7Safari,
resumeTemplate: resumeTemplateSafari
},
normalized: {
simple: simpleNormalizedSafari,
Expand All @@ -105,7 +115,8 @@ export const browserFixtures = {
manyOneItem: manyOneItemNormalizedSafari,
heading1: heading1NormalizedSafari,
heading3Styled: heading3StyledNormalizedSafari,
heading7: heading7NormalizedSafari
heading7: heading7NormalizedSafari,
resumeTemplate: resumeTemplateNormalizedSafari
},
model: {
simple: simpleModel,
Expand All @@ -115,7 +126,8 @@ export const browserFixtures = {
manyOneItem: manyOneItemModel,
heading1: heading1Model,
heading3Styled: heading3StyledModel,
heading7: heading7Model
heading7: heading7Model,
resumeTemplate: resumeTemplateSafariModel
}
}
};
Loading

0 comments on commit 4ebc363

Please sign in to comment.