2b1eed411f531a271f0e47693c82216a.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
  59. "use strict";
  60. var keys = require("../../lib/keys");
  61. module.exports.getEditorKeybordShortcuts = function (editor) {
  62. var KEY_MODS = keys.KEY_MODS;
  63. var keybindings = [];
  64. var commandMap = {};
  65. editor.keyBinding.$handlers.forEach(function (handler) {
  66. var ckb = handler.commandKeyBinding;
  67. for (var i in ckb) {
  68. var key = i.replace(/(^|-)\w/g, function (x) { return x.toUpperCase(); });
  69. var commands = ckb[i];
  70. if (!Array.isArray(commands))
  71. commands = [commands];
  72. commands.forEach(function (command) {
  73. if (typeof command != "string")
  74. command = command.name;
  75. if (commandMap[command]) {
  76. commandMap[command].key += "|" + key;
  77. }
  78. else {
  79. commandMap[command] = { key: key, command: command };
  80. keybindings.push(commandMap[command]);
  81. }
  82. });
  83. }
  84. });
  85. return keybindings;
  86. };
  87. });
  88. ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
  89. "use strict";
  90. var Editor = require("../editor").Editor;
  91. function showKeyboardShortcuts(editor) {
  92. if (!document.getElementById('kbshortcutmenu')) {
  93. var overlayPage = require('./menu_tools/overlay_page').overlayPage;
  94. var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
  95. var kb = getEditorKeybordShortcuts(editor);
  96. var el = document.createElement('div');
  97. var commands = kb.reduce(function (previous, current) {
  98. return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'
  99. + current.command + '</span> : '
  100. + '<span class="ace_optionsMenuKey">' + current.key + '</span></div>';
  101. }, '');
  102. el.id = 'kbshortcutmenu';
  103. el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>';
  104. overlayPage(editor, el);
  105. }
  106. }
  107. module.exports.init = function (editor) {
  108. Editor.prototype.showKeyboardShortcuts = function () {
  109. showKeyboardShortcuts(this);
  110. };
  111. editor.commands.addCommands([{
  112. name: "showKeyboardShortcuts",
  113. bindKey: { win: "Ctrl-Alt-h", mac: "Command-Alt-h" },
  114. exec: function (editor, line) {
  115. editor.showKeyboardShortcuts();
  116. }
  117. }]);
  118. };
  119. }); (function() {
  120. ace.require(["ace/ext/keybinding_menu"], function(m) {
  121. if (typeof module == "object" && typeof exports == "object" && module) {
  122. module.exports = m;
  123. }
  124. });
  125. })();