Skip to content

Commit 9b8ff65

Browse files
committed
Merge branch 't/11376'
2 parents 894c103 + cd2cf2a commit 9b8ff65

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Fixed Issues:
2121
* [#13410](http://dev.ckeditor.com/ticket/13410): Fixed: Error thrown in the [Auto Embed](http://ckeditor.com/addon/autoembed) plugin when undoing right after pasting a link.
2222
* [#13143](http://dev.ckeditor.com/ticket/13143): [Edge] Fixed: Focus lost while opening the panel.
2323
* [#13494](http://dev.ckeditor.com/ticket/13494): Fixed: Error thrown in toolbar configurator if plugin requirements are unsatisfied.
24+
* [#11376](http://dev.ckeditor.com/ticket/11376): [IE11] Fixed: Loss of text when pasting bullet lists from Microsoft Word.
2425

2526
## CKEditor 4.5.1
2627

plugins/pastefromword/filter/default.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,18 @@
337337
var attributes = child.attributes,
338338
listItemChildren = child.children,
339339
count = listItemChildren.length,
340+
first = listItemChildren[ 0 ],
340341
last = listItemChildren[ count - 1 ];
341342

343+
// Converts <li><p style="_MSO_LIST_STYLES_">{...}</p></li> -> <li style="_MSO_LIST_STYLES_">{...}</li>.
344+
// The above format is what we got when pasting from Word 2010 to IE11 and possibly some others.
345+
// Existence of extra <p> tag that can be later recognized as list item (see #getRules.return.elements.p)
346+
// creates incorrect and problematic structures similar to <cke:li><cke:li>{...}</cke:li></cke:li>. (#11376)
347+
if ( first.attributes && first.attributes.style && first.attributes.style.indexOf( 'mso-list' ) > -1 ) {
348+
child.attributes.style = first.attributes.style;
349+
first.replaceWithChildren();
350+
}
351+
342352
// Move out nested list.
343353
if ( last.name in CKEDITOR.dtd.$list ) {
344354
element.add( last, i + 1 );

tests/plugins/pastefromword/pastefromword.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,18 @@
1313
style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
1414
Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1515
</span></span></span><![endif]>item3<o:p></o:p></p>
16-
</textarea>
16+
</textarea>
17+
18+
19+
<!-- Word 2010 / IE 11 !-->
20+
<textarea id="pastedHtmlList2" cols="10" rows="10">
21+
<font color="#000000" face="Times New Roman" size="3">
22+
23+
</font><ul style="list-style-type: disc; direction: ltr;"><li style="font-weight: normal;"><p style="font-weight: normal; margin-top: 0cm; margin-bottom: 0pt; mso-add-space: auto; mso-list: l0 level1 lfo1;"><strong><span lang="DE-CH" style='font-family: "Arial",sans-serif; font-size: 10pt;'>hello</span></strong></p></li><li style='color: rgb(0, 0, 0); font-family: "Arial",sans-serif; font-size: 10pt; font-weight: normal;'><p style='color: rgb(0, 0, 0); font-family: "Helvetica",sans-serif; font-size: 11pt; font-weight: normal; margin-top: 0cm; margin-bottom: 0pt; mso-add-space: auto; mso-list: l0 level1 lfo1;'><strong><span lang="DE-CH" style='font-family: "Arial",sans-serif; font-size: 10pt;'>world</span></strong></p></li><li style='color: rgb(0, 0, 0); font-family: "Arial",sans-serif; font-size: 10pt; font-weight: normal;'><p style='color: rgb(0, 0, 0); font-family: "Helvetica",sans-serif; font-size: 11pt; font-weight: normal; margin-top: 0cm; margin-bottom: 0pt; mso-add-space: auto; mso-list: l0 level1 lfo1;'><strong><span lang="DE-CH" style='font-family: "Arial",sans-serif; font-size: 10pt;'>abc</span></strong></p></li></ul><font color="#000000" face="Times New Roman" size="3">
24+
25+
26+
27+
28+
29+
</font>
30+
</textarea>

tests/plugins/pastefromword/pastefromword.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,23 @@
198198
},
199199
null, true
200200
);
201+
},
202+
203+
// #11376 - test pasting a list with a Word 2010 / IE11 output.
204+
'test paste list on Word 2010 + IE': function() {
205+
if ( !CKEDITOR.env.ie ) {
206+
assert.ignore();
207+
}
208+
209+
var editor = this.editors.inline;
210+
211+
assertPasteEvent( editor,
212+
{ dataValue: CKEDITOR.document.getById( 'pastedHtmlList2' ).getValue() },
213+
function( data ) {
214+
assert.isInnerHtmlMatching( '<ul><li><strong>hello</strong></li><li><strong>world</strong></li><li><strong>abc</strong></li></ul>', data.dataValue );
215+
},
216+
null, true
217+
);
201218
}
202219
} );
203-
204-
} )();
220+
} )();

0 commit comments

Comments
 (0)