Changeset 6148
- Timestamp:
- 12/02/10 02:10:10 (2 years ago)
- Location:
- CKEditor/branches/features/adobeair/_source
- Files:
-
- 3 edited
-
core/dom/document.js (modified) (1 diff)
-
plugins/adobeair/plugin.js (modified) (5 diffs)
-
plugins/wysiwygarea/plugin.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/branches/features/adobeair/_source/core/dom/document.js
r6132 r6148 227 227 228 228 /** 229 * Wrapper for document.write that works around certain security 230 * limitation because of the closed stream when calling this method. 231 * @param html 232 * @param mode 233 */ 234 write : function( html, mode ) 235 { 236 // document.write() or document.writeln() fail silently after 237 // the page load event in Adobe AIR. 238 // DOM manipulation could be used instead. 239 if ( CKEDITOR.env.air && this.getBody() ) 240 { 241 // We're taking the below extra work only because innerHTML 242 // on <html> element doesn't work as expected. 243 var doc = this; 244 245 // Grab all the <link> and <style>. 246 var styleSheetLinks = [], 247 styleTexts = []; 248 249 html.replace( /<style[^>]*>([\s\S]*?)<\/style>/gi, function ( match, styleText ) 250 { 251 styleTexts.push( styleText ); 252 }); 253 254 html.replace( /<link[^>]*?>/gi, function( linkHtml ) 255 { 256 styleSheetLinks.push( linkHtml ); 257 }); 258 259 if ( styleSheetLinks.length ) 260 { 261 // Inject the <head> HTML inside a <div>. 262 // Do that before getDocumentHead because WebKit moves 263 // <link css> elements to the <head> at this point. 264 var div = new CKEDITOR.dom.element( 'div', doc ); 265 div.setHtml( styleSheetLinks.join( '' ) ); 266 // Move the <div> nodes to <head>. 267 div.moveChildren( this.getHead( doc ) ); 268 } 269 270 // Create style nodes for inline css. 271 // ( <style> content doesn't applied when setting via innerHTML ) 272 var count = styleTexts.length; 273 if ( count ) 274 { 275 var head = this.getHead( doc ); 276 for ( var i = 0; i < count; i++ ) 277 { 278 var node = head.append( 'style' ); 279 node.setAttribute( "type", "text/css" ); 280 node.append( doc.createText( styleTexts[ i ] ) ); 281 } 282 } 283 284 // Copy the entire <body>. 285 doc.getBody().setAttributes( CKEDITOR.htmlParser.fragment.fromHtml( 286 // Separate body content and attributes. 287 html.replace( /(<body[^>]*>)([\s\S]*)(?=<\/body>)/i, 288 function( match, startTag, innerHTML ) 289 { 290 doc.getBody().setHtml( innerHTML ); 291 return startTag; 292 }) 293 ).children[ 0 ].attributes ); 294 } 295 else 296 { 297 this.$.open( "text/html", mode ); 298 // Support for custom document.domain in IE. 299 if ( CKEDITOR.env.isCustomDomain() ) 300 this.$.domain = document.domain; 301 this.$.write( html ); 302 this.$.close(); 303 } 229 * Defines the document contents through document.write. Note that the 230 * previous document contents will be lost (cleaned). 231 * @since 3.5 232 * @param {String} html The HTML defining the document contents. 233 * @example 234 * document.write( 235 * '<html>' + 236 * '<head><title>Sample Doc</title></head>' + 237 * '<body>Document contents created by code</body>' + 238 * '</html>' ); 239 */ 240 write : function( html ) 241 { 242 // Don't leave any history log in IE. (#5657) 243 this.$.open( 'text/html', 'replace' ); 244 245 // Support for custom document.domain in IE. 246 CKEDITOR.env.isCustomDomain() && ( this.$.domain = document.domain ); 247 248 this.$.write( html ); 249 this.$.close(); 304 250 } 305 251 }); -
CKEditor/branches/features/adobeair/_source/plugins/adobeair/plugin.js
r6147 r6148 7 7 { 8 8 var eventNameList = [ 'click', 'keydown', 'mousedown', 'keypress' ]; 9 // any inline event callbacks assigned via innerHTML/outerHTML such as 9 10 // Inline event callbacks assigned via innerHTML/outerHTML, such as 10 11 // onclick/onmouseover, are ignored in AIR. 11 12 // Use DOM2 event listeners to substitue inline handlers instead. … … 16 17 count = children.count(), 17 18 child; 19 18 20 for ( var i = 0; i < count; i++ ) 19 21 { … … 102 104 editor._.air_bootstrap_frame_url = this.path + '/assets/air_boostrap_frame.html?' + editor.name; 103 105 104 105 106 editor.on( 'uiReady', function() 106 107 { … … 111 112 }); 112 113 114 editor.on( 'contentDom', function() 115 { 116 // Hyperlinks are enabled in editable documents in Adobe 117 // AIR. Prevent their click behavior. 118 editor.document.on( 'click', function( ev ) 119 { 120 ev.data.preventDefault( true ); 121 }); 122 }); 113 123 }, 114 124 … … 143 153 }); 144 154 })(); 155 156 CKEDITOR.dom.document.prototype.write = CKEDITOR.tools.override( CKEDITOR.dom.document.prototype.write, 157 function( original_write ) 158 { 159 return function( html, mode ) 160 { 161 // document.write() or document.writeln() fail silently after 162 // the page load event in Adobe AIR. 163 // DOM manipulation could be used instead. 164 if ( this.getBody() ) 165 { 166 // We're taking the below extra work only because innerHTML 167 // on <html> element doesn't work as expected. 168 var doc = this; 169 170 // Grab all the <link> and <style>. 171 var styleSheetLinks = [], 172 styleTexts = []; 173 174 html.replace( /<style[^>]*>([\s\S]*?)<\/style>/gi, function ( match, styleText ) 175 { 176 styleTexts.push( styleText ); 177 }); 178 179 html.replace( /<link[^>]*?>/gi, function( linkHtml ) 180 { 181 styleSheetLinks.push( linkHtml ); 182 }); 183 184 if ( styleSheetLinks.length ) 185 { 186 // Inject the <head> HTML inside a <div>. 187 // Do that before getDocumentHead because WebKit moves 188 // <link css> elements to the <head> at this point. 189 var div = new CKEDITOR.dom.element( 'div', doc ); 190 div.setHtml( styleSheetLinks.join( '' ) ); 191 // Move the <div> nodes to <head>. 192 div.moveChildren( this.getHead( doc ) ); 193 } 194 195 // Create style nodes for inline css. 196 // ( <style> content doesn't applied when setting via innerHTML ) 197 var count = styleTexts.length; 198 if ( count ) 199 { 200 var head = this.getHead( doc ); 201 for ( var i = 0; i < count; i++ ) 202 { 203 var node = head.append( 'style' ); 204 node.setAttribute( "type", "text/css" ); 205 node.append( doc.createText( styleTexts[ i ] ) ); 206 } 207 } 208 209 // Copy the entire <body>. 210 doc.getBody().setAttributes( CKEDITOR.htmlParser.fragment.fromHtml( 211 // Separate body content and attributes. 212 html.replace( /(<body[^>]*>)([\s\S]*)(?=<\/body>)/i, 213 function( match, startTag, innerHTML ) 214 { 215 doc.getBody().setHtml( innerHTML ); 216 return startTag; 217 }) 218 ).children[ 0 ].attributes ); 219 } 220 else 221 original_write.apply( this, arguments ); 222 }; 223 }); -
CKEditor/branches/features/adobeair/_source/plugins/wysiwygarea/plugin.js
r6131 r6148 608 608 } 609 609 610 if ( CKEDITOR.env.air )611 {612 // Hyperlinks is enabled in Adobe AIR wysiwyg mode.613 domDocument.$.addEventListener( 'click', function( ev )614 {615 ev.preventDefault() ;616 ev.stopPropagation() ;617 }, true ) ;618 }619 var focusTarget = ( CKEDITOR.env.ie || CKEDITOR.env.webkit ) ?620 domWindow : domDocument;621 610 // IE standard compliant in editing frame doesn't focus the editor when 622 611 // clicking outside actual content, manually apply the focus. (#1659) … … 974 963 else if ( !CKEDITOR.env.opera && win ) 975 964 { 976 // AIR need a while when focus was switching previouslyfrom a link.965 // AIR needs a while to focus when moving from a link. 977 966 CKEDITOR.env.air ? setTimeout( function () { win.focus(); }, 0 ) : win.focus(); 978 967 editor.selectionChange();
Note: See TracChangeset
for help on using the changeset viewer.
