Skip to content

Commit

Permalink
Merge branch 't/16593c' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Nov 4, 2016
2 parents fc8bae5 + cd6a5be commit a00236b
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 2 deletions.
21 changes: 21 additions & 0 deletions plugins/pastefromword/filter/default.js
Expand Up @@ -24,6 +24,8 @@

CKEDITOR.cleanWord = function( mswordHtml, editor ) {

var msoListsDetected = Boolean( mswordHtml.match( /mso-list:\s*l\d+\s+level\d+\s+lfo\d+/ ) );

// Sometimes Word malforms the comments.
mswordHtml = mswordHtml.replace( /<!\[/g, '<!--[' ).replace( /\]>/g, ']-->' );

Expand Down Expand Up @@ -151,6 +153,11 @@
createAttributeStack( element, filter );
},
'ul': function( element ) {
if ( !msoListsDetected ) {
// List should only be processed if we're sure we're working with Word. (#16593)
return;
}

// Edge case from 11683 - an unusual way to create a level 2 list.
if ( element.parent.name == 'li' && tools.indexOf( element.parent.children, element ) === 0 ) {
Style.setStyle( element.parent, 'list-style-type', 'none' );
Expand All @@ -160,11 +167,20 @@
return false;
},
'li': function( element ) {
if ( !msoListsDetected ) {
return;
}

element.attributes.style = Style.normalizedStyles( element, editor );

Style.pushStylesLower( element );
},
'ol': function( element ) {
if ( !msoListsDetected ) {
// List should only be processed if we're sure we're working with Word. (#16593)
return;
}

// Fix edge-case where when a list skips a level in IE11, the <ol> element
// is implicitly surrounded by a <li>.
if ( element.parent.name == 'li' && tools.indexOf( element.parent.children, element ) === 0 ) {
Expand Down Expand Up @@ -1172,6 +1188,11 @@
return valueFound + ( elementIndex - valueElementIndex );
},

/**
* @private
* @param {CKEDITOR.htmlParser.element} element
* @member CKEDITOR.plugins.pastefromword.lists
*/
dissolveList: function( element ) {
var i, children = [],
deletedLists = [];
Expand Down
@@ -0,0 +1,13 @@
<h1>Hello world!</h1>
<ol>
<li>
dsa
<ol>
<li>dsa</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com" data-cke-saved-href="http://ckeditor.com">CKEditor</a>.</p>
@@ -0,0 +1,12 @@
<h1>Hello world!</h1>
<ol>
<li>dsa
<ol>
<li>dsa</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a data-cke-saved-href="http://ckeditor.com" href="http://ckeditor.com">CKEditor</a>.</p>
@@ -0,0 +1,19 @@
<h1>
Hello world!
<br>
</h1>
<ol>
<li>dsa
<ol>
<li>dsa</li>
</ol>
</li>
<li>dsa
<br>
</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com/" data-cke-saved-href="http://ckeditor.com">
<font color="#0066cc">CKEditor</font>
</a>.</p>
@@ -0,0 +1,20 @@
<h1>Hello world!
<br>
</h1>
<ol>
<li>
dsa
<ol>
<li>dsa
</li>
</ol>
</li>
<li>dsa
<br>
</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com/" data-cke-saved-href="http://ckeditor.com">
<font color="#0066cc">CKEditor</font>
</a>.</p>
@@ -0,0 +1,17 @@
<h1>Hello world!
<br>
</h1>
<ol>
<li>
dsa
<ol>
<li>dsa
<br>
</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com" data-cke-saved-href="http://ckeditor.com">CKEditor</a>.</p>
@@ -0,0 +1,17 @@
<h1>Hello world!
<br>
</h1>
<ol>
<li>
dsa
<ol>
<li>dsa</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com/" data-cke-saved-href="http://ckeditor.com">
<font color="#0066cc">CKEditor</font>
</a>.</p>
@@ -0,0 +1,16 @@
<h1>Hello world!
<br>
</h1>
<ol>
<li>dsa
<ol>
<li>dsa
<br>
</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a data-cke-saved-href="http://ckeditor.com" href="http://ckeditor.com">CKEditor</a>.</p>
@@ -0,0 +1,17 @@
<h1>Hello world!
<br>
</h1>
<ol>
<li>
dsa
<ol>
<li>dsa</li>
</ol>
</li>
<li>dsa</li>
</ol>

<p>I'm an instance of
<a href="http://ckeditor.com/" data-cke-saved-href="http://ckeditor.com">
<font color="#0066cc">CKEditor</font>
</a>.</p>
6 changes: 4 additions & 2 deletions tests/plugins/pastefromword/generated/tickets5.js
Expand Up @@ -17,11 +17,13 @@
'chrome',
'firefox',
'ie8',
'ie11'
'ie11',
'edge'
],
wordVersion = 'word2013',
ticketTests = {
'14867examples': [ 'word2013' ]
'14867examples': [ 'word2013' ],
'16593regular_paste': [ 'word2013' ]
},
testData = {
_should: {
Expand Down

0 comments on commit a00236b

Please sign in to comment.