Ticket #5910: 5910_4.patch
File 5910_4.patch, 3.8 KB (added by , 14 years ago) |
---|
-
_source/plugins/bidi/plugin.js
42 42 */ 43 43 function switchDir( element, dir, editor ) 44 44 { 45 var dirBefore = element.getComputedStyle( 'direction' ); 46 45 47 if ( element.hasAttribute( 'dir' ) && element.getAttribute( 'dir' ).toLowerCase() == dir ) 46 48 element.removeAttribute( 'dir' ); 47 49 else 48 50 element.setAttribute( 'dir', dir ); 49 51 52 // If the element direction changed, we need to switch the margins of 53 // the element and all its children, so it will get really reflected 54 // like a mirror. (#5910) 55 var dirAfter = element.getComputedStyle( 'direction' ); 56 if ( dirAfter != dirBefore ) 57 { 58 var range = new CKEDITOR.dom.range( element.getDocument() ); 59 range.setStartBefore( element ); 60 range.setEndAfter( element ); 61 62 var walker = new CKEDITOR.dom.walker( range ); 63 64 var node; 65 while ( node = walker.next() ) 66 { 67 if ( node.type == CKEDITOR.NODE_ELEMENT ) 68 { 69 // A child with dir defined is to be ignored. 70 if ( !node.equals( element ) && node.hasAttribute( 'dir' ) ) 71 { 72 range.setStartAfter( node ); 73 walker = new CKEDITOR.dom.walker( range ); 74 continue; 75 } 76 77 // Switch the margins. 78 var marginLeft = node.getStyle( 'margin-right' ), 79 marginRight = node.getStyle( 'margin-left' ); 80 81 marginLeft ? node.setStyle( 'margin-left', marginLeft ) : node.removeStyle( 'margin-left' ); 82 marginRight ? node.setStyle( 'margin-right', marginRight ) : node.removeStyle( 'margin-right' ); 83 } 84 } 85 } 86 50 87 editor.forceNextSelectionCheck(); 51 88 } 52 89 -
_source/plugins/indent/plugin.js
53 53 } 54 54 else 55 55 { 56 var indent = parseInt( firstBlock.getStyle( this.indentCssProperty), 10 );56 var indent = parseInt( firstBlock.getStyle( getIndentCssProperty( firstBlock ) ), 10 ); 57 57 if ( isNaN( indent ) ) 58 58 indent = 0; 59 59 if ( indent <= 0 ) … … 73 73 for ( var i = 0 ; i < editor.config.indentClasses.length ; i++ ) 74 74 this.indentClassMap[ editor.config.indentClasses[i] ] = i + 1; 75 75 } 76 else 77 this.indentCssProperty = editor.config.contentsLangDirection == 'ltr' ? 'margin-left' : 'margin-right'; 76 78 77 this.startDisabled = name == 'outdent'; 79 78 } 80 79 80 // Returns the CSS property to be used for identing a given element. 81 function getIndentCssProperty( element ) 82 { 83 return element.getComputedStyle( 'direction' ) == 'ltr' ? 'margin-left' : 'margin-right'; 84 } 85 81 86 function isListItem( node ) 82 87 { 83 88 return node.type = CKEDITOR.NODE_ELEMENT && node.is( 'li' ); … … 250 255 } 251 256 else 252 257 { 253 var currentOffset = parseInt( element.getStyle( self.indentCssProperty ), 10 ); 258 var indentCssProperty = getIndentCssProperty( element ); 259 var currentOffset = parseInt( element.getStyle( indentCssProperty ), 10 ); 254 260 if ( isNaN( currentOffset ) ) 255 261 currentOffset = 0; 256 262 currentOffset += ( self.name == 'indent' ? 1 : -1 ) * editor.config.indentOffset; … … 260 266 261 267 currentOffset = Math.max( currentOffset, 0 ); 262 268 currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; 263 element.setStyle( self.indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' );269 element.setStyle( indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' ); 264 270 if ( element.getAttribute( 'style' ) === '' ) 265 271 element.removeAttribute( 'style' ); 266 272 }