mode-css.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. define("ace/mode/css_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  2. "use strict";
  3. var oop = ace_require("../lib/oop");
  4. var lang = ace_require("../lib/lang");
  5. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  6. var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|bottom|box-shadow|box-sizing|caption-side|clear|clip|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|max-zoom|min-height|min-width|min-zoom|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|user-select|user-zoom|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index";
  7. var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
  8. var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero|zoom";
  9. var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";
  10. var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
  11. var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))";
  12. var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
  13. var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
  14. var CssHighlightRules = function() {
  15. var keywordMapper = this.createKeywordMapper({
  16. "support.function": supportFunction,
  17. "support.constant": supportConstant,
  18. "support.type": supportType,
  19. "support.constant.color": supportConstantColor,
  20. "support.constant.fonts": supportConstantFonts
  21. }, "text", true);
  22. this.$rules = {
  23. "start" : [{
  24. include : ["strings", "url", "comments"]
  25. }, {
  26. token: "paren.lparen",
  27. regex: "\\{",
  28. next: "ruleset"
  29. }, {
  30. token: "paren.rparen",
  31. regex: "\\}"
  32. }, {
  33. token: "string",
  34. regex: "@(?!viewport)",
  35. next: "media"
  36. }, {
  37. token: "keyword",
  38. regex: "#[a-z0-9-_]+"
  39. }, {
  40. token: "keyword",
  41. regex: "%"
  42. }, {
  43. token: "variable",
  44. regex: "\\.[a-z0-9-_]+"
  45. }, {
  46. token: "string",
  47. regex: ":[a-z0-9-_]+"
  48. }, {
  49. token : "constant.numeric",
  50. regex : numRe
  51. }, {
  52. token: "constant",
  53. regex: "[a-z0-9-_]+"
  54. }, {
  55. caseInsensitive: true
  56. }],
  57. "media": [{
  58. include : ["strings", "url", "comments"]
  59. }, {
  60. token: "paren.lparen",
  61. regex: "\\{",
  62. next: "start"
  63. }, {
  64. token: "paren.rparen",
  65. regex: "\\}",
  66. next: "start"
  67. }, {
  68. token: "string",
  69. regex: ";",
  70. next: "start"
  71. }, {
  72. token: "keyword",
  73. regex: "(?:media|supports|document|charset|import|namespace|media|supports|document"
  74. + "|page|font|keyframes|viewport|counter-style|font-feature-values"
  75. + "|swash|ornaments|annotation|stylistic|styleset|character-variant)"
  76. }],
  77. "comments" : [{
  78. token: "comment", // multi line comment
  79. regex: "\\/\\*",
  80. push: [{
  81. token : "comment",
  82. regex : "\\*\\/",
  83. next : "pop"
  84. }, {
  85. defaultToken : "comment"
  86. }]
  87. }],
  88. "ruleset" : [{
  89. regex : "-(webkit|ms|moz|o)-",
  90. token : "text"
  91. }, {
  92. token : "punctuation.operator",
  93. regex : "[:;]"
  94. }, {
  95. token : "paren.rparen",
  96. regex : "\\}",
  97. next : "start"
  98. }, {
  99. include : ["strings", "url", "comments"]
  100. }, {
  101. token : ["constant.numeric", "keyword"],
  102. regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vm|vw|%)"
  103. }, {
  104. token : "constant.numeric",
  105. regex : numRe
  106. }, {
  107. token : "constant.numeric", // hex6 color
  108. regex : "#[a-f0-9]{6}"
  109. }, {
  110. token : "constant.numeric", // hex3 color
  111. regex : "#[a-f0-9]{3}"
  112. }, {
  113. token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
  114. regex : pseudoElements
  115. }, {
  116. token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
  117. regex : pseudoClasses
  118. }, {
  119. include: "url"
  120. }, {
  121. token : keywordMapper,
  122. regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
  123. }, {
  124. caseInsensitive: true
  125. }],
  126. url: [{
  127. token : "support.function",
  128. regex : "(?:url(:?-prefix)?|domain|regexp)\\(",
  129. push: [{
  130. token : "support.function",
  131. regex : "\\)",
  132. next : "pop"
  133. }, {
  134. defaultToken: "string"
  135. }]
  136. }],
  137. strings: [{
  138. token : "string.start",
  139. regex : "'",
  140. push : [{
  141. token : "string.end",
  142. regex : "'|$",
  143. next: "pop"
  144. }, {
  145. include : "escapes"
  146. }, {
  147. token : "constant.language.escape",
  148. regex : /\\$/,
  149. consumeLineEnd: true
  150. }, {
  151. defaultToken: "string"
  152. }]
  153. }, {
  154. token : "string.start",
  155. regex : '"',
  156. push : [{
  157. token : "string.end",
  158. regex : '"|$',
  159. next: "pop"
  160. }, {
  161. include : "escapes"
  162. }, {
  163. token : "constant.language.escape",
  164. regex : /\\$/,
  165. consumeLineEnd: true
  166. }, {
  167. defaultToken: "string"
  168. }]
  169. }],
  170. escapes: [{
  171. token : "constant.language.escape",
  172. regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/
  173. }]
  174. };
  175. this.normalizeRules();
  176. };
  177. oop.inherits(CssHighlightRules, TextHighlightRules);
  178. exports.CssHighlightRules = CssHighlightRules;
  179. });
  180. define("ace/mode/matching_brace_outdent",["ace_require","exports","module","ace/range"], function(ace_require, exports, module) {
  181. "use strict";
  182. var Range = ace_require("../range").Range;
  183. var MatchingBraceOutdent = function() {};
  184. (function() {
  185. this.checkOutdent = function(line, input) {
  186. if (! /^\s+$/.test(line))
  187. return false;
  188. return /^\s*\}/.test(input);
  189. };
  190. this.autoOutdent = function(doc, row) {
  191. var line = doc.getLine(row);
  192. var match = line.match(/^(\s*\})/);
  193. if (!match) return 0;
  194. var column = match[1].length;
  195. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  196. if (!openBracePos || openBracePos.row == row) return 0;
  197. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  198. doc.replace(new Range(row, 0, row, column-1), indent);
  199. };
  200. this.$getIndent = function(line) {
  201. return line.match(/^\s*/)[0];
  202. };
  203. }).call(MatchingBraceOutdent.prototype);
  204. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  205. });
  206. define("ace/mode/css_completions",["ace_require","exports","module"], function(ace_require, exports, module) {
  207. "use strict";
  208. var propertyMap = {
  209. "background": {"#$0": 1},
  210. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  211. "background-image": {"url('/$0')": 1},
  212. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  213. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  214. "background-attachment": {"scroll": 1, "fixed": 1},
  215. "background-size": {"cover": 1, "contain": 1},
  216. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  217. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  218. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  219. "border-color": {"#$0": 1},
  220. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  221. "border-collapse": {"collapse": 1, "separate": 1},
  222. "bottom": {"px": 1, "em": 1, "%": 1},
  223. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  224. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  225. "cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1},
  226. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  227. "empty-cells": {"show": 1, "hide": 1},
  228. "float": {"left": 1, "right": 1, "none": 1},
  229. "font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1},
  230. "font-size": {"px": 1, "em": 1, "%": 1},
  231. "font-weight": {"bold": 1, "normal": 1},
  232. "font-style": {"italic": 1, "normal": 1},
  233. "font-variant": {"normal": 1, "small-caps": 1},
  234. "height": {"px": 1, "em": 1, "%": 1},
  235. "left": {"px": 1, "em": 1, "%": 1},
  236. "letter-spacing": {"normal": 1},
  237. "line-height": {"normal": 1},
  238. "list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1},
  239. "margin": {"px": 1, "em": 1, "%": 1},
  240. "margin-right": {"px": 1, "em": 1, "%": 1},
  241. "margin-left": {"px": 1, "em": 1, "%": 1},
  242. "margin-top": {"px": 1, "em": 1, "%": 1},
  243. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  244. "max-height": {"px": 1, "em": 1, "%": 1},
  245. "max-width": {"px": 1, "em": 1, "%": 1},
  246. "min-height": {"px": 1, "em": 1, "%": 1},
  247. "min-width": {"px": 1, "em": 1, "%": 1},
  248. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  249. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  250. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  251. "padding": {"px": 1, "em": 1, "%": 1},
  252. "padding-top": {"px": 1, "em": 1, "%": 1},
  253. "padding-right": {"px": 1, "em": 1, "%": 1},
  254. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  255. "padding-left": {"px": 1, "em": 1, "%": 1},
  256. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  257. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  258. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  259. "right": {"px": 1, "em": 1, "%": 1},
  260. "table-layout": {"fixed": 1, "auto": 1},
  261. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  262. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  263. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  264. "top": {"px": 1, "em": 1, "%": 1},
  265. "vertical-align": {"top": 1, "bottom": 1},
  266. "visibility": {"hidden": 1, "visible": 1},
  267. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  268. "width": {"px": 1, "em": 1, "%": 1},
  269. "word-spacing": {"normal": 1},
  270. "filter": {"alpha(opacity=$0100)": 1},
  271. "text-shadow": {"$02px 2px 2px #777": 1},
  272. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  273. "-moz-border-radius": 1,
  274. "-moz-border-radius-topright": 1,
  275. "-moz-border-radius-bottomright": 1,
  276. "-moz-border-radius-topleft": 1,
  277. "-moz-border-radius-bottomleft": 1,
  278. "-webkit-border-radius": 1,
  279. "-webkit-border-top-right-radius": 1,
  280. "-webkit-border-top-left-radius": 1,
  281. "-webkit-border-bottom-right-radius": 1,
  282. "-webkit-border-bottom-left-radius": 1,
  283. "-moz-box-shadow": 1,
  284. "-webkit-box-shadow": 1,
  285. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  286. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  287. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  288. };
  289. var CssCompletions = function() {
  290. };
  291. (function() {
  292. this.completionsDefined = false;
  293. this.defineCompletions = function() {
  294. if (document) {
  295. var style = document.createElement('c').style;
  296. for (var i in style) {
  297. if (typeof style[i] !== 'string')
  298. continue;
  299. var name = i.replace(/[A-Z]/g, function(x) {
  300. return '-' + x.toLowerCase();
  301. });
  302. if (!propertyMap.hasOwnProperty(name))
  303. propertyMap[name] = 1;
  304. }
  305. }
  306. this.completionsDefined = true;
  307. };
  308. this.getCompletions = function(state, session, pos, prefix) {
  309. if (!this.completionsDefined) {
  310. this.defineCompletions();
  311. }
  312. if (state==='ruleset' || session.$mode.$id == "ace/mode/scss") {
  313. var line = session.getLine(pos.row).substr(0, pos.column);
  314. if (/:[^;]+$/.test(line)) {
  315. /([\w\-]+):[^:]*$/.test(line);
  316. return this.getPropertyValueCompletions(state, session, pos, prefix);
  317. } else {
  318. return this.getPropertyCompletions(state, session, pos, prefix);
  319. }
  320. }
  321. return [];
  322. };
  323. this.getPropertyCompletions = function(state, session, pos, prefix) {
  324. var properties = Object.keys(propertyMap);
  325. return properties.map(function(property){
  326. return {
  327. caption: property,
  328. snippet: property + ': $0;',
  329. meta: "property",
  330. score: 1000000
  331. };
  332. });
  333. };
  334. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  335. var line = session.getLine(pos.row).substr(0, pos.column);
  336. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  337. if (!property)
  338. return [];
  339. var values = [];
  340. if (property in propertyMap && typeof propertyMap[property] === "object") {
  341. values = Object.keys(propertyMap[property]);
  342. }
  343. return values.map(function(value){
  344. return {
  345. caption: value,
  346. snippet: value,
  347. meta: "property value",
  348. score: 1000000
  349. };
  350. });
  351. };
  352. }).call(CssCompletions.prototype);
  353. exports.CssCompletions = CssCompletions;
  354. });
  355. define("ace/mode/behaviour/css",["ace_require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(ace_require, exports, module) {
  356. "use strict";
  357. var oop = ace_require("../../lib/oop");
  358. var Behaviour = ace_require("../behaviour").Behaviour;
  359. var CstyleBehaviour = ace_require("./cstyle").CstyleBehaviour;
  360. var TokenIterator = ace_require("../../token_iterator").TokenIterator;
  361. var CssBehaviour = function () {
  362. this.inherit(CstyleBehaviour);
  363. this.add("colon", "insertion", function (state, action, editor, session, text) {
  364. if (text === ':' && editor.selection.isEmpty()) {
  365. var cursor = editor.getCursorPosition();
  366. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  367. var token = iterator.getCurrentToken();
  368. if (token && token.value.match(/\s+/)) {
  369. token = iterator.stepBackward();
  370. }
  371. if (token && token.type === 'support.type') {
  372. var line = session.doc.getLine(cursor.row);
  373. var rightChar = line.substring(cursor.column, cursor.column + 1);
  374. if (rightChar === ':') {
  375. return {
  376. text: '',
  377. selection: [1, 1]
  378. };
  379. }
  380. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  381. return {
  382. text: ':;',
  383. selection: [1, 1]
  384. };
  385. }
  386. }
  387. }
  388. });
  389. this.add("colon", "deletion", function (state, action, editor, session, range) {
  390. var selected = session.doc.getTextRange(range);
  391. if (!range.isMultiLine() && selected === ':') {
  392. var cursor = editor.getCursorPosition();
  393. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  394. var token = iterator.getCurrentToken();
  395. if (token && token.value.match(/\s+/)) {
  396. token = iterator.stepBackward();
  397. }
  398. if (token && token.type === 'support.type') {
  399. var line = session.doc.getLine(range.start.row);
  400. var rightChar = line.substring(range.end.column, range.end.column + 1);
  401. if (rightChar === ';') {
  402. range.end.column ++;
  403. return range;
  404. }
  405. }
  406. }
  407. });
  408. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  409. if (text === ';' && editor.selection.isEmpty()) {
  410. var cursor = editor.getCursorPosition();
  411. var line = session.doc.getLine(cursor.row);
  412. var rightChar = line.substring(cursor.column, cursor.column + 1);
  413. if (rightChar === ';') {
  414. return {
  415. text: '',
  416. selection: [1, 1]
  417. };
  418. }
  419. }
  420. });
  421. this.add("!important", "insertion", function (state, action, editor, session, text) {
  422. if (text === '!' && editor.selection.isEmpty()) {
  423. var cursor = editor.getCursorPosition();
  424. var line = session.doc.getLine(cursor.row);
  425. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  426. return {
  427. text: '!important',
  428. selection: [10, 10]
  429. };
  430. }
  431. }
  432. });
  433. };
  434. oop.inherits(CssBehaviour, CstyleBehaviour);
  435. exports.CssBehaviour = CssBehaviour;
  436. });
  437. define("ace/mode/folding/cstyle",["ace_require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(ace_require, exports, module) {
  438. "use strict";
  439. var oop = ace_require("../../lib/oop");
  440. var Range = ace_require("../../range").Range;
  441. var BaseFoldMode = ace_require("./fold_mode").FoldMode;
  442. var FoldMode = exports.FoldMode = function(commentRegex) {
  443. if (commentRegex) {
  444. this.foldingStartMarker = new RegExp(
  445. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  446. );
  447. this.foldingStopMarker = new RegExp(
  448. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  449. );
  450. }
  451. };
  452. oop.inherits(FoldMode, BaseFoldMode);
  453. (function() {
  454. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  455. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  456. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  457. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  458. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  459. this._getFoldWidgetBase = this.getFoldWidget;
  460. this.getFoldWidget = function(session, foldStyle, row) {
  461. var line = session.getLine(row);
  462. if (this.singleLineBlockCommentRe.test(line)) {
  463. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  464. return "";
  465. }
  466. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  467. if (!fw && this.startRegionRe.test(line))
  468. return "start"; // lineCommentRegionStart
  469. return fw;
  470. };
  471. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  472. var line = session.getLine(row);
  473. if (this.startRegionRe.test(line))
  474. return this.getCommentRegionBlock(session, line, row);
  475. var match = line.match(this.foldingStartMarker);
  476. if (match) {
  477. var i = match.index;
  478. if (match[1])
  479. return this.openingBracketBlock(session, match[1], row, i);
  480. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  481. if (range && !range.isMultiLine()) {
  482. if (forceMultiline) {
  483. range = this.getSectionRange(session, row);
  484. } else if (foldStyle != "all")
  485. range = null;
  486. }
  487. return range;
  488. }
  489. if (foldStyle === "markbegin")
  490. return;
  491. var match = line.match(this.foldingStopMarker);
  492. if (match) {
  493. var i = match.index + match[0].length;
  494. if (match[1])
  495. return this.closingBracketBlock(session, match[1], row, i);
  496. return session.getCommentFoldRange(row, i, -1);
  497. }
  498. };
  499. this.getSectionRange = function(session, row) {
  500. var line = session.getLine(row);
  501. var startIndent = line.search(/\S/);
  502. var startRow = row;
  503. var startColumn = line.length;
  504. row = row + 1;
  505. var endRow = row;
  506. var maxRow = session.getLength();
  507. while (++row < maxRow) {
  508. line = session.getLine(row);
  509. var indent = line.search(/\S/);
  510. if (indent === -1)
  511. continue;
  512. if (startIndent > indent)
  513. break;
  514. var subRange = this.getFoldWidgetRange(session, "all", row);
  515. if (subRange) {
  516. if (subRange.start.row <= startRow) {
  517. break;
  518. } else if (subRange.isMultiLine()) {
  519. row = subRange.end.row;
  520. } else if (startIndent == indent) {
  521. break;
  522. }
  523. }
  524. endRow = row;
  525. }
  526. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  527. };
  528. this.getCommentRegionBlock = function(session, line, row) {
  529. var startColumn = line.search(/\s*$/);
  530. var maxRow = session.getLength();
  531. var startRow = row;
  532. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  533. var depth = 1;
  534. while (++row < maxRow) {
  535. line = session.getLine(row);
  536. var m = re.exec(line);
  537. if (!m) continue;
  538. if (m[1]) depth--;
  539. else depth++;
  540. if (!depth) break;
  541. }
  542. var endRow = row;
  543. if (endRow > startRow) {
  544. return new Range(startRow, startColumn, endRow, line.length);
  545. }
  546. };
  547. }).call(FoldMode.prototype);
  548. });
  549. define("ace/mode/css",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/css_completions","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(ace_require, exports, module) {
  550. "use strict";
  551. var oop = ace_require("../lib/oop");
  552. var TextMode = ace_require("./text").Mode;
  553. var CssHighlightRules = ace_require("./css_highlight_rules").CssHighlightRules;
  554. var MatchingBraceOutdent = ace_require("./matching_brace_outdent").MatchingBraceOutdent;
  555. var WorkerClient = ace_require("../worker/worker_client").WorkerClient;
  556. var CssCompletions = ace_require("./css_completions").CssCompletions;
  557. var CssBehaviour = ace_require("./behaviour/css").CssBehaviour;
  558. var CStyleFoldMode = ace_require("./folding/cstyle").FoldMode;
  559. var Mode = function() {
  560. this.HighlightRules = CssHighlightRules;
  561. this.$outdent = new MatchingBraceOutdent();
  562. this.$behaviour = new CssBehaviour();
  563. this.$completer = new CssCompletions();
  564. this.foldingRules = new CStyleFoldMode();
  565. };
  566. oop.inherits(Mode, TextMode);
  567. (function() {
  568. this.foldingRules = "cStyle";
  569. this.blockComment = {start: "/*", end: "*/"};
  570. this.getNextLineIndent = function(state, line, tab) {
  571. var indent = this.$getIndent(line);
  572. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  573. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  574. return indent;
  575. }
  576. var match = line.match(/^.*\{\s*$/);
  577. if (match) {
  578. indent += tab;
  579. }
  580. return indent;
  581. };
  582. this.checkOutdent = function(state, line, input) {
  583. return this.$outdent.checkOutdent(line, input);
  584. };
  585. this.autoOutdent = function(state, doc, row) {
  586. this.$outdent.autoOutdent(doc, row);
  587. };
  588. this.getCompletions = function(state, session, pos, prefix) {
  589. return this.$completer.getCompletions(state, session, pos, prefix);
  590. };
  591. this.createWorker = function(session) {
  592. var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
  593. worker.attachToDocument(session.getDocument());
  594. worker.on("annotate", function(e) {
  595. session.setAnnotations(e.data);
  596. });
  597. worker.on("terminate", function() {
  598. session.clearAnnotations();
  599. });
  600. return worker;
  601. };
  602. this.$id = "ace/mode/css";
  603. this.snippetFileId = "ace/snippets/css";
  604. }).call(Mode.prototype);
  605. exports.Mode = Mode;
  606. }); (function() {
  607. window.ace_require(["ace/mode/css"], function(m) {
  608. if (typeof module == "object" && typeof exports == "object" && module) {
  609. module.exports = m;
  610. }
  611. });
  612. })();