This commit was manufactured by cvs2svn to create tag 'freeside_1_9_2'.
[freeside.git] / httemplate / elements / fckeditor / editor / dialog / fck_paste.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
2 <!--\r
3  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
4  * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
5  *\r
6  * == BEGIN LICENSE ==\r
7  *\r
8  * Licensed under the terms of any of the following licenses at your\r
9  * choice:\r
10  *\r
11  *  - GNU General Public License Version 2 or later (the "GPL")\r
12  *    http://www.gnu.org/licenses/gpl.html\r
13  *\r
14  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
15  *    http://www.gnu.org/licenses/lgpl.html\r
16  *\r
17  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
18  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
19  *\r
20  * == END LICENSE ==\r
21  *\r
22  * This dialog is shown when, for some reason (usually security settings),\r
23  * the user is not able to paste data from the clipboard to the editor using\r
24  * the toolbar buttons or the context menu.\r
25 -->\r
26 <html xmlns="http://www.w3.org/1999/xhtml">\r
27 <head>\r
28         <title></title>\r
29         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
30         <meta name="robots" content="noindex, nofollow" />\r
31 \r
32         <script type="text/javascript">\r
33 var oEditor = window.parent.InnerDialogLoaded() ;\r
34 var FCK = oEditor.FCK;\r
35 var FCKTools    = oEditor.FCKTools ;\r
36 var FCKConfig   = oEditor.FCKConfig ;\r
37 \r
38 window.onload = function ()\r
39 {\r
40         // First of all, translate the dialog box texts\r
41         oEditor.FCKLanguageManager.TranslatePage(document) ;\r
42         \r
43         var sPastingType = window.parent.dialogArguments.CustomValue ;\r
44 \r
45         if ( sPastingType == 'Word' || sPastingType == 'Security' )\r
46         {\r
47                 if ( sPastingType == 'Security' )\r
48                         document.getElementById( 'xSecurityMsg' ).style.display = '' ;\r
49 \r
50                 var oFrame = document.getElementById('frmData') ;\r
51                 oFrame.style.display = '' ;\r
52 \r
53                 if ( oFrame.contentDocument )\r
54                         oFrame.contentDocument.designMode = 'on' ;\r
55                 else\r
56                         oFrame.contentWindow.document.body.contentEditable = true ;\r
57         }\r
58         else\r
59         {\r
60                 document.getElementById('txtData').style.display = '' ;\r
61         }\r
62 \r
63         if ( sPastingType != 'Word' )\r
64                 document.getElementById('oWordCommands').style.display = 'none' ;\r
65 \r
66         window.parent.SetOkButton( true ) ;\r
67         window.parent.SetAutoSize( true ) ;\r
68 }\r
69 \r
70 function Ok()\r
71 {\r
72         var sHtml ;\r
73 \r
74         var sPastingType = window.parent.dialogArguments.CustomValue ;\r
75 \r
76         if ( sPastingType == 'Word' || sPastingType == 'Security' )\r
77         {\r
78                 var oFrame = document.getElementById('frmData') ;\r
79                 var oBody ;\r
80 \r
81                 if ( oFrame.contentDocument )\r
82                         oBody = oFrame.contentDocument.body ;\r
83                 else\r
84                         oBody = oFrame.contentWindow.document.body ;\r
85 \r
86                 if ( sPastingType == 'Word' )\r
87                 {\r
88                         // If a plugin creates a FCK.CustomCleanWord function it will be called instead of the default one\r
89                         if ( typeof( FCK.CustomCleanWord ) == 'function' )\r
90                                 sHtml = FCK.CustomCleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;\r
91                         else\r
92                                 sHtml = CleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;\r
93                 }\r
94                 else\r
95                         sHtml = oBody.innerHTML ;\r
96 \r
97                 // Fix relative anchor URLs (IE automatically adds the current page URL).\r
98                 var re = new RegExp( window.location + "#", "g" ) ;\r
99                 sHtml = sHtml.replace( re, '#') ;\r
100         }\r
101         else\r
102         {\r
103                 sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value )  ;\r
104                 sHtml = sHtml.replace( /\n/g, '<BR>' ) ;\r
105         }\r
106 \r
107         oEditor.FCK.InsertHtml( sHtml ) ;\r
108 \r
109         return true ;\r
110 }\r
111 \r
112 function CleanUpBox()\r
113 {\r
114         var oFrame = document.getElementById('frmData') ;\r
115 \r
116         if ( oFrame.contentDocument )\r
117                 oFrame.contentDocument.body.innerHTML = '' ;\r
118         else\r
119                 oFrame.contentWindow.document.body.innerHTML = '' ;\r
120 }\r
121 \r
122 \r
123 // This function will be called from the PasteFromWord dialog (fck_paste.html)\r
124 // Input: oNode a DOM node that contains the raw paste from the clipboard\r
125 // bIgnoreFont, bRemoveStyles booleans according to the values set in the dialog\r
126 // Output: the cleaned string\r
127 function CleanWord( oNode, bIgnoreFont, bRemoveStyles )\r
128 {\r
129         var html = oNode.innerHTML ;\r
130 \r
131         html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;\r
132         html = html.replace(/<o:p>.*?<\/o:p>/g, '&nbsp;') ;\r
133 \r
134         // Remove mso-xxx styles.\r
135         html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;\r
136 \r
137         // Remove margin styles.\r
138         html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ;\r
139         html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;\r
140 \r
141         html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;\r
142         html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;\r
143 \r
144         html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;\r
145 \r
146         html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;\r
147 \r
148         html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;\r
149 \r
150         html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;\r
151         html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;\r
152 \r
153         // Remove FONT face attributes.\r
154         if ( bIgnoreFont )\r
155         {\r
156                 html = html.replace( /\s*face="[^"]*"/gi, '' ) ;\r
157                 html = html.replace( /\s*face=[^ >]*/gi, '' ) ;\r
158 \r
159                 html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;\r
160         }\r
161 \r
162         // Remove Class attributes\r
163         html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;\r
164 \r
165         // Remove styles.\r
166         if ( bRemoveStyles )\r
167                 html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;\r
168 \r
169         // Remove empty styles.\r
170         html =  html.replace( /\s*style="\s*"/gi, '' ) ;\r
171 \r
172         html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;\r
173 \r
174         html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;\r
175 \r
176         // Remove Lang attributes\r
177         html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;\r
178 \r
179         html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;\r
180 \r
181         html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;\r
182 \r
183         // Remove XML elements and declarations\r
184         html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;\r
185 \r
186         // Remove Tags with XML namespace declarations: <o:p><\/o:p>\r
187         html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;\r
188 \r
189         // Remove comments [SF BUG-1481861].\r
190         html = html.replace(/<\!--.*-->/g, '' ) ;\r
191 \r
192         html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;\r
193 \r
194         html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;\r
195 \r
196         // Remove "display:none" tags.\r
197         html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ;\r
198 \r
199         if ( FCKConfig.CleanWordKeepsStructure )\r
200         {\r
201                 // The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">\r
202                 html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;\r
203 \r
204                 // Word likes to insert extra <font> tags, when using MSIE. (Wierd).\r
205                 html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );\r
206                 html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );\r
207         }\r
208         else\r
209         {\r
210                 html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;\r
211                 html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;\r
212                 html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;\r
213                 html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;\r
214                 html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;\r
215                 html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;\r
216 \r
217                 html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;\r
218 \r
219                 // Transform <P> to <DIV>\r
220                 var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ; // Different because of a IE 5.0 error\r
221                 html = html.replace( re, '<div$2<\/div>' ) ;\r
222 \r
223                 // Remove empty tags (three times, just to be sure).\r
224                 // This also removes any empty anchor\r
225                 html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
226                 html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
227                 html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;\r
228         }\r
229 \r
230         return html ;\r
231 }\r
232 \r
233         </script>\r
234 \r
235 </head>\r
236 <body style="overflow: hidden">\r
237         <table cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 98%">\r
238                 <tr>\r
239                         <td>\r
240                                 <div id="xSecurityMsg" style="display: none">\r
241                                         <span fcklang="DlgPasteSec">Because of your browser security settings,\r
242                                                 the editor is not able to access your clipboard data directly. You are required\r
243                                                 to paste it again in this window.</span><br />\r
244                                         &nbsp;\r
245                                 </div>\r
246                                 <div>\r
247                                         <span fcklang="DlgPasteMsg2">Please paste inside the following box using the keyboard\r
248                                                 (<strong>Ctrl+V</strong>) and hit <strong>OK</strong>.</span><br />\r
249                                         &nbsp;\r
250                                 </div>\r
251                         </td>\r
252                 </tr>\r
253                 <tr>\r
254                         <td valign="top" height="100%" style="border-right: #000000 1px solid; border-top: #000000 1px solid;\r
255                                 border-left: #000000 1px solid; border-bottom: #000000 1px solid">\r
256                                 <textarea id="txtData" cols="80" rows="5" style="border: #000000 1px; display: none;\r
257                                         width: 99%; height: 98%"></textarea>\r
258                                 <iframe id="frmData" src="javascript:void(0)" height="98%" width="99%" frameborder="0"\r
259                                         style="border-right: #000000 1px; border-top: #000000 1px; display: none; border-left: #000000 1px;\r
260                                         border-bottom: #000000 1px; background-color: #ffffff"></iframe>\r
261                         </td>\r
262                 </tr>\r
263                 <tr id="oWordCommands">\r
264                         <td>\r
265                                 <table border="0" cellpadding="0" cellspacing="0" width="100%">\r
266                                         <tr>\r
267                                                 <td nowrap="nowrap">\r
268                                                         <input id="chkRemoveFont" type="checkbox" checked="checked" />\r
269                                                         <label for="chkRemoveFont" fcklang="DlgPasteIgnoreFont">\r
270                                                                 Ignore Font Face definitions</label>\r
271                                                         <br />\r
272                                                         <input id="chkRemoveStyles" type="checkbox" />\r
273                                                         <label for="chkRemoveStyles" fcklang="DlgPasteRemoveStyles">\r
274                                                                 Remove Styles definitions</label>\r
275                                                 </td>\r
276                                                 <td align="right" valign="top">\r
277                                                         <input type="button" fcklang="DlgPasteCleanBox" value="Clean Up Box" onclick="CleanUpBox()" />\r
278                                                 </td>\r
279                                         </tr>\r
280                                 </table>\r
281                         </td>\r
282                 </tr>\r
283         </table>\r
284 </body>\r
285 </html>\r