From 839edd2e27cb612304f5f1df9f4dcf064826227c Mon Sep 17 00:00:00 2001 From: azaozz Date: Wed, 29 Feb 2012 23:06:24 +0000 Subject: [PATCH] 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 --- .../plugins/wordpress/editor_plugin_src.js | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js index dcd6f149c8..40d978ff48 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js @@ -63,7 +63,7 @@ setUserSetting('hidetb', '0'); } }); - + ed.addCommand('WP_Medialib', function() { var id = ed.getParam('wp_fullscreen_editor_id') || ed.getParam('fullscreen_editor_id') || ed.id, link = tinymce.DOM.select('#wp-' + id + '-media-buttons a.thickbox'); @@ -144,9 +144,35 @@ } } }); - + 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 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 ed.onBeforeSetContent.add(function(ed, o) { 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, ''); } }); - - if ( bodyClass ) - ed.dom.addClass(ed.getBody(), bodyClass); }); // Word count