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