/source/Plug-in/fck/editor/_source/internals/fckxhtmlentities.js

http://prosporous.googlecode.com/ · JavaScript · 354 lines · 321 code · 8 blank · 25 comment · 2 complexity · 4e8b85bc72839f24390a8a2d230890df MD5 · raw file

  1. /*
  2. * FCKeditor - The text editor for Internet - http://www.fckeditor.net
  3. * Copyright (C) 2003-2007 Frederico Caldeira Knabben
  4. *
  5. * == BEGIN LICENSE ==
  6. *
  7. * Licensed under the terms of any of the following licenses at your
  8. * choice:
  9. *
  10. * - GNU General Public License Version 2 or later (the "GPL")
  11. * http://www.gnu.org/licenses/gpl.html
  12. *
  13. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14. * http://www.gnu.org/licenses/lgpl.html
  15. *
  16. * - Mozilla Public License Version 1.1 or later (the "MPL")
  17. * http://www.mozilla.org/MPL/MPL-1.1.html
  18. *
  19. * == END LICENSE ==
  20. *
  21. * This file define the HTML entities handled by the editor.
  22. */
  23. var FCKXHtmlEntities = new Object() ;
  24. FCKXHtmlEntities.Initialize = function()
  25. {
  26. if ( FCKXHtmlEntities.Entities )
  27. return ;
  28. var sChars = '' ;
  29. var oEntities, e ;
  30. if ( FCKConfig.ProcessHTMLEntities )
  31. {
  32. FCKXHtmlEntities.Entities = {
  33. // Latin-1 Entities
  34. ' ':'nbsp',
  35. 'Ą':'iexcl',
  36. '˘':'cent',
  37. 'Ł':'pound',
  38. '¤':'curren',
  39. 'Ľ':'yen',
  40. 'Ś':'brvbar',
  41. '§':'sect',
  42. '¨':'uml',
  43. 'Š':'copy',
  44. 'Ş':'ordf',
  45. 'Ť':'laquo',
  46. 'Ź':'not',
  47. '­':'shy',
  48. 'Ž':'reg',
  49. 'Ż':'macr',
  50. '°':'deg',
  51. 'ą':'plusmn',
  52. '˛':'sup2',
  53. 'ł':'sup3',
  54. '´':'acute',
  55. 'ľ':'micro',
  56. 'ś':'para',
  57. 'ˇ':'middot',
  58. '¸':'cedil',
  59. 'š':'sup1',
  60. 'ş':'ordm',
  61. 'ť':'raquo',
  62. 'ź':'frac14',
  63. '˝':'frac12',
  64. 'ž':'frac34',
  65. 'ż':'iquest',
  66. '×':'times',
  67. '÷':'divide',
  68. // Symbols
  69. 'ƒ':'fnof',
  70. '•':'bull',
  71. '…':'hellip',
  72. '?':'prime',
  73. '?':'Prime',
  74. '?':'oline',
  75. '?':'frasl',
  76. '?':'weierp',
  77. '?':'image',
  78. '?':'real',
  79. '™':'trade',
  80. '?':'alefsym',
  81. '?':'larr',
  82. '?':'uarr',
  83. '?':'rarr',
  84. '?':'darr',
  85. '?':'harr',
  86. '?':'crarr',
  87. '?':'lArr',
  88. '?':'uArr',
  89. '?':'rArr',
  90. '?':'dArr',
  91. '?':'hArr',
  92. '?':'forall',
  93. '?':'part',
  94. '?':'exist',
  95. '?':'empty',
  96. '?':'nabla',
  97. '?':'isin',
  98. '?':'notin',
  99. '?':'ni',
  100. '?':'prod',
  101. '?':'sum',
  102. '?':'minus',
  103. '?':'lowast',
  104. '?':'radic',
  105. '?':'prop',
  106. '?':'infin',
  107. '?':'ang',
  108. '?':'and',
  109. '?':'or',
  110. '?':'cap',
  111. '?':'cup',
  112. '?':'int',
  113. '?':'there4',
  114. '?':'sim',
  115. '?':'cong',
  116. '?':'asymp',
  117. '?':'ne',
  118. '?':'equiv',
  119. '?':'le',
  120. '?':'ge',
  121. '?':'sub',
  122. '?':'sup',
  123. '?':'nsub',
  124. '?':'sube',
  125. '?':'supe',
  126. '?':'oplus',
  127. '?':'otimes',
  128. '?':'perp',
  129. '?':'sdot',
  130. '\u2308':'lceil',
  131. '\u2309':'rceil',
  132. '\u230a':'lfloor',
  133. '\u230b':'rfloor',
  134. '\u2329':'lang',
  135. '\u232a':'rang',
  136. '?':'loz',
  137. '?':'spades',
  138. '?':'clubs',
  139. '?':'hearts',
  140. '?':'diams',
  141. // Other Special Characters
  142. '"':'quot',
  143. // '&':'amp', // This entity is automatically handled by the XHTML parser.
  144. // '<':'lt', // This entity is automatically handled by the XHTML parser.
  145. // '>':'gt', // This entity is automatically handled by the XHTML parser.
  146. 'ˆ':'circ',
  147. '˜':'tilde',
  148. '?':'ensp',
  149. '?':'emsp',
  150. '?':'thinsp',
  151. '?':'zwnj',
  152. '?':'zwj',
  153. '?':'lrm',
  154. '?':'rlm',
  155. '–':'ndash',
  156. '—':'mdash',
  157. '‘':'lsquo',
  158. '’':'rsquo',
  159. '‚':'sbquo',
  160. '“':'ldquo',
  161. '”':'rdquo',
  162. '„':'bdquo',
  163. '†':'dagger',
  164. '‡':'Dagger',
  165. '‰':'permil',
  166. '‹':'lsaquo',
  167. '›':'rsaquo',
  168. '€':'euro'
  169. } ;
  170. // Process Base Entities.
  171. for ( e in FCKXHtmlEntities.Entities )
  172. sChars += e ;
  173. // Include Latin Letters Entities.
  174. if ( FCKConfig.IncludeLatinEntities )
  175. {
  176. oEntities = {
  177. 'Ŕ':'Agrave',
  178. 'Á':'Aacute',
  179. 'Â':'Acirc',
  180. 'Ă':'Atilde',
  181. 'Ä':'Auml',
  182. 'Ĺ':'Aring',
  183. 'Ć':'AElig',
  184. 'Ç':'Ccedil',
  185. 'Č':'Egrave',
  186. 'É':'Eacute',
  187. 'Ę':'Ecirc',
  188. 'Ë':'Euml',
  189. 'Ě':'Igrave',
  190. 'Í':'Iacute',
  191. 'Î':'Icirc',
  192. 'Ď':'Iuml',
  193. 'Đ':'ETH',
  194. 'Ń':'Ntilde',
  195. 'Ň':'Ograve',
  196. 'Ó':'Oacute',
  197. 'Ô':'Ocirc',
  198. 'Ő':'Otilde',
  199. 'Ö':'Ouml',
  200. 'Ř':'Oslash',
  201. 'Ů':'Ugrave',
  202. 'Ú':'Uacute',
  203. 'Ű':'Ucirc',
  204. 'Ü':'Uuml',
  205. 'Ý':'Yacute',
  206. 'Ţ':'THORN',
  207. 'ß':'szlig',
  208. 'ŕ':'agrave',
  209. 'á':'aacute',
  210. 'â':'acirc',
  211. 'ă':'atilde',
  212. 'ä':'auml',
  213. 'ĺ':'aring',
  214. 'ć':'aelig',
  215. 'ç':'ccedil',
  216. 'č':'egrave',
  217. 'é':'eacute',
  218. 'ę':'ecirc',
  219. 'ë':'euml',
  220. 'ě':'igrave',
  221. 'í':'iacute',
  222. 'î':'icirc',
  223. 'ď':'iuml',
  224. 'đ':'eth',
  225. 'ń':'ntilde',
  226. 'ň':'ograve',
  227. 'ó':'oacute',
  228. 'ô':'ocirc',
  229. 'ő':'otilde',
  230. 'ö':'ouml',
  231. 'ř':'oslash',
  232. 'ů':'ugrave',
  233. 'ú':'uacute',
  234. 'ű':'ucirc',
  235. 'ü':'uuml',
  236. 'ý':'yacute',
  237. 'ţ':'thorn',
  238. '˙':'yuml',
  239. 'Œ':'OElig',
  240. 'œ':'oelig',
  241. 'Š':'Scaron',
  242. 'š':'scaron',
  243. 'Ÿ':'Yuml'
  244. } ;
  245. for ( e in oEntities )
  246. {
  247. FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
  248. sChars += e ;
  249. }
  250. oEntities = null ;
  251. }
  252. // Include Greek Letters Entities.
  253. if ( FCKConfig.IncludeGreekEntities )
  254. {
  255. oEntities = {
  256. '?':'Alpha',
  257. '?':'Beta',
  258. '?':'Gamma',
  259. '?':'Delta',
  260. '?':'Epsilon',
  261. '?':'Zeta',
  262. '?':'Eta',
  263. '?':'Theta',
  264. '?':'Iota',
  265. '?':'Kappa',
  266. '?':'Lambda',
  267. '?':'Mu',
  268. '?':'Nu',
  269. '?':'Xi',
  270. '?':'Omicron',
  271. '?':'Pi',
  272. '?':'Rho',
  273. '?':'Sigma',
  274. '?':'Tau',
  275. '?':'Upsilon',
  276. '?':'Phi',
  277. '?':'Chi',
  278. '?':'Psi',
  279. '?':'Omega',
  280. '?':'alpha',
  281. '?':'beta',
  282. '?':'gamma',
  283. '?':'delta',
  284. '?':'epsilon',
  285. '?':'zeta',
  286. '?':'eta',
  287. '?':'theta',
  288. '?':'iota',
  289. '?':'kappa',
  290. '?':'lambda',
  291. '?':'mu',
  292. '?':'nu',
  293. '?':'xi',
  294. '?':'omicron',
  295. '?':'pi',
  296. '?':'rho',
  297. '?':'sigmaf',
  298. '?':'sigma',
  299. '?':'tau',
  300. '?':'upsilon',
  301. '?':'phi',
  302. '?':'chi',
  303. '?':'psi',
  304. '?':'omega',
  305. '\u03d1':'thetasym',
  306. '\u03d2':'upsih',
  307. '\u03d6':'piv'
  308. } ;
  309. for ( e in oEntities )
  310. {
  311. FCKXHtmlEntities.Entities[ e ] = oEntities[ e ] ;
  312. sChars += e ;
  313. }
  314. oEntities = null ;
  315. }
  316. }
  317. else
  318. {
  319. FCKXHtmlEntities.Entities = {} ;
  320. // Even if we are not processing the entities, we must render the &nbsp;
  321. // correctly. As we don't want HTML entities, let's use its numeric
  322. // representation (&#160).
  323. sChars = ' ' ;
  324. }
  325. // Create the Regex used to find entities in the text.
  326. var sRegexPattern = '[' + sChars + ']' ;
  327. if ( FCKConfig.ProcessNumericEntities )
  328. sRegexPattern = '[^ -~]|' + sRegexPattern ;
  329. var sAdditional = FCKConfig.AdditionalNumericEntities ;
  330. if ( sAdditional && sAdditional.length > 0 )
  331. sRegexPattern += '|' + FCKConfig.AdditionalNumericEntities ;
  332. FCKXHtmlEntities.EntitiesRegex = new RegExp( sRegexPattern, 'g' ) ;
  333. }