mode-less.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. ace.define("ace/mode/css_highlight_rules",[], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var lang = require("../lib/lang");
  5. var TextHighlightRules = 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. ace.define("ace/mode/less_highlight_rules",[], function(require, exports, module) {
  181. "use strict";
  182. var oop = require("../lib/oop");
  183. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  184. var CssHighlightRules = require('./css_highlight_rules');
  185. var LessHighlightRules = function() {
  186. var keywordList = "@import|@media|@font-face|@keyframes|@-webkit-keyframes|@supports|" +
  187. "@charset|@plugin|@namespace|@document|@page|@viewport|@-ms-viewport|" +
  188. "or|and|when|not";
  189. var keywords = keywordList.split('|');
  190. var properties = CssHighlightRules.supportType.split('|');
  191. var keywordMapper = this.createKeywordMapper({
  192. "support.constant": CssHighlightRules.supportConstant,
  193. "keyword": keywordList,
  194. "support.constant.color": CssHighlightRules.supportConstantColor,
  195. "support.constant.fonts": CssHighlightRules.supportConstantFonts
  196. }, "identifier", true);
  197. var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  198. this.$rules = {
  199. "start" : [
  200. {
  201. token : "comment",
  202. regex : "\\/\\/.*$"
  203. },
  204. {
  205. token : "comment", // multi line comment
  206. regex : "\\/\\*",
  207. next : "comment"
  208. }, {
  209. token : "string", // single line
  210. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  211. }, {
  212. token : "string", // single line
  213. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  214. }, {
  215. token : ["constant.numeric", "keyword"],
  216. regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
  217. }, {
  218. token : "constant.numeric", // hex6 color
  219. regex : "#[a-f0-9]{6}"
  220. }, {
  221. token : "constant.numeric", // hex3 color
  222. regex : "#[a-f0-9]{3}"
  223. }, {
  224. token : "constant.numeric",
  225. regex : numRe
  226. }, {
  227. token : ["support.function", "paren.lparen", "string", "paren.rparen"],
  228. regex : "(url)(\\()(.*)(\\))"
  229. }, {
  230. token : ["support.function", "paren.lparen"],
  231. regex : "(:extend|[a-z0-9_\\-]+)(\\()"
  232. }, {
  233. token : function(value) {
  234. if (keywords.indexOf(value.toLowerCase()) > -1)
  235. return "keyword";
  236. else
  237. return "variable";
  238. },
  239. regex : "[@\\$][a-z0-9_\\-@\\$]*\\b"
  240. }, {
  241. token : "variable",
  242. regex : "[@\\$]\\{[a-z0-9_\\-@\\$]*\\}"
  243. }, {
  244. token : function(first, second) {
  245. if(properties.indexOf(first.toLowerCase()) > -1) {
  246. return ["support.type.property", "text"];
  247. }
  248. else {
  249. return ["support.type.unknownProperty", "text"];
  250. }
  251. },
  252. regex : "([a-z0-9-_]+)(\\s*:)"
  253. }, {
  254. token : "keyword",
  255. regex : "&" // special case - always treat as keyword
  256. }, {
  257. token : keywordMapper,
  258. regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
  259. }, {
  260. token: "variable.language",
  261. regex: "#[a-z0-9-_]+"
  262. }, {
  263. token: "variable.language",
  264. regex: "\\.[a-z0-9-_]+"
  265. }, {
  266. token: "variable.language",
  267. regex: ":[a-z_][a-z0-9-_]*"
  268. }, {
  269. token: "constant",
  270. regex: "[a-z0-9-_]+"
  271. }, {
  272. token : "keyword.operator",
  273. regex : "<|>|<=|>=|=|!=|-|%|\\+|\\*"
  274. }, {
  275. token : "paren.lparen",
  276. regex : "[[({]"
  277. }, {
  278. token : "paren.rparen",
  279. regex : "[\\])}]"
  280. }, {
  281. token : "text",
  282. regex : "\\s+"
  283. }, {
  284. caseInsensitive: true
  285. }
  286. ],
  287. "comment" : [
  288. {
  289. token : "comment", // closing comment
  290. regex : "\\*\\/",
  291. next : "start"
  292. }, {
  293. defaultToken : "comment"
  294. }
  295. ]
  296. };
  297. this.normalizeRules();
  298. };
  299. oop.inherits(LessHighlightRules, TextHighlightRules);
  300. exports.LessHighlightRules = LessHighlightRules;
  301. });
  302. ace.define("ace/mode/matching_brace_outdent",[], function(require, exports, module) {
  303. "use strict";
  304. var Range = require("../range").Range;
  305. var MatchingBraceOutdent = function() {};
  306. (function() {
  307. this.checkOutdent = function(line, input) {
  308. if (! /^\s+$/.test(line))
  309. return false;
  310. return /^\s*\}/.test(input);
  311. };
  312. this.autoOutdent = function(doc, row) {
  313. var line = doc.getLine(row);
  314. var match = line.match(/^(\s*\})/);
  315. if (!match) return 0;
  316. var column = match[1].length;
  317. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  318. if (!openBracePos || openBracePos.row == row) return 0;
  319. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  320. doc.replace(new Range(row, 0, row, column-1), indent);
  321. };
  322. this.$getIndent = function(line) {
  323. return line.match(/^\s*/)[0];
  324. };
  325. }).call(MatchingBraceOutdent.prototype);
  326. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  327. });
  328. ace.define("ace/mode/behaviour/css",[], function(require, exports, module) {
  329. "use strict";
  330. var oop = require("../../lib/oop");
  331. var Behaviour = require("../behaviour").Behaviour;
  332. var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
  333. var TokenIterator = require("../../token_iterator").TokenIterator;
  334. var CssBehaviour = function () {
  335. this.inherit(CstyleBehaviour);
  336. this.add("colon", "insertion", function (state, action, editor, session, text) {
  337. if (text === ':' && editor.selection.isEmpty()) {
  338. var cursor = editor.getCursorPosition();
  339. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  340. var token = iterator.getCurrentToken();
  341. if (token && token.value.match(/\s+/)) {
  342. token = iterator.stepBackward();
  343. }
  344. if (token && token.type === 'support.type') {
  345. var line = session.doc.getLine(cursor.row);
  346. var rightChar = line.substring(cursor.column, cursor.column + 1);
  347. if (rightChar === ':') {
  348. return {
  349. text: '',
  350. selection: [1, 1]
  351. };
  352. }
  353. if (/^(\s+[^;]|\s*$)/.test(line.substring(cursor.column))) {
  354. return {
  355. text: ':;',
  356. selection: [1, 1]
  357. };
  358. }
  359. }
  360. }
  361. });
  362. this.add("colon", "deletion", function (state, action, editor, session, range) {
  363. var selected = session.doc.getTextRange(range);
  364. if (!range.isMultiLine() && selected === ':') {
  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(range.start.row);
  373. var rightChar = line.substring(range.end.column, range.end.column + 1);
  374. if (rightChar === ';') {
  375. range.end.column ++;
  376. return range;
  377. }
  378. }
  379. }
  380. });
  381. this.add("semicolon", "insertion", function (state, action, editor, session, text) {
  382. if (text === ';' && editor.selection.isEmpty()) {
  383. var cursor = editor.getCursorPosition();
  384. var line = session.doc.getLine(cursor.row);
  385. var rightChar = line.substring(cursor.column, cursor.column + 1);
  386. if (rightChar === ';') {
  387. return {
  388. text: '',
  389. selection: [1, 1]
  390. };
  391. }
  392. }
  393. });
  394. this.add("!important", "insertion", function (state, action, editor, session, text) {
  395. if (text === '!' && editor.selection.isEmpty()) {
  396. var cursor = editor.getCursorPosition();
  397. var line = session.doc.getLine(cursor.row);
  398. if (/^\s*(;|}|$)/.test(line.substring(cursor.column))) {
  399. return {
  400. text: '!important',
  401. selection: [10, 10]
  402. };
  403. }
  404. }
  405. });
  406. };
  407. oop.inherits(CssBehaviour, CstyleBehaviour);
  408. exports.CssBehaviour = CssBehaviour;
  409. });
  410. ace.define("ace/mode/css_completions",[], function(require, exports, module) {
  411. "use strict";
  412. var propertyMap = {
  413. "background": {"#$0": 1},
  414. "background-color": {"#$0": 1, "transparent": 1, "fixed": 1},
  415. "background-image": {"url('/$0')": 1},
  416. "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1},
  417. "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2},
  418. "background-attachment": {"scroll": 1, "fixed": 1},
  419. "background-size": {"cover": 1, "contain": 1},
  420. "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1},
  421. "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1},
  422. "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1},
  423. "border-color": {"#$0": 1},
  424. "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2},
  425. "border-collapse": {"collapse": 1, "separate": 1},
  426. "bottom": {"px": 1, "em": 1, "%": 1},
  427. "clear": {"left": 1, "right": 1, "both": 1, "none": 1},
  428. "color": {"#$0": 1, "rgb(#$00,0,0)": 1},
  429. "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},
  430. "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1},
  431. "empty-cells": {"show": 1, "hide": 1},
  432. "float": {"left": 1, "right": 1, "none": 1},
  433. "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},
  434. "font-size": {"px": 1, "em": 1, "%": 1},
  435. "font-weight": {"bold": 1, "normal": 1},
  436. "font-style": {"italic": 1, "normal": 1},
  437. "font-variant": {"normal": 1, "small-caps": 1},
  438. "height": {"px": 1, "em": 1, "%": 1},
  439. "left": {"px": 1, "em": 1, "%": 1},
  440. "letter-spacing": {"normal": 1},
  441. "line-height": {"normal": 1},
  442. "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},
  443. "margin": {"px": 1, "em": 1, "%": 1},
  444. "margin-right": {"px": 1, "em": 1, "%": 1},
  445. "margin-left": {"px": 1, "em": 1, "%": 1},
  446. "margin-top": {"px": 1, "em": 1, "%": 1},
  447. "margin-bottom": {"px": 1, "em": 1, "%": 1},
  448. "max-height": {"px": 1, "em": 1, "%": 1},
  449. "max-width": {"px": 1, "em": 1, "%": 1},
  450. "min-height": {"px": 1, "em": 1, "%": 1},
  451. "min-width": {"px": 1, "em": 1, "%": 1},
  452. "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  453. "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  454. "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1},
  455. "padding": {"px": 1, "em": 1, "%": 1},
  456. "padding-top": {"px": 1, "em": 1, "%": 1},
  457. "padding-right": {"px": 1, "em": 1, "%": 1},
  458. "padding-bottom": {"px": 1, "em": 1, "%": 1},
  459. "padding-left": {"px": 1, "em": 1, "%": 1},
  460. "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  461. "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1},
  462. "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1},
  463. "right": {"px": 1, "em": 1, "%": 1},
  464. "table-layout": {"fixed": 1, "auto": 1},
  465. "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1},
  466. "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1},
  467. "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1},
  468. "top": {"px": 1, "em": 1, "%": 1},
  469. "vertical-align": {"top": 1, "bottom": 1},
  470. "visibility": {"hidden": 1, "visible": 1},
  471. "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1},
  472. "width": {"px": 1, "em": 1, "%": 1},
  473. "word-spacing": {"normal": 1},
  474. "filter": {"alpha(opacity=$0100)": 1},
  475. "text-shadow": {"$02px 2px 2px #777": 1},
  476. "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1},
  477. "-moz-border-radius": 1,
  478. "-moz-border-radius-topright": 1,
  479. "-moz-border-radius-bottomright": 1,
  480. "-moz-border-radius-topleft": 1,
  481. "-moz-border-radius-bottomleft": 1,
  482. "-webkit-border-radius": 1,
  483. "-webkit-border-top-right-radius": 1,
  484. "-webkit-border-top-left-radius": 1,
  485. "-webkit-border-bottom-right-radius": 1,
  486. "-webkit-border-bottom-left-radius": 1,
  487. "-moz-box-shadow": 1,
  488. "-webkit-box-shadow": 1,
  489. "transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  490. "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1},
  491. "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 }
  492. };
  493. var CssCompletions = function() {
  494. };
  495. (function() {
  496. this.completionsDefined = false;
  497. this.defineCompletions = function() {
  498. if (document) {
  499. var style = document.createElement('c').style;
  500. for (var i in style) {
  501. if (typeof style[i] !== 'string')
  502. continue;
  503. var name = i.replace(/[A-Z]/g, function(x) {
  504. return '-' + x.toLowerCase();
  505. });
  506. if (!propertyMap.hasOwnProperty(name))
  507. propertyMap[name] = 1;
  508. }
  509. }
  510. this.completionsDefined = true;
  511. };
  512. this.getCompletions = function(state, session, pos, prefix) {
  513. if (!this.completionsDefined) {
  514. this.defineCompletions();
  515. }
  516. var token = session.getTokenAt(pos.row, pos.column);
  517. if (!token)
  518. return [];
  519. if (state==='ruleset'){
  520. var line = session.getLine(pos.row).substr(0, pos.column);
  521. if (/:[^;]+$/.test(line)) {
  522. /([\w\-]+):[^:]*$/.test(line);
  523. return this.getPropertyValueCompletions(state, session, pos, prefix);
  524. } else {
  525. return this.getPropertyCompletions(state, session, pos, prefix);
  526. }
  527. }
  528. return [];
  529. };
  530. this.getPropertyCompletions = function(state, session, pos, prefix) {
  531. var properties = Object.keys(propertyMap);
  532. return properties.map(function(property){
  533. return {
  534. caption: property,
  535. snippet: property + ': $0;',
  536. meta: "property",
  537. score: Number.MAX_VALUE
  538. };
  539. });
  540. };
  541. this.getPropertyValueCompletions = function(state, session, pos, prefix) {
  542. var line = session.getLine(pos.row).substr(0, pos.column);
  543. var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1];
  544. if (!property)
  545. return [];
  546. var values = [];
  547. if (property in propertyMap && typeof propertyMap[property] === "object") {
  548. values = Object.keys(propertyMap[property]);
  549. }
  550. return values.map(function(value){
  551. return {
  552. caption: value,
  553. snippet: value,
  554. meta: "property value",
  555. score: Number.MAX_VALUE
  556. };
  557. });
  558. };
  559. }).call(CssCompletions.prototype);
  560. exports.CssCompletions = CssCompletions;
  561. });
  562. ace.define("ace/mode/folding/cstyle",[], function(require, exports, module) {
  563. "use strict";
  564. var oop = require("../../lib/oop");
  565. var Range = require("../../range").Range;
  566. var BaseFoldMode = require("./fold_mode").FoldMode;
  567. var FoldMode = exports.FoldMode = function(commentRegex) {
  568. if (commentRegex) {
  569. this.foldingStartMarker = new RegExp(
  570. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  571. );
  572. this.foldingStopMarker = new RegExp(
  573. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  574. );
  575. }
  576. };
  577. oop.inherits(FoldMode, BaseFoldMode);
  578. (function() {
  579. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  580. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  581. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  582. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  583. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  584. this._getFoldWidgetBase = this.getFoldWidget;
  585. this.getFoldWidget = function(session, foldStyle, row) {
  586. var line = session.getLine(row);
  587. if (this.singleLineBlockCommentRe.test(line)) {
  588. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  589. return "";
  590. }
  591. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  592. if (!fw && this.startRegionRe.test(line))
  593. return "start"; // lineCommentRegionStart
  594. return fw;
  595. };
  596. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  597. var line = session.getLine(row);
  598. if (this.startRegionRe.test(line))
  599. return this.getCommentRegionBlock(session, line, row);
  600. var match = line.match(this.foldingStartMarker);
  601. if (match) {
  602. var i = match.index;
  603. if (match[1])
  604. return this.openingBracketBlock(session, match[1], row, i);
  605. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  606. if (range && !range.isMultiLine()) {
  607. if (forceMultiline) {
  608. range = this.getSectionRange(session, row);
  609. } else if (foldStyle != "all")
  610. range = null;
  611. }
  612. return range;
  613. }
  614. if (foldStyle === "markbegin")
  615. return;
  616. var match = line.match(this.foldingStopMarker);
  617. if (match) {
  618. var i = match.index + match[0].length;
  619. if (match[1])
  620. return this.closingBracketBlock(session, match[1], row, i);
  621. return session.getCommentFoldRange(row, i, -1);
  622. }
  623. };
  624. this.getSectionRange = function(session, row) {
  625. var line = session.getLine(row);
  626. var startIndent = line.search(/\S/);
  627. var startRow = row;
  628. var startColumn = line.length;
  629. row = row + 1;
  630. var endRow = row;
  631. var maxRow = session.getLength();
  632. while (++row < maxRow) {
  633. line = session.getLine(row);
  634. var indent = line.search(/\S/);
  635. if (indent === -1)
  636. continue;
  637. if (startIndent > indent)
  638. break;
  639. var subRange = this.getFoldWidgetRange(session, "all", row);
  640. if (subRange) {
  641. if (subRange.start.row <= startRow) {
  642. break;
  643. } else if (subRange.isMultiLine()) {
  644. row = subRange.end.row;
  645. } else if (startIndent == indent) {
  646. break;
  647. }
  648. }
  649. endRow = row;
  650. }
  651. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  652. };
  653. this.getCommentRegionBlock = function(session, line, row) {
  654. var startColumn = line.search(/\s*$/);
  655. var maxRow = session.getLength();
  656. var startRow = row;
  657. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  658. var depth = 1;
  659. while (++row < maxRow) {
  660. line = session.getLine(row);
  661. var m = re.exec(line);
  662. if (!m) continue;
  663. if (m[1]) depth--;
  664. else depth++;
  665. if (!depth) break;
  666. }
  667. var endRow = row;
  668. if (endRow > startRow) {
  669. return new Range(startRow, startColumn, endRow, line.length);
  670. }
  671. };
  672. }).call(FoldMode.prototype);
  673. });
  674. ace.define("ace/mode/less",[], function(require, exports, module) {
  675. "use strict";
  676. var oop = require("../lib/oop");
  677. var TextMode = require("./text").Mode;
  678. var LessHighlightRules = require("./less_highlight_rules").LessHighlightRules;
  679. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  680. var CssBehaviour = require("./behaviour/css").CssBehaviour;
  681. var CssCompletions = require("./css_completions").CssCompletions;
  682. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  683. var Mode = function() {
  684. this.HighlightRules = LessHighlightRules;
  685. this.$outdent = new MatchingBraceOutdent();
  686. this.$behaviour = new CssBehaviour();
  687. this.$completer = new CssCompletions();
  688. this.foldingRules = new CStyleFoldMode();
  689. };
  690. oop.inherits(Mode, TextMode);
  691. (function() {
  692. this.lineCommentStart = "//";
  693. this.blockComment = {start: "/*", end: "*/"};
  694. this.getNextLineIndent = function(state, line, tab) {
  695. var indent = this.$getIndent(line);
  696. var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
  697. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  698. return indent;
  699. }
  700. var match = line.match(/^.*\{\s*$/);
  701. if (match) {
  702. indent += tab;
  703. }
  704. return indent;
  705. };
  706. this.checkOutdent = function(state, line, input) {
  707. return this.$outdent.checkOutdent(line, input);
  708. };
  709. this.autoOutdent = function(state, doc, row) {
  710. this.$outdent.autoOutdent(doc, row);
  711. };
  712. this.getCompletions = function(state, session, pos, prefix) {
  713. return this.$completer.getCompletions("ruleset", session, pos, prefix);
  714. };
  715. this.$id = "ace/mode/less";
  716. }).call(Mode.prototype);
  717. exports.Mode = Mode;
  718. });
  719. (function() {
  720. ace.require(["ace/mode/less"], function(m) {
  721. if (typeof module == "object" && typeof exports == "object" && module) {
  722. module.exports = m;
  723. }
  724. });
  725. })();