Skip to content

Commit

Permalink
Tabletools will now correctly convert td[valign] attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Jan 20, 2017
1 parent 0311c25 commit a25120c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugins/tabletools/plugin.js
Expand Up @@ -662,17 +662,25 @@
addCmd( 'cellProperties', new CKEDITOR.dialogCommand( 'cellProperties', createDef( {
allowedContent: 'td th{width,height,border-color,background-color,white-space,vertical-align,text-align}[colspan,rowspan]',
requiredContent: 'table',
contentTransformations: [
[ {
contentTransformations: [ [ {
element: 'td',
left: function( element ) {
return element.styles.background && element.styles.background.match( /^(#[a-fA-F0-9]{3,6}|rgb\([\d, ]+\)|\w+)$/ );
},
right: function( element ) {
element.styles[ 'background-color' ] = element.styles.background;
}
} ]
]
}, {
element: 'td',
left: function( element ) {
return element.attributes && element.attributes.valign;
},
right: function( element ) {
element.styles[ 'vertical-align' ] = element.attributes.valign;
delete element.attributes.valign;
}
}
] ]
} ) ) );
CKEDITOR.dialog.add( 'cellProperties', this.path + 'dialogs/tableCell.js' );

Expand Down
20 changes: 20 additions & 0 deletions tests/plugins/tabletools/tabletools.html
Expand Up @@ -1450,4 +1450,24 @@
</tr>
</tbody>
</table>
</textarea>

<textarea id="align-conversion">
<table border="1">
<tbody>
<tr>
<td valign="bottom">[aaa]</td>
<td>bbb</td>
</tr>
</tbody>
</table>
=>
<table border="1">
<tbody>
<tr>
<td style="vertical-align: bottom">aaa</td>
<td>bbb</td>
</tr>
</tbody>
</table>
</textarea>
9 changes: 9 additions & 0 deletions tests/plugins/tabletools/tabletools.js
Expand Up @@ -181,6 +181,15 @@
// (#10308)
'test remove trailing cell': function() {
this.doTest( 'delete-cell-trailing', 'cellDelete' );
},

'test valign conversion': function() {
var bot = this.editorBot;

bender.tools.testInputOut( 'align-conversion', function( source, expected ) {
bot.setHtmlWithSelection( source );
assert.beautified.html( expected, bot.getData( true ) );
} );
}
} );
} )();

0 comments on commit a25120c

Please sign in to comment.