Changeset 244
- Timestamp:
- 2007-04-09 20:12:02 (3 years ago)
- Location:
- FCKeditor/branches/developers/mjk/editor
- Files:
-
- 11 modified
-
dialog/fck_anchor.html (modified) (1 diff)
-
dialog/fck_find.html (modified) (5 diffs)
-
dialog/fck_table.html (modified) (2 diffs)
-
fckdialog.html (modified) (5 diffs)
-
lang/en.js (modified) (1 diff)
-
_source/classes/fckeditingarea.js (modified) (3 diffs)
-
_source/commandclasses/fck_othercommands.js (modified) (2 diffs)
-
_source/internals/fckcommands.js (modified) (1 diff)
-
_source/internals/fck.js (modified) (8 diffs)
-
_source/internals/fcktoolbaritems.js (modified) (2 diffs)
-
_source/internals/fcktoolbarset.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/branches/developers/mjk/editor/dialog/fck_anchor.html
r132 r244 65 65 if ( oAnchor ) 66 66 GetE('txtName').value = oAnchor.name ; 67 else 68 oAnchor = null ; 67 else if (FCK.Selection.GetType() == 'Text') 68 //for text anchors, use the selected text as default anchor name 69 if (FCK.Selection.SelectedText()) 70 GetE('txtName').value = FCK.Selection.SelectedText(); 71 69 72 70 73 window.parent.SetOkButton( true ) ; -
FCKeditor/branches/developers/mjk/editor/dialog/fck_find.html
r132 r244 24 24 <html xmlns="http://www.w3.org/1999/xhtml"> 25 25 <head> 26 <title> </title>26 <title>Find and Replace</title> 27 27 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 28 28 <meta content="noindex, nofollow" name="robots" /> 29 <script src="common/fck_dialog_common.js" type="text/javascript"></script> 30 <link href="common/fck_dialog_common.css" rel="stylesheet" type="text/css" /> 29 31 <script type="text/javascript"> 30 32 31 33 var oEditor = window.parent.InnerDialogLoaded() ; 34 var FCK = oEditor.FCK ; 35 var FCKLang = oEditor.FCKLang ; 36 var FCKConfig = oEditor.FCKConfig ; 37 var strFind = ''; 38 var bFirstFind = true; 39 40 window.parent.AddTab( 'Find', FCKLang.DlgFindTitle) ; 41 window.parent.AddTab( 'Replace', FCKLang.DlgReplaceTitle) ; 42 43 //show the tabs and hide the buttons -- because we draw buttons on the tabs 44 parent.document.getElementById("TabsRow").style.display = ""; 45 parent.document.getElementById("Buttons").style.display = "none"; 46 47 // Function called when a dialog tag is selected. 48 function OnDialogTabChange( tabCode ) 49 { 50 document.getElementById('replace').style.display = (tabCode == 'Find') ? 'none' : ''; 51 document.getElementById('replaceButtons').style.display = (tabCode == 'Find') ? 'none' : ''; 52 //fixme: allow hide/show of regex based on user privs 53 document.getElementById('regex').style.display = (tabCode == 'Replace') ? '' : 'none'; 54 55 } 32 56 33 57 function OnLoad() 34 58 { 35 // Whole word is available on IE only.36 if ( oEditor.FCKBrowserInfo.IsIE )37 document.getElementById('divWord').style.display = '' ;38 39 59 // First of all, translate the dialog box texts. 40 60 oEditor.FCKLanguageManager.TranslatePage( document ) ; 41 61 42 62 window.parent.SetAutoSize( true ) ; 63 if ( document.location.search.substr(1) == 'rep') 64 window.parent.SetSelectedTab('Replace'); 43 65 } 44 66 … … 48 70 ( document.getElementById('txtFind').value.length == 0 ) ; 49 71 } 50 51 function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll ) 52 { 53 for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) 54 { 55 var oNode = parentNode.childNodes[i] ; 56 if ( oNode.nodeType == 3 ) 57 { 58 var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ; 59 if ( oNode.nodeValue != sReplaced ) 60 { 61 oNode.nodeValue = sReplaced ; 62 if ( ! replaceAll ) 63 return true ; 64 } 65 } 66 else 67 { 68 if ( ReplaceTextNodes( oNode, regex, replaceValue ) ) 69 return true ; 70 } 71 } 72 return false ; 73 } 74 75 function GetRegexExpr() 76 { 77 var sExpr ; 78 79 if ( document.getElementById('chkWord').checked ) 80 sExpr = '\\b' + document.getElementById('txtFind').value + '\\b' ; 81 else 82 sExpr = document.getElementById('txtFind').value ; 83 84 return sExpr ; 85 } 86 87 function GetCase() 88 { 89 return ( document.getElementById('chkCase').checked ? '' : 'i' ) ; 90 } 91 92 function Ok() 93 { 94 if ( document.getElementById('txtFind').value.length == 0 ) 95 return ; 96 97 if ( oEditor.FCKBrowserInfo.IsIE ) 98 FindIE() ; 99 else 100 FindGecko() ; 101 } 102 72 function Find(bDB) 73 { 74 //start finding at the top -- IE does this automagically 75 if (bFirstFind) 76 { 77 FCK.Selection.SelectNode(oEditor.FCK.EditorDocument.body); 78 FCK.Selection.Collapse(); 79 } 80 if ( document.getElementById('txtFind').value.length == 0 ) 81 return false; 82 var bOut; 83 if ( oEditor.FCKBrowserInfo.IsIE ) 84 bOut = FindIE(document.getElementById('txtFind').value, 85 document.getElementById('chkCase').checked, 86 document.getElementById('chkWord').checked) ; 87 else 88 bOut = FindGecko(document.getElementById('txtFind').value, 89 document.getElementById('chkCase').checked, 90 document.getElementById('chkWord').checked) ; 91 if (!bOut && bDB) alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ; 92 bFirstFind = false; 93 return bOut; 94 } 95 96 function Replace() //replace -- or if nothing selected, Find Next 97 { 98 if (document.getElementById('chkRegex').checked) 99 return ReplaceAllRegex(); 100 101 if (FCK.Selection.SelectedHTML()) 102 FCK.InsertHtml(filterReplaceText()); 103 Find(true); 104 } 105 106 function ReplaceAll() 107 { 108 if (document.getElementById('chkRegex').checked) 109 return ReplaceAllRegex(); 110 while (Find(false) && FCK.Selection.SelectedHTML()) 111 { 112 FCK.InsertHtml(filterReplaceText()); 113 } 114 } 115 116 function ReplaceAllRegex() 117 { 118 var strXHTML = FCK.GetXHTML(false); 119 strXHTML = strXHTML.replace(new RegExp(document.getElementById('txtFind').value, 120 document.getElementById('chkCase').checked ? 'g' : 'gi'), 121 document.getElementById('txtReplace').value); 122 FCK.SetHTML(strXHTML); 123 } 124 125 function filterReplaceText() 126 { 127 var sHtml = document.getElementById('txtReplace').value; 128 sHtml = sHtml.replace(/&/ig,'&'); 129 sHtml = sHtml.replace(/</ig,'<'); 130 sHtml = sHtml.replace(/>/ig,'>'); 131 return sHtml 132 } 103 133 var oRange ; 104 134 … … 106 136 oRange = oEditor.FCK.EditorDocument.body.createTextRange() ; 107 137 108 function FindIE( )138 function FindIE(strText, bCase, bWord) 109 139 { 110 140 var iFlags = 0 ; 111 141 112 if ( chkCase.checked)142 if (bCase) 113 143 iFlags = iFlags | 4 ; 114 144 115 if ( chkWord.checked)145 if (bWord) 116 146 iFlags = iFlags | 2 ; 117 118 var bFound = oRange.findText( document.getElementById('txtFind').value, 1, iFlags ) ; 119 120 if ( bFound ) 121 { 147 var bFound = oRange.findText(strText, 1, iFlags ) ; 148 149 if ( bFound ) { 122 150 oRange.scrollIntoView() ; 123 151 oRange.select() ; 124 152 oRange.collapse(false) ; 125 153 oLastRangeFound = oRange ; 154 return true; 126 155 } 127 156 else 128 157 { 129 158 oRange = oEditor.FCK.EditorDocument.body.createTextRange() ; 130 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;131 159 } 132 } 133 134 function FindGecko() 160 return false; 161 } 162 163 function FindGecko(strText, bCase, bWord) 135 164 { 136 165 var bCase = document.getElementById('chkCase').checked ; … … 138 167 139 168 // window.find( searchString, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog ) ; 140 if ( !oEditor.FCK.EditorWindow.find( document.getElementById('txtFind').value, bCase, false, false, bWord, false, false ) ) 141 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ; 142 } 143 </script> 169 var bFound = oEditor.FCK.EditorWindow.find( document.getElementById('txtFind').value, bCase, false, false, bWord, false, false ); 170 171 return (bFound); 172 } 173 174 function toggleRegex() 175 { 176 bRegex = document.getElementById('chkRegex').checked ; 177 document.getElementById('btnReplace').disabled = bRegex; 178 document.getElementById('btnFind').disabled = bRegex; 179 } 180 </script> 144 181 </head> 145 182 <body onload="OnLoad()" style="overflow: hidden"> 146 <table cellspacing="3" cellpadding="2" width="100%" border="0" >183 <table cellspacing="3" cellpadding="2" width="100%" border="0" height="130"> 147 184 <tr> 148 185 <td nowrap="nowrap"> … … 151 188 </td> 152 189 <td width="100%"> 153 <input id="txtFind" style="width: 100%" tabindex="1" type="text" /> 154 </td> 155 <td> 156 <input id="btnFind" style="padding-right: 5px; padding-left: 5px" onclick="Ok();" 157 type="button" value="Find" fcklang="DlgFindFindBtn" /> 190 <input id="txtFind" style="width: 100%" tabindex="1" type="text" 191 onkeyup = "document.getElementById('btnFind').disabled = ( document.getElementById('txtFind').value.length == 0 || document.getElementById('chkRegex').checked );" /> 192 </td> 193 </tr> 194 <tr id="replace" style="display:none"> 195 <td valign="top" nowrap="nowrap"> 196 <label for="txtReplace" fcklang="DlgReplaceReplaceLbl"> 197 Replace with:</label> 198 </td> 199 <td valign="top"> 200 <input id="txtReplace" style="width: 100%" tabindex="2" type="text" /> 158 201 </td> 159 202 </tr> 160 203 <tr> 161 <td valign="bottom" colspan="3"> 162 <input id="chkCase" tabindex="3" type="checkbox" /><label for="chkCase" fcklang="DlgReplaceCaseChk">Match 163 case</label> 164 <br /> 165 <div id="divWord" style="display: none"> 166 <input id="chkWord" tabindex="4" type="checkbox" /><label for="chkWord" fcklang="DlgReplaceWordChk">Match 167 whole word</label> 168 </div> 204 <td valign="middle" colspan="2"> 205 <table border="0"> 206 <tr> 207 <td> 208 <input id="chkCase" tabindex="3" type="checkbox" /><label for="chkCase" fcklang="DlgReplaceCaseChk">Match 209 case</label> 210 <br /> 211 <input id="chkWord" tabindex="4" type="checkbox" /><label for="chkWord" fcklang="DlgReplaceWordChk">Match 212 whole word</label> 213 </td> 214 <td id="regex" valign="top" style="display:none"> 215 <input id="chkRegex" tabindex="5" type="checkbox" onclick="toggleRegex()"/><label for="chkRegex">Regex</label> 216 </td> 217 </tr> 218 </table> 169 219 </td> 170 220 </tr> 171 221 </table> 222 <div style="text-align: right; margin-right: 5px"> 223 <span id="replaceButtons" style="display:none"> 224 <input type="button" id="btnReplaceAll" class="button" value="Replace All" onclick="ReplaceAll()" fcklang="DlgReplaceReplaceAllBtn" /> 225 <input type="button" id="btnReplace" class="button" value="Replace" onclick="Replace()" fcklang="DlgReplaceReplaceBtn" /></span> 226 <input type="button" id="btnFind" class="button" value="Find Next" onclick="Find()" disabled="disabled" /> 227 <input type="button" id="btnCancel" class="button" value="Close" onclick="top.Cancel()" /> 228 </div> 172 229 </body> 173 230 </html> -
FCKeditor/branches/developers/mjk/editor/dialog/fck_table.html
r132 r244 66 66 document.getElementById('selWidthType').value = "percent" ; 67 67 } 68 else if (iWidth.indexOf('px') >= 0) // Style Pixel = px68 else // Style Pixel = px, or width=nn 69 69 { // 70 70 iWidth = iWidth.substr(0,iWidth.length - 2); … … 89 89 document.getElementById('txtColumns').disabled = true ; 90 90 } 91 92 window.parent.SetOkButton( true ) ; 93 window.parent.SetAutoSize( true ) ; 91 window.parent.SetOkButton( true ) ; 92 window.parent.SetAutoSize( true ) ; 94 93 } 95 94 -
FCKeditor/branches/developers/mjk/editor/fckdialog.html
r153 r244 132 132 SetSelectedTab( this.TabCode ) ; 133 133 } 134 135 function AddTab( tabCode, tabText, startHidden )134 135 function AddTab( tabCode, tabText, startHidden, bNoTabRow ) 136 136 { 137 137 if ( typeof( oTabs[ tabCode ] ) != 'undefined' ) … … 162 162 163 163 oDiv.className = 'PopupTabSelected' ; 164 eTabsRow.style.display = '' ;164 if (!bNoTabRow) eTabsRow.style.display = '' ; 165 165 166 166 if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE ) … … 183 183 if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' ) 184 184 window.frames["frmMain"].OnDialogTabChange( tabCode ) ; 185 } 186 187 function GetSelectedTab() 188 { 189 for ( var sCode in oTabs ) 190 { 191 if (oTabs[sCode].className == 'PopupTabSelected') 192 return sCode; 193 } 185 194 } 186 195 … … 210 219 switch ( e.keyCode ) 211 220 { 212 case 13 : // ENTER 221 case 76 : // Ctrl+Alt+L: become lowercase 222 if (e.altKey && e.ctrlKey) 223 { 224 var oTarget = e.srcElement || e.target ; 225 if (oTarget.value) oTarget.value = oTarget.value.toLowerCase(); 226 return false; 227 } 228 break; 229 case 82 : // Ctrl+Alt+R: become Propercase 230 if (e.altKey && e.ctrlKey) 231 { 232 var oTarget = e.srcElement || e.target ; 233 if (oTarget.value) oTarget.value = oTarget.value.toLowerCase().replace(/(\S)(\S*\s*)/g, 234 function(str,p1,p2) {return p1.toUpperCase()+p2}); 235 return false; 236 } 237 break; 238 case 85 : // Ctrl+Alt+U: become UPPERCASE 239 if (e.altKey && e.ctrlKey) 240 { 241 var oTarget = e.srcElement || e.target ; 242 if (oTarget.value) oTarget.value = oTarget.value.toUpperCase(); 243 return false; 244 } 245 break; 246 247 case 13 : // ENTER 213 248 var oTarget = e.srcElement || e.target ; 214 249 if ( oTarget.tagName == 'TEXTAREA' ) … … 306 341 </td> 307 342 </tr> 308 <tr >343 <tr id="Buttons"> 309 344 <td class="PopupButtons"> 310 <table border="0" cellpadding="0" cellspacing="0" >345 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 311 346 <tr> 312 <td width="100%"> </td>313 <td nowrap="nowrap">314 <input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />347 <td nowrap="nowrap" align="right" width="100%"> 348 <span id="runtimeButtons"></span> 349 <input id="btnOk" style="VISIBILITY: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" /> 315 350 316 351 <input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" /> -
FCKeditor/branches/developers/mjk/editor/lang/en.js
r174 r244 124 124 FlashProperties : "Flash Properties", 125 125 126 AnchorDelete : "Remove Anchor", 126 127 AnchorProp : "Anchor Properties", 127 128 ButtonProp : "Button Properties", -
FCKeditor/branches/developers/mjk/editor/_source/classes/fckeditingarea.js
r205 r244 49 49 eTargetElement.removeChild( eTargetElement.childNodes[0] ) ; 50 50 51 if ( this.Mode == FCK_EDITMODE_WYSIWYG ) 52 { 51 52 53 53 // Create the editing area IFRAME. 54 54 var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ; … … 120 120 else 121 121 FCKEditingArea_CompleteStart.call( this.Window ) ; 122 } 123 else 124 { 125 var eTextarea = this.Textarea = oTargetDocument.createElement( 'textarea' ) ; 126 eTextarea.className = 'SourceField' ; 127 eTextarea.dir = 'ltr' ; 128 eTextarea.style.width = eTextarea.style.height = '100%' ; 129 eTextarea.style.border = 'none' ; 130 eTargetElement.appendChild( eTextarea ) ; 131 132 eTextarea.value = html ; 133 134 // Fire the "OnLoad" event. 135 FCKTools.RunFunction( this.OnLoad ) ; 136 } 122 123 137 124 } 138 125 … … 214 201 try 215 202 { 216 if ( this.Mode == FCK_EDITMODE_WYSIWYG ) 217 { 218 // The following check is important to avoid IE entering in a focus loop. Ref: 219 // http://sourceforge.net/tracker/index.php?func=detail&aid=1567060&group_id=75348&atid=543653 220 if ( FCKBrowserInfo.IsIE && this.Document.hasFocus() ) 221 return ; 222 223 if ( FCKBrowserInfo.IsSafari ) 224 this.IFrame.focus() ; 225 else 226 { 227 this.Window.focus() ; 228 } 229 } 203 // The following check is important to avoid IE entering in a focus loop. Ref: 204 // http://sourceforge.net/tracker/index.php?func=detail&aid=1567060&group_id=75348&atid=543653 205 if ( FCKBrowserInfo.IsIE && this.Document.hasFocus() ) 206 return ; 207 if ( FCKBrowserInfo.IsSafari ) 208 this.IFrame.focus() ; 230 209 else 231 210 { 232 var oDoc = FCKTools.GetElementDocument( this.Textarea ) ; 233 if ( (!oDoc.hasFocus || oDoc.hasFocus() ) && oDoc.activeElement == this.Textarea ) 234 return ; 235 236 this.Textarea.focus() ; 211 this.Window.focus() ; 237 212 } 238 213 } -
FCKeditor/branches/developers/mjk/editor/_source/commandclasses/fck_othercommands.js
r243 r244 339 339 340 340 // FCKSelectAllCommand 341 // mjk: since source is in the main frame, this command is now 342 // redundant and probably should be removed. 341 343 var FCKSelectAllCommand = function() 342 344 { … … 346 348 FCKSelectAllCommand.prototype.Execute = function() 347 349 { 348 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) 349 { 350 FCK.ExecuteNamedCommand( 'SelectAll' ) ; 351 } 352 else 353 { 354 // Select the contents of the textarea 355 var textarea = FCK.EditingArea.Textarea ; 356 if ( FCKBrowserInfo.IsIE ) 357 { 358 textarea.createTextRange().execCommand( 'SelectAll' ) ; 359 } 360 else 361 { 362 textarea.selectionStart = 0; 363 textarea.selectionEnd = textarea.value.length ; 364 } 365 textarea.focus() ; 366 } 350 FCK.ExecuteNamedCommand( 'SelectAll' ) ; 367 351 } 368 352 -
FCKeditor/branches/developers/mjk/editor/_source/internals/fckcommands.js
r243 r244 50 50 51 51 case 'Find' : oCommand = new FCKDialogCommand( 'Find' , FCKLang.DlgFindTitle , 'dialog/fck_find.html' , 340, 170 ) ; break ; 52 case 'Replace' : oCommand = new FCKDialogCommand( 'Replace' , FCKLang.DlgReplaceTitle , 'dialog/fck_ replace.html', 340, 200 ) ; break ;52 case 'Replace' : oCommand = new FCKDialogCommand( 'Replace' , FCKLang.DlgReplaceTitle , 'dialog/fck_find.html?rep' , 340, 200 ) ; break ; 53 53 54 54 case 'Image' : oCommand = new FCKDialogCommand( 'Image' , FCKLang.DlgImgTitle , 'dialog/fck_image.html' , 450, 400 ) ; break ; -
FCKeditor/branches/developers/mjk/editor/_source/internals/fck.js
r219 r244 49 49 { 50 50 if ( this.EditMode == FCK_EDITMODE_SOURCE ) 51 return ( this.StartupValue != this.EditingArea.Textarea.value );51 return ( this.StartupValue != FCK._fromRawHTML(this.EditorDocument.body.innerHTML)); 52 52 else 53 53 return ( this.StartupValue != this.EditorDocument.body.innerHTML ) ; … … 57 57 { 58 58 if ( this.EditMode == FCK_EDITMODE_SOURCE ) 59 this.StartupValue = this.EditingArea.Textarea.value;59 this.StartupValue = FCK._fromRawHTML(this.EditorDocument.body.innerHTML); 60 60 else if ( this.EditorDocument.body ) 61 61 this.StartupValue = this.EditorDocument.body.innerHTML ; … … 196 196 // represent the exact contents of the source, as the user wanted it to be. 197 197 if ( FCK.EditMode == FCK_EDITMODE_SOURCE ) 198 return FCK. EditingArea.Textarea.value;198 return FCK._fromRawHTML(FCK.EditorDocument.body.innerHTML); 199 199 200 200 this.FixBody() ; … … 257 257 { 258 258 FCKDocumentProcessor.Process( FCK.EditorDocument ) ; 259 //Put the cursor where we left it when moving into or 260 //out of Source view -- or somewhere close to it. 261 if (FCK.MoveToMarker) 262 { 263 if (FCKBrowserInfo.IsIE) 264 { 265 var oRange = FCK.EditorDocument.body.createTextRange(); 266 oRange.findText("__FCK_RAW_Marker__",1); 267 oRange.select(); 268 FCK.InsertHtml(''); 269 oRange.scrollIntoView(); 270 } 271 else 272 { 273 FCK.Selection.SelectNode(FCK.EditorDocument.body); 274 FCK.Selection.Collapse(); 275 FCK.EditorWindow.find("__FCK_RAW_Marker__", true, false, false, false, false, false ); 276 var oSel = FCKSelection.Delete() ; 277 var oRange = oSel.getRangeAt(0) ; 278 oRange.Select() ; 279 } 280 FCK.MoveToMarker = null; 281 } 259 282 FCKUndo.SaveUndoStep() ; 260 283 … … 327 350 this.EditingArea.Mode = FCK.EditMode ; 328 351 329 if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) 330 { 331 html = FCKConfig.ProtectedSource.Protect( html ) ; 332 333 // Fix for invalid self-closing tags (see #152). 334 html = html.replace( FCKRegexLib.InvalidSelfCloseTags, '$1></$2>' ) ; 335 336 html = FCK.ProtectEvents( html ) ; 337 html = FCK.ProtectUrls( html ) ; 338 html = FCK.ProtectTags( html ) ; 339 340 // Firefox can't handle correctly the editing of the STRONG and EM tags. 341 // We must replace them with B and I. 342 if ( FCKBrowserInfo.IsGecko ) 352 html = FCKConfig.ProtectedSource.Protect( html ) ; 353 354 // Fix for invalid self-closing tags (see #152). 355 html = html.replace( FCKRegexLib.InvalidSelfCloseTags, '$1></$2>' ) ; 356 357 html = FCK.ProtectEvents( html ) ; 358 html = FCK.ProtectUrls( html ) ; 359 html = FCK.ProtectTags( html ) ; 360 361 // Firefox can't handle correctly the editing of the STRONG and EM tags. 362 // We must replace them with B and I. 363 if ( FCKBrowserInfo.IsGecko ) 364 { 365 html = html.replace( FCKRegexLib.StrongOpener, '<b$1' ) ; 366 html = html.replace( FCKRegexLib.StrongCloser, '<\/b>' ) ; 367 html = html.replace( FCKRegexLib.EmOpener, '<i$1' ) ; 368 html = html.replace( FCKRegexLib.EmCloser, '<\/i>' ) ; 369 } 370 371 this._ForceResetIsDirty = ( resetIsDirty === true ) ; 372 373 var sHtml = '' ; 374 375 if ( FCKConfig.FullPage ) 376 { 377 // The HTML must be fixed if the <head> is not available. 378 if ( !FCKRegexLib.HeadOpener.test( html ) ) 343 379 { 344 html = html.replace( FCKRegexLib.StrongOpener, '<b$1' ) ; 345 html = html.replace( FCKRegexLib.StrongCloser, '<\/b>' ) ; 346 html = html.replace( FCKRegexLib.EmOpener, '<i$1' ) ; 347 html = html.replace( FCKRegexLib.EmCloser, '<\/i>' ) ; 380 // Check if the <html> is available. 381 if ( !FCKRegexLib.HtmlOpener.test( html ) ) 382 html = '<html dir="' + FCKConfig.ContentLangDirection + '">' + html + '</html>' ; 383 384 // Add the <head>. 385 html = html.replace( FCKRegexLib.HtmlOpener, '$&<head></head>' ) ; 348 386 } 349 387 350 this._ForceResetIsDirty = ( resetIsDirty === true ) ; 351 352 var sHtml = '' ; 353 354 if ( FCKConfig.FullPage ) 355 { 356 // The HTML must be fixed if the <head> is not available. 357 if ( !FCKRegexLib.HeadOpener.test( html ) ) 358 { 359 // Check if the <html> is available. 360 if ( !FCKRegexLib.HtmlOpener.test( html ) ) 361 html = '<html dir="' + FCKConfig.ContentLangDirection + '">' + html + '</html>' ; 362 363 // Add the <head>. 364 html = html.replace( FCKRegexLib.HtmlOpener, '$&<head></head>' ) ; 365 } 366 367 // Save the DOCTYPE. 368 FCK.DocTypeDeclaration = html.match( FCKRegexLib.DocTypeTag ) ; 369 370 if ( FCKBrowserInfo.IsIE ) 371 sHtml = FCK._GetBehaviorsStyle() ; 372 else if ( FCKConfig.ShowBorders ) 373 sHtml = '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 374 375 sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 376 377 // Attention: do not change it before testing it well (sample07)! 378 // This is tricky... if the head ends with <meta ... content type>, 379 // Firefox will break. But, it works if we include the temporary 380 // links as the last elements in the HEAD. 381 sHtml = html.replace( FCKRegexLib.HeadCloser, sHtml + '$&' ) ; 382 383 // Insert the base tag (FCKConfig.BaseHref), if not exists in the source. 384 // The base must be the first tag in the HEAD, to get relative 385 // links on styles, for example. 386 if ( FCK.TempBaseTag.length > 0 && !FCKRegexLib.HasBaseTag.test( html ) ) 387 sHtml = sHtml.replace( FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag ) ; 388 } 388 // Save the DOCTYPE. 389 FCK.DocTypeDeclaration = html.match( FCKRegexLib.DocTypeTag ) ; 390 391 if ( FCKBrowserInfo.IsIE ) 392 sHtml = FCK._GetBehaviorsStyle() ; 393 else if ( FCKConfig.ShowBorders ) 394 sHtml = '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 395 396 sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 397 398 // Attention: do not change it before testing it well (sample07)! 399 // This is tricky... if the head ends with <meta ... content type>, 400 // Firefox will break. But, it works if we include the temporary 401 // links as the last elements in the HEAD. 402 sHtml = html.replace( FCKRegexLib.HeadCloser, sHtml + '$&' ) ; 403 404 // Insert the base tag (FCKConfig.BaseHref), if not exists in the source. 405 // The base must be the first tag in the HEAD, to get relative 406 // links on styles, for example. 407 if ( FCK.TempBaseTag.length > 0 && !FCKRegexLib.HasBaseTag.test( html ) ) 408 sHtml = sHtml.replace( FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag ) ; 409 } 410 else 411 { 412 sHtml = 413 FCKConfig.DocType + 414 '<html dir="' + FCKConfig.ContentLangDirection + '"' ; 415 416 // On IE, if you are use a DOCTYPE differenft of HTML 4 (like 417 // XHTML), you must force the vertical scroll to show, otherwise 418 // the horizontal one may appear when the page needs vertical scrolling. 419 if ( FCKBrowserInfo.IsIE && !FCKRegexLib.Html4DocType.test( FCKConfig.DocType ) ) 420 sHtml += ' style="overflow-y: scroll"' ; 421 422 sHtml += 423 '><head><title></title>' + 424 _FCK_GetEditorAreaStyleTags() + 425 '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 426 427 if ( FCKBrowserInfo.IsIE ) 428 sHtml += FCK._GetBehaviorsStyle() ; 429 else if ( FCKConfig.ShowBorders ) 430 sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 431 432 sHtml += FCK.TempBaseTag ; 433 434 // Add ID and Class to the body 435 var sBodyTag = '<body' ; 436 if ( FCKConfig.BodyId && FCKConfig.BodyId.length > 0 ) 437 sBodyTag += ' id="' + FCKConfig.BodyId + '"' ; 438 if ( FCKConfig.BodyClass && FCKConfig.BodyClass.length > 0 ) 439 sBodyTag += ' class="' + FCKConfig.BodyClass + '"' ; 440 sHtml += '</head>' + sBodyTag + '>' ; 441 442 if ( FCKBrowserInfo.IsGecko && ( html.length == 0 || FCKRegexLib.EmptyParagraph.test( html ) ) ) 443 sHtml += GECKO_BOGUS ; 389 444 else 390 { 391 sHtml = 392 FCKConfig.DocType + 393 '<html dir="' + FCKConfig.ContentLangDirection + '"' ; 394 395 // On IE, if you are use a DOCTYPE differenft of HTML 4 (like 396 // XHTML), you must force the vertical scroll to show, otherwise 397 // the horizontal one may appear when the page needs vertical scrolling. 398 if ( FCKBrowserInfo.IsIE && !FCKRegexLib.Html4DocType.test( FCKConfig.DocType ) ) 399 sHtml += ' style="overflow-y: scroll"' ; 400 401 sHtml += 402 '><head><title></title>' + 403 _FCK_GetEditorAreaStyleTags() + 404 '<link href="' + FCKConfig.FullBasePath + 'css/fck_internal.css' + '" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 405 406 if ( FCKBrowserInfo.IsIE ) 407 sHtml += FCK._GetBehaviorsStyle() ; 408 else if ( FCKConfig.ShowBorders ) 409 sHtml += '<link href="' + FCKConfig.FullBasePath + 'css/fck_showtableborders_gecko.css" rel="stylesheet" type="text/css" _fcktemp="true" />' ; 410 411 sHtml += FCK.TempBaseTag ; 412 413 // Add ID and Class to the body 414 var sBodyTag = '<body' ; 415 if ( FCKConfig.BodyId && FCKConfig.BodyId.length > 0 ) 416 sBodyTag += ' id="' + FCKConfig.BodyId + '"' ; 417 if ( FCKConfig.BodyClass && FCKConfig.BodyClass.length > 0 ) 418 sBodyTag += ' class="' + FCKConfig.BodyClass + '"' ; 419 sHtml += '</head>' + sBodyTag + '>' ; 420 421 if ( FCKBrowserInfo.IsGecko && ( html.length == 0 || FCKRegexLib.EmptyParagraph.test( html ) ) ) 422 sHtml += GECKO_BOGUS ; 423 else 424 sHtml += html ; 425 426 sHtml += '</body></html>' ; 427 } 428 429 this.EditingArea.OnLoad = _FCK_EditingArea_OnLoad ; 430 this.EditingArea.Start( sHtml ) ; 431 } 432 else 433 { 434 // Remove the references to the following elements, as the editing area 435 // IFRAME will be removed. 436 FCK.EditorWindow = null ; 437 FCK.EditorDocument = null ; 438 439 this.EditingArea.OnLoad = null ; 440 this.EditingArea.Start( html ) ; 441 442 // Enables the context menu in the textarea. 443 this.EditingArea.Textarea._FCKShowContextMenu = true ; 444 445 // Removes the enter key handler. 446 FCK.EnterKeyHandler = null ; 447 448 if ( resetIsDirty ) 449 this.ResetIsDirty() ; 450 451 // Listen for keystroke events. 452 FCK.KeystrokeHandler.AttachToElement( this.EditingArea.Textarea ) ; 453 454 this.EditingArea.Textarea.focus() ; 455 456 FCK.Events.FireEvent( 'OnAfterSetHTML' ) ; 457 } 445 sHtml += html ; 446 447 sHtml += '</body></html>' ; 448 } 449 450 this.EditingArea.OnLoad = _FCK_EditingArea_OnLoad ; 451 this.EditingArea.Start( sHtml ) ; 458 452 459 453 if ( FCKBrowserInfo.IsGecko ) … … 566 560 var bIsDirty = FCK.IsDirty() ; 567 561 568 var sHtml ;569 570 562 // Update the HTML in the view output to show. 571 563 if ( bIsWysiwyg ) … … 573 565 if ( !noUndo && FCKBrowserInfo.IsIE ) 574 566 FCKUndo.SaveUndoStep() ; 575 576 sHtml = FCK.GetXHTML( FCKConfig.FormatSource ) ; 577 578 if ( sHtml == null ) 579 return false ; 567 568 //drop a marker so we can find where we were 569 if (FCK.Selection.GetType() != 'None') FCK.Selection.Collapse(); 570 FCK.InsertHtml("__FCK_RAW_Marker__"); 571 sHtml = FCK._toRawHTML(FCK.GetXHTML( FCKConfig.FormatSource )); 572 FCK.MoveToMarker = true; 580 573 } 581 574 else 582 sHtml = this.EditingArea.Textarea.value ; 583 575 { 576 sHtml = FCK.GetXHTML( FCKConfig.FormatSource ); 577 //set this before SetHTML so we get HTML out rather than raw out 578 FCK.EditMode = FCK_EDITMODE_WYSIWYG; 579 } 580 581 FCK.SetHTML( sHtml ) ; 582 584 583 FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ; 585 586 FCK.SetHTML( sHtml, !bIsDirty ) ; 587 584 588 585 // Set the Focus. 589 586 FCK.Focus() ; 590 587 591 588 // Update the toolbar (Running it directly causes IE to fail). 592 589 FCKTools.RunFunction( FCK.ToolbarSet.RefreshModeState, FCK.ToolbarSet ) ; 593 590 594 591 return true ; 595 592 }, … … 618 615 } 619 616 return null ; 617 }, 618 619 // Handle text processing when moving into or out of Source view. 620 // per mjk's patches, Source is no longer a separate textarea but 621 // a differently formatted view inside the main editor iframe. 622 // Consequently, we get some redundant source formatting that we need 623 // to simply remove before returning to WYSIWYG view. 624 // TODO: Add syntax coloring support. 625 _fromRawHTML : function(sIn) 626 { 627 var sHtml = sIn; 628 sHtml = sHtml.replace(/<[\/]*pre>/ig,''); 629 sHtml = sHtml.replace(/<p>/ig,'\n'); 630 sHtml = sHtml.replace(/<[\/]*b>/ig,''); 631 sHtml = sHtml.replace(/<\/p>/ig,''); 632 sHtml = sHtml.replace(/<br[^>]*>/ig,'\n'); 633 sHtml = sHtml.replace(/>/ig,'>'); 634 sHtml = sHtml.replace(/</ig,'<'); 635 sHtml = sHtml.replace(/&/ig,'&'); 636 return sHtml; 637 }, 638 639 _toRawHTML : function (sIn) 640 { 641 sHtml = sIn; 642 sHtml = sHtml.replace(/&/ig,'&'); 643 sHtml = sHtml.replace(/</ig,'<'); 644 sHtml = sHtml.replace(/>/ig,'>'); 645 sHtml = '<pre>' + sHtml + '</pre>'; 646 return sHtml; 620 647 } 621 648 -
FCKeditor/branches/developers/mjk/editor/_source/internals/fcktoolbaritems.js
r152 r244 47 47 case 'About' : oItem = new FCKToolbarButton( 'About' , FCKLang.About, null, null, true, null, 47 ) ; break ; 48 48 49 case 'Cut' : oItem = new FCKToolbarButton( 'Cut' , FCKLang.Cut, null, null, false, true, 7 ) ; break ;50 case 'Copy' : oItem = new FCKToolbarButton( 'Copy' , FCKLang.Copy, null, null, false, true, 8 ) ; break ;51 case 'Paste' : oItem = new FCKToolbarButton( 'Paste' , FCKLang.Paste, null, null, false, true, 9 ) ; break ;49 case 'Cut' : oItem = new FCKToolbarButton( 'Cut' , FCKLang.Cut, null, null, true, true, 7 ) ; break ; 50 case 'Copy' : oItem = new FCKToolbarButton( 'Copy' , FCKLang.Copy, null, null, true, true, 8 ) ; break ; 51 case 'Paste' : oItem = new FCKToolbarButton( 'Paste' , FCKLang.Paste, null, null, true, true, 9 ) ; break ; 52 52 case 'PasteText' : oItem = new FCKToolbarButton( 'PasteText' , FCKLang.PasteText, null, null, false, true, 10 ) ; break ; 53 53 case 'PasteWord' : oItem = new FCKToolbarButton( 'PasteWord' , FCKLang.PasteWord, null, null, false, true, 11 ) ; break ; 54 case 'Print' : oItem = new FCKToolbarButton( 'Print' , FCKLang.Print, null, null, false, true, 12 ) ; break ;54 case 'Print' : oItem = new FCKToolbarButton( 'Print' , FCKLang.Print, null, null, true, true, 12 ) ; break ; 55 55 case 'SpellCheck' : oItem = new FCKToolbarButton( 'SpellCheck', FCKLang.SpellCheck, null, null, null, null, 13 ) ; break ; 56 56 case 'Undo' : oItem = new FCKToolbarButton( 'Undo' , FCKLang.Undo, null, null, false, true, 14 ) ; break ; … … 98 98 case 'BGColor' : oItem = new FCKToolbarPanelButton( 'BGColor' , FCKLang.BGColor, null, null, 46 ) ; break ; 99 99 100 case 'Find' : oItem = new FCKToolbarButton( 'Find' , FCKLang.Find, null, null, null, null, 16 ) ; break ;101 case 'Replace' : oItem = new FCKToolbarButton( 'Replace' , FCKLang.Replace, null, null, null, null, 17 ) ; break ;100 case 'Find' : oItem = new FCKToolbarButton( 'Find' , FCKLang.Find, null, null, null, true, 16 ) ; break ; 101 case 'Replace' : oItem = new FCKToolbarButton( 'Replace' , FCKLang.Replace, null, null, null, true, 17 ) ; break ; 102 102 103 103 case 'Form' : oItem = new FCKToolbarButton( 'Form' , FCKLang.Form, null, null, null, null, 48 ) ; break ; -
FCKeditor/branches/developers/mjk/editor/_source/internals/fcktoolbarset.js
r132 r244 355 355 356 356 for ( var i = 0 ; i < aItems.length ; i++ ) 357 aItems[i].RefreshState() ; 358 } 357 { 358 if (FCK.EditMode == FCK_EDITMODE_WYSIWYG || 359 aItems[i].SourceView) 360 aItems[i].RefreshState() ; 361 } 362 }