Ticket #3933: 3933_2.patch
File 3933_2.patch, 3.1 KB (added by , 14 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
139 139 setTimeout( function(){ editor.resetDirty(); } ); 140 140 } 141 141 142 var isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true ), 143 isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ); 144 145 function isNotEmpty( node ) 146 { 147 return isNotWhitespace( node ) && isNotBookmark( node ); 148 }; 149 150 function isNbsp( node ) 151 { 152 return node.type == CKEDITOR.NODE_TEXT 153 && CKEDITOR.tools.trim( node.getText() ).match( /^(?: |\xa0)$/ ); 154 } 155 142 156 /** 143 157 * Auto-fixing block-less content by wrapping paragraph (#3190), prevent 144 158 * non-exitable-block by padding extra br.(#3189) … … 165 179 fixedBlock = range.fixBlock( true, 166 180 editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); 167 181 168 // For IE, we'll be removing any bogus br ( introduce by fixing body ) 169 // right now to prevent it introducing visual line break. 182 // For IE, we should remove any filler node which was introduced before. 170 183 if ( CKEDITOR.env.ie ) 171 184 { 172 var brNodeList = fixedBlock.getElementsByTag( 'br' ), brNode; 173 for ( var i = 0 ; i < brNodeList.count() ; i++ ) 174 { 175 if( ( brNode = brNodeList.getItem( i ) ) && brNode.hasAttribute( '_cke_bogus' ) ) 176 brNode.remove(); 177 } 178 } 185 var first = fixedBlock.getFirst( isNotEmpty ); 186 isNbsp( first ) && first.remove(); 187 } 179 188 180 189 selection.selectBookmarks( bms ); 181 190 … … 184 193 var children = fixedBlock.getChildren(), 185 194 count = children.count(), 186 195 firstChild, 187 whitespaceGuard = CKEDITOR.dom.walker.whitespaces( true ), 188 previousElement = fixedBlock.getPrevious( whitespaceGuard ), 189 nextElement = fixedBlock.getNext( whitespaceGuard ), 196 previousElement = fixedBlock.getPrevious( isNotWhitespace ), 197 nextElement = fixedBlock.getNext( isNotWhitespace ), 190 198 enterBlock; 191 199 if ( previousElement && previousElement.getName 192 200 && !( previousElement.getName() in nonExitableElementNames ) ) … … 206 214 } 207 215 } 208 216 209 // Inserting the padding-br before body if it's preceded by an 210 // unexitable block. 217 // All browsers are incapable to moving cursor out of certain non-exitable 218 // blocks (e.g. table, list, pre) at the end of document, make this happen by 219 // place a bogus node there, which would be later removed by dataprocessor. 211 220 var lastNode = body.getLast( CKEDITOR.dom.walker.whitespaces( true ) ); 212 221 if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) ) 213 222 { 214 223 restoreDirty( editor ); 215 var paddingBlock = editor.document.createElement(216 ( CKEDITOR.env.ie && enterMode != CKEDITOR.ENTER_BR ) ?217 '<br _cke_bogus="true" />' : 'br' );218 body.append( paddingBlock);224 if( !CKEDITOR.env.ie ) 225 body.appendBogus(); 226 else 227 body.append( editor.document.createText( '\xa0' ) ); 219 228 } 220 229 } 221 230