mode-scss.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  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/scss_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules","ace/mode/css_highlight_rules"], function(ace_require, exports, module) {
  181. "use strict";
  182. var oop = ace_require("../lib/oop");
  183. var lang = ace_require("../lib/lang");
  184. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  185. var CssHighlightRules = ace_require("./css_highlight_rules");
  186. var ScssHighlightRules = function() {
  187. var properties = lang.arrayToMap(CssHighlightRules.supportType.split("|"));
  188. var functions = lang.arrayToMap(
  189. ("hsl|hsla|rgb|rgba|url|attr|counter|counters|abs|adjust_color|adjust_hue|" +
  190. "alpha|join|blue|ceil|change_color|comparable|complement|darken|desaturate|" +
  191. "floor|grayscale|green|hue|if|invert|join|length|lighten|lightness|mix|" +
  192. "nth|opacify|opacity|percentage|quote|red|round|saturate|saturation|" +
  193. "scale_color|transparentize|type_of|unit|unitless|unquote").split("|")
  194. );
  195. var constants = lang.arrayToMap(CssHighlightRules.supportConstant.split("|"));
  196. var colors = lang.arrayToMap(CssHighlightRules.supportConstantColor.split("|"));
  197. var keywords = lang.arrayToMap(
  198. ("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
  199. );
  200. var tags = lang.arrayToMap(
  201. ("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
  202. "big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
  203. "command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
  204. "figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
  205. "header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
  206. "link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
  207. "option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
  208. "small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
  209. "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
  210. );
  211. var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  212. this.$rules = {
  213. "start" : [
  214. {
  215. token : "comment",
  216. regex : "\\/\\/.*$"
  217. },
  218. {
  219. token : "comment", // multi line comment
  220. regex : "\\/\\*",
  221. next : "comment"
  222. }, {
  223. token : "string", // single line
  224. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  225. }, {
  226. token : "string", // multi line string start
  227. regex : '["].*\\\\$',
  228. next : "qqstring"
  229. }, {
  230. token : "string", // single line
  231. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  232. }, {
  233. token : "string", // multi line string start
  234. regex : "['].*\\\\$",
  235. next : "qstring"
  236. }, {
  237. token : "constant.numeric",
  238. 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|%)"
  239. }, {
  240. token : "constant.numeric", // hex6 color
  241. regex : "#[a-f0-9]{6}"
  242. }, {
  243. token : "constant.numeric", // hex3 color
  244. regex : "#[a-f0-9]{3}"
  245. }, {
  246. token : "constant.numeric",
  247. regex : numRe
  248. }, {
  249. token : ["support.function", "string", "support.function"],
  250. regex : "(url\\()(.*)(\\))"
  251. }, {
  252. token : function(value) {
  253. if (properties.hasOwnProperty(value.toLowerCase()))
  254. return "support.type";
  255. if (keywords.hasOwnProperty(value))
  256. return "keyword";
  257. else if (constants.hasOwnProperty(value))
  258. return "constant.language";
  259. else if (functions.hasOwnProperty(value))
  260. return "support.function";
  261. else if (colors.hasOwnProperty(value.toLowerCase()))
  262. return "support.constant.color";
  263. else if (tags.hasOwnProperty(value.toLowerCase()))
  264. return "variable.language";
  265. else
  266. return "text";
  267. },
  268. regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
  269. }, {
  270. token : "variable",
  271. regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b"
  272. }, {
  273. token: "variable.language",
  274. regex: "#[a-z0-9-_]+"
  275. }, {
  276. token: "variable.language",
  277. regex: "\\.[a-z0-9-_]+"
  278. }, {
  279. token: "variable.language",
  280. regex: ":[a-z0-9-_]+"
  281. }, {
  282. token: "constant",
  283. regex: "[a-z0-9-_]+"
  284. }, {
  285. token : "keyword.operator",
  286. regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*"
  287. }, {
  288. token : "paren.lparen",
  289. regex : "[[({]"
  290. }, {
  291. token : "paren.rparen",
  292. regex : "[\\])}]"
  293. }, {
  294. token : "text",
  295. regex : "\\s+"
  296. }, {
  297. caseInsensitive: true
  298. }
  299. ],
  300. "comment" : [
  301. {
  302. token : "comment", // closing comment
  303. regex : "\\*\\/",
  304. next : "start"
  305. }, {
  306. defaultToken : "comment"
  307. }
  308. ],
  309. "qqstring" : [
  310. {
  311. token : "string",
  312. regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  313. next : "start"
  314. }, {
  315. token : "string",
  316. regex : '.+'
  317. }
  318. ],
  319. "qstring" : [
  320. {
  321. token : "string",
  322. regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  323. next : "start"
  324. }, {
  325. token : "string",
  326. regex : '.+'
  327. }
  328. ]
  329. };
  330. };
  331. oop.inherits(ScssHighlightRules, TextHighlightRules);
  332. exports.ScssHighlightRules = ScssHighlightRules;
  333. });
  334. define("ace/mode/matching_brace_outdent",["ace_require","exports","module","ace/range"], function(ace_require, exports, module) {
  335. "use strict";
  336. var Range = ace_require("../range").Range;
  337. var MatchingBraceOutdent = function() {};
  338. (function() {
  339. this.checkOutdent = function(line, input) {
  340. if (! /^\s+$/.test(line))
  341. return false;
  342. return /^\s*\}/.test(input);
  343. };
  344. this.autoOutdent = function(doc, row) {
  345. var line = doc.getLine(row);
  346. var match = line.match(/^(\s*\})/);
  347. if (!match) return 0;
  348. var column = match[1].length;
  349. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  350. if (!openBracePos || openBracePos.row == row) return 0;
  351. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  352. doc.replace(new Range(row, 0, row, column-1), indent);
  353. };
  354. this.$getIndent = function(line) {
  355. return line.match(/^\s*/)[0];
  356. };
  357. }).call(MatchingBraceOutdent.prototype);
  358. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  359. });
  360. 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) {
  361. "use strict";
  362. var oop = ace_require("../../lib/oop");
  363. var Behaviour = ace_require("../behaviour").Behaviour;
  364. var CstyleBehaviour = ace_require("./cstyle").CstyleBehaviour;
  365. var TokenIterator = ace_require("../../token_iterator").TokenIterator;
  366. var CssBehaviour = function () {
  367. this.inherit(CstyleBehaviour);
  368. this.add("colon", "insertion", function (state, action, editor, session, text) {
  369. if (text === ':' && editor.selection.isEmpty()) {
  370. var cursor = editor.getCursorPosition();
  371. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  372. var token = iterator.getCurrentToken();
  373. if (token && token.value.match(/\s+/)) {
  374. token = iterator.stepBackward();
  375. }
  376. if (token && token.type === 'support.type') {
  377. var line = session.doc.getLine(cursor.row);
  378. var rightChar = line.substring(cursor.column, cursor.column + 1);
  379. if (rightChar === ':') {
  380. return {
  381. text: '',
  382. selection: [1, 1]
  383. };
  384. }
  385. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  386. return {
  387. text: ':;',
  388. selection: [1, 1]
  389. };
  390. }
  391. }
  392. }
  393. });
  394. this.add("colon", "deletion", function (state, action, editor, session, range) {
  395. var selected = session.doc.getTextRange(range);
  396. if (!range.isMultiLine() && selected === ':') {
  397. var cursor = editor.getCursorPosition();
  398. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  399. var token = iterator.getCurrentToken();
  400. if (token && token.value.match(/\s+/)) {
  401. token = iterator.stepBackward();
  402. }
  403. if (token && token.type === 'support.type') {
  404. var line = session.doc.getLine(range.start.row);
  405. var rightChar = line.substring(range.end.column, range.end.column + 1);
  406. if (rightChar === ';') {
  407. range.end.column ++;
  408. return range;
  409. }
  410. }
  411. }
  412. });
  413. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  414. if (text === ';' && editor.selection.isEmpty()) {
  415. var cursor = editor.getCursorPosition();
  416. var line = session.doc.getLine(cursor.row);
  417. var rightChar = line.substring(cursor.column, cursor.column + 1);
  418. if (rightChar === ';') {
  419. return {
  420. text: '',
  421. selection: [1, 1]
  422. };
  423. }
  424. }
  425. });
  426. this.add("!important", "insertion", function (state, action, editor, session, text) {
  427. if (text === '!' && editor.selection.isEmpty()) {
  428. var cursor = editor.getCursorPosition();
  429. var line = session.doc.getLine(cursor.row);
  430. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  431. return {
  432. text: '!important',
  433. selection: [10, 10]
  434. };
  435. }
  436. }
  437. });
  438. };
  439. oop.inherits(CssBehaviour, CstyleBehaviour);
  440. exports.CssBehaviour = CssBehaviour;
  441. });
  442. define("ace/mode/folding/cstyle",["ace_require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(ace_require, exports, module) {
  443. "use strict";
  444. var oop = ace_require("../../lib/oop");
  445. var Range = ace_require("../../range").Range;
  446. var BaseFoldMode = ace_require("./fold_mode").FoldMode;
  447. var FoldMode = exports.FoldMode = function(commentRegex) {
  448. if (commentRegex) {
  449. this.foldingStartMarker = new RegExp(
  450. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  451. );
  452. this.foldingStopMarker = new RegExp(
  453. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  454. );
  455. }
  456. };
  457. oop.inherits(FoldMode, BaseFoldMode);
  458. (function() {
  459. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  460. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  461. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  462. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  463. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  464. this._getFoldWidgetBase = this.getFoldWidget;
  465. this.getFoldWidget = function(session, foldStyle, row) {
  466. var line = session.getLine(row);
  467. if (this.singleLineBlockCommentRe.test(line)) {
  468. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  469. return "";
  470. }
  471. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  472. if (!fw && this.startRegionRe.test(line))
  473. return "start"; // lineCommentRegionStart
  474. return fw;
  475. };
  476. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  477. var line = session.getLine(row);
  478. if (this.startRegionRe.test(line))
  479. return this.getCommentRegionBlock(session, line, row);
  480. var match = line.match(this.foldingStartMarker);
  481. if (match) {
  482. var i = match.index;
  483. if (match[1])
  484. return this.openingBracketBlock(session, match[1], row, i);
  485. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  486. if (range && !range.isMultiLine()) {
  487. if (forceMultiline) {
  488. range = this.getSectionRange(session, row);
  489. } else if (foldStyle != "all")
  490. range = null;
  491. }
  492. return range;
  493. }
  494. if (foldStyle === "markbegin")
  495. return;
  496. var match = line.match(this.foldingStopMarker);
  497. if (match) {
  498. var i = match.index + match[0].length;
  499. if (match[1])
  500. return this.closingBracketBlock(session, match[1], row, i);
  501. return session.getCommentFoldRange(row, i, -1);
  502. }
  503. };
  504. this.getSectionRange = function(session, row) {
  505. var line = session.getLine(row);
  506. var startIndent = line.search(/\S/);
  507. var startRow = row;
  508. var startColumn = line.length;
  509. row = row + 1;
  510. var endRow = row;
  511. var maxRow = session.getLength();
  512. while (++row < maxRow) {
  513. line = session.getLine(row);
  514. var indent = line.search(/\S/);
  515. if (indent === -1)
  516. continue;
  517. if (startIndent > indent)
  518. break;
  519. var subRange = this.getFoldWidgetRange(session, "all", row);
  520. if (subRange) {
  521. if (subRange.start.row <= startRow) {
  522. break;
  523. } else if (subRange.isMultiLine()) {
  524. row = subRange.end.row;
  525. } else if (startIndent == indent) {
  526. break;
  527. }
  528. }
  529. endRow = row;
  530. }
  531. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  532. };
  533. this.getCommentRegionBlock = function(session, line, row) {
  534. var startColumn = line.search(/\s*$/);
  535. var maxRow = session.getLength();
  536. var startRow = row;
  537. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  538. var depth = 1;
  539. while (++row < maxRow) {
  540. line = session.getLine(row);
  541. var m = re.exec(line);
  542. if (!m) continue;
  543. if (m[1]) depth--;
  544. else depth++;
  545. if (!depth) break;
  546. }
  547. var endRow = row;
  548. if (endRow > startRow) {
  549. return new Range(startRow, startColumn, endRow, line.length);
  550. }
  551. };
  552. }).call(FoldMode.prototype);
  553. });
  554. define("ace/mode/css_completions",["ace_require","exports","module"], function(ace_require, exports, module) {
  555. "use strict";
  556. var propertyMap = {
  557. "background": {"#$0": 1},
  558. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  559. "background-image": {"url('/$0')": 1},
  560. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  561. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  562. "background-attachment": {"scroll": 1, "fixed": 1},
  563. "background-size": {"cover": 1, "contain": 1},
  564. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  565. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  566. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  567. "border-color": {"#$0": 1},
  568. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  569. "border-collapse": {"collapse": 1, "separate": 1},
  570. "bottom": {"px": 1, "em": 1, "%": 1},
  571. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  572. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  573. "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},
  574. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  575. "empty-cells": {"show": 1, "hide": 1},
  576. "float": {"left": 1, "right": 1, "none": 1},
  577. "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},
  578. "font-size": {"px": 1, "em": 1, "%": 1},
  579. "font-weight": {"bold": 1, "normal": 1},
  580. "font-style": {"italic": 1, "normal": 1},
  581. "font-variant": {"normal": 1, "small-caps": 1},
  582. "height": {"px": 1, "em": 1, "%": 1},
  583. "left": {"px": 1, "em": 1, "%": 1},
  584. "letter-spacing": {"normal": 1},
  585. "line-height": {"normal": 1},
  586. "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},
  587. "margin": {"px": 1, "em": 1, "%": 1},
  588. "margin-right": {"px": 1, "em": 1, "%": 1},
  589. "margin-left": {"px": 1, "em": 1, "%": 1},
  590. "margin-top": {"px": 1, "em": 1, "%": 1},
  591. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  592. "max-height": {"px": 1, "em": 1, "%": 1},
  593. "max-width": {"px": 1, "em": 1, "%": 1},
  594. "min-height": {"px": 1, "em": 1, "%": 1},
  595. "min-width": {"px": 1, "em": 1, "%": 1},
  596. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  597. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  598. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  599. "padding": {"px": 1, "em": 1, "%": 1},
  600. "padding-top": {"px": 1, "em": 1, "%": 1},
  601. "padding-right": {"px": 1, "em": 1, "%": 1},
  602. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  603. "padding-left": {"px": 1, "em": 1, "%": 1},
  604. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  605. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  606. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  607. "right": {"px": 1, "em": 1, "%": 1},
  608. "table-layout": {"fixed": 1, "auto": 1},
  609. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  610. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  611. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  612. "top": {"px": 1, "em": 1, "%": 1},
  613. "vertical-align": {"top": 1, "bottom": 1},
  614. "visibility": {"hidden": 1, "visible": 1},
  615. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  616. "width": {"px": 1, "em": 1, "%": 1},
  617. "word-spacing": {"normal": 1},
  618. "filter": {"alpha(opacity=$0100)": 1},
  619. "text-shadow": {"$02px 2px 2px #777": 1},
  620. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  621. "-moz-border-radius": 1,
  622. "-moz-border-radius-topright": 1,
  623. "-moz-border-radius-bottomright": 1,
  624. "-moz-border-radius-topleft": 1,
  625. "-moz-border-radius-bottomleft": 1,
  626. "-webkit-border-radius": 1,
  627. "-webkit-border-top-right-radius": 1,
  628. "-webkit-border-top-left-radius": 1,
  629. "-webkit-border-bottom-right-radius": 1,
  630. "-webkit-border-bottom-left-radius": 1,
  631. "-moz-box-shadow": 1,
  632. "-webkit-box-shadow": 1,
  633. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  634. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  635. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  636. };
  637. var CssCompletions = function() {
  638. };
  639. (function() {
  640. this.completionsDefined = false;
  641. this.defineCompletions = function() {
  642. if (document) {
  643. var style = document.createElement('c').style;
  644. for (var i in style) {
  645. if (typeof style[i] !== 'string')
  646. continue;
  647. var name = i.replace(/[A-Z]/g, function(x) {
  648. return '-' + x.toLowerCase();
  649. });
  650. if (!propertyMap.hasOwnProperty(name))
  651. propertyMap[name] = 1;
  652. }
  653. }
  654. this.completionsDefined = true;
  655. };
  656. this.getCompletions = function(state, session, pos, prefix) {
  657. if (!this.completionsDefined) {
  658. this.defineCompletions();
  659. }
  660. if (state==='ruleset' || session.$mode.$id == "ace/mode/scss") {
  661. var line = session.getLine(pos.row).substr(0, pos.column);
  662. if (/:[^;]+$/.test(line)) {
  663. /([\w\-]+):[^:]*$/.test(line);
  664. return this.getPropertyValueCompletions(state, session, pos, prefix);
  665. } else {
  666. return this.getPropertyCompletions(state, session, pos, prefix);
  667. }
  668. }
  669. return [];
  670. };
  671. this.getPropertyCompletions = function(state, session, pos, prefix) {
  672. var properties = Object.keys(propertyMap);
  673. return properties.map(function(property){
  674. return {
  675. caption: property,
  676. snippet: property + ': $0;',
  677. meta: "property",
  678. score: 1000000
  679. };
  680. });
  681. };
  682. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  683. var line = session.getLine(pos.row).substr(0, pos.column);
  684. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  685. if (!property)
  686. return [];
  687. var values = [];
  688. if (property in propertyMap && typeof propertyMap[property] === "object") {
  689. values = Object.keys(propertyMap[property]);
  690. }
  691. return values.map(function(value){
  692. return {
  693. caption: value,
  694. snippet: value,
  695. meta: "property value",
  696. score: 1000000
  697. };
  698. });
  699. };
  700. }).call(CssCompletions.prototype);
  701. exports.CssCompletions = CssCompletions;
  702. });
  703. define("ace/mode/scss",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scss_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/css","ace/mode/folding/cstyle","ace/mode/css_completions"], function(ace_require, exports, module) {
  704. "use strict";
  705. var oop = ace_require("../lib/oop");
  706. var TextMode = ace_require("./text").Mode;
  707. var ScssHighlightRules = ace_require("./scss_highlight_rules").ScssHighlightRules;
  708. var MatchingBraceOutdent = ace_require("./matching_brace_outdent").MatchingBraceOutdent;
  709. var CssBehaviour = ace_require("./behaviour/css").CssBehaviour;
  710. var CStyleFoldMode = ace_require("./folding/cstyle").FoldMode;
  711. var CssCompletions = ace_require("./css_completions").CssCompletions;
  712. var Mode = function() {
  713. this.HighlightRules = ScssHighlightRules;
  714. this.$outdent = new MatchingBraceOutdent();
  715. this.$behaviour = new CssBehaviour();
  716. this.$completer = new CssCompletions();
  717. this.foldingRules = new CStyleFoldMode();
  718. };
  719. oop.inherits(Mode, TextMode);
  720. (function() {
  721. this.lineCommentStart = "//";
  722. this.blockComment = {start: "/*", end: "*/"};
  723. this.getNextLineIndent = function(state, line, tab) {
  724. var indent = this.$getIndent(line);
  725. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  726. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  727. return indent;
  728. }
  729. var match = line.match(/^.*\{\s*$/);
  730. if (match) {
  731. indent += tab;
  732. }
  733. return indent;
  734. };
  735. this.checkOutdent = function(state, line, input) {
  736. return this.$outdent.checkOutdent(line, input);
  737. };
  738. this.autoOutdent = function(state, doc, row) {
  739. this.$outdent.autoOutdent(doc, row);
  740. };
  741. this.getCompletions = function(state, session, pos, prefix) {
  742. return this.$completer.getCompletions(state, session, pos, prefix);
  743. };
  744. this.$id = "ace/mode/scss";
  745. }).call(Mode.prototype);
  746. exports.Mode = Mode;
  747. }); (function() {
  748. window.ace_require(["ace/mode/scss"], function(m) {
  749. if (typeof module == "object" && typeof exports == "object" && module) {
  750. module.exports = m;
  751. }
  752. });
  753. })();