1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
\r
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
\r
6 * == BEGIN LICENSE ==
\r
8 * Licensed under the terms of any of the following licenses at your
\r
11 * - GNU General Public License Version 2 or later (the "GPL")
\r
12 * http://www.gnu.org/licenses/gpl.html
\r
14 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
15 * http://www.gnu.org/licenses/lgpl.html
\r
17 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
18 * http://www.mozilla.org/MPL/MPL-1.1.html
\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
26 <html xmlns="http://www.w3.org/1999/xhtml">
\r
29 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
30 <meta name="robots" content="noindex, nofollow" />
\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
38 window.onload = function ()
\r
40 // First of all, translate the dialog box texts
\r
41 oEditor.FCKLanguageManager.TranslatePage(document) ;
\r
43 var sPastingType = window.parent.dialogArguments.CustomValue ;
\r
45 if ( sPastingType == 'Word' || sPastingType == 'Security' )
\r
47 if ( sPastingType == 'Security' )
\r
48 document.getElementById( 'xSecurityMsg' ).style.display = '' ;
\r
50 var oFrame = document.getElementById('frmData') ;
\r
51 oFrame.style.display = '' ;
\r
53 if ( oFrame.contentDocument )
\r
54 oFrame.contentDocument.designMode = 'on' ;
\r
56 oFrame.contentWindow.document.body.contentEditable = true ;
\r
60 document.getElementById('txtData').style.display = '' ;
\r
63 if ( sPastingType != 'Word' )
\r
64 document.getElementById('oWordCommands').style.display = 'none' ;
\r
66 window.parent.SetOkButton( true ) ;
\r
67 window.parent.SetAutoSize( true ) ;
\r
74 var sPastingType = window.parent.dialogArguments.CustomValue ;
\r
76 if ( sPastingType == 'Word' || sPastingType == 'Security' )
\r
78 var oFrame = document.getElementById('frmData') ;
\r
81 if ( oFrame.contentDocument )
\r
82 oBody = oFrame.contentDocument.body ;
\r
84 oBody = oFrame.contentWindow.document.body ;
\r
86 if ( sPastingType == 'Word' )
\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
92 sHtml = CleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;
\r
95 sHtml = oBody.innerHTML ;
\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
103 sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value ) ;
\r
104 sHtml = sHtml.replace( /\n/g, '<BR>' ) ;
\r
107 oEditor.FCK.InsertHtml( sHtml ) ;
\r
112 function CleanUpBox()
\r
114 var oFrame = document.getElementById('frmData') ;
\r
116 if ( oFrame.contentDocument )
\r
117 oFrame.contentDocument.body.innerHTML = '' ;
\r
119 oFrame.contentWindow.document.body.innerHTML = '' ;
\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
129 var html = oNode.innerHTML ;
\r
131 html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
\r
132 html = html.replace(/<o:p>.*?<\/o:p>/g, ' ') ;
\r
134 // Remove mso-xxx styles.
\r
135 html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;
\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
141 html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;
\r
142 html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
\r
144 html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
\r
146 html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
\r
148 html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
\r
150 html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
\r
151 html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;
\r
153 // Remove FONT face attributes.
\r
156 html = html.replace( /\s*face="[^"]*"/gi, '' ) ;
\r
157 html = html.replace( /\s*face=[^ >]*/gi, '' ) ;
\r
159 html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;
\r
162 // Remove Class attributes
\r
163 html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
\r
166 if ( bRemoveStyles )
\r
167 html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
\r
169 // Remove empty styles.
\r
170 html = html.replace( /\s*style="\s*"/gi, '' ) ;
\r
172 html = html.replace( /<SPAN\s*[^>]*>\s* \s*<\/SPAN>/gi, ' ' ) ;
\r
174 html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
\r
176 // Remove Lang attributes
\r
177 html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
\r
179 html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
\r
181 html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
\r
183 // Remove XML elements and declarations
\r
184 html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
\r
186 // Remove Tags with XML namespace declarations: <o:p><\/o:p>
\r
187 html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
\r
189 // Remove comments [SF BUG-1481861].
\r
190 html = html.replace(/<\!--.*-->/g, '' ) ;
\r
192 html = html.replace( /<(U|I|STRIKE)> <\/\1>/g, ' ' ) ;
\r
194 html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
\r
196 // Remove "display:none" tags.
\r
197 html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ;
\r
199 if ( FCKConfig.CleanWordKeepsStructure )
\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
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
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
217 html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;
\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
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
236 <body style="overflow: hidden">
\r
237 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 98%">
\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
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
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
263 <tr id="oWordCommands">
\r
265 <table border="0" cellpadding="0" cellspacing="0" width="100%">
\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
272 <input id="chkRemoveStyles" type="checkbox" />
\r
273 <label for="chkRemoveStyles" fcklang="DlgPasteRemoveStyles">
\r
274 Remove Styles definitions</label>
\r
276 <td align="right" valign="top">
\r
277 <input type="button" fcklang="DlgPasteCleanBox" value="Clean Up Box" onclick="CleanUpBox()" />
\r