Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<!--
3
 * FCKeditor - The text editor for internet
4
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
 *
6
 * Licensed under the terms of the GNU Lesser General Public License:
7
 * 		http://www.opensource.org/licenses/lgpl-license.php
8
 *
9
 * For further information visit:
10
 * 		http://www.fckeditor.net/
11
 *
12
 * File Name: fck_paste.html
13
 * 	This dialog is shown when, for some reason (usually security settings),
14
 * 	the user is not able to paste data from the clipboard to the editor using
15
 * 	the toolbar buttons or the context menu.
16
 *
17
 * File Authors:
18
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
19
-->
20
<html>
21
	<head>
22
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23
		<meta name="robots" content="noindex, nofollow">
24
		<script language="javascript">
25
var oEditor = window.parent.InnerDialogLoaded() ;
26
 
27
window.onload = function ()
28
{
29
	// First of all, translate the dialog box texts
30
	oEditor.FCKLanguageManager.TranslatePage(document) ;
31
 
32
	window.parent.SetOkButton( true ) ;
33
 
34
	if ( window.parent.dialogArguments.CustomValue == 'Word' )
35
	{
36
		var oFrame = document.getElementById('frmData')
37
		oFrame.style.display = '' ;
38
 
39
		if ( oFrame.contentDocument )
40
			oFrame.contentDocument.designMode = 'on' ;
41
		else
42
			oFrame.contentWindow.document.body.contentEditable = true ;
43
	}
44
	else
45
	{
46
		document.getElementById('txtData').style.display = '' ;
47
		document.getElementById('oWordCommands').style.display = 'none' ;
48
	}
49
}
50
 
51
function Ok()
52
{
53
	var sHtml ;
54
 
55
	if ( window.parent.dialogArguments.CustomValue == 'Word' )
56
	{
57
		var oFrame = document.getElementById('frmData') ;
58
 
59
		if ( oFrame.contentDocument )
60
			sHtml = oFrame.contentDocument.body.innerHTML ;
61
		else
62
			sHtml = oFrame.contentWindow.document.body.innerHTML ;
63
 
64
		sHtml = CleanWord( sHtml ) ;
65
	}
66
	else
67
	{
68
		var sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value )  ;
69
		sHtml = sHtml.replace( /\n/g, '<BR>' ) ;
70
	}
71
 
72
	oEditor.FCK.InsertHtml( sHtml ) ;
73
 
74
	return true ;
75
}
76
 
77
function CleanUpBox()
78
{
79
	var oFrame = document.getElementById('frmData') ;
80
 
81
	if ( oFrame.contentDocument )
82
		oFrame.contentDocument.body.innerHTML = '' ;
83
	else
84
		oFrame.contentWindow.document.body.innerHTML = '' ;
85
}
86
 
87
function CleanWord( html )
88
{
89
	var bIgnoreFont = document.getElementById('chkRemoveFont').checked ;
90
	var bRemoveStyles = document.getElementById('chkRemoveStyles').checked ;
91
 
92
	html = html.replace(/<o:p>\s*<\/o:p>/g, "") ;
93
	html = html.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
94
 
95
	// Remove mso-xxx styles.
96
	html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
97
 
98
	// Remove margin styles.
99
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
100
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
101
 
102
	html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
103
	html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
104
 
105
	html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
106
 
107
	html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
108
 
109
	html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
110
 
111
	html = html.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
112
	html = html.replace( /\s*tab-stops:[^"]*/gi, "" ) ;
113
 
114
	// Remove FONT face attributes.
115
	if ( bIgnoreFont )
116
	{
117
		html = html.replace( /\s*face="[^"]*"/gi, "" ) ;
118
		html = html.replace( /\s*face=[^ >]*/gi, "" ) ;
119
 
120
		html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
121
	}
122
 
123
	// Remove Class attributes
124
	html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
125
 
126
	// Remove styles.
127
	if ( bRemoveStyles )
128
		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
129
 
130
	// Remove empty styles.
131
	html =  html.replace( /\s*style="\s*"/gi, '' ) ;
132
 
133
	html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
134
 
135
	html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
136
 
137
	// Remove Lang attributes
138
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
139
 
140
	html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
141
 
142
	html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
143
 
144
	// Remove XML elements and declarations
145
	html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
146
 
147
	// Remove Tags with XML namespace declarations: <o:p></o:p>
148
	html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
149
 
150
	html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
151
 
152
	html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
153
	html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
154
	html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
155
	html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
156
	html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
157
	html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;
158
 
159
	html = html.replace( /<\/H\d>/gi, '</font></b></div>' ) ;
160
 
161
	html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
162
 
163
	// Remove empty tags (three times, just to be sure).
164
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
165
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
166
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
167
 
168
	// Transform <P> to <DIV>
169
	var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;	// Different because of a IE 5.0 error
170
	html = html.replace( re, "<div$2</div>" ) ;
171
 
172
	return html ;
173
}
174
 
175
		</script>
176
	</head>
177
	<body scroll="no" style="OVERFLOW: hidden">
178
		<table height="98%" cellspacing="0" cellpadding="0" width="100%" border="0">
179
			<tr>
180
				<td>
181
					<span fckLang="DlgPasteMsg2">Please paste inside the following box using the
182
						keyboard (<STRONG>Ctrl+V</STRONG>) and hit <STRONG>OK</STRONG>.</span>
183
					<br>
184
					&nbsp;
185
				</td>
186
			</tr>
187
			<tr>
188
				<td valign="top" height="100%" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid">
189
					<textarea id="txtData" style="BORDER-RIGHT: #000000 1px; BORDER-TOP: #000000 1px; DISPLAY: none; BORDER-LEFT: #000000 1px; WIDTH: 99%; BORDER-BOTTOM: #000000 1px; HEIGHT: 98%"></textarea>
190
					<iframe id="frmData" src="../fckblank.html" height="98%" width="99%" frameborder="no" style="BORDER-RIGHT: #000000 1px; BORDER-TOP: #000000 1px; DISPLAY: none; BORDER-LEFT: #000000 1px; BORDER-BOTTOM: #000000 1px; BACKGROUND-COLOR: #ffffff">
191
					</iframe>
192
				</td>
193
			</tr>
194
			<tr id="oWordCommands">
195
				<td>
196
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
197
						<tr>
198
							<td nowrap>
199
								<input id="chkRemoveFont" type="checkbox" checked="checked"> <label for="chkRemoveFont" fckLang="DlgPasteIgnoreFont">
200
									Ignore Font Face definitions</label>
201
								<br>
202
								<input id="chkRemoveStyles" type="checkbox"> <label for="chkRemoveStyles" fckLang="DlgPasteRemoveStyles">
203
									Remove Styles definitions</label>
204
							</td>
205
							<td align="right" valign="top">
206
								<input type="button" fckLang="DlgPasteCleanBox" value="Clean Up Box" onclick="CleanUpBox()">
207
							</td>
208
						</tr>
209
					</table>
210
				</td>
211
			</tr>
212
		</table>
213
	</body>
214
</html>