From 3396375d47033e6041e7183885f827c19a328ca1 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 13 Apr 2014 00:22:56 +0000 Subject: [PATCH] RTL for TinyMCE: - Add _dir: 'rtl' to the TinyMCE translation object. - Fix editor.css for RTL. - Fix the Edit and Delete buttons position for wpview and images. - For _mce_set_direction(), update documentation and fix adding the 'ltr' button. Fixes #27773 git-svn-id: https://develop.svn.wordpress.org/trunk@28094 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-editor.php | 5 +++++ src/wp-includes/css/editor.css | 10 ++++++++++ src/wp-includes/functions.php | 9 +++++---- .../js/tinymce/plugins/wordpress/plugin.js | 1 + .../js/tinymce/plugins/wpeditimage/plugin.js | 12 ++++++++---- .../js/tinymce/skins/wordpress/wp-content.css | 16 ++++++++++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 17e7003fa9..0fe4150542 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -982,6 +982,11 @@ final class _WP_Editors { $baseurl = self::$baseurl; $mce_locale = self::$mce_locale; + // Set direction + if ( is_rtl() ) { + $mce_translation['_dir'] = 'rtl'; + } + /** * Filter translated strings prepared for TinyMCE. * diff --git a/src/wp-includes/css/editor.css b/src/wp-includes/css/editor.css index 0f0f3a40cb..daea468fa9 100644 --- a/src/wp-includes/css/editor.css +++ b/src/wp-includes/css/editor.css @@ -1851,6 +1851,16 @@ i.mce-i-hr:before { font-family: Tahoma, sans-serif; } +/* @noflip */ +.mce-rtl .mce-flow-layout .mce-flow-layout-item > div { + direction: rtl; +} + +/* @noflip */ +.mce-rtl .mce-listbox i.mce-caret { + left: 6px; +} + html:lang(he-il) .rtl .wp-switch-editor, html:lang(he-il) .rtl .quicktags-toolbar input { font-family: Arial, sans-serif; diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 3ac8b13a94..5b8a20457f 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -2457,20 +2457,21 @@ function _config_wp_siteurl( $url = '' ) { * Will only set the direction to 'rtl', if the WordPress locale has the text * direction set to 'rtl'. * - * Fills in the 'directionality', 'plugins', and 'theme_advanced_button1' array - * keys. These keys are then returned in the $input array. + * Fills in the 'directionality' setting, enables the 'directionality' plugin, + * and adds the 'ltr' button to 'toolbar1', formerly 'theme_advanced_buttons1' array + * keys. These keys are then returned in the $input (TinyMCE settings) array. * * @access private * @since 2.1.0 * - * @param array $input MCE plugin array. + * @param array $input MCE settings array. * @return array Direction set for 'rtl', if needed by locale. */ function _mce_set_direction( $input ) { if ( is_rtl() ) { $input['directionality'] = 'rtl'; $input['plugins'] .= ',directionality'; - $input['theme_advanced_buttons1'] .= ',ltr'; + $input['toolbar1'] .= ',ltr'; } return $input; diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index c843dba264..64c5ff1c5a 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -279,6 +279,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( editor.getParam( 'directionality' ) === 'rtl' ) { bodyClass.push('rtl'); + dom.setAttrib( doc.documentElement, 'dir', 'rtl' ); } if ( env.ie ) { diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index a6c350264a..efe221e055 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -403,7 +403,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } function addToolbar( node ) { - var rectangle, toolbarHtml, toolbar, toolbarSize, + var rectangle, toolbarHtml, toolbar, left, dom = editor.dom; removeToolbar(); @@ -425,12 +425,16 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 'contenteditable': false }, toolbarHtml ); - editor.getBody().appendChild( toolbar ); - toolbarSize = dom.getSize( toolbar ); + if ( editor.rtl ) { + left = rectangle.x + rectangle.w - 82; + } else { + left = rectangle.x; + } + editor.getBody().appendChild( toolbar ); dom.setStyles( toolbar, { top: rectangle.y, - left: rectangle.x + left: left }); toolbarActive = true; diff --git a/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css b/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css index b6356ad9dd..b0a5c56a9b 100644 --- a/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css +++ b/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css @@ -453,6 +453,22 @@ img.wp-oembed { outline: 0; } +/* rtl */ +.rtl .gallery .gallery-item { + float: right; +} + +.rtl .wpview-wrap .toolbar { + left: auto; + right: 0; +} + +.rtl .wpview-wrap .toolbar div, +.rtl #wp-image-toolbar div { + margin-left: auto; + margin-right: 7px; +} + @media print, (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25),