ext-settings_menu.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  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. let oldPos = {x:0,y:0};
  95. let isCanClose = false
  96. closer.addEventListener('mousedown', function(e) {
  97. oldPos.x = e.clientX
  98. oldPos.y = e.clientY
  99. isCanClose = true
  100. });
  101. closer.addEventListener('mousemove', function(e) {
  102. isCanClose = Math.abs(oldPos.x - e.clientX) <4 && Math.abs(oldPos.y - e.clientY) <4;
  103. });
  104. closer.addEventListener('click', function(e) {
  105. if(!isCanClose){
  106. return
  107. }
  108. if (!ignoreFocusOut) {
  109. close();
  110. }
  111. });
  112. document.addEventListener('keydown', documentEscListener);
  113. contentElement.addEventListener('click', function (e) {
  114. e.stopPropagation();
  115. });
  116. closer.appendChild(contentElement);
  117. document.body.appendChild(closer);
  118. if (editor) {
  119. editor.blur();
  120. }
  121. return {
  122. close: close,
  123. setIgnoreFocusOut: setIgnoreFocusOut
  124. };
  125. };
  126. });
  127. define("ace/ext/modelist",["ace_require","exports","module"], function(ace_require, exports, module) {
  128. "use strict";
  129. var modes = [];
  130. function getModeForPath(path) {
  131. var mode = modesByName.text;
  132. var fileName = path.split(/[\/\\]/).pop();
  133. for (var i = 0; i < modes.length; i++) {
  134. if (modes[i].supportsFile(fileName)) {
  135. mode = modes[i];
  136. break;
  137. }
  138. }
  139. return mode;
  140. }
  141. var Mode = function(name, caption, extensions) {
  142. this.name = name;
  143. this.caption = caption;
  144. this.mode = name,//"ace/mode/" + name;
  145. this.extensions = extensions;
  146. var re;
  147. if (/\^/.test(extensions)) {
  148. re = extensions.replace(/\|(\^)?/g, function(a, b){
  149. return "$|" + (b ? "^" : "^.*\\.");
  150. }) + "$";
  151. } else {
  152. re = "^.*\\.(" + extensions + ")$";
  153. }
  154. this.extRe = new RegExp(re, "gi");
  155. };
  156. Mode.prototype.supportsFile = function(filename) {
  157. return filename.match(this.extRe);
  158. };
  159. var supportedModes = {
  160. ABAP: ["abap"],
  161. ABC: ["abc"],
  162. ActionScript:["as"],
  163. ADA: ["ada|adb"],
  164. Alda: ["alda"],
  165. Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
  166. Apex: ["apex|cls|trigger|tgr"],
  167. AQL: ["aql"],
  168. AsciiDoc: ["asciidoc|adoc"],
  169. ASL: ["dsl|asl"],
  170. Assembly_x86:["asm|a"],
  171. AutoHotKey: ["ahk"],
  172. BatchFile: ["bat|cmd"],
  173. C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
  174. C9Search: ["c9search_results"],
  175. Cirru: ["cirru|cr"],
  176. Clojure: ["clj|cljs"],
  177. Cobol: ["CBL|COB"],
  178. coffee: ["coffee|cf|cson|^Cakefile"],
  179. ColdFusion: ["cfm"],
  180. Crystal: ["cr"],
  181. CSharp: ["cs"],
  182. Csound_Document: ["csd"],
  183. Csound_Orchestra: ["orc"],
  184. Csound_Score: ["sco"],
  185. CSS: ["css"],
  186. Curly: ["curly"],
  187. D: ["d|di"],
  188. Dart: ["dart"],
  189. Diff: ["diff|patch"],
  190. Dockerfile: ["^Dockerfile"],
  191. Dot: ["dot"],
  192. Drools: ["drl"],
  193. Edifact: ["edi"],
  194. Eiffel: ["e|ge"],
  195. EJS: ["ejs"],
  196. Elixir: ["ex|exs"],
  197. Elm: ["elm"],
  198. Erlang: ["erl|hrl"],
  199. Forth: ["frt|fs|ldr|fth|4th"],
  200. Fortran: ["f|f90"],
  201. FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
  202. FSL: ["fsl"],
  203. FTL: ["ftl"],
  204. Gcode: ["gcode"],
  205. Gherkin: ["feature"],
  206. Gitignore: ["^.gitignore"],
  207. Glsl: ["glsl|frag|vert"],
  208. Gobstones: ["gbs"],
  209. golang: ["go"],
  210. GraphQLSchema: ["gql"],
  211. Groovy: ["groovy"],
  212. HAML: ["haml"],
  213. Handlebars: ["hbs|handlebars|tpl|mustache"],
  214. Haskell: ["hs"],
  215. Haskell_Cabal: ["cabal"],
  216. haXe: ["hx"],
  217. Hjson: ["hjson"],
  218. HTML: ["html|htm|xhtml|vue|we|wpy"],
  219. HTML_Elixir: ["eex|html.eex"],
  220. HTML_Ruby: ["erb|rhtml|html.erb"],
  221. INI: ["ini|conf|cfg|prefs"],
  222. Io: ["io"],
  223. Jack: ["jack"],
  224. Jade: ["jade|pug"],
  225. Java: ["java"],
  226. JavaScript: ["js|jsm|jsx"],
  227. JSON: ["json"],
  228. JSON5: ["json5"],
  229. JSONiq: ["jq"],
  230. JSP: ["jsp"],
  231. JSSM: ["jssm|jssm_state"],
  232. JSX: ["jsx"],
  233. Julia: ["jl"],
  234. Kotlin: ["kt|kts"],
  235. LaTeX: ["tex|latex|ltx|bib"],
  236. LESS: ["less"],
  237. Liquid: ["liquid"],
  238. Lisp: ["lisp"],
  239. LiveScript: ["ls"],
  240. LogiQL: ["logic|lql"],
  241. LSL: ["lsl"],
  242. Lua: ["lua"],
  243. LuaPage: ["lp"],
  244. Lucene: ["lucene"],
  245. Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
  246. Markdown: ["md|markdown"],
  247. Mask: ["mask"],
  248. MATLAB: ["matlab"],
  249. Maze: ["mz"],
  250. MediaWiki: ["wiki|mediawiki"],
  251. MEL: ["mel"],
  252. MIXAL: ["mixal"],
  253. MUSHCode: ["mc|mush"],
  254. MySQL: ["mysql"],
  255. Nginx: ["nginx|conf"],
  256. Nim: ["nim"],
  257. Nix: ["nix"],
  258. NSIS: ["nsi|nsh"],
  259. Nunjucks: ["nunjucks|nunjs|nj|njk"],
  260. ObjectiveC: ["m|mm"],
  261. OCaml: ["ml|mli"],
  262. Pascal: ["pas|p"],
  263. Perl: ["pl|pm"],
  264. Perl6: ["p6|pl6|pm6"],
  265. pgSQL: ["pgsql"],
  266. PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
  267. PHP_Laravel_blade: ["blade.php"],
  268. Pig: ["pig"],
  269. Powershell: ["ps1"],
  270. Praat: ["praat|praatscript|psc|proc"],
  271. Prisma: ["prisma"],
  272. Prolog: ["plg|prolog"],
  273. Properties: ["properties"],
  274. Protobuf: ["proto"],
  275. Puppet: ["epp|pp"],
  276. Python: ["py"],
  277. QML: ["qml"],
  278. R: ["r"],
  279. Razor: ["cshtml|asp"],
  280. RDoc: ["Rd"],
  281. Red: ["red|reds"],
  282. RHTML: ["Rhtml"],
  283. RST: ["rst"],
  284. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  285. Rust: ["rs"],
  286. SASS: ["sass"],
  287. SCAD: ["scad"],
  288. Scala: ["scala|sbt"],
  289. Scheme: ["scm|sm|rkt|oak|scheme"],
  290. SCSS: ["scss"],
  291. SH: ["sh|bash|^.bashrc"],
  292. SJS: ["sjs"],
  293. Slim: ["slim|skim"],
  294. Smarty: ["smarty|tpl"],
  295. snippets: ["snippets"],
  296. Soy_Template:["soy"],
  297. Space: ["space"],
  298. SQL: ["sql"],
  299. SQLServer: ["sqlserver"],
  300. Stylus: ["styl|stylus"],
  301. SVG: ["svg"],
  302. Swift: ["swift"],
  303. Tcl: ["tcl"],
  304. Terraform: ["tf", "tfvars", "terragrunt"],
  305. Tex: ["tex"],
  306. Text: ["txt"],
  307. Textile: ["textile"],
  308. Toml: ["toml"],
  309. TSX: ["tsx"],
  310. Twig: ["latte|twig|swig"],
  311. Typescript: ["ts|typescript|str"],
  312. Vala: ["vala"],
  313. VBScript: ["vbs|vb"],
  314. Velocity: ["vm"],
  315. Verilog: ["v|vh|sv|svh"],
  316. VHDL: ["vhd|vhdl"],
  317. Visualforce: ["vfp|component|page"],
  318. Wollok: ["wlk|wpgm|wtest"],
  319. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
  320. XQuery: ["xq"],
  321. YAML: ["yaml|yml"],
  322. Zeek: ["zeek|bro"],
  323. Django: ["html"]
  324. };
  325. var nameOverrides = {
  326. ObjectiveC: "Objective-C",
  327. CSharp: "C#",
  328. golang: "Go",
  329. C_Cpp: "C and C++",
  330. Csound_Document: "Csound Document",
  331. Csound_Orchestra: "Csound",
  332. Csound_Score: "Csound Score",
  333. coffee: "CoffeeScript",
  334. HTML_Ruby: "HTML (Ruby)",
  335. HTML_Elixir: "HTML (Elixir)",
  336. FTL: "FreeMarker",
  337. PHP_Laravel_blade: "PHP (Blade Template)",
  338. Perl6: "Perl 6",
  339. AutoHotKey: "AutoHotkey / AutoIt"
  340. };
  341. var modesByName = {};
  342. for (var name in supportedModes) {
  343. var data = supportedModes[name];
  344. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  345. var filename = name.toLowerCase();
  346. var mode = new Mode(filename, displayName, data[0]);
  347. modesByName[filename] = mode;
  348. modes.push(mode);
  349. }
  350. module.exports = {
  351. getModeForPath: getModeForPath,
  352. modes: modes,
  353. modesByName: modesByName
  354. };
  355. });
  356. define("ace/ext/themelist",["ace_require","exports","module"], function(ace_require, exports, module) {
  357. "use strict";
  358. var themeData = [
  359. // ["Chrome" ],
  360. // ["Clouds" ],
  361. // ["Crimson Editor" ],
  362. // ["Dawn" ],
  363. // ["Dreamweaver" ],
  364. // ["Eclipse" ],
  365. // ["GitHub" ],
  366. // ["IPlastic" ],
  367. // ["Solarized Light"],
  368. // ["TextMate" ],
  369. // ["Tomorrow" ],
  370. // ["Xcode" ],
  371. // ["Kuroir"],
  372. // ["KatzenMilch"],
  373. // ["SQL Server" ,"sqlserver" , "light"],
  374. // ["Ambiance" ,"ambiance" , "dark"],
  375. // ["Chaos" ,"chaos" , "dark"],
  376. // ["Clouds Midnight" ,"clouds_midnight" , "dark"],
  377. // ["Dracula" ,"" , "dark"],
  378. // ["Cobalt" ,"cobalt" , "dark"],
  379. // ["Gruvbox" ,"gruvbox" , "dark"],
  380. // ["Green on Black" ,"gob" , "dark"],
  381. // ["idle Fingers" ,"idle_fingers" , "dark"],
  382. // ["krTheme" ,"kr_theme" , "dark"],
  383. // ["Merbivore" ,"merbivore" , "dark"],
  384. // ["Merbivore Soft" ,"merbivore_soft" , "dark"],
  385. // ["Mono Industrial" ,"mono_industrial" , "dark"],
  386. // ["Monokai" ,"monokai" , "dark"],
  387. // ["Nord Dark" ,"nord_dark" , "dark"],
  388. // ["Pastel on dark" ,"pastel_on_dark" , "dark"],
  389. // ["Solarized Dark" ,"solarized_dark" , "dark"],
  390. // ["Terminal" ,"terminal" , "dark"],
  391. // ["Tomorrow Night" ,"tomorrow_night" , "dark"],
  392. // ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
  393. // ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
  394. // ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
  395. // ["Twilight" ,"twilight" , "dark"],
  396. // ["Vibrant Ink" ,"vibrant_ink" , "dark"]
  397. ["vs" ,"vs" , "light"],
  398. ["vs-dark" ,"vs-dark" , "dark"],
  399. ["hc-black" ,"hc-black" , "dark"]
  400. ];
  401. exports.themesByName = {};
  402. exports.themes = themeData.map(function(data) {
  403. var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
  404. var theme = {
  405. caption: data[0],
  406. theme: name,//"ace/theme/" + name,
  407. isDark: data[2] == "dark",
  408. name: name
  409. };
  410. exports.themesByName[name] = theme;
  411. return theme;
  412. });
  413. });
  414. 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) {
  415. "use strict";
  416. ace_require("./menu_tools/overlay_page");
  417. var dom = ace_require("../lib/dom");
  418. var oop = ace_require("../lib/oop");
  419. var config = ace_require("../config");
  420. var EventEmitter = ace_require("../lib/event_emitter").EventEmitter;
  421. var buildDom = dom.buildDom;
  422. var modelist = ace_require("./modelist");
  423. var themelist = ace_require("./themelist");
  424. var themes = { Bright: [], Dark: [] };
  425. themelist.themes.forEach(function(x) {
  426. themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
  427. });
  428. var modes = modelist.modes.map(function(x){
  429. return { caption: x.caption, value: x.mode };
  430. });
  431. var package_config = Editor.require('packages://simple-code/package.json');
  432. var simple_config = Editor.require('packages://simple-code/config.js');
  433. var optionGroups = simple_config.optionGroups;
  434. // var optionGroups = {
  435. // Main: {
  436. // "语言": {
  437. // path: "mode",
  438. // type: "select",
  439. // items: modes
  440. // },
  441. // "主题": {
  442. // path: "theme",
  443. // type: "select",
  444. // items: themes
  445. // },
  446. // "快捷键习惯": {
  447. // type: "buttonBar",
  448. // path: "keyboardHandler",
  449. // defaultValue: "VSCode",
  450. // items: [
  451. // // { caption : "Ace", value : null },
  452. // // { caption : "Vim", value : "ace/keyboard/vim" },
  453. // // { caption : "Emacs", value : "ace/keyboard/emacs" },
  454. // // { caption : "Sublime", value : "ace/keyboard/sublime" },
  455. // { caption : "VSCode", value : "ace/keyboard/vscode" }
  456. // ]
  457. // },
  458. // "新建文件格式": {
  459. // type: "buttonBar",
  460. // path: "newFileType",
  461. // items: [
  462. // { caption : "js文件", value : "js" },
  463. // { caption : "ts文件", value : "ts" },
  464. // { caption : "coffe文件", value : "coffee" },
  465. // { caption : "lua文件", value : "lua" }
  466. // ]
  467. // },
  468. // "字体大小": {
  469. // path: "fontSize",
  470. // type: "number",
  471. // defaultValue: 12,
  472. // defaults: [
  473. // {caption: "6px", value: 8},
  474. // {caption: "10px", value: 10},
  475. // {caption: "12px", value: 12},
  476. // {caption: "16px", value: 16},
  477. // {caption: "18px", value: 18}
  478. // ]
  479. // },
  480. // // "换行显示": {
  481. // // type: "buttonBar",
  482. // // path: "wrap",
  483. // // items: [
  484. // // { caption : "Off", value : "off" },
  485. // // { caption : "View", value : "free" },
  486. // // { caption : "margin", value : "printMargin" },
  487. // // { caption : "40", value : "40" }
  488. // // ]
  489. // // }
  490. // // "光标样式": {
  491. // // path: "cursorStyle",
  492. // // items: [
  493. // // { caption : "Ace", value : "ace" },
  494. // // { caption : "Slim", value : "slim" },
  495. // // { caption : "Smooth", value : "smooth" },
  496. // // { caption : "Smooth And Slim", value : "smooth slim" },
  497. // // { caption : "Wide", value : "wide" }
  498. // // ]
  499. // // },
  500. // // "折叠模式": {
  501. // // path: "foldStyle",
  502. // // items: [
  503. // // { caption : "Manual", value : "manual" },
  504. // // { caption : "Mark begin", value : "markbegin" },
  505. // // { caption : "Mark begin and end", value : "markbeginend" }
  506. // // ]
  507. // // },
  508. // // "tab缩进": [{
  509. // // path: "useSoftTabs"
  510. // // }, {
  511. // // ariaLabel: "Tab Size",
  512. // // path: "tabSize",
  513. // // type: "number",
  514. // // values: [2, 3, 4, 8, 16]
  515. // // }],
  516. // // "页面滚动范围": {
  517. // // type: "buttonBar",
  518. // // path: "scrollPastEnd",
  519. // // items: [
  520. // // { caption : "None", value : 0 },
  521. // // { caption : "Half", value : 0.5 },
  522. // // { caption : "Full", value : 1 }
  523. // // ]
  524. // // }
  525. // },
  526. // More: {
  527. // "显示代码预览": {
  528. // path: "fixedWidthGutter"
  529. // },
  530. // "vim编辑模式": {
  531. // path: "useTextareaForIME"
  532. // },
  533. // },
  534. // // "空格tab缩进": {
  535. // // path: "navigateWithinSoftTabs"
  536. // // },
  537. // // "括号包选中的内容": {
  538. // // path: "wrapBehavioursEnabled"
  539. // // },
  540. // // "自动缩进": {
  541. // // path: "enableAutoIndent"
  542. // // },
  543. // // "全行选择": {
  544. // // type: "checkbox",
  545. // // values: "text|line",
  546. // // path: "selectionStyle"
  547. // // },
  548. // // // "Highlight Active Line": {
  549. // // // path: "highlightActiveLine"
  550. // // // },
  551. // // "显示行虚线": {
  552. // // path: "showInvisibles"
  553. // // },
  554. // // "显示列虚线": {
  555. // // path: "displayIndentGuides"
  556. // // },
  557. // // // "Persistent HScrollbar": {
  558. // // // path: "hScrollBarAlwaysVisible"
  559. // // // },
  560. // // // "Persistent VScrollbar": {
  561. // // // path: "vScrollBarAlwaysVisible"
  562. // // // },
  563. // // "滚动动作": {
  564. // // path: "animatedScroll"
  565. // // },
  566. // // // "显示行数": {
  567. // // // path: "showGutter"
  568. // // // },
  569. // // // "Show Line Numbers": {
  570. // // // path: "showLineNumbers"
  571. // // // },
  572. // // "相对性行数": {
  573. // // path: "relativeLineNumbers"
  574. // // },
  575. // // "行数固定宽": {
  576. // // path: "fixedWidthGutter"
  577. // // },
  578. // // // "显示打印边距": [{
  579. // // // path: "showPrintMargin"
  580. // // // }, {
  581. // // // ariaLabel: "Print Margin",
  582. // // // type: "number",
  583. // // // path: "printMarginColumn"
  584. // // // }],
  585. // // "Indented Soft Wrap": {
  586. // // path: "indentedSoftWrap"
  587. // // },
  588. // // "突出显示所选单词": {
  589. // // path: "highlightSelectedWord"
  590. // // },
  591. // // "淡入淡出折叠小部件": {
  592. // // path: "fadeFoldWidgets"
  593. // // },
  594. // // "使用文本区域输入法": {
  595. // // path: "useTextareaForIME"
  596. // // },
  597. // // "合并撤消操作": {
  598. // // path: "mergeUndoDeltas",
  599. // // items: [
  600. // // { caption : "Always", value : "always" },
  601. // // { caption : "Never", value : "false" },
  602. // // { caption : "Timed", value : "true" }
  603. // // ]
  604. // // },
  605. // // "弹性止动块": {
  606. // // path: "useElasticTabstops"
  607. // // },
  608. // // "增量搜索": {
  609. // // path: "useIncrementalSearch"
  610. // // },
  611. // // "不可编辑": {
  612. // // defaultValue: 0,
  613. // // path: "readOnly"
  614. // // },
  615. // // "无选择时复制整行": {
  616. // // defaultValue: 1,
  617. // // path: "copyWithEmptySelection"
  618. // // },
  619. // // "使用代码提示": {
  620. // // defaultValue: 1,
  621. // // path: "enableLiveAutocompletion"
  622. // // },
  623. // // "Enable Behaviours": {
  624. // // path: "behavioursEnabled"
  625. // // },
  626. // // }
  627. // };
  628. var OptionPanel = function(editor,cfg) {
  629. this.editor = editor;
  630. this.container = document.createElement("div");
  631. this.cfg = cfg;
  632. this.groups = [];
  633. this.options = {};
  634. };
  635. (function() {
  636. const tools = require("../../../tools/tools");
  637. oop.implement(this, EventEmitter);
  638. this.add = function(config) {
  639. if (config.Main)
  640. oop.mixin(optionGroups.Main, config.Main);
  641. if (config.More)
  642. oop.mixin(optionGroups.More, config.More);
  643. };
  644. this.render = function() {
  645. this.container.innerHTML = "";
  646. buildDom(["table", {role: "presentation", id: "controls"},
  647. this.renderOptionGroup(optionGroups.Main),
  648. ["tr", {class: "ace_optionsMenuEntry"}, ["td",["label", {for: 'More', id: 'More1'}, 'More']]],
  649. ["tr", null, ["td", {colspan: 2},
  650. ["table", {role: "presentation", id: "more-controls"},
  651. this.renderOptionGroup(optionGroups.More)
  652. ]
  653. ]],
  654. ["tr", null, ["td", {colspan: 2}, "version " + package_config.version]]
  655. ], this.container);
  656. };
  657. this.renderOptionGroup = function(group) {
  658. return Object.keys(group).map(function(key, i) {
  659. var item = group[key];
  660. if (!item.position)
  661. item.position = i / 10000;
  662. if (!item.label)
  663. item.label = tools.translate(key);
  664. return item;
  665. }).sort(function(a, b) {
  666. return a.position - b.position;
  667. }).map(function(item) {
  668. return this.renderOption(item.label, item);
  669. }, this);
  670. };
  671. this.renderOptionControl = function(key, option) {
  672. var self = this;
  673. if (Array.isArray(option)) {
  674. return option.map(function(x) {
  675. return self.renderOptionControl(key, x);
  676. });
  677. }
  678. var control;
  679. var value = self.getOption(option);
  680. if (option.values && option.type != "checkbox") {
  681. if (typeof option.values == "string")
  682. option.values = option.values.split("|");
  683. option.items = option.values.map(function(v) {
  684. return { value: v, name: v };
  685. });
  686. }
  687. if (option.type == "buttonBar") {
  688. control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
  689. return ["button", {
  690. value: item.value,
  691. ace_selected_button: value == item.value,
  692. 'aria-pressed': value == item.value,
  693. onclick: function() {
  694. self.setOption(option, item.value);
  695. var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
  696. for (var i = 0; i < nodes.length; i++) {
  697. nodes[i].removeAttribute("ace_selected_button");
  698. nodes[i].setAttribute("aria-pressed", false);
  699. }
  700. this.setAttribute("ace_selected_button", true);
  701. this.setAttribute("aria-pressed", true);
  702. }
  703. }, item.desc || item.caption || item.name];
  704. })];
  705. } else if (option.type == "number") {
  706. control = ["input", {type: "number", value: value == null ? option.defaultValue : value, style:"width:3em", oninput: function() {
  707. self.setOption(option, Number(this.value));
  708. }}];
  709. if (option.ariaLabel) {
  710. control[1]["aria-label"] = option.ariaLabel;
  711. } else {
  712. control[1].id = key;
  713. }
  714. if (option.defaults) {
  715. control = [control, option.defaults.map(function(item) {
  716. return ["button", {onclick: function() {
  717. var input = this.parentNode.firstChild;
  718. input.value = item.value;
  719. input.oninput();
  720. }}, item.caption];
  721. })];
  722. }
  723. } else if (option.items) {
  724. var buildItems = function(items) {
  725. return items.map(function(item) {
  726. return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
  727. });
  728. };
  729. var items = Array.isArray(option.items)
  730. ? buildItems(option.items)
  731. : Object.keys(option.items).map(function(key) {
  732. return ["optgroup", {"label": key}, buildItems(option.items[key])];
  733. });
  734. control = ["select", { id: key, value: value, onchange: function() {
  735. self.setOption(option, this.value);
  736. } }, items];
  737. } else {
  738. if (typeof option.values == "string")
  739. option.values = option.values.split("|");
  740. if (option.values) value = value == option.values[1];
  741. control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
  742. var value = this.checked;
  743. if (option.values) value = option.values[value ? 1 : 0];
  744. self.setOption(option, value);
  745. }}];
  746. if (option.type == "checkedNumber") {
  747. control = [control, []];
  748. }
  749. }
  750. return control;
  751. };
  752. this.renderOption = function(key, option) {
  753. // if (option.path && !option.onchange && !this.editor.$options[option.path])
  754. // return;
  755. var path = Array.isArray(option) ? option[0].path : option.path;
  756. this.options[path] = option;
  757. var safeKey = "-" + path;
  758. var safeId = path + "-label";
  759. var control = this.renderOptionControl(safeKey, option);
  760. return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
  761. ["label", {for: safeKey, id: safeId}, key]
  762. ], ["td", control]];
  763. };
  764. this.setOption = function(option, value) {
  765. if (typeof option == "string")
  766. option = this.options[option];
  767. if (value == "false") value = false;
  768. if (value == "true") value = true;
  769. if (value == "null") value = null;
  770. if (value == "undefined") value = undefined;
  771. if (typeof value == "string" && parseFloat(value).toString() == value)
  772. value = parseFloat(value);
  773. if (option.onchange)
  774. option.onchange(value);
  775. else if (option.path){
  776. this.editor.setOption(option.path, value);
  777. this.cfg[option.path] = value;
  778. }
  779. this._signal("setOption", {name: option.path, value: value});
  780. };
  781. this.getOption = function(option) {
  782. if (option.getValue)
  783. return option.getValue();
  784. // return this.editor.getOption(option.path);
  785. return this.cfg[option.path]
  786. };
  787. }).call(OptionPanel.prototype);
  788. exports.OptionPanel = OptionPanel;
  789. });
  790. define("ace/ext/settings_menu",["ace_require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(ace_require, exports, module) {
  791. "use strict";
  792. var OptionPanel = ace_require("./options").OptionPanel;
  793. var overlayPage = ace_require('./menu_tools/overlay_page').overlayPage;
  794. function showSettingsMenu(editor,cfg) {
  795. if (!document.getElementById('ace_settingsmenu')) {
  796. var options = new OptionPanel(editor,cfg);
  797. options.render();
  798. options.container.id = "ace_settingsmenu";
  799. overlayPage(editor, options.container);
  800. options.container.querySelector("select,input,button,checkbox").focus();
  801. }
  802. }
  803. module.exports.init = function() {
  804. var Editor = ace_require("../editor").Editor;
  805. Editor.prototype.showSettingsMenu = function(cfg) {
  806. showSettingsMenu(this,cfg);
  807. };
  808. };
  809. }); (function() {
  810. window.ace_require(["ace/ext/settings_menu"], function(m) {
  811. if (typeof module == "object" && typeof exports == "object" && module) {
  812. module.exports = m;
  813. }
  814. });
  815. })();