69 | | var htmlToLoad = |
70 | | '<html dir="' + editor.config.contentsLangDirection + '"' + |
71 | | ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' + |
72 | | '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' + |
73 | | '<script id="cke_actscrpt" type="text/javascript">' + |
74 | | 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' + |
75 | | '</script></body>' + |
76 | | '</html>'; |
77 | | |
78 | | var src = |
79 | | CKEDITOR.env.air ? |
80 | | 'javascript:void(0)' : |
81 | | isCustomDomain ? |
82 | | 'javascript:void((function(){' + |
83 | | 'document.open();' + |
84 | | 'document.domain=\'' + document.domain + '\';' + |
85 | | 'document.close();' + |
86 | | '})())"' |
87 | | : |
88 | | ''; |
89 | | |
90 | | var iframe = CKEDITOR.dom.element.createFromHtml( |
91 | | '<iframe' + |
92 | | ' class="cke_pasteframe"' + |
93 | | ' frameborder="0" ' + |
94 | | ' allowTransparency="true"' + |
95 | | ' src="' + src + '"' + |
96 | | ' role="region"' + |
97 | | ' aria-label="' + lang.pasteArea + '"' + |
98 | | ' aria-describedby="' + this.getContentElement( 'general', 'pasteMsg' ).domId + '"' + |
99 | | ' aria-multiple="true"' + |
100 | | '></iframe>' ); |
101 | | |
102 | | iframe.on( 'load', function( e ) |
103 | | { |
104 | | e.removeListener(); |
105 | | |
106 | | var doc = iframe.getFrameDocument(); |
107 | | doc.write( htmlToLoad ); |
108 | | |
109 | | if ( CKEDITOR.env.air ) |
110 | | onPasteFrameLoad.call( this, doc.getWindow().$ ); |
111 | | }, |
112 | | this ); |
113 | | |
114 | | iframe.setCustomData( 'dialog', this ); |
115 | | |
116 | | var field = this.getContentElement( 'general', 'editing_area' ), |
117 | | container = field.getElement(); |
118 | | container.setHtml( '' ); |
119 | | container.append( iframe ); |
120 | | |
121 | | // IE need a redirect on focus to make |
122 | | // the cursor blinking inside iframe. (#5461) |
123 | | if ( CKEDITOR.env.ie ) |
124 | | { |
125 | | var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' ); |
126 | | focusGrabber.on( 'focus', function() |
127 | | { |
128 | | iframe.$.contentWindow.focus(); |
129 | | }); |
130 | | container.append( focusGrabber ); |
131 | | |
132 | | // Override focus handler on field. |
133 | | field.focus = function() |
134 | | { |
135 | | focusGrabber.focus(); |
136 | | this.fire( 'focus' ); |
137 | | }; |
138 | | } |
139 | | |
140 | | field.getInputElement = function(){ return iframe; }; |
141 | | |
142 | | // Force container to scale in IE. |
143 | | if ( CKEDITOR.env.ie ) |
144 | | { |
145 | | container.setStyle( 'display', 'block' ); |
146 | | container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); |
147 | | } |
| 69 | this.setupContent(); |
164 | | var container = this.getContentElement( 'general', 'editing_area' ).getElement(), |
165 | | iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), |
166 | | editor = this.getParentEditor(), |
167 | | body = iframe.getFrameDocument().getBody(), |
168 | | bogus = body.getBogus(), |
169 | | html; |
170 | | bogus && bogus.remove(); |
171 | | // Saving the contents in variable so changes until paste is complete will not take place (#7500) |
172 | | html = body.getHtml(); |
173 | | |
174 | | setTimeout( function(){ |
175 | | editor.fire( 'paste', { 'html' : html } ); |
176 | | }, 0 ); |
177 | | |
| 86 | this.commitContent(); |
| 120 | }, |
| 121 | setup : function() |
| 122 | { |
| 123 | var dialog = this.getDialog(); |
| 124 | var htmlToLoad = |
| 125 | '<html dir="' + editor.config.contentsLangDirection + '"' + |
| 126 | ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' + |
| 127 | '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' + |
| 128 | '<script id="cke_actscrpt" type="text/javascript">' + |
| 129 | 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, dialog ) + ', this );' + |
| 130 | '</script></body>' + |
| 131 | '</html>'; |
| 132 | |
| 133 | var src = |
| 134 | CKEDITOR.env.air ? |
| 135 | 'javascript:void(0)' : |
| 136 | isCustomDomain ? |
| 137 | 'javascript:void((function(){' + |
| 138 | 'document.open();' + |
| 139 | 'document.domain=\'' + document.domain + '\';' + |
| 140 | 'document.close();' + |
| 141 | '})())"' |
| 142 | : |
| 143 | ''; |
| 144 | |
| 145 | var iframe = CKEDITOR.dom.element.createFromHtml( |
| 146 | '<iframe' + |
| 147 | ' class="cke_pasteframe"' + |
| 148 | ' frameborder="0" ' + |
| 149 | ' allowTransparency="true"' + |
| 150 | ' src="' + src + '"' + |
| 151 | ' role="region"' + |
| 152 | ' aria-label="' + lang.pasteArea + '"' + |
| 153 | ' aria-describedby="' + dialog.getContentElement( 'general', 'pasteMsg' ).domId + '"' + |
| 154 | ' aria-multiple="true"' + |
| 155 | '></iframe>' ); |
| 156 | |
| 157 | iframe.on( 'load', function( e ) |
| 158 | { |
| 159 | e.removeListener(); |
| 160 | |
| 161 | var doc = iframe.getFrameDocument(); |
| 162 | doc.write( htmlToLoad ); |
| 163 | |
| 164 | if ( CKEDITOR.env.air ) |
| 165 | onPasteFrameLoad.call( this, doc.getWindow().$ ); |
| 166 | }, dialog ); |
| 167 | |
| 168 | iframe.setCustomData( 'dialog', dialog ); |
| 169 | |
| 170 | var container = this.getElement(); |
| 171 | container.setHtml( '' ); |
| 172 | container.append( iframe ); |
| 173 | |
| 174 | // IE need a redirect on focus to make |
| 175 | // the cursor blinking inside iframe. (#5461) |
| 176 | if ( CKEDITOR.env.ie ) |
| 177 | { |
| 178 | var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' ); |
| 179 | focusGrabber.on( 'focus', function() |
| 180 | { |
| 181 | iframe.$.contentWindow.focus(); |
| 182 | }); |
| 183 | container.append( focusGrabber ); |
| 184 | |
| 185 | // Override focus handler on field. |
| 186 | this.focus = function() |
| 187 | { |
| 188 | focusGrabber.focus(); |
| 189 | this.fire( 'focus' ); |
| 190 | }; |
| 191 | } |
| 192 | |
| 193 | this.getInputElement = function(){ return iframe; }; |
| 194 | |
| 195 | // Force container to scale in IE. |
| 196 | if ( CKEDITOR.env.ie ) |
| 197 | { |
| 198 | container.setStyle( 'display', 'block' ); |
| 199 | container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); |
| 200 | } |
| 201 | }, |
| 202 | commit : function( data ) |
| 203 | { |
| 204 | var container = this.getElement(), |
| 205 | editor = this.getDialog().getParentEditor(), |
| 206 | body = this.getInputElement().getFrameDocument().getBody(), |
| 207 | bogus = body.getBogus(), |
| 208 | html; |
| 209 | bogus && bogus.remove(); |
| 210 | |
| 211 | // Saving the contents so changes until paste is complete will not take place (#7500) |
| 212 | html = body.getHtml(); |
| 213 | |
| 214 | setTimeout( function(){ |
| 215 | editor.fire( 'paste', { 'html' : html } ); |
| 216 | }, 0 ); |