1 | /* |
---|
2 | * FCKeditor - The text editor for internet |
---|
3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
7 | * |
---|
8 | * For further information visit: |
---|
9 | * http://www.fckeditor.net/ |
---|
10 | * |
---|
11 | * "Support Open Source software. What about a donation today?" |
---|
12 | * |
---|
13 | * File Name: fckxhtmlentities.js |
---|
14 | * This file define the HTML entities handled by the editor. |
---|
15 | * |
---|
16 | * File Authors: |
---|
17 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
18 | */ |
---|
19 | |
---|
20 | var FCKXHtmlEntities = new Object() ; |
---|
21 | |
---|
22 | FCKXHtmlEntities.Initialize = function() |
---|
23 | { |
---|
24 | if ( FCKXHtmlEntities.Entities ) |
---|
25 | return ; |
---|
26 | |
---|
27 | var sChars = '' ; |
---|
28 | |
---|
29 | if ( FCKConfig.ProcessHTMLEntities ) |
---|
30 | { |
---|
31 | FCKXHtmlEntities.Entities = { |
---|
32 | // Latin-1 Entities |
---|
33 | ' ':'nbsp', |
---|
34 | '¡':'iexcl', |
---|
35 | '¢':'cent', |
---|
36 | '£':'pound', |
---|
37 | '¤':'curren', |
---|
38 | '¥':'yen', |
---|
39 | '¦':'brvbar', |
---|
40 | '§':'sect', |
---|
41 | '¨':'uml', |
---|
42 | '©':'copy', |
---|
43 | 'ª':'ordf', |
---|
44 | '«':'laquo', |
---|
45 | '¬':'not', |
---|
46 | '':'shy', |
---|
47 | '®':'reg', |
---|
48 | '¯':'macr', |
---|
49 | '°':'deg', |
---|
50 | '±':'plusmn', |
---|
51 | '²':'sup2', |
---|
52 | '³':'sup3', |
---|
53 | '´':'acute', |
---|
54 | 'µ':'micro', |
---|
55 | '¶':'para', |
---|
56 | '·':'middot', |
---|
57 | '¸':'cedil', |
---|
58 | '¹':'sup1', |
---|
59 | 'º':'ordm', |
---|
60 | '»':'raquo', |
---|
61 | '¼':'frac14', |
---|
62 | '½':'frac12', |
---|
63 | '¾':'frac34', |
---|
64 | '¿':'iquest', |
---|
65 | '×':'times', |
---|
66 | '÷':'divide', |
---|
67 | |
---|
68 | // Symbols |
---|
69 | |
---|
70 | 'ƒ':'fnof', |
---|
71 | '•':'bull', |
---|
72 | '…':'hellip', |
---|
73 | '′':'prime', |
---|
74 | '″':'Prime', |
---|
75 | '‾':'oline', |
---|
76 | '⁄':'frasl', |
---|
77 | '℘':'weierp', |
---|
78 | 'ℑ':'image', |
---|
79 | 'ℜ':'real', |
---|
80 | '™':'trade', |
---|
81 | 'ℵ':'alefsym', |
---|
82 | '←':'larr', |
---|
83 | '↑':'uarr', |
---|
84 | '→':'rarr', |
---|
85 | '↓':'darr', |
---|
86 | '↔':'harr', |
---|
87 | '↵':'crarr', |
---|
88 | '⇐':'lArr', |
---|
89 | '⇑':'uArr', |
---|
90 | '⇒':'rArr', |
---|
91 | '⇓':'dArr', |
---|
92 | '⇔':'hArr', |
---|
93 | '∀':'forall', |
---|
94 | '∂':'part', |
---|
95 | '∃':'exist', |
---|
96 | '∅':'empty', |
---|
97 | '∇':'nabla', |
---|
98 | '∈':'isin', |
---|
99 | '∉':'notin', |
---|
100 | '∋':'ni', |
---|
101 | '∏':'prod', |
---|
102 | '∑':'sum', |
---|
103 | '−':'minus', |
---|
104 | '∗':'lowast', |
---|
105 | '√':'radic', |
---|
106 | '∝':'prop', |
---|
107 | '∞':'infin', |
---|
108 | '∠':'ang', |
---|
109 | '∧':'and', |
---|
110 | '∨':'or', |
---|
111 | '∩':'cap', |
---|
112 | '∪':'cup', |
---|
113 | '∫':'int', |
---|
114 | '∴':'there4', |
---|
115 | '∼':'sim', |
---|
116 | '≅':'cong', |
---|
117 | '≈':'asymp', |
---|
118 | '≠':'ne', |
---|
119 | '≡':'equiv', |
---|
120 | '≤':'le', |
---|
121 | '≥':'ge', |
---|
122 | '⊂':'sub', |
---|
123 | '⊃':'sup', |
---|
124 | '⊄':'nsub', |
---|
125 | '⊆':'sube', |
---|
126 | '⊇':'supe', |
---|
127 | '⊕':'oplus', |
---|
128 | '⊗':'otimes', |
---|
129 | '⊥':'perp', |
---|
130 | '⋅':'sdot', |
---|
131 | '◊':'loz', |
---|
132 | '♠':'spades', |
---|
133 | '♣':'clubs', |
---|
134 | '♥':'hearts', |
---|
135 | '♦':'diams', |
---|
136 | |
---|
137 | // Other Special Characters |
---|
138 | |
---|
139 | '"':'quot', |
---|
140 | // '&':'amp', // This entity is automatically handled by the XHTML parser. |
---|
141 | // '<':'lt', // This entity is automatically handled by the XHTML parser. |
---|
142 | // '>':'gt', // This entity is automatically handled by the XHTML parser. |
---|
143 | 'ˆ':'circ', |
---|
144 | '˜':'tilde', |
---|
145 | ' ':'ensp', |
---|
146 | ' ':'emsp', |
---|
147 | ' ':'thinsp', |
---|
148 | '':'zwnj', |
---|
149 | '':'zwj', |
---|
150 | '':'lrm', |
---|
151 | '':'rlm', |
---|
152 | '–':'ndash', |
---|
153 | '—':'mdash', |
---|
154 | '‘':'lsquo', |
---|
155 | '’':'rsquo', |
---|
156 | '‚':'sbquo', |
---|
157 | '“':'ldquo', |
---|
158 | '”':'rdquo', |
---|
159 | '„':'bdquo', |
---|
160 | '†':'dagger', |
---|
161 | '‡':'Dagger', |
---|
162 | '‰':'permil', |
---|
163 | '‹':'lsaquo', |
---|
164 | '›':'rsaquo', |
---|
165 | '€':'euro' |
---|
166 | } ; |
---|
167 | |
---|
168 | // Process Base Entities. |
---|
169 | for ( var e in FCKXHtmlEntities.Entities ) |
---|
170 | sChars += e ; |
---|
171 | |
---|
172 | // Include Latin Letters Entities. |
---|
173 | if ( FCKConfig.IncludeLatinEntities ) |
---|
174 | { |
---|
175 | var oEntities = { |
---|
176 | 'À':'Agrave', |
---|
177 | 'Á':'Aacute', |
---|
178 | 'Â':'Acirc', |
---|
179 | 'Ã':'Atilde', |
---|
180 | 'Ä':'Auml', |
---|
181 | 'Å':'Aring', |
---|
182 | 'Æ':'AElig', |
---|
183 | 'Ç':'Ccedil', |
---|
184 | 'È':'Egrave', |
---|
185 | 'É':'Eacute', |
---|
186 | 'Ê':'Ecirc', |
---|
187 | 'Ë':'Euml', |
---|
188 | 'Ì':'Igrave', |
---|
189 | 'Í':'Iacute', |
---|
190 | 'Î':'Icirc', |
---|
191 | 'Ï':'Iuml', |
---|
192 | 'Ð':'ETH', |
---|
193 | 'Ñ':'Ntilde', |
---|
194 | 'Ò':'Ograve', |
---|
195 | 'Ó':'Oacute', |
---|
196 | 'Ô':'Ocirc', |
---|
197 | 'Õ':'Otilde', |
---|
198 | 'Ö':'Ouml', |
---|
199 | 'Ø':'Oslash', |
---|
200 | 'Ù':'Ugrave', |
---|
201 | 'Ú':'Uacute', |
---|
202 | 'Û':'Ucirc', |
---|
203 | 'Ü':'Uuml', |
---|
204 | 'Ý':'Yacute', |
---|
205 | 'Þ':'THORN', |
---|
206 | 'ß':'szlig', |
---|
207 | 'à':'agrave', |
---|
208 | 'á':'aacute', |
---|
209 | 'â':'acirc', |
---|
210 | 'ã':'atilde', |
---|
211 | 'ä':'auml', |
---|
212 | 'å':'aring', |
---|
213 | 'æ':'aelig', |
---|
214 | 'ç':'ccedil', |
---|
215 | 'è':'egrave', |
---|
216 | 'é':'eacute', |
---|
217 | 'ê':'ecirc', |
---|
218 | 'ë':'euml', |
---|
219 | 'ì':'igrave', |
---|
220 | 'í':'iacute', |
---|
221 | 'î':'icirc', |
---|
222 | 'ï':'iuml', |
---|
223 | 'ð':'eth', |
---|
224 | 'ñ':'ntilde', |
---|
225 | 'ò':'ograve', |
---|
226 | 'ó':'oacute', |
---|
227 | 'ô':'ocirc', |
---|
228 | 'õ':'otilde', |
---|
229 | 'ö':'ouml', |
---|
230 | 'ø':'oslash', |
---|
231 | 'ù':'ugrave', |
---|
232 | 'ú':'uacute', |
---|
233 | 'û':'ucirc', |
---|
234 | 'ü':'uuml', |
---|
235 | 'ý':'yacute', |
---|
236 | 'þ':'thorn', |
---|
237 | 'ÿ':'yuml', |
---|
238 | 'Œ':'OElig', |
---|
239 | 'œ':'oelig', |
---|
240 | 'Š':'Scaron', |
---|
241 | 'š':'scaron', |
---|
242 | 'Ÿ':'Yuml' |
---|
243 | } ; |
---|
244 | |
---|
245 | for ( var e in oEntities ) |
---|
246 | { |
---|
247 | FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ; |
---|
248 | sChars += e ; |
---|
249 | } |
---|
250 | |
---|
251 | oEntities = null ; |
---|
252 | } |
---|
253 | |
---|
254 | // Include Greek Letters Entities. |
---|
255 | if ( FCKConfig.IncludeGreekEntities ) |
---|
256 | { |
---|
257 | var oEntities = { |
---|
258 | 'Α':'Alpha', |
---|
259 | 'Β':'Beta', |
---|
260 | 'Γ':'Gamma', |
---|
261 | 'Δ':'Delta', |
---|
262 | 'Ε':'Epsilon', |
---|
263 | 'Ζ':'Zeta', |
---|
264 | 'Η':'Eta', |
---|
265 | 'Θ':'Theta', |
---|
266 | 'Ι':'Iota', |
---|
267 | 'Κ':'Kappa', |
---|
268 | 'Λ':'Lambda', |
---|
269 | 'Μ':'Mu', |
---|
270 | 'Ν':'Nu', |
---|
271 | 'Ξ':'Xi', |
---|
272 | 'Ο':'Omicron', |
---|
273 | 'Π':'Pi', |
---|
274 | 'Ρ':'Rho', |
---|
275 | 'Σ':'Sigma', |
---|
276 | 'Τ':'Tau', |
---|
277 | 'Υ':'Upsilon', |
---|
278 | 'Φ':'Phi', |
---|
279 | 'Χ':'Chi', |
---|
280 | 'Ψ':'Psi', |
---|
281 | 'Ω':'Omega', |
---|
282 | 'α':'alpha', |
---|
283 | 'β':'beta', |
---|
284 | 'γ':'gamma', |
---|
285 | 'δ':'delta', |
---|
286 | 'ε':'epsilon', |
---|
287 | 'ζ':'zeta', |
---|
288 | 'η':'eta', |
---|
289 | 'θ':'theta', |
---|
290 | 'ι':'iota', |
---|
291 | 'κ':'kappa', |
---|
292 | 'λ':'lambda', |
---|
293 | 'μ':'mu', |
---|
294 | 'ν':'nu', |
---|
295 | 'ξ':'xi', |
---|
296 | 'ο':'omicron', |
---|
297 | 'π':'pi', |
---|
298 | 'ρ':'rho', |
---|
299 | 'ς':'sigmaf', |
---|
300 | 'σ':'sigma', |
---|
301 | 'τ':'tau', |
---|
302 | 'υ':'upsilon', |
---|
303 | 'φ':'phi', |
---|
304 | 'χ':'chi', |
---|
305 | 'ψ':'psi', |
---|
306 | 'ω':'omega' |
---|
307 | } ; |
---|
308 | |
---|
309 | for ( var e in oEntities ) |
---|
310 | { |
---|
311 | FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ; |
---|
312 | sChars += e ; |
---|
313 | } |
---|
314 | |
---|
315 | oEntities = null ; |
---|
316 | } |
---|
317 | } |
---|
318 | else |
---|
319 | { |
---|
320 | FCKXHtmlEntities.Entities = {} ; |
---|
321 | |
---|
322 | // Even if we are not processing the entities, we must render the |
---|
323 | // correctly. As we don't want HTML entities, let's use its numeric |
---|
324 | // representation ( ). |
---|
325 | sChars = ' ' ; |
---|
326 | } |
---|
327 | |
---|
328 | // Create the Regex used to find entities in the text. |
---|
329 | var sRegexPattern = '[' + sChars + ']' ; |
---|
330 | |
---|
331 | if ( FCKConfig.ProcessNumericEntities ) |
---|
332 | sRegexPattern = '[^ -~]|' + sRegexPattern ; |
---|
333 | |
---|
334 | var sAdditional = FCKConfig.AdditionalNumericEntities ; |
---|
335 | |
---|
336 | if ( sAdditional || sAdditional.length > 0 ) |
---|
337 | sRegexPattern += '|' + FCKConfig.AdditionalNumericEntities ; |
---|
338 | |
---|
339 | FCKXHtmlEntities.EntitiesRegex = new RegExp( sRegexPattern, 'g' ) ; |
---|
340 | } |
---|