36 | | |
37 | | this.focus(); |
38 | | |
39 | | var selection = this.getSelection(); |
40 | | if ( checkReadOnly( selection ) ) |
41 | | return; |
42 | | |
43 | | var data = evt.data; |
44 | | this.fire( 'saveSnapshot' ); |
45 | | |
46 | | if ( this.dataProcessor ) |
47 | | data = this.dataProcessor.toHtml( data ); |
48 | | |
49 | | if ( CKEDITOR.env.ie ) |
50 | | { |
51 | | var selIsLocked = selection.isLocked; |
52 | | |
53 | | if ( selIsLocked ) |
54 | | selection.unlock(); |
55 | | |
56 | | var $sel = selection.getNative(); |
57 | | |
58 | | // Delete control selections to avoid IE bugs on pasteHTML. |
59 | | if ( $sel.type == 'Control' ) |
60 | | $sel.clear(); |
61 | | else if ( selection.getType() == CKEDITOR.SELECTION_TEXT ) |
62 | | { |
63 | | // Due to IE bugs on handling contenteditable=false blocks |
64 | | // (#6005), we need to make some checks and eventually |
65 | | // delete the selection first. |
66 | | |
67 | | var range = selection.getRanges()[0], |
68 | | endContainer = range && range.endContainer; |
69 | | |
70 | | if ( endContainer && |
71 | | endContainer.type == CKEDITOR.NODE_ELEMENT && |
72 | | endContainer.getAttribute( 'contenteditable' ) == 'false' && |
73 | | range.checkBoundaryOfElement( endContainer, CKEDITOR.END ) ) |
74 | | { |
75 | | range.setEndAfter( range.endContainer ); |
76 | | range.deleteContents(); |
77 | | } |
78 | | } |
79 | | |
80 | | try |
81 | | { |
82 | | $sel.createRange().pasteHTML( data ); |
83 | | } |
84 | | catch (e) {} |
85 | | |
86 | | if ( selIsLocked ) |
87 | | this.getSelection().lock(); |
88 | | } |
89 | | else |
90 | | this.document.$.execCommand( 'inserthtml', false, data ); |
91 | | |
92 | | // Webkit does not scroll to the cursor position after pasting (#5558) |
93 | | if ( CKEDITOR.env.webkit ) |
94 | | { |
95 | | this.document.$.execCommand( 'inserthtml', false, '<span id="cke_paste_marker" cke_temp="1"></span>' ); |
96 | | var marker = this.document.getById( 'cke_paste_marker' ); |
97 | | marker.scrollIntoView(); |
98 | | marker.remove(); |
99 | | marker = null; |
100 | | } |
101 | | |
102 | | CKEDITOR.tools.setTimeout( function() |
103 | | { |
104 | | this.fire( 'saveSnapshot' ); |
105 | | }, 0, this ); |