19f066c0bebc1c63ec7fc7cc1a63b1df.js 26 KB

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