Ticket #5910: 5910_3.patch
File 5910_3.patch, 4.4 KB (added by , 14 years ago) |
---|
-
_source/plugins/indent/plugin.js
26 26 var elementPath = evt.data.path, 27 27 list = elementPath && elementPath.contains( listNodeNames ); 28 28 29 var elementDirection = evt.data.element.getComputedStyle( 'direction' ).toLowerCase(); 30 editor._.commands.indent.indentCssProperty = ( elementDirection == 'ltr' ) ? 'margin-left' : 'margin-right'; 31 29 32 if ( list ) 30 33 return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); 31 34 … … 37 40 if ( !firstBlock ) 38 41 return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); 39 42 43 // Fix reference to command property (by redundant copy). 44 this.indentCssProperty = editor._.commands.indent.indentCssProperty; 45 40 46 if ( this.useIndentClasses ) 41 47 { 42 48 var indentClass = firstBlock.$.className.match( this.classNameRegex ), … … 183 189 184 190 function indentBlock( editor, range ) 185 191 { 192 // Fix reference to command property (by redundant copy). 193 this.indentCssProperty = editor._.commands.indent.indentCssProperty; 194 186 195 var iterator = range.createIterator(), 187 196 enterMode = editor.config.enterMode; 188 197 iterator.enforceRealBlocks = true; … … 233 242 if ( currentOffset < 0 ) 234 243 return false; 235 244 236 currentOffset = Math.max( currentOffset, 0 ); 237 currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; 238 element.setStyle( this.indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' ); 239 if ( element.getAttribute( 'style' ) === '' ) 240 element.removeAttribute( 'style' ); 245 currentOffset = Math.max( currentOffset, 0 ); 246 currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; 247 248 // Determine text direction for this element. 249 var editorDir = ( editor.config.contentsLangDirection == 'ui' ) 250 ? editor.lang.dir : editor.config.contentsLangDirection; 251 var dir = element.getComputedStyle( 'direction' ).toLowerCase(); 252 253 var marginDir = ( dir == 'ltr' ) ? 'left' : 'right'; 254 element.setStyle( 'margin-' + marginDir, currentOffset ? currentOffset + editor.config.indentUnit : '' ); 255 256 if ( element.getAttribute( 'style' ) === '' ) 257 element.removeAttribute( 'style' ); 241 258 } 242 259 243 260 return true; 244 261 } 245 262 246 263 function indentCommand( editor, name ) 247 264 { -
_source/plugins/bidi/plugin.js
26 26 && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements ) 27 27 ) 28 28 selectedElement = getFullySelected( selection, guardElements ); 29 29 30 30 selectedElement = selectedElement || path.block || path.blockLimit; 31 31 32 32 if ( !selectedElement || selectedElement.getName() == 'body' ) … … 42 42 */ 43 43 function switchDir( element, dir, editor ) 44 44 { 45 if ( element.hasAttribute( 'dir' ) && element.getAttribute( 'dir' ).toLowerCase() == dir ) 46 element.removeAttribute( 'dir' ); 47 else 48 element.setAttribute( 'dir', dir ); 45 var switchMargin, 46 editorDir = ( editor.config.contentsLangDirection == 'ui' ) 47 ? editor.lang.dir : editor.config.contentsLangDirection; 48 49 if ( element.hasAttribute( 'dir' ) ) 50 { 51 if ( element.getAttribute( 'dir' ).toLowerCase() == dir ) 52 element.removeAttribute( 'dir' ); 53 else 54 element.setAttribute( 'dir', dir ); 55 } 56 else 57 { 58 element.setAttribute( 'dir', dir ); 49 59 60 if ( dir != editorDir ) 61 switchMargin = dir; 62 } 63 50 64 editor.forceNextSelectionCheck(); 51 } 65 66 if ( !switchMargin ) 67 return; 68 69 var selection = new CKEDITOR.dom.selection( editor.document ); 70 selection.selectElement( element ); 71 // Walker searching for guardElements. 72 var walker = new CKEDITOR.dom.walker( selection.getRanges()[ 0 ] ); 73 74 var block; 75 var sourceMargin = ( dir == 'rtl' ) ? 'left' : 'right'; 76 var targetMargin = ( sourceMargin == 'left' ) ? 'right' : 'left'; 77 78 while ( block = walker.next() ) 79 { 80 if ( block.type == CKEDITOR.NODE_ELEMENT && block.getStyle( 'margin-' + sourceMargin ) ) 81 { 82 var val = block.getStyle( 'margin-' + sourceMargin ); 83 block.setStyle( 'margin-' + targetMargin, val ); 84 block.removeStyle( 'margin-' + sourceMargin ); 85 } 86 } 87 } 52 88 53 89 /** 54 90 *