glebtv-ckeditor 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (348) hide show
  1. data/Rakefile +63 -62
  2. data/app/assets/stylesheets/ckcontent.css +0 -0
  3. data/lib/ckeditor.rb +4 -3
  4. data/lib/ckeditor/engine.rb +1 -1
  5. data/lib/ckeditor/version.rb +2 -2
  6. data/vendor/assets/javascripts/ckeditor/CHANGES.md +27 -1
  7. data/vendor/assets/javascripts/ckeditor/README.md +1 -1
  8. data/vendor/assets/javascripts/ckeditor/build-config.js +10 -89
  9. data/vendor/assets/javascripts/ckeditor/ckeditor.js +286 -329
  10. data/vendor/assets/javascripts/ckeditor/config.js.erb +3 -8
  11. data/vendor/assets/javascripts/ckeditor/lang/en.js +1 -1
  12. data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
  13. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/ckcss.png +0 -0
  14. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cs.js +2 -2
  15. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cy.js +1 -1
  16. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fa.js +1 -1
  17. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/km.js +9 -0
  18. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ku.js +6 -6
  19. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/nl.js +2 -2
  20. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pl.js +6 -5
  21. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pt-br.js +1 -1
  22. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sv.js +2 -2
  23. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/th.js +9 -0
  24. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/vi.js +2 -2
  25. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.ckeditor.css +74 -0
  26. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.css +16 -10
  27. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.min.css +1 -0
  28. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/AutoFormat.png +0 -0
  29. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/CommentSelectedRange.png +0 -0
  30. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/icons/UncommentSelectedRange.png +0 -0
  31. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/dialog}/dialog.js +76 -75
  32. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/closebrackets.js +29 -0
  33. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/edit}/closetag.js +86 -85
  34. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/edit}/continuelist.js +28 -28
  35. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/edit}/matchbrackets.js +74 -63
  36. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/foldcode}/foldcode.js +183 -182
  37. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/format/autoFormatAll.js +43 -0
  38. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/format}/formatting.js +114 -108
  39. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/match-highlighter.js +60 -0
  40. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/search}/search.js +131 -119
  41. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/{util → addon/search}/searchcursor.js +131 -119
  42. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.min.js +1 -0
  43. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.js +5384 -4553
  44. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.min.js +1 -0
  45. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.modes.min.js +1 -0
  46. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.search-addons.min.js +1 -0
  47. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/css.js +465 -465
  48. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/htmlmixed.js +104 -84
  49. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/javascript.js +426 -411
  50. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/xml.js +324 -324
  51. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/af.js +4 -1
  52. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ar.js +4 -1
  53. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bg.js +4 -1
  54. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bn.js +4 -1
  55. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bs.js +4 -1
  56. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ca.js +4 -1
  57. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cs.js +4 -1
  58. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cy.js +4 -1
  59. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/da.js +4 -1
  60. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/de.js +4 -1
  61. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/el.js +4 -1
  62. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-au.js +4 -1
  63. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-ca.js +4 -1
  64. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-gb.js +4 -1
  65. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en.js +4 -1
  66. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eo.js +4 -1
  67. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/es.js +4 -1
  68. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/et.js +4 -1
  69. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eu.js +4 -1
  70. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fa.js +4 -1
  71. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fi.js +4 -1
  72. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fo.js +4 -1
  73. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr-ca.js +4 -1
  74. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr.js +4 -1
  75. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gl.js +4 -1
  76. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gu.js +4 -1
  77. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/he.js +4 -1
  78. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hi.js +4 -1
  79. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hr.js +4 -1
  80. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hu.js +4 -1
  81. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/is.js +4 -1
  82. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/it.js +4 -1
  83. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ja.js +4 -1
  84. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ka.js +4 -1
  85. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/km.js +4 -1
  86. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ko.js +4 -1
  87. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ku.js +4 -1
  88. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lt.js +4 -1
  89. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lv.js +4 -1
  90. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mk.js +4 -1
  91. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mn.js +4 -1
  92. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ms.js +4 -1
  93. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nb.js +4 -1
  94. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nl.js +4 -1
  95. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/no.js +4 -1
  96. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pl.js +4 -1
  97. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt-br.js +4 -1
  98. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt.js +4 -1
  99. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ro.js +4 -1
  100. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ru.js +4 -1
  101. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sk.js +4 -1
  102. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sl.js +4 -1
  103. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr-latn.js +4 -1
  104. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr.js +4 -1
  105. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sv.js +4 -1
  106. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/th.js +4 -1
  107. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/tr.js +4 -1
  108. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ug.js +4 -1
  109. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/uk.js +4 -1
  110. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/vi.js +4 -1
  111. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh-cn.js +4 -1
  112. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh.js +4 -1
  113. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/plugin.js +249 -103
  114. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/ambiance-mobile.css +6 -6
  115. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/ambiance.css +76 -76
  116. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/blackboard.css +25 -25
  117. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/cobalt.css +18 -18
  118. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/eclipse.css +25 -25
  119. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/elegant.css +10 -10
  120. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/erlang-dark.css +21 -21
  121. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/lesser-dark.css +44 -44
  122. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/monokai.css +28 -28
  123. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/neat.css +9 -9
  124. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/night.css +21 -21
  125. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/rubyblue.css +21 -21
  126. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/solarized.css +207 -207
  127. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/twilight.css +26 -25
  128. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/vibrant-ink.css +27 -27
  129. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/xq-dark.css +46 -46
  130. data/vendor/assets/javascripts/ckeditor/plugins/icons.png +0 -0
  131. data/vendor/assets/javascripts/ckeditor/plugins/iframedialog/plugin.js +173 -173
  132. data/vendor/assets/javascripts/ckeditor/plugins/{MediaEmbed → mediaembed}/images/icon.png +0 -0
  133. data/vendor/assets/javascripts/ckeditor/plugins/{MediaEmbed → mediaembed}/plugin.js +16 -13
  134. data/vendor/assets/javascripts/ckeditor/plugins/oembed/images/icon.png +0 -0
  135. data/vendor/assets/javascripts/ckeditor/plugins/oembed/lang/de.js +5 -2
  136. data/vendor/assets/javascripts/ckeditor/plugins/oembed/lang/en.js +4 -1
  137. data/vendor/assets/javascripts/ckeditor/plugins/oembed/lang/fr.js +9 -6
  138. data/vendor/assets/javascripts/ckeditor/plugins/oembed/lang/nl.js +4 -1
  139. data/vendor/assets/javascripts/ckeditor/plugins/oembed/lang/ru.js +11 -8
  140. data/vendor/assets/javascripts/ckeditor/plugins/oembed/libs/jquery.oembed.js +161 -30
  141. data/vendor/assets/javascripts/ckeditor/plugins/oembed/libs/jquery.oembed.min.js +1 -4
  142. data/vendor/assets/javascripts/ckeditor/plugins/oembed/plugin.js +55 -59
  143. data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +11 -10
  144. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/fa.js +8 -9
  145. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/fr.js +1 -1
  146. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ku.js +9 -10
  147. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/pl.js +12 -0
  148. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/th.js +13 -0
  149. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog.css +1 -1
  150. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie.css +1 -1
  151. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie7.css +1 -1
  152. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie8.css +1 -1
  153. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_iequirks.css +5 -3
  154. data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_opera.css +1 -1
  155. data/vendor/assets/javascripts/ckeditor/skins/moono/editor.css +1 -1
  156. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_gecko.css +1 -1
  157. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie.css +1 -1
  158. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +1 -1
  159. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie8.css +1 -1
  160. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +52 -196
  161. data/vendor/assets/javascripts/ckeditor/skins/moono/icons.png +0 -0
  162. metadata +29 -203
  163. data/vendor/assets/javascripts/ckeditor/contents.css +0 -99
  164. data/vendor/assets/javascripts/ckeditor/lang/af.js +0 -5
  165. data/vendor/assets/javascripts/ckeditor/lang/ar.js +0 -5
  166. data/vendor/assets/javascripts/ckeditor/lang/bg.js +0 -5
  167. data/vendor/assets/javascripts/ckeditor/lang/bn.js +0 -5
  168. data/vendor/assets/javascripts/ckeditor/lang/bs.js +0 -5
  169. data/vendor/assets/javascripts/ckeditor/lang/ca.js +0 -5
  170. data/vendor/assets/javascripts/ckeditor/lang/cs.js +0 -5
  171. data/vendor/assets/javascripts/ckeditor/lang/cy.js +0 -5
  172. data/vendor/assets/javascripts/ckeditor/lang/da.js +0 -5
  173. data/vendor/assets/javascripts/ckeditor/lang/de.js +0 -5
  174. data/vendor/assets/javascripts/ckeditor/lang/el.js +0 -5
  175. data/vendor/assets/javascripts/ckeditor/lang/en-au.js +0 -5
  176. data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +0 -5
  177. data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +0 -5
  178. data/vendor/assets/javascripts/ckeditor/lang/eo.js +0 -5
  179. data/vendor/assets/javascripts/ckeditor/lang/es.js +0 -5
  180. data/vendor/assets/javascripts/ckeditor/lang/et.js +0 -5
  181. data/vendor/assets/javascripts/ckeditor/lang/eu.js +0 -5
  182. data/vendor/assets/javascripts/ckeditor/lang/fa.js +0 -5
  183. data/vendor/assets/javascripts/ckeditor/lang/fi.js +0 -5
  184. data/vendor/assets/javascripts/ckeditor/lang/fo.js +0 -5
  185. data/vendor/assets/javascripts/ckeditor/lang/fr-ca.js +0 -5
  186. data/vendor/assets/javascripts/ckeditor/lang/fr.js +0 -5
  187. data/vendor/assets/javascripts/ckeditor/lang/gl.js +0 -5
  188. data/vendor/assets/javascripts/ckeditor/lang/gu.js +0 -5
  189. data/vendor/assets/javascripts/ckeditor/lang/he.js +0 -5
  190. data/vendor/assets/javascripts/ckeditor/lang/hi.js +0 -5
  191. data/vendor/assets/javascripts/ckeditor/lang/hr.js +0 -5
  192. data/vendor/assets/javascripts/ckeditor/lang/hu.js +0 -5
  193. data/vendor/assets/javascripts/ckeditor/lang/is.js +0 -5
  194. data/vendor/assets/javascripts/ckeditor/lang/it.js +0 -5
  195. data/vendor/assets/javascripts/ckeditor/lang/ja.js +0 -5
  196. data/vendor/assets/javascripts/ckeditor/lang/ka.js +0 -5
  197. data/vendor/assets/javascripts/ckeditor/lang/km.js +0 -5
  198. data/vendor/assets/javascripts/ckeditor/lang/ko.js +0 -5
  199. data/vendor/assets/javascripts/ckeditor/lang/ku.js +0 -5
  200. data/vendor/assets/javascripts/ckeditor/lang/lt.js +0 -5
  201. data/vendor/assets/javascripts/ckeditor/lang/lv.js +0 -5
  202. data/vendor/assets/javascripts/ckeditor/lang/mk.js +0 -5
  203. data/vendor/assets/javascripts/ckeditor/lang/mn.js +0 -5
  204. data/vendor/assets/javascripts/ckeditor/lang/ms.js +0 -5
  205. data/vendor/assets/javascripts/ckeditor/lang/nb.js +0 -5
  206. data/vendor/assets/javascripts/ckeditor/lang/nl.js +0 -5
  207. data/vendor/assets/javascripts/ckeditor/lang/no.js +0 -5
  208. data/vendor/assets/javascripts/ckeditor/lang/pl.js +0 -5
  209. data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +0 -5
  210. data/vendor/assets/javascripts/ckeditor/lang/pt.js +0 -5
  211. data/vendor/assets/javascripts/ckeditor/lang/ro.js +0 -5
  212. data/vendor/assets/javascripts/ckeditor/lang/sk.js +0 -5
  213. data/vendor/assets/javascripts/ckeditor/lang/sl.js +0 -5
  214. data/vendor/assets/javascripts/ckeditor/lang/sr-latn.js +0 -5
  215. data/vendor/assets/javascripts/ckeditor/lang/sr.js +0 -5
  216. data/vendor/assets/javascripts/ckeditor/lang/sv.js +0 -5
  217. data/vendor/assets/javascripts/ckeditor/lang/th.js +0 -5
  218. data/vendor/assets/javascripts/ckeditor/lang/tr.js +0 -5
  219. data/vendor/assets/javascripts/ckeditor/lang/ug.js +0 -5
  220. data/vendor/assets/javascripts/ckeditor/lang/uk.js +0 -5
  221. data/vendor/assets/javascripts/ckeditor/lang/vi.js +0 -5
  222. data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +0 -5
  223. data/vendor/assets/javascripts/ckeditor/lang/zh.js +0 -5
  224. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/CKCss.xml +0 -26
  225. data/vendor/assets/javascripts/ckeditor/plugins/CKCss/ckcss1.png +0 -0
  226. data/vendor/assets/javascripts/ckeditor/plugins/MediaEmbed/icons/mediaembed.png +0 -0
  227. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +0 -6
  228. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
  229. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/sourcecodepro-regular.eot +0 -0
  230. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/sourcecodepro-regular.otf +0 -0
  231. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/sourcecodepro-regular.svg +0 -242
  232. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/sourcecodepro-regular.ttf +0 -0
  233. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/sourcecodepro-regular.woff +0 -0
  234. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/colorize.js +0 -29
  235. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/continuecomment.js +0 -36
  236. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/dialog.css +0 -32
  237. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/javascript-hint.js +0 -137
  238. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/loadmode.js +0 -51
  239. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/match-highlighter.js +0 -46
  240. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/multiplex.js +0 -95
  241. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/overlay.js +0 -59
  242. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/pig-hint.js +0 -117
  243. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/runmode-standalone.js +0 -90
  244. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/runmode.js +0 -52
  245. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/simple-hint.css +0 -16
  246. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/simple-hint.js +0 -102
  247. data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/util/xml-hint.js +0 -131
  248. data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +0 -13
  249. data/vendor/assets/javascripts/ckeditor/plugins/div/dialogs/div.js +0 -9
  250. data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +0 -24
  251. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/button.js +0 -8
  252. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/checkbox.js +0 -8
  253. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/form.js +0 -8
  254. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/hiddenfield.js +0 -8
  255. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/radio.js +0 -8
  256. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/select.js +0 -20
  257. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textarea.js +0 -8
  258. data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textfield.js +0 -10
  259. data/vendor/assets/javascripts/ckeditor/plugins/forms/images/hiddenfield.gif +0 -0
  260. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/docs/install.html +0 -93
  261. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/docs/styles.css +0 -59
  262. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/icon1.png +0 -0
  263. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/icon2.png +0 -0
  264. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/icon3.png +0 -0
  265. data/vendor/assets/javascripts/ckeditor/plugins/htmlbuttons/plugin.js +0 -71
  266. data/vendor/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +0 -10
  267. data/vendor/assets/javascripts/ckeditor/plugins/iframe/images/placeholder.png +0 -0
  268. data/vendor/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +0 -10
  269. data/vendor/assets/javascripts/ckeditor/plugins/pagebreak/images/pagebreak.gif +0 -0
  270. data/vendor/assets/javascripts/ckeditor/plugins/preview/preview.html +0 -10
  271. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_address.png +0 -0
  272. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
  273. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_div.png +0 -0
  274. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
  275. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
  276. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
  277. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
  278. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
  279. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
  280. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_p.png +0 -0
  281. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
  282. data/vendor/assets/javascripts/ckeditor/plugins/smiley/dialogs/smiley.js +0 -10
  283. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angel_smile.gif +0 -0
  284. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angry_smile.gif +0 -0
  285. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/broken_heart.gif +0 -0
  286. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/confused_smile.gif +0 -0
  287. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/cry_smile.gif +0 -0
  288. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/devil_smile.gif +0 -0
  289. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embaressed_smile.gif +0 -0
  290. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embarrassed_smile.gif +0 -0
  291. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/envelope.gif +0 -0
  292. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/heart.gif +0 -0
  293. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/kiss.gif +0 -0
  294. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/lightbulb.gif +0 -0
  295. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/omg_smile.gif +0 -0
  296. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/regular_smile.gif +0 -0
  297. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/sad_smile.gif +0 -0
  298. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/shades_smile.gif +0 -0
  299. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/teeth_smile.gif +0 -0
  300. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_down.gif +0 -0
  301. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_up.gif +0 -0
  302. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tongue_smile.gif +0 -0
  303. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tounge_smile.gif +0 -0
  304. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.gif +0 -0
  305. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/wink_smile.gif +0 -0
  306. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +0 -84
  307. data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +0 -10
  308. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +0 -6
  309. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
  310. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
  311. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
  312. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/en.js +0 -9
  313. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/ru.js +0 -9
  314. data/vendor/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +0 -95
  315. data/vendor/assets/javascripts/ckeditor/samples/ajax.html +0 -82
  316. data/vendor/assets/javascripts/ckeditor/samples/api.html +0 -207
  317. data/vendor/assets/javascripts/ckeditor/samples/appendto.html +0 -57
  318. data/vendor/assets/javascripts/ckeditor/samples/assets/inlineall/logo.png +0 -0
  319. data/vendor/assets/javascripts/ckeditor/samples/assets/outputxhtml/outputxhtml.css +0 -204
  320. data/vendor/assets/javascripts/ckeditor/samples/assets/posteddata.php +0 -59
  321. data/vendor/assets/javascripts/ckeditor/samples/assets/sample.css +0 -3
  322. data/vendor/assets/javascripts/ckeditor/samples/assets/sample.jpg +0 -0
  323. data/vendor/assets/javascripts/ckeditor/samples/assets/uilanguages/languages.js +0 -7
  324. data/vendor/assets/javascripts/ckeditor/samples/divreplace.html +0 -141
  325. data/vendor/assets/javascripts/ckeditor/samples/index.html +0 -119
  326. data/vendor/assets/javascripts/ckeditor/samples/inlineall.html +0 -311
  327. data/vendor/assets/javascripts/ckeditor/samples/inlinebycode.html +0 -122
  328. data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/assets/my_dialog.js +0 -48
  329. data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/dialog.html +0 -187
  330. data/vendor/assets/javascripts/ckeditor/samples/plugins/enterkey/enterkey.html +0 -103
  331. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.fla +0 -0
  332. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.swf +0 -0
  333. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/swfobject.js +0 -18
  334. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputforflash.html +0 -280
  335. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputhtml.html +0 -237
  336. data/vendor/assets/javascripts/ckeditor/samples/plugins/magicline/magicline.html +0 -203
  337. data/vendor/assets/javascripts/ckeditor/samples/plugins/toolbar/toolbar.html +0 -200
  338. data/vendor/assets/javascripts/ckeditor/samples/plugins/wysiwygarea/fullpage.html +0 -71
  339. data/vendor/assets/javascripts/ckeditor/samples/readonly.html +0 -73
  340. data/vendor/assets/javascripts/ckeditor/samples/replacebyclass.html +0 -57
  341. data/vendor/assets/javascripts/ckeditor/samples/replacebycode.html +0 -56
  342. data/vendor/assets/javascripts/ckeditor/samples/sample.css +0 -333
  343. data/vendor/assets/javascripts/ckeditor/samples/sample.js +0 -5
  344. data/vendor/assets/javascripts/ckeditor/samples/sample_posteddata.php +0 -16
  345. data/vendor/assets/javascripts/ckeditor/samples/tabindex.html +0 -75
  346. data/vendor/assets/javascripts/ckeditor/samples/uicolor.html +0 -69
  347. data/vendor/assets/javascripts/ckeditor/samples/uilanguages.html +0 -119
  348. data/vendor/assets/javascripts/ckeditor/samples/xhtmlstyle.html +0 -219
