Ticket #3136: 3136.patch
File 3136.patch, 2.5 KB (added by , 16 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
36 36 isBlock = CKEDITOR.dtd.$block[ elementName ]; 37 37 38 38 var selection = this.getSelection(), 39 range s = selection.getRanges();39 range = selection.getRanges().pop(); 40 40 41 var range, clone, lastElement, bookmark; 41 // Remove the original contents. 42 range.deleteContents(); 42 43 43 for ( var i = ranges.length - 1 ; i >= 0 ; i-- ) 44 var toSplit; 45 46 // If the new node is a block element, split the current block (if any). 47 if ( this.config.enterMode != 'br' && isBlock ) 44 48 { 45 range = ranges[ i ]; 49 var startPath = new CKEDITOR.dom.elementPath( range.startContainer ), 50 j = 0, 51 parent; 46 52 47 // Remove the original contents. 48 range.deleteContents(); 49 50 clone = element.clone( true ); 51 52 var toSplit; 53 54 // If the new node is a block element, split the current block (if any). 55 if ( this.config.enterMode != 'br' && isBlock ) 53 while( ( parent = startPath.elements[ j++ ] ) && parent != startPath.blockLimit ) 56 54 { 57 var startPath = new CKEDITOR.dom.elementPath( range.startContainer ), 58 j = 0, 59 parent; 55 var parentName = parent.getName(), 56 parentDtd = CKEDITOR.dtd[ parentName ]; 60 57 61 while( ( parent = startPath.elements[ j++ ] ) && parent != startPath.blockLimit ) 62 { 63 var parentName = parent.getName(), 64 parentDtd = CKEDITOR.dtd[ parentName ]; 65 66 if ( parentDtd && !parentDtd[ elementName ] ) 67 toSplit = parent; 68 } 58 if ( parentDtd && !parentDtd[ elementName ] ) 59 toSplit = parent; 69 60 } 61 } 70 62 71 72 range.insertNode( clone);63 // Insert the new node. 64 range.insertNode( element ); 73 65 74 75 clone.breakParent( toSplit );66 if ( toSplit ) 67 element.breakParent( toSplit ); 76 68 77 // Save the last element reference so we can make the 78 // selection later. 79 if ( !lastElement ) 80 lastElement = clone; 81 } 69 range.moveToPosition( element, CKEDITOR.POSITION_AFTER_END ); 82 70 83 range.moveToPosition( lastElement, CKEDITOR.POSITION_AFTER_END ); 84 85 var next = lastElement.getNextSourceNode( true ); 71 var next = element.getNextSourceNode( true ); 86 72 if ( next && next.type == CKEDITOR.NODE_ELEMENT ) 87 73 range.moveToElementEditStart( next ); 88 74