css.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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" && stream.match(/rl(-prefix)?\(/)) ||
  75. (ch == "d" && stream.match("omain(")) ||
  76. (ch == "r" && stream.match("egexp("))) {
  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/.test(type)) {
  149. return pushContext(state, stream, "atComponentBlock");
  150. } else if (/^@(-moz-)?document$/.test(type)) {
  151. return pushContext(state, stream, "documentTypes");
  152. } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
  153. return pushContext(state, stream, "atBlock");
  154. } else if (/^@(font-face|counter-style)/.test(type)) {
  155. state.stateArg = type;
  156. return "restricted_atBlock_before";
  157. } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.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. lineComment: lineComment,
  374. fold: "brace"
  375. };
  376. });
  377. function keySet(array) {
  378. var keys = {};
  379. for (var i = 0; i < array.length; ++i) {
  380. keys[array[i].toLowerCase()] = true;
  381. }
  382. return keys;
  383. }
  384. var documentTypes_ = [
  385. "domain", "regexp", "url", "url-prefix"
  386. ], documentTypes = keySet(documentTypes_);
  387. var mediaTypes_ = [
  388. "all", "aural", "braille", "handheld", "print", "projection", "screen",
  389. "tty", "tv", "embossed"
  390. ], mediaTypes = keySet(mediaTypes_);
  391. var mediaFeatures_ = [
  392. "width", "min-width", "max-width", "height", "min-height", "max-height",
  393. "device-width", "min-device-width", "max-device-width", "device-height",
  394. "min-device-height", "max-device-height", "aspect-ratio",
  395. "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
  396. "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
  397. "max-color", "color-index", "min-color-index", "max-color-index",
  398. "monochrome", "min-monochrome", "max-monochrome", "resolution",
  399. "min-resolution", "max-resolution", "scan", "grid", "orientation",
  400. "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
  401. "pointer", "any-pointer", "hover", "any-hover"
  402. ], mediaFeatures = keySet(mediaFeatures_);
  403. var mediaValueKeywords_ = [
  404. "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
  405. "interlace", "progressive"
  406. ], mediaValueKeywords = keySet(mediaValueKeywords_);
  407. var propertyKeywords_ = [
  408. "align-content", "align-items", "align-self", "alignment-adjust",
  409. "alignment-baseline", "anchor-point", "animation", "animation-delay",
  410. "animation-direction", "animation-duration", "animation-fill-mode",
  411. "animation-iteration-count", "animation-name", "animation-play-state",
  412. "animation-timing-function", "appearance", "azimuth", "backface-visibility",
  413. "background", "background-attachment", "background-blend-mode", "background-clip",
  414. "background-color", "background-image", "background-origin", "background-position",
  415. "background-repeat", "background-size", "baseline-shift", "binding",
  416. "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
  417. "bookmark-target", "border", "border-bottom", "border-bottom-color",
  418. "border-bottom-left-radius", "border-bottom-right-radius",
  419. "border-bottom-style", "border-bottom-width", "border-collapse",
  420. "border-color", "border-image", "border-image-outset",
  421. "border-image-repeat", "border-image-slice", "border-image-source",
  422. "border-image-width", "border-left", "border-left-color",
  423. "border-left-style", "border-left-width", "border-radius", "border-right",
  424. "border-right-color", "border-right-style", "border-right-width",
  425. "border-spacing", "border-style", "border-top", "border-top-color",
  426. "border-top-left-radius", "border-top-right-radius", "border-top-style",
  427. "border-top-width", "border-width", "bottom", "box-decoration-break",
  428. "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
  429. "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
  430. "column-fill", "column-gap", "column-rule", "column-rule-color",
  431. "column-rule-style", "column-rule-width", "column-span", "column-width",
  432. "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
  433. "cue-after", "cue-before", "cursor", "direction", "display",
  434. "dominant-baseline", "drop-initial-after-adjust",
  435. "drop-initial-after-align", "drop-initial-before-adjust",
  436. "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
  437. "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
  438. "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
  439. "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
  440. "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
  441. "font-stretch", "font-style", "font-synthesis", "font-variant",
  442. "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
  443. "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
  444. "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
  445. "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
  446. "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
  447. "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
  448. "grid-template-rows", "hanging-punctuation", "height", "hyphens",
  449. "icon", "image-orientation", "image-rendering", "image-resolution",
  450. "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
  451. "line-break", "line-height", "line-stacking", "line-stacking-ruby",
  452. "line-stacking-shift", "line-stacking-strategy", "list-style",
  453. "list-style-image", "list-style-position", "list-style-type", "margin",
  454. "margin-bottom", "margin-left", "margin-right", "margin-top",
  455. "marks", "marquee-direction", "marquee-loop",
  456. "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
  457. "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
  458. "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
  459. "opacity", "order", "orphans", "outline",
  460. "outline-color", "outline-offset", "outline-style", "outline-width",
  461. "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
  462. "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
  463. "page", "page-break-after", "page-break-before", "page-break-inside",
  464. "page-policy", "pause", "pause-after", "pause-before", "perspective",
  465. "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
  466. "presentation-level", "punctuation-trim", "quotes", "region-break-after",
  467. "region-break-before", "region-break-inside", "region-fragment",
  468. "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
  469. "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
  470. "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
  471. "shape-outside", "size", "speak", "speak-as", "speak-header",
  472. "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
  473. "tab-size", "table-layout", "target", "target-name", "target-new",
  474. "target-position", "text-align", "text-align-last", "text-decoration",
  475. "text-decoration-color", "text-decoration-line", "text-decoration-skip",
  476. "text-decoration-style", "text-emphasis", "text-emphasis-color",
  477. "text-emphasis-position", "text-emphasis-style", "text-height",
  478. "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
  479. "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
  480. "text-wrap", "top", "transform", "transform-origin", "transform-style",
  481. "transition", "transition-delay", "transition-duration",
  482. "transition-property", "transition-timing-function", "unicode-bidi",
  483. "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
  484. "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
  485. "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
  486. "word-spacing", "word-wrap", "z-index",
  487. // SVG-specific
  488. "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
  489. "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
  490. "color-interpolation", "color-interpolation-filters",
  491. "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
  492. "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
  493. "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
  494. "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
  495. "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
  496. "glyph-orientation-vertical", "text-anchor", "writing-mode"
  497. ], propertyKeywords = keySet(propertyKeywords_);
  498. var nonStandardPropertyKeywords_ = [
  499. "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
  500. "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
  501. "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
  502. "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
  503. "searchfield-results-decoration", "zoom"
  504. ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
  505. var fontProperties_ = [
  506. "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
  507. "font-stretch", "font-weight", "font-style"
  508. ], fontProperties = keySet(fontProperties_);
  509. var counterDescriptors_ = [
  510. "additive-symbols", "fallback", "negative", "pad", "prefix", "range",
  511. "speak-as", "suffix", "symbols", "system"
  512. ], counterDescriptors = keySet(counterDescriptors_);
  513. var colorKeywords_ = [
  514. "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
  515. "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
  516. "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
  517. "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
  518. "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
  519. "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
  520. "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
  521. "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
  522. "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
  523. "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
  524. "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
  525. "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
  526. "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
  527. "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
  528. "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
  529. "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
  530. "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
  531. "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
  532. "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
  533. "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
  534. "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
  535. "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
  536. "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
  537. "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
  538. "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
  539. "whitesmoke", "yellow", "yellowgreen"
  540. ], colorKeywords = keySet(colorKeywords_);
  541. var valueKeywords_ = [
  542. "above", "absolute", "activeborder", "additive", "activecaption", "afar",
  543. "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
  544. "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
  545. "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
  546. "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
  547. "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
  548. "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
  549. "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
  550. "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
  551. "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
  552. "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
  553. "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
  554. "compact", "condensed", "contain", "content", "contents",
  555. "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
  556. "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
  557. "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
  558. "destination-in", "destination-out", "destination-over", "devanagari", "difference",
  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",
  562. "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
  563. "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
  564. "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
  565. "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
  566. "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
  567. "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
  568. "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
  569. "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
  570. "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
  571. "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
  572. "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
  573. "help", "hidden", "hide", "higher", "highlight", "highlighttext",
  574. "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
  575. "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
  576. "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
  577. "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
  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",
  581. "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
  582. "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
  583. "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
  584. "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
  585. "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
  586. "media-controls-background", "media-current-time-display",
  587. "media-fullscreen-button", "media-mute-button", "media-play-button",
  588. "media-return-to-realtime-button", "media-rewind-button",
  589. "media-seek-back-button", "media-seek-forward-button", "media-slider",
  590. "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
  591. "media-volume-slider-container", "media-volume-sliderthumb", "medium",
  592. "menu", "menulist", "menulist-button", "menulist-text",
  593. "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
  594. "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
  595. "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
  596. "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
  597. "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
  598. "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
  599. "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
  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", "row-resize", "row-reverse", "rtl", "run-in", "running",
  608. "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
  609. "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
  610. "searchfield-cancel-button", "searchfield-decoration",
  611. "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
  612. "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
  613. "simp-chinese-formal", "simp-chinese-informal", "single",
  614. "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
  615. "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
  616. "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
  617. "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
  618. "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
  619. "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
  620. "table-caption", "table-cell", "table-column", "table-column-group",
  621. "table-footer-group", "table-header-group", "table-row", "table-row-group",
  622. "tamil",
  623. "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
  624. "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
  625. "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
  626. "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
  627. "trad-chinese-formal", "trad-chinese-informal", "transform",
  628. "translate", "translate3d", "translateX", "translateY", "translateZ",
  629. "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
  630. "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
  631. "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
  632. "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
  633. "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
  634. "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
  635. "xx-large", "xx-small"
  636. ], valueKeywords = keySet(valueKeywords_);
  637. var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
  638. .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
  639. .concat(valueKeywords_);
  640. CodeMirror.registerHelper("hintWords", "css", allWords);
  641. function tokenCComment(stream, state) {
  642. var maybeEnd = false, ch;
  643. while ((ch = stream.next()) != null) {
  644. if (maybeEnd && ch == "/") {
  645. state.tokenize = null;
  646. break;
  647. }
  648. maybeEnd = (ch == "*");
  649. }
  650. return ["comment", "comment"];
  651. }
  652. CodeMirror.defineMIME("text/css", {
  653. documentTypes: documentTypes,
  654. mediaTypes: mediaTypes,
  655. mediaFeatures: mediaFeatures,
  656. mediaValueKeywords: mediaValueKeywords,
  657. propertyKeywords: propertyKeywords,
  658. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  659. fontProperties: fontProperties,
  660. counterDescriptors: counterDescriptors,
  661. colorKeywords: colorKeywords,
  662. valueKeywords: valueKeywords,
  663. tokenHooks: {
  664. "/": function(stream, state) {
  665. if (!stream.eat("*")) return false;
  666. state.tokenize = tokenCComment;
  667. return tokenCComment(stream, state);
  668. }
  669. },
  670. name: "css"
  671. });
  672. CodeMirror.defineMIME("text/x-scss", {
  673. mediaTypes: mediaTypes,
  674. mediaFeatures: mediaFeatures,
  675. mediaValueKeywords: mediaValueKeywords,
  676. propertyKeywords: propertyKeywords,
  677. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  678. colorKeywords: colorKeywords,
  679. valueKeywords: valueKeywords,
  680. fontProperties: fontProperties,
  681. allowNested: true,
  682. lineComment: "//",
  683. tokenHooks: {
  684. "/": function(stream, state) {
  685. if (stream.eat("/")) {
  686. stream.skipToEnd();
  687. return ["comment", "comment"];
  688. } else if (stream.eat("*")) {
  689. state.tokenize = tokenCComment;
  690. return tokenCComment(stream, state);
  691. } else {
  692. return ["operator", "operator"];
  693. }
  694. },
  695. ":": function(stream) {
  696. if (stream.match(/\s*\{/, false))
  697. return [null, null]
  698. return false;
  699. },
  700. "$": function(stream) {
  701. stream.match(/^[\w-]+/);
  702. if (stream.match(/^\s*:/, false))
  703. return ["variable-2", "variable-definition"];
  704. return ["variable-2", "variable"];
  705. },
  706. "#": function(stream) {
  707. if (!stream.eat("{")) return false;
  708. return [null, "interpolation"];
  709. }
  710. },
  711. name: "css",
  712. helperType: "scss"
  713. });
  714. CodeMirror.defineMIME("text/x-less", {
  715. mediaTypes: mediaTypes,
  716. mediaFeatures: mediaFeatures,
  717. mediaValueKeywords: mediaValueKeywords,
  718. propertyKeywords: propertyKeywords,
  719. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  720. colorKeywords: colorKeywords,
  721. valueKeywords: valueKeywords,
  722. fontProperties: fontProperties,
  723. allowNested: true,
  724. lineComment: "//",
  725. tokenHooks: {
  726. "/": function(stream, state) {
  727. if (stream.eat("/")) {
  728. stream.skipToEnd();
  729. return ["comment", "comment"];
  730. } else if (stream.eat("*")) {
  731. state.tokenize = tokenCComment;
  732. return tokenCComment(stream, state);
  733. } else {
  734. return ["operator", "operator"];
  735. }
  736. },
  737. "@": function(stream) {
  738. if (stream.eat("{")) return [null, "interpolation"];
  739. if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
  740. stream.eatWhile(/[\w\\\-]/);
  741. if (stream.match(/^\s*:/, false))
  742. return ["variable-2", "variable-definition"];
  743. return ["variable-2", "variable"];
  744. },
  745. "&": function() {
  746. return ["atom", "atom"];
  747. }
  748. },
  749. name: "css",
  750. helperType: "less"
  751. });
  752. CodeMirror.defineMIME("text/x-gss", {
  753. documentTypes: documentTypes,
  754. mediaTypes: mediaTypes,
  755. mediaFeatures: mediaFeatures,
  756. propertyKeywords: propertyKeywords,
  757. nonStandardPropertyKeywords: nonStandardPropertyKeywords,
  758. fontProperties: fontProperties,
  759. counterDescriptors: counterDescriptors,
  760. colorKeywords: colorKeywords,
  761. valueKeywords: valueKeywords,
  762. supportsAtComponent: true,
  763. tokenHooks: {
  764. "/": function(stream, state) {
  765. if (!stream.eat("*")) return false;
  766. state.tokenize = tokenCComment;
  767. return tokenCComment(stream, state);
  768. }
  769. },
  770. name: "css",
  771. helperType: "gss"
  772. });
  773. });