e9363e5994cbee7225491f99dcfeacf5.js 37 KB

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