fluentd-ui 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +4 -0
  3. data/Gemfile.lock +1 -1
  4. data/app/assets/javascripts/application.js +2 -0
  5. data/app/assets/javascripts/codemirror.js +29 -0
  6. data/app/assets/javascripts/codemirror_fluentd.js +59 -0
  7. data/app/assets/stylesheets/application.css +6 -0
  8. data/app/views/fluentd/settings/edit.html.haml +1 -1
  9. data/app/views/shared/vue/_setting.html.erb +1 -1
  10. data/bower.json +2 -1
  11. data/lib/fluentd-ui/version.rb +1 -1
  12. data/spec/features/source_and_output_spec.rb +16 -6
  13. data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
  14. data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
  15. data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
  16. data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
  17. data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
  18. data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
  19. data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
  20. data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
  21. data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
  22. data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
  23. data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
  24. data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
  25. data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
  26. data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
  27. data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
  28. data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
  29. data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
  30. data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
  31. data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
  32. data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
  33. data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
  34. data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
  35. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
  36. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
  37. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
  38. data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
  39. data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
  40. data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
  41. data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
  42. data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
  43. data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
  44. data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
  45. data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
  46. data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
  47. data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
  48. data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
  49. data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
  50. data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
  51. data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
  52. data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
  53. data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
  54. data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
  55. data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
  56. data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
  57. data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
  58. data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
  59. data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
  60. data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
  61. data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
  62. data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
  63. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
  64. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
  65. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
  66. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
  67. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
  68. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
  69. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
  70. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
  71. data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
  72. data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
  73. data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
  74. data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
  75. data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
  76. data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
  77. data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
  78. data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
  79. data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
  80. data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
  81. data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
  82. data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
  83. data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
  84. data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
  85. data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
  86. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
  87. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
  88. data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
  89. data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
  90. data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
  91. data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
  92. data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
  93. data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
  94. data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
  95. data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
  96. data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
  97. data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
  98. data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
  99. data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
  100. data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
  101. data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
  102. data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
  103. data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
  104. data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
  105. data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
  106. data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
  107. data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
  108. data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
  109. data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
  110. data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
  111. data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
  112. data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
  113. data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
  114. data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
  115. data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
  116. data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
  117. data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
  118. data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
  119. data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
  120. data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
  121. data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
  122. data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
  123. data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
  124. data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
  125. data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
  126. data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
  127. data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
  128. data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
  129. data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
  130. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
  131. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
  132. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
  133. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
  134. data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
  135. data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
  136. data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
  137. data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
  138. data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
  139. data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
  140. data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
  141. data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
  142. data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
  143. data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
  144. data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
  145. data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
  146. data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
  147. data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
  148. data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
  149. data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
  150. data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
  151. data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
  152. data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
  153. data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
  154. data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
  155. data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
  156. data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
  157. data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
  158. data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
  159. data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
  160. data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
  161. data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
  162. data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
  163. data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
  164. data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
  165. data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
  166. data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
  167. data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
  168. data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
  169. data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
  170. data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
  171. data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
  172. data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
  173. data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
  174. data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
  175. data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
  176. data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
  177. data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
  178. data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
  179. data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
  180. data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
  181. data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
  182. data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
  183. data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
  184. data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  185. data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
  186. data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
  187. data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
  188. data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
  189. data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
  190. data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
  191. data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
  192. data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
  193. data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
  194. data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
  195. data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
  196. data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
  197. data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
  198. data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
  199. data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
  200. data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
  201. data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
  202. data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
  203. data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
  204. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
  205. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
  206. data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
  207. data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
  208. data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
  209. data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
  210. data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
  211. data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
  212. data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
  213. data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
  214. data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
  215. data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
  216. data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
  217. data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
  218. data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
  219. data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
  220. data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
  221. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
  222. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
  223. data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
  224. data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
  225. data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
  226. data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
  227. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
  228. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
  229. data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
  230. data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
  231. data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
  232. data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
  233. data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
  234. metadata +225 -2
