Skip to content

Commit

Permalink
Merge branch 't/11376'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jul 22, 2015
2 parents 894c103 + cd2cf2a commit 9b8ff65
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -21,6 +21,7 @@ Fixed Issues:
* [#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. * [#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.
* [#13143](http://dev.ckeditor.com/ticket/13143): [Edge] Fixed: Focus lost while opening the panel. * [#13143](http://dev.ckeditor.com/ticket/13143): [Edge] Fixed: Focus lost while opening the panel.
* [#13494](http://dev.ckeditor.com/ticket/13494): Fixed: Error thrown in toolbar configurator if plugin requirements are unsatisfied. * [#13494](http://dev.ckeditor.com/ticket/13494): Fixed: Error thrown in toolbar configurator if plugin requirements are unsatisfied.
* [#11376](http://dev.ckeditor.com/ticket/11376): [IE11] Fixed: Loss of text when pasting bullet lists from Microsoft Word.


## CKEditor 4.5.1 ## CKEditor 4.5.1


Expand Down
10 changes: 10 additions & 0 deletions plugins/pastefromword/filter/default.js
Expand Up @@ -337,8 +337,18 @@
var attributes = child.attributes, var attributes = child.attributes,
listItemChildren = child.children, listItemChildren = child.children,
count = listItemChildren.length, count = listItemChildren.length,
first = listItemChildren[ 0 ],
last = listItemChildren[ count - 1 ]; last = listItemChildren[ count - 1 ];


// Converts <li><p style="_MSO_LIST_STYLES_">{...}</p></li> -> <li style="_MSO_LIST_STYLES_">{...}</li>.
// The above format is what we got when pasting from Word 2010 to IE11 and possibly some others.
// Existence of extra <p> tag that can be later recognized as list item (see #getRules.return.elements.p)
// creates incorrect and problematic structures similar to <cke:li><cke:li>{...}</cke:li></cke:li>. (#11376)
if ( first.attributes && first.attributes.style && first.attributes.style.indexOf( 'mso-list' ) > -1 ) {

This comment has been minimized.

Copy link
@andreyskv

andreyskv Jul 27, 2015

Isn't it better to not even have 'mso-list' style set at all, which is done in code, breaks the editor and requires this sort of fixing?

This comment has been minimized.

Copy link
@Reinmar

Reinmar Jul 27, 2015

Author Member

Please see my comment in #199 (comment). I'm not quite sure what you mean and I'm afraid that without code we're talking theory only. MS Word produces so many weird HTMLs for lists that all work must be done based on the tests.

This comment has been minimized.

Copy link
@andreyskv

andreyskv Jul 28, 2015

Nevermind I take it back. I think this fix is actually good because it strips out bad p tags in list items.

child.attributes.style = first.attributes.style;
first.replaceWithChildren();
}

// Move out nested list. // Move out nested list.
if ( last.name in CKEDITOR.dtd.$list ) { if ( last.name in CKEDITOR.dtd.$list ) {
element.add( last, i + 1 ); element.add( last, i + 1 );
Expand Down
16 changes: 15 additions & 1 deletion tests/plugins/pastefromword/pastefromword.html
Expand Up @@ -13,4 +13,18 @@
style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family: style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>item3<o:p></o:p></p> </span></span></span><![endif]>item3<o:p></o:p></p>
</textarea> </textarea>


<!-- Word 2010 / IE 11 !-->
<textarea id="pastedHtmlList2" cols="10" rows="10">
<font color="#000000" face="Times New Roman" size="3">

</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">





</font>
</textarea>
20 changes: 18 additions & 2 deletions tests/plugins/pastefromword/pastefromword.js
Expand Up @@ -198,7 +198,23 @@
}, },
null, true null, true
); );
},

// #11376 - test pasting a list with a Word 2010 / IE11 output.
'test paste list on Word 2010 + IE': function() {
if ( !CKEDITOR.env.ie ) {
assert.ignore();
}

var editor = this.editors.inline;

assertPasteEvent( editor,
{ dataValue: CKEDITOR.document.getById( 'pastedHtmlList2' ).getValue() },
function( data ) {
assert.isInnerHtmlMatching( '<ul><li><strong>hello</strong></li><li><strong>world</strong></li><li><strong>abc</strong></li></ul>', data.dataValue );
},
null, true
);
} }
} ); } );

} )();
} )();

0 comments on commit 9b8ff65

Please sign in to comment.