codemirror-rails 4.12 → 4.13
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 +45 -22
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +6 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +1 -1
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +14 -9
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +94 -51
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +2 -1
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +211 -123
- data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +36 -12
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/selection/selection-pointer.js +3 -0
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +31 -4
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +46 -7
- data/vendor/assets/javascripts/codemirror/modes/clike.js +5 -1
- data/vendor/assets/javascripts/codemirror/modes/css.js +104 -55
- data/vendor/assets/javascripts/codemirror/modes/cypher.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/forth.js +180 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/idl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/stylus.js +444 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +192 -19
- data/vendor/assets/stylesheets/codemirror/themes/colorforth.css +33 -0
- metadata +4 -1
@@ -11,27 +11,46 @@
|
|
11
11
|
})(function(CodeMirror) {
|
12
12
|
"use strict";
|
13
13
|
|
14
|
-
CodeMirror.defineExtension("annotateScrollbar", function(
|
15
|
-
|
14
|
+
CodeMirror.defineExtension("annotateScrollbar", function(options) {
|
15
|
+
if (typeof options == "string") options = {className: options};
|
16
|
+
return new Annotation(this, options);
|
16
17
|
});
|
17
18
|
|
18
|
-
|
19
|
+
CodeMirror.defineOption("scrollButtonHeight", 0);
|
20
|
+
|
21
|
+
function Annotation(cm, options) {
|
19
22
|
this.cm = cm;
|
20
|
-
this.
|
23
|
+
this.options = options;
|
24
|
+
this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight");
|
21
25
|
this.annotations = [];
|
26
|
+
this.doRedraw = this.doUpdate = null;
|
22
27
|
this.div = cm.getWrapperElement().appendChild(document.createElement("div"));
|
23
28
|
this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none";
|
24
29
|
this.computeScale();
|
25
30
|
|
31
|
+
function scheduleRedraw(delay) {
|
32
|
+
clearTimeout(self.doRedraw);
|
33
|
+
self.doRedraw = setTimeout(function() { self.redraw(); }, delay);
|
34
|
+
}
|
35
|
+
|
26
36
|
var self = this;
|
27
|
-
cm.on("refresh", this.resizeHandler = function(){
|
28
|
-
|
37
|
+
cm.on("refresh", this.resizeHandler = function() {
|
38
|
+
clearTimeout(self.doUpdate);
|
39
|
+
self.doUpdate = setTimeout(function() {
|
40
|
+
if (self.computeScale()) scheduleRedraw(20);
|
41
|
+
}, 100);
|
29
42
|
});
|
43
|
+
cm.on("markerAdded", this.resizeHandler);
|
44
|
+
cm.on("markerCleared", this.resizeHandler);
|
45
|
+
if (options.listenForChanges !== false)
|
46
|
+
cm.on("change", this.changeHandler = function() {
|
47
|
+
scheduleRedraw(250);
|
48
|
+
});
|
30
49
|
}
|
31
50
|
|
32
51
|
Annotation.prototype.computeScale = function() {
|
33
52
|
var cm = this.cm;
|
34
|
-
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight) /
|
53
|
+
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
|
35
54
|
cm.heightAtLine(cm.lastLine() + 1, "local");
|
36
55
|
if (hScale != this.hScale) {
|
37
56
|
this.hScale = hScale;
|
@@ -44,12 +63,12 @@
|
|
44
63
|
this.redraw();
|
45
64
|
};
|
46
65
|
|
47
|
-
Annotation.prototype.redraw = function() {
|
66
|
+
Annotation.prototype.redraw = function(compute) {
|
67
|
+
if (compute !== false) this.computeScale();
|
48
68
|
var cm = this.cm, hScale = this.hScale;
|
49
|
-
if (!cm.display.barWidth) return;
|
50
69
|
|
51
70
|
var frag = document.createDocumentFragment(), anns = this.annotations;
|
52
|
-
for (var i = 0, nextTop; i < anns.length; i++) {
|
71
|
+
if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) {
|
53
72
|
var ann = anns[i];
|
54
73
|
var top = nextTop || cm.charCoords(ann.from, "local").top * hScale;
|
55
74
|
var bottom = cm.charCoords(ann.to, "local").bottom * hScale;
|
@@ -59,11 +78,13 @@
|
|
59
78
|
ann = anns[++i];
|
60
79
|
bottom = cm.charCoords(ann.to, "local").bottom * hScale;
|
61
80
|
}
|
81
|
+
if (bottom == top) continue;
|
62
82
|
var height = Math.max(bottom - top, 3);
|
63
83
|
|
64
84
|
var elt = frag.appendChild(document.createElement("div"));
|
65
|
-
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
|
66
|
-
|
85
|
+
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
|
86
|
+
+ (top + this.buttonHeight) + "px; height: " + height + "px";
|
87
|
+
elt.className = this.options.className;
|
67
88
|
}
|
68
89
|
this.div.textContent = "";
|
69
90
|
this.div.appendChild(frag);
|
@@ -71,6 +92,9 @@
|
|
71
92
|
|
72
93
|
Annotation.prototype.clear = function() {
|
73
94
|
this.cm.off("refresh", this.resizeHandler);
|
95
|
+
this.cm.off("markerAdded", this.resizeHandler);
|
96
|
+
this.cm.off("markerCleared", this.resizeHandler);
|
97
|
+
if (this.changeHandler) this.cm.off("change", this.changeHandler);
|
74
98
|
this.div.parentNode.removeChild(this.div);
|
75
99
|
};
|
76
100
|
});
|
@@ -11,13 +11,18 @@
|
|
11
11
|
})(function(CodeMirror) {
|
12
12
|
"use strict";
|
13
13
|
|
14
|
-
CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold,
|
15
|
-
|
14
|
+
CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) {
|
15
|
+
if (typeof options == "string") options = {className: options};
|
16
|
+
if (!options) options = {};
|
17
|
+
return new SearchAnnotation(this, query, caseFold, options);
|
16
18
|
});
|
17
19
|
|
18
|
-
function SearchAnnotation(cm, query, caseFold,
|
20
|
+
function SearchAnnotation(cm, query, caseFold, options) {
|
19
21
|
this.cm = cm;
|
20
|
-
|
22
|
+
var annotateOptions = {listenForChanges: false};
|
23
|
+
for (var prop in options) annotateOptions[prop] = options[prop];
|
24
|
+
if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
|
25
|
+
this.annotation = cm.annotateScrollbar(annotateOptions);
|
21
26
|
this.query = query;
|
22
27
|
this.caseFold = caseFold;
|
23
28
|
this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1};
|
@@ -16,6 +16,7 @@
|
|
16
16
|
if (data) {
|
17
17
|
CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
|
18
18
|
CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
|
19
|
+
CodeMirror.off(window, "scroll", data.windowScroll);
|
19
20
|
cm.off("cursorActivity", reset);
|
20
21
|
cm.off("scroll", reset);
|
21
22
|
cm.state.selectionPointer = null;
|
@@ -26,12 +27,14 @@
|
|
26
27
|
value: typeof val == "string" ? val : "default",
|
27
28
|
mousemove: function(event) { mousemove(cm, event); },
|
28
29
|
mouseout: function(event) { mouseout(cm, event); },
|
30
|
+
windowScroll: function() { reset(cm); },
|
29
31
|
rects: null,
|
30
32
|
mouseX: null, mouseY: null,
|
31
33
|
willUpdate: false
|
32
34
|
};
|
33
35
|
CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
|
34
36
|
CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
|
37
|
+
CodeMirror.on(window, "scroll", data.windowScroll);
|
35
38
|
cm.on("cursorActivity", reset);
|
36
39
|
cm.on("scroll", reset);
|
37
40
|
}
|
@@ -130,6 +130,13 @@
|
|
130
130
|
data = self.options.responseFilter(doc, query, request, error, data);
|
131
131
|
c(error, data);
|
132
132
|
});
|
133
|
+
},
|
134
|
+
|
135
|
+
destroy: function () {
|
136
|
+
if (this.worker) {
|
137
|
+
this.worker.terminate();
|
138
|
+
this.worker = null;
|
139
|
+
}
|
133
140
|
}
|
134
141
|
};
|
135
142
|
|
@@ -252,7 +259,9 @@
|
|
252
259
|
tip.appendChild(document.createTextNode(" — " + data.doc));
|
253
260
|
if (data.url) {
|
254
261
|
tip.appendChild(document.createTextNode(" "));
|
255
|
-
tip.appendChild(elt("a", null, "[docs]"))
|
262
|
+
var child = tip.appendChild(elt("a", null, "[docs]"));
|
263
|
+
child.href = data.url;
|
264
|
+
child.target = "_blank";
|
256
265
|
}
|
257
266
|
}
|
258
267
|
tempTooltip(cm, tip);
|
@@ -582,15 +591,33 @@
|
|
582
591
|
// Tooltips
|
583
592
|
|
584
593
|
function tempTooltip(cm, content) {
|
594
|
+
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
|
585
595
|
var where = cm.cursorCoords();
|
586
|
-
var tip = makeTooltip(where.right + 1, where.bottom, content);
|
596
|
+
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
|
597
|
+
function maybeClear() {
|
598
|
+
old = true;
|
599
|
+
if (!mouseOnTip) clear();
|
600
|
+
}
|
587
601
|
function clear() {
|
602
|
+
cm.state.ternTooltip = null;
|
588
603
|
if (!tip.parentNode) return;
|
589
604
|
cm.off("cursorActivity", clear);
|
605
|
+
cm.off('blur', clear);
|
606
|
+
cm.off('scroll', clear);
|
590
607
|
fadeOut(tip);
|
591
608
|
}
|
592
|
-
|
609
|
+
var mouseOnTip = false, old = false;
|
610
|
+
CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
|
611
|
+
CodeMirror.on(tip, "mouseout", function(e) {
|
612
|
+
if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) {
|
613
|
+
if (old) clear();
|
614
|
+
else mouseOnTip = false;
|
615
|
+
}
|
616
|
+
});
|
617
|
+
setTimeout(maybeClear, 1700);
|
593
618
|
cm.on("cursorActivity", clear);
|
619
|
+
cm.on('blur', clear);
|
620
|
+
cm.on('scroll', clear);
|
594
621
|
}
|
595
622
|
|
596
623
|
function makeTooltip(x, y, content) {
|
@@ -631,7 +658,7 @@
|
|
631
658
|
// Worker wrapper
|
632
659
|
|
633
660
|
function WorkerServer(ts) {
|
634
|
-
var worker = new Worker(ts.options.workerScript);
|
661
|
+
var worker = ts.worker = new Worker(ts.options.workerScript);
|
635
662
|
worker.postMessage({type: "init",
|
636
663
|
defs: ts.options.defs,
|
637
664
|
plugins: ts.options.plugins,
|
@@ -776,7 +776,16 @@
|
|
776
776
|
},
|
777
777
|
handleEx: function(cm, input) {
|
778
778
|
exCommandDispatcher.processCommand(cm, input);
|
779
|
-
}
|
779
|
+
},
|
780
|
+
|
781
|
+
defineMotion: defineMotion,
|
782
|
+
defineAction: defineAction,
|
783
|
+
defineOperator: defineOperator,
|
784
|
+
mapCommand: mapCommand,
|
785
|
+
_mapCommand: _mapCommand,
|
786
|
+
|
787
|
+
exitVisualMode: exitVisualMode,
|
788
|
+
exitInsertMode: exitInsertMode
|
780
789
|
};
|
781
790
|
|
782
791
|
// Represents the current input state.
|
@@ -1449,7 +1458,7 @@
|
|
1449
1458
|
var operatorMoveTo = operators[operator](
|
1450
1459
|
cm, operatorArgs, cmSel.ranges, oldAnchor, newHead);
|
1451
1460
|
if (vim.visualMode) {
|
1452
|
-
exitVisualMode(cm);
|
1461
|
+
exitVisualMode(cm, operatorMoveTo != null);
|
1453
1462
|
}
|
1454
1463
|
if (operatorMoveTo) {
|
1455
1464
|
cm.setCursor(operatorMoveTo);
|
@@ -1817,6 +1826,10 @@
|
|
1817
1826
|
}
|
1818
1827
|
};
|
1819
1828
|
|
1829
|
+
function defineMotion(name, fn) {
|
1830
|
+
motions[name] = fn;
|
1831
|
+
}
|
1832
|
+
|
1820
1833
|
function fillArray(val, times) {
|
1821
1834
|
var arr = [];
|
1822
1835
|
for (var i = 0; i < times; i++) {
|
@@ -1899,7 +1912,7 @@
|
|
1899
1912
|
vimGlobalState.registerController.pushText(
|
1900
1913
|
args.registerName, 'delete', text,
|
1901
1914
|
args.linewise, vim.visualBlock);
|
1902
|
-
return finalHead;
|
1915
|
+
return clipCursorToContent(cm, finalHead);
|
1903
1916
|
},
|
1904
1917
|
indent: function(cm, args, ranges) {
|
1905
1918
|
var vim = cm.state.vim;
|
@@ -1967,6 +1980,10 @@
|
|
1967
1980
|
}
|
1968
1981
|
};
|
1969
1982
|
|
1983
|
+
function defineOperator(name, fn) {
|
1984
|
+
operators[name] = fn;
|
1985
|
+
}
|
1986
|
+
|
1970
1987
|
var actions = {
|
1971
1988
|
jumpListWalk: function(cm, actionArgs, vim) {
|
1972
1989
|
if (vim.visualMode) {
|
@@ -2183,6 +2200,11 @@
|
|
2183
2200
|
if (vim.visualMode) {
|
2184
2201
|
curStart = cm.getCursor('anchor');
|
2185
2202
|
curEnd = cm.getCursor('head');
|
2203
|
+
if (cursorIsBefore(curEnd, curStart)) {
|
2204
|
+
var tmp = curEnd;
|
2205
|
+
curEnd = curStart;
|
2206
|
+
curStart = tmp;
|
2207
|
+
}
|
2186
2208
|
curEnd.ch = lineLength(cm, curEnd.line) - 1;
|
2187
2209
|
} else {
|
2188
2210
|
// Repeat is the number of lines to join. Minimum 2 lines.
|
@@ -2201,10 +2223,10 @@
|
|
2201
2223
|
cm.replaceRange(text, curStart, tmp);
|
2202
2224
|
}
|
2203
2225
|
var curFinalPos = Pos(curStart.line, finalCh);
|
2204
|
-
cm.setCursor(curFinalPos);
|
2205
2226
|
if (vim.visualMode) {
|
2206
|
-
exitVisualMode(cm);
|
2227
|
+
exitVisualMode(cm, false);
|
2207
2228
|
}
|
2229
|
+
cm.setCursor(curFinalPos);
|
2208
2230
|
},
|
2209
2231
|
newLineAndEnterInsertMode: function(cm, actionArgs, vim) {
|
2210
2232
|
vim.insertMode = true;
|
@@ -2367,7 +2389,7 @@
|
|
2367
2389
|
}
|
2368
2390
|
}
|
2369
2391
|
if (vim.visualMode) {
|
2370
|
-
exitVisualMode(cm);
|
2392
|
+
exitVisualMode(cm, false);
|
2371
2393
|
}
|
2372
2394
|
cm.setCursor(curPosFinal);
|
2373
2395
|
},
|
@@ -2425,7 +2447,7 @@
|
|
2425
2447
|
curStart = cursorIsBefore(selections[0].anchor, selections[0].head) ?
|
2426
2448
|
selections[0].anchor : selections[0].head;
|
2427
2449
|
cm.setCursor(curStart);
|
2428
|
-
exitVisualMode(cm);
|
2450
|
+
exitVisualMode(cm, false);
|
2429
2451
|
} else {
|
2430
2452
|
cm.setCursor(offsetCursor(curEnd, 0, -1));
|
2431
2453
|
}
|
@@ -2473,6 +2495,10 @@
|
|
2473
2495
|
exitInsertMode: exitInsertMode
|
2474
2496
|
};
|
2475
2497
|
|
2498
|
+
function defineAction(name, fn) {
|
2499
|
+
actions[name] = fn;
|
2500
|
+
}
|
2501
|
+
|
2476
2502
|
/*
|
2477
2503
|
* Below are miscellaneous utility functions used by vim.js
|
2478
2504
|
*/
|
@@ -4627,6 +4653,19 @@
|
|
4627
4653
|
}
|
4628
4654
|
}
|
4629
4655
|
|
4656
|
+
function _mapCommand(command) {
|
4657
|
+
defaultKeymap.push(command);
|
4658
|
+
}
|
4659
|
+
|
4660
|
+
function mapCommand(keys, type, name, args, extra) {
|
4661
|
+
var command = {keys: keys, type: type};
|
4662
|
+
command[type] = name;
|
4663
|
+
command[type + "Args"] = args;
|
4664
|
+
for (var key in extra)
|
4665
|
+
command[key] = extra[key];
|
4666
|
+
_mapCommand(command);
|
4667
|
+
}
|
4668
|
+
|
4630
4669
|
// The timeout in milliseconds for the two-character ESC keymap should be
|
4631
4670
|
// adjusted according to your typing speed to prevent false positives.
|
4632
4671
|
defineOption('insertModeEscKeysTimeout', 200, 'number');
|
@@ -354,7 +354,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
354
354
|
state.tokenize = null;
|
355
355
|
break;
|
356
356
|
}
|
357
|
-
escaped = stream.next()
|
357
|
+
escaped = stream.next() == "\\" && !escaped;
|
358
358
|
}
|
359
359
|
return "string";
|
360
360
|
}
|
@@ -398,6 +398,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
398
398
|
if (!stream.match('""')) return false;
|
399
399
|
state.tokenize = tokenTripleString;
|
400
400
|
return state.tokenize(stream, state);
|
401
|
+
},
|
402
|
+
"'": function(stream) {
|
403
|
+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
404
|
+
return "atom";
|
401
405
|
}
|
402
406
|
}
|
403
407
|
});
|
@@ -16,13 +16,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
16
16
|
|
17
17
|
var indentUnit = config.indentUnit,
|
18
18
|
tokenHooks = parserConfig.tokenHooks,
|
19
|
+
documentTypes = parserConfig.documentTypes || {},
|
19
20
|
mediaTypes = parserConfig.mediaTypes || {},
|
20
21
|
mediaFeatures = parserConfig.mediaFeatures || {},
|
21
22
|
propertyKeywords = parserConfig.propertyKeywords || {},
|
22
23
|
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
24
|
+
fontProperties = parserConfig.fontProperties || {},
|
25
|
+
counterDescriptors = parserConfig.counterDescriptors || {},
|
23
26
|
colorKeywords = parserConfig.colorKeywords || {},
|
24
27
|
valueKeywords = parserConfig.valueKeywords || {},
|
25
|
-
fontProperties = parserConfig.fontProperties || {},
|
26
28
|
allowNested = parserConfig.allowNested;
|
27
29
|
|
28
30
|
var type, override;
|
@@ -57,6 +59,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
57
59
|
if (/[\d.]/.test(stream.peek())) {
|
58
60
|
stream.eatWhile(/[\w.%]/);
|
59
61
|
return ret("number", "unit");
|
62
|
+
} else if (stream.match(/^-[\w\\\-]+/)) {
|
63
|
+
stream.eatWhile(/[\w\\\-]/);
|
64
|
+
if (stream.match(/^\s*:/, false))
|
65
|
+
return ret("variable-2", "variable-definition");
|
66
|
+
return ret("variable-2", "variable");
|
60
67
|
} else if (stream.match(/^\w+-/)) {
|
61
68
|
return ret("meta", "meta");
|
62
69
|
}
|
@@ -66,7 +73,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
66
73
|
return ret("qualifier", "qualifier");
|
67
74
|
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
68
75
|
return ret(null, ch);
|
69
|
-
} else if (ch == "u" && stream.match(
|
76
|
+
} else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
|
77
|
+
(ch == "d" && stream.match("omain(")) ||
|
78
|
+
(ch == "r" && stream.match("egexp("))) {
|
70
79
|
stream.backUp(1);
|
71
80
|
state.tokenize = tokenParenthesized;
|
72
81
|
return ret("property", "word");
|
@@ -148,10 +157,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
148
157
|
return pushContext(state, stream, "block");
|
149
158
|
} else if (type == "}" && state.context.prev) {
|
150
159
|
return popContext(state);
|
151
|
-
} else if (
|
152
|
-
return pushContext(state, stream, "
|
153
|
-
} else if (
|
154
|
-
|
160
|
+
} else if (/@(media|supports|(-moz-)?document)/.test(type)) {
|
161
|
+
return pushContext(state, stream, "atBlock");
|
162
|
+
} else if (/@(font-face|counter-style)/.test(type)) {
|
163
|
+
state.stateArg = type;
|
164
|
+
return "restricted_atBlock_before";
|
155
165
|
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
156
166
|
return "keyframes";
|
157
167
|
} else if (type && type.charAt(0) == "@") {
|
@@ -241,47 +251,63 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
241
251
|
return pass(type, stream, state);
|
242
252
|
};
|
243
253
|
|
244
|
-
states.
|
245
|
-
if (type == "(") return pushContext(state, stream, "
|
254
|
+
states.atBlock = function(type, stream, state) {
|
255
|
+
if (type == "(") return pushContext(state, stream, "atBlock_parens");
|
246
256
|
if (type == "}") return popAndPass(type, stream, state);
|
247
257
|
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
248
258
|
|
249
259
|
if (type == "word") {
|
250
260
|
var word = stream.current().toLowerCase();
|
251
|
-
if (word == "only" || word == "not" || word == "and")
|
261
|
+
if (word == "only" || word == "not" || word == "and" || word == "or")
|
252
262
|
override = "keyword";
|
263
|
+
else if (documentTypes.hasOwnProperty(word))
|
264
|
+
override = "tag";
|
253
265
|
else if (mediaTypes.hasOwnProperty(word))
|
254
266
|
override = "attribute";
|
255
267
|
else if (mediaFeatures.hasOwnProperty(word))
|
256
268
|
override = "property";
|
269
|
+
else if (propertyKeywords.hasOwnProperty(word))
|
270
|
+
override = "property";
|
271
|
+
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
|
272
|
+
override = "string-2";
|
273
|
+
else if (valueKeywords.hasOwnProperty(word))
|
274
|
+
override = "atom";
|
257
275
|
else
|
258
276
|
override = "error";
|
259
277
|
}
|
260
278
|
return state.context.type;
|
261
279
|
};
|
262
280
|
|
263
|
-
states.
|
281
|
+
states.atBlock_parens = function(type, stream, state) {
|
264
282
|
if (type == ")") return popContext(state);
|
265
283
|
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
266
|
-
return states.
|
284
|
+
return states.atBlock(type, stream, state);
|
267
285
|
};
|
268
286
|
|
269
|
-
states.
|
287
|
+
states.restricted_atBlock_before = function(type, stream, state) {
|
270
288
|
if (type == "{")
|
271
|
-
return pushContext(state, stream, "
|
289
|
+
return pushContext(state, stream, "restricted_atBlock");
|
290
|
+
if (type == "word" && state.stateArg == "@counter-style") {
|
291
|
+
override = "variable";
|
292
|
+
return "restricted_atBlock_before";
|
293
|
+
}
|
272
294
|
return pass(type, stream, state);
|
273
295
|
};
|
274
296
|
|
275
|
-
states.
|
276
|
-
if (type == "}")
|
297
|
+
states.restricted_atBlock = function(type, stream, state) {
|
298
|
+
if (type == "}") {
|
299
|
+
state.stateArg = null;
|
300
|
+
return popContext(state);
|
301
|
+
}
|
277
302
|
if (type == "word") {
|
278
|
-
if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
|
303
|
+
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
|
304
|
+
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
|
279
305
|
override = "error";
|
280
306
|
else
|
281
307
|
override = "property";
|
282
308
|
return "maybeprop";
|
283
309
|
}
|
284
|
-
return "
|
310
|
+
return "restricted_atBlock";
|
285
311
|
};
|
286
312
|
|
287
313
|
states.keyframes = function(type, stream, state) {
|
@@ -309,6 +335,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
309
335
|
startState: function(base) {
|
310
336
|
return {tokenize: null,
|
311
337
|
state: "top",
|
338
|
+
stateArg: null,
|
312
339
|
context: new Context("top", base || 0, null)};
|
313
340
|
},
|
314
341
|
|
@@ -329,9 +356,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
329
356
|
var indent = cx.indent;
|
330
357
|
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
331
358
|
if (cx.prev &&
|
332
|
-
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "
|
333
|
-
ch == ")" && (cx.type == "parens" || cx.type == "
|
334
|
-
ch == "{" && (cx.type == "at" || cx.type == "
|
359
|
+
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") ||
|
360
|
+
ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
|
361
|
+
ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) {
|
335
362
|
indent = cx.indent - indentUnit;
|
336
363
|
cx = cx.prev;
|
337
364
|
}
|
@@ -353,6 +380,10 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
353
380
|
return keys;
|
354
381
|
}
|
355
382
|
|
383
|
+
var documentTypes_ = [
|
384
|
+
"domain", "regexp", "url", "url-prefix"
|
385
|
+
], documentTypes = keySet(documentTypes_);
|
386
|
+
|
356
387
|
var mediaTypes_ = [
|
357
388
|
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
358
389
|
"tty", "tv", "embossed"
|
@@ -469,6 +500,16 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
469
500
|
"searchfield-results-decoration", "zoom"
|
470
501
|
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
471
502
|
|
503
|
+
var fontProperties_ = [
|
504
|
+
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
505
|
+
"font-stretch", "font-weight", "font-style"
|
506
|
+
], fontProperties = keySet(fontProperties_);
|
507
|
+
|
508
|
+
var counterDescriptors_ = [
|
509
|
+
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
|
510
|
+
"speak-as", "suffix", "symbols", "system"
|
511
|
+
], counterDescriptors = keySet(counterDescriptors_);
|
512
|
+
|
472
513
|
var colorKeywords_ = [
|
473
514
|
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
474
515
|
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
@@ -499,32 +540,33 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
499
540
|
], colorKeywords = keySet(colorKeywords_);
|
500
541
|
|
501
542
|
var valueKeywords_ = [
|
502
|
-
"above", "absolute", "activeborder", "activecaption", "afar",
|
503
|
-
"after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
|
543
|
+
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
|
544
|
+
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
|
504
545
|
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
505
|
-
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
|
546
|
+
"arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
|
506
547
|
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
507
548
|
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
508
|
-
"both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
|
509
|
-
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
|
549
|
+
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
550
|
+
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
|
510
551
|
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
511
|
-
"cell", "center", "checkbox", "circle", "cjk-earthly-branch",
|
552
|
+
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
|
512
553
|
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
513
554
|
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
|
514
|
-
"content-box", "context-menu", "continuous", "copy", "cover", "crop",
|
515
|
-
"cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
|
555
|
+
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
|
556
|
+
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
|
516
557
|
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
517
558
|
"destination-in", "destination-out", "destination-over", "devanagari",
|
518
|
-
"disc", "discard", "
|
519
|
-
"
|
559
|
+
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
|
560
|
+
"dot-dash", "dot-dot-dash",
|
561
|
+
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
520
562
|
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
|
521
563
|
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
|
522
564
|
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
|
523
565
|
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
|
524
566
|
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
525
567
|
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
526
|
-
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
|
527
|
-
"ethiopic-
|
568
|
+
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
|
569
|
+
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
|
528
570
|
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",
|
529
571
|
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
530
572
|
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
@@ -533,12 +575,14 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
533
575
|
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
534
576
|
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
535
577
|
"inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
|
536
|
-
"italic", "
|
578
|
+
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
|
579
|
+
"katakana", "katakana-iroha", "keep-all", "khmer",
|
580
|
+
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
|
537
581
|
"landscape", "lao", "large", "larger", "left", "level", "lighter",
|
538
|
-
"line-through", "linear", "lines", "list-item", "listbox", "listitem",
|
582
|
+
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
|
539
583
|
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
540
584
|
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
541
|
-
"lower-roman", "lowercase", "ltr", "malayalam", "match",
|
585
|
+
"lower-roman", "lowercase", "ltr", "malayalam", "match", "matrix", "matrix3d",
|
542
586
|
"media-controls-background", "media-current-time-display",
|
543
587
|
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
544
588
|
"media-return-to-realtime-button", "media-rewind-button",
|
@@ -550,45 +594,48 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
550
594
|
"mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
|
551
595
|
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
552
596
|
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
553
|
-
"ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
|
597
|
+
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
|
554
598
|
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
555
599
|
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
556
|
-
"painted", "page", "paused", "persian", "plus-darker", "plus-lighter",
|
557
|
-
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
|
558
|
-
"
|
559
|
-
"
|
560
|
-
"
|
561
|
-
"
|
600
|
+
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
|
601
|
+
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
|
602
|
+
"progress", "push-button", "radial-gradient", "radio", "read-only",
|
603
|
+
"read-write", "read-write-plaintext-only", "rectangle", "region",
|
604
|
+
"relative", "repeat", "repeating-linear-gradient",
|
605
|
+
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
606
|
+
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
|
607
|
+
"rotateZ", "round", "row-resize", "rtl", "run-in", "running",
|
608
|
+
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
|
609
|
+
"scroll", "scrollbar", "se-resize", "searchfield",
|
562
610
|
"searchfield-cancel-button", "searchfield-decoration",
|
563
611
|
"searchfield-results-button", "searchfield-results-decoration",
|
564
612
|
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
565
|
-
"
|
613
|
+
"simp-chinese-formal", "simp-chinese-informal", "single",
|
614
|
+
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
566
615
|
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
567
616
|
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
|
568
|
-
"source-atop", "source-in", "source-out", "source-over", "space", "square",
|
569
|
-
"square-button", "start", "static", "status-bar", "stretch", "stroke",
|
570
|
-
"
|
617
|
+
"source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
|
618
|
+
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
|
619
|
+
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
|
571
620
|
"table-caption", "table-cell", "table-column", "table-column-group",
|
572
621
|
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
622
|
+
"tamil",
|
573
623
|
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
|
574
624
|
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
575
625
|
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
576
626
|
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
627
|
+
"trad-chinese-formal", "trad-chinese-informal",
|
628
|
+
"translate", "translate3d", "translateX", "translateY", "translateZ",
|
577
629
|
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
|
578
630
|
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
579
631
|
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
580
|
-
"vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
632
|
+
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
581
633
|
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
582
|
-
"window", "windowframe", "windowtext", "x-large", "x-small", "xor",
|
634
|
+
"window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
|
583
635
|
"xx-large", "xx-small"
|
584
636
|
], valueKeywords = keySet(valueKeywords_);
|
585
637
|
|
586
|
-
var
|
587
|
-
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
588
|
-
"font-stretch", "font-weight", "font-style"
|
589
|
-
], fontProperties = keySet(fontProperties_);
|
590
|
-
|
591
|
-
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
|
638
|
+
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_)
|
592
639
|
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
|
593
640
|
CodeMirror.registerHelper("hintWords", "css", allWords);
|
594
641
|
|
@@ -615,13 +662,15 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|
615
662
|
}
|
616
663
|
|
617
664
|
CodeMirror.defineMIME("text/css", {
|
665
|
+
documentTypes: documentTypes,
|
618
666
|
mediaTypes: mediaTypes,
|
619
667
|
mediaFeatures: mediaFeatures,
|
620
668
|
propertyKeywords: propertyKeywords,
|
621
669
|
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
670
|
+
fontProperties: fontProperties,
|
671
|
+
counterDescriptors: counterDescriptors,
|
622
672
|
colorKeywords: colorKeywords,
|
623
673
|
valueKeywords: valueKeywords,
|
624
|
-
fontProperties: fontProperties,
|
625
674
|
tokenHooks: {
|
626
675
|
"<": function(stream, state) {
|
627
676
|
if (!stream.match("!--")) return false;
|