Ticket #6099: 6099_6.patch
File 6099_6.patch, 2.6 KB (added by , 14 years ago) |
---|
-
_source/plugins/bidi/plugin.js
6 6 (function() 7 7 { 8 8 var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 }, 9 directSelectionGuardElements = {}; 9 directSelectionGuardElements = {}, 10 stateGuardElements = {}; 10 11 CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } ); 12 CKEDITOR.tools.extend( stateGuardElements, directSelectionGuardElements, { td:1 } ); 11 13 12 function onSelectionChange( e vt)14 function onSelectionChange( e ) 13 15 { 16 setToolbarStates( e ); 17 handleMixedDirContent( e ); 18 } 19 20 function setToolbarStates( evt ) 21 { 14 22 var editor = evt.editor, 15 23 path = evt.data.path; 16 24 var useComputedState = editor.config.useComputedState, … … 18 26 19 27 useComputedState = useComputedState === undefined || useComputedState; 20 28 21 if ( useComputedState ) 29 // We can use computedState provided by the browser or traverse parents manually. 30 if ( !useComputedState ) 22 31 { 23 var selection = editor.getSelection(), 24 ranges = selection.getRanges(); 32 selectedElement = path.lastElement; 25 33 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 } 34 while ( !( selectedElement.getName() in stateGuardElements || selectedElement.is( 'body' ) ) ) 35 { 36 var parent = selectedElement.getParent(); 37 if ( !parent ) 38 break; 39 40 selectedElement = parent; 41 } 42 } 34 43 35 44 selectedElement = selectedElement || path.block || path.blockLimit; 36 45 … … 43 52 44 53 editor.getCommand( 'bidirtl' ).setState( selectionDir == 'rtl' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 45 54 editor.getCommand( 'bidiltr' ).setState( selectionDir == 'ltr' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 55 } 46 56 57 function handleMixedDirContent( evt ) 58 { 47 59 var chromeRoot = editor.container.getChild( 1 ); 48 49 if ( selectionDir != editor.lang.dir ) 60 var node = evt.data.path.elements[ 0 ]; 61 62 if ( node && editor.lang.dir != evt.data.path.elements[ 0 ].getComputedStyle( 'direction' ) ) 50 63 chromeRoot.addClass( 'cke_mixed_dir_content' ); 51 64 else 52 65 chromeRoot.removeClass( 'cke_mixed_dir_content' );