@@ -1,84 +1,104 @@
1
- CodeMirror.defineMode("htmlmixed", function(config) {
2
- var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
3
- var jsMode = CodeMirror.getMode(config, "javascript");
4
- var cssMode = CodeMirror.getMode(config, "css");
5
-
6
- function html(stream, state) {
7
- var style = htmlMode.token(stream, state.htmlState);
8
- if (/(?:^|\s)tag(?:\s|$)/.test(style) && stream.current() == ">" && state.htmlState.context) {
9
- if (/^script$/i.test(state.htmlState.context.tagName)) {
10
- state.token = javascript;
11
- state.localState = jsMode.startState(htmlMode.indent(state.htmlState, ""));
12
- }
13
- else if (/^style$/i.test(state.htmlState.context.tagName)) {
14
- state.token = css;
15
- state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
16
- }
17
- }
18
- return style;
19
- }
20
- function maybeBackup(stream, pat, style) {
21
- var cur = stream.current();
22
- var close = cur.search(pat), m;
23
- if (close > -1) stream.backUp(cur.length - close);
24
- else if (m = cur.match(/<\/?$/)) {
25
- stream.backUp(cur.length);
26
- if (!stream.match(pat, false)) stream.match(cur[0]);
27
- }
28
- return style;
29
- }
30
- function javascript(stream, state) {
31
- if (stream.match(/^<\/\s*script\s*>/i, false)) {
32
- state.token = html;
33
- state.localState = null;
34
- return html(stream, state);
35
- }
36
- return maybeBackup(stream, /<\/\s*script\s*>/,
37
- jsMode.token(stream, state.localState));
38
- }
39
- function css(stream, state) {
40
- if (stream.match(/^<\/\s*style\s*>/i, false)) {
41
- state.token = html;
42
- state.localState = null;
43
- return html(stream, state);
44
- }
45
- return maybeBackup(stream, /<\/\s*style\s*>/,
46
- cssMode.token(stream, state.localState));
47
- }
48
-
49
- return {
50
- startState: function() {
51
- var state = htmlMode.startState();
52
- return {token: html, localState: null, mode: "html", htmlState: state};
53
- },
54
-
55
- copyState: function(state) {
56
- if (state.localState)
57
- var local = CodeMirror.copyState(state.token == css ? cssMode : jsMode, state.localState);
58
- return {token: state.token, localState: local, mode: state.mode,
59
- htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
60
- },
61
-
62
- token: function(stream, state) {
63
- return state.token(stream, state);
64
- },
65
-
66
- indent: function(state, textAfter) {
67
- if (state.token == html || /^\s*<\//.test(textAfter))
68
- return htmlMode.indent(state.htmlState, textAfter);
69
- else if (state.token == javascript)
70
- return jsMode.indent(state.localState, textAfter);
71
- else
72
- return cssMode.indent(state.localState, textAfter);
73
- },
74
-
75
- electricChars: "/{}:",
76
-
77
- innerMode: function(state) {
78
- var mode = state.token == html ? htmlMode : state.token == javascript ? jsMode : cssMode;
79
- return {state: state.localState || state.htmlState, mode: mode};
80
- }
81
- };
82
- }, "xml", "javascript", "css");
83
-
84
- CodeMirror.defineMIME("text/html", "htmlmixed");
1
+ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
2
+ var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
3
+ var cssMode = CodeMirror.getMode(config, "css");
4
+
5
+ var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
6
+ scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
7
+ mode: CodeMirror.getMode(config, "javascript")});
8
+ if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) {
9
+ var conf = scriptTypesConf[i];
10
+ scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)});
11
+ }
12
+ scriptTypes.push({matches: /./,
13
+ mode: CodeMirror.getMode(config, "text/plain")});
14
+
15
+ function html(stream, state) {
16
+ var tagName = state.htmlState.tagName;
17
+ var style = htmlMode.token(stream, state.htmlState);
18
+ if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") {
19
+ // Script block: mode to change to depends on type attribute
20
+ var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
21
+ scriptType = scriptType ? scriptType[1] : "";
22
+ if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1);
23
+ for (var i = 0; i < scriptTypes.length; ++i) {
24
+ var tp = scriptTypes[i];
25
+ if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) {
26
+ if (tp.mode) {
27
+ state.token = script;
28
+ state.localMode = tp.mode;
29
+ state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, ""));
30
+ }
31
+ break;
32
+ }
33
+ }
34
+ } else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") {
35
+ state.token = css;
36
+ state.localMode = cssMode;
37
+ state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
38
+ }
39
+ return style;
40
+ }
41
+ function maybeBackup(stream, pat, style) {
42
+ var cur = stream.current();
43
+ var close = cur.search(pat), m;
44
+ if (close > -1) stream.backUp(cur.length - close);
45
+ else if (m = cur.match(/<\/?$/)) {
46
+ stream.backUp(cur.length);
47
+ if (!stream.match(pat, false)) stream.match(cur[0]);
48
+ }
49
+ return style;
50
+ }
51
+ function script(stream, state) {
52
+ if (stream.match(/^<\/\s*script\s*>/i, false)) {
53
+ state.token = html;
54
+ state.localState = state.localMode = null;
55
+ return html(stream, state);
56
+ }
57
+ return maybeBackup(stream, /<\/\s*script\s*>/,
58
+ state.localMode.token(stream, state.localState));
59
+ }
60
+ function css(stream, state) {
61
+ if (stream.match(/^<\/\s*style\s*>/i, false)) {
62
+ state.token = html;
63
+ state.localState = state.localMode = null;
64
+ return html(stream, state);
65
+ }
66
+ return maybeBackup(stream, /<\/\s*style\s*>/,
67
+ cssMode.token(stream, state.localState));
68
+ }
69
+
70
+ return {
71
+ startState: function() {
72
+ var state = htmlMode.startState();
73
+ return {token: html, localMode: null, localState: null, htmlState: state};
74
+ },
75
+
76
+ copyState: function(state) {
77
+ if (state.localState)
78
+ var local = CodeMirror.copyState(state.localMode, state.localState);
79
+ return {token: state.token, localMode: state.localMode, localState: local,
80
+ htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
81
+ },
82
+
83
+ token: function(stream, state) {
84
+ return state.token(stream, state);
85
+ },
86
+
87
+ indent: function(state, textAfter) {
88
+ if (!state.localMode || /^\s*<\//.test(textAfter))
89
+ return htmlMode.indent(state.htmlState, textAfter);
90
+ else if (state.localMode.indent)
91
+ return state.localMode.indent(state.localState, textAfter);
92
+ else
93
+ return CodeMirror.Pass;
94
+ },
95
+
96
+ electricChars: "/{}:",
97
+
98
+ innerMode: function(state) {
99
+ return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
100
+ }
101
+ };
102
+ }, "xml", "javascript", "css");
103
+
104
+ CodeMirror.defineMIME("text/html", "htmlmixed");
@@ -1,411 +1,426 @@
1
- // TODO actually recognize syntax of TypeScript constructs
2
-
3
- CodeMirror.defineMode("javascript", function(config, parserConfig) {
4
- var indentUnit = config.indentUnit;
5
- var jsonMode = parserConfig.json;
6
- var isTS = parserConfig.typescript;
7
-
8
- // Tokenizer
9
-
10
- var keywords = function(){
11
- function kw(type) {return {type: type, style: "keyword"};}
12
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
13
- var operator = kw("operator"), atom = {type: "atom", style: "atom"};
14
-
15
- var jsKeywords = {
16
- "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
17
- "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
18
- "var": kw("var"), "const": kw("var"), "let": kw("var"),
19
- "function": kw("function"), "catch": kw("catch"),
20
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
21
- "in": operator, "typeof": operator, "instanceof": operator,
22
- "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom
23
- };
24
-
25
- // Extend the 'normal' keywords with the TypeScript language extensions
26
- if (isTS) {
27
- var type = {type: "variable", style: "variable-3"};
28
- var tsKeywords = {
29
- // object-like things
30
- "interface": kw("interface"),
31
- "class": kw("class"),
32
- "extends": kw("extends"),
33
- "constructor": kw("constructor"),
34
-
35
- // scope modifiers
36
- "public": kw("public"),
37
- "private": kw("private"),
38
- "protected": kw("protected"),
39
- "static": kw("static"),
40
-
41
- "super": kw("super"),
42
-
43
- // types
44
- "string": type, "number": type, "bool": type, "any": type
45
- };
46
-
47
- for (var attr in tsKeywords) {
48
- jsKeywords[attr] = tsKeywords[attr];
49
- }
50
- }
51
-
52
- return jsKeywords;
53
- }();
54
-
55
- var isOperatorChar = /[+\-*&%=<>!?|]/;
56
-
57
- function chain(stream, state, f) {
58
- state.tokenize = f;
59
- return f(stream, state);
60
- }
61
-
62
- function nextUntilUnescaped(stream, end) {
63
- var escaped = false, next;
64
- while ((next = stream.next()) != null) {
65
- if (next == end && !escaped)
66
- return false;
67
- escaped = !escaped && next == "\\";
68
- }
69
- return escaped;
70
- }
71
-
72
- // Used as scratch variables to communicate multiple values without
73
- // consing up tons of objects.
74
- var type, content;
75
- function ret(tp, style, cont) {
76
- type = tp; content = cont;
77
- return style;
78
- }
79
-
80
- function jsTokenBase(stream, state) {
81
- var ch = stream.next();
82
- if (ch == '"' || ch == "'")
83
- return chain(stream, state, jsTokenString(ch));
84
- else if (/[\[\]{}\(\),;\:\.]/.test(ch))
85
- return ret(ch);
86
- else if (ch == "0" && stream.eat(/x/i)) {
87
- stream.eatWhile(/[\da-f]/i);
88
- return ret("number", "number");
89
- }
90
- else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
91
- stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
92
- return ret("number", "number");
93
- }
94
- else if (ch == "/") {
95
- if (stream.eat("*")) {
96
- return chain(stream, state, jsTokenComment);
97
- }
98
- else if (stream.eat("/")) {
99
- stream.skipToEnd();
100
- return ret("comment", "comment");
101
- }
102
- else if (state.lastType == "operator" || state.lastType == "keyword c" ||
103
- /^[\[{}\(,;:]$/.test(state.lastType)) {
104
- nextUntilUnescaped(stream, "/");
105
- stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
106
- return ret("regexp", "string-2");
107
- }
108
- else {
109
- stream.eatWhile(isOperatorChar);
110
- return ret("operator", null, stream.current());
111
- }
112
- }
113
- else if (ch == "#") {
114
- stream.skipToEnd();
115
- return ret("error", "error");
116
- }
117
- else if (isOperatorChar.test(ch)) {
118
- stream.eatWhile(isOperatorChar);
119
- return ret("operator", null, stream.current());
120
- }
121
- else {
122
- stream.eatWhile(/[\w\$_]/);
123
- var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
124
- return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
125
- ret("variable", "variable", word);
126
- }
127
- }
128
-
129
- function jsTokenString(quote) {
130
- return function(stream, state) {
131
- if (!nextUntilUnescaped(stream, quote))
132
- state.tokenize = jsTokenBase;
133
- return ret("string", "string");
134
- };
135
- }
136
-
137
- function jsTokenComment(stream, state) {
138
- var maybeEnd = false, ch;
139
- while (ch = stream.next()) {
140
- if (ch == "/" && maybeEnd) {
141
- state.tokenize = jsTokenBase;
142
- break;
143
- }
144
- maybeEnd = (ch == "*");
145
- }
146
- return ret("comment", "comment");
147
- }
148
-
149
- // Parser
150
-
151
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
152
-
153
- function JSLexical(indented, column, type, align, prev, info) {
154
- this.indented = indented;
155
- this.column = column;
156
- this.type = type;
157
- this.prev = prev;
158
- this.info = info;
159
- if (align != null) this.align = align;
160
- }
161
-
162
- function inScope(state, varname) {
163
- for (var v = state.localVars; v; v = v.next)
164
- if (v.name == varname) return true;
165
- }
166
-
167
- function parseJS(state, style, type, content, stream) {
168
- var cc = state.cc;
169
- // Communicate our context to the combinators.
170
- // (Less wasteful than consing up a hundred closures on every call.)
171
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
172
-
173
- if (!state.lexical.hasOwnProperty("align"))
174
- state.lexical.align = true;
175
-
176
- while(true) {
177
- var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
178
- if (combinator(type, content)) {
179
- while(cc.length && cc[cc.length - 1].lex)
180
- cc.pop()();
181
- if (cx.marked) return cx.marked;
182
- if (type == "variable" && inScope(state, content)) return "variable-2";
183
- return style;
184
- }
185
- }
186
- }
187
-
188
- // Combinator utils
189
-
190
- var cx = {state: null, column: null, marked: null, cc: null};
191
- function pass() {
192
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
193
- }
194
- function cont() {
195
- pass.apply(null, arguments);
196
- return true;
197
- }
198
- function register(varname) {
199
- var state = cx.state;
200
- if (state.context) {
201
- cx.marked = "def";
202
- for (var v = state.localVars; v; v = v.next)
203
- if (v.name == varname) return;
204
- state.localVars = {name: varname, next: state.localVars};
205
- }
206
- }
207
-
208
- // Combinators
209
-
210
- var defaultVars = {name: "this", next: {name: "arguments"}};
211
- function pushcontext() {
212
- cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
213
- cx.state.localVars = defaultVars;
214
- }
215
- function popcontext() {
216
- cx.state.localVars = cx.state.context.vars;
217
- cx.state.context = cx.state.context.prev;
218
- }
219
- function pushlex(type, info) {
220
- var result = function() {
221
- var state = cx.state;
222
- state.lexical = new JSLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
223
- };
224
- result.lex = true;
225
- return result;
226
- }
227
- function poplex() {
228
- var state = cx.state;
229
- if (state.lexical.prev) {
230
- if (state.lexical.type == ")")
231
- state.indented = state.lexical.indented;
232
- state.lexical = state.lexical.prev;
233
- }
234
- }
235
- poplex.lex = true;
236
-
237
- function expect(wanted) {
238
- return function expecting(type) {
239
- if (type == wanted) return cont();
240
- else if (wanted == ";") return pass();
241
- else return cont(arguments.callee);
242
- };
243
- }
244
-
245
- function statement(type) {
246
- if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
247
- if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
248
- if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
249
- if (type == "{") return cont(pushlex("}"), block, poplex);
250
- if (type == ";") return cont();
251
- if (type == "function") return cont(functiondef);
252
- if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
253
- poplex, statement, poplex);
254
- if (type == "variable") return cont(pushlex("stat"), maybelabel);
255
- if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
256
- block, poplex, poplex);
257
- if (type == "case") return cont(expression, expect(":"));
258
- if (type == "default") return cont(expect(":"));
259
- if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
260
- statement, poplex, popcontext);
261
- return pass(pushlex("stat"), expression, expect(";"), poplex);
262
- }
263
- function expression(type) {
264
- if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
265
- if (type == "function") return cont(functiondef);
266
- if (type == "keyword c") return cont(maybeexpression);
267
- if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
268
- if (type == "operator") return cont(expression);
269
- if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
270
- if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
271
- return cont();
272
- }
273
- function maybeexpression(type) {
274
- if (type.match(/[;\}\)\],]/)) return pass();
275
- return pass(expression);
276
- }
277
-
278
- function maybeoperator(type, value) {
279
- if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
280
- if (type == "operator" && value == "?") return cont(expression, expect(":"), expression);
281
- if (type == ";") return;
282
- if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
283
- if (type == ".") return cont(property, maybeoperator);
284
- if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
285
- }
286
- function maybelabel(type) {
287
- if (type == ":") return cont(poplex, statement);
288
- return pass(maybeoperator, expect(";"), poplex);
289
- }
290
- function property(type) {
291
- if (type == "variable") {cx.marked = "property"; return cont();}
292
- }
293
- function objprop(type) {
294
- if (type == "variable") cx.marked = "property";
295
- if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
296
- }
297
- function commasep(what, end) {
298
- function proceed(type) {
299
- if (type == ",") return cont(what, proceed);
300
- if (type == end) return cont();
301
- return cont(expect(end));
302
- }
303
- return function commaSeparated(type) {
304
- if (type == end) return cont();
305
- else return pass(what, proceed);
306
- };
307
- }
308
- function block(type) {
309
- if (type == "}") return cont();
310
- return pass(statement, block);
311
- }
312
- function maybetype(type) {
313
- if (type == ":") return cont(typedef);
314
- return pass();
315
- }
316
- function typedef(type) {
317
- if (type == "variable"){cx.marked = "variable-3"; return cont();}
318
- return pass();
319
- }
320
- function vardef1(type, value) {
321
- if (type == "variable") {
322
- register(value);
323
- return isTS ? cont(maybetype, vardef2) : cont(vardef2);
324
- }
325
- return pass();
326
- }
327
- function vardef2(type, value) {
328
- if (value == "=") return cont(expression, vardef2);
329
- if (type == ",") return cont(vardef1);
330
- }
331
- function forspec1(type) {
332
- if (type == "var") return cont(vardef1, expect(";"), forspec2);
333
- if (type == ";") return cont(forspec2);
334
- if (type == "variable") return cont(formaybein);
335
- return cont(forspec2);
336
- }
337
- function formaybein(_type, value) {
338
- if (value == "in") return cont(expression);
339
- return cont(maybeoperator, forspec2);
340
- }
341
- function forspec2(type, value) {
342
- if (type == ";") return cont(forspec3);
343
- if (value == "in") return cont(expression);
344
- return cont(expression, expect(";"), forspec3);
345
- }
346
- function forspec3(type) {
347
- if (type != ")") cont(expression);
348
- }
349
- function functiondef(type, value) {
350
- if (type == "variable") {register(value); return cont(functiondef);}
351
- if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
352
- }
353
- function funarg(type, value) {
354
- if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();}
355
- }
356
-
357
- // Interface
358
-
359
- return {
360
- startState: function(basecolumn) {
361
- return {
362
- tokenize: jsTokenBase,
363
- lastType: null,
364
- cc: [],
365
- lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
366
- localVars: parserConfig.localVars,
367
- context: parserConfig.localVars && {vars: parserConfig.localVars},
368
- indented: 0
369
- };
370
- },
371
-
372
- token: function(stream, state) {
373
- if (stream.sol()) {
374
- if (!state.lexical.hasOwnProperty("align"))
375
- state.lexical.align = false;
376
- state.indented = stream.indentation();
377
- }
378
- if (stream.eatSpace()) return null;
379
- var style = state.tokenize(stream, state);
380
- if (type == "comment") return style;
381
- state.lastType = type;
382
- return parseJS(state, style, type, content, stream);
383
- },
384
-
385
- indent: function(state, textAfter) {
386
- if (state.tokenize == jsTokenComment) return CodeMirror.Pass;
387
- if (state.tokenize != jsTokenBase) return 0;
388
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
389
- if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
390
- var type = lexical.type, closing = firstChar == type;
391
- if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0);
392
- else if (type == "form" && firstChar == "{") return lexical.indented;
393
- else if (type == "form") return lexical.indented + indentUnit;
394
- else if (type == "stat")
395
- return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? indentUnit : 0);
396
- else if (lexical.info == "switch" && !closing)
397
- return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
398
- else if (lexical.align) return lexical.column + (closing ? 0 : 1);
399
- else return lexical.indented + (closing ? 0 : indentUnit);
400
- },
401
-
402
- electricChars: ":{}",
403
-
404
- jsonMode: jsonMode
405
- };
406
- });
407
-
408
- CodeMirror.defineMIME("text/javascript", "javascript");
409
- CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
410
- CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
411
- CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
1
+ // TODO actually recognize syntax of TypeScript constructs
2
+
3
+ CodeMirror.defineMode("javascript", function(config, parserConfig) {
4
+ var indentUnit = config.indentUnit;
5
+ var jsonMode = parserConfig.json;
6
+ var isTS = parserConfig.typescript;
7
+
8
+ // Tokenizer
9
+
10
+ var keywords = function(){
11
+ function kw(type) {return {type: type, style: "keyword"};}
12
+ var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
13
+ var operator = kw("operator"), atom = {type: "atom", style: "atom"};
14
+
15
+ var jsKeywords = {
16
+ "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
17
+ "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
18
+ "var": kw("var"), "const": kw("var"), "let": kw("var"),
19
+ "function": kw("function"), "catch": kw("catch"),
20
+ "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
21
+ "in": operator, "typeof": operator, "instanceof": operator,
22
+ "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom
23
+ };
24
+
25
+ // Extend the 'normal' keywords with the TypeScript language extensions
26
+ if (isTS) {
27
+ var type = {type: "variable", style: "variable-3"};
28
+ var tsKeywords = {
29
+ // object-like things
30
+ "interface": kw("interface"),
31
+ "class": kw("class"),
32
+ "extends": kw("extends"),
33
+ "constructor": kw("constructor"),
34
+
35
+ // scope modifiers
36
+ "public": kw("public"),
37
+ "private": kw("private"),
38
+ "protected": kw("protected"),
39
+ "static": kw("static"),
40
+
41
+ "super": kw("super"),
42
+
43
+ // types
44
+ "string": type, "number": type, "bool": type, "any": type
45
+ };
46
+
47
+ for (var attr in tsKeywords) {
48
+ jsKeywords[attr] = tsKeywords[attr];
49
+ }
50
+ }
51
+
52
+ return jsKeywords;
53
+ }();
54
+
55
+ var isOperatorChar = /[+\-*&%=<>!?|]/;
56
+
57
+ function chain(stream, state, f) {
58
+ state.tokenize = f;
59
+ return f(stream, state);
60
+ }
61
+
62
+ function nextUntilUnescaped(stream, end) {
63
+ var escaped = false, next;
64
+ while ((next = stream.next()) != null) {
65
+ if (next == end && !escaped)
66
+ return false;
67
+ escaped = !escaped && next == "\\";
68
+ }
69
+ return escaped;
70
+ }
71
+
72
+ // Used as scratch variables to communicate multiple values without
73
+ // consing up tons of objects.
74
+ var type, content;
75
+ function ret(tp, style, cont) {
76
+ type = tp; content = cont;
77
+ return style;
78
+ }
79
+
80
+ function jsTokenBase(stream, state) {
81
+ var ch = stream.next();
82
+ if (ch == '"' || ch == "'")
83
+ return chain(stream, state, jsTokenString(ch));
84
+ else if (/[\[\]{}\(\),;\:\.]/.test(ch))
85
+ return ret(ch);
86
+ else if (ch == "0" && stream.eat(/x/i)) {
87
+ stream.eatWhile(/[\da-f]/i);
88
+ return ret("number", "number");
89
+ }
90
+ else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
91
+ stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
92
+ return ret("number", "number");
93
+ }
94
+ else if (ch == "/") {
95
+ if (stream.eat("*")) {
96
+ return chain(stream, state, jsTokenComment);
97
+ }
98
+ else if (stream.eat("/")) {
99
+ stream.skipToEnd();
100
+ return ret("comment", "comment");
101
+ }
102
+ else if (state.lastType == "operator" || state.lastType == "keyword c" ||
103
+ /^[\[{}\(,;:]$/.test(state.lastType)) {
104
+ nextUntilUnescaped(stream, "/");
105
+ stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
106
+ return ret("regexp", "string-2");
107
+ }
108
+ else {
109
+ stream.eatWhile(isOperatorChar);
110
+ return ret("operator", null, stream.current());
111
+ }
112
+ }
113
+ else if (ch == "#") {
114
+ stream.skipToEnd();
115
+ return ret("error", "error");
116
+ }
117
+ else if (isOperatorChar.test(ch)) {
118
+ stream.eatWhile(isOperatorChar);
119
+ return ret("operator", null, stream.current());
120
+ }
121
+ else {
122
+ stream.eatWhile(/[\w\$_]/);
123
+ var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
124
+ return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
125
+ ret("variable", "variable", word);
126
+ }
127
+ }
128
+
129
+ function jsTokenString(quote) {
130
+ return function(stream, state) {
131
+ if (!nextUntilUnescaped(stream, quote))
132
+ state.tokenize = jsTokenBase;
133
+ return ret("string", "string");
134
+ };
135
+ }
136
+
137
+ function jsTokenComment(stream, state) {
138
+ var maybeEnd = false, ch;
139
+ while (ch = stream.next()) {
140
+ if (ch == "/" && maybeEnd) {
141
+ state.tokenize = jsTokenBase;
142
+ break;
143
+ }
144
+ maybeEnd = (ch == "*");
145
+ }
146
+ return ret("comment", "comment");
147
+ }
148
+
149
+ // Parser
150
+
151
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
152
+
153
+ function JSLexical(indented, column, type, align, prev, info) {
154
+ this.indented = indented;
155
+ this.column = column;
156
+ this.type = type;
157
+ this.prev = prev;
158
+ this.info = info;
159
+ if (align != null) this.align = align;
160
+ }
161
+
162
+ function inScope(state, varname) {
163
+ for (var v = state.localVars; v; v = v.next)
164
+ if (v.name == varname) return true;
165
+ }
166
+
167
+ function parseJS(state, style, type, content, stream) {
168
+ var cc = state.cc;
169
+ // Communicate our context to the combinators.
170
+ // (Less wasteful than consing up a hundred closures on every call.)
171
+ cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
172
+
173
+ if (!state.lexical.hasOwnProperty("align"))
174
+ state.lexical.align = true;
175
+
176
+ while(true) {
177
+ var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
178
+ if (combinator(type, content)) {
179
+ while(cc.length && cc[cc.length - 1].lex)
180
+ cc.pop()();
181
+ if (cx.marked) return cx.marked;
182
+ if (type == "variable" && inScope(state, content)) return "variable-2";
183
+ return style;
184
+ }
185
+ }
186
+ }
187
+
188
+ // Combinator utils
189
+
190
+ var cx = {state: null, column: null, marked: null, cc: null};
191
+ function pass() {
192
+ for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
193
+ }
194
+ function cont() {
195
+ pass.apply(null, arguments);
196
+ return true;
197
+ }
198
+ function register(varname) {
199
+ function inList(list) {
200
+ for (var v = list; v; v = v.next)
201
+ if (v.name == varname) return true;
202
+ return false;
203
+ }
204
+ var state = cx.state;
205
+ if (state.context) {
206
+ cx.marked = "def";
207
+ if (inList(state.localVars)) return;
208
+ state.localVars = {name: varname, next: state.localVars};
209
+ } else {
210
+ if (inList(state.globalVars)) return;
211
+ state.globalVars = {name: varname, next: state.globalVars};
212
+ }
213
+ }
214
+
215
+ // Combinators
216
+
217
+ var defaultVars = {name: "this", next: {name: "arguments"}};
218
+ function pushcontext() {
219
+ cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
220
+ cx.state.localVars = defaultVars;
221
+ }
222
+ function popcontext() {
223
+ cx.state.localVars = cx.state.context.vars;
224
+ cx.state.context = cx.state.context.prev;
225
+ }
226
+ function pushlex(type, info) {
227
+ var result = function() {
228
+ var state = cx.state;
229
+ state.lexical = new JSLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
230
+ };
231
+ result.lex = true;
232
+ return result;
233
+ }
234
+ function poplex() {
235
+ var state = cx.state;
236
+ if (state.lexical.prev) {
237
+ if (state.lexical.type == ")")
238
+ state.indented = state.lexical.indented;
239
+ state.lexical = state.lexical.prev;
240
+ }
241
+ }
242
+ poplex.lex = true;
243
+
244
+ function expect(wanted) {
245
+ return function(type) {
246
+ if (type == wanted) return cont();
247
+ else if (wanted == ";") return pass();
248
+ else return cont(arguments.callee);
249
+ };
250
+ }
251
+
252
+ function statement(type) {
253
+ if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
254
+ if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
255
+ if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
256
+ if (type == "{") return cont(pushlex("}"), block, poplex);
257
+ if (type == ";") return cont();
258
+ if (type == "function") return cont(functiondef);
259
+ if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
260
+ poplex, statement, poplex);
261
+ if (type == "variable") return cont(pushlex("stat"), maybelabel);
262
+ if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
263
+ block, poplex, poplex);
264
+ if (type == "case") return cont(expression, expect(":"));
265
+ if (type == "default") return cont(expect(":"));
266
+ if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
267
+ statement, poplex, popcontext);
268
+ return pass(pushlex("stat"), expression, expect(";"), poplex);
269
+ }
270
+ function expression(type) {
271
+ if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
272
+ if (type == "function") return cont(functiondef);
273
+ if (type == "keyword c") return cont(maybeexpression);
274
+ if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
275
+ if (type == "operator") return cont(expression);
276
+ if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
277
+ if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
278
+ return cont();
279
+ }
280
+ function maybeexpression(type) {
281
+ if (type.match(/[;\}\)\],]/)) return pass();
282
+ return pass(expression);
283
+ }
284
+
285
+ function maybeoperator(type, value) {
286
+ if (type == "operator") {
287
+ if (/\+\+|--/.test(value)) return cont(maybeoperator);
288
+ if (value == "?") return cont(expression, expect(":"), expression);
289
+ return cont(expression);
290
+ }
291
+ if (type == ";") return;
292
+ if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
293
+ if (type == ".") return cont(property, maybeoperator);
294
+ if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
295
+ }
296
+ function maybelabel(type) {
297
+ if (type == ":") return cont(poplex, statement);
298
+ return pass(maybeoperator, expect(";"), poplex);
299
+ }
300
+ function property(type) {
301
+ if (type == "variable") {cx.marked = "property"; return cont();}
302
+ }
303
+ function objprop(type) {
304
+ if (type == "variable") cx.marked = "property";
305
+ else if (type == "number" || type == "string") cx.marked = type + " property";
306
+ if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
307
+ }
308
+ function commasep(what, end) {
309
+ function proceed(type) {
310
+ if (type == ",") return cont(what, proceed);
311
+ if (type == end) return cont();
312
+ return cont(expect(end));
313
+ }
314
+ return function(type) {
315
+ if (type == end) return cont();
316
+ else return pass(what, proceed);
317
+ };
318
+ }
319
+ function block(type) {
320
+ if (type == "}") return cont();
321
+ return pass(statement, block);
322
+ }
323
+ function maybetype(type) {
324
+ if (type == ":") return cont(typedef);
325
+ return pass();
326
+ }
327
+ function typedef(type) {
328
+ if (type == "variable"){cx.marked = "variable-3"; return cont();}
329
+ return pass();
330
+ }
331
+ function vardef1(type, value) {
332
+ if (type == "variable") {
333
+ register(value);
334
+ return isTS ? cont(maybetype, vardef2) : cont(vardef2);
335
+ }
336
+ return pass();
337
+ }
338
+ function vardef2(type, value) {
339
+ if (value == "=") return cont(expression, vardef2);
340
+ if (type == ",") return cont(vardef1);
341
+ }
342
+ function forspec1(type) {
343
+ if (type == "var") return cont(vardef1, expect(";"), forspec2);
344
+ if (type == ";") return cont(forspec2);
345
+ if (type == "variable") return cont(formaybein);
346
+ return cont(forspec2);
347
+ }
348
+ function formaybein(_type, value) {
349
+ if (value == "in") return cont(expression);
350
+ return cont(maybeoperator, forspec2);
351
+ }
352
+ function forspec2(type, value) {
353
+ if (type == ";") return cont(forspec3);
354
+ if (value == "in") return cont(expression);
355
+ return cont(expression, expect(";"), forspec3);
356
+ }
357
+ function forspec3(type) {
358
+ if (type != ")") cont(expression);
359
+ }
360
+ function functiondef(type, value) {
361
+ if (type == "variable") {register(value); return cont(functiondef);}
362
+ if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
363
+ }
364
+ function funarg(type, value) {
365
+ if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();}
366
+ }
367
+
368
+ // Interface
369
+
370
+ return {
371
+ startState: function(basecolumn) {
372
+ return {
373
+ tokenize: jsTokenBase,
374
+ lastType: null,
375
+ cc: [],
376
+ lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
377
+ localVars: parserConfig.localVars,
378
+ globalVars: parserConfig.globalVars,
379
+ context: parserConfig.localVars && {vars: parserConfig.localVars},
380
+ indented: 0
381
+ };
382
+ },
383
+
384
+ token: function(stream, state) {
385
+ if (stream.sol()) {
386
+ if (!state.lexical.hasOwnProperty("align"))
387
+ state.lexical.align = false;
388
+ state.indented = stream.indentation();
389
+ }
390
+ if (stream.eatSpace()) return null;
391
+ var style = state.tokenize(stream, state);
392
+ if (type == "comment") return style;
393
+ state.lastType = type;
394
+ return parseJS(state, style, type, content, stream);
395
+ },
396
+
397
+ indent: function(state, textAfter) {
398
+ if (state.tokenize == jsTokenComment) return CodeMirror.Pass;
399
+ if (state.tokenize != jsTokenBase) return 0;
400
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
401
+ if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
402
+ var type = lexical.type, closing = firstChar == type;
403
+ if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0);
404
+ else if (type == "form" && firstChar == "{") return lexical.indented;
405
+ else if (type == "form") return lexical.indented + indentUnit;
406
+ else if (type == "stat")
407
+ return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? indentUnit : 0);
408
+ else if (lexical.info == "switch" && !closing)
409
+ return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
410
+ else if (lexical.align) return lexical.column + (closing ? 0 : 1);
411
+ else return lexical.indented + (closing ? 0 : indentUnit);
412
+ },
413
+
414
+ electricChars: ":{}",
415
+
416
+ jsonMode: jsonMode
417
+ };
418
+ });
419
+
420
+ CodeMirror.defineMIME("text/javascript", "javascript");
421
+ CodeMirror.defineMIME("text/ecmascript", "javascript");
422
+ CodeMirror.defineMIME("application/javascript", "javascript");
423
+ CodeMirror.defineMIME("application/ecmascript", "javascript");
424
+ CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
425
+ CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
426
+ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });