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,51 @@
|
|
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
|
+
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)\.)(\s*)/,
|
15
|
+
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)\.)(\s*)$/,
|
16
|
+
unorderedListRE = /[*+-]\s/;
|
17
|
+
|
18
|
+
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
19
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
20
|
+
var ranges = cm.listSelections(), replacements = [];
|
21
|
+
for (var i = 0; i < ranges.length; i++) {
|
22
|
+
var pos = ranges[i].head, match;
|
23
|
+
var eolState = cm.getStateAfter(pos.line);
|
24
|
+
var inList = eolState.list !== false;
|
25
|
+
var inQuote = eolState.quote !== false;
|
26
|
+
|
27
|
+
if (!ranges[i].empty() || (!inList && !inQuote) || !(match = cm.getLine(pos.line).match(listRE))) {
|
28
|
+
cm.execCommand("newlineAndIndent");
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
if (cm.getLine(pos.line).match(emptyListRE)) {
|
32
|
+
cm.replaceRange("", {
|
33
|
+
line: pos.line, ch: 0
|
34
|
+
}, {
|
35
|
+
line: pos.line, ch: pos.ch + 1
|
36
|
+
});
|
37
|
+
replacements[i] = "\n";
|
38
|
+
|
39
|
+
} else {
|
40
|
+
var indent = match[1], after = match[4];
|
41
|
+
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
|
42
|
+
? match[2]
|
43
|
+
: (parseInt(match[3], 10) + 1) + ".";
|
44
|
+
|
45
|
+
replacements[i] = "\n" + indent + bullet + after;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
cm.replaceSelections(replacements);
|
50
|
+
};
|
51
|
+
});
|
@@ -0,0 +1,120 @@
|
|
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 ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
|
13
|
+
(document.documentMode == null || document.documentMode < 8);
|
14
|
+
|
15
|
+
var Pos = CodeMirror.Pos;
|
16
|
+
|
17
|
+
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
|
18
|
+
|
19
|
+
function findMatchingBracket(cm, where, strict, config) {
|
20
|
+
var line = cm.getLineHandle(where.line), pos = where.ch - 1;
|
21
|
+
var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
|
22
|
+
if (!match) return null;
|
23
|
+
var dir = match.charAt(1) == ">" ? 1 : -1;
|
24
|
+
if (strict && (dir > 0) != (pos == where.ch)) return null;
|
25
|
+
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
|
26
|
+
|
27
|
+
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
|
28
|
+
if (found == null) return null;
|
29
|
+
return {from: Pos(where.line, pos), to: found && found.pos,
|
30
|
+
match: found && found.ch == match.charAt(0), forward: dir > 0};
|
31
|
+
}
|
32
|
+
|
33
|
+
// bracketRegex is used to specify which type of bracket to scan
|
34
|
+
// should be a regexp, e.g. /[[\]]/
|
35
|
+
//
|
36
|
+
// Note: If "where" is on an open bracket, then this bracket is ignored.
|
37
|
+
//
|
38
|
+
// Returns false when no bracket was found, null when it reached
|
39
|
+
// maxScanLines and gave up
|
40
|
+
function scanForBracket(cm, where, dir, style, config) {
|
41
|
+
var maxScanLen = (config && config.maxScanLineLength) || 10000;
|
42
|
+
var maxScanLines = (config && config.maxScanLines) || 1000;
|
43
|
+
|
44
|
+
var stack = [];
|
45
|
+
var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
|
46
|
+
var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
|
47
|
+
: Math.max(cm.firstLine() - 1, where.line - maxScanLines);
|
48
|
+
for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
|
49
|
+
var line = cm.getLine(lineNo);
|
50
|
+
if (!line) continue;
|
51
|
+
var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
|
52
|
+
if (line.length > maxScanLen) continue;
|
53
|
+
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
|
54
|
+
for (; pos != end; pos += dir) {
|
55
|
+
var ch = line.charAt(pos);
|
56
|
+
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
|
57
|
+
var match = matching[ch];
|
58
|
+
if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
|
59
|
+
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
|
60
|
+
else stack.pop();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
|
65
|
+
}
|
66
|
+
|
67
|
+
function matchBrackets(cm, autoclear, config) {
|
68
|
+
// Disable brace matching in long lines, since it'll cause hugely slow updates
|
69
|
+
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
|
70
|
+
var marks = [], ranges = cm.listSelections();
|
71
|
+
for (var i = 0; i < ranges.length; i++) {
|
72
|
+
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
|
73
|
+
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
|
74
|
+
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
|
75
|
+
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
|
76
|
+
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
|
77
|
+
marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
if (marks.length) {
|
82
|
+
// Kludge to work around the IE bug from issue #1193, where text
|
83
|
+
// input stops going to the textare whever this fires.
|
84
|
+
if (ie_lt8 && cm.state.focused) cm.display.input.focus();
|
85
|
+
|
86
|
+
var clear = function() {
|
87
|
+
cm.operation(function() {
|
88
|
+
for (var i = 0; i < marks.length; i++) marks[i].clear();
|
89
|
+
});
|
90
|
+
};
|
91
|
+
if (autoclear) setTimeout(clear, 800);
|
92
|
+
else return clear;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
var currentlyHighlighted = null;
|
97
|
+
function doMatchBrackets(cm) {
|
98
|
+
cm.operation(function() {
|
99
|
+
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
|
100
|
+
currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
|
105
|
+
if (old && old != CodeMirror.Init)
|
106
|
+
cm.off("cursorActivity", doMatchBrackets);
|
107
|
+
if (val) {
|
108
|
+
cm.state.matchBrackets = typeof val == "object" ? val : {};
|
109
|
+
cm.on("cursorActivity", doMatchBrackets);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
|
113
|
+
CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
|
114
|
+
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){
|
115
|
+
return findMatchingBracket(this, pos, strict, config);
|
116
|
+
});
|
117
|
+
CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
|
118
|
+
return scanForBracket(this, pos, dir, style, config);
|
119
|
+
});
|
120
|
+
});
|
@@ -0,0 +1,66 @@
|
|
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"), require("../fold/xml-fold"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
|
15
|
+
if (old && old != CodeMirror.Init) {
|
16
|
+
cm.off("cursorActivity", doMatchTags);
|
17
|
+
cm.off("viewportChange", maybeUpdateMatch);
|
18
|
+
clear(cm);
|
19
|
+
}
|
20
|
+
if (val) {
|
21
|
+
cm.state.matchBothTags = typeof val == "object" && val.bothTags;
|
22
|
+
cm.on("cursorActivity", doMatchTags);
|
23
|
+
cm.on("viewportChange", maybeUpdateMatch);
|
24
|
+
doMatchTags(cm);
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
function clear(cm) {
|
29
|
+
if (cm.state.tagHit) cm.state.tagHit.clear();
|
30
|
+
if (cm.state.tagOther) cm.state.tagOther.clear();
|
31
|
+
cm.state.tagHit = cm.state.tagOther = null;
|
32
|
+
}
|
33
|
+
|
34
|
+
function doMatchTags(cm) {
|
35
|
+
cm.state.failedTagMatch = false;
|
36
|
+
cm.operation(function() {
|
37
|
+
clear(cm);
|
38
|
+
if (cm.somethingSelected()) return;
|
39
|
+
var cur = cm.getCursor(), range = cm.getViewport();
|
40
|
+
range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to);
|
41
|
+
var match = CodeMirror.findMatchingTag(cm, cur, range);
|
42
|
+
if (!match) return;
|
43
|
+
if (cm.state.matchBothTags) {
|
44
|
+
var hit = match.at == "open" ? match.open : match.close;
|
45
|
+
if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
|
46
|
+
}
|
47
|
+
var other = match.at == "close" ? match.open : match.close;
|
48
|
+
if (other)
|
49
|
+
cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
|
50
|
+
else
|
51
|
+
cm.state.failedTagMatch = true;
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
function maybeUpdateMatch(cm) {
|
56
|
+
if (cm.state.failedTagMatch) doMatchTags(cm);
|
57
|
+
}
|
58
|
+
|
59
|
+
CodeMirror.commands.toMatchingTag = function(cm) {
|
60
|
+
var found = CodeMirror.findMatchingTag(cm, cm.getCursor());
|
61
|
+
if (found) {
|
62
|
+
var other = found.at == "close" ? found.open : found.close;
|
63
|
+
if (other) cm.extendSelection(other.to, other.from);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
});
|
@@ -0,0 +1,27 @@
|
|
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("showTrailingSpace", false, function(cm, val, prev) {
|
13
|
+
if (prev == CodeMirror.Init) prev = false;
|
14
|
+
if (prev && !val)
|
15
|
+
cm.removeOverlay("trailingspace");
|
16
|
+
else if (!prev && val)
|
17
|
+
cm.addOverlay({
|
18
|
+
token: function(stream) {
|
19
|
+
for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
|
20
|
+
if (i > stream.pos) { stream.pos = i; return null; }
|
21
|
+
stream.pos = l;
|
22
|
+
return "trailingspace";
|
23
|
+
},
|
24
|
+
name: "trailingspace"
|
25
|
+
});
|
26
|
+
});
|
27
|
+
});
|
@@ -0,0 +1,105 @@
|
|
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.registerHelper("fold", "brace", function(cm, start) {
|
15
|
+
var line = start.line, lineText = cm.getLine(line);
|
16
|
+
var startCh, tokenType;
|
17
|
+
|
18
|
+
function findOpening(openCh) {
|
19
|
+
for (var at = start.ch, pass = 0;;) {
|
20
|
+
var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
|
21
|
+
if (found == -1) {
|
22
|
+
if (pass == 1) break;
|
23
|
+
pass = 1;
|
24
|
+
at = lineText.length;
|
25
|
+
continue;
|
26
|
+
}
|
27
|
+
if (pass == 1 && found < start.ch) break;
|
28
|
+
tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
|
29
|
+
if (!/^(comment|string)/.test(tokenType)) return found + 1;
|
30
|
+
at = found - 1;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
var startToken = "{", endToken = "}", startCh = findOpening("{");
|
35
|
+
if (startCh == null) {
|
36
|
+
startToken = "[", endToken = "]";
|
37
|
+
startCh = findOpening("[");
|
38
|
+
}
|
39
|
+
|
40
|
+
if (startCh == null) return;
|
41
|
+
var count = 1, lastLine = cm.lastLine(), end, endCh;
|
42
|
+
outer: for (var i = line; i <= lastLine; ++i) {
|
43
|
+
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
44
|
+
for (;;) {
|
45
|
+
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
46
|
+
if (nextOpen < 0) nextOpen = text.length;
|
47
|
+
if (nextClose < 0) nextClose = text.length;
|
48
|
+
pos = Math.min(nextOpen, nextClose);
|
49
|
+
if (pos == text.length) break;
|
50
|
+
if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
|
51
|
+
if (pos == nextOpen) ++count;
|
52
|
+
else if (!--count) { end = i; endCh = pos; break outer; }
|
53
|
+
}
|
54
|
+
++pos;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
if (end == null || line == end && endCh == startCh) return;
|
58
|
+
return {from: CodeMirror.Pos(line, startCh),
|
59
|
+
to: CodeMirror.Pos(end, endCh)};
|
60
|
+
});
|
61
|
+
|
62
|
+
CodeMirror.registerHelper("fold", "import", function(cm, start) {
|
63
|
+
function hasImport(line) {
|
64
|
+
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
65
|
+
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
66
|
+
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
67
|
+
if (start.type != "keyword" || start.string != "import") return null;
|
68
|
+
// Now find closing semicolon, return its position
|
69
|
+
for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
|
70
|
+
var text = cm.getLine(i), semi = text.indexOf(";");
|
71
|
+
if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
var start = start.line, has = hasImport(start), prev;
|
76
|
+
if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
|
77
|
+
return null;
|
78
|
+
for (var end = has.end;;) {
|
79
|
+
var next = hasImport(end.line + 1);
|
80
|
+
if (next == null) break;
|
81
|
+
end = next.end;
|
82
|
+
}
|
83
|
+
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
|
84
|
+
});
|
85
|
+
|
86
|
+
CodeMirror.registerHelper("fold", "include", function(cm, start) {
|
87
|
+
function hasInclude(line) {
|
88
|
+
if (line < cm.firstLine() || line > cm.lastLine()) return null;
|
89
|
+
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
|
90
|
+
if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
|
91
|
+
if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
|
92
|
+
}
|
93
|
+
|
94
|
+
var start = start.line, has = hasInclude(start);
|
95
|
+
if (has == null || hasInclude(start - 1) != null) return null;
|
96
|
+
for (var end = start;;) {
|
97
|
+
var next = hasInclude(end + 1);
|
98
|
+
if (next == null) break;
|
99
|
+
++end;
|
100
|
+
}
|
101
|
+
return {from: CodeMirror.Pos(start, has + 1),
|
102
|
+
to: cm.clipPos(CodeMirror.Pos(end))};
|
103
|
+
});
|
104
|
+
|
105
|
+
});
|
@@ -0,0 +1,57 @@
|
|
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.registerGlobalHelper("fold", "comment", function(mode) {
|
15
|
+
return mode.blockCommentStart && mode.blockCommentEnd;
|
16
|
+
}, function(cm, start) {
|
17
|
+
var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
|
18
|
+
if (!startToken || !endToken) return;
|
19
|
+
var line = start.line, lineText = cm.getLine(line);
|
20
|
+
|
21
|
+
var startCh;
|
22
|
+
for (var at = start.ch, pass = 0;;) {
|
23
|
+
var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
|
24
|
+
if (found == -1) {
|
25
|
+
if (pass == 1) return;
|
26
|
+
pass = 1;
|
27
|
+
at = lineText.length;
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
if (pass == 1 && found < start.ch) return;
|
31
|
+
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
|
32
|
+
startCh = found + startToken.length;
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
at = found - 1;
|
36
|
+
}
|
37
|
+
|
38
|
+
var depth = 1, lastLine = cm.lastLine(), end, endCh;
|
39
|
+
outer: for (var i = line; i <= lastLine; ++i) {
|
40
|
+
var text = cm.getLine(i), pos = i == line ? startCh : 0;
|
41
|
+
for (;;) {
|
42
|
+
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
|
43
|
+
if (nextOpen < 0) nextOpen = text.length;
|
44
|
+
if (nextClose < 0) nextClose = text.length;
|
45
|
+
pos = Math.min(nextOpen, nextClose);
|
46
|
+
if (pos == text.length) break;
|
47
|
+
if (pos == nextOpen) ++depth;
|
48
|
+
else if (!--depth) { end = i; endCh = pos; break outer; }
|
49
|
+
++pos;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if (end == null || line == end && endCh == startCh) return;
|
53
|
+
return {from: CodeMirror.Pos(line, startCh),
|
54
|
+
to: CodeMirror.Pos(end, endCh)};
|
55
|
+
});
|
56
|
+
|
57
|
+
});
|
@@ -0,0 +1,145 @@
|
|
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
|
+
function doFold(cm, pos, options, force) {
|
15
|
+
if (options && options.call) {
|
16
|
+
var finder = options;
|
17
|
+
options = null;
|
18
|
+
} else {
|
19
|
+
var finder = getOption(cm, options, "rangeFinder");
|
20
|
+
}
|
21
|
+
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
|
22
|
+
var minSize = getOption(cm, options, "minFoldSize");
|
23
|
+
|
24
|
+
function getRange(allowFolded) {
|
25
|
+
var range = finder(cm, pos);
|
26
|
+
if (!range || range.to.line - range.from.line < minSize) return null;
|
27
|
+
var marks = cm.findMarksAt(range.from);
|
28
|
+
for (var i = 0; i < marks.length; ++i) {
|
29
|
+
if (marks[i].__isFold && force !== "fold") {
|
30
|
+
if (!allowFolded) return null;
|
31
|
+
range.cleared = true;
|
32
|
+
marks[i].clear();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return range;
|
36
|
+
}
|
37
|
+
|
38
|
+
var range = getRange(true);
|
39
|
+
if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
|
40
|
+
pos = CodeMirror.Pos(pos.line - 1, 0);
|
41
|
+
range = getRange(false);
|
42
|
+
}
|
43
|
+
if (!range || range.cleared || force === "unfold") return;
|
44
|
+
|
45
|
+
var myWidget = makeWidget(cm, options);
|
46
|
+
CodeMirror.on(myWidget, "mousedown", function(e) {
|
47
|
+
myRange.clear();
|
48
|
+
CodeMirror.e_preventDefault(e);
|
49
|
+
});
|
50
|
+
var myRange = cm.markText(range.from, range.to, {
|
51
|
+
replacedWith: myWidget,
|
52
|
+
clearOnEnter: true,
|
53
|
+
__isFold: true
|
54
|
+
});
|
55
|
+
myRange.on("clear", function(from, to) {
|
56
|
+
CodeMirror.signal(cm, "unfold", cm, from, to);
|
57
|
+
});
|
58
|
+
CodeMirror.signal(cm, "fold", cm, range.from, range.to);
|
59
|
+
}
|
60
|
+
|
61
|
+
function makeWidget(cm, options) {
|
62
|
+
var widget = getOption(cm, options, "widget");
|
63
|
+
if (typeof widget == "string") {
|
64
|
+
var text = document.createTextNode(widget);
|
65
|
+
widget = document.createElement("span");
|
66
|
+
widget.appendChild(text);
|
67
|
+
widget.className = "CodeMirror-foldmarker";
|
68
|
+
}
|
69
|
+
return widget;
|
70
|
+
}
|
71
|
+
|
72
|
+
// Clumsy backwards-compatible interface
|
73
|
+
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
|
74
|
+
return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
|
75
|
+
};
|
76
|
+
|
77
|
+
// New-style interface
|
78
|
+
CodeMirror.defineExtension("foldCode", function(pos, options, force) {
|
79
|
+
doFold(this, pos, options, force);
|
80
|
+
});
|
81
|
+
|
82
|
+
CodeMirror.defineExtension("isFolded", function(pos) {
|
83
|
+
var marks = this.findMarksAt(pos);
|
84
|
+
for (var i = 0; i < marks.length; ++i)
|
85
|
+
if (marks[i].__isFold) return true;
|
86
|
+
});
|
87
|
+
|
88
|
+
CodeMirror.commands.toggleFold = function(cm) {
|
89
|
+
cm.foldCode(cm.getCursor());
|
90
|
+
};
|
91
|
+
CodeMirror.commands.fold = function(cm) {
|
92
|
+
cm.foldCode(cm.getCursor(), null, "fold");
|
93
|
+
};
|
94
|
+
CodeMirror.commands.unfold = function(cm) {
|
95
|
+
cm.foldCode(cm.getCursor(), null, "unfold");
|
96
|
+
};
|
97
|
+
CodeMirror.commands.foldAll = function(cm) {
|
98
|
+
cm.operation(function() {
|
99
|
+
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
100
|
+
cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
|
101
|
+
});
|
102
|
+
};
|
103
|
+
CodeMirror.commands.unfoldAll = function(cm) {
|
104
|
+
cm.operation(function() {
|
105
|
+
for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
|
106
|
+
cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
|
107
|
+
});
|
108
|
+
};
|
109
|
+
|
110
|
+
CodeMirror.registerHelper("fold", "combine", function() {
|
111
|
+
var funcs = Array.prototype.slice.call(arguments, 0);
|
112
|
+
return function(cm, start) {
|
113
|
+
for (var i = 0; i < funcs.length; ++i) {
|
114
|
+
var found = funcs[i](cm, start);
|
115
|
+
if (found) return found;
|
116
|
+
}
|
117
|
+
};
|
118
|
+
});
|
119
|
+
|
120
|
+
CodeMirror.registerHelper("fold", "auto", function(cm, start) {
|
121
|
+
var helpers = cm.getHelpers(start, "fold");
|
122
|
+
for (var i = 0; i < helpers.length; i++) {
|
123
|
+
var cur = helpers[i](cm, start);
|
124
|
+
if (cur) return cur;
|
125
|
+
}
|
126
|
+
});
|
127
|
+
|
128
|
+
var defaultOptions = {
|
129
|
+
rangeFinder: CodeMirror.fold.auto,
|
130
|
+
widget: "\u2194",
|
131
|
+
minFoldSize: 0,
|
132
|
+
scanUp: false
|
133
|
+
};
|
134
|
+
|
135
|
+
CodeMirror.defineOption("foldOptions", null);
|
136
|
+
|
137
|
+
function getOption(cm, options, name) {
|
138
|
+
if (options && options[name] !== undefined)
|
139
|
+
return options[name];
|
140
|
+
var editorOptions = cm.options.foldOptions;
|
141
|
+
if (editorOptions && editorOptions[name] !== undefined)
|
142
|
+
return editorOptions[name];
|
143
|
+
return defaultOptions[name];
|
144
|
+
}
|
145
|
+
});
|