@@ -0,0 +1,6 @@
1
+ .CodeMirror-fullscreen {
2
+ position: fixed;
3
+ top: 0; left: 0; right: 0; bottom: 0;
4
+ height: auto;
5
+ z-index: 9;
6
+ }
@@ -0,0 +1,41 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
15
+ if (old == CodeMirror.Init) old = false;
16
+ if (!old == !val) return;
17
+ if (val) setFullscreen(cm);
18
+ else setNormal(cm);
19
+ });
20
+
21
+ function setFullscreen(cm) {
22
+ var wrap = cm.getWrapperElement();
23
+ cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
24
+ width: wrap.style.width, height: wrap.style.height};
25
+ wrap.style.width = "";
26
+ wrap.style.height = "auto";
27
+ wrap.className += " CodeMirror-fullscreen";
28
+ document.documentElement.style.overflow = "hidden";
29
+ cm.refresh();
30
+ }
31
+
32
+ function setNormal(cm) {
33
+ var wrap = cm.getWrapperElement();
34
+ wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
35
+ document.documentElement.style.overflow = "";
36
+ var info = cm.state.fullScreenRestore;
37
+ wrap.style.width = info.width; wrap.style.height = info.height;
38
+ window.scrollTo(info.scrollLeft, info.scrollTop);
39
+ cm.refresh();
40
+ }
41
+ });
@@ -0,0 +1,94 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ CodeMirror.defineExtension("addPanel", function(node, options) {
13
+ if (!this.state.panels) initPanels(this);
14
+
15
+ var info = this.state.panels;
16
+ if (options && options.position == "bottom")
17
+ info.wrapper.appendChild(node);
18
+ else
19
+ info.wrapper.insertBefore(node, info.wrapper.firstChild);
20
+ var height = (options && options.height) || node.offsetHeight;
21
+ this._setSize(null, info.heightLeft -= height);
22
+ info.panels++;
23
+ return new Panel(this, node, options, height);
24
+ });
25
+
26
+ function Panel(cm, node, options, height) {
27
+ this.cm = cm;
28
+ this.node = node;
29
+ this.options = options;
30
+ this.height = height;
31
+ this.cleared = false;
32
+ }
33
+
34
+ Panel.prototype.clear = function() {
35
+ if (this.cleared) return;
36
+ this.cleared = true;
37
+ var info = this.cm.state.panels;
38
+ this.cm._setSize(null, info.heightLeft += this.height);
39
+ info.wrapper.removeChild(this.node);
40
+ if (--info.panels == 0) removePanels(this.cm);
41
+ };
42
+
43
+ Panel.prototype.changed = function(height) {
44
+ var newHeight = height == null ? this.node.offsetHeight : height;
45
+ var info = this.cm.state.panels;
46
+ this.cm._setSize(null, info.height += (newHeight - this.height));
47
+ this.height = newHeight;
48
+ };
49
+
50
+ function initPanels(cm) {
51
+ var wrap = cm.getWrapperElement();
52
+ var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
53
+ var height = parseInt(style.height);
54
+ var info = cm.state.panels = {
55
+ setHeight: wrap.style.height,
56
+ heightLeft: height,
57
+ panels: 0,
58
+ wrapper: document.createElement("div")
59
+ };
60
+ wrap.parentNode.insertBefore(info.wrapper, wrap);
61
+ var hasFocus = cm.hasFocus();
62
+ info.wrapper.appendChild(wrap);
63
+ if (hasFocus) cm.focus();
64
+
65
+ cm._setSize = cm.setSize;
66
+ if (height != null) cm.setSize = function(width, newHeight) {
67
+ if (newHeight == null) return this._setSize(width, newHeight);
68
+ info.setHeight = newHeight;
69
+ if (typeof newHeight != "number") {
70
+ var px = /^(\d+\.?\d*)px$/.exec(newHeight);
71
+ if (px) {
72
+ newHeight = Number(px[1]);
73
+ } else {
74
+ info.wrapper.style.height = newHeight;
75
+ newHeight = info.wrapper.offsetHeight;
76
+ info.wrapper.style.height = "";
77
+ }
78
+ }
79
+ cm._setSize(width, info.heightLeft += (newHeight - height));
80
+ height = newHeight;
81
+ };
82
+ }
83
+
84
+ function removePanels(cm) {
85
+ var info = cm.state.panels;
86
+ cm.state.panels = null;
87
+
88
+ var wrap = cm.getWrapperElement();
89
+ info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
90
+ wrap.style.height = info.setHeight;
91
+ cm.setSize = cm._setSize;
92
+ cm.setSize();
93
+ }
94
+ });
@@ -0,0 +1,58 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
13
+ var prev = old && old != CodeMirror.Init;
14
+ if (val && !prev) {
15
+ cm.on("blur", onBlur);
16
+ cm.on("change", onChange);
17
+ onChange(cm);
18
+ } else if (!val && prev) {
19
+ cm.off("blur", onBlur);
20
+ cm.off("change", onChange);
21
+ clearPlaceholder(cm);
22
+ var wrapper = cm.getWrapperElement();
23
+ wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
24
+ }
25
+
26
+ if (val && !cm.hasFocus()) onBlur(cm);
27
+ });
28
+
29
+ function clearPlaceholder(cm) {
30
+ if (cm.state.placeholder) {
31
+ cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
32
+ cm.state.placeholder = null;
33
+ }
34
+ }
35
+ function setPlaceholder(cm) {
36
+ clearPlaceholder(cm);
37
+ var elt = cm.state.placeholder = document.createElement("pre");
38
+ elt.style.cssText = "height: 0; overflow: visible";
39
+ elt.className = "CodeMirror-placeholder";
40
+ elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
41
+ cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
42
+ }
43
+
44
+ function onBlur(cm) {
45
+ if (isEmpty(cm)) setPlaceholder(cm);
46
+ }
47
+ function onChange(cm) {
48
+ var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
49
+ wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
50
+
51
+ if (empty) setPlaceholder(cm);
52
+ else clearPlaceholder(cm);
53
+ }
54
+
55
+ function isEmpty(cm) {
56
+ return (cm.lineCount() === 1) && (cm.getLine(0) === "");
57
+ }
58
+ });
@@ -0,0 +1,64 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineOption("rulers", false, function(cm, val, old) {
15
+ if (old && old != CodeMirror.Init) {
16
+ clearRulers(cm);
17
+ cm.off("refresh", refreshRulers);
18
+ }
19
+ if (val && val.length) {
20
+ setRulers(cm);
21
+ cm.on("refresh", refreshRulers);
22
+ }
23
+ });
24
+
25
+ function clearRulers(cm) {
26
+ for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
27
+ var node = cm.display.lineSpace.childNodes[i];
28
+ if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
29
+ node.parentNode.removeChild(node);
30
+ }
31
+ }
32
+
33
+ function setRulers(cm) {
34
+ var val = cm.getOption("rulers");
35
+ var cw = cm.defaultCharWidth();
36
+ var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
37
+ var minH = cm.display.scroller.offsetHeight + 30;
38
+ for (var i = 0; i < val.length; i++) {
39
+ var elt = document.createElement("div");
40
+ elt.className = "CodeMirror-ruler";
41
+ var col, cls = null, conf = val[i];
42
+ if (typeof conf == "number") {
43
+ col = conf;
44
+ } else {
45
+ col = conf.column;
46
+ if (conf.className) elt.className += " " + conf.className;
47
+ if (conf.color) elt.style.borderColor = conf.color;
48
+ if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
49
+ if (conf.width) elt.style.borderLeftWidth = conf.width;
50
+ cls = val[i].className;
51
+ }
52
+ elt.style.left = (left + col * cw) + "px";
53
+ elt.style.top = "-50px";
54
+ elt.style.bottom = "-20px";
55
+ elt.style.minHeight = minH + "px";
56
+ cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
57
+ }
58
+ }
59
+
60
+ function refreshRulers(cm) {
61
+ clearRulers(cm);
62
+ setRulers(cm);
63
+ }
64
+ });
@@ -0,0 +1,159 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ var DEFAULT_BRACKETS = "()[]{}''\"\"";
13
+ var DEFAULT_EXPLODE_ON_ENTER = "[]{}";
14
+ var SPACE_CHAR_REGEX = /\s/;
15
+
16
+ var Pos = CodeMirror.Pos;
17
+
18
+ CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
19
+ if (old != CodeMirror.Init && old)
20
+ cm.removeKeyMap("autoCloseBrackets");
21
+ if (!val) return;
22
+ var pairs = DEFAULT_BRACKETS, explode = DEFAULT_EXPLODE_ON_ENTER;
23
+ if (typeof val == "string") pairs = val;
24
+ else if (typeof val == "object") {
25
+ if (val.pairs != null) pairs = val.pairs;
26
+ if (val.explode != null) explode = val.explode;
27
+ }
28
+ var map = buildKeymap(pairs);
29
+ if (explode) map.Enter = buildExplodeHandler(explode);
30
+ cm.addKeyMap(map);
31
+ });
32
+
33
+ function charsAround(cm, pos) {
34
+ var str = cm.getRange(Pos(pos.line, pos.ch - 1),
35
+ Pos(pos.line, pos.ch + 1));
36
+ return str.length == 2 ? str : null;
37
+ }
38
+
39
+ // Project the token type that will exists after the given char is
40
+ // typed, and use it to determine whether it would cause the start
41
+ // of a string token.
42
+ function enteringString(cm, pos, ch) {
43
+ var line = cm.getLine(pos.line);
44
+ var token = cm.getTokenAt(pos);
45
+ if (/\bstring2?\b/.test(token.type)) return false;
46
+ var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4);
47
+ stream.pos = stream.start = token.start;
48
+ for (;;) {
49
+ var type1 = cm.getMode().token(stream, token.state);
50
+ if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1);
51
+ stream.start = stream.pos;
52
+ }
53
+ }
54
+
55
+ function buildKeymap(pairs) {
56
+ var map = {
57
+ name : "autoCloseBrackets",
58
+ Backspace: function(cm) {
59
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
60
+ var ranges = cm.listSelections();
61
+ for (var i = 0; i < ranges.length; i++) {
62
+ if (!ranges[i].empty()) return CodeMirror.Pass;
63
+ var around = charsAround(cm, ranges[i].head);
64
+ if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
65
+ }
66
+ for (var i = ranges.length - 1; i >= 0; i--) {
67
+ var cur = ranges[i].head;
68
+ cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
69
+ }
70
+ }
71
+ };
72
+ var closingBrackets = "";
73
+ for (var i = 0; i < pairs.length; i += 2) (function(left, right) {
74
+ closingBrackets += right;
75
+ map["'" + left + "'"] = function(cm) {
76
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
77
+ var ranges = cm.listSelections(), type, next;
78
+ for (var i = 0; i < ranges.length; i++) {
79
+ var range = ranges[i], cur = range.head, curType;
80
+ var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
81
+ if (!range.empty()) {
82
+ curType = "surround";
83
+ } else if (left == right && next == right) {
84
+ if (cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == left + left + left)
85
+ curType = "skipThree";
86
+ else
87
+ curType = "skip";
88
+ } else if (left == right && cur.ch > 1 &&
89
+ cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left &&
90
+ (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) {
91
+ curType = "addFour";
92
+ } else if (left == '"' || left == "'") {
93
+ if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, left)) curType = "both";
94
+ else return CodeMirror.Pass;
95
+ } else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next)) {
96
+ curType = "both";
97
+ } else {
98
+ return CodeMirror.Pass;
99
+ }
100
+ if (!type) type = curType;
101
+ else if (type != curType) return CodeMirror.Pass;
102
+ }
103
+
104
+ cm.operation(function() {
105
+ if (type == "skip") {
106
+ cm.execCommand("goCharRight");
107
+ } else if (type == "skipThree") {
108
+ for (var i = 0; i < 3; i++)
109
+ cm.execCommand("goCharRight");
110
+ } else if (type == "surround") {
111
+ var sels = cm.getSelections();
112
+ for (var i = 0; i < sels.length; i++)
113
+ sels[i] = left + sels[i] + right;
114
+ cm.replaceSelections(sels, "around");
115
+ } else if (type == "both") {
116
+ cm.replaceSelection(left + right, null);
117
+ cm.execCommand("goCharLeft");
118
+ } else if (type == "addFour") {
119
+ cm.replaceSelection(left + left + left + left, "before");
120
+ cm.execCommand("goCharRight");
121
+ }
122
+ });
123
+ };
124
+ if (left != right) map["'" + right + "'"] = function(cm) {
125
+ var ranges = cm.listSelections();
126
+ for (var i = 0; i < ranges.length; i++) {
127
+ var range = ranges[i];
128
+ if (!range.empty() ||
129
+ cm.getRange(range.head, Pos(range.head.line, range.head.ch + 1)) != right)
130
+ return CodeMirror.Pass;
131
+ }
132
+ cm.execCommand("goCharRight");
133
+ };
134
+ })(pairs.charAt(i), pairs.charAt(i + 1));
135
+ return map;
136
+ }
137
+
138
+ function buildExplodeHandler(pairs) {
139
+ return function(cm) {
140
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
141
+ var ranges = cm.listSelections();
142
+ for (var i = 0; i < ranges.length; i++) {
143
+ if (!ranges[i].empty()) return CodeMirror.Pass;
144
+ var around = charsAround(cm, ranges[i].head);
145
+ if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
146
+ }
147
+ cm.operation(function() {
148
+ cm.replaceSelection("\n\n", null);
149
+ cm.execCommand("goCharLeft");
150
+ ranges = cm.listSelections();
151
+ for (var i = 0; i < ranges.length; i++) {
152
+ var line = ranges[i].head.line;
153
+ cm.indentLine(line, null, true);
154
+ cm.indentLine(line + 1, null, true);
155
+ }
156
+ });
157
+ };
158
+ }
159
+ });
@@ -0,0 +1,159 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ /**
5
+ * Tag-closer extension for CodeMirror.
6
+ *
7
+ * This extension adds an "autoCloseTags" option that can be set to
8
+ * either true to get the default behavior, or an object to further
9
+ * configure its behavior.
10
+ *
11
+ * These are supported options:
12
+ *
13
+ * `whenClosing` (default true)
14
+ * Whether to autoclose when the '/' of a closing tag is typed.
15
+ * `whenOpening` (default true)
16
+ * Whether to autoclose the tag when the final '>' of an opening
17
+ * tag is typed.
18
+ * `dontCloseTags` (default is empty tags for HTML, none for XML)
19
+ * An array of tag names that should not be autoclosed.
20
+ * `indentTags` (default is block tags for HTML, none for XML)
21
+ * An array of tag names that should, when opened, cause a
22
+ * blank line to be added inside the tag, and the blank line and
23
+ * closing line to be indented.
24
+ *
25
+ * See demos/closetag.html for a usage example.
26
+ */
27
+
28
+ (function(mod) {
29
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
30
+ mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
31
+ else if (typeof define == "function" && define.amd) // AMD
32
+ define(["../../lib/codemirror", "../fold/xml-fold"], mod);
33
+ else // Plain browser env
34
+ mod(CodeMirror);
35
+ })(function(CodeMirror) {
36
+ CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
37
+ if (old != CodeMirror.Init && old)
38
+ cm.removeKeyMap("autoCloseTags");
39
+ if (!val) return;
40
+ var map = {name: "autoCloseTags"};
41
+ if (typeof val != "object" || val.whenClosing)
42
+ map["'/'"] = function(cm) { return autoCloseSlash(cm); };
43
+ if (typeof val != "object" || val.whenOpening)
44
+ map["'>'"] = function(cm) { return autoCloseGT(cm); };
45
+ cm.addKeyMap(map);
46
+ });
47
+
48
+ var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
49
+ "source", "track", "wbr"];
50
+ var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
51
+ "h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
52
+
53
+ function autoCloseGT(cm) {
54
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
55
+ var ranges = cm.listSelections(), replacements = [];
56
+ for (var i = 0; i < ranges.length; i++) {
57
+ if (!ranges[i].empty()) return CodeMirror.Pass;
58
+ var pos = ranges[i].head, tok = cm.getTokenAt(pos);
59
+ var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
60
+ if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;
61
+
62
+ var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
63
+ var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
64
+ var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
65
+
66
+ var tagName = state.tagName;
67
+ if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
68
+ var lowerTagName = tagName.toLowerCase();
69
+ // Don't process the '>' at the end of an end-tag or self-closing tag
70
+ if (!tagName ||
71
+ tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
72
+ tok.type == "tag" && state.type == "closeTag" ||
73
+ tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
74
+ dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
75
+ closingTagExists(cm, tagName, pos, state, true))
76
+ return CodeMirror.Pass;
77
+
78
+ var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
79
+ replacements[i] = {indent: indent,
80
+ text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
81
+ newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
82
+ }
83
+
84
+ for (var i = ranges.length - 1; i >= 0; i--) {
85
+ var info = replacements[i];
86
+ cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
87
+ var sel = cm.listSelections().slice(0);
88
+ sel[i] = {head: info.newPos, anchor: info.newPos};
89
+ cm.setSelections(sel);
90
+ if (info.indent) {
91
+ cm.indentLine(info.newPos.line, null, true);
92
+ cm.indentLine(info.newPos.line + 1, null, true);
93
+ }
94
+ }
95
+ }
96
+
97
+ function autoCloseSlash(cm) {
98
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
99
+ var ranges = cm.listSelections(), replacements = [];
100
+ for (var i = 0; i < ranges.length; i++) {
101
+ if (!ranges[i].empty()) return CodeMirror.Pass;
102
+ var pos = ranges[i].head, tok = cm.getTokenAt(pos);
103
+ var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
104
+ if (tok.type == "string" || tok.string.charAt(0) != "<" ||
105
+ tok.start != pos.ch - 1)
106
+ return CodeMirror.Pass;
107
+ // Kludge to get around the fact that we are not in XML mode
108
+ // when completing in JS/CSS snippet in htmlmixed mode. Does not
109
+ // work for other XML embedded languages (there is no general
110
+ // way to go from a mixed mode to its current XML state).
111
+ if (inner.mode.name != "xml") {
112
+ if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
113
+ replacements[i] = "/script>";
114
+ else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
115
+ replacements[i] = "/style>";
116
+ else
117
+ return CodeMirror.Pass;
118
+ } else {
119
+ if (!state.context || !state.context.tagName ||
120
+ closingTagExists(cm, state.context.tagName, pos, state))
121
+ return CodeMirror.Pass;
122
+ replacements[i] = "/" + state.context.tagName + ">";
123
+ }
124
+ }
125
+ cm.replaceSelections(replacements);
126
+ ranges = cm.listSelections();
127
+ for (var i = 0; i < ranges.length; i++)
128
+ if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
129
+ cm.indentLine(ranges[i].head.line);
130
+ }
131
+
132
+ function indexOf(collection, elt) {
133
+ if (collection.indexOf) return collection.indexOf(elt);
134
+ for (var i = 0, e = collection.length; i < e; ++i)
135
+ if (collection[i] == elt) return i;
136
+ return -1;
137
+ }
138
+
139
+ // If xml-fold is loaded, we use its functionality to try and verify
140
+ // whether a given tag is actually unclosed.
141
+ function closingTagExists(cm, tagName, pos, state, newTag) {
142
+ if (!CodeMirror.scanForClosingTag) return false;
143
+ var end = Math.min(cm.lastLine() + 1, pos.line + 500);
144
+ var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
145
+ if (!nextClose || nextClose.tag != tagName) return false;
146
+ var cx = state.context;
147
+ // If the immediate wrapping context contains onCx instances of
148
+ // the same tag, a closing tag only exists if there are at least
149
+ // that many closing tags of that type following.
150
+ for (var onCx = newTag ? 1 : 0; cx && cx.tagName == tagName; cx = cx.prev) ++onCx;
151
+ pos = nextClose.to;
152
+ for (var i = 1; i < onCx; i++) {
153
+ var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
154
+ if (!next || next.tag != tagName) return false;
155
+ pos = next.to;
156
+ }
157
+ return true;
158
+ }
159
+ });