ll-plus 2.10.24 → 2.10.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/theme-chalk/code-editor-vue3/addon/comment/comment.js +211 -0
- package/theme-chalk/code-editor-vue3/addon/comment/continuecomment.js +114 -0
- package/theme-chalk/code-editor-vue3/addon/dialog/dialog.css +32 -0
- package/theme-chalk/code-editor-vue3/addon/dialog/dialog.js +163 -0
- package/theme-chalk/code-editor-vue3/addon/display/autorefresh.js +47 -0
- package/theme-chalk/code-editor-vue3/addon/display/fullscreen.css +6 -0
- package/theme-chalk/code-editor-vue3/addon/display/fullscreen.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/display/panel.js +133 -0
- package/theme-chalk/code-editor-vue3/addon/display/placeholder.js +78 -0
- package/theme-chalk/code-editor-vue3/addon/display/rulers.js +51 -0
- package/theme-chalk/code-editor-vue3/addon/edit/closebrackets.js +201 -0
- package/theme-chalk/code-editor-vue3/addon/edit/closetag.js +185 -0
- package/theme-chalk/code-editor-vue3/addon/edit/continuelist.js +101 -0
- package/theme-chalk/code-editor-vue3/addon/edit/matchbrackets.js +160 -0
- package/theme-chalk/code-editor-vue3/addon/edit/matchtags.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/edit/trailingspace.js +27 -0
- package/theme-chalk/code-editor-vue3/addon/fold/brace-fold.js +119 -0
- package/theme-chalk/code-editor-vue3/addon/fold/comment-fold.js +59 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldcode.js +159 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldgutter.css +20 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldgutter.js +169 -0
- package/theme-chalk/code-editor-vue3/addon/fold/indent-fold.js +48 -0
- package/theme-chalk/code-editor-vue3/addon/fold/markdown-fold.js +49 -0
- package/theme-chalk/code-editor-vue3/addon/fold/xml-fold.js +184 -0
- package/theme-chalk/code-editor-vue3/addon/hint/anyword-hint.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/hint/css-hint.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/hint/html-hint.js +351 -0
- package/theme-chalk/code-editor-vue3/addon/hint/javascript-hint.js +162 -0
- package/theme-chalk/code-editor-vue3/addon/hint/show-hint.css +37 -0
- package/theme-chalk/code-editor-vue3/addon/hint/show-hint.js +523 -0
- package/theme-chalk/code-editor-vue3/addon/hint/sql-hint.js +304 -0
- package/theme-chalk/code-editor-vue3/addon/hint/xml-hint.js +132 -0
- package/theme-chalk/code-editor-vue3/addon/lint/coffeescript-lint.js +47 -0
- package/theme-chalk/code-editor-vue3/addon/lint/css-lint.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/lint/html-lint.js +59 -0
- package/theme-chalk/code-editor-vue3/addon/lint/javascript-lint.js +65 -0
- package/theme-chalk/code-editor-vue3/addon/lint/json-lint.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/lint/lint.css +79 -0
- package/theme-chalk/code-editor-vue3/addon/lint/lint.js +288 -0
- package/theme-chalk/code-editor-vue3/addon/lint/yaml-lint.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/merge/merge.css +119 -0
- package/theme-chalk/code-editor-vue3/addon/merge/merge.js +1018 -0
- package/theme-chalk/code-editor-vue3/addon/mode/loadmode.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/mode/multiplex.js +136 -0
- package/theme-chalk/code-editor-vue3/addon/mode/multiplex_test.js +49 -0
- package/theme-chalk/code-editor-vue3/addon/mode/overlay.js +90 -0
- package/theme-chalk/code-editor-vue3/addon/mode/simple.js +216 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/colorize.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode-standalone.js +334 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode.js +76 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode.node.js +329 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/annotatescrollbar.js +128 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/scrollpastend.js +48 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/simplescrollbars.css +66 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/simplescrollbars.js +152 -0
- package/theme-chalk/code-editor-vue3/addon/search/jump-to-line.js +53 -0
- package/theme-chalk/code-editor-vue3/addon/search/match-highlighter.js +167 -0
- package/theme-chalk/code-editor-vue3/addon/search/matchesonscrollbar.css +8 -0
- package/theme-chalk/code-editor-vue3/addon/search/matchesonscrollbar.js +97 -0
- package/theme-chalk/code-editor-vue3/addon/search/search.js +295 -0
- package/theme-chalk/code-editor-vue3/addon/search/searchcursor.js +305 -0
- package/theme-chalk/code-editor-vue3/addon/selection/active-line.js +72 -0
- package/theme-chalk/code-editor-vue3/addon/selection/mark-selection.js +119 -0
- package/theme-chalk/code-editor-vue3/addon/selection/selection-pointer.js +98 -0
- package/theme-chalk/code-editor-vue3/addon/tern/tern.css +87 -0
- package/theme-chalk/code-editor-vue3/addon/tern/tern.js +756 -0
- package/theme-chalk/code-editor-vue3/addon/tern/worker.js +44 -0
- package/theme-chalk/code-editor-vue3/addon/wrap/hardwrap.js +160 -0
- package/theme-chalk/code-editor-vue3/lib/codemirror.css +344 -0
- package/theme-chalk/code-editor-vue3/lib/codemirror.js +9884 -0
- package/theme-chalk/code-editor-vue3/mode/apl/apl.js +174 -0
- package/theme-chalk/code-editor-vue3/mode/asciiarmor/asciiarmor.js +74 -0
- package/theme-chalk/code-editor-vue3/mode/asn.1/asn.1.js +204 -0
- package/theme-chalk/code-editor-vue3/mode/asterisk/asterisk.js +220 -0
- package/theme-chalk/code-editor-vue3/mode/brainfuck/brainfuck.js +85 -0
- package/theme-chalk/code-editor-vue3/mode/clike/clike.js +942 -0
- package/theme-chalk/code-editor-vue3/mode/clojure/clojure.js +293 -0
- package/theme-chalk/code-editor-vue3/mode/cmake/cmake.js +97 -0
- package/theme-chalk/code-editor-vue3/mode/cobol/cobol.js +255 -0
- package/theme-chalk/code-editor-vue3/mode/coffeescript/coffeescript.js +359 -0
- package/theme-chalk/code-editor-vue3/mode/commonlisp/commonlisp.js +125 -0
- package/theme-chalk/code-editor-vue3/mode/crystal/crystal.js +433 -0
- package/theme-chalk/code-editor-vue3/mode/cypher/cypher.js +152 -0
- package/theme-chalk/code-editor-vue3/mode/d/d.js +223 -0
- package/theme-chalk/code-editor-vue3/mode/dart/dart.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/diff/diff.js +47 -0
- package/theme-chalk/code-editor-vue3/mode/django/django.js +356 -0
- package/theme-chalk/code-editor-vue3/mode/dockerfile/dockerfile.js +211 -0
- package/theme-chalk/code-editor-vue3/mode/dtd/dtd.js +142 -0
- package/theme-chalk/code-editor-vue3/mode/dylan/dylan.js +352 -0
- package/theme-chalk/code-editor-vue3/mode/ebnf/ebnf.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/ecl/ecl.js +206 -0
- package/theme-chalk/code-editor-vue3/mode/eiffel/eiffel.js +160 -0
- package/theme-chalk/code-editor-vue3/mode/elm/elm.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/erlang/erlang.js +619 -0
- package/theme-chalk/code-editor-vue3/mode/factor/factor.js +85 -0
- package/theme-chalk/code-editor-vue3/mode/fcl/fcl.js +173 -0
- package/theme-chalk/code-editor-vue3/mode/forth/forth.js +180 -0
- package/theme-chalk/code-editor-vue3/mode/fortran/fortran.js +188 -0
- package/theme-chalk/code-editor-vue3/mode/gas/gas.js +353 -0
- package/theme-chalk/code-editor-vue3/mode/gfm/gfm.js +129 -0
- package/theme-chalk/code-editor-vue3/mode/gherkin/gherkin.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/go/go.js +187 -0
- package/theme-chalk/code-editor-vue3/mode/groovy/groovy.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/haml/haml.js +161 -0
- package/theme-chalk/code-editor-vue3/mode/handlebars/handlebars.js +70 -0
- package/theme-chalk/code-editor-vue3/mode/haskell/haskell.js +268 -0
- package/theme-chalk/code-editor-vue3/mode/haskell-literate/haskell-literate.js +43 -0
- package/theme-chalk/code-editor-vue3/mode/haxe/haxe.js +515 -0
- package/theme-chalk/code-editor-vue3/mode/htmlmixed/htmlmixed.js +153 -0
- package/theme-chalk/code-editor-vue3/mode/http/http.js +113 -0
- package/theme-chalk/code-editor-vue3/mode/idl/idl.js +290 -0
- package/theme-chalk/code-editor-vue3/mode/jinja2/jinja2.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/julia/julia.js +390 -0
- package/theme-chalk/code-editor-vue3/mode/livescript/livescript.js +280 -0
- package/theme-chalk/code-editor-vue3/mode/lua/lua.js +160 -0
- package/theme-chalk/code-editor-vue3/mode/markdown/markdown.js +886 -0
- package/theme-chalk/code-editor-vue3/mode/mathematica/mathematica.js +176 -0
- package/theme-chalk/code-editor-vue3/mode/mbox/mbox.js +129 -0
- package/theme-chalk/code-editor-vue3/mode/meta.js +221 -0
- package/theme-chalk/code-editor-vue3/mode/mirc/mirc.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/mllike/mllike.js +359 -0
- package/theme-chalk/code-editor-vue3/mode/modelica/modelica.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/mscgen/mscgen.js +175 -0
- package/theme-chalk/code-editor-vue3/mode/mumps/mumps.js +148 -0
- package/theme-chalk/code-editor-vue3/mode/nginx/nginx.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/nsis/nsis.js +95 -0
- package/theme-chalk/code-editor-vue3/mode/ntriples/ntriples.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/octave/octave.js +139 -0
- package/theme-chalk/code-editor-vue3/mode/oz/oz.js +252 -0
- package/theme-chalk/code-editor-vue3/mode/pascal/pascal.js +136 -0
- package/theme-chalk/code-editor-vue3/mode/pegjs/pegjs.js +111 -0
- package/theme-chalk/code-editor-vue3/mode/perl/perl.js +836 -0
- package/theme-chalk/code-editor-vue3/mode/php/php.js +234 -0
- package/theme-chalk/code-editor-vue3/mode/pig/pig.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/powershell/powershell.js +398 -0
- package/theme-chalk/code-editor-vue3/mode/properties/properties.js +78 -0
- package/theme-chalk/code-editor-vue3/mode/protobuf/protobuf.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/pug/pug.js +591 -0
- package/theme-chalk/code-editor-vue3/mode/puppet/puppet.js +220 -0
- package/theme-chalk/code-editor-vue3/mode/python/python.js +402 -0
- package/theme-chalk/code-editor-vue3/mode/q/q.js +139 -0
- package/theme-chalk/code-editor-vue3/mode/r/r.js +190 -0
- package/theme-chalk/code-editor-vue3/mode/rpm/changes/index.html +66 -0
- package/theme-chalk/code-editor-vue3/mode/rpm/rpm.js +109 -0
- package/theme-chalk/code-editor-vue3/mode/rst/rst.js +557 -0
- package/theme-chalk/code-editor-vue3/mode/ruby/ruby.js +303 -0
- package/theme-chalk/code-editor-vue3/mode/rust/rust.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/sas/sas.js +303 -0
- package/theme-chalk/code-editor-vue3/mode/sass/sass.js +459 -0
- package/theme-chalk/code-editor-vue3/mode/scheme/scheme.js +284 -0
- package/theme-chalk/code-editor-vue3/mode/shell/shell.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/sieve/sieve.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/slim/slim.js +575 -0
- package/theme-chalk/code-editor-vue3/mode/smalltalk/smalltalk.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/smarty/smarty.js +225 -0
- package/theme-chalk/code-editor-vue3/mode/solr/solr.js +104 -0
- package/theme-chalk/code-editor-vue3/mode/soy/soy.js +665 -0
- package/theme-chalk/code-editor-vue3/mode/sparql/sparql.js +184 -0
- package/theme-chalk/code-editor-vue3/mode/spreadsheet/spreadsheet.js +112 -0
- package/theme-chalk/code-editor-vue3/mode/sql/sql.js +525 -0
- package/theme-chalk/code-editor-vue3/mode/stex/stex.js +264 -0
- package/theme-chalk/code-editor-vue3/mode/stylus/stylus.js +775 -0
- package/theme-chalk/code-editor-vue3/mode/swift/swift.js +221 -0
- package/theme-chalk/code-editor-vue3/mode/tcl/tcl.js +140 -0
- package/theme-chalk/code-editor-vue3/mode/textile/textile.js +469 -0
- package/theme-chalk/code-editor-vue3/mode/tiddlywiki/tiddlywiki.css +14 -0
- package/theme-chalk/code-editor-vue3/mode/tiddlywiki/tiddlywiki.js +308 -0
- package/theme-chalk/code-editor-vue3/mode/tiki/tiki.css +26 -0
- package/theme-chalk/code-editor-vue3/mode/tiki/tiki.js +312 -0
- package/theme-chalk/code-editor-vue3/mode/toml/toml.js +88 -0
- package/theme-chalk/code-editor-vue3/mode/tornado/tornado.js +68 -0
- package/theme-chalk/code-editor-vue3/mode/troff/troff.js +84 -0
- package/theme-chalk/code-editor-vue3/mode/ttcn/ttcn.js +283 -0
- package/theme-chalk/code-editor-vue3/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- package/theme-chalk/code-editor-vue3/mode/turtle/turtle.js +162 -0
- package/theme-chalk/code-editor-vue3/mode/twig/twig.js +141 -0
- package/theme-chalk/code-editor-vue3/mode/vb/vb.js +275 -0
- package/theme-chalk/code-editor-vue3/mode/vbscript/vbscript.js +350 -0
- package/theme-chalk/code-editor-vue3/mode/velocity/velocity.js +202 -0
- package/theme-chalk/code-editor-vue3/mode/verilog/verilog.js +781 -0
- package/theme-chalk/code-editor-vue3/mode/vhdl/vhdl.js +189 -0
- package/theme-chalk/code-editor-vue3/mode/wast/wast.js +132 -0
- package/theme-chalk/code-editor-vue3/mode/webidl/webidl.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/xml/xml.js +417 -0
- package/theme-chalk/code-editor-vue3/mode/xquery/xquery.js +448 -0
- package/theme-chalk/code-editor-vue3/mode/yacas/yacas.js +204 -0
- package/theme-chalk/code-editor-vue3/mode/yaml/yaml.js +120 -0
- package/theme-chalk/code-editor-vue3/mode/yaml-frontmatter/yaml-frontmatter.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/z80/z80.js +116 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/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
|
+
options = options || {};
|
|
14
|
+
|
|
15
|
+
if (!this.state.panels) initPanels(this);
|
|
16
|
+
|
|
17
|
+
var info = this.state.panels;
|
|
18
|
+
var wrapper = info.wrapper;
|
|
19
|
+
var cmWrapper = this.getWrapperElement();
|
|
20
|
+
var replace = options.replace instanceof Panel && !options.replace.cleared;
|
|
21
|
+
|
|
22
|
+
if (options.after instanceof Panel && !options.after.cleared) {
|
|
23
|
+
wrapper.insertBefore(node, options.before.node.nextSibling);
|
|
24
|
+
} else if (options.before instanceof Panel && !options.before.cleared) {
|
|
25
|
+
wrapper.insertBefore(node, options.before.node);
|
|
26
|
+
} else if (replace) {
|
|
27
|
+
wrapper.insertBefore(node, options.replace.node);
|
|
28
|
+
options.replace.clear(true);
|
|
29
|
+
} else if (options.position == "bottom") {
|
|
30
|
+
wrapper.appendChild(node);
|
|
31
|
+
} else if (options.position == "before-bottom") {
|
|
32
|
+
wrapper.insertBefore(node, cmWrapper.nextSibling);
|
|
33
|
+
} else if (options.position == "after-top") {
|
|
34
|
+
wrapper.insertBefore(node, cmWrapper);
|
|
35
|
+
} else {
|
|
36
|
+
wrapper.insertBefore(node, wrapper.firstChild);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var height = (options && options.height) || node.offsetHeight;
|
|
40
|
+
|
|
41
|
+
var panel = new Panel(this, node, options, height);
|
|
42
|
+
info.panels.push(panel);
|
|
43
|
+
|
|
44
|
+
this.setSize();
|
|
45
|
+
if (options.stable && isAtTop(this, node))
|
|
46
|
+
this.scrollTo(null, this.getScrollInfo().top + height);
|
|
47
|
+
|
|
48
|
+
return panel;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function Panel(cm, node, options, height) {
|
|
52
|
+
this.cm = cm;
|
|
53
|
+
this.node = node;
|
|
54
|
+
this.options = options;
|
|
55
|
+
this.height = height;
|
|
56
|
+
this.cleared = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* when skipRemove is true, clear() was called from addPanel().
|
|
60
|
+
* Thus removePanels() should not be called (issue 5518) */
|
|
61
|
+
Panel.prototype.clear = function (skipRemove) {
|
|
62
|
+
if (this.cleared) return;
|
|
63
|
+
this.cleared = true;
|
|
64
|
+
var info = this.cm.state.panels;
|
|
65
|
+
info.panels.splice(info.panels.indexOf(this), 1);
|
|
66
|
+
this.cm.setSize();
|
|
67
|
+
if (this.options.stable && isAtTop(this.cm, this.node))
|
|
68
|
+
this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height)
|
|
69
|
+
info.wrapper.removeChild(this.node);
|
|
70
|
+
if (info.panels.length == 0 && !skipRemove) removePanels(this.cm);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Panel.prototype.changed = function () {
|
|
74
|
+
this.height = this.node.getBoundingClientRect().height;
|
|
75
|
+
this.cm.setSize();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
function initPanels(cm) {
|
|
79
|
+
var wrap = cm.getWrapperElement()
|
|
80
|
+
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
|
81
|
+
var height = parseInt(style.height);
|
|
82
|
+
var info = cm.state.panels = {
|
|
83
|
+
setHeight: wrap.style.height,
|
|
84
|
+
panels: [],
|
|
85
|
+
wrapper: document.createElement("div")
|
|
86
|
+
};
|
|
87
|
+
var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo()
|
|
88
|
+
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
|
89
|
+
info.wrapper.appendChild(wrap);
|
|
90
|
+
cm.scrollTo(scrollPos.left, scrollPos.top)
|
|
91
|
+
if (hasFocus) cm.focus();
|
|
92
|
+
|
|
93
|
+
cm._setSize = cm.setSize;
|
|
94
|
+
if (height != null) cm.setSize = function (width, newHeight) {
|
|
95
|
+
if (!newHeight) newHeight = info.wrapper.offsetHeight;
|
|
96
|
+
info.setHeight = newHeight;
|
|
97
|
+
if (typeof newHeight != "number") {
|
|
98
|
+
var px = /^(\d+\.?\d*)px$/.exec(newHeight);
|
|
99
|
+
if (px) {
|
|
100
|
+
newHeight = Number(px[1]);
|
|
101
|
+
} else {
|
|
102
|
+
info.wrapper.style.height = newHeight;
|
|
103
|
+
newHeight = info.wrapper.offsetHeight;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
var editorheight = newHeight - info.panels
|
|
107
|
+
.map(function (p) { return p.node.getBoundingClientRect().height; })
|
|
108
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
109
|
+
cm._setSize(width, editorheight);
|
|
110
|
+
height = newHeight;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function removePanels(cm) {
|
|
115
|
+
var info = cm.state.panels;
|
|
116
|
+
cm.state.panels = null;
|
|
117
|
+
|
|
118
|
+
var wrap = cm.getWrapperElement()
|
|
119
|
+
var hasFocus = cm.hasFocus(), scrollPos = cm.getScrollInfo()
|
|
120
|
+
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
|
121
|
+
cm.scrollTo(scrollPos.left, scrollPos.top)
|
|
122
|
+
if (hasFocus) cm.focus();
|
|
123
|
+
wrap.style.height = info.setHeight;
|
|
124
|
+
cm.setSize = cm._setSize;
|
|
125
|
+
cm.setSize();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isAtTop(cm, dom) {
|
|
129
|
+
for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling)
|
|
130
|
+
if (sibling == cm.getWrapperElement()) return true
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/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
|
+
cm.on("swapDoc", onChange);
|
|
18
|
+
CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm) })
|
|
19
|
+
onChange(cm);
|
|
20
|
+
} else if (!val && prev) {
|
|
21
|
+
cm.off("blur", onBlur);
|
|
22
|
+
cm.off("change", onChange);
|
|
23
|
+
cm.off("swapDoc", onChange);
|
|
24
|
+
CodeMirror.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose)
|
|
25
|
+
clearPlaceholder(cm);
|
|
26
|
+
var wrapper = cm.getWrapperElement();
|
|
27
|
+
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (val && !cm.hasFocus()) onBlur(cm);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function clearPlaceholder(cm) {
|
|
34
|
+
if (cm.state.placeholder) {
|
|
35
|
+
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
|
|
36
|
+
cm.state.placeholder = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function setPlaceholder(cm) {
|
|
40
|
+
clearPlaceholder(cm);
|
|
41
|
+
var elt = cm.state.placeholder = document.createElement("pre");
|
|
42
|
+
elt.style.cssText = "height: 0; overflow: visible";
|
|
43
|
+
elt.style.direction = cm.getOption("direction");
|
|
44
|
+
elt.className = "CodeMirror-placeholder CodeMirror-line-like";
|
|
45
|
+
var placeHolder = cm.getOption("placeholder")
|
|
46
|
+
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
|
|
47
|
+
elt.appendChild(placeHolder)
|
|
48
|
+
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function onComposition(cm) {
|
|
52
|
+
setTimeout(function() {
|
|
53
|
+
var empty = false
|
|
54
|
+
if (cm.lineCount() == 1) {
|
|
55
|
+
var input = cm.getInputField()
|
|
56
|
+
empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length
|
|
57
|
+
: !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
|
|
58
|
+
}
|
|
59
|
+
if (empty) setPlaceholder(cm)
|
|
60
|
+
else clearPlaceholder(cm)
|
|
61
|
+
}, 20)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function onBlur(cm) {
|
|
65
|
+
if (isEmpty(cm)) setPlaceholder(cm);
|
|
66
|
+
}
|
|
67
|
+
function onChange(cm) {
|
|
68
|
+
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
|
|
69
|
+
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
|
|
70
|
+
|
|
71
|
+
if (empty) setPlaceholder(cm);
|
|
72
|
+
else clearPlaceholder(cm);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isEmpty(cm) {
|
|
76
|
+
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/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) {
|
|
15
|
+
if (cm.state.rulerDiv) {
|
|
16
|
+
cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv)
|
|
17
|
+
cm.state.rulerDiv = null
|
|
18
|
+
cm.off("refresh", drawRulers)
|
|
19
|
+
}
|
|
20
|
+
if (val && val.length) {
|
|
21
|
+
cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace)
|
|
22
|
+
cm.state.rulerDiv.className = "CodeMirror-rulers"
|
|
23
|
+
drawRulers(cm)
|
|
24
|
+
cm.on("refresh", drawRulers)
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function drawRulers(cm) {
|
|
29
|
+
cm.state.rulerDiv.textContent = ""
|
|
30
|
+
var val = cm.getOption("rulers");
|
|
31
|
+
var cw = cm.defaultCharWidth();
|
|
32
|
+
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
|
|
33
|
+
cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
|
|
34
|
+
for (var i = 0; i < val.length; i++) {
|
|
35
|
+
var elt = document.createElement("div");
|
|
36
|
+
elt.className = "CodeMirror-ruler";
|
|
37
|
+
var col, conf = val[i];
|
|
38
|
+
if (typeof conf == "number") {
|
|
39
|
+
col = conf;
|
|
40
|
+
} else {
|
|
41
|
+
col = conf.column;
|
|
42
|
+
if (conf.className) elt.className += " " + conf.className;
|
|
43
|
+
if (conf.color) elt.style.borderColor = conf.color;
|
|
44
|
+
if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
|
|
45
|
+
if (conf.width) elt.style.borderLeftWidth = conf.width;
|
|
46
|
+
}
|
|
47
|
+
elt.style.left = (left + col * cw) + "px";
|
|
48
|
+
cm.state.rulerDiv.appendChild(elt)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/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 defaults = {
|
|
13
|
+
pairs: "()[]{}''\"\"",
|
|
14
|
+
closeBefore: ")]}'\":;>",
|
|
15
|
+
triples: "",
|
|
16
|
+
explode: "[]{}"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var Pos = CodeMirror.Pos;
|
|
20
|
+
|
|
21
|
+
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
|
|
22
|
+
if (old && old != CodeMirror.Init) {
|
|
23
|
+
cm.removeKeyMap(keyMap);
|
|
24
|
+
cm.state.closeBrackets = null;
|
|
25
|
+
}
|
|
26
|
+
if (val) {
|
|
27
|
+
ensureBound(getOption(val, "pairs"))
|
|
28
|
+
cm.state.closeBrackets = val;
|
|
29
|
+
cm.addKeyMap(keyMap);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function getOption(conf, name) {
|
|
34
|
+
if (name == "pairs" && typeof conf == "string") return conf;
|
|
35
|
+
if (typeof conf == "object" && conf[name] != null) return conf[name];
|
|
36
|
+
return defaults[name];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
|
|
40
|
+
function ensureBound(chars) {
|
|
41
|
+
for (var i = 0; i < chars.length; i++) {
|
|
42
|
+
var ch = chars.charAt(i), key = "'" + ch + "'"
|
|
43
|
+
if (!keyMap[key]) keyMap[key] = handler(ch)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ensureBound(defaults.pairs + "`")
|
|
47
|
+
|
|
48
|
+
function handler(ch) {
|
|
49
|
+
return function(cm) { return handleChar(cm, ch); };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getConfig(cm) {
|
|
53
|
+
var deflt = cm.state.closeBrackets;
|
|
54
|
+
if (!deflt || deflt.override) return deflt;
|
|
55
|
+
var mode = cm.getModeAt(cm.getCursor());
|
|
56
|
+
return mode.closeBrackets || deflt;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function handleBackspace(cm) {
|
|
60
|
+
var conf = getConfig(cm);
|
|
61
|
+
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
|
62
|
+
|
|
63
|
+
var pairs = getOption(conf, "pairs");
|
|
64
|
+
var ranges = cm.listSelections();
|
|
65
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
66
|
+
if (!ranges[i].empty()) return CodeMirror.Pass;
|
|
67
|
+
var around = charsAround(cm, ranges[i].head);
|
|
68
|
+
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
|
69
|
+
}
|
|
70
|
+
for (var i = ranges.length - 1; i >= 0; i--) {
|
|
71
|
+
var cur = ranges[i].head;
|
|
72
|
+
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function handleEnter(cm) {
|
|
77
|
+
var conf = getConfig(cm);
|
|
78
|
+
var explode = conf && getOption(conf, "explode");
|
|
79
|
+
if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
|
|
80
|
+
|
|
81
|
+
var ranges = cm.listSelections();
|
|
82
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
83
|
+
if (!ranges[i].empty()) return CodeMirror.Pass;
|
|
84
|
+
var around = charsAround(cm, ranges[i].head);
|
|
85
|
+
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
|
86
|
+
}
|
|
87
|
+
cm.operation(function() {
|
|
88
|
+
var linesep = cm.lineSeparator() || "\n";
|
|
89
|
+
cm.replaceSelection(linesep + linesep, null);
|
|
90
|
+
moveSel(cm, -1)
|
|
91
|
+
ranges = cm.listSelections();
|
|
92
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
93
|
+
var line = ranges[i].head.line;
|
|
94
|
+
cm.indentLine(line, null, true);
|
|
95
|
+
cm.indentLine(line + 1, null, true);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function moveSel(cm, dir) {
|
|
101
|
+
var newRanges = [], ranges = cm.listSelections(), primary = 0
|
|
102
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
103
|
+
var range = ranges[i]
|
|
104
|
+
if (range.head == cm.getCursor()) primary = i
|
|
105
|
+
var pos = range.head.ch || dir > 0 ? {line: range.head.line, ch: range.head.ch + dir} : {line: range.head.line - 1}
|
|
106
|
+
newRanges.push({anchor: pos, head: pos})
|
|
107
|
+
}
|
|
108
|
+
cm.setSelections(newRanges, primary)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function contractSelection(sel) {
|
|
112
|
+
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
|
113
|
+
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
|
114
|
+
head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function handleChar(cm, ch) {
|
|
118
|
+
var conf = getConfig(cm);
|
|
119
|
+
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
|
120
|
+
|
|
121
|
+
var pairs = getOption(conf, "pairs");
|
|
122
|
+
var pos = pairs.indexOf(ch);
|
|
123
|
+
if (pos == -1) return CodeMirror.Pass;
|
|
124
|
+
|
|
125
|
+
var closeBefore = getOption(conf,"closeBefore");
|
|
126
|
+
|
|
127
|
+
var triples = getOption(conf, "triples");
|
|
128
|
+
|
|
129
|
+
var identical = pairs.charAt(pos + 1) == ch;
|
|
130
|
+
var ranges = cm.listSelections();
|
|
131
|
+
var opening = pos % 2 == 0;
|
|
132
|
+
|
|
133
|
+
var type;
|
|
134
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
135
|
+
var range = ranges[i], cur = range.head, curType;
|
|
136
|
+
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
|
|
137
|
+
if (opening && !range.empty()) {
|
|
138
|
+
curType = "surround";
|
|
139
|
+
} else if ((identical || !opening) && next == ch) {
|
|
140
|
+
if (identical && stringStartsAfter(cm, cur))
|
|
141
|
+
curType = "both";
|
|
142
|
+
else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
|
|
143
|
+
curType = "skipThree";
|
|
144
|
+
else
|
|
145
|
+
curType = "skip";
|
|
146
|
+
} else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
|
|
147
|
+
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) {
|
|
148
|
+
if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass;
|
|
149
|
+
curType = "addFour";
|
|
150
|
+
} else if (identical) {
|
|
151
|
+
var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
|
|
152
|
+
if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
|
|
153
|
+
else return CodeMirror.Pass;
|
|
154
|
+
} else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) {
|
|
155
|
+
curType = "both";
|
|
156
|
+
} else {
|
|
157
|
+
return CodeMirror.Pass;
|
|
158
|
+
}
|
|
159
|
+
if (!type) type = curType;
|
|
160
|
+
else if (type != curType) return CodeMirror.Pass;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
|
|
164
|
+
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
|
165
|
+
cm.operation(function() {
|
|
166
|
+
if (type == "skip") {
|
|
167
|
+
moveSel(cm, 1)
|
|
168
|
+
} else if (type == "skipThree") {
|
|
169
|
+
moveSel(cm, 3)
|
|
170
|
+
} else if (type == "surround") {
|
|
171
|
+
var sels = cm.getSelections();
|
|
172
|
+
for (var i = 0; i < sels.length; i++)
|
|
173
|
+
sels[i] = left + sels[i] + right;
|
|
174
|
+
cm.replaceSelections(sels, "around");
|
|
175
|
+
sels = cm.listSelections().slice();
|
|
176
|
+
for (var i = 0; i < sels.length; i++)
|
|
177
|
+
sels[i] = contractSelection(sels[i]);
|
|
178
|
+
cm.setSelections(sels);
|
|
179
|
+
} else if (type == "both") {
|
|
180
|
+
cm.replaceSelection(left + right, null);
|
|
181
|
+
cm.triggerElectric(left + right);
|
|
182
|
+
moveSel(cm, -1)
|
|
183
|
+
} else if (type == "addFour") {
|
|
184
|
+
cm.replaceSelection(left + left + left + left, "before");
|
|
185
|
+
moveSel(cm, 1)
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function charsAround(cm, pos) {
|
|
191
|
+
var str = cm.getRange(Pos(pos.line, pos.ch - 1),
|
|
192
|
+
Pos(pos.line, pos.ch + 1));
|
|
193
|
+
return str.length == 2 ? str : null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function stringStartsAfter(cm, pos) {
|
|
197
|
+
var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
|
|
198
|
+
return /\bstring/.test(token.type) && token.start == pos.ch &&
|
|
199
|
+
(pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos)))
|
|
200
|
+
}
|
|
201
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/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
|
+
* `emptyTags` (default is none)
|
|
25
|
+
* An array of XML tag names that should be autoclosed with '/>'.
|
|
26
|
+
*
|
|
27
|
+
* See demos/closetag.html for a usage example.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
(function(mod) {
|
|
31
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
32
|
+
mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
|
|
33
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
34
|
+
define(["../../lib/codemirror", "../fold/xml-fold"], mod);
|
|
35
|
+
else // Plain browser env
|
|
36
|
+
mod(CodeMirror);
|
|
37
|
+
})(function(CodeMirror) {
|
|
38
|
+
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
|
|
39
|
+
if (old != CodeMirror.Init && old)
|
|
40
|
+
cm.removeKeyMap("autoCloseTags");
|
|
41
|
+
if (!val) return;
|
|
42
|
+
var map = {name: "autoCloseTags"};
|
|
43
|
+
if (typeof val != "object" || val.whenClosing !== false)
|
|
44
|
+
map["'/'"] = function(cm) { return autoCloseSlash(cm); };
|
|
45
|
+
if (typeof val != "object" || val.whenOpening !== false)
|
|
46
|
+
map["'>'"] = function(cm) { return autoCloseGT(cm); };
|
|
47
|
+
cm.addKeyMap(map);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
|
|
51
|
+
"source", "track", "wbr"];
|
|
52
|
+
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
|
|
53
|
+
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
|
|
54
|
+
|
|
55
|
+
function autoCloseGT(cm) {
|
|
56
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
|
57
|
+
var ranges = cm.listSelections(), replacements = [];
|
|
58
|
+
var opt = cm.getOption("autoCloseTags");
|
|
59
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
60
|
+
if (!ranges[i].empty()) return CodeMirror.Pass;
|
|
61
|
+
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
|
62
|
+
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
|
63
|
+
var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state)
|
|
64
|
+
var tagName = tagInfo && tagInfo.name
|
|
65
|
+
if (!tagName) return CodeMirror.Pass
|
|
66
|
+
|
|
67
|
+
var html = inner.mode.configuration == "html";
|
|
68
|
+
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
|
|
69
|
+
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
|
|
70
|
+
|
|
71
|
+
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
|
|
72
|
+
var lowerTagName = tagName.toLowerCase();
|
|
73
|
+
// Don't process the '>' at the end of an end-tag or self-closing tag
|
|
74
|
+
if (!tagName ||
|
|
75
|
+
tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
|
|
76
|
+
tok.type == "tag" && tagInfo.close ||
|
|
77
|
+
tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like <someTagName />
|
|
78
|
+
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
|
|
79
|
+
closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true))
|
|
80
|
+
return CodeMirror.Pass;
|
|
81
|
+
|
|
82
|
+
var emptyTags = typeof opt == "object" && opt.emptyTags;
|
|
83
|
+
if (emptyTags && indexOf(emptyTags, tagName) > -1) {
|
|
84
|
+
replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) };
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
|
|
89
|
+
replacements[i] = {indent: indent,
|
|
90
|
+
text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
|
|
91
|
+
newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose);
|
|
95
|
+
for (var i = ranges.length - 1; i >= 0; i--) {
|
|
96
|
+
var info = replacements[i];
|
|
97
|
+
cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
|
|
98
|
+
var sel = cm.listSelections().slice(0);
|
|
99
|
+
sel[i] = {head: info.newPos, anchor: info.newPos};
|
|
100
|
+
cm.setSelections(sel);
|
|
101
|
+
if (!dontIndentOnAutoClose && info.indent) {
|
|
102
|
+
cm.indentLine(info.newPos.line, null, true);
|
|
103
|
+
cm.indentLine(info.newPos.line + 1, null, true);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function autoCloseCurrent(cm, typingSlash) {
|
|
109
|
+
var ranges = cm.listSelections(), replacements = [];
|
|
110
|
+
var head = typingSlash ? "/" : "</";
|
|
111
|
+
var opt = cm.getOption("autoCloseTags");
|
|
112
|
+
var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnSlash);
|
|
113
|
+
for (var i = 0; i < ranges.length; i++) {
|
|
114
|
+
if (!ranges[i].empty()) return CodeMirror.Pass;
|
|
115
|
+
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
|
116
|
+
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
|
117
|
+
if (typingSlash && (tok.type == "string" || tok.string.charAt(0) != "<" ||
|
|
118
|
+
tok.start != pos.ch - 1))
|
|
119
|
+
return CodeMirror.Pass;
|
|
120
|
+
// Kludge to get around the fact that we are not in XML mode
|
|
121
|
+
// when completing in JS/CSS snippet in htmlmixed mode. Does not
|
|
122
|
+
// work for other XML embedded languages (there is no general
|
|
123
|
+
// way to go from a mixed mode to its current XML state).
|
|
124
|
+
var replacement, mixed = inner.mode.name != "xml" && cm.getMode().name == "htmlmixed"
|
|
125
|
+
if (mixed && inner.mode.name == "javascript") {
|
|
126
|
+
replacement = head + "script";
|
|
127
|
+
} else if (mixed && inner.mode.name == "css") {
|
|
128
|
+
replacement = head + "style";
|
|
129
|
+
} else {
|
|
130
|
+
var context = inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state)
|
|
131
|
+
var top = context.length ? context[context.length - 1] : ""
|
|
132
|
+
if (!context || (context.length && closingTagExists(cm, context, top, pos)))
|
|
133
|
+
return CodeMirror.Pass;
|
|
134
|
+
replacement = head + top
|
|
135
|
+
}
|
|
136
|
+
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
|
|
137
|
+
replacements[i] = replacement;
|
|
138
|
+
}
|
|
139
|
+
cm.replaceSelections(replacements);
|
|
140
|
+
ranges = cm.listSelections();
|
|
141
|
+
if (!dontIndentOnAutoClose) {
|
|
142
|
+
for (var i = 0; i < ranges.length; i++)
|
|
143
|
+
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
|
|
144
|
+
cm.indentLine(ranges[i].head.line);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function autoCloseSlash(cm) {
|
|
149
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
|
150
|
+
return autoCloseCurrent(cm, true);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
|
|
154
|
+
|
|
155
|
+
function indexOf(collection, elt) {
|
|
156
|
+
if (collection.indexOf) return collection.indexOf(elt);
|
|
157
|
+
for (var i = 0, e = collection.length; i < e; ++i)
|
|
158
|
+
if (collection[i] == elt) return i;
|
|
159
|
+
return -1;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// If xml-fold is loaded, we use its functionality to try and verify
|
|
163
|
+
// whether a given tag is actually unclosed.
|
|
164
|
+
function closingTagExists(cm, context, tagName, pos, newTag) {
|
|
165
|
+
if (!CodeMirror.scanForClosingTag) return false;
|
|
166
|
+
var end = Math.min(cm.lastLine() + 1, pos.line + 500);
|
|
167
|
+
var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
|
168
|
+
if (!nextClose || nextClose.tag != tagName) return false;
|
|
169
|
+
// If the immediate wrapping context contains onCx instances of
|
|
170
|
+
// the same tag, a closing tag only exists if there are at least
|
|
171
|
+
// that many closing tags of that type following.
|
|
172
|
+
var onCx = newTag ? 1 : 0
|
|
173
|
+
for (var i = context.length - 1; i >= 0; i--) {
|
|
174
|
+
if (context[i] == tagName) ++onCx
|
|
175
|
+
else break
|
|
176
|
+
}
|
|
177
|
+
pos = nextClose.to;
|
|
178
|
+
for (var i = 1; i < onCx; i++) {
|
|
179
|
+
var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
|
180
|
+
if (!next || next.tag != tagName) return false;
|
|
181
|
+
pos = next.to;
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
});
|