codemirror-rails 3.13 → 3.14
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.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +328 -250
- data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +7 -6
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +33 -7
- data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +14 -10
- data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +15 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +70 -17
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +56 -20
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +135 -39
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +324 -571
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +199 -109
- data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +60 -113
- data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +24 -0
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +431 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +7 -1
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +46 -20
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +1 -1
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +370 -13
- data/vendor/assets/javascripts/codemirror/keymaps/extra.js +43 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +535 -214
- data/vendor/assets/javascripts/codemirror/modes/clike.js +56 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +19 -14
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +67 -16
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +167 -110
- data/vendor/assets/javascripts/codemirror/modes/sql.js +97 -15
- data/vendor/assets/javascripts/codemirror/modes/xml.js +14 -18
- data/vendor/assets/stylesheets/codemirror.css +0 -1
- data/vendor/assets/stylesheets/codemirror/addons/merge/merge.css +82 -0
- metadata +7 -2
@@ -1,57 +1,168 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
var startCh = cm.getCursor().ch, continued = false;
|
4
|
-
var closeOn = options.closeCharacters || /[\s()\[\]{};:]/;
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
5
3
|
|
6
|
-
function
|
4
|
+
CodeMirror.showHint = function(cm, getHints, options) {
|
7
5
|
// We want a single cursor position.
|
8
6
|
if (cm.somethingSelected()) return;
|
9
7
|
|
10
|
-
if (
|
11
|
-
|
8
|
+
if (cm.state.completionActive) cm.state.completionActive.close();
|
9
|
+
|
10
|
+
var completion = cm.state.completionActive = new Completion(cm, getHints, options || {});
|
11
|
+
CodeMirror.signal(cm, "startCompletion", cm);
|
12
|
+
if (completion.options.async)
|
13
|
+
getHints(cm, function(hints) { completion.showHints(hints); }, completion.options);
|
12
14
|
else
|
13
|
-
return showHints(getHints(cm, options));
|
15
|
+
return completion.showHints(getHints(cm, completion.options));
|
16
|
+
};
|
17
|
+
|
18
|
+
function Completion(cm, getHints, options) {
|
19
|
+
this.cm = cm;
|
20
|
+
this.getHints = getHints;
|
21
|
+
this.options = options;
|
22
|
+
this.widget = this.onClose = null;
|
14
23
|
}
|
15
24
|
|
25
|
+
Completion.prototype = {
|
26
|
+
close: function() {
|
27
|
+
if (!this.active()) return;
|
28
|
+
|
29
|
+
if (this.widget) this.widget.close();
|
30
|
+
if (this.onClose) this.onClose();
|
31
|
+
this.cm.state.completionActive = null;
|
32
|
+
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
33
|
+
},
|
34
|
+
|
35
|
+
active: function() {
|
36
|
+
return this.cm.state.completionActive == this;
|
37
|
+
},
|
38
|
+
|
39
|
+
pick: function(data, i) {
|
40
|
+
var completion = data.list[i];
|
41
|
+
if (completion.hint) completion.hint(this.cm, data, completion);
|
42
|
+
else this.cm.replaceRange(getText(completion), data.from, data.to);
|
43
|
+
this.close();
|
44
|
+
},
|
45
|
+
|
46
|
+
showHints: function(data) {
|
47
|
+
if (!data || !data.list.length || !this.active()) return this.close();
|
48
|
+
|
49
|
+
if (this.options.completeSingle != false && data.list.length == 1)
|
50
|
+
this.pick(data, 0);
|
51
|
+
else
|
52
|
+
this.showWidget(data);
|
53
|
+
},
|
54
|
+
|
55
|
+
showWidget: function(data) {
|
56
|
+
this.widget = new Widget(this, data);
|
57
|
+
CodeMirror.signal(data, "shown");
|
58
|
+
|
59
|
+
var debounce = null, completion = this, finished;
|
60
|
+
var closeOn = this.options.closeCharacters || /[\s()\[\]{};:>,]/;
|
61
|
+
var startPos = this.cm.getCursor(), startLen = this.cm.getLine(startPos.line).length;
|
62
|
+
|
63
|
+
function done() {
|
64
|
+
if (finished) return;
|
65
|
+
finished = true;
|
66
|
+
completion.close();
|
67
|
+
completion.cm.off("cursorActivity", activity);
|
68
|
+
CodeMirror.signal(data, "close");
|
69
|
+
}
|
70
|
+
function isDone() {
|
71
|
+
if (finished) return true;
|
72
|
+
if (!completion.widget) { done(); return true; }
|
73
|
+
}
|
74
|
+
|
75
|
+
function update() {
|
76
|
+
if (isDone()) return;
|
77
|
+
if (completion.options.async)
|
78
|
+
completion.getHints(completion.cm, finishUpdate, completion.options);
|
79
|
+
else
|
80
|
+
finishUpdate(completion.getHints(completion.cm, completion.options));
|
81
|
+
}
|
82
|
+
function finishUpdate(data) {
|
83
|
+
if (isDone()) return;
|
84
|
+
if (!data || !data.list.length) return done();
|
85
|
+
completion.widget.close();
|
86
|
+
completion.widget = new Widget(completion, data);
|
87
|
+
}
|
88
|
+
|
89
|
+
function activity() {
|
90
|
+
clearTimeout(debounce);
|
91
|
+
var pos = completion.cm.getCursor(), line = completion.cm.getLine(pos.line);
|
92
|
+
if (pos.line != startPos.line || line.length - pos.ch != startLen - startPos.ch ||
|
93
|
+
pos.ch < startPos.ch || completion.cm.somethingSelected() ||
|
94
|
+
(pos.ch && closeOn.test(line.charAt(pos.ch - 1))))
|
95
|
+
completion.close();
|
96
|
+
else
|
97
|
+
debounce = setTimeout(update, 170);
|
98
|
+
}
|
99
|
+
this.cm.on("cursorActivity", activity);
|
100
|
+
this.onClose = done;
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
16
104
|
function getText(completion) {
|
17
105
|
if (typeof completion == "string") return completion;
|
18
106
|
else return completion.text;
|
19
107
|
}
|
20
108
|
|
21
|
-
function
|
22
|
-
|
23
|
-
|
109
|
+
function buildKeyMap(options, handle) {
|
110
|
+
var baseMap = {
|
111
|
+
Up: function() {handle.moveFocus(-1);},
|
112
|
+
Down: function() {handle.moveFocus(1);},
|
113
|
+
PageUp: function() {handle.moveFocus(-handle.menuSize());},
|
114
|
+
PageDown: function() {handle.moveFocus(handle.menuSize());},
|
115
|
+
Home: function() {handle.setFocus(0);},
|
116
|
+
End: function() {handle.setFocus(handle.length);},
|
117
|
+
Enter: handle.pick,
|
118
|
+
Tab: handle.pick,
|
119
|
+
Esc: handle.close
|
120
|
+
};
|
121
|
+
var ourMap = options.customKeys ? {} : baseMap;
|
122
|
+
function addBinding(key, val) {
|
123
|
+
var bound;
|
124
|
+
if (typeof val != "string")
|
125
|
+
bound = function(cm) { return val(cm, handle); };
|
126
|
+
// This mechanism is deprecated
|
127
|
+
else if (baseMap.hasOwnProperty(val))
|
128
|
+
bound = baseMap[val];
|
129
|
+
else
|
130
|
+
bound = val;
|
131
|
+
ourMap[key] = bound;
|
132
|
+
}
|
133
|
+
if (options.customKeys)
|
134
|
+
for (var key in options.customKeys) if (options.customKeys.hasOwnProperty(key))
|
135
|
+
addBinding(key, options.customKeys[key]);
|
136
|
+
if (options.extraKeys)
|
137
|
+
for (var key in options.extraKeys) if (options.extraKeys.hasOwnProperty(key))
|
138
|
+
addBinding(key, options.extraKeys[key]);
|
139
|
+
return ourMap;
|
24
140
|
}
|
25
141
|
|
26
|
-
function
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if (!continued && options.completeSingle !== false && completions.length == 1) {
|
31
|
-
pickCompletion(cm, data, completions[0]);
|
32
|
-
CodeMirror.signal(data, "close");
|
33
|
-
return true;
|
34
|
-
}
|
142
|
+
function Widget(completion, data) {
|
143
|
+
this.completion = completion;
|
144
|
+
this.data = data;
|
145
|
+
var widget = this, cm = completion.cm, options = completion.options;
|
35
146
|
|
36
|
-
|
37
|
-
var hints = document.createElement("ul"), selectedHint = 0;
|
147
|
+
var hints = this.hints = document.createElement("ul");
|
38
148
|
hints.className = "CodeMirror-hints";
|
149
|
+
this.selectedHint = 0;
|
150
|
+
|
151
|
+
var completions = data.list;
|
39
152
|
for (var i = 0; i < completions.length; ++i) {
|
40
|
-
var elt = hints.appendChild(document.createElement("li")),
|
153
|
+
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
41
154
|
var className = "CodeMirror-hint" + (i ? "" : " CodeMirror-hint-active");
|
42
|
-
if (
|
155
|
+
if (cur.className != null) className = cur.className + " " + className;
|
43
156
|
elt.className = className;
|
44
|
-
if (
|
45
|
-
else elt.appendChild(document.createTextNode(
|
157
|
+
if (cur.render) cur.render(elt, data, cur);
|
158
|
+
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
46
159
|
elt.hintId = i;
|
47
160
|
}
|
161
|
+
|
48
162
|
var pos = cm.cursorCoords(options.alignWithWord !== false ? data.from : null);
|
49
163
|
var left = pos.left, top = pos.bottom, below = true;
|
50
164
|
hints.style.left = left + "px";
|
51
165
|
hints.style.top = top + "px";
|
52
|
-
document.body.appendChild(hints);
|
53
|
-
CodeMirror.signal(data, "shown");
|
54
|
-
|
55
166
|
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
56
167
|
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
57
168
|
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
@@ -75,106 +186,85 @@ CodeMirror.showHint = function(cm, getHints, options) {
|
|
75
186
|
}
|
76
187
|
hints.style.top = (top = pos.bottom - overlapY) + "px";
|
77
188
|
}
|
189
|
+
(options.container || document.body).appendChild(hints);
|
78
190
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
hints.scrollTop = node.offsetTop - 3;
|
88
|
-
else if (node.offsetTop + node.offsetHeight > hints.scrollTop + hints.clientHeight)
|
89
|
-
hints.scrollTop = node.offsetTop + node.offsetHeight - hints.clientHeight + 3;
|
90
|
-
CodeMirror.signal(data, "select", completions[selectedHint], node);
|
91
|
-
}
|
191
|
+
cm.addKeyMap(this.keyMap = buildKeyMap(options, {
|
192
|
+
moveFocus: function(n) { widget.changeActive(widget.selectedHint + n); },
|
193
|
+
setFocus: function(n) { widget.changeActive(n); },
|
194
|
+
menuSize: function() { return widget.screenAmount(); },
|
195
|
+
length: completions.length,
|
196
|
+
close: function() { completion.close(); },
|
197
|
+
pick: function() { widget.pick(); }
|
198
|
+
}));
|
92
199
|
|
93
|
-
|
94
|
-
|
200
|
+
if (options.closeOnUnfocus !== false) {
|
201
|
+
var closingOnBlur;
|
202
|
+
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
203
|
+
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
95
204
|
}
|
96
205
|
|
97
|
-
var ourMap, baseMap = {
|
98
|
-
Up: function() {changeActive(selectedHint - 1);},
|
99
|
-
Down: function() {changeActive(selectedHint + 1);},
|
100
|
-
PageUp: function() {changeActive(selectedHint - screenAmount());},
|
101
|
-
PageDown: function() {changeActive(selectedHint + screenAmount());},
|
102
|
-
Home: function() {changeActive(0);},
|
103
|
-
End: function() {changeActive(completions.length - 1);},
|
104
|
-
Enter: pick,
|
105
|
-
Tab: pick,
|
106
|
-
Esc: close
|
107
|
-
};
|
108
|
-
if (options.customKeys) {
|
109
|
-
ourMap = {};
|
110
|
-
for (var key in options.customKeys) if (options.customKeys.hasOwnProperty(key)) {
|
111
|
-
var val = options.customKeys[key];
|
112
|
-
if (baseMap.hasOwnProperty(val)) val = baseMap[val];
|
113
|
-
ourMap[key] = val;
|
114
|
-
}
|
115
|
-
} else ourMap = baseMap;
|
116
|
-
|
117
|
-
cm.addKeyMap(ourMap);
|
118
|
-
cm.on("cursorActivity", cursorActivity);
|
119
|
-
var closingOnBlur;
|
120
|
-
function onBlur(){ closingOnBlur = setTimeout(close, 100); };
|
121
|
-
function onFocus(){ clearTimeout(closingOnBlur); };
|
122
|
-
cm.on("blur", onBlur);
|
123
|
-
cm.on("focus", onFocus);
|
124
206
|
var startScroll = cm.getScrollInfo();
|
125
|
-
|
207
|
+
cm.on("scroll", this.onScroll = function() {
|
126
208
|
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
127
|
-
var newTop = top + startScroll.top - curScroll.top
|
209
|
+
var newTop = top + startScroll.top - curScroll.top;
|
210
|
+
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
128
211
|
if (!below) point += hints.offsetHeight;
|
129
|
-
if (point <= editor.top || point >= editor.bottom) return close();
|
212
|
+
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
130
213
|
hints.style.top = newTop + "px";
|
131
214
|
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
132
|
-
}
|
133
|
-
|
215
|
+
});
|
216
|
+
|
134
217
|
CodeMirror.on(hints, "dblclick", function(e) {
|
135
218
|
var t = e.target || e.srcElement;
|
136
|
-
if (t.hintId != null) {
|
219
|
+
if (t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
137
220
|
});
|
138
221
|
CodeMirror.on(hints, "click", function(e) {
|
139
222
|
var t = e.target || e.srcElement;
|
140
|
-
if (t.hintId != null) changeActive(t.hintId);
|
223
|
+
if (t.hintId != null) widget.changeActive(t.hintId);
|
141
224
|
});
|
142
225
|
CodeMirror.on(hints, "mousedown", function() {
|
143
226
|
setTimeout(function(){cm.focus();}, 20);
|
144
227
|
});
|
145
228
|
|
146
|
-
var done = false, once;
|
147
|
-
function close(willContinue) {
|
148
|
-
if (done) return;
|
149
|
-
done = true;
|
150
|
-
clearTimeout(once);
|
151
|
-
hints.parentNode.removeChild(hints);
|
152
|
-
cm.removeKeyMap(ourMap);
|
153
|
-
cm.off("cursorActivity", cursorActivity);
|
154
|
-
cm.off("blur", onBlur);
|
155
|
-
cm.off("focus", onFocus);
|
156
|
-
cm.off("scroll", onScroll);
|
157
|
-
if (willContinue !== true) CodeMirror.signal(data, "close");
|
158
|
-
}
|
159
|
-
function pick() {
|
160
|
-
pickCompletion(cm, data, completions[selectedHint]);
|
161
|
-
close();
|
162
|
-
}
|
163
|
-
var once, lastPos = cm.getCursor(), lastLen = cm.getLine(lastPos.line).length;
|
164
|
-
function cursorActivity() {
|
165
|
-
clearTimeout(once);
|
166
|
-
|
167
|
-
var pos = cm.getCursor(), line = cm.getLine(pos.line);
|
168
|
-
if (pos.line != lastPos.line || line.length - pos.ch != lastLen - lastPos.ch ||
|
169
|
-
pos.ch < startCh || cm.somethingSelected() ||
|
170
|
-
(pos.ch && closeOn.test(line.charAt(pos.ch - 1))))
|
171
|
-
close();
|
172
|
-
else
|
173
|
-
once = setTimeout(function(){close(true); continued = true; startHinting();}, 70);
|
174
|
-
}
|
175
229
|
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
|
176
230
|
return true;
|
177
231
|
}
|
178
232
|
|
179
|
-
|
180
|
-
|
233
|
+
Widget.prototype = {
|
234
|
+
close: function() {
|
235
|
+
if (this.completion.widget != this) return;
|
236
|
+
this.completion.widget = null;
|
237
|
+
this.hints.parentNode.removeChild(this.hints);
|
238
|
+
this.completion.cm.removeKeyMap(this.keyMap);
|
239
|
+
|
240
|
+
var cm = this.completion.cm;
|
241
|
+
if (this.completion.options.closeOnUnfocus !== false) {
|
242
|
+
cm.off("blur", this.onBlur);
|
243
|
+
cm.off("focus", this.onFocus);
|
244
|
+
}
|
245
|
+
cm.off("scroll", this.onScroll);
|
246
|
+
},
|
247
|
+
|
248
|
+
pick: function() {
|
249
|
+
this.completion.pick(this.data, this.selectedHint);
|
250
|
+
},
|
251
|
+
|
252
|
+
changeActive: function(i) {
|
253
|
+
i = Math.max(0, Math.min(i, this.data.list.length - 1));
|
254
|
+
if (this.selectedHint == i) return;
|
255
|
+
var node = this.hints.childNodes[this.selectedHint];
|
256
|
+
node.className = node.className.replace(" CodeMirror-hint-active", "");
|
257
|
+
node = this.hints.childNodes[this.selectedHint = i];
|
258
|
+
node.className += " CodeMirror-hint-active";
|
259
|
+
if (node.offsetTop < this.hints.scrollTop)
|
260
|
+
this.hints.scrollTop = node.offsetTop - 3;
|
261
|
+
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
262
|
+
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
263
|
+
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
264
|
+
},
|
265
|
+
|
266
|
+
screenAmount: function() {
|
267
|
+
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
268
|
+
}
|
269
|
+
};
|
270
|
+
})();
|
@@ -1,118 +1,65 @@
|
|
1
1
|
(function() {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var Pos = CodeMirror.Pos;
|
5
|
+
|
6
|
+
CodeMirror.xmlHint = function(cm, options) {
|
7
|
+
var tags = options && options.schemaInfo;
|
8
|
+
var quote = (options && options.quoteChar) || '"';
|
9
|
+
if (!tags) return;
|
10
|
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
11
|
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
12
|
+
if (inner.mode.name != "xml") return;
|
13
|
+
var result = [], replaceToken = false, prefix;
|
14
|
+
var isTag = token.string.charAt(0) == "<";
|
15
|
+
if (!inner.state.tagName || isTag) { // Tag completion
|
16
|
+
if (isTag) {
|
17
|
+
prefix = token.string.slice(1);
|
18
|
+
replaceToken = true;
|
19
|
+
}
|
20
|
+
var cx = inner.state.context, curTag = cx && tags[cx.tagName];
|
21
|
+
var childList = cx ? curTag && curTag.children : tags["!top"];
|
22
|
+
if (childList) {
|
23
|
+
for (var i = 0; i < childList.length; ++i) if (!prefix || childList[i].indexOf(prefix) == 0)
|
24
|
+
result.push("<" + childList[i]);
|
25
|
+
} else {
|
26
|
+
for (var name in tags) if (tags.hasOwnProperty(name) && name != "!top" && (!prefix || name.indexOf(prefix) == 0))
|
27
|
+
result.push("<" + name);
|
28
|
+
}
|
29
|
+
if (cx && (!prefix || ("/" + cx.tagName).indexOf(prefix) == 0))
|
30
|
+
result.push("</" + cx.tagName + ">");
|
31
|
+
} else {
|
32
|
+
// Attribute completion
|
33
|
+
var curTag = tags[inner.state.tagName], attrs = curTag && curTag.attrs;
|
34
|
+
if (!attrs) return;
|
35
|
+
if (token.type == "string" || token.string == "=") { // A value
|
36
|
+
var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)),
|
37
|
+
Pos(cur.line, token.type == "string" ? token.start : token.end));
|
38
|
+
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
|
39
|
+
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
|
40
|
+
if (token.type == "string") {
|
41
|
+
prefix = token.string;
|
42
|
+
if (/['"]/.test(token.string.charAt(0))) {
|
43
|
+
quote = token.string.charAt(0);
|
44
|
+
prefix = token.string.slice(1);
|
45
|
+
}
|
46
|
+
replaceToken = true;
|
44
47
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
if(text.length >= 0) {
|
52
|
-
|
53
|
-
var regex = new RegExp('<([^!?][^\\s/>]*)[\\s\\S]*?>', 'g');
|
54
|
-
|
55
|
-
var matches = [];
|
56
|
-
var match;
|
57
|
-
while ((match = regex.exec(text)) != null) {
|
58
|
-
matches.push({
|
59
|
-
tag: match[1],
|
60
|
-
selfclose: (match[0].slice(match[0].length - 2) === '/>')
|
61
|
-
});
|
62
|
-
}
|
63
|
-
|
64
|
-
for (var i = matches.length - 1, skip = 0; i >= 0; i--) {
|
65
|
-
|
66
|
-
var item = matches[i];
|
67
|
-
|
68
|
-
if (item.tag[0] == '/')
|
69
|
-
{
|
70
|
-
skip++;
|
71
|
-
}
|
72
|
-
else if (item.selfclose == false)
|
73
|
-
{
|
74
|
-
if (skip > 0)
|
75
|
-
{
|
76
|
-
skip--;
|
77
|
-
}
|
78
|
-
else
|
79
|
-
{
|
80
|
-
element = '<' + item.tag + '>' + element;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
element += getOpenTag(text);
|
48
|
+
for (var i = 0; i < atValues.length; ++i) if (!prefix || atValues[i].indexOf(prefix) == 0)
|
49
|
+
result.push(quote + atValues[i] + quote);
|
50
|
+
} else { // An attribute name
|
51
|
+
if (token.type == "attribute") {
|
52
|
+
prefix = token.string;
|
53
|
+
replaceToken = true;
|
86
54
|
}
|
87
|
-
|
88
|
-
|
55
|
+
for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || attr.indexOf(prefix) == 0))
|
56
|
+
result.push(attr);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return {
|
60
|
+
list: result,
|
61
|
+
from: replaceToken ? Pos(cur.line, token.start) : cur,
|
62
|
+
to: replaceToken ? Pos(cur.line, token.end) : cur
|
89
63
|
};
|
90
|
-
|
91
|
-
var getOpenTag = function(text) {
|
92
|
-
|
93
|
-
var open = text.lastIndexOf('<');
|
94
|
-
var close = text.lastIndexOf('>');
|
95
|
-
|
96
|
-
if (close < open)
|
97
|
-
{
|
98
|
-
text = text.slice(open);
|
99
|
-
|
100
|
-
if(text != '<') {
|
101
|
-
|
102
|
-
var space = text.indexOf(' ');
|
103
|
-
if(space < 0)
|
104
|
-
space = text.indexOf('\t');
|
105
|
-
if(space < 0)
|
106
|
-
space = text.indexOf('\n');
|
107
|
-
|
108
|
-
if (space < 0)
|
109
|
-
space = text.length;
|
110
|
-
|
111
|
-
return text.slice(0, space);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
return '';
|
116
|
-
};
|
117
|
-
|
64
|
+
};
|
118
65
|
})();
|