css.js 37 KB

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