Ticket #123: 123_3.patch
| File 123_3.patch, 33.6 kB (added by fredck, 10 months ago) |
|---|
-
_whatsnew.html
37 37 <p> 38 38 New Features and Improvements:</p> 39 39 <ul> 40 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/123">#123</a>] Full support 41 for <strong>document.domain</strong> with automatic domain detection.</li> 40 42 <li>JavaScript integration file: 41 43 <ul> 42 44 <li>The new "<strong>FCKeditor.ReplaceAllTextareas</strong>" function is being introduced, … … 52 54 <p> 53 55 Fixed Bugs:</p> 54 56 <ul> 55 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/681">#339</a>] [<a target="_blank" href="http://dev.fckeditor.net/ticket/681">#681</a>] The SpellerPages 57 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/339">#339</a>] [<a 58 target="_blank" href="http://dev.fckeditor.net/ticket/681">#681</a>] The SpellerPages 56 59 spell checker will now completely ignore the presence of HTML tags in the text.</li> 57 60 </ul> 58 61 <p> -
editor/_source/classes/fckeditingarea.js
57 57 58 58 if ( this.Mode == FCK_EDITMODE_WYSIWYG ) 59 59 { 60 // Create the editing area IFRAME. 61 var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ; 62 63 // Firefox will render the tables inside the body in Quirks mode if the 64 // source of the iframe is set to javascript. see #515 65 if ( !FCKBrowserInfo.IsGecko ) 66 oIFrame.src = 'javascript:void(0)' ; 67 68 oIFrame.frameBorder = 0 ; 69 oIFrame.width = oIFrame.height = '100%' ; 60 // For FF, document.domain must be set only when different, otherwhise 61 // we'll strangely have "Permission denied" issues. 62 if ( FCK_IS_CUSTOM_DOMAIN ) 63 html = '<script>document.domain="' + FCK_RUNTIME_DOMAIN + '";</script>' + html ; 70 64 71 // Append the new IFRAME to the target.72 eTargetElement.appendChild( oIFrame ) ;73 74 65 // IE has a bug with the <base> tag... it must have a </base> closer, 75 66 // otherwise the all successive tags will be set as children nodes of the <base>. 76 67 if ( FCKBrowserInfo.IsIE ) … … 105 96 this._BodyHTML = html ; // Invalid HTML input. 106 97 } 107 98 99 // Create the editing area IFRAME. 100 var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ; 101 102 oIFrame.frameBorder = 0 ; 103 oIFrame.width = oIFrame.height = '100%' ; 104 105 if ( FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE ) 106 { 107 window._FCKHtmlToLoad = html ; 108 oIFrame.src = 'javascript:void( (function(){' + 109 'document.open() ;' + 110 'document.domain="' + document.domain + '" ;' + 111 'document.write( window.parent._FCKHtmlToLoad );' + 112 'document.close() ;' + 113 'window.parent._FCKHtmlToLoad = null ;' + 114 '})() )' ; 115 } 116 else if ( !FCKBrowserInfo.IsGecko ) 117 { 118 // Firefox will render the tables inside the body in Quirks mode if the 119 // source of the iframe is set to javascript. see #515 120 oIFrame.src = 'javascript:void(0)' ; 121 } 122 123 // Append the new IFRAME to the target. For IE, it must be done after 124 // setting the "src", to avoid the "secure/unsecure" message under HTTPS. 125 eTargetElement.appendChild( oIFrame ) ; 126 108 127 // Get the window and document objects used to interact with the newly created IFRAME. 109 128 this.Window = oIFrame.contentWindow ; 110 129 … … 112 131 // TODO: This error handler is not being fired. 113 132 // this.Window.onerror = function() { alert( 'Error!' ) ; return true ; } 114 133 115 var oDoc = this.Document = this.Window.document ; 134 if ( !FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ) 135 { 136 var oDoc = this.Window.document ; 116 137 117 oDoc.open() ; 118 oDoc.write( html ) ; 119 oDoc.close() ; 138 oDoc.open() ; 139 oDoc.write( html ) ; 140 oDoc.close() ; 141 } 120 142 121 143 // Firefox 1.0.x is buggy... ohh yes... so let's do it two times and it 122 144 // will magically work. … … 126 148 return ; 127 149 } 128 150 129 this.Window._FCKEditingArea = this ; 151 if ( oIFrame.readyState && oIFrame.readyState != 'completed' ) 152 { 153 var editArea = this ; 154 ( oIFrame.onreadystatechange = function() 155 { 156 if ( oIFrame.readyState == 'complete' ) 157 { 158 oIFrame.onreadystatechange = null ; 159 editArea.Window._FCKEditingArea = editArea ; 160 FCKEditingArea_CompleteStart.call( editArea.Window ) ; 161 } 162 // It happened that IE changed the state to "complete" after the 163 // "if" and before the "onreadystatechange" assignement, making we 164 // lost the event call, so we do a manual call just to be sure. 165 } )() ; 166 } 167 else 168 { 169 this.Window._FCKEditingArea = this ; 130 170 131 // FF 1.0.x is buggy... we must wait a lot to enable editing because 132 // sometimes the content simply disappears, for example when pasting 133 // "bla1!<img src='some_url'>!bla2" in the source and then switching 134 // back to design. 135 if ( FCKBrowserInfo.IsGecko10 ) 136 this.Window.setTimeout( FCKEditingArea_CompleteStart, 500 ) ; 137 else 138 FCKEditingArea_CompleteStart.call( this.Window ) ; 171 // FF 1.0.x is buggy... we must wait a lot to enable editing because 172 // sometimes the content simply disappears, for example when pasting 173 // "bla1!<img src='some_url'>!bla2" in the source and then switching 174 // back to design. 175 if ( FCKBrowserInfo.IsGecko10 ) 176 this.Window.setTimeout( FCKEditingArea_CompleteStart, 500 ) ; 177 else 178 FCKEditingArea_CompleteStart.call( this.Window ) ; 179 } 139 180 } 140 181 else 141 182 { 142 183 var eTextarea = this.Textarea = oTargetDocument.createElement( 'textarea' ) ; 143 184 eTextarea.className = 'SourceField' ; 144 185 eTextarea.dir = 'ltr' ; 145 FCKDomTools.SetElementStyles( eTextarea, 146 { 147 width : '100%', 148 height : '100%', 149 border : 'none', 186 FCKDomTools.SetElementStyles( eTextarea, 187 { 188 width : '100%', 189 height : '100%', 190 border : 'none', 150 191 resize : 'none', 151 192 outline : 'none' 152 193 } ) ; … … 170 211 } 171 212 172 213 var oEditorArea = this._FCKEditingArea ; 173 214 215 // Save this reference to be re-used later. 216 oEditorArea.Document = oEditorArea.Window.document ; 217 174 218 oEditorArea.MakeEditable() ; 175 219 176 220 // Fire the "OnLoad" event. … … 214 258 // Disable the standard table editing features of Firefox. 215 259 oDoc.execCommand( 'enableInlineTableEditing', false, !FCKConfig.DisableFFTableHandles ) ; 216 260 } 217 catch (e) 261 catch (e) 218 262 { 219 263 // In Firefox if the iframe is initially hidden it can't be set to designMode and it raises an exception 220 264 // So we set up a DOM Mutation event Listener on the HTML, as it will raise several events when the document is visible again … … 229 273 function FCKEditingArea_Document_AttributeNodeModified( evt ) 230 274 { 231 275 var editingArea = evt.currentTarget.contentWindow._FCKEditingArea ; 232 276 233 277 // We want to run our function after the events no longer fire, so we can know that it's a stable situation 234 278 if ( editingArea._timer ) 235 279 window.clearTimeout( editingArea._timer ) ; 236 280 237 editingArea._timer = FCKTools.SetTimeout( FCKEditingArea_MakeEditableByMutation, 1000, editingArea ) ; 281 editingArea._timer = FCKTools.SetTimeout( FCKEditingArea_MakeEditableByMutation, 1000, editingArea ) ; 238 282 } 239 283 240 284 // This function ideally should be called after the document is visible, it does clean up of the -
editor/_source/classes/fckpanel.js
34 34 35 35 if ( FCKBrowserInfo.IsIE ) 36 36 { 37 // This is a trick to IE6 (not IE7). The original domain must be set 38 // before creating the popup, so we are able to take a refence to the 39 // document inside of it, and the set the proper domain for it. (#123) 40 if ( FCK_IS_CUSTOM_DOMAIN ) 41 document.domain = FCK_ORIGINAL_DOMAIN ; 42 37 43 // Create the Popup that will hold the panel. 38 44 this._Popup = this._Window.createPopup() ; 39 45 oDocument = this.Document = this._Popup.document ; 40 46 47 // Set the proper domain inside the popup. 48 if ( FCK_IS_CUSTOM_DOMAIN ) 49 document.domain = oDocument.domain = FCK_RUNTIME_DOMAIN ; 50 41 51 FCK.IECleanup.AddItem( this, FCKPanel_Cleanup ) ; 42 52 } 43 53 else -
editor/_source/classes/fckxml_gecko.js
26 26 LoadUrl : function( urlToCall ) 27 27 { 28 28 this.Error = false ; 29 var oFCKXml = this ;30 29 30 var oXml ; 31 31 var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ; 32 oXmlHttp.open( "GET", urlToCall, false ) ;32 oXmlHttp.open( 'GET', urlToCall, false ) ; 33 33 oXmlHttp.send( null ) ; 34 34 35 35 if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) 36 this.DOMDocument= oXmlHttp.responseXML ;36 oXml = oXmlHttp.responseXML ; 37 37 else if ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 ) 38 this.DOMDocument= oXmlHttp.responseXML ;38 oXml = oXmlHttp.responseXML ; 39 39 else 40 this.DOMDocument= null ;40 oXml = null ; 41 41 42 if ( this.DOMDocument == null || this.DOMDocument.firstChild == null )42 if ( oXml ) 43 43 { 44 // Try to access something on it. 45 try 46 { 47 var test = oXml.firstChild ; 48 } 49 catch (e) 50 { 51 // If document.domain has been changed (#123), we'll have a security 52 // error at this point. The workaround here is parsing the responseText: 53 // http://alexander.kirk.at/2006/07/27/firefox-15-xmlhttprequest-reqresponsexml-and-documentdomain/ 54 oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; 55 } 56 } 57 58 if ( !oXml || !oXml.firstChild ) 59 { 44 60 this.Error = true ; 45 if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) ) 46 alert( 'URL requested: "' + urlToCall + '"\r\n' + 47 'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' + 48 'Response text:\r\n' + oXmlHttp.responseText ) ; 49 61 if ( window.confirm( 'Error loading "' + urlToCall + '" (HTTP Status: ' + oXmlHttp.status + ').\r\nDo you want to see the server response dump?' ) ) 62 alert( oXmlHttp.responseText ) ; 50 63 } 64 65 this.DOMDocument = oXml ; 51 66 }, 52 67 53 68 SelectNodes : function( xpath, contextNode ) … … 84 99 else 85 100 return null ; 86 101 } 87 } ; 88 No newline at end of file 102 } ; -
editor/_source/internals/fck.js
558 558 559 559 Preview : function() 560 560 { 561 var iWidth = FCKConfig.ScreenWidth * 0.8 ;562 var iHeight = FCKConfig.ScreenHeight * 0.7 ;563 var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;564 var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;565 566 561 var sHTML ; 567 562 568 563 if ( FCKConfig.FullPage ) … … 586 581 '</body></html>' ; 587 582 } 588 583 589 oWindow.document.write( sHTML ); 590 oWindow.document.close(); 584 var iWidth = FCKConfig.ScreenWidth * 0.8 ; 585 var iHeight = FCKConfig.ScreenHeight * 0.7 ; 586 var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ; 587 588 var sOpenUrl = '' ; 589 if ( FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE) 590 { 591 window._FCKHtmlToLoad = sHTML ; 592 sOpenUrl = 'javascript:void( (function(){' + 593 'document.open() ;' + 594 'document.domain="' + document.domain + '" ;' + 595 'document.write( window.opener._FCKHtmlToLoad );' + 596 'document.close() ;' + 597 'window.opener._FCKHtmlToLoad = null ;' + 598 '})() )' ; 599 } 600 601 var oWindow = window.open( sOpenUrl, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ; 602 603 if ( !FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE) 604 { 605 oWindow.document.write( sHTML ); 606 oWindow.document.close(); 607 } 608 591 609 }, 592 610 593 611 SwitchEditMode : function( noUndo ) … … 1142 1160 } 1143 1161 } 1144 1162 1163 1164 -
editor/_source/internals/fcktools_gecko.js
111 111 { 112 112 case 'XmlHttp' : 113 113 return new XMLHttpRequest() ; 114 114 115 case 'DOMDocument' : 115 return document.implementation.createDocument( '', '', null ) ; 116 // Originaly, we were had the following here: 117 // return document.implementation.createDocument( '', '', null ) ; 118 // 119 // But, when manipulating document.domain (#123), we had 120 // "Permission denied" errors when trying to call methods inside 121 // the returned object. To avoid it, we have to change to the 122 // following, by implementing a "custom" DOM document object, which 123 // includes the methods that are useful for us. 124 125 var domDoc = document.createDocumentFragment() ; 126 127 domDoc.createElement = function( name ) 128 { 129 return document.createElement( name ) ; 130 } 131 132 domDoc.createTextNode = function( text ) 133 { 134 return document.createTextNode( text ) ; 135 } 136 137 domDoc.createAttribute = function( attName ) 138 { 139 return document.createAttribute( attName ) ; 140 } 141 142 domDoc.createComment = function( text ) 143 { 144 return document.createComment( text ) ; 145 } 146 147 return domDoc ; 116 148 } 117 149 return null ; 118 150 } … … 224 256 break ; 225 257 226 258 /* 227 FCKDebug.Output( el.tagName + ":" + "offset=" + el.offsetLeft + "," + el.offsetTop + " " 259 FCKDebug.Output( el.tagName + ":" + "offset=" + el.offsetLeft + "," + el.offsetTop + " " 228 260 + "scroll=" + el.scrollLeft + "," + el.scrollTop ) ; 229 261 */ 230 262 -
editor/_source/internals/fckxhtml.js
43 43 44 44 // Create the XML DOMDocument object. 45 45 this.XML = FCKTools.CreateXmlObject( 'DOMDocument' ) ; 46 46 47 47 // Add a root element that holds all child nodes. 48 48 this.MainNode = this.XML.appendChild( this.XML.createElement( 'xhtml' ) ) ; 49 49 -
editor/_source/internals/fckxhtml_gecko.js
24 24 25 25 FCKXHtml._GetMainXmlString = function() 26 26 { 27 // Create the XMLSerializer. 28 var oSerializer = new XMLSerializer() ; 29 30 // Return the serialized XML as a string. 31 return oSerializer.serializeToString( this.MainNode ) ; 27 return '<xhtml>' + this.MainNode.innerHTML + '</xhtml>' ; 32 28 } 33 29 34 30 FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node ) … … 102 98 103 99 return node ; 104 100 } 105 } 106 No newline at end of file 101 } -
editor/dialog/common/fck_dialog_common.js
19 19 * == END LICENSE == 20 20 * 21 21 * Useful functions used by almost all dialog window pages. 22 * Dialogs should link to this file as the very first script on the page. 22 23 */ 23 24 25 // Automatically detect the correct document.domain (#123). 26 (function() 27 { 28 var d = document.domain ; 29 30 while ( true ) 31 { 32 // Test if we can access a parent property. 33 try 34 { 35 var test = window.parent.document.domain ; 36 break ; 37 } 38 catch( e ) {} 39 40 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 41 d = d.replace( /.*?(?:\.|$)/, '' ) ; 42 43 if ( d.length == 0 ) 44 break ; // It was not able to detect the domain. 45 46 try 47 { 48 document.domain = d ; 49 } 50 catch (e) 51 { 52 break ; 53 } 54 } 55 })() ; 56 24 57 // Gets a element by its Id. Used for shorter coding. 25 58 function GetE( elementId ) 26 59 { -
editor/dialog/fck_colorselector.html
34 34 #btnClear { width: 75px ; height: 22px ; margin-bottom: 6px ; } 35 35 .ColorCell { height: 15px ; width: 15px ; } 36 36 </style> 37 <script src="common/fck_dialog_common.js" type="text/javascript"></script> 37 38 <script type="text/javascript"> 38 39 39 40 var oEditor = window.parent.InnerDialogLoaded() ; … … 135 136 136 137 function Ok() 137 138 { 138 if ( typeof(window.parent. dialogArguments.CustomValue) == 'function' )139 window.parent. dialogArguments.CustomValue( document.getElementById('selcolor').value ) ;139 if ( typeof(window.parent.args.CustomValue) == 'function' ) 140 window.parent.args.CustomValue( document.getElementById('selcolor').value ) ; 140 141 141 142 return true ; 142 143 } -
editor/dialog/fck_flash/fck_flash_preview.html
27 27 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 28 28 <meta name="robots" content="noindex, nofollow"> 29 29 <link href="../common/fck_dialog_common.css" rel="stylesheet" type="text/css" /> 30 <script src="../common/fck_dialog_common.js" type="text/javascript"></script> 30 31 <script language="javascript"> 31 32 32 33 // Sets the Skin CSS -
editor/dialog/fck_image/fck_image_preview.html
29 29 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 30 30 <meta name="robots" content="noindex, nofollow" /> 31 31 <link href="../common/fck_dialog_common.css" rel="stylesheet" type="text/css" /> 32 <script src="../common/fck_dialog_common.js" type="text/javascript"></script> 32 33 <script type="text/javascript"> 33 34 34 35 // Sets the Skin CSS … … 47 48 </script> 48 49 </head> 49 50 <body style="color: #000000; background-color: #ffffff"> 50 <a id="lnkPreview" onclick="return false;" style="cursor: default"> 51 <img id="imgPreview" onload="window.parent.UpdateOriginal();" style="display: none" /></a>Lorem 52 ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. 53 Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. 54 Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis 55 euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce 56 mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. 57 Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque 58 egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, 59 in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut 60 placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy 61 metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, 62 ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris 63 non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas 64 elementum. Nunc imperdiet gravida mauris. 51 <div> 52 <a id="lnkPreview" onclick="return false;" style="cursor: default"> 53 <img id="imgPreview" src="javascript:void(0)" onload="window.parent.UpdateOriginal();" 54 style="display: none" alt="" /></a>Lorem ipsum dolor sit amet, consectetuer adipiscing 55 elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus 56 a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, 57 nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed 58 velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper 59 nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices 60 a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus 61 faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget 62 tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, 63 tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis 64 id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, 65 eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur 66 ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris. 67 </div> 65 68 </body> 66 69 </html> -
editor/dialog/fck_paste.html
28 28 <title></title> 29 29 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 30 30 <meta name="robots" content="noindex, nofollow" /> 31 31 <script src="common/fck_dialog_common.js" type="text/javascript"></script> 32 32 <script type="text/javascript"> 33 33 var oEditor = window.parent.InnerDialogLoaded() ; 34 34 var FCK = oEditor.FCK; 35 35 var FCKTools = oEditor.FCKTools ; 36 36 var FCKConfig = oEditor.FCKConfig ; 37 var FCKBrowserInfo = oEditor.FCKBrowserInfo ; 37 38 38 39 window.onload = function () 39 40 { 40 41 // First of all, translate the dialog box texts 41 42 oEditor.FCKLanguageManager.TranslatePage(document) ; 42 43 43 var sPastingType = window.parent. dialogArguments.CustomValue ;44 var sPastingType = window.parent.args.CustomValue ; 44 45 45 46 if ( sPastingType == 'Word' || sPastingType == 'Security' ) 46 47 { 47 48 if ( sPastingType == 'Security' ) 48 49 document.getElementById( 'xSecurityMsg' ).style.display = '' ; 49 50 50 var oFrame = document.getElementById('frmData') ; 51 oFrame.style.display = '' ; 52 53 // Avoid errors if the pasted content has any script that fails: #389 54 var oDoc = oFrame.contentWindow.document ; 55 oDoc.open() ; 56 oDoc.write('<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>') ; 57 oDoc.close() ; 51 // For document.domain compatibility (#123) we must do all the magic in 52 // the URL for IE. 53 var sFrameUrl = !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ? 54 'javascript:void(0)' : 55 'javascript:void( (function(){' + 56 'document.open() ;' + 57 'document.domain=\'' + docu