~alexharrington/xibo/pyclient-1.1.0a22

« back to all changes in this revision

Viewing changes to server/3rdparty/fckeditor/editor/dialog/fck_paste.html

  • Committer: Alex Harrington
  • Date: 2009-12-31 11:38:50 UTC
  • Revision ID: alex@longhill.org.uk-20091231113850-bz5flhqq2gsw0qxf
Converted to 2.0 repo format and fixed lineendings

Show diffs side-by-side

added added

removed removed

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