Ticket #3715: 3715.patch
File 3715.patch, 5.7 KB (added by , 14 years ago) |
---|
-
_source/core/htmlparser/element.js
36 36 37 37 var dtd = CKEDITOR.dtd, 38 38 isBlockLike = !!( dtd.$block[ name ] || dtd.$listItem[ name ] || dtd.$tableContent[ name ] ), 39 isPre = name == 'pre'; 39 40 isEmpty = !!dtd.$empty[ name ]; 40 41 41 42 this.isEmpty = isEmpty; … … 45 46 this._ = 46 47 { 47 48 isBlockLike : isBlockLike, 49 isPre : isPre, 48 50 hasInlineStarted : isEmpty || !isBlockLike 49 51 }; 50 52 }; … … 124 126 if ( !( element = filter.onElement( element ) ) ) 125 127 return; 126 128 127 if ( element.name == writeName ) 129 // Element already get serialized. 130 if ( typeof element == 'string' ) 131 { 132 writer.write(element); 133 return; 134 } 135 else if ( element.name == writeName ) 128 136 break; 129 137 130 138 writeName = element.name; -
_source/core/htmlparser/text.js
19 19 * @type String 20 20 * @example 21 21 */ 22 this.value = value .replace( spacesRegex, ' ' );22 this.value = value; 23 23 24 24 /** @private */ 25 25 this._ = … … 46 46 { 47 47 var text = this.value; 48 48 49 if ( filter && !( text = filter.onText( text ) ) )49 if ( filter && !( text = filter.onText( text, this ) ) ) 50 50 return; 51 52 51 writer.text( text ); 53 52 } 54 53 }; -
_source/core/htmlparser/fragment.js
118 118 } 119 119 120 120 // Rtrim empty spaces on block end boundary. (#3585) 121 if ( element._.isBlockLike ) 121 if ( element._.isBlockLike 122 && !element._.isPre ) 122 123 { 123 124 124 var length = element.children.length, 125 125 lastChild = element.children[ length - 1 ], 126 126 text; -
_source/core/htmlparser/filter.js
57 57 return filterName( name, this._.attributeNames ); 58 58 }, 59 59 60 onText : function( text )60 onText : function( text , node ) 61 61 { 62 62 var textFilter = this._.text; 63 return textFilter ? textFilter.filter( text ) : text;63 return textFilter ? textFilter.filter( text, node ) : text; 64 64 }, 65 65 66 66 onComment : function( commentText ) … … 87 87 if ( ret === false ) 88 88 return null; 89 89 90 // Element might been transformed into text node. 91 if( ret && ret.type == CKEDITOR.NODE_TEXT ) 92 return this.onText( ret.value, ret ); 93 90 94 if ( ret && ret != element ) 91 95 return this.onElement( ret ); 92 96 } … … 212 216 if ( ret === false ) 213 217 return false; 214 218 215 if ( isObject && ret != currentEntry ) 219 // 1. Stop further filtering if current filter has changed the 220 // element. 221 // 2. Make sure we safely return last filtering result. 222 if ( isObject && ret != currentEntry 223 || i == this.length -1 ) 216 224 return ret; 217 225 } 218 226 } -
_source/plugins/htmldataprocessor/plugin.js
56 56 block.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); 57 57 } 58 58 59 /** 60 * Filter function for shrinking consequential spaces into one single white 61 * space in text node. 62 * Note: This behavior is IE's default treatment for all text node within 63 * non-pre, we generalize to all browers to reach consistent result. 64 * @param text 65 */ 66 function compressSpaces( text , node ) 67 { 68 if ( node.parent.name != 'pre' ) 69 return text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); 70 else 71 return text; 72 } 73 59 74 var dtd = CKEDITOR.dtd; 60 75 61 76 // Find out the list of block-like tags that can contain <br>. … … 65 80 if ( ! ( 'br' in dtd[i] ) ) 66 81 delete blockLikeTags[i]; 67 82 } 68 83 // We just avoid filler in <pre> right now. 84 // TODO: Support filler for <pre>, line break is also occupy line height. 85 delete blockLikeTags.pre; 69 86 var defaultDataFilterRules = 70 87 { 71 88 elementNames : … … 82 99 ] 83 100 }; 84 101 102 defaultDataFilterRules.text = compressSpaces; 103 85 104 var defaultDataBlockFilterRules = { elements : {} }; 86 105 87 106 for ( var i in blockLikeTags ) … … 120 139 121 140 elements : 122 141 { 142 br : function( node ) 143 { 144 // Gecko had been replacing all linebreaks into <br>s, which 145 // are required to be restored here. 146 if ( node.parent.name == 'pre' ) 147 { 148 var parent = node.parent; 149 node = new CKEDITOR.htmlParser.text( '\n' ); 150 node.parent = parent; 151 } 152 return node; 153 }, 154 123 155 embed : function( element ) 124 156 { 125 157 var parent = element.parent; … … 169 201 } 170 202 }; 171 203 204 defaultHtmlFilterRules.text = compressSpaces; 172 205 var defaultHtmlBlockFilterRules = { elements : {} }; 173 206 174 207 for ( var i in blockLikeTags ) … … 211 244 CKEDITOR.htmlDataProcessor = function() 212 245 { 213 246 this.writer = new CKEDITOR.htmlWriter(); 247 // Disable indentation on <pre>. 248 this.writer.setRules( 'pre', 249 { 250 indent: false 251 } ); 214 252 this.dataFilter = new CKEDITOR.htmlParser.filter(); 215 253 this.htmlFilter = new CKEDITOR.htmlParser.filter(); 216 254 };