Ticket #3256: 3256_2.patch
File 3256_2.patch, 5.2 KB (added by , 14 years ago) |
---|
-
_source/plugins/domiterator/plugin.js
31 31 return next; 32 32 } 33 33 34 /** 35 * Evaluator for skipping bookmark nodes. 36 */ 37 function bookmarkEvaluator( node ) 38 { 39 return !( node && node.is && node.is ( 'span' ) 40 && node.hasAttribute( '_fck_bookmark' ) 41 || !node.is && !bookmarkEvaluator( node.getParent() ) ) 42 } 43 34 44 var iterator = function( range ) 35 45 { 36 46 if ( arguments.length < 1 ) … … 65 75 { 66 76 range = this.range.clone(); 67 77 range.enlarge( this.forceBrBreak ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS ); 78 79 var walker; 80 walker = new CKEDITOR.dom.walker( range ) 81 // Skip bookmark nodes. 82 walker.evaluator = bookmarkEvaluator; 83 this._.nextNode = walker.next(); 68 84 69 var boundary = range.getBoundaryNodes(); 70 this._.nextNode = boundary.startNode; 71 this._.lastNode = boundary.endNode.getNextSourceNode( true ); 85 range = range.clone(); 86 range.collapse(); 87 range.setEndAt( range.document.getBody(), CKEDITOR.POSITION_BEFORE_END ); 88 walker = new CKEDITOR.dom.walker( range ); 89 // Skip bookmark nodes. 90 walker.evaluator = bookmarkEvaluator; 91 this._.lastNode = walker.next(); 92 72 93 // Probably the document end is reached, we need a marker node. 73 94 if ( !this._.lastNode ) 74 95 { … … 73 94 if ( !this._.lastNode ) 74 95 { 75 96 this._.lastNode = range.document.createText( '' ); 76 this._.lastNode.insertAfter( boundary.endNode );97 range.document.getBody().append( this._.lastNode ); 77 98 } 78 99 79 100 // Let's reuse this variable. -
_source/plugins/justify/plugin.js
66 66 justifyCommand.prototype = { 67 67 exec : function( editor ) 68 68 { 69 var selection = editor.getSelection(), 70 range = selection && selection.getRanges()[0]; 71 72 if ( !range ) 69 var selection = editor.getSelection(); 70 if ( !selection ) 73 71 return; 74 72 75 73 var bookmarks = selection.createBookmarks(), 76 cssClassName = this.cssClassName, 77 iterator = range.createIterator(), 78 block; 79 80 while ( ( block = iterator.getNextParagraph() ) ) 81 { 82 block.removeAttribute( 'align' ); 74 ranges = selection.getRanges(); 83 75 84 if ( cssClassName )85 {86 // Remove any of the alignment classes from the className.87 var className = block.$.className =88 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) );89 76 90 // Append the desired class name. 91 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 92 block.addClass( cssClassName ); 93 else if ( !className ) 94 block.removeAttribute( 'class' ); 95 } 96 else 77 var cssClassName = this.cssClassName, 78 iterator, 79 block; 80 for ( var i = ranges.length-1 ; i >= 0 ; i-- ) { 81 iterator = ranges[ i ].createIterator(); 82 while ( ( block = iterator.getNextParagraph() ) ) 97 83 { 98 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 99 block.setStyle( 'text-align', this.value ); 84 block.removeAttribute( 'align' ); 85 86 if ( cssClassName ) 87 { 88 // Remove any of the alignment classes from the className. 89 var className = block.$.className = 90 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) ); 91 92 // Append the desired class name. 93 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 94 block.addClass( cssClassName ); 95 else if ( !className ) 96 block.removeAttribute( 'class' ); 97 } 100 98 else 101 block.removeStyle( 'text-align' ); 99 { 100 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 101 block.setStyle( 'text-align', this.value ); 102 else 103 block.removeStyle( 'text-align' ); 104 } 102 105 } 106 103 107 } 104 108 105 109 editor.focus(); -
_source/plugins/selection/plugin.js
868 868 createBookmarks : function( serializable ) 869 869 { 870 870 var retval = [], 871 ranges = this.getRanges(); 872 for ( var i = 0 ; i < ranges.length ; i++ ) 871 ranges = this.getRanges(), 872 length = ranges.length; 873 for ( var i = length-1 ; i >= 0 ; i-- ) 873 874 retval.push( ranges[i].createBookmark( serializable ) ); 875 876 // Original ranges were mangled after bookmarking. 877 if ( length ) 878 this.reset(); 874 879 return retval; 875 880 }, 876 881 … … 887 892 888 893 selectBookmarks : function( bookmarks ) 889 894 { 890 var ranges = [] ;891 for ( var i = 0 ; i < bookmarks.length ; i++)895 var ranges = [], l = bookmarks.length; 896 for ( var i = l -1 ; i >= 0 ; i-- ) 892 897 { 893 898 var range = new CKEDITOR.dom.range( this.document ); 894 899 range.moveToBookmark( bookmarks[i] );