[1257] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
| 2 | <!-- |
---|
| 3 | * FCKeditor - The text editor for internet |
---|
| 4 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
| 5 | * |
---|
| 6 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
| 7 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
| 8 | * |
---|
| 9 | * For further information visit: |
---|
| 10 | * http://www.fckeditor.net/ |
---|
| 11 | * |
---|
| 12 | * "Support Open Source software. What about a donation today?" |
---|
| 13 | * |
---|
| 14 | * File Name: fck_paste.html |
---|
| 15 | * This dialog is shown when, for some reason (usually security settings), |
---|
| 16 | * the user is not able to paste data from the clipboard to the editor using |
---|
| 17 | * the toolbar buttons or the context menu. |
---|
| 18 | * |
---|
| 19 | * File Authors: |
---|
| 20 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
| 21 | --> |
---|
| 22 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
| 23 | <head> |
---|
| 24 | <title></title> |
---|
| 25 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
| 26 | <meta name="robots" content="noindex, nofollow" /> |
---|
| 27 | <script type="text/javascript"> |
---|
| 28 | var oEditor = window.parent.InnerDialogLoaded() ; |
---|
| 29 | |
---|
| 30 | window.onload = function () |
---|
| 31 | { |
---|
| 32 | // First of all, translate the dialog box texts |
---|
| 33 | oEditor.FCKLanguageManager.TranslatePage(document) ; |
---|
| 34 | |
---|
| 35 | if ( window.parent.dialogArguments.CustomValue == 'Word' ) |
---|
| 36 | { |
---|
| 37 | var oFrame = document.getElementById('frmData') |
---|
| 38 | oFrame.style.display = '' ; |
---|
| 39 | |
---|
| 40 | if ( oFrame.contentDocument ) |
---|
| 41 | oFrame.contentDocument.designMode = 'on' ; |
---|
| 42 | else |
---|
| 43 | oFrame.contentWindow.document.body.contentEditable = true ; |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | document.getElementById('txtData').style.display = '' ; |
---|
| 48 | document.getElementById('oWordCommands').style.display = 'none' ; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | window.parent.SetOkButton( true ) ; |
---|
| 52 | window.parent.SetAutoSize( true ) ; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function Ok() |
---|
| 56 | { |
---|
| 57 | var sHtml ; |
---|
| 58 | |
---|
| 59 | if ( window.parent.dialogArguments.CustomValue == 'Word' ) |
---|
| 60 | { |
---|
| 61 | var oFrame = document.getElementById('frmData') ; |
---|
| 62 | |
---|
| 63 | if ( oFrame.contentDocument ) |
---|
| 64 | sHtml = oFrame.contentDocument.body.innerHTML ; |
---|
| 65 | else |
---|
| 66 | sHtml = oFrame.contentWindow.document.body.innerHTML ; |
---|
| 67 | |
---|
| 68 | sHtml = CleanWord( sHtml ) ; |
---|
| 69 | } |
---|
| 70 | else |
---|
| 71 | { |
---|
| 72 | var sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value ) ; |
---|
| 73 | sHtml = sHtml.replace( /\n/g, '<BR>' ) ; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | oEditor.FCK.InsertHtml( sHtml ) ; |
---|
| 77 | |
---|
| 78 | return true ; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | function CleanUpBox() |
---|
| 82 | { |
---|
| 83 | var oFrame = document.getElementById('frmData') ; |
---|
| 84 | |
---|
| 85 | if ( oFrame.contentDocument ) |
---|
| 86 | oFrame.contentDocument.body.innerHTML = '' ; |
---|
| 87 | else |
---|
| 88 | oFrame.contentWindow.document.body.innerHTML = '' ; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function CleanWord( html ) |
---|
| 92 | { |
---|
| 93 | var bIgnoreFont = document.getElementById('chkRemoveFont').checked ; |
---|
| 94 | var bRemoveStyles = document.getElementById('chkRemoveStyles').checked ; |
---|
| 95 | |
---|
| 96 | html = html.replace(/<o:p>\s*<\/o:p>/g, "") ; |
---|
| 97 | html = html.replace(/<o:p>.*?<\/o:p>/g, " ") ; |
---|
| 98 | |
---|
| 99 | // Remove mso-xxx styles. |
---|
| 100 | html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ; |
---|
| 101 | |
---|
| 102 | // Remove margin styles. |
---|
| 103 | html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ; |
---|
| 104 | html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ; |
---|
| 105 | |
---|
| 106 | html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ; |
---|
| 107 | html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ; |
---|
| 108 | |
---|
| 109 | html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ; |
---|
| 110 | |
---|
| 111 | html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ; |
---|
| 112 | |
---|
| 113 | html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ; |
---|
| 114 | |
---|
| 115 | html = html.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ; |
---|
| 116 | html = html.replace( /\s*tab-stops:[^"]*/gi, "" ) ; |
---|
| 117 | |
---|
| 118 | // Remove FONT face attributes. |
---|
| 119 | if ( bIgnoreFont ) |
---|
| 120 | { |
---|
| 121 | html = html.replace( /\s*face="[^"]*"/gi, "" ) ; |
---|
| 122 | html = html.replace( /\s*face=[^ >]*/gi, "" ) ; |
---|
| 123 | |
---|
| 124 | html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | // Remove Class attributes |
---|
| 128 | html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ; |
---|
| 129 | |
---|
| 130 | // Remove styles. |
---|
| 131 | if ( bRemoveStyles ) |
---|
| 132 | html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ; |
---|
| 133 | |
---|
| 134 | // Remove empty styles. |
---|
| 135 | html = html.replace( /\s*style="\s*"/gi, '' ) ; |
---|
| 136 | |
---|
| 137 | html = html.replace( /<SPAN\s*[^>]*>\s* \s*<\/SPAN>/gi, ' ' ) ; |
---|
| 138 | |
---|
| 139 | html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ; |
---|
| 140 | |
---|
| 141 | // Remove Lang attributes |
---|
| 142 | html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ; |
---|
| 143 | |
---|
| 144 | html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ; |
---|
| 145 | |
---|
| 146 | html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ; |
---|
| 147 | |
---|
| 148 | // Remove XML elements and declarations |
---|
| 149 | html = html.replace(/<\\?\?xml[^>]*>/gi, "") ; |
---|
| 150 | |
---|
| 151 | // Remove Tags with XML namespace declarations: <o:p><\/o:p> |
---|
| 152 | html = html.replace(/<\/?\w+:[^>]*>/gi, "") ; |
---|
| 153 | |
---|
| 154 | // Remove comments [SF BUG-1481861]. |
---|
| 155 | html = html.replace(/<\!--.*-->/g, "") ; |
---|
| 156 | |
---|
| 157 | html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ; |
---|
| 158 | |
---|
| 159 | html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ; |
---|
| 160 | html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ; |
---|
| 161 | html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ; |
---|
| 162 | html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ; |
---|
| 163 | html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ; |
---|
| 164 | html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ; |
---|
| 165 | |
---|
| 166 | html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ; |
---|
| 167 | |
---|
| 168 | html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ; |
---|
| 169 | |
---|
| 170 | // Remove empty tags (three times, just to be sure). |
---|
| 171 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ; |
---|
| 172 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ; |
---|
| 173 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ; |
---|
| 174 | |
---|
| 175 | // Transform <P> to <DIV> |
---|
| 176 | var re = new RegExp( "(<P)([^>]*>.*?)(<\/P>)", "gi" ) ; // Different because of a IE 5.0 error |
---|
| 177 | html = html.replace( re, "<div$2<\/div>" ) ; |
---|
| 178 | |
---|
| 179 | // Fix relative anchor URLs (IE automatically adds the current page URL). |
---|
| 180 | re = new RegExp( window.location + "#", "g" ) ; |
---|
| 181 | html = html.replace( re, '#') ; |
---|
| 182 | |
---|
| 183 | return html ; |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | </script> |
---|
| 187 | </head> |
---|
| 188 | <body style="overflow: hidden"> |
---|
| 189 | <table cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 98%"> |
---|
| 190 | <tr> |
---|
| 191 | <td> |
---|
| 192 | <span fcklang="DlgPasteMsg2">Please paste inside the following box using the keyboard |
---|
| 193 | (<strong>Ctrl+V</strong>) and hit <strong>OK</strong>.</span> |
---|
| 194 | <br /> |
---|
| 195 | |
---|
| 196 | </td> |
---|
| 197 | </tr> |
---|
| 198 | <tr> |
---|
| 199 | <td valign="top" height="100%" style="border-right: #000000 1px solid; border-top: #000000 1px solid; |
---|
| 200 | border-left: #000000 1px solid; border-bottom: #000000 1px solid"> |
---|
| 201 | <textarea id="txtData" cols="80" rows="5" style="border: #000000 1px; display: none; |
---|
| 202 | width: 99%; height: 98%"></textarea> |
---|
| 203 | <iframe id="frmData" src="javascript:void(0)" height="98%" width="99%" frameborder="0" |
---|
| 204 | style="border-right: #000000 1px; border-top: #000000 1px; display: none; border-left: #000000 1px; |
---|
| 205 | border-bottom: #000000 1px; background-color: #ffffff"></iframe> |
---|
| 206 | </td> |
---|
| 207 | </tr> |
---|
| 208 | <tr id="oWordCommands"> |
---|
| 209 | <td> |
---|
| 210 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
---|
| 211 | <tr> |
---|
| 212 | <td nowrap="nowrap"> |
---|
| 213 | <input id="chkRemoveFont" type="checkbox" checked="checked" /> |
---|
| 214 | <label for="chkRemoveFont" fcklang="DlgPasteIgnoreFont"> |
---|
| 215 | Ignore Font Face definitions</label> |
---|
| 216 | <br /> |
---|
| 217 | <input id="chkRemoveStyles" type="checkbox" /> |
---|
| 218 | <label for="chkRemoveStyles" fcklang="DlgPasteRemoveStyles"> |
---|
| 219 | Remove Styles definitions</label> |
---|
| 220 | </td> |
---|
| 221 | <td align="right" valign="top"> |
---|
| 222 | <input type="button" fcklang="DlgPasteCleanBox" value="Clean Up Box" onclick="CleanUpBox()" /> |
---|
| 223 | </td> |
---|
| 224 | </tr> |
---|
| 225 | </table> |
---|
| 226 | </td> |
---|
| 227 | </tr> |
---|
| 228 | </table> |
---|
| 229 | </body> |
---|
| 230 | </html> |
---|