Improve adding more css classes to the editor body, add "rtl", "ie7", "ie8", "ie9" so they can be targeted in editor-style.css, see #19437

git-svn-id: http://svn.automattic.com/wordpress/trunk@20054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-02-29 23:06:24 +00:00
parent 71aa5ca72a
commit 839edd2e27
1 changed files with 29 additions and 11 deletions

View File

@ -146,7 +146,33 @@
}); });
ed.onInit.add(function(ed) { ed.onInit.add(function(ed) {
var bodyClass = ed.getParam('body_class', ''); var bodyClass = ed.getParam('body_class', ''), body = ed.getBody();
// add body classes
if ( bodyClass )
bodyClass = bodyClass.split(' ');
else
bodyClass = [];
if ( ed.getParam('directionality', '') == 'rtl' )
bodyClass.push('rtl');
if ( tinymce.isIE9 )
bodyClass.push('ie9');
else if ( tinymce.isIE8 )
bodyClass.push('ie8');
else if ( tinymce.isIE7 )
bodyClass.push('ie7');
if ( ed.id != 'wp_mce_fullscreen' && ed.id != 'mce_fullscreen' )
bodyClass.push('wp-editor');
else if ( ed.id == 'mce_fullscreen' )
bodyClass.push('mce-fullscreen');
tinymce.each( bodyClass, function(cls){
if ( cls )
ed.dom.addClass(body, cls);
});
// make sure these run last // make sure these run last
ed.onNodeChange.add( function(ed, cm, e) { ed.onNodeChange.add( function(ed, cm, e) {
@ -171,11 +197,6 @@
} }
}); });
if ( ed.id != 'wp_mce_fullscreen' && ed.id != 'mce_fullscreen' )
ed.dom.addClass(ed.getBody(), 'wp-editor');
else if ( ed.id == 'mce_fullscreen' )
ed.dom.addClass(ed.getBody(), 'mce-fullscreen');
// remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back // remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back
ed.onBeforeSetContent.add(function(ed, o) { ed.onBeforeSetContent.add(function(ed, o) {
if ( o.content ) { if ( o.content ) {
@ -183,9 +204,6 @@
o.content = o.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>'); o.content = o.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
} }
}); });
if ( bodyClass )
ed.dom.addClass(ed.getBody(), bodyClass);
}); });
// Word count // Word count