991088887944004e5b79fbc071dfe791.js 26 KB

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