auto-add css class when using align on Image. Props azaozz. fixes #5856

git-svn-id: https://develop.svn.wordpress.org/trunk@6844 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-02-14 05:45:40 +00:00
parent 68166b1851
commit 08be3a54a0
3 changed files with 34 additions and 10 deletions
@@ -72,6 +72,24 @@
}
});
// Add class "alignleft" or "alignright" when selecting align for images.
ed.onBeforeExecCommand.add(function( editor, cmd ) {
var node, dir, xdir;
if ( ( cmd.indexOf('Justify') != -1 ) && ( node = editor.selection.getNode() ) ) {
if ( node.nodeName !== 'IMG' ) return;
dir = cmd.substring(7).toLowerCase();
if ( 'JustifyCenter' == cmd || editor.queryCommandState( cmd ) ) {
editor.dom.removeClass( node, "alignleft" );
editor.dom.removeClass( node, "alignright" );
} else {
xdir = ( dir == 'left' ) ? 'right' : 'left';
editor.dom.removeClass( node, "align"+xdir );
editor.dom.addClass( node, "align"+dir );
}
}
});
// Add listeners to handle more break
t._handleMoreBreak(ed, url);
},