Ticket #3707: 3707.patch
File 3707.patch, 4.5 KB (added by , 15 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
22 22 if ( this.mode == 'wysiwyg' ) 23 23 { 24 24 this.focus(); 25 var data = evt.data; 25 26 26 var selection = this.getSelection(),27 data = evt.data;28 29 27 if ( this.dataProcessor ) 30 28 data = this.dataProcessor.toHtml( data ); 31 29 32 if ( CKEDITOR.env.ie ) 30 // Translate html string into a serial of elements insertion. 31 var temp = new CKEDITOR.dom.element( 'body' ); 32 temp.setHtml( data ); 33 var children = temp.getChildren(); 34 while ( children.count() ) 33 35 { 34 var selIsLocked = selection.isLocked; 35 36 if ( selIsLocked ) 37 selection.unlock(); 38 39 var $sel = selection.getNative(); 40 if ( $sel.type == 'Control' ) 41 $sel.clear(); 42 $sel.createRange().pasteHTML( data ); 43 44 if ( selIsLocked ) 45 this.getSelection().lock(); 36 // Mock up the 'insertElement' event. 37 onInsertElement.call( this, { data : children.getItem( 0 ) } ); 46 38 } 47 else48 this.document.$.execCommand( 'inserthtml', false, data );49 39 } 50 40 } 51 41 … … 54 44 if ( this.mode == 'wysiwyg' ) 55 45 { 56 46 this.focus(); 57 this.fire( 'saveSnapshot' );58 59 47 var element = evt.data, 60 elementName = element.getName(), 61 isBlock = CKEDITOR.dtd.$block[ elementName ]; 62 48 elementName = element.getName && element.getName() || '#'; 63 49 var selection = this.getSelection(), 64 50 ranges = selection.getRanges(); 65 51 … … 79 65 80 66 clone = !i && element || element.clone( true ); 81 67 82 // If we're inserting a blockat dtd-violated positoin, split83 // the parent blocks until we reach blockLimit.68 // If we're inserting a node at dtd-violated positoin, split 69 // the parent elements until we find a corrent position. 84 70 var parent, dtd; 85 if ( this.config.enterMode != CKEDITOR.ENTER_BR && isBlock ) 86 while( ( parent = range.getCommonAncestor( false, true ) ) 87 && ( dtd = CKEDITOR.dtd[ parent.getName() ] ) 88 && !( dtd && dtd [ elementName ] ) ) 89 range.splitBlock(); 71 while( ( parent = range.getCommonAncestor( false, true ) ) 72 && ( dtd = CKEDITOR.dtd[ parent.getName() ] ) 73 && !( dtd && dtd [ elementName ] ) ) 74 range.splitBlock(); 90 75 91 76 // Insert the new node. 92 77 range.insertNode( clone ); … … 108 93 if ( selIsLocked ) 109 94 this.getSelection().lock(); 110 95 111 // Save snaps after the whole execution completed.112 // This's a workaround for make DOM modification's happened after113 // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents'114 // call.115 CKEDITOR.tools.setTimeout( function(){116 this.fire( 'saveSnapshot' );117 }, 0, this );118 96 } 119 97 } 120 98 -
_source/plugins/selection/plugin.js
582 582 if ( !sel ) 583 583 return []; 584 584 585 for ( var i = 0 ; i < sel.rangeCount ; i++ ) 585 var count = sel.rangeCount; 586 587 // When a fresh loaded document gain focus, it doesn't contain 588 // any ranges, we force a range at the beginning of document. 589 if ( !count ) 590 sel.addRange( this.document.$.createRange() ); 591 592 for ( var i = 0 ; i < count ; i++ ) 586 593 { 587 594 var nativeRange = sel.getRangeAt( i ); 588 595 var range = new CKEDITOR.dom.range( this.document ); -
_source/core/editor.js
577 577 */ 578 578 insertHtml : function( data ) 579 579 { 580 this.fire( 'saveSnapshot' ); 580 581 this.fire( 'insertHtml', data ); 582 // Save snaps after the whole execution completed. 583 CKEDITOR.tools.setTimeout( function(){ 584 this.fire( 'saveSnapshot' ); 585 }, 0, this ); 581 586 }, 582 587 583 588 /** … … 591 596 */ 592 597 insertElement : function( element ) 593 598 { 599 this.fire( 'saveSnapshot' ); 594 600 this.fire( 'insertElement', element ); 601 // Save snaps after the whole execution completed. 602 CKEDITOR.tools.setTimeout( function(){ 603 this.fire( 'saveSnapshot' ); 604 }, 0, this ); 595 605 }, 596 606 597 607 checkDirty : function()