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

git-svn-id: http://svn.automattic.com/wordpress/trunk@6844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-02-14 05:45:40 +00:00
parent e3b7a9c202
commit 467387c34f
3 changed files with 34 additions and 10 deletions

View File

@@ -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);
},