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-2009 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 | <script src="common/fck_dialog_common.js" type="text/javascript"></script>
|
---|
32 | <script type="text/javascript">
|
---|
33 | var dialog = window.parent ;
|
---|
34 | var oEditor = dialog.InnerDialogLoaded() ;
|
---|
35 | var FCK = oEditor.FCK;
|
---|
36 | var FCKTools = oEditor.FCKTools ;
|
---|
37 | var FCKConfig = oEditor.FCKConfig ;
|
---|
38 | var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
|
---|
39 |
|
---|
40 | window.onload = function ()
|
---|
41 | {
|
---|
42 | // First of all, translate the dialog box texts
|
---|
43 | oEditor.FCKLanguageManager.TranslatePage(document) ;
|
---|
44 |
|
---|
45 | var sPastingType = dialog.Args().CustomValue ;
|
---|
46 |
|
---|
47 | if ( sPastingType == 'Word' || sPastingType == 'Security' )
|
---|
48 | {
|
---|
49 | if ( sPastingType == 'Security' )
|
---|
50 | document.getElementById( 'xSecurityMsg' ).style.display = '' ;
|
---|
51 |
|
---|
52 | // For document.domain compatibility (#123) we must do all the magic in
|
---|
53 | // the URL for IE.
|
---|
54 | var sFrameUrl = !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ?
|
---|
55 | 'javascript:void(0)' :
|
---|
56 | 'javascript:void( (function(){' +
|
---|
57 | 'document.open() ;' +
|
---|
58 | 'document.domain=\'' + document.domain + '\' ;' +
|
---|
59 | 'document.write(\'<html><head><scr' + 'ipt>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>\') ;' +
|
---|
60 | 'document.close() ;' +
|
---|
61 | 'document.body.contentEditable = true ;' +
|
---|
62 | 'window.focus() ;' +
|
---|
63 | '})() )' ;
|
---|
64 |
|
---|
65 | var eFrameSpace = document.getElementById( 'xFrameSpace' ) ;
|
---|
66 | eFrameSpace.innerHTML = '<iframe id="frmData" src="' + sFrameUrl + '" ' +
|
---|
67 | 'height="98%" width="99%" frameborder="0" style="border: #000000 1px; background-color: #ffffff"><\/iframe>' ;
|
---|
68 |
|
---|
69 | var oFrame = eFrameSpace.firstChild ;
|
---|
70 |
|
---|
71 | if ( !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE )
|
---|
72 | {
|
---|
73 | // Avoid errors if the pasted content has any script that fails: #389
|
---|
74 | var oDoc = oFrame.contentWindow.document ;
|
---|
75 | oDoc.open() ;
|
---|
76 | oDoc.write('<html><head><scr' + 'ipt>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>') ;
|
---|
77 | oDoc.close() ;
|
---|
78 |
|
---|
79 | if ( FCKBrowserInfo.IsIE )
|
---|
80 | oDoc.body.contentEditable = true ;
|
---|
81 | else
|
---|
82 | oDoc.designMode = 'on' ;
|
---|
83 |
|
---|
84 | oFrame.contentWindow.focus();
|
---|
85 | }
|
---|
86 | }
|
---|
87 | else
|
---|
88 | {
|
---|
89 | document.getElementById('txtData').style.display = '' ;
|
---|
90 | SelectField( 'txtData' ) ;
|
---|
91 | }
|
---|
92 |
|
---|
93 | if ( sPastingType != 'Word' )
|
---|
94 | document.getElementById('oWordCommands').style.display = 'none' ;
|
---|
95 |
|
---|
96 | dialog.SetOkButton( true ) ;
|
---|
97 | dialog.SetAutoSize( true ) ;
|
---|
98 | }
|
---|
99 |
|
---|
100 | function Ok()
|
---|
101 | {
|
---|
102 | // Before doing anything, save undo snapshot.
|
---|
103 | oEditor.FCKUndo.SaveUndoStep() ;
|
---|
104 |
|
---|
105 | var sHtml ;
|
---|
106 |
|
---|
107 | var sPastingType = dialog.Args().CustomValue ;
|
---|
108 |
|
---|
109 | if ( sPastingType == 'Word' || sPastingType == 'Security' )
|
---|
110 | {
|
---|
111 | var oFrame = document.getElementById('frmData') ;
|
---|
112 | var oBody ;
|
---|
113 |
|
---|
114 | if ( oFrame.contentDocument )
|
---|
115 | oBody = oFrame.contentDocument.body ;
|
---|
116 | else
|
---|
117 | oBody = oFrame.contentWindow.document.body ;
|
---|
118 |
|
---|
119 | if ( sPastingType == 'Word' )
|
---|
120 | {
|
---|
121 | // If a plugin creates a FCK.CustomCleanWord function it will be called instead of the default one
|
---|
122 | if ( typeof( FCK.CustomCleanWord ) == 'function' )
|
---|
123 | sHtml = FCK.CustomCleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;
|
---|
124 | else
|
---|
125 | sHtml = CleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;
|
---|
126 | }
|
---|
127 | else
|
---|
128 | sHtml = oBody.innerHTML ;
|
---|
129 |
|
---|
130 | // Fix relative anchor URLs (IE automatically adds the current page URL).
|
---|
131 | var re = new RegExp( window.location + "#", "g" ) ;
|
---|
132 | sHtml = sHtml.replace( re, '#') ;
|
---|
133 | }
|
---|
134 | else
|
---|
135 | {
|
---|
136 | sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value ) ;
|
---|
137 | sHtml = FCKTools.ProcessLineBreaks( oEditor, FCKConfig, sHtml ) ;
|
---|
138 |
|
---|
139 | // FCK.InsertHtml() does not work for us, since document fragments cannot contain node fragments. :(
|
---|
140 | // Use the marker method instead. It's primitive, but it works.
|
---|
141 | var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ;
|
---|
142 | var oDoc = oEditor.FCK.EditorDocument ;
|
---|
143 | dialog.Selection.EnsureSelection() ;
|
---|
144 | range.MoveToSelection() ;
|
---|
145 | range.DeleteContents() ;
|
---|
146 | var marker = [] ;
|
---|
147 | for ( var i = 0 ; i < 5 ; i++ )
|
---|
148 | marker.push( parseInt(Math.random() * 100000, 10 ) ) ;
|
---|
149 | marker = marker.join( "" ) ;
|
---|
150 | range.InsertNode ( oDoc.createTextNode( marker ) ) ;
|
---|
151 | var bookmark = range.CreateBookmark() ;
|
---|
152 |
|
---|
153 | // Now we've got a marker indicating the paste position in the editor document.
|
---|
154 | // Find its position in the HTML code.
|
---|
155 | var htmlString = oDoc.body.innerHTML ;
|
---|
156 | var index = htmlString.indexOf( marker ) ;
|
---|
157 |
|
---|
158 | // Split it the HTML code up, add the code we generated, and put them back together.
|
---|
159 | var htmlList = [] ;
|
---|
160 | htmlList.push( htmlString.substr( 0, index ) ) ;
|
---|
161 | htmlList.push( sHtml ) ;
|
---|
162 | htmlList.push( htmlString.substr( index + marker.length ) ) ;
|
---|
163 | htmlString = htmlList.join( "" ) ;
|
---|
164 |
|
---|
165 | if ( oEditor.FCKBrowserInfo.IsIE )
|
---|
166 | oEditor.FCK.SetInnerHtml( htmlString ) ;
|
---|
167 | else
|
---|
168 | oDoc.body.innerHTML = htmlString ;
|
---|
169 |
|
---|
170 | range.MoveToBookmark( bookmark ) ;
|
---|
171 | range.Collapse( false ) ;
|
---|
172 | range.Select() ;
|
---|
173 | range.Release() ;
|
---|
174 | return true ;
|
---|
175 | }
|
---|
176 |
|
---|
177 | oEditor.FCK.InsertHtml( sHtml ) ;
|
---|
178 |
|
---|
179 | return true ;
|
---|
180 | }
|
---|
181 |
|
---|
182 | // This function will be called from the PasteFromWord dialog (fck_paste.html)
|
---|
183 | // Input: oNode a DOM node that contains the raw paste from the clipboard
|
---|
184 | // bIgnoreFont, bRemoveStyles booleans according to the values set in the dialog
|
---|
185 | // Output: the cleaned string
|
---|
186 | function CleanWord( oNode, bIgnoreFont, bRemoveStyles )
|
---|
187 | {
|
---|
188 | var html = oNode.innerHTML ;
|
---|
189 |
|
---|
190 | html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
|
---|
191 | html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, ' ') ;
|
---|
192 |
|
---|
193 | // Remove mso-xxx styles.
|
---|
194 | html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;
|
---|
195 |
|
---|
196 | // Remove margin styles.
|
---|
197 | html = html.replace( /\s*MARGIN: 0(?:cm|in) 0(?:cm|in) 0pt\s*;/gi, '' ) ;
|
---|
198 | html = html.replace( /\s*MARGIN: 0(?:cm|in) 0(?:cm|in) 0pt\s*"/gi, "\"" ) ;
|
---|
199 |
|
---|
200 | html = html.replace( /\s*TEXT-INDENT: 0(?:cm|in)\s*;/gi, '' ) ;
|
---|
201 | html = html.replace( /\s*TEXT-INDENT: 0(?:cm|in)\s*"/gi, "\"" ) ;
|
---|
202 |
|
---|
203 | html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
|
---|
204 |
|
---|
205 | html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
|
---|
206 |
|
---|
207 | html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
|
---|
208 |
|
---|
209 | html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
|
---|
210 | html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;
|
---|
211 |
|
---|
212 | // Remove FONT face attributes.
|
---|
213 | if ( bIgnoreFont )
|
---|
214 | {
|
---|
215 | html = html.replace( /\s*face="[^"]*"/gi, '' ) ;
|
---|
216 | html = html.replace( /\s*face=[^ >]*/gi, '' ) ;
|
---|
217 |
|
---|
218 | html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;
|
---|
219 | }
|
---|
220 |
|
---|
221 | // Remove Class attributes
|
---|
222 | html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
|
---|
223 |
|
---|
224 | // Remove styles.
|
---|
225 | if ( bRemoveStyles )
|
---|
226 | html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
|
---|
227 |
|
---|
228 | // Remove style, meta and link tags
|
---|
229 | html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' ) ;
|
---|
230 | html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' ) ;
|
---|
231 |
|
---|
232 | // Remove empty styles.
|
---|
233 | html = html.replace( /\s*style="\s*"/gi, '' ) ;
|
---|
234 |
|
---|
235 | html = html.replace( /<SPAN\s*[^>]*>\s* \s*<\/SPAN>/gi, ' ' ) ;
|
---|
236 |
|
---|
237 | html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
|
---|
238 |
|
---|
239 | // Remove Lang attributes
|
---|
240 | html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
|
---|
241 |
|
---|
242 | html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ;
|
---|
243 |
|
---|
244 | html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ;
|
---|
245 |
|
---|
246 | // Remove XML elements and declarations
|
---|
247 | html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
|
---|
248 |
|
---|
249 | // Remove w: tags with contents.
|
---|
250 | html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' ) ;
|
---|
251 |
|
---|
252 | // Remove Tags with XML namespace declarations: <o:p><\/o:p>
|
---|
253 | html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
|
---|
254 |
|
---|
255 | // Remove comments [SF BUG-1481861].
|
---|
256 | html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ;
|
---|
257 |
|
---|
258 | html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ;
|
---|
259 |
|
---|
260 | html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
|
---|
261 |
|
---|
262 | // Remove "display:none" tags.
|
---|
263 | html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ;
|
---|
264 |
|
---|
265 | // Remove language tags
|
---|
266 | html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3") ;
|
---|
267 |
|
---|
268 | // Remove onmouseover and onmouseout events (from MS Word comments effect)
|
---|
269 | html = html.replace( /<(\w[^>]*) onmouseover="([^\"]*)"([^>]*)/gi, "<$1$3") ;
|
---|
270 | html = html.replace( /<(\w[^>]*) onmouseout="([^\"]*)"([^>]*)/gi, "<$1$3") ;
|
---|
271 |
|
---|
272 | if ( FCKConfig.CleanWordKeepsStructure )
|
---|
273 | {
|
---|
274 | // The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
|
---|
275 | html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;
|
---|
276 |
|
---|
277 | // Word likes to insert extra <font> tags, when using MSIE. (Wierd).
|
---|
278 | html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );
|
---|
279 | html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );
|
---|
280 | }
|
---|
281 | else
|
---|
282 | {
|
---|
283 | html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
|
---|
284 | html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
|
---|
285 | html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
|
---|
286 | html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
|
---|
287 | html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
|
---|
288 | html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;
|
---|
289 |
|
---|
290 | html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;
|
---|
291 |
|
---|
292 | // Transform <P> to <DIV>
|
---|
293 | var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ; // Different because of a IE 5.0 error
|
---|
294 | html = html.replace( re, '<div$2<\/div>' ) ;
|
---|
295 |
|
---|
296 | // Remove empty tags (three times, just to be sure).
|
---|
297 | // This also removes any empty anchor
|
---|
298 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
|
---|
299 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
|
---|
300 | html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
|
---|
301 | }
|
---|
302 |
|
---|
303 | return html ;
|
---|
304 | }
|
---|
305 |
|
---|
306 | </script>
|
---|
307 |
|
---|
308 | </head>
|
---|
309 | <body style="overflow: hidden">
|
---|
310 | <table cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 98%">
|
---|
311 | <tr>
|
---|
312 | <td>
|
---|
313 | <div id="xSecurityMsg" style="display: none">
|
---|
314 | <span fcklang="DlgPasteSec">Because of your browser security settings,
|
---|
315 | the editor is not able to access your clipboard data directly. You are required
|
---|
316 | to paste it again in this window.</span><br />
|
---|
317 |
|
---|
318 | </div>
|
---|
319 | <div>
|
---|
320 | <span fcklang="DlgPasteMsg2">Please paste inside the following box using the keyboard
|
---|
321 | (<strong>Ctrl+V</strong>) and hit <strong>OK</strong>.</span><br />
|
---|
322 |
|
---|
323 | </div>
|
---|
324 | </td>
|
---|
325 | </tr>
|
---|
326 | <tr>
|
---|
327 | <td id="xFrameSpace" valign="top" height="100%" style="border: #000000 1px solid">
|
---|
328 | <textarea id="txtData" cols="80" rows="5" style="border: #000000 1px; display: none;
|
---|
329 | width: 99%; height: 98%"></textarea>
|
---|
330 | </td>
|
---|
331 | </tr>
|
---|
332 | <tr id="oWordCommands">
|
---|
333 | <td>
|
---|
334 |
|
---|
335 | <input id="chkRemoveFont" type="checkbox" checked="checked" />
|
---|
336 | <label for="chkRemoveFont" fcklang="DlgPasteIgnoreFont">
|
---|
337 | Ignore Font Face definitions</label>
|
---|
338 | <br />
|
---|
339 | <input id="chkRemoveStyles" type="checkbox" />
|
---|
340 | <label for="chkRemoveStyles" fcklang="DlgPasteRemoveStyles">
|
---|
341 | Remove Styles definitions</label>
|
---|
342 |
|
---|
343 | </td>
|
---|
344 | </tr>
|
---|
345 | </table>
|
---|
346 | </body>
|
---|
347 | </html>
|
---|