You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

867 lines
40KB

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