Ticket #6099: 6099_5.patch
File 6099_5.patch, 2.6 KB (added by , 14 years ago) |
---|
-
_source/plugins/bidi/plugin.js
9 9 var directSelectionGuardElements = {}; 10 10 CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } ); 11 11 12 function onSelectionChange( evt )12 function setToolbarStates( evt ) 13 13 { 14 14 var editor = evt.editor, 15 15 path = evt.data.path; … … 18 18 19 19 useComputedState = useComputedState === undefined || useComputedState; 20 20 21 if ( useComputedState ) 21 // We can use computedState provided by the browser or traverse parents manually. 22 if ( !useComputedState ) 22 23 { 23 var selection = editor.getSelection(), 24 ranges = selection.getRanges(); 24 selectedElement = path.elements[ 0 ]; 25 25 26 selectedElement = ranges && ranges[ 0 ].getEnclosedNode(); 27 28 // If this is not our element of interest, apply to fully selected elements from guardElements. 29 if ( !selectedElement || selectedElement 30 && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements ) 31 ) 32 selectedElement = getFullySelected( selection, guardElements ); 33 } 26 while ( !( selectedElement.getName() in directSelectionGuardElements || selectedElement.is( 'body' ) ) ) 27 { 28 var parent = selectedElement.getParent(); 29 if ( !parent ) 30 break; 31 32 selectedElement = parent; 33 } 34 } 34 35 35 36 selectedElement = selectedElement || path.block || path.blockLimit; 36 37 … … 43 44 44 45 editor.getCommand( 'bidirtl' ).setState( selectionDir == 'rtl' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 45 46 editor.getCommand( 'bidiltr' ).setState( selectionDir == 'ltr' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 47 } 46 48 49 function handleMixedDirContent( evt ) 50 { 47 51 var chromeRoot = editor.container.getChild( 1 ); 48 49 if ( selectionDir != editor.lang.dir ) 52 var node = evt.data.path.elements[ 0 ]; 53 54 if ( node && editor.lang.dir != evt.data.path.elements[ 0 ].getComputedStyle( 'direction' ) ) 50 55 chromeRoot.addClass( 'cke_mixed_dir_content' ); 51 56 else 52 57 chromeRoot.removeClass( 'cke_mixed_dir_content' ); … … 240 245 addButtonCommand( 'BidiLtr', lang.ltr, 'bidiltr', bidiCommand( 'ltr' ) ); 241 246 addButtonCommand( 'BidiRtl', lang.rtl, 'bidirtl', bidiCommand( 'rtl' ) ); 242 247 243 editor.on( 'selectionChange', onSelectionChange ); 248 editor.on( 'selectionChange', function( e ) 249 { 250 setToolbarStates( e ); 251 handleMixedDirContent( e ); 252 }); 244 253 } 245 254 }); 246 255