Ticket #3509: 3509_3.patch
File 3509_3.patch, 4.2 KB (added by , 15 years ago) |
---|
-
_source/plugins/styles/plugin.js
283 283 function applyInlineStyle( range ) 284 284 { 285 285 var document = range.document; 286 287 var wasCollapsed = range.collapsed; 286 288 287 if ( range.collapsed ) 289 // Get next element after range. If it's a Gecko-appended BR, 290 // we want to include it in the range, so that the style will 291 // be maintained in new text added at the end of the line. 292 var nextElement = range.endContainer.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT ); 293 if ( CKEDITOR.env.gecko && nextElement && nextElement.is( 'br' )) 288 294 { 295 if (range.endContainer.type != CKEDITOR.NODE_TEXT || range.endOffset === range.endContainer.getLength() ) 296 range.setEndAfter(nextElement); 297 } 298 299 if ( wasCollapsed ) 300 { 289 301 // Create the element to be inserted in the DOM. 290 302 var collapsedElement = getElement( this, document ); 303 304 // Even though the range was collapsed, it may now contain a single BR. 305 var contents = range.extractContents(); 291 306 292 307 // Insert the empty element into the DOM at the range position. 293 308 range.insertNode( collapsedElement ); 309 contents.appendTo( collapsedElement ); 294 310 295 311 // Place the selection right inside the empty element. 296 range.moveToPosition( collapsedElement, CKEDITOR.POSITION_ BEFORE_END);312 range.moveToPosition( collapsedElement, CKEDITOR.POSITION_AFTER_START ); 297 313 298 314 return; 299 315 } -
_source/plugins/enterkey/plugin.js
139 139 if ( !newBlock ) 140 140 newBlock = doc.createElement( blockTag ); 141 141 142 // We need to insert the bogus element inside all of the inline 143 // style elements, so that clicking after the line or pressing end 144 // and typing makes the typed text keep these inline styles. 145 var blockWithBogus = newBlock; 146 142 147 // Recreate the inline elements tree, which was available 143 148 // before hitting enter, so the same styles will be available in 144 149 // the new block. … … 157 162 element = element.clone(); 158 163 newBlock.moveChildren( element ); 159 164 newBlock.append( element ); 165 166 blockWithBogus = element; 160 167 } 161 168 } 162 169 } 163 170 164 171 if ( !CKEDITOR.env.ie ) 165 newBlock.appendBogus();172 blockWithBogus.appendBogus(); 166 173 167 174 range.insertNode( newBlock ); 168 175 -
_source/core/dom/element.js
243 243 lastChild = lastChild.getPrevious(); 244 244 if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) ) 245 245 { 246 this.append( 247 CKEDITOR.env.opera ? 248 this.getDocument().createText('') : 249 this.getDocument().createElement( 'br' ) ); 246 var bogusElement = CKEDITOR.env.opera ? 247 this.getDocument().createText( '' ) : 248 this.getDocument().createElement( 'br' ); 249 this.append( bogusElement ); 250 return bogusElement; 250 251 } 251 252 }, 252 253 -
_source/core/dom/range.js
1299 1299 1300 1300 this.collapse( isStart ); 1301 1301 1302 // If endContainer is at the end of the document, we need to create 1303 // a bogus element so that the range can include the entire endContainer. 1304 // (This isn't necessary otherwise, but doesn't hurt.) 1305 var tempBogus = null; 1306 if ( !CKEDITOR.env.ie ) 1307 tempBogus = this.endContainer.getParent().appendBogus(); 1308 1302 1309 this.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS ); 1303 1310 1304 1311 this.extractContents().appendTo( fixedBlock ); … … 1307 1314 if ( !CKEDITOR.env.ie ) 1308 1315 fixedBlock.appendBogus(); 1309 1316 1317 if ( tempBogus ) 1318 tempBogus.remove(); 1319 1310 1320 this.insertNode( fixedBlock ); 1311 1321 1312 1322 this.moveToBookmark( bookmark );