Bug 22773: (follow-up) Ensure buttons only affect their related table
[koha.git] / koha-tmpl / intranet-tmpl / lib / codemirror / css.js
1 /* CodeMirror version: 5.40.2 */
2 // CodeMirror, copyright (c) by Marijn Haverbeke and others
3 // Distributed under an MIT license: https://codemirror.net/LICENSE
4
5 (function(mod) {
6   if (typeof exports == "object" && typeof module == "object") // CommonJS
7     mod(require("../../lib/codemirror"));
8   else if (typeof define == "function" && define.amd) // AMD
9     define(["../../lib/codemirror"], mod);
10   else // Plain browser env
11     mod(CodeMirror);
12 })(function(CodeMirror) {
13 "use strict";
14
15 CodeMirror.defineMode("css", function(config, parserConfig) {
16   var inline = parserConfig.inline
17   if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
18
19   var indentUnit = config.indentUnit,
20       tokenHooks = parserConfig.tokenHooks,
21       documentTypes = parserConfig.documentTypes || {},
22       mediaTypes = parserConfig.mediaTypes || {},
23       mediaFeatures = parserConfig.mediaFeatures || {},
24       mediaValueKeywords = parserConfig.mediaValueKeywords || {},
25       propertyKeywords = parserConfig.propertyKeywords || {},
26       nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
27       fontProperties = parserConfig.fontProperties || {},
28       counterDescriptors = parserConfig.counterDescriptors || {},
29       colorKeywords = parserConfig.colorKeywords || {},
30       valueKeywords = parserConfig.valueKeywords || {},
31       allowNested = parserConfig.allowNested,
32       lineComment = parserConfig.lineComment,
33       supportsAtComponent = parserConfig.supportsAtComponent === true;
34
35   var type, override;
36   function ret(style, tp) { type = tp; return style; }
37
38   // Tokenizers
39
40   function tokenBase(stream, state) {
41     var ch = stream.next();
42     if (tokenHooks[ch]) {
43       var result = tokenHooks[ch](stream, state);
44       if (result !== false) return result;
45     }
46     if (ch == "@") {
47       stream.eatWhile(/[\w\\\-]/);
48       return ret("def", stream.current());
49     } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
50       return ret(null, "compare");
51     } else if (ch == "\"" || ch == "'") {
52       state.tokenize = tokenString(ch);
53       return state.tokenize(stream, state);
54     } else if (ch == "#") {
55       stream.eatWhile(/[\w\\\-]/);
56       return ret("atom", "hash");
57     } else if (ch == "!") {
58       stream.match(/^\s*\w*/);
59       return ret("keyword", "important");
60     } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
61       stream.eatWhile(/[\w.%]/);
62       return ret("number", "unit");
63     } else if (ch === "-") {
64       if (/[\d.]/.test(stream.peek())) {
65         stream.eatWhile(/[\w.%]/);
66         return ret("number", "unit");
67       } else if (stream.match(/^-[\w\\\-]+/)) {
68         stream.eatWhile(/[\w\\\-]/);
69         if (stream.match(/^\s*:/, false))
70           return ret("variable-2", "variable-definition");
71         return ret("variable-2", "variable");
72       } else if (stream.match(/^\w+-/)) {
73         return ret("meta", "meta");
74       }
75     } else if (/[,+>*\/]/.test(ch)) {
76       return ret(null, "select-op");
77     } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
78       return ret("qualifier", "qualifier");
79     } else if (/[:;{}\[\]\(\)]/.test(ch)) {
80       return ret(null, ch);
81     } else if (((ch == "u" || ch == "U") && stream.match(/rl(-prefix)?\(/i)) ||
82                ((ch == "d" || ch == "D") && stream.match("omain(", true, true)) ||
83                ((ch == "r" || ch == "R") && stream.match("egexp(", true, true))) {
84       stream.backUp(1);
85       state.tokenize = tokenParenthesized;
86       return ret("property", "word");
87     } else if (/[\w\\\-]/.test(ch)) {
88       stream.eatWhile(/[\w\\\-]/);
89       return ret("property", "word");
90     } else {
91       return ret(null, null);
92     }
93   }
94
95   function tokenString(quote) {
96     return function(stream, state) {
97       var escaped = false, ch;
98       while ((ch = stream.next()) != null) {
99         if (ch == quote && !escaped) {
100           if (quote == ")") stream.backUp(1);
101           break;
102         }
103         escaped = !escaped && ch == "\\";
104       }
105       if (ch == quote || !escaped && quote != ")") state.tokenize = null;
106       return ret("string", "string");
107     };
108   }
109
110   function tokenParenthesized(stream, state) {
111     stream.next(); // Must be '('
112     if (!stream.match(/\s*[\"\')]/, false))
113       state.tokenize = tokenString(")");
114     else
115       state.tokenize = null;
116     return ret(null, "(");
117   }
118
119   // Context management
120
121   function Context(type, indent, prev) {
122     this.type = type;
123     this.indent = indent;
124     this.prev = prev;
125   }
126
127   function pushContext(state, stream, type, indent) {
128     state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
129     return type;
130   }
131
132   function popContext(state) {
133     if (state.context.prev)
134       state.context = state.context.prev;
135     return state.context.type;
136   }
137
138   function pass(type, stream, state) {
139     return states[state.context.type](type, stream, state);
140   }
141   function popAndPass(type, stream, state, n) {
142     for (var i = n || 1; i > 0; i--)
143       state.context = state.context.prev;
144     return pass(type, stream, state);
145   }
146
147   // Parser
148
149   function wordAsValue(stream) {
150     var word = stream.current().toLowerCase();
151     if (valueKeywords.hasOwnProperty(word))
152       override = "atom";
153     else if (colorKeywords.hasOwnProperty(word))
154       override = "keyword";
155     else
156       override = "variable";
157   }
158
159   var states = {};
160
161   states.top = function(type, stream, state) {
162     if (type == "{") {
163       return pushContext(state, stream, "block");
164     } else if (type == "}" && state.context.prev) {
165       return popContext(state);
166     } else if (supportsAtComponent && /@component/i.test(type)) {
167       return pushContext(state, stream, "atComponentBlock");
168     } else if (/^@(-moz-)?document$/i.test(type)) {
169       return pushContext(state, stream, "documentTypes");
170     } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
171       return pushContext(state, stream, "atBlock");
172     } else if (/^@(font-face|counter-style)/i.test(type)) {
173       state.stateArg = type;
174       return "restricted_atBlock_before";
175     } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
176       return "keyframes";
177     } else if (type && type.charAt(0) == "@") {
178       return pushContext(state, stream, "at");
179     } else if (type == "hash") {
180       override = "builtin";
181     } else if (type == "word") {
182       override = "tag";
183     } else if (type == "variable-definition") {
184       return "maybeprop";
185     } else if (type == "interpolation") {
186       return pushContext(state, stream, "interpolation");
187     } else if (type == ":") {
188       return "pseudo";
189     } else if (allowNested && type == "(") {
190       return pushContext(state, stream, "parens");
191     }
192     return state.context.type;
193   };
194
195   states.block = function(type, stream, state) {
196     if (type == "word") {
197       var word = stream.current().toLowerCase();
198       if (propertyKeywords.hasOwnProperty(word)) {
199         override = "property";
200         return "maybeprop";
201       } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
202         override = "string-2";
203         return "maybeprop";
204       } else if (allowNested) {
205         override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
206         return "block";
207       } else {
208         override += " error";
209         return "maybeprop";
210       }
211     } else if (type == "meta") {
212       return "block";
213     } else if (!allowNested && (type == "hash" || type == "qualifier")) {
214       override = "error";
215       return "block";
216     } else {
217       return states.top(type, stream, state);
218     }
219   };
220
221   states.maybeprop = function(type, stream, state) {
222     if (type == ":") return pushContext(state, stream, "prop");
223     return pass(type, stream, state);
224   };
225
226   states.prop = function(type, stream, state) {
227     if (type == ";") return popContext(state);
228     if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
229     if (type == "}" || type == "{") return popAndPass(type, stream, state);
230     if (type == "(") return pushContext(state, stream, "parens");
231
232     if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
233       override += " error";
234     } else if (type == "word") {
235       wordAsValue(stream);
236     } else if (type == "interpolation") {
237       return pushContext(state, stream, "interpolation");
238     }
239     return "prop";
240   };
241
242   states.propBlock = function(type, _stream, state) {
243     if (type == "}") return popContext(state);
244     if (type == "word") { override = "property"; return "maybeprop"; }
245     return state.context.type;
246   };
247
248   states.parens = function(type, stream, state) {
249     if (type == "{" || type == "}") return popAndPass(type, stream, state);
250     if (type == ")") return popContext(state);
251     if (type == "(") return pushContext(state, stream, "parens");
252     if (type == "interpolation") return pushContext(state, stream, "interpolation");
253     if (type == "word") wordAsValue(stream);
254     return "parens";
255   };
256
257   states.pseudo = function(type, stream, state) {
258     if (type == "meta") return "pseudo";
259
260     if (type == "word") {
261       override = "variable-3";
262       return state.context.type;
263     }
264     return pass(type, stream, state);
265   };
266
267   states.documentTypes = function(type, stream, state) {
268     if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
269       override = "tag";
270       return state.context.type;
271     } else {
272       return states.atBlock(type, stream, state);
273     }
274   };
275
276   states.atBlock = function(type, stream, state) {
277     if (type == "(") return pushContext(state, stream, "atBlock_parens");
278     if (type == "}" || type == ";") return popAndPass(type, stream, state);
279     if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
280
281     if (type == "interpolation") return pushContext(state, stream, "interpolation");
282
283     if (type == "word") {
284       var word = stream.current().toLowerCase();
285       if (word == "only" || word == "not" || word == "and" || word == "or")
286         override = "keyword";
287       else if (mediaTypes.hasOwnProperty(word))
288         override = "attribute";
289       else if (mediaFeatures.hasOwnProperty(word))
290         override = "property";
291       else if (mediaValueKeywords.hasOwnProperty(word))
292         override = "keyword";
293       else if (propertyKeywords.hasOwnProperty(word))
294         override = "property";
295       else if (nonStandardPropertyKeywords.hasOwnProperty(word))
296         override = "string-2";
297       else if (valueKeywords.hasOwnProperty(word))
298         override = "atom";
299       else if (colorKeywords.hasOwnProperty(word))
300         override = "keyword";
301       else
302         override = "error";
303     }
304     return state.context.type;
305   };
306
307   states.atComponentBlock = function(type, stream, state) {
308     if (type == "}")
309       return popAndPass(type, stream, state);
310     if (type == "{")
311       return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
312     if (type == "word")
313       override = "error";
314     return state.context.type;
315   };
316
317   states.atBlock_parens = function(type, stream, state) {
318     if (type == ")") return popContext(state);
319     if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
320     return states.atBlock(type, stream, state);
321   };
322
323   states.restricted_atBlock_before = function(type, stream, state) {
324     if (type == "{")
325       return pushContext(state, stream, "restricted_atBlock");
326     if (type == "word" && state.stateArg == "@counter-style") {
327       override = "variable";
328       return "restricted_atBlock_before";
329     }
330     return pass(type, stream, state);
331   };
332
333   states.restricted_atBlock = function(type, stream, state) {
334     if (type == "}") {
335       state.stateArg = null;
336       return popContext(state);
337     }
338     if (type == "word") {
339       if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
340           (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
341         override = "error";
342       else
343         override = "property";
344       return "maybeprop";
345     }
346     return "restricted_atBlock";
347   };
348
349   states.keyframes = function(type, stream, state) {
350     if (type == "word") { override = "variable"; return "keyframes"; }
351     if (type == "{") return pushContext(state, stream, "top");
352     return pass(type, stream, state);
353   };
354
355   states.at = function(type, stream, state) {
356     if (type == ";") return popContext(state);
357     if (type == "{" || type == "}") return popAndPass(type, stream, state);
358     if (type == "word") override = "tag";
359     else if (type == "hash") override = "builtin";
360     return "at";
361   };
362
363   states.interpolation = function(type, stream, state) {
364     if (type == "}") return popContext(state);
365     if (type == "{" || type == ";") return popAndPass(type, stream, state);
366     if (type == "word") override = "variable";
367     else if (type != "variable" && type != "(" && type != ")") override = "error";
368     return "interpolation";
369   };
370
371   return {
372     startState: function(base) {
373       return {tokenize: null,
374               state: inline ? "block" : "top",
375               stateArg: null,
376               context: new Context(inline ? "block" : "top", base || 0, null)};
377     },
378
379     token: function(stream, state) {
380       if (!state.tokenize && stream.eatSpace()) return null;
381       var style = (state.tokenize || tokenBase)(stream, state);
382       if (style && typeof style == "object") {
383         type = style[1];
384         style = style[0];
385       }
386       override = style;
387       if (type != "comment")
388         state.state = states[state.state](type, stream, state);
389       return override;
390     },
391
392     indent: function(state, textAfter) {
393       var cx = state.context, ch = textAfter && textAfter.charAt(0);
394       var indent = cx.indent;
395       if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
396       if (cx.prev) {
397         if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
398                           cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
399           // Resume indentation from parent context.
400           cx = cx.prev;
401           indent = cx.indent;
402         } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
403             ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
404           // Dedent relative to current context.
405           indent = Math.max(0, cx.indent - indentUnit);
406         }
407       }
408       return indent;
409     },
410
411     electricChars: "}",
412     blockCommentStart: "/*",
413     blockCommentEnd: "*/",
414     blockCommentContinue: " * ",
415     lineComment: lineComment,
416     fold: "brace"
417   };
418 });
419
420   function keySet(array) {
421     var keys = {};
422     for (var i = 0; i < array.length; ++i) {
423       keys[array[i].toLowerCase()] = true;
424     }
425     return keys;
426   }
427
428   var documentTypes_ = [
429     "domain", "regexp", "url", "url-prefix"
430   ], documentTypes = keySet(documentTypes_);
431
432   var mediaTypes_ = [
433     "all", "aural", "braille", "handheld", "print", "projection", "screen",
434     "tty", "tv", "embossed"
435   ], mediaTypes = keySet(mediaTypes_);
436
437   var mediaFeatures_ = [
438     "width", "min-width", "max-width", "height", "min-height", "max-height",
439     "device-width", "min-device-width", "max-device-width", "device-height",
440     "min-device-height", "max-device-height", "aspect-ratio",
441     "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
442     "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
443     "max-color", "color-index", "min-color-index", "max-color-index",
444     "monochrome", "min-monochrome", "max-monochrome", "resolution",
445     "min-resolution", "max-resolution", "scan", "grid", "orientation",
446     "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
447     "pointer", "any-pointer", "hover", "any-hover"
448   ], mediaFeatures = keySet(mediaFeatures_);
449
450   var mediaValueKeywords_ = [
451     "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
452     "interlace", "progressive"
453   ], mediaValueKeywords = keySet(mediaValueKeywords_);
454
455   var propertyKeywords_ = [
456     "align-content", "align-items", "align-self", "alignment-adjust",
457     "alignment-baseline", "anchor-point", "animation", "animation-delay",
458     "animation-direction", "animation-duration", "animation-fill-mode",
459     "animation-iteration-count", "animation-name", "animation-play-state",
460     "animation-timing-function", "appearance", "azimuth", "backface-visibility",
461     "background", "background-attachment", "background-blend-mode", "background-clip",
462     "background-color", "background-image", "background-origin", "background-position",
463     "background-repeat", "background-size", "baseline-shift", "binding",
464     "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
465     "bookmark-target", "border", "border-bottom", "border-bottom-color",
466     "border-bottom-left-radius", "border-bottom-right-radius",
467     "border-bottom-style", "border-bottom-width", "border-collapse",
468     "border-color", "border-image", "border-image-outset",
469     "border-image-repeat", "border-image-slice", "border-image-source",
470     "border-image-width", "border-left", "border-left-color",
471     "border-left-style", "border-left-width", "border-radius", "border-right",
472     "border-right-color", "border-right-style", "border-right-width",
473     "border-spacing", "border-style", "border-top", "border-top-color",
474     "border-top-left-radius", "border-top-right-radius", "border-top-style",
475     "border-top-width", "border-width", "bottom", "box-decoration-break",
476     "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
477     "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
478     "column-fill", "column-gap", "column-rule", "column-rule-color",
479     "column-rule-style", "column-rule-width", "column-span", "column-width",
480     "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
481     "cue-after", "cue-before", "cursor", "direction", "display",
482     "dominant-baseline", "drop-initial-after-adjust",
483     "drop-initial-after-align", "drop-initial-before-adjust",
484     "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
485     "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
486     "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
487     "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
488     "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
489     "font-stretch", "font-style", "font-synthesis", "font-variant",
490     "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
491     "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
492     "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
493     "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
494     "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
495     "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
496     "grid-template-rows", "hanging-punctuation", "height", "hyphens",
497     "icon", "image-orientation", "image-rendering", "image-resolution",
498     "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
499     "line-break", "line-height", "line-stacking", "line-stacking-ruby",
500     "line-stacking-shift", "line-stacking-strategy", "list-style",
501     "list-style-image", "list-style-position", "list-style-type", "margin",
502     "margin-bottom", "margin-left", "margin-right", "margin-top",
503     "marks", "marquee-direction", "marquee-loop",
504     "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
505     "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
506     "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
507     "opacity", "order", "orphans", "outline",
508     "outline-color", "outline-offset", "outline-style", "outline-width",
509     "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
510     "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
511     "page", "page-break-after", "page-break-before", "page-break-inside",
512     "page-policy", "pause", "pause-after", "pause-before", "perspective",
513     "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
514     "presentation-level", "punctuation-trim", "quotes", "region-break-after",
515     "region-break-before", "region-break-inside", "region-fragment",
516     "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
517     "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
518     "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
519     "shape-outside", "size", "speak", "speak-as", "speak-header",
520     "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
521     "tab-size", "table-layout", "target", "target-name", "target-new",
522     "target-position", "text-align", "text-align-last", "text-decoration",
523     "text-decoration-color", "text-decoration-line", "text-decoration-skip",
524     "text-decoration-style", "text-emphasis", "text-emphasis-color",
525     "text-emphasis-position", "text-emphasis-style", "text-height",
526     "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
527     "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
528     "text-wrap", "top", "transform", "transform-origin", "transform-style",
529     "transition", "transition-delay", "transition-duration",
530     "transition-property", "transition-timing-function", "unicode-bidi",
531     "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
532     "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
533     "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
534     "word-spacing", "word-wrap", "z-index",
535     // SVG-specific
536     "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
537     "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
538     "color-interpolation", "color-interpolation-filters",
539     "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
540     "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
541     "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
542     "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
543     "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
544     "glyph-orientation-vertical", "text-anchor", "writing-mode"
545   ], propertyKeywords = keySet(propertyKeywords_);
546
547   var nonStandardPropertyKeywords_ = [
548     "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
549     "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
550     "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
551     "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
552     "searchfield-results-decoration", "zoom"
553   ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
554
555   var fontProperties_ = [
556     "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
557     "font-stretch", "font-weight", "font-style"
558   ], fontProperties = keySet(fontProperties_);
559
560   var counterDescriptors_ = [
561     "additive-symbols", "fallback", "negative", "pad", "prefix", "range",
562     "speak-as", "suffix", "symbols", "system"
563   ], counterDescriptors = keySet(counterDescriptors_);
564
565   var colorKeywords_ = [
566     "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
567     "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
568     "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
569     "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
570     "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
571     "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
572     "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
573     "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
574     "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
575     "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
576     "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
577     "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
578     "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
579     "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
580     "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
581     "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
582     "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
583     "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
584     "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
585     "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
586     "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
587     "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
588     "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
589     "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
590     "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
591     "whitesmoke", "yellow", "yellowgreen"
592   ], colorKeywords = keySet(colorKeywords_);
593
594   var valueKeywords_ = [
595     "above", "absolute", "activeborder", "additive", "activecaption", "afar",
596     "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
597     "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
598     "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
599     "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
600     "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
601     "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
602     "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
603     "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
604     "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
605     "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
606     "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
607     "compact", "condensed", "contain", "content", "contents",
608     "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
609     "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
610     "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
611     "destination-in", "destination-out", "destination-over", "devanagari", "difference",
612     "disc", "discard", "disclosure-closed", "disclosure-open", "document",
613     "dot-dash", "dot-dot-dash",
614     "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
615     "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
616     "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
617     "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
618     "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
619     "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
620     "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
621     "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
622     "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
623     "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
624     "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
625     "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
626     "help", "hidden", "hide", "higher", "highlight", "highlighttext",
627     "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
628     "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
629     "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
630     "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
631     "italic", "japanese-formal", "japanese-informal", "justify", "kannada",
632     "katakana", "katakana-iroha", "keep-all", "khmer",
633     "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
634     "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
635     "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
636     "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
637     "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
638     "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
639     "media-controls-background", "media-current-time-display",
640     "media-fullscreen-button", "media-mute-button", "media-play-button",
641     "media-return-to-realtime-button", "media-rewind-button",
642     "media-seek-back-button", "media-seek-forward-button", "media-slider",
643     "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
644     "media-volume-slider-container", "media-volume-sliderthumb", "medium",
645     "menu", "menulist", "menulist-button", "menulist-text",
646     "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
647     "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
648     "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
649     "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
650     "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
651     "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
652     "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
653     "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
654     "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
655     "progress", "push-button", "radial-gradient", "radio", "read-only",
656     "read-write", "read-write-plaintext-only", "rectangle", "region",
657     "relative", "repeat", "repeating-linear-gradient",
658     "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
659     "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
660     "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
661     "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
662     "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
663     "searchfield-cancel-button", "searchfield-decoration",
664     "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
665     "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
666     "simp-chinese-formal", "simp-chinese-informal", "single",
667     "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
668     "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
669     "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
670     "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
671     "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
672     "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
673     "table-caption", "table-cell", "table-column", "table-column-group",
674     "table-footer-group", "table-header-group", "table-row", "table-row-group",
675     "tamil",
676     "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
677     "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
678     "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
679     "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
680     "trad-chinese-formal", "trad-chinese-informal", "transform",
681     "translate", "translate3d", "translateX", "translateY", "translateZ",
682     "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
683     "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
684     "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
685     "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
686     "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
687     "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
688     "xx-large", "xx-small"
689   ], valueKeywords = keySet(valueKeywords_);
690
691   var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
692     .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
693     .concat(valueKeywords_);
694   CodeMirror.registerHelper("hintWords", "css", allWords);
695
696   function tokenCComment(stream, state) {
697     var maybeEnd = false, ch;
698     while ((ch = stream.next()) != null) {
699       if (maybeEnd && ch == "/") {
700         state.tokenize = null;
701         break;
702       }
703       maybeEnd = (ch == "*");
704     }
705     return ["comment", "comment"];
706   }
707
708   CodeMirror.defineMIME("text/css", {
709     documentTypes: documentTypes,
710     mediaTypes: mediaTypes,
711     mediaFeatures: mediaFeatures,
712     mediaValueKeywords: mediaValueKeywords,
713     propertyKeywords: propertyKeywords,
714     nonStandardPropertyKeywords: nonStandardPropertyKeywords,
715     fontProperties: fontProperties,
716     counterDescriptors: counterDescriptors,
717     colorKeywords: colorKeywords,
718     valueKeywords: valueKeywords,
719     tokenHooks: {
720       "/": function(stream, state) {
721         if (!stream.eat("*")) return false;
722         state.tokenize = tokenCComment;
723         return tokenCComment(stream, state);
724       }
725     },
726     name: "css"
727   });
728
729   CodeMirror.defineMIME("text/x-scss", {
730     mediaTypes: mediaTypes,
731     mediaFeatures: mediaFeatures,
732     mediaValueKeywords: mediaValueKeywords,
733     propertyKeywords: propertyKeywords,
734     nonStandardPropertyKeywords: nonStandardPropertyKeywords,
735     colorKeywords: colorKeywords,
736     valueKeywords: valueKeywords,
737     fontProperties: fontProperties,
738     allowNested: true,
739     lineComment: "//",
740     tokenHooks: {
741       "/": function(stream, state) {
742         if (stream.eat("/")) {
743           stream.skipToEnd();
744           return ["comment", "comment"];
745         } else if (stream.eat("*")) {
746           state.tokenize = tokenCComment;
747           return tokenCComment(stream, state);
748         } else {
749           return ["operator", "operator"];
750         }
751       },
752       ":": function(stream) {
753         if (stream.match(/\s*\{/, false))
754           return [null, null]
755         return false;
756       },
757       "$": function(stream) {
758         stream.match(/^[\w-]+/);
759         if (stream.match(/^\s*:/, false))
760           return ["variable-2", "variable-definition"];
761         return ["variable-2", "variable"];
762       },
763       "#": function(stream) {
764         if (!stream.eat("{")) return false;
765         return [null, "interpolation"];
766       }
767     },
768     name: "css",
769     helperType: "scss"
770   });
771
772   CodeMirror.defineMIME("text/x-less", {
773     mediaTypes: mediaTypes,
774     mediaFeatures: mediaFeatures,
775     mediaValueKeywords: mediaValueKeywords,
776     propertyKeywords: propertyKeywords,
777     nonStandardPropertyKeywords: nonStandardPropertyKeywords,
778     colorKeywords: colorKeywords,
779     valueKeywords: valueKeywords,
780     fontProperties: fontProperties,
781     allowNested: true,
782     lineComment: "//",
783     tokenHooks: {
784       "/": function(stream, state) {
785         if (stream.eat("/")) {
786           stream.skipToEnd();
787           return ["comment", "comment"];
788         } else if (stream.eat("*")) {
789           state.tokenize = tokenCComment;
790           return tokenCComment(stream, state);
791         } else {
792           return ["operator", "operator"];
793         }
794       },
795       "@": function(stream) {
796         if (stream.eat("{")) return [null, "interpolation"];
797         if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
798         stream.eatWhile(/[\w\\\-]/);
799         if (stream.match(/^\s*:/, false))
800           return ["variable-2", "variable-definition"];
801         return ["variable-2", "variable"];
802       },
803       "&": function() {
804         return ["atom", "atom"];
805       }
806     },
807     name: "css",
808     helperType: "less"
809   });
810
811   CodeMirror.defineMIME("text/x-gss", {
812     documentTypes: documentTypes,
813     mediaTypes: mediaTypes,
814     mediaFeatures: mediaFeatures,
815     propertyKeywords: propertyKeywords,
816     nonStandardPropertyKeywords: nonStandardPropertyKeywords,
817     fontProperties: fontProperties,
818     counterDescriptors: counterDescriptors,
819     colorKeywords: colorKeywords,
820     valueKeywords: valueKeywords,
821     supportsAtComponent: true,
822     tokenHooks: {
823       "/": function(stream, state) {
824         if (!stream.eat("*")) return false;
825         state.tokenize = tokenCComment;
826         return tokenCComment(stream, state);
827       }
828     },
829     name: "css",
830     helperType: "gss"
831   });
832
833 });