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