Skip to content

Commit f8d2136

Browse files
committed
Merge branch 't/16817' into major
2 parents 2d07c87 + 65c5433 commit f8d2136

File tree

14 files changed

+341
-375
lines changed

14 files changed

+341
-375
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ New Features:
99

1010
Fixed Issues:
1111

12+
* [#16817](http://dev.ckeditor.com/ticket/16817): Fixed: Paragraph transformed into lists, with corrupted data when pasting from Word.
1213
* [#16833](http://dev.ckeditor.com/ticket/16833): [IE11] Fixed: Malformed list with headers [pasted from Word](http://ckeditor.com/addon/pastefromword).
1314
* [#16826](http://dev.ckeditor.com/ticket/16826): Fixed: Superfluous paragraphs within lists [pasted from Word](http://ckeditor.com/addon/pastefromword) in IE.
1415
* [#16811](http://dev.ckeditor.com/ticket/16811): Fixed: Pasted from Word table alignment not preserved.

plugins/pastefromword/filter/default.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,17 +697,22 @@
697697
return true;
698698
}
699699

700+
var innerText = '';
701+
element.forEach( function( text ) {
702+
innerText += text.value;
703+
}, CKEDITOR.NODE_TEXT );
704+
700705
/*jshint -W024 */
701706
// Normally a style of the sort that looks like "mso-list: l0 level1 lfo1"
702707
// indicates a list element, but the same style may appear in a <p> that's within a <li>.
703-
if ( ( ( element.attributes.style && element.attributes.style.match( /mso\-list:\s?l\d/ ) ) &&
708+
if ( ( element.attributes.style && element.attributes.style.match( /mso\-list:\s?l\d/ ) &&
704709
element.parent.name !== 'li' ) ||
705710
element.attributes[ 'cke-dissolved' ] ||
706711
element.getHtml().match( /<!\-\-\[if !supportLists]\-\->/ ) ||
707-
// Flat, ordered lists are represented by paragraphs
708-
// who's text content roughly matches /(&nbsp;)*(.*?)(&nbsp;)+/
709-
// where the middle parentheses contain the symbol.
710-
element.getHtml().match( /^( )*.*?[\.\)] ( ){2,700}/ )
712+
// Flat, ordered lists are represented by paragraphs
713+
// who's text content roughly matches /(&nbsp;)*(.*?)(&nbsp;)+/
714+
// where the middle parentheses contain the symbol.
715+
innerText.match( /^( )*\(?[a-zA-Z0-9]+?[\.\)] ( ){2,700}/ )
711716
) {
712717
return true;
713718
}
@@ -725,7 +730,7 @@
725730
* @member CKEDITOR.plugins.pastefromword.lists
726731
*/
727732
convertToFakeListItem: function( editor, element ) {
728-
if ( Heuristics.isEdgeListItem( editor, element ) ) {
733+
if ( Heuristics.isDegenerateListItem( editor, element ) ) {
729734
Heuristics.assignListLevels( editor, element );
730735
}
731736

@@ -1700,6 +1705,22 @@
17001705
return false;
17011706
}
17021707

1708+
return Heuristics.isDegenerateListItem( editor, item );
1709+
},
1710+
1711+
/**
1712+
* Check whether an element is a degenerate list item.
1713+
*
1714+
* Degenerate list items are elements that have some styles specific to list items,
1715+
* but lack the ones that could be used to determine their features(like list level etc.).
1716+
*
1717+
* @param {CKEDITOR.editor} item
1718+
* @param {CKEDITOR.htmlParser.element} item
1719+
* @return {Boolean}
1720+
* @member CKEDITOR.plugins.pastefromword.heuristics
1721+
* @private
1722+
* */
1723+
isDegenerateListItem: function( editor, item ) {
17031724
return !!item.attributes[ 'cke-list-level' ] || ( item.attributes.style && !item.attributes.style.match( /mso\-list/ ) && !!item.find( function( child ) {
17041725
// In rare cases there's no indication that a heading is a list item other than
17051726
// the fact that it has a child element containing only a list symbol.
@@ -1749,7 +1770,7 @@
17491770
array = CKEDITOR.tools.array,
17501771
map = array.map;
17511772

1752-
while ( item.next && item.next.attributes && !item.next.attributes[ 'cke-list-level' ] && Heuristics.isEdgeListItem( editor, item.next ) ) {
1773+
while ( item.next && item.next.attributes && !item.next.attributes[ 'cke-list-level' ] && Heuristics.isDegenerateListItem( editor, item.next ) ) {
17531774
item = item.next;
17541775
indents.push( List.getElementIndentation( item ) );
17551776
items.push( item );
Lines changed: 45 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,55 @@
1-
<p style="margin:0px 0px 0px 48px">
2-
<span style="margin:0px">
3-
<span style="margin:0px">
4-
<font color="#000000">
5-
<font face="calibri">
6-
<font size="3">1.</font>
7-
</font>
8-
</font>
9-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
10-
<span style="font-size-adjust:none">
11-
<span style="font-stretch:normal">
12-
<font color="#000000"> </font>
13-
</span>
14-
</span>
15-
</span>
16-
</span>
17-
</span>
18-
<font color="#000000">
19-
<font face="calibri">
20-
<font size="3">this</font>
21-
</font>
22-
</font>
23-
</p>
24-
<p style="margin:0px 0px 0px 48px">
25-
<span style="margin:0px">
26-
<span style="margin:0px">
27-
<font color="#000000">
28-
<font face="calibri">
29-
<font size="3">2.</font>
30-
</font>
1+
<ol>
2+
<li style="margin:0px 0px 0px 48px">
3+
<font color="#000000">
4+
<font face="calibri">
5+
<font size="3">this</font>
316
</font>
32-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
33-
<span style="font-size-adjust:none">
34-
<span style="font-stretch:normal">
35-
<font color="#000000"> </font>
36-
</span>
37-
</span>
38-
</span>
39-
</span>
40-
</span>
41-
<font color="#000000">
42-
<font face="calibri">
43-
<font size="3">is</font>
447
</font>
45-
</font>
46-
</p>
47-
<p style="margin:0px 0px 0px 48px">
48-
<span style="margin:0px">
49-
<span style="margin:0px">
50-
<font color="#000000">
51-
<font face="calibri">
52-
<font size="3">3.</font>
53-
</font>
8+
</li>
9+
<li style="margin:0px 0px 0px 48px">
10+
<font color="#000000">
11+
<font face="calibri">
12+
<font size="3">is</font>
5413
</font>
55-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
56-
<span style="font-size-adjust:none">
57-
<span style="font-stretch:normal">
58-
<font color="#000000"> </font>
59-
</span>
60-
</span>
61-
</span>
62-
</span>
63-
</span>
64-
<font color="#000000">
65-
<font face="calibri">
66-
<font size="3">a</font>
6714
</font>
68-
</font>
69-
</p>
70-
<p style="margin:0px 0px 0px 96px">
71-
<span style="margin:0px">
72-
<span style="margin:0px">
73-
<font color="#000000">
74-
<font face="calibri">
75-
<font size="3">a.</font>
76-
</font>
15+
</li>
16+
<li style="margin:0px 0px 0px 48px">
17+
<font color="#000000">
18+
<font face="calibri">
19+
<font size="3">a</font>
7720
</font>
78-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
79-
<span style="font-size-adjust:none">
80-
<span style="font-stretch:normal">
81-
<font color="#000000"> </font>
82-
</span>
83-
</span>
84-
</span>
85-
</span>
86-
</span>
87-
<font color="#000000">
88-
<font face="calibri">
89-
<font size="3">multi</font>
9021
</font>
91-
</font>
92-
</p>
93-
<p style="margin:0px 0px 0px 144px">
94-
<span style="margin:0px">
95-
<span style="margin:0px">
96-
<font color="#000000">
97-
<font face="calibri">
98-
<font size="3">i.</font>
22+
<ol style="list-style-type:lower-alpha">
23+
<li style="margin:0px 0px 0px 96px">
24+
<font color="#000000">
25+
<font face="calibri">
26+
<font size="3">multi</font>
27+
</font>
9928
</font>
100-
</font>
101-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
102-
<span style="font-size-adjust:none">
103-
<span style="font-stretch:normal">
104-
<font color="#000000"> </font>
105-
</span>
106-
</span>
107-
</span>
108-
</span>
109-
</span>
110-
<font color="#000000">
111-
<font face="calibri">
112-
<font size="3">level</font>
113-
</font>
114-
</font>
115-
</p>
116-
<p style="margin:0px 0px 0px 96px">
117-
<span style="margin:0px">
118-
<span style="margin:0px">
119-
<font color="#000000">
120-
<font face="calibri">
121-
<font size="3">b.</font>
122-
</font>
123-
</font>
124-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
125-
<span style="font-size-adjust:none">
126-
<span style="font-stretch:normal">
127-
<font color="#000000"> </font>
128-
</span>
129-
</span>
130-
</span>
131-
</span>
132-
</span>
133-
<font color="#000000">
134-
<font face="calibri">
135-
<font size="3">ordered</font>
136-
</font>
137-
</font>
138-
</p>
139-
<p style="margin:0px 0px 11px 48px">
140-
<span style="margin:0px">
141-
<span style="margin:0px">
142-
<font color="#000000">
143-
<font face="calibri">
144-
<font size="3">4.</font>
29+
<ol style="list-style-type:lower-roman">
30+
<li style="margin:0px 0px 0px 144px">
31+
<font color="#000000">
32+
<font face="calibri">
33+
<font size="3">level</font>
34+
</font>
35+
</font>
36+
</li>
37+
</ol>
38+
</li>
39+
<li style="margin:0px 0px 0px 96px">
40+
<font color="#000000">
41+
<font face="calibri">
42+
<font size="3">ordered</font>
43+
</font>
14544
</font>
45+
</li>
46+
</ol>
47+
</li>
48+
<li style="margin:0px 0px 11px 48px">
49+
<font color="#000000">
50+
<font face="calibri">
51+
<font size="3">list</font>
14652
</font>
147-
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
148-
<span style="font-size-adjust:none">
149-
<span style="font-stretch:normal">
150-
<font color="#000000"> </font>
151-
</span>
152-
</span>
153-
</span>
154-
</span>
155-
</span>
156-
<font color="#000000">
157-
<font face="calibri">
158-
<font size="3">list</font>
15953
</font>
160-
</font>
161-
</p>
54+
</li>
55+
</ol>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>bla bla bla ..this is a paragraph with some text. not sure why this becomes a list in ckeditor. the first word of this paragraph also disappears. this content is edited in microsoft outlook. losing text is a difficult problem to repro. this is a difficult bug to repro but i am doing my best to author some text which would help in reproducing this issue. some text here�some text here . bla bla bla�. why am i not losing text here. this is something we need to fix, because it is affecting the users. this is a dummy text, dummy text, dummy text. thank you for your help to fix this bug!</p>
2+
<p></p>
3+
<p>going to lose first word here as well. bla bla bla. add some text here� some text here� some text here. sometimes all the list items show 1, 1 and 1. adding more words here.</p>
4+
<p></p>
5+
<p></p>
6+
<p></p>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
3+
4+
<p class="MsoNormal">Bla bla bla ..This is a paragraph with some text.<span style="mso-spacerun:yes">&nbsp; </span>Not sure why this becomes a list in Ckeditor.
5+
The first word of this paragraph also disappears. This content is edited in
6+
Microsoft Outlook. Losing text is a difficult problem to repro.&nbsp;This is a
7+
difficult bug to repro but I am doing my best to author some text which would
8+
help in reproducing this issue.&nbsp;&nbsp;Some text here…some text here
9+
.&nbsp; Bla bla bla…. Why am I not losing text here.&nbsp; This is something we
10+
need to fix, because it is affecting the users. &nbsp;This is a dummy text,
11+
dummy text, dummy text.&nbsp;&nbsp; Thank you for your help to fix this bug!<o:p></o:p></p>
12+
13+
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
14+
15+
<p class="MsoNormal">Going to lose first word here as well.<span style="mso-spacerun:yes">&nbsp; </span>Bla bla bla.&nbsp;Add some text here… some
16+
text here… some text here.&nbsp;Sometimes all the list items show 1, 1 and
17+
1.&nbsp;&nbsp; Adding more words here.<o:p></o:p></p>
18+
19+
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
20+
21+
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-ascii-theme-font:
22+
minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;
23+
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi"><o:p>&nbsp;</o:p></span></p>
24+
25+
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
26+
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<p style="margin:0in 0in 0pt">
2+
<font face="calibri">
3+
<font size="3">
4+
<font color="#000000">bla bla bla ..this is a paragraph with some text. </font>
5+
</font>
6+
<font color="#000000">
7+
<font size="3">not sure why this becomes a list in ckeditor. the first word of this paragraph also disappears. this content is edited in microsoft outlook. losing text is a difficult problem to repro. this is a difficult bug to repro but i am doing my best to author some text which would help in reproducing this issue. some text here…some text here . bla bla bla…. why am i not losing text here. this is something we need to fix, because it is affecting the users. this is a dummy text, dummy text, dummy text. thank you for your help to fix this bug!</font>
8+
</font>
9+
</font>
10+
</p>
11+
<p style="margin:0in 0in 0pt"></p>
12+
<p style="margin:0in 0in 0pt">
13+
<font face="calibri">
14+
<font size="3">
15+
<font color="#000000">going to lose first word here as well. </font>
16+
</font>
17+
<font color="#000000">
18+
<font size="3">bla bla bla. add some text here… some text here… some text here. sometimes all the list items show 1, 1 and 1. adding more words here.</font>
19+
</font>
20+
</font>
21+
</p>
22+
<p style="margin:0in 0in 0pt"></p>
23+
<p style="margin:0in 0in 0pt"></p>
24+
<p style="margin:0in 0in 0pt"></p>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<p style="margin:0in 0in 0pt">
2+
<font size="3">
3+
<font color="#000000">bla bla bla ..this is a paragraph with some text. not sure why this becomes a list in ckeditor. the first word of this paragraph also disappears. this content is edited in microsoft outlook. losing text is a difficult problem to repro. this is a difficult bug to repro but i am doing my best to author some text which would help in reproducing this issue. some text here�some text here . bla bla bla�. why am i not losing text here. this is something we need to fix, because it is affecting the users. this is a dummy text, dummy text, dummy text. thank you for your help to fix this bug!</font>
4+
</font>
5+
</p>
6+
<p style="margin:0in 0in 0pt"></p>
7+
<p style="margin:0in 0in 0pt">
8+
<font size="3">
9+
<font color="#000000">going to lose first word here as well. bla bla bla. add some text here� some text here� some text here. sometimes all the list items show 1, 1 and 1. adding more words here.</font>
10+
</font>
11+
</p>
12+
<p style="margin:0in 0in 0pt"></p>
13+
<p style="margin:0in 0in 0pt"></p>
14+
<p style="margin:0in 0in 0pt"></p>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
4+
<p class="MsoNormal">Bla bla bla ..This is a paragraph with some text.<span style="mso-spacerun:yes">&nbsp; </span>Not sure why this becomes a list in Ckeditor.
5+
The first word of this paragraph also disappears. This content is edited in
6+
Microsoft Outlook. Losing text is a difficult problem to repro.&nbsp;This is a
7+
difficult bug to repro but I am doing my best to author some text which would
8+
help in reproducing this issue.&nbsp;&nbsp;Some text here…some text here
9+
.&nbsp; Bla bla bla…. Why am I not losing text here.&nbsp; This is something we
10+
need to fix, because it is affecting the users. &nbsp;This is a dummy text,
11+
dummy text, dummy text.&nbsp;&nbsp; Thank you for your help to fix this bug!<o:p></o:p></p>
12+
13+
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
14+
15+
<p class="MsoNormal">Going to lose first word here as well.<span style="mso-spacerun:yes">&nbsp; </span>Bla bla bla.&nbsp;Add some text here… some
16+
text here… some text here.&nbsp;Sometimes all the list items show 1, 1 and
17+
1.&nbsp;&nbsp; Adding more words here.<o:p></o:p></p>
18+
19+
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
20+
21+
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-ascii-theme-font:
22+
minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;
23+
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi"><o:p>&nbsp;</o:p></span></p>
24+
25+
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
26+

0 commit comments

Comments
 (0)