Ticket #7035: 7035.patch
File 7035.patch, 4.9 KB (added by , 12 years ago) |
---|
-
_source/core/dom/element.js
947 947 } 948 948 }, 949 949 950 /** 951 * @param {Boolean} [inlineOnly=true] Allow only inline elements to be merged. 952 */ 950 953 mergeSiblings : ( function() 951 954 { 952 955 function mergeElements( element, sibling, isNext ) … … 986 989 } 987 990 } 988 991 989 return function( )992 return function( inlineOnly ) 990 993 { 991 // Merge empty links and anchors also. (#5567) 992 if ( !( CKEDITOR.dtd.$removeEmpty[ this.getName() ] || this.is( 'a' ) ) ) 994 if ( ! ( inlineOnly === false 995 || CKEDITOR.dtd.$removeEmpty[ this.getName() ] 996 || this.is( 'a' ) ) ) // Merge empty links and anchors also. (#5567) 997 { 993 998 return; 999 } 994 1000 995 1001 mergeElements( this, this.getNext(), true ); 996 1002 mergeElements( this, this.getPrevious() ); -
_source/plugins/wysiwygarea/plugin.js
205 205 206 206 if ( !range.checkReadOnly() ) 207 207 { 208 // Remove the original contents .209 range.deleteContents( );208 // Remove the original contents, merge splitted nodes. 209 range.deleteContents( 1 ); 210 210 211 211 clone = !i && element || element.clone( 1 ); 212 212 -
_source/core/dom/range.js
32 32 // This is a shared function used to delete, extract and clone the range 33 33 // contents. 34 34 // V2 35 var execContentsAction = function( range, action, docFrag )35 var execContentsAction = function( range, action, docFrag, mergeThen ) 36 36 { 37 37 range.optimizeBookmark(); 38 38 … … 247 247 if ( removeStartNode && topEnd.$.parentNode == startNode.$.parentNode ) 248 248 endIndex--; 249 249 250 range.setStart( topEnd.getParent(), endIndex ); 250 // Merge splitted parents. 251 if ( mergeThen ) 252 { 253 var span = CKEDITOR.dom.element.createFromHtml( '<span ' + 254 'data-cke-bookmark="1" style="display:none"> </span>', range.document ); 255 span.insertAfter( topStart ); 256 topStart.mergeSiblings( false ); 257 range.moveToBookmark( { startNode : span } ); 258 } 259 else 260 range.setStart( topEnd.getParent(), endIndex ); 251 261 } 252 262 253 263 // Collapse it to the start. … … 367 377 368 378 /** 369 379 * Deletes the content nodes of the range permanently from the DOM tree. 380 * @param {Boolean} [mergeThen] Merge any splitted elements result in DOM true due to partial selection. 370 381 */ 371 deleteContents : function( )382 deleteContents : function( mergeThen ) 372 383 { 373 384 if ( this.collapsed ) 374 385 return; 375 386 376 this.fixListRange(); 377 execContentsAction( this, 0 ); 387 execContentsAction( this, 0, null, mergeThen ); 378 388 }, 379 389 380 390 /** 381 391 * The content nodes of the range are cloned and added to a document fragment, 382 392 * meanwhile they're removed permanently from the DOM tree. 393 * @param {Boolean} [mergeThen] Merge any splitted elements result in DOM true due to partial selection. 383 394 */ 384 extractContents : function( )395 extractContents : function( mergeThen ) 385 396 { 386 397 var docFrag = new CKEDITOR.dom.documentFragment( this.document ); 387 398 388 399 if ( !this.collapsed ) 389 execContentsAction( this, 1, docFrag );400 execContentsAction( this, 1, docFrag, mergeThen ); 390 401 391 402 return docFrag; 392 403 }, … … 1910 1921 return container ; 1911 1922 1912 1923 return container.getChild( this.endOffset - 1 ) || container ; 1913 }, 1914 1915 // Fix list selection range where entire range is selected from the inner side. 1916 // <ul><li>[...]</li></ul> => [<ul><li>...</li></ul>] 1917 fixListRange : (function() 1918 { 1919 function moveListBoundary( fixEnd ) 1920 { 1921 var listItem, listRoot; 1922 if ( ( listItem = this[ fixEnd ? 'endContainer' : 'startContainer' ].getAscendant( 'li', 1 ) ) 1923 && this.checkBoundaryOfElement( listItem, fixEnd ? CKEDITOR.END : CKEDITOR.START ) 1924 && ( listRoot = listItem.getParent() ) 1925 && ( listItem.equals( listRoot[ fixEnd ? 'getLast' : 'getFirst' ]( CKEDITOR.dom.walker.nodeType( CKEDITOR.NODE_ELEMENT ) ) ) ) 1926 // Make the fix only when both sides are in same situation. 1927 && ( fixEnd || moveListBoundary.call( this, 1 ) ) ) 1928 { 1929 this[ fixEnd ? 'setEndAt' : 'setStartAt' ]( listRoot, fixEnd ? 1930 CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START ); 1931 return true; 1932 } 1933 } 1934 1935 return function() 1936 { 1937 moveListBoundary.call( this ); 1938 }; 1939 })() 1940 }; 1924 } 1925 }; 1941 1926 })(); 1942 1927 1943 1928 CKEDITOR.POSITION_AFTER_START = 1; // <element>^contents</element> "^text"