Skip to content

Commit aa8ad88

Browse files
authored
Fix list continuation if non-list item between. (#18779)
Fix (list): No longer merge separate lists pasted from Microsoft Office into a single list. Closes #18015
1 parent 7568a17 commit aa8ad88

File tree

5 files changed

+934
-4
lines changed

5 files changed

+934
-4
lines changed

packages/ckeditor5-paste-from-office/src/filters/list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ function isListContinuation( currentItem: ListLikeElement ) {
268268
const previousSibling = currentItem.element.previousSibling;
269269

270270
if ( !previousSibling ) {
271+
const parent = currentItem.element.parent as ViewElement;
272+
271273
// If it's a li inside ul or ol like in here: https://github.com/ckeditor/ckeditor5/issues/15964.
272-
return isList( currentItem.element.parent as ViewElement );
274+
// If the parent has previous sibling, which is not a list, then it is not a continuation.
275+
return isList( parent ) && ( !parent.previousSibling || isList( parent.previousSibling ) );
273276
}
274277

275278
// Even with the same id the list does not have to be continuous (#43).

packages/ckeditor5-paste-from-office/tests/_data/list/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import styledAnchor from './styled-anchor/input.word2016.html';
2121
import multiBlock from './multi-block/input.word.html';
2222
import mixedElements from './mixed-elements/input.word.html';
2323
import multiBlockBlockAfter from './multi-block-block-after/input.word.html';
24+
import listContinuation from './list-continuation/input.word2016.html';
2425

2526
import simpleNormalized from './simple/normalized.word2016.html';
2627
import styledNormalized from './styled/normalized.word2016.html';
@@ -39,6 +40,7 @@ import styledAnchorNormalized from './styled-anchor/normalized.word2016.html';
3940
import multiBlockNormalized from './multi-block/normalized.word.html';
4041
import mixedElementsNormalized from './mixed-elements/normalized.word.html';
4142
import multiBlockBlockAfterNormalized from './multi-block-block-after/normalized.word.html';
43+
import listContinuationNormalized from './list-continuation/normalized.word2016.html';
4244

4345
import simpleModel from './simple/model.word2016.html';
4446
import styledModel from './styled/model.word2016.html';
@@ -57,6 +59,7 @@ import styledAnchorModel from './styled-anchor/model.word2016.html';
5759
import multiBlockModel from './multi-block/model.word.html';
5860
import mixedElementsModel from './mixed-elements/model.word.html';
5961
import multiBlockBlockAfterModel from './multi-block-block-after/model.word.html';
62+
import listContinuationModel from './list-continuation/model.word2016.html';
6063

6164
export const fixtures = {
6265
input: {
@@ -76,7 +79,8 @@ export const fixtures = {
7679
styledAnchor,
7780
multiBlock,
7881
mixedElements,
79-
multiBlockBlockAfter
82+
multiBlockBlockAfter,
83+
listContinuation
8084
},
8185
normalized: {
8286
simple: simpleNormalized,
@@ -95,7 +99,8 @@ export const fixtures = {
9599
styledAnchor: styledAnchorNormalized,
96100
multiBlock: multiBlockNormalized,
97101
mixedElements: mixedElementsNormalized,
98-
multiBlockBlockAfter: multiBlockBlockAfterNormalized
102+
multiBlockBlockAfter: multiBlockBlockAfterNormalized,
103+
listContinuation: listContinuationNormalized
99104
},
100105
model: {
101106
simple: simpleModel,
@@ -114,7 +119,8 @@ export const fixtures = {
114119
styledAnchor: styledAnchorModel,
115120
multiBlock: multiBlockModel,
116121
mixedElements: mixedElementsModel,
117-
multiBlockBlockAfter: multiBlockBlockAfterModel
122+
multiBlockBlockAfter: multiBlockBlockAfterModel,
123+
listContinuation: listContinuationModel
118124
}
119125
};
120126

0 commit comments

Comments
 (0)