X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fbidi%2Fplugin.js;h=6c5d8a6f28ca1ac61c69ddd178ba67d58e3fd42c;hp=c91af0a7957be17f96a0eacc903b96c7b697d408;hb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7;hpb=9873d66421922c7aef8be0f5d2ab51e547b19e66 diff --git a/_source/plugins/bidi/plugin.js b/_source/plugins/bidi/plugin.js index c91af0a..6c5d8a6 100644 --- a/_source/plugins/bidi/plugin.js +++ b/_source/plugins/bidi/plugin.js @@ -11,12 +11,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function onSelectionChange( evt ) { - evt.editor.getCommand( 'bidirtl' ).setState( getState( evt.editor, evt.data.path, 'rtl' ) ); - evt.editor.getCommand( 'bidiltr' ).setState( getState( evt.editor, evt.data.path, 'ltr' ) ); - } - - function getState( editor, path, dir ) - { + var editor = evt.editor, + path = evt.data.path; var useComputedState = editor.config.useComputedState, selectedElement; @@ -39,14 +35,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license selectedElement = selectedElement || path.block || path.blockLimit; if ( !selectedElement || selectedElement.getName() == 'body' ) - return CKEDITOR.TRISTATE_OFF; + return; - selectedElement = useComputedState ? + var selectionDir = useComputedState ? selectedElement.getComputedStyle( 'direction' ) : selectedElement.getStyle( 'direction' ) || selectedElement.getAttribute( 'dir' ); - return ( selectedElement == dir ) ? - CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF; + editor.getCommand( 'bidirtl' ).setState( selectionDir == 'rtl' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); + editor.getCommand( 'bidiltr' ).setState( selectionDir == 'ltr' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); + + var chromeRoot = editor.container.getChild( 1 ); + + if ( selectionDir != editor.lang.dir ) + chromeRoot.addClass( 'cke_mixed_dir_content' ); + else + chromeRoot.removeClass( 'cke_mixed_dir_content' ); } function switchDir( element, dir, editor )