Skip to content

Commit

Permalink
wordcontenthandler: Remove alignment (#1606)
Browse files Browse the repository at this point in the history
SUP-6082
  • Loading branch information
rainerda authored and npomaroli committed May 2, 2018
1 parent 31988ad commit 4de152e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions build/changelog/entries/2018/03/12349.SUP-6082.bugfix
@@ -0,0 +1 @@
wordcontenthandler: Removed alignment when pasting aligned text from Word.
2 changes: 2 additions & 0 deletions src/plugins/common/contenthandler/lib/wordcontenthandler.js
Expand Up @@ -230,6 +230,8 @@ define([
} else if (nodeName === 'a'
&& $node.attr('href') && $node.attr('href').match("^file://")) {
$node.contents().unwrap();
} else if (nodeName === 'p' && $node.attr('align')) {
$node.removeAttr('align');
}
}

Expand Down
19 changes: 16 additions & 3 deletions src/test/unit/wordcontenthandler.html
Expand Up @@ -43,16 +43,19 @@
defaultCommand: 'inserthtml',
label: 'wordcontenthandler',
tests: [ ]
}
},
defaultAttributes = ['class','id']

// now add tests for copy & paste from different sources (from './wordcontenthandler/<name>-[start|expected|value].html' files)
files = [ 'word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7', 'word8', 'word9', 'word10', 'word11', 'word12', 'word13', 'word14', 'word15', 'word16' ];
files = [ 'word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7', 'word8', 'word9', 'word10', 'word11', 'word12', 'word13', 'word14', 'word15', 'word16', 'word17' ];

elements = [ 'div' ];

for ( i=0; i<files.length; i++ ) {
var data_start,
data_expected,
data_value,
data_attributes,
file_expected,
index;

Expand All @@ -78,11 +81,21 @@
data_value = data;
}} );

jQuery.ajax( {url: 'wordcontenthandler/' + file +'-attributes.html', async: false, success: function(data) {
data_attributes = data.split(',');
data_attributes.concat(defaultAttributes);
}} );

if (typeof data_attributes == undefined) {
data_attributes = defaultAttributes;
}

for ( j=0; j<elements.length; j++ ) {
tests.tests.push({
start: '<' + elements[ j ] + '>' + data_start + '</' + elements[ j ] + '>',
execResult: '<' + elements[ j ] + '>' + data_expected + '</' + elements[ j ] + '>',
value: data_value
value: data_value,
attributes: data_attributes
});
}

Expand Down
1 change: 1 addition & 0 deletions src/test/unit/wordcontenthandler/word17-attributes.html
@@ -0,0 +1 @@
align
1 change: 1 addition & 0 deletions src/test/unit/wordcontenthandler/word17-expected.html
@@ -0,0 +1 @@
<p class="">center</p>{}
1 change: 1 addition & 0 deletions src/test/unit/wordcontenthandler/word17-start.html
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions src/test/unit/wordcontenthandler/word17-value.html
@@ -0,0 +1 @@
<p class="MsoNormal" align="center" style="text-align:center"><span lang="DE-AT">center<o:p></o:p></span></p>

0 comments on commit 4de152e

Please sign in to comment.