123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866 |
- define("ace/ext/menu_tools/overlay_page",["ace_require","exports","module","ace/lib/dom"], function(ace_require, exports, module) {
- 'use strict';
- var dom = ace_require("../../lib/dom");
- var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
- background-color: #F7F7F7;\
- color: black;\
- box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
- padding: 1em 0.5em 2em 1em;\
- overflow: auto;\
- position: absolute;\
- margin: 0;\
- bottom: 0;\
- right: 0;\
- top: 0;\
- z-index: 9991;\
- cursor: default;\
- }\
- .ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
- box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
- background-color: rgba(255, 255, 255, 0.6);\
- color: black;\
- }\
- .ace_optionsMenuEntry:hover {\
- background-color: rgba(100, 100, 100, 0.1);\
- transition: all 0.3s\
- }\
- .ace_closeButton {\
- background: rgba(245, 146, 146, 0.5);\
- border: 1px solid #F48A8A;\
- border-radius: 50%;\
- padding: 7px;\
- position: absolute;\
- right: -8px;\
- top: -8px;\
- z-index: 100000;\
- }\
- .ace_closeButton{\
- background: rgba(245, 146, 146, 0.9);\
- }\
- .ace_optionsMenuKey {\
- color: darkslateblue;\
- font-weight: bold;\
- }\
- .ace_optionsMenuCommand {\
- color: darkcyan;\
- font-weight: normal;\
- }\
- .ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
- vertical-align: middle;\
- }\
- .ace_optionsMenuEntry button[ace_selected_button=true] {\
- background: #e7e7e7;\
- box-shadow: 1px 0px 2px 0px #adadad inset;\
- border-color: #adadad;\
- }\
- .ace_optionsMenuEntry button {\
- background: white;\
- border: 1px solid lightgray;\
- margin: 0px;\
- }\
- .ace_optionsMenuEntry button:hover{\
- background: #f0f0f0;\
- }";
- dom.importCssString(cssText);
- module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
- var closer = document.createElement('div');
- var ignoreFocusOut = false;
- function documentEscListener(e) {
- if (e.keyCode === 27) {
- close();
- }
- }
- function close() {
- if (!closer) return;
- document.removeEventListener('keydown', documentEscListener);
- closer.parentNode.removeChild(closer);
- // if (editor) {
- // editor.focus();
- // }
- closer = null;
- callback && callback();
- }
- function setIgnoreFocusOut(ignore) {
- ignoreFocusOut = ignore;
- if (ignore) {
- closer.style.pointerEvents = "none";
- contentElement.style.pointerEvents = "auto";
- }
- }
- closer.style.cssText = 'margin: 0; padding: 0; ' +
- 'position: fixed; top:0; bottom:0; left:0; right:0;' +
- 'z-index: 9990; ' +
- (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
- let oldPos = {x:0,y:0};
- let isCanClose = false
- closer.addEventListener('mousedown', function(e) {
- oldPos.x = e.clientX
- oldPos.y = e.clientY
- isCanClose = true
- });
- closer.addEventListener('mousemove', function(e) {
- isCanClose = Math.abs(oldPos.x - e.clientX) <4 && Math.abs(oldPos.y - e.clientY) <4;
- });
- closer.addEventListener('click', function(e) {
- if(!isCanClose){
- return
- }
- if (!ignoreFocusOut) {
- close();
- }
- });
-
- document.addEventListener('keydown', documentEscListener);
- contentElement.addEventListener('click', function (e) {
- e.stopPropagation();
- });
- closer.appendChild(contentElement);
- document.body.appendChild(closer);
- if (editor) {
- editor.blur();
- }
- return {
- close: close,
- setIgnoreFocusOut: setIgnoreFocusOut
- };
- };
- });
- define("ace/ext/modelist",["ace_require","exports","module"], function(ace_require, exports, module) {
- "use strict";
- var modes = [];
- function getModeForPath(path) {
- var mode = modesByName.text;
- var fileName = path.split(/[\/\\]/).pop();
- for (var i = 0; i < modes.length; i++) {
- if (modes[i].supportsFile(fileName)) {
- mode = modes[i];
- break;
- }
- }
- return mode;
- }
- var Mode = function(name, caption, extensions) {
- this.name = name;
- this.caption = caption;
- this.mode = name,//"ace/mode/" + name;
- this.extensions = extensions;
- var re;
- if (/\^/.test(extensions)) {
- re = extensions.replace(/\|(\^)?/g, function(a, b){
- return "$|" + (b ? "^" : "^.*\\.");
- }) + "$";
- } else {
- re = "^.*\\.(" + extensions + ")$";
- }
- this.extRe = new RegExp(re, "gi");
- };
- Mode.prototype.supportsFile = function(filename) {
- return filename.match(this.extRe);
- };
- var supportedModes = {
- ABAP: ["abap"],
- ABC: ["abc"],
- ActionScript:["as"],
- ADA: ["ada|adb"],
- Alda: ["alda"],
- Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
- Apex: ["apex|cls|trigger|tgr"],
- AQL: ["aql"],
- AsciiDoc: ["asciidoc|adoc"],
- ASL: ["dsl|asl"],
- Assembly_x86:["asm|a"],
- AutoHotKey: ["ahk"],
- BatchFile: ["bat|cmd"],
- C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
- C9Search: ["c9search_results"],
- Cirru: ["cirru|cr"],
- Clojure: ["clj|cljs"],
- Cobol: ["CBL|COB"],
- coffee: ["coffee|cf|cson|^Cakefile"],
- ColdFusion: ["cfm"],
- Crystal: ["cr"],
- CSharp: ["cs"],
- Csound_Document: ["csd"],
- Csound_Orchestra: ["orc"],
- Csound_Score: ["sco"],
- CSS: ["css"],
- Curly: ["curly"],
- D: ["d|di"],
- Dart: ["dart"],
- Diff: ["diff|patch"],
- Dockerfile: ["^Dockerfile"],
- Dot: ["dot"],
- Drools: ["drl"],
- Edifact: ["edi"],
- Eiffel: ["e|ge"],
- EJS: ["ejs"],
- Elixir: ["ex|exs"],
- Elm: ["elm"],
- Erlang: ["erl|hrl"],
- Forth: ["frt|fs|ldr|fth|4th"],
- Fortran: ["f|f90"],
- FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
- FSL: ["fsl"],
- FTL: ["ftl"],
- Gcode: ["gcode"],
- Gherkin: ["feature"],
- Gitignore: ["^.gitignore"],
- Glsl: ["glsl|frag|vert"],
- Gobstones: ["gbs"],
- golang: ["go"],
- GraphQLSchema: ["gql"],
- Groovy: ["groovy"],
- HAML: ["haml"],
- Handlebars: ["hbs|handlebars|tpl|mustache"],
- Haskell: ["hs"],
- Haskell_Cabal: ["cabal"],
- haXe: ["hx"],
- Hjson: ["hjson"],
- HTML: ["html|htm|xhtml|vue|we|wpy"],
- HTML_Elixir: ["eex|html.eex"],
- HTML_Ruby: ["erb|rhtml|html.erb"],
- INI: ["ini|conf|cfg|prefs"],
- Io: ["io"],
- Jack: ["jack"],
- Jade: ["jade|pug"],
- Java: ["java"],
- JavaScript: ["js|jsm|jsx"],
- JSON: ["json"],
- JSON5: ["json5"],
- JSONiq: ["jq"],
- JSP: ["jsp"],
- JSSM: ["jssm|jssm_state"],
- JSX: ["jsx"],
- Julia: ["jl"],
- Kotlin: ["kt|kts"],
- LaTeX: ["tex|latex|ltx|bib"],
- LESS: ["less"],
- Liquid: ["liquid"],
- Lisp: ["lisp"],
- LiveScript: ["ls"],
- LogiQL: ["logic|lql"],
- LSL: ["lsl"],
- Lua: ["lua"],
- LuaPage: ["lp"],
- Lucene: ["lucene"],
- Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
- Markdown: ["md|markdown"],
- Mask: ["mask"],
- MATLAB: ["matlab"],
- Maze: ["mz"],
- MediaWiki: ["wiki|mediawiki"],
- MEL: ["mel"],
- MIXAL: ["mixal"],
- MUSHCode: ["mc|mush"],
- MySQL: ["mysql"],
- Nginx: ["nginx|conf"],
- Nim: ["nim"],
- Nix: ["nix"],
- NSIS: ["nsi|nsh"],
- Nunjucks: ["nunjucks|nunjs|nj|njk"],
- ObjectiveC: ["m|mm"],
- OCaml: ["ml|mli"],
- Pascal: ["pas|p"],
- Perl: ["pl|pm"],
- Perl6: ["p6|pl6|pm6"],
- pgSQL: ["pgsql"],
- PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
- PHP_Laravel_blade: ["blade.php"],
- Pig: ["pig"],
- Powershell: ["ps1"],
- Praat: ["praat|praatscript|psc|proc"],
- Prisma: ["prisma"],
- Prolog: ["plg|prolog"],
- Properties: ["properties"],
- Protobuf: ["proto"],
- Puppet: ["epp|pp"],
- Python: ["py"],
- QML: ["qml"],
- R: ["r"],
- Razor: ["cshtml|asp"],
- RDoc: ["Rd"],
- Red: ["red|reds"],
- RHTML: ["Rhtml"],
- RST: ["rst"],
- Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
- Rust: ["rs"],
- SASS: ["sass"],
- SCAD: ["scad"],
- Scala: ["scala|sbt"],
- Scheme: ["scm|sm|rkt|oak|scheme"],
- SCSS: ["scss"],
- SH: ["sh|bash|^.bashrc"],
- SJS: ["sjs"],
- Slim: ["slim|skim"],
- Smarty: ["smarty|tpl"],
- snippets: ["snippets"],
- Soy_Template:["soy"],
- Space: ["space"],
- SQL: ["sql"],
- SQLServer: ["sqlserver"],
- Stylus: ["styl|stylus"],
- SVG: ["svg"],
- Swift: ["swift"],
- Tcl: ["tcl"],
- Terraform: ["tf", "tfvars", "terragrunt"],
- Tex: ["tex"],
- Text: ["txt"],
- Textile: ["textile"],
- Toml: ["toml"],
- TSX: ["tsx"],
- Twig: ["latte|twig|swig"],
- Typescript: ["ts|typescript|str"],
- Vala: ["vala"],
- VBScript: ["vbs|vb"],
- Velocity: ["vm"],
- Verilog: ["v|vh|sv|svh"],
- VHDL: ["vhd|vhdl"],
- Visualforce: ["vfp|component|page"],
- Wollok: ["wlk|wpgm|wtest"],
- XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
- XQuery: ["xq"],
- YAML: ["yaml|yml"],
- Zeek: ["zeek|bro"],
- Django: ["html"]
- };
- var nameOverrides = {
- ObjectiveC: "Objective-C",
- CSharp: "C#",
- golang: "Go",
- C_Cpp: "C and C++",
- Csound_Document: "Csound Document",
- Csound_Orchestra: "Csound",
- Csound_Score: "Csound Score",
- coffee: "CoffeeScript",
- HTML_Ruby: "HTML (Ruby)",
- HTML_Elixir: "HTML (Elixir)",
- FTL: "FreeMarker",
- PHP_Laravel_blade: "PHP (Blade Template)",
- Perl6: "Perl 6",
- AutoHotKey: "AutoHotkey / AutoIt"
- };
- var modesByName = {};
- for (var name in supportedModes) {
- var data = supportedModes[name];
- var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
- var filename = name.toLowerCase();
- var mode = new Mode(filename, displayName, data[0]);
- modesByName[filename] = mode;
- modes.push(mode);
- }
- module.exports = {
- getModeForPath: getModeForPath,
- modes: modes,
- modesByName: modesByName
- };
- });
- define("ace/ext/themelist",["ace_require","exports","module"], function(ace_require, exports, module) {
- "use strict";
- var themeData = [
- // ["Chrome" ],
- // ["Clouds" ],
- // ["Crimson Editor" ],
- // ["Dawn" ],
- // ["Dreamweaver" ],
- // ["Eclipse" ],
- // ["GitHub" ],
- // ["IPlastic" ],
- // ["Solarized Light"],
- // ["TextMate" ],
- // ["Tomorrow" ],
- // ["Xcode" ],
- // ["Kuroir"],
- // ["KatzenMilch"],
- // ["SQL Server" ,"sqlserver" , "light"],
- // ["Ambiance" ,"ambiance" , "dark"],
- // ["Chaos" ,"chaos" , "dark"],
- // ["Clouds Midnight" ,"clouds_midnight" , "dark"],
- // ["Dracula" ,"" , "dark"],
- // ["Cobalt" ,"cobalt" , "dark"],
- // ["Gruvbox" ,"gruvbox" , "dark"],
- // ["Green on Black" ,"gob" , "dark"],
- // ["idle Fingers" ,"idle_fingers" , "dark"],
- // ["krTheme" ,"kr_theme" , "dark"],
- // ["Merbivore" ,"merbivore" , "dark"],
- // ["Merbivore Soft" ,"merbivore_soft" , "dark"],
- // ["Mono Industrial" ,"mono_industrial" , "dark"],
- // ["Monokai" ,"monokai" , "dark"],
- // ["Nord Dark" ,"nord_dark" , "dark"],
- // ["Pastel on dark" ,"pastel_on_dark" , "dark"],
- // ["Solarized Dark" ,"solarized_dark" , "dark"],
- // ["Terminal" ,"terminal" , "dark"],
- // ["Tomorrow Night" ,"tomorrow_night" , "dark"],
- // ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
- // ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
- // ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
- // ["Twilight" ,"twilight" , "dark"],
- // ["Vibrant Ink" ,"vibrant_ink" , "dark"]
- ["vs" ,"vs" , "light"],
- ["vs-dark" ,"vs-dark" , "dark"],
- ["hc-black" ,"hc-black" , "dark"]
- ];
- exports.themesByName = {};
- exports.themes = themeData.map(function(data) {
- var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
- var theme = {
- caption: data[0],
- theme: name,//"ace/theme/" + name,
- isDark: data[2] == "dark",
- name: name
- };
- exports.themesByName[name] = theme;
- return theme;
- });
- });
- 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) {
- "use strict";
- ace_require("./menu_tools/overlay_page");
- var dom = ace_require("../lib/dom");
- var oop = ace_require("../lib/oop");
- var config = ace_require("../config");
- var EventEmitter = ace_require("../lib/event_emitter").EventEmitter;
- var buildDom = dom.buildDom;
- var modelist = ace_require("./modelist");
- var themelist = ace_require("./themelist");
- var themes = { Bright: [], Dark: [] };
- themelist.themes.forEach(function(x) {
- themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
- });
- var modes = modelist.modes.map(function(x){
- return { caption: x.caption, value: x.mode };
- });
- var package_config = Editor.require('packages://simple-code/package.json');
- var simple_config = Editor.require('packages://simple-code/config.js');
- var optionGroups = simple_config.optionGroups;
- // var optionGroups = {
- // Main: {
- // "语言": {
- // path: "mode",
- // type: "select",
- // items: modes
- // },
- // "主题": {
- // path: "theme",
- // type: "select",
- // items: themes
- // },
- // "快捷键习惯": {
- // type: "buttonBar",
- // path: "keyboardHandler",
- // defaultValue: "VSCode",
- // items: [
- // // { caption : "Ace", value : null },
- // // { caption : "Vim", value : "ace/keyboard/vim" },
- // // { caption : "Emacs", value : "ace/keyboard/emacs" },
- // // { caption : "Sublime", value : "ace/keyboard/sublime" },
- // { caption : "VSCode", value : "ace/keyboard/vscode" }
- // ]
- // },
- // "新建文件格式": {
- // type: "buttonBar",
- // path: "newFileType",
- // items: [
- // { caption : "js文件", value : "js" },
- // { caption : "ts文件", value : "ts" },
- // { caption : "coffe文件", value : "coffee" },
- // { caption : "lua文件", value : "lua" }
- // ]
- // },
- // "字体大小": {
- // path: "fontSize",
- // type: "number",
- // defaultValue: 12,
- // defaults: [
- // {caption: "6px", value: 8},
- // {caption: "10px", value: 10},
- // {caption: "12px", value: 12},
- // {caption: "16px", value: 16},
- // {caption: "18px", value: 18}
- // ]
- // },
- // // "换行显示": {
- // // type: "buttonBar",
- // // path: "wrap",
- // // items: [
- // // { caption : "Off", value : "off" },
- // // { caption : "View", value : "free" },
- // // { caption : "margin", value : "printMargin" },
- // // { caption : "40", value : "40" }
- // // ]
- // // }
- // // "光标样式": {
- // // path: "cursorStyle",
- // // items: [
- // // { caption : "Ace", value : "ace" },
- // // { caption : "Slim", value : "slim" },
- // // { caption : "Smooth", value : "smooth" },
- // // { caption : "Smooth And Slim", value : "smooth slim" },
- // // { caption : "Wide", value : "wide" }
- // // ]
- // // },
- // // "折叠模式": {
- // // path: "foldStyle",
- // // items: [
- // // { caption : "Manual", value : "manual" },
- // // { caption : "Mark begin", value : "markbegin" },
- // // { caption : "Mark begin and end", value : "markbeginend" }
- // // ]
- // // },
- // // "tab缩进": [{
- // // path: "useSoftTabs"
- // // }, {
- // // ariaLabel: "Tab Size",
- // // path: "tabSize",
- // // type: "number",
- // // values: [2, 3, 4, 8, 16]
- // // }],
- // // "页面滚动范围": {
- // // type: "buttonBar",
- // // path: "scrollPastEnd",
- // // items: [
- // // { caption : "None", value : 0 },
- // // { caption : "Half", value : 0.5 },
- // // { caption : "Full", value : 1 }
- // // ]
- // // }
- // },
- // More: {
- // "显示代码预览": {
- // path: "fixedWidthGutter"
- // },
- // "vim编辑模式": {
- // path: "useTextareaForIME"
- // },
- // },
- // // "空格tab缩进": {
- // // path: "navigateWithinSoftTabs"
- // // },
- // // "括号包选中的内容": {
- // // path: "wrapBehavioursEnabled"
- // // },
- // // "自动缩进": {
- // // path: "enableAutoIndent"
- // // },
- // // "全行选择": {
- // // type: "checkbox",
- // // values: "text|line",
- // // path: "selectionStyle"
- // // },
- // // // "Highlight Active Line": {
- // // // path: "highlightActiveLine"
- // // // },
- // // "显示行虚线": {
- // // path: "showInvisibles"
- // // },
- // // "显示列虚线": {
- // // path: "displayIndentGuides"
- // // },
- // // // "Persistent HScrollbar": {
- // // // path: "hScrollBarAlwaysVisible"
- // // // },
- // // // "Persistent VScrollbar": {
- // // // path: "vScrollBarAlwaysVisible"
- // // // },
- // // "滚动动作": {
- // // path: "animatedScroll"
- // // },
- // // // "显示行数": {
- // // // path: "showGutter"
- // // // },
- // // // "Show Line Numbers": {
- // // // path: "showLineNumbers"
- // // // },
- // // "相对性行数": {
- // // path: "relativeLineNumbers"
- // // },
- // // "行数固定宽": {
- // // path: "fixedWidthGutter"
- // // },
- // // // "显示打印边距": [{
- // // // path: "showPrintMargin"
- // // // }, {
- // // // ariaLabel: "Print Margin",
- // // // type: "number",
- // // // path: "printMarginColumn"
- // // // }],
- // // "Indented Soft Wrap": {
- // // path: "indentedSoftWrap"
- // // },
- // // "突出显示所选单词": {
- // // path: "highlightSelectedWord"
- // // },
- // // "淡入淡出折叠小部件": {
- // // path: "fadeFoldWidgets"
- // // },
- // // "使用文本区域输入法": {
- // // path: "useTextareaForIME"
- // // },
- // // "合并撤消操作": {
- // // path: "mergeUndoDeltas",
- // // items: [
- // // { caption : "Always", value : "always" },
- // // { caption : "Never", value : "false" },
- // // { caption : "Timed", value : "true" }
- // // ]
- // // },
- // // "弹性止动块": {
- // // path: "useElasticTabstops"
- // // },
- // // "增量搜索": {
- // // path: "useIncrementalSearch"
- // // },
- // // "不可编辑": {
- // // defaultValue: 0,
- // // path: "readOnly"
- // // },
- // // "无选择时复制整行": {
- // // defaultValue: 1,
- // // path: "copyWithEmptySelection"
- // // },
- // // "使用代码提示": {
- // // defaultValue: 1,
- // // path: "enableLiveAutocompletion"
- // // },
- // // "Enable Behaviours": {
- // // path: "behavioursEnabled"
- // // },
- // // }
- // };
- var OptionPanel = function(editor,cfg) {
- this.editor = editor;
- this.container = document.createElement("div");
- this.cfg = cfg;
- this.groups = [];
- this.options = {};
- };
- (function() {
- const tools = require("../../../tools/tools");
- oop.implement(this, EventEmitter);
-
- this.add = function(config) {
- if (config.Main)
- oop.mixin(optionGroups.Main, config.Main);
- if (config.More)
- oop.mixin(optionGroups.More, config.More);
- };
-
- this.render = function() {
- this.container.innerHTML = "";
- buildDom(["table", {role: "presentation", id: "controls"},
- this.renderOptionGroup(optionGroups.Main),
- ["tr", {class: "ace_optionsMenuEntry"}, ["td",["label", {for: 'More', id: 'More1'}, 'More']]],
- ["tr", null, ["td", {colspan: 2},
- ["table", {role: "presentation", id: "more-controls"},
- this.renderOptionGroup(optionGroups.More)
- ]
- ]],
- ["tr", null, ["td", {colspan: 2}, "version " + package_config.version]]
- ], this.container);
- };
-
- this.renderOptionGroup = function(group) {
- return Object.keys(group).map(function(key, i) {
- var item = group[key];
- if (!item.position)
- item.position = i / 10000;
- if (!item.label)
- item.label = tools.translate(key);
- return item;
- }).sort(function(a, b) {
- return a.position - b.position;
- }).map(function(item) {
- return this.renderOption(item.label, item);
- }, this);
- };
-
- this.renderOptionControl = function(key, option) {
- var self = this;
- if (Array.isArray(option)) {
- return option.map(function(x) {
- return self.renderOptionControl(key, x);
- });
- }
- var control;
-
- var value = self.getOption(option);
-
- if (option.values && option.type != "checkbox") {
- if (typeof option.values == "string")
- option.values = option.values.split("|");
- option.items = option.values.map(function(v) {
- return { value: v, name: v };
- });
- }
-
- if (option.type == "buttonBar") {
- control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
- return ["button", {
- value: item.value,
- ace_selected_button: value == item.value,
- 'aria-pressed': value == item.value,
- onclick: function() {
- self.setOption(option, item.value);
- var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
- for (var i = 0; i < nodes.length; i++) {
- nodes[i].removeAttribute("ace_selected_button");
- nodes[i].setAttribute("aria-pressed", false);
- }
- this.setAttribute("ace_selected_button", true);
- this.setAttribute("aria-pressed", true);
- }
- }, item.desc || item.caption || item.name];
- })];
- } else if (option.type == "number") {
- control = ["input", {type: "number", value: value == null ? option.defaultValue : value, style:"width:3em", oninput: function() {
- self.setOption(option, Number(this.value));
- }}];
- if (option.ariaLabel) {
- control[1]["aria-label"] = option.ariaLabel;
- } else {
- control[1].id = key;
- }
- if (option.defaults) {
- control = [control, option.defaults.map(function(item) {
- return ["button", {onclick: function() {
- var input = this.parentNode.firstChild;
- input.value = item.value;
- input.oninput();
- }}, item.caption];
- })];
- }
- } else if (option.items) {
- var buildItems = function(items) {
- return items.map(function(item) {
- return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
- });
- };
-
- var items = Array.isArray(option.items)
- ? buildItems(option.items)
- : Object.keys(option.items).map(function(key) {
- return ["optgroup", {"label": key}, buildItems(option.items[key])];
- });
- control = ["select", { id: key, value: value, onchange: function() {
- self.setOption(option, this.value);
- } }, items];
- } else {
- if (typeof option.values == "string")
- option.values = option.values.split("|");
- if (option.values) value = value == option.values[1];
- control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
- var value = this.checked;
- if (option.values) value = option.values[value ? 1 : 0];
- self.setOption(option, value);
- }}];
- if (option.type == "checkedNumber") {
- control = [control, []];
- }
- }
- return control;
- };
-
- this.renderOption = function(key, option) {
- // if (option.path && !option.onchange && !this.editor.$options[option.path])
- // return;
- var path = Array.isArray(option) ? option[0].path : option.path;
- this.options[path] = option;
- var safeKey = "-" + path;
- var safeId = path + "-label";
- var control = this.renderOptionControl(safeKey, option);
- return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
- ["label", {for: safeKey, id: safeId}, key]
- ], ["td", control]];
- };
-
- this.setOption = function(option, value) {
- if (typeof option == "string")
- option = this.options[option];
- if (value == "false") value = false;
- if (value == "true") value = true;
- if (value == "null") value = null;
- if (value == "undefined") value = undefined;
- if (typeof value == "string" && parseFloat(value).toString() == value)
- value = parseFloat(value);
- if (option.onchange)
- option.onchange(value);
- else if (option.path){
- this.editor.setOption(option.path, value);
- this.cfg[option.path] = value;
- }
- this._signal("setOption", {name: option.path, value: value});
- };
-
- this.getOption = function(option) {
- if (option.getValue)
- return option.getValue();
- // return this.editor.getOption(option.path);
- return this.cfg[option.path]
- };
-
- }).call(OptionPanel.prototype);
- exports.OptionPanel = OptionPanel;
- });
- 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) {
- "use strict";
- var OptionPanel = ace_require("./options").OptionPanel;
- var overlayPage = ace_require('./menu_tools/overlay_page').overlayPage;
- function showSettingsMenu(editor,cfg) {
- if (!document.getElementById('ace_settingsmenu')) {
- var options = new OptionPanel(editor,cfg);
- options.render();
- options.container.id = "ace_settingsmenu";
- overlayPage(editor, options.container);
- options.container.querySelector("select,input,button,checkbox").focus();
- }
- }
- module.exports.init = function() {
- var Editor = ace_require("../editor").Editor;
- Editor.prototype.showSettingsMenu = function(cfg) {
- showSettingsMenu(this,cfg);
- };
- };
- }); (function() {
- window.ace_require(["ace/ext/settings_menu"], function(m) {
- if (typeof module == "object" && typeof exports == "object" && module) {
- module.exports = m;
- }
- });
- })();
-
|