Skip to content

Commit

Permalink
Merge branch 't/16817' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Feb 3, 2017
2 parents 2d07c87 + 65c5433 commit f8d2136
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 375 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -9,6 +9,7 @@ New Features:

Fixed Issues:

* [#16817](http://dev.ckeditor.com/ticket/16817): Fixed: Paragraph transformed into lists, with corrupted data when pasting from Word.
* [#16833](http://dev.ckeditor.com/ticket/16833): [IE11] Fixed: Malformed list with headers [pasted from Word](http://ckeditor.com/addon/pastefromword).
* [#16826](http://dev.ckeditor.com/ticket/16826): Fixed: Superfluous paragraphs within lists [pasted from Word](http://ckeditor.com/addon/pastefromword) in IE.
* [#16811](http://dev.ckeditor.com/ticket/16811): Fixed: Pasted from Word table alignment not preserved.
Expand Down
35 changes: 28 additions & 7 deletions plugins/pastefromword/filter/default.js
Expand Up @@ -697,17 +697,22 @@
return true;
}

var innerText = '';
element.forEach( function( text ) {
innerText += text.value;
}, CKEDITOR.NODE_TEXT );

/*jshint -W024 */
// Normally a style of the sort that looks like "mso-list: l0 level1 lfo1"
// indicates a list element, but the same style may appear in a <p> that's within a <li>.
if ( ( ( element.attributes.style && element.attributes.style.match( /mso\-list:\s?l\d/ ) ) &&
if ( ( element.attributes.style && element.attributes.style.match( /mso\-list:\s?l\d/ ) &&
element.parent.name !== 'li' ) ||
element.attributes[ 'cke-dissolved' ] ||
element.getHtml().match( /<!\-\-\[if !supportLists]\-\->/ ) ||
// Flat, ordered lists are represented by paragraphs
// who's text content roughly matches /(&nbsp;)*(.*?)(&nbsp;)+/
// where the middle parentheses contain the symbol.
element.getHtml().match( /^( )*.*?[\.\)] ( ){2,700}/ )
// Flat, ordered lists are represented by paragraphs
// who's text content roughly matches /(&nbsp;)*(.*?)(&nbsp;)+/
// where the middle parentheses contain the symbol.
innerText.match( /^( )*\(?[a-zA-Z0-9]+?[\.\)] ( ){2,700}/ )
) {
return true;
}
Expand All @@ -725,7 +730,7 @@
* @member CKEDITOR.plugins.pastefromword.lists
*/
convertToFakeListItem: function( editor, element ) {
if ( Heuristics.isEdgeListItem( editor, element ) ) {
if ( Heuristics.isDegenerateListItem( editor, element ) ) {
Heuristics.assignListLevels( editor, element );
}

Expand Down Expand Up @@ -1700,6 +1705,22 @@
return false;
}

return Heuristics.isDegenerateListItem( editor, item );
},

/**
* Check whether an element is a degenerate list item.
*
* Degenerate list items are elements that have some styles specific to list items,
* but lack the ones that could be used to determine their features(like list level etc.).
*
* @param {CKEDITOR.editor} item
* @param {CKEDITOR.htmlParser.element} item
* @return {Boolean}
* @member CKEDITOR.plugins.pastefromword.heuristics
* @private
* */
isDegenerateListItem: function( editor, item ) {
return !!item.attributes[ 'cke-list-level' ] || ( item.attributes.style && !item.attributes.style.match( /mso\-list/ ) && !!item.find( function( child ) {
// In rare cases there's no indication that a heading is a list item other than
// the fact that it has a child element containing only a list symbol.
Expand Down Expand Up @@ -1749,7 +1770,7 @@
array = CKEDITOR.tools.array,
map = array.map;

while ( item.next && item.next.attributes && !item.next.attributes[ 'cke-list-level' ] && Heuristics.isEdgeListItem( editor, item.next ) ) {
while ( item.next && item.next.attributes && !item.next.attributes[ 'cke-list-level' ] && Heuristics.isDegenerateListItem( editor, item.next ) ) {
item = item.next;
indents.push( List.getElementIndentation( item ) );
items.push( item );
Expand Down
@@ -1,161 +1,55 @@
<p style="margin:0px 0px 0px 48px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">1.</font>
</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">this</font>
</font>
</font>
</p>
<p style="margin:0px 0px 0px 48px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">2.</font>
</font>
<ol>
<li style="margin:0px 0px 0px 48px">
<font color="#000000">
<font face="calibri">
<font size="3">this</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">is</font>
</font>
</font>
</p>
<p style="margin:0px 0px 0px 48px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">3.</font>
</font>
</li>
<li style="margin:0px 0px 0px 48px">
<font color="#000000">
<font face="calibri">
<font size="3">is</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">a</font>
</font>
</font>
</p>
<p style="margin:0px 0px 0px 96px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">a.</font>
</font>
</li>
<li style="margin:0px 0px 0px 48px">
<font color="#000000">
<font face="calibri">
<font size="3">a</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">multi</font>
</font>
</font>
</p>
<p style="margin:0px 0px 0px 144px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">i.</font>
<ol style="list-style-type:lower-alpha">
<li style="margin:0px 0px 0px 96px">
<font color="#000000">
<font face="calibri">
<font size="3">multi</font>
</font>
</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">level</font>
</font>
</font>
</p>
<p style="margin:0px 0px 0px 96px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">b.</font>
</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">ordered</font>
</font>
</font>
</p>
<p style="margin:0px 0px 11px 48px">
<span style="margin:0px">
<span style="margin:0px">
<font color="#000000">
<font face="calibri">
<font size="3">4.</font>
<ol style="list-style-type:lower-roman">
<li style="margin:0px 0px 0px 144px">
<font color="#000000">
<font face="calibri">
<font size="3">level</font>
</font>
</font>
</li>
</ol>
</li>
<li style="margin:0px 0px 0px 96px">
<font color="#000000">
<font face="calibri">
<font size="3">ordered</font>
</font>
</font>
</li>
</ol>
</li>
<li style="margin:0px 0px 11px 48px">
<font color="#000000">
<font face="calibri">
<font size="3">list</font>
</font>
<span style="font:7pt &quot;times new roman&quot;; margin:0px">
<span style="font-size-adjust:none">
<span style="font-stretch:normal">
<font color="#000000"> </font>
</span>
</span>
</span>
</span>
</span>
<font color="#000000">
<font face="calibri">
<font size="3">list</font>
</font>
</font>
</p>
</li>
</ol>
@@ -0,0 +1,6 @@
<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>
<p></p>
<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>
<p></p>
<p></p>
<p></p>
@@ -0,0 +1,27 @@



<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.
The first word of this paragraph also disappears. This content is edited in
Microsoft Outlook. Losing text is a difficult problem to repro.&nbsp;This is a
difficult bug to repro but I am doing my best to author some text which would
help in reproducing this issue.&nbsp;&nbsp;Some text here…some text here
.&nbsp; Bla bla bla…. Why am I not losing text here.&nbsp; This is something we
need to fix, because it is affecting the users. &nbsp;This is a dummy text,
dummy text, dummy text.&nbsp;&nbsp; Thank you for your help to fix this bug!<o:p></o:p></p>

<p class="MsoNormal">&nbsp;<o:p></o:p></p>

<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
text here… some text here.&nbsp;Sometimes all the list items show 1, 1 and
1.&nbsp;&nbsp; Adding more words here.<o:p></o:p></p>

<p class="MsoNormal">&nbsp;<o:p></o:p></p>

<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-ascii-theme-font:
minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>


@@ -0,0 +1,24 @@
<p style="margin:0in 0in 0pt">
<font face="calibri">
<font size="3">
<font color="#000000">bla bla bla ..this is a paragraph with some text. </font>
</font>
<font color="#000000">
<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>
</font>
</font>
</p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt">
<font face="calibri">
<font size="3">
<font color="#000000">going to lose first word here as well. </font>
</font>
<font color="#000000">
<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>
</font>
</font>
</p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt"></p>
@@ -0,0 +1,14 @@
<p style="margin:0in 0in 0pt">
<font size="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>
</font>
</p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt">
<font size="3">
<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>
</font>
</p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt"></p>
<p style="margin:0in 0in 0pt"></p>
@@ -0,0 +1,26 @@



<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.
The first word of this paragraph also disappears. This content is edited in
Microsoft Outlook. Losing text is a difficult problem to repro.&nbsp;This is a
difficult bug to repro but I am doing my best to author some text which would
help in reproducing this issue.&nbsp;&nbsp;Some text here…some text here
.&nbsp; Bla bla bla…. Why am I not losing text here.&nbsp; This is something we
need to fix, because it is affecting the users. &nbsp;This is a dummy text,
dummy text, dummy text.&nbsp;&nbsp; Thank you for your help to fix this bug!<o:p></o:p></p>

<p class="MsoNormal">&nbsp;<o:p></o:p></p>

<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
text here… some text here.&nbsp;Sometimes all the list items show 1, 1 and
1.&nbsp;&nbsp; Adding more words here.<o:p></o:p></p>

<p class="MsoNormal">&nbsp;<o:p></o:p></p>

<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-ascii-theme-font:
minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi"><o:p>&nbsp;</o:p></span></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

0 comments on commit f8d2136

Please sign in to comment.