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.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/codemirror.js +29 -0
- data/app/assets/javascripts/codemirror_fluentd.js +59 -0
- data/app/assets/stylesheets/application.css +6 -0
- data/app/views/fluentd/settings/edit.html.haml +1 -1
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/bower.json +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/source_and_output_spec.rb +16 -6
- data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
- data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
- data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
- data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
- metadata +225 -2
@@ -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
|
+
});
|