ext-options.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. define("ace/ext/menu_tools/overlay_page",["ace_require","exports","module","ace/lib/dom"], function(ace_require, exports, module) {
  2. 'use strict';
  3. var dom = ace_require("../../lib/dom");
  4. var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
  5. background-color: #F7F7F7;\
  6. color: black;\
  7. box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
  8. padding: 1em 0.5em 2em 1em;\
  9. overflow: auto;\
  10. position: absolute;\
  11. margin: 0;\
  12. bottom: 0;\
  13. right: 0;\
  14. top: 0;\
  15. z-index: 9991;\
  16. cursor: default;\
  17. }\
  18. .ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
  19. box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
  20. background-color: rgba(255, 255, 255, 0.6);\
  21. color: black;\
  22. }\
  23. .ace_optionsMenuEntry:hover {\
  24. background-color: rgba(100, 100, 100, 0.1);\
  25. transition: all 0.3s\
  26. }\
  27. .ace_closeButton {\
  28. background: rgba(245, 146, 146, 0.5);\
  29. border: 1px solid #F48A8A;\
  30. border-radius: 50%;\
  31. padding: 7px;\
  32. position: absolute;\
  33. right: -8px;\
  34. top: -8px;\
  35. z-index: 100000;\
  36. }\
  37. .ace_closeButton{\
  38. background: rgba(245, 146, 146, 0.9);\
  39. }\
  40. .ace_optionsMenuKey {\
  41. color: darkslateblue;\
  42. font-weight: bold;\
  43. }\
  44. .ace_optionsMenuCommand {\
  45. color: darkcyan;\
  46. font-weight: normal;\
  47. }\
  48. .ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
  49. vertical-align: middle;\
  50. }\
  51. .ace_optionsMenuEntry button[ace_selected_button=true] {\
  52. background: #e7e7e7;\
  53. box-shadow: 1px 0px 2px 0px #adadad inset;\
  54. border-color: #adadad;\
  55. }\
  56. .ace_optionsMenuEntry button {\
  57. background: white;\
  58. border: 1px solid lightgray;\
  59. margin: 0px;\
  60. }\
  61. .ace_optionsMenuEntry button:hover{\
  62. background: #f0f0f0;\
  63. }";
  64. dom.importCssString(cssText);
  65. module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
  66. var closer = document.createElement('div');
  67. var ignoreFocusOut = false;
  68. function documentEscListener(e) {
  69. if (e.keyCode === 27) {
  70. close();
  71. }
  72. }
  73. function close() {
  74. if (!closer) return;
  75. document.removeEventListener('keydown', documentEscListener);
  76. closer.parentNode.removeChild(closer);
  77. if (editor) {
  78. editor.focus();
  79. }
  80. closer = null;
  81. callback && callback();
  82. }
  83. function setIgnoreFocusOut(ignore) {
  84. ignoreFocusOut = ignore;
  85. if (ignore) {
  86. closer.style.pointerEvents = "none";
  87. contentElement.style.pointerEvents = "auto";
  88. }
  89. }
  90. closer.style.cssText = 'margin: 0; padding: 0; ' +
  91. 'position: fixed; top:0; bottom:0; left:0; right:0;' +
  92. 'z-index: 9990; ' +
  93. (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
  94. closer.addEventListener('click', function(e) {
  95. if (!ignoreFocusOut) {
  96. close();
  97. }
  98. });
  99. document.addEventListener('keydown', documentEscListener);
  100. contentElement.addEventListener('click', function (e) {
  101. e.stopPropagation();
  102. });
  103. closer.appendChild(contentElement);
  104. document.body.appendChild(closer);
  105. if (editor) {
  106. editor.blur();
  107. }
  108. return {
  109. close: close,
  110. setIgnoreFocusOut: setIgnoreFocusOut
  111. };
  112. };
  113. });
  114. define("ace/ext/modelist",["ace_require","exports","module"], function(ace_require, exports, module) {
  115. "use strict";
  116. var modes = [];
  117. function getModeForPath(path) {
  118. var mode = modesByName.text;
  119. var fileName = path.split(/[\/\\]/).pop();
  120. for (var i = 0; i < modes.length; i++) {
  121. if (modes[i].supportsFile(fileName)) {
  122. mode = modes[i];
  123. break;
  124. }
  125. }
  126. return mode;
  127. }
  128. var Mode = function(name, caption, extensions) {
  129. this.name = name;
  130. this.caption = caption;
  131. this.mode = "ace/mode/" + name;
  132. this.extensions = extensions;
  133. var re;
  134. if (/\^/.test(extensions)) {
  135. re = extensions.replace(/\|(\^)?/g, function(a, b){
  136. return "$|" + (b ? "^" : "^.*\\.");
  137. }) + "$";
  138. } else {
  139. re = "^.*\\.(" + extensions + ")$";
  140. }
  141. this.extRe = new RegExp(re, "gi");
  142. };
  143. Mode.prototype.supportsFile = function(filename) {
  144. return filename.match(this.extRe);
  145. };
  146. var supportedModes = {
  147. ABAP: ["abap"],
  148. ABC: ["abc"],
  149. ActionScript:["as"],
  150. ADA: ["ada|adb"],
  151. Alda: ["alda"],
  152. Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
  153. Apex: ["apex|cls|trigger|tgr"],
  154. AQL: ["aql"],
  155. AsciiDoc: ["asciidoc|adoc"],
  156. ASL: ["dsl|asl"],
  157. Assembly_x86:["asm|a"],
  158. AutoHotKey: ["ahk"],
  159. BatchFile: ["bat|cmd"],
  160. C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
  161. C9Search: ["c9search_results"],
  162. Cirru: ["cirru|cr"],
  163. Clojure: ["clj|cljs"],
  164. Cobol: ["CBL|COB"],
  165. coffee: ["coffee|cf|cson|^Cakefile"],
  166. ColdFusion: ["cfm"],
  167. Crystal: ["cr"],
  168. CSharp: ["cs"],
  169. Csound_Document: ["csd"],
  170. Csound_Orchestra: ["orc"],
  171. Csound_Score: ["sco"],
  172. CSS: ["css"],
  173. Curly: ["curly"],
  174. D: ["d|di"],
  175. Dart: ["dart"],
  176. Diff: ["diff|patch"],
  177. Dockerfile: ["^Dockerfile"],
  178. Dot: ["dot"],
  179. Drools: ["drl"],
  180. Edifact: ["edi"],
  181. Eiffel: ["e|ge"],
  182. EJS: ["ejs"],
  183. Elixir: ["ex|exs"],
  184. Elm: ["elm"],
  185. Erlang: ["erl|hrl"],
  186. Forth: ["frt|fs|ldr|fth|4th"],
  187. Fortran: ["f|f90"],
  188. FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
  189. FSL: ["fsl"],
  190. FTL: ["ftl"],
  191. Gcode: ["gcode"],
  192. Gherkin: ["feature"],
  193. Gitignore: ["^.gitignore"],
  194. Glsl: ["glsl|frag|vert"],
  195. Gobstones: ["gbs"],
  196. golang: ["go"],
  197. GraphQLSchema: ["gql"],
  198. Groovy: ["groovy"],
  199. HAML: ["haml"],
  200. Handlebars: ["hbs|handlebars|tpl|mustache"],
  201. Haskell: ["hs"],
  202. Haskell_Cabal: ["cabal"],
  203. haXe: ["hx"],
  204. Hjson: ["hjson"],
  205. HTML: ["html|htm|xhtml|vue|we|wpy"],
  206. HTML_Elixir: ["eex|html.eex"],
  207. HTML_Ruby: ["erb|rhtml|html.erb"],
  208. INI: ["ini|conf|cfg|prefs"],
  209. Io: ["io"],
  210. Jack: ["jack"],
  211. Jade: ["jade|pug"],
  212. Java: ["java"],
  213. JavaScript: ["js|jsm|jsx"],
  214. JSON: ["json"],
  215. JSON5: ["json5"],
  216. JSONiq: ["jq"],
  217. JSP: ["jsp"],
  218. JSSM: ["jssm|jssm_state"],
  219. JSX: ["jsx"],
  220. Julia: ["jl"],
  221. Kotlin: ["kt|kts"],
  222. LaTeX: ["tex|latex|ltx|bib"],
  223. LESS: ["less"],
  224. Liquid: ["liquid"],
  225. Lisp: ["lisp"],
  226. LiveScript: ["ls"],
  227. LogiQL: ["logic|lql"],
  228. LSL: ["lsl"],
  229. Lua: ["lua"],
  230. LuaPage: ["lp"],
  231. Lucene: ["lucene"],
  232. Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
  233. Markdown: ["md|markdown"],
  234. Mask: ["mask"],
  235. MATLAB: ["matlab"],
  236. Maze: ["mz"],
  237. MediaWiki: ["wiki|mediawiki"],
  238. MEL: ["mel"],
  239. MIXAL: ["mixal"],
  240. MUSHCode: ["mc|mush"],
  241. MySQL: ["mysql"],
  242. Nginx: ["nginx|conf"],
  243. Nim: ["nim"],
  244. Nix: ["nix"],
  245. NSIS: ["nsi|nsh"],
  246. Nunjucks: ["nunjucks|nunjs|nj|njk"],
  247. ObjectiveC: ["m|mm"],
  248. OCaml: ["ml|mli"],
  249. Pascal: ["pas|p"],
  250. Perl: ["pl|pm"],
  251. Perl6: ["p6|pl6|pm6"],
  252. pgSQL: ["pgsql"],
  253. PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
  254. PHP_Laravel_blade: ["blade.php"],
  255. Pig: ["pig"],
  256. Powershell: ["ps1"],
  257. Praat: ["praat|praatscript|psc|proc"],
  258. Prisma: ["prisma"],
  259. Prolog: ["plg|prolog"],
  260. Properties: ["properties"],
  261. Protobuf: ["proto"],
  262. Puppet: ["epp|pp"],
  263. Python: ["py"],
  264. QML: ["qml"],
  265. R: ["r"],
  266. Razor: ["cshtml|asp"],
  267. RDoc: ["Rd"],
  268. Red: ["red|reds"],
  269. RHTML: ["Rhtml"],
  270. RST: ["rst"],
  271. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  272. Rust: ["rs"],
  273. SASS: ["sass"],
  274. SCAD: ["scad"],
  275. Scala: ["scala|sbt"],
  276. Scheme: ["scm|sm|rkt|oak|scheme"],
  277. SCSS: ["scss"],
  278. SH: ["sh|bash|^.bashrc"],
  279. SJS: ["sjs"],
  280. Slim: ["slim|skim"],
  281. Smarty: ["smarty|tpl"],
  282. snippets: ["snippets"],
  283. Soy_Template:["soy"],
  284. Space: ["space"],
  285. SQL: ["sql"],
  286. SQLServer: ["sqlserver"],
  287. Stylus: ["styl|stylus"],
  288. SVG: ["svg"],
  289. Swift: ["swift"],
  290. Tcl: ["tcl"],
  291. Terraform: ["tf", "tfvars", "terragrunt"],
  292. Tex: ["tex"],
  293. Text: ["txt"],
  294. Textile: ["textile"],
  295. Toml: ["toml"],
  296. TSX: ["tsx"],
  297. Twig: ["latte|twig|swig"],
  298. Typescript: ["ts|typescript|str"],
  299. Vala: ["vala"],
  300. VBScript: ["vbs|vb"],
  301. Velocity: ["vm"],
  302. Verilog: ["v|vh|sv|svh"],
  303. VHDL: ["vhd|vhdl"],
  304. Visualforce: ["vfp|component|page"],
  305. Wollok: ["wlk|wpgm|wtest"],
  306. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
  307. XQuery: ["xq"],
  308. YAML: ["yaml|yml"],
  309. Zeek: ["zeek|bro"],
  310. Django: ["html"]
  311. };
  312. var nameOverrides = {
  313. ObjectiveC: "Objective-C",
  314. CSharp: "C#",
  315. golang: "Go",
  316. C_Cpp: "C and C++",
  317. Csound_Document: "Csound Document",
  318. Csound_Orchestra: "Csound",
  319. Csound_Score: "Csound Score",
  320. coffee: "CoffeeScript",
  321. HTML_Ruby: "HTML (Ruby)",
  322. HTML_Elixir: "HTML (Elixir)",
  323. FTL: "FreeMarker",
  324. PHP_Laravel_blade: "PHP (Blade Template)",
  325. Perl6: "Perl 6",
  326. AutoHotKey: "AutoHotkey / AutoIt"
  327. };
  328. var modesByName = {};
  329. for (var name in supportedModes) {
  330. var data = supportedModes[name];
  331. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  332. var filename = name.toLowerCase();
  333. var mode = new Mode(filename, displayName, data[0]);
  334. modesByName[filename] = mode;
  335. modes.push(mode);
  336. }
  337. module.exports = {
  338. getModeForPath: getModeForPath,
  339. modes: modes,
  340. modesByName: modesByName
  341. };
  342. });
  343. define("ace/ext/themelist",["ace_require","exports","module"], function(ace_require, exports, module) {
  344. "use strict";
  345. var themeData = [
  346. // ["Chrome" ],
  347. // ["Clouds" ],
  348. // ["Crimson Editor" ],
  349. // ["Dawn" ],
  350. // ["Dreamweaver" ],
  351. // ["Eclipse" ],
  352. // ["GitHub" ],
  353. // ["IPlastic" ],
  354. // ["Solarized Light"],
  355. // ["TextMate" ],
  356. // ["Tomorrow" ],
  357. // ["Xcode" ],
  358. // ["Kuroir"],
  359. // ["KatzenMilch"],
  360. ["vs" ,"vs" , "light"],
  361. ["vs-dark" ,"vs-dark" , "dark"],
  362. ["hc-black" ,"hc-black" , "dark"],
  363. // ["Clouds Midnight" ,"clouds_midnight" , "dark"],
  364. // ["Dracula" ,"" , "dark"],
  365. // ["Cobalt" ,"cobalt" , "dark"],
  366. // ["Gruvbox" ,"gruvbox" , "dark"],
  367. // ["Green on Black" ,"gob" , "dark"],
  368. // ["idle Fingers" ,"idle_fingers" , "dark"],
  369. // ["krTheme" ,"kr_theme" , "dark"],
  370. // ["Merbivore" ,"merbivore" , "dark"],
  371. // ["Merbivore Soft" ,"merbivore_soft" , "dark"],
  372. // ["Mono Industrial" ,"mono_industrial" , "dark"],
  373. // ["Monokai" ,"monokai" , "dark"],
  374. // ["Nord Dark" ,"nord_dark" , "dark"],
  375. // ["Pastel on dark" ,"pastel_on_dark" , "dark"],
  376. // ["Solarized Dark" ,"solarized_dark" , "dark"],
  377. // ["Terminal" ,"terminal" , "dark"],
  378. // ["Tomorrow Night" ,"tomorrow_night" , "dark"],
  379. // ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
  380. // ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
  381. // ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
  382. // ["Twilight" ,"twilight" , "dark"],
  383. // ["Vibrant Ink" ,"vibrant_ink" , "dark"]
  384. ];
  385. exports.themesByName = {};
  386. exports.themes = themeData.map(function(data) {
  387. var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
  388. var theme = {
  389. caption: data[0],
  390. theme: name,//"ace/theme/" + name,
  391. isDark: data[2] == "dark",
  392. name: name
  393. };
  394. exports.themesByName[name] = theme;
  395. return theme;
  396. });
  397. });
  398. define("ace/ext/options",["ace_require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(ace_require, exports, module) {
  399. "use strict";
  400. ace_require("./menu_tools/overlay_page");
  401. var dom = ace_require("../lib/dom");
  402. var oop = ace_require("../lib/oop");
  403. var config = ace_require("../config");
  404. var EventEmitter = ace_require("../lib/event_emitter").EventEmitter;
  405. var buildDom = dom.buildDom;
  406. var modelist = ace_require("./modelist");
  407. var themelist = ace_require("./themelist");
  408. var themes = { Bright: [], Dark: [] };
  409. themelist.themes.forEach(function(x) {
  410. themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
  411. });
  412. var modes = modelist.modes.map(function(x){
  413. return { caption: x.caption, value: x.mode };
  414. });
  415. var optionGroups = {
  416. Main: {
  417. Mode: {
  418. path: "mode",
  419. type: "select",
  420. items: modes
  421. },
  422. Theme: {
  423. path: "theme",
  424. type: "select",
  425. items: themes
  426. },
  427. "Keybinding": {
  428. type: "buttonBar",
  429. path: "keyboardHandler",
  430. items: [
  431. // { caption : "Ace", value : null },
  432. // { caption : "Vim", value : "ace/keyboard/vim" },
  433. // { caption : "Emacs", value : "ace/keyboard/emacs" },
  434. // { caption : "Sublime", value : "ace/keyboard/sublime" },
  435. { caption : "VSCode", value : "ace/keyboard/vscode" }
  436. ]
  437. },
  438. "Font Size": {
  439. path: "fontSize",
  440. type: "number",
  441. defaultValue: 12,
  442. defaults: [
  443. {caption: "12px", value: 12},
  444. {caption: "24px", value: 24}
  445. ]
  446. }
  447. // "Soft Wrap": {
  448. // type: "buttonBar",
  449. // path: "wrap",
  450. // items: [
  451. // { caption : "Off", value : "off" },
  452. // { caption : "View", value : "free" },
  453. // { caption : "margin", value : "printMargin" },
  454. // { caption : "40", value : "40" }
  455. // ]
  456. // },
  457. // "Cursor Style": {
  458. // path: "cursorStyle",
  459. // items: [
  460. // { caption : "Ace", value : "ace" },
  461. // { caption : "Slim", value : "slim" },
  462. // { caption : "Smooth", value : "smooth" },
  463. // { caption : "Smooth And Slim", value : "smooth slim" },
  464. // { caption : "Wide", value : "wide" }
  465. // ]
  466. // },
  467. // "Folding": {
  468. // path: "foldStyle",
  469. // items: [
  470. // { caption : "Manual", value : "manual" },
  471. // { caption : "Mark begin", value : "markbegin" },
  472. // { caption : "Mark begin and end", value : "markbeginend" }
  473. // ]
  474. // },
  475. // "Soft Tabs": [{
  476. // path: "useSoftTabs"
  477. // }, {
  478. // ariaLabel: "Tab Size",
  479. // path: "tabSize",
  480. // type: "number",
  481. // values: [2, 3, 4, 8, 16]
  482. // }],
  483. // "Overscroll": {
  484. // type: "buttonBar",
  485. // path: "scrollPastEnd",
  486. // items: [
  487. // { caption : "None", value : 0 },
  488. // { caption : "Half", value : 0.5 },
  489. // { caption : "Full", value : 1 }
  490. // ]
  491. // }
  492. // },
  493. // More: {
  494. // "Atomic soft tabs": {
  495. // path: "navigateWithinSoftTabs"
  496. // },
  497. // "Enable Behaviours": {
  498. // path: "behavioursEnabled"
  499. // },
  500. // "Wrap with quotes": {
  501. // path: "wrapBehavioursEnabled"
  502. // },
  503. // "Enable Auto Indent": {
  504. // path: "enableAutoIndent"
  505. // },
  506. // "Full Line Selection": {
  507. // type: "checkbox",
  508. // values: "text|line",
  509. // path: "selectionStyle"
  510. // },
  511. // "Highlight Active Line": {
  512. // path: "highlightActiveLine"
  513. // },
  514. // "Show Invisibles": {
  515. // path: "showInvisibles"
  516. // },
  517. // "Show Indent Guides": {
  518. // path: "displayIndentGuides"
  519. // },
  520. // "Persistent HScrollbar": {
  521. // path: "hScrollBarAlwaysVisible"
  522. // },
  523. // "Persistent VScrollbar": {
  524. // path: "vScrollBarAlwaysVisible"
  525. // },
  526. // "Animate scrolling": {
  527. // path: "animatedScroll"
  528. // },
  529. // "Show Gutter": {
  530. // path: "showGutter"
  531. // },
  532. // "Show Line Numbers": {
  533. // path: "showLineNumbers"
  534. // },
  535. // "Relative Line Numbers": {
  536. // path: "relativeLineNumbers"
  537. // },
  538. // "Fixed Gutter Width": {
  539. // path: "fixedWidthGutter"
  540. // },
  541. // "Show Print Margin": [{
  542. // path: "showPrintMargin"
  543. // }, {
  544. // ariaLabel: "Print Margin",
  545. // type: "number",
  546. // path: "printMarginColumn"
  547. // }],
  548. // "Indented Soft Wrap": {
  549. // path: "indentedSoftWrap"
  550. // },
  551. // "Highlight selected word": {
  552. // path: "highlightSelectedWord"
  553. // },
  554. // "Fade Fold Widgets": {
  555. // path: "fadeFoldWidgets"
  556. // },
  557. // "Use textarea for IME": {
  558. // path: "useTextareaForIME"
  559. // },
  560. // "Merge Undo Deltas": {
  561. // path: "mergeUndoDeltas",
  562. // items: [
  563. // { caption : "Always", value : "always" },
  564. // { caption : "Never", value : "false" },
  565. // { caption : "Timed", value : "true" }
  566. // ]
  567. // },
  568. // "Elastic Tabstops": {
  569. // path: "useElasticTabstops"
  570. // },
  571. // "Incremental Search": {
  572. // path: "useIncrementalSearch"
  573. // },
  574. // "Read-only": {
  575. // path: "readOnly"
  576. // },
  577. // "Copy without selection": {
  578. // path: "copyWithEmptySelection"
  579. // },
  580. // "Live Autocompletion": {
  581. // path: "enableLiveAutocompletion"
  582. // }
  583. }
  584. };
  585. var OptionPanel = function(editor, element) {
  586. this.editor = editor;
  587. this.container = element || document.createElement("div");
  588. this.groups = [];
  589. this.options = {};
  590. };
  591. (function() {
  592. oop.implement(this, EventEmitter);
  593. this.add = function(config) {
  594. if (config.Main)
  595. oop.mixin(optionGroups.Main, config.Main);
  596. if (config.More)
  597. oop.mixin(optionGroups.More, config.More);
  598. };
  599. this.render = function() {
  600. this.container.innerHTML = "";
  601. buildDom(["table", {role: "presentation", id: "controls"},
  602. this.renderOptionGroup(optionGroups.Main),
  603. ["tr", null, ["td", {colspan: 2},
  604. ["table", {role: "presentation", id: "more-controls"},
  605. this.renderOptionGroup(optionGroups.More)
  606. ]
  607. ]],
  608. ["tr", null, ["td", {colspan: 2}, "version " + config.version]]
  609. ], this.container);
  610. };
  611. this.renderOptionGroup = function(group) {
  612. return Object.keys(group).map(function(key, i) {
  613. var item = group[key];
  614. if (!item.position)
  615. item.position = i / 10000;
  616. if (!item.label)
  617. item.label = key;
  618. return item;
  619. }).sort(function(a, b) {
  620. return a.position - b.position;
  621. }).map(function(item) {
  622. return this.renderOption(item.label, item);
  623. }, this);
  624. };
  625. this.renderOptionControl = function(key, option) {
  626. var self = this;
  627. if (Array.isArray(option)) {
  628. return option.map(function(x) {
  629. return self.renderOptionControl(key, x);
  630. });
  631. }
  632. var control;
  633. var value = self.getOption(option);
  634. if (option.values && option.type != "checkbox") {
  635. if (typeof option.values == "string")
  636. option.values = option.values.split("|");
  637. option.items = option.values.map(function(v) {
  638. return { value: v, name: v };
  639. });
  640. }
  641. if (option.type == "buttonBar") {
  642. control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
  643. return ["button", {
  644. value: item.value,
  645. ace_selected_button: value == item.value,
  646. 'aria-pressed': value == item.value,
  647. onclick: function() {
  648. self.setOption(option, item.value);
  649. var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
  650. for (var i = 0; i < nodes.length; i++) {
  651. nodes[i].removeAttribute("ace_selected_button");
  652. nodes[i].setAttribute("aria-pressed", false);
  653. }
  654. this.setAttribute("ace_selected_button", true);
  655. this.setAttribute("aria-pressed", true);
  656. }
  657. }, item.desc || item.caption || item.name];
  658. })];
  659. } else if (option.type == "number") {
  660. control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() {
  661. self.setOption(option, parseInt(this.value));
  662. }}];
  663. if (option.ariaLabel) {
  664. control[1]["aria-label"] = option.ariaLabel;
  665. } else {
  666. control[1].id = key;
  667. }
  668. if (option.defaults) {
  669. control = [control, option.defaults.map(function(item) {
  670. return ["button", {onclick: function() {
  671. var input = this.parentNode.firstChild;
  672. input.value = item.value;
  673. input.oninput();
  674. }}, item.caption];
  675. })];
  676. }
  677. } else if (option.items) {
  678. var buildItems = function(items) {
  679. return items.map(function(item) {
  680. return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
  681. });
  682. };
  683. var items = Array.isArray(option.items)
  684. ? buildItems(option.items)
  685. : Object.keys(option.items).map(function(key) {
  686. return ["optgroup", {"label": key}, buildItems(option.items[key])];
  687. });
  688. control = ["select", { id: key, value: value, onchange: function() {
  689. self.setOption(option, this.value);
  690. } }, items];
  691. } else {
  692. if (typeof option.values == "string")
  693. option.values = option.values.split("|");
  694. if (option.values) value = value == option.values[1];
  695. control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
  696. var value = this.checked;
  697. if (option.values) value = option.values[value ? 1 : 0];
  698. self.setOption(option, value);
  699. }}];
  700. if (option.type == "checkedNumber") {
  701. control = [control, []];
  702. }
  703. }
  704. return control;
  705. };
  706. this.renderOption = function(key, option) {
  707. if (option.path && !option.onchange && !this.editor.$options[option.path])
  708. return;
  709. var path = Array.isArray(option) ? option[0].path : option.path;
  710. this.options[path] = option;
  711. var safeKey = "-" + path;
  712. var safeId = path + "-label";
  713. var control = this.renderOptionControl(safeKey, option);
  714. return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
  715. ["label", {for: safeKey, id: safeId}, key]
  716. ], ["td", control]];
  717. };
  718. this.setOption = function(option, value) {
  719. if (typeof option == "string")
  720. option = this.options[option];
  721. if (value == "false") value = false;
  722. if (value == "true") value = true;
  723. if (value == "null") value = null;
  724. if (value == "undefined") value = undefined;
  725. if (typeof value == "string" && parseFloat(value).toString() == value)
  726. value = parseFloat(value);
  727. if (option.onchange)
  728. option.onchange(value);
  729. else if (option.path)
  730. this.editor.setOption(option.path, value);
  731. this._signal("setOption", {name: option.path, value: value});
  732. };
  733. this.getOption = function(option) {
  734. if (option.getValue)
  735. return option.getValue();
  736. return this.editor.getOption(option.path);
  737. };
  738. }).call(OptionPanel.prototype);
  739. exports.OptionPanel = OptionPanel;
  740. }); (function() {
  741. window.ace_require(["ace/ext/options"], function(m) {
  742. if (typeof module == "object" && typeof exports == "object" && module) {
  743. module.exports = m;
  744. }
  745. });
  746. })();