adds demo show_settings_menu
adds keyboard shortcut on init adds keyboard shortcut on init
This commit is contained in:
parent
7aac105a07
commit
3adba8eb21
4 changed files with 69 additions and 8 deletions
|
|
@ -31,8 +31,8 @@
|
||||||
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="../build/src-noconflict/ext-show_keyboard_shortcuts.js" type="text/javascript" charset="utf-8"></script>
|
<script src="../build/src-noconflict/ext-show_keyboard_shortcuts.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script>
|
<script>
|
||||||
ace.require('ace/ext/show_keyboard_shortcuts');
|
|
||||||
var editor = ace.edit("editor");
|
var editor = ace.edit("editor");
|
||||||
|
ace.require('ace/ext/show_keyboard_shortcuts').init(editor);
|
||||||
editor.setTheme("ace/theme/twilight");
|
editor.setTheme("ace/theme/twilight");
|
||||||
editor.getSession().setMode("ace/mode/javascript");
|
editor.getSession().setMode("ace/mode/javascript");
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
41
demo/show_settings_menu.html
Normal file
41
demo/show_settings_menu.html
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<title>Editor</title>
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor {
|
||||||
|
margin: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<pre id="editor">function foo(items) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < items.length; i++) {
|
||||||
|
alert("Ace Rocks " + items[i]);
|
||||||
|
}
|
||||||
|
}</pre>
|
||||||
|
|
||||||
|
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
<script src="../build/src-noconflict/ext-show_settings_menu.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
<script>
|
||||||
|
var editor = ace.edit("editor");
|
||||||
|
ace.require('ace/ext/show_settings_menu').init(editor);
|
||||||
|
editor.setTheme("ace/theme/twilight");
|
||||||
|
editor.getSession().setMode("ace/mode/javascript");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -61,7 +61,7 @@ define(function(require, exports, module) {
|
||||||
* ☭ Hial Atropa!! ☭
|
* ☭ Hial Atropa!! ☭
|
||||||
* @param {ace.Editor} editor An instance of the ace editor.
|
* @param {ace.Editor} editor An instance of the ace editor.
|
||||||
*/
|
*/
|
||||||
module.exports.showKeyboardShortcuts = function showKeyboardShortcuts (editor) {
|
function showKeyboardShortcuts (editor) {
|
||||||
// make sure the menu isn't open already.
|
// make sure the menu isn't open already.
|
||||||
if(!document.getElementById('kbshortcutmenu')) {
|
if(!document.getElementById('kbshortcutmenu')) {
|
||||||
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
||||||
|
|
@ -79,7 +79,17 @@ define(function(require, exports, module) {
|
||||||
overlayPage(editor, el, '0', '0', '0', null);
|
overlayPage(editor, el, '0', '0', '0', null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Editor.prototype.showKeyboardShortcuts = function () {
|
module.exports.init = function (editor) {
|
||||||
module.exports.showKeyboardShortcuts(this);
|
Editor.prototype.showKeyboardShortcuts = function () {
|
||||||
|
showKeyboardShortcuts(this);
|
||||||
|
};
|
||||||
|
editor.commands.addCommands([{
|
||||||
|
name: "showKeyboardShortcuts",
|
||||||
|
bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
|
||||||
|
exec: function(editor, line) {
|
||||||
|
editor.showKeyboardShortcuts();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -384,15 +384,25 @@ define(function(require, exports, module) {
|
||||||
* ☭ Hial Atropa!! ☭
|
* ☭ Hial Atropa!! ☭
|
||||||
* @param {ace.Editor} editor An instance of the ace editor.
|
* @param {ace.Editor} editor An instance of the ace editor.
|
||||||
*/
|
*/
|
||||||
module.exports.showSettingsMenu = function showSettingsMenu (editor) {
|
function showSettingsMenu (editor) {
|
||||||
// make sure the menu isn't open already.
|
// make sure the menu isn't open already.
|
||||||
if(!document.getElementById('settingsmenu')) {
|
if(!document.getElementById('settingsmenu')) {
|
||||||
addEditorMenuOptions(editor);
|
addEditorMenuOptions(editor);
|
||||||
generateMenu(editor);
|
generateMenu(editor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Editor.prototype.showSettingsMenu = function () {
|
|
||||||
module.exports.showSettingsMenu(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
module.exports.init = function (editor) {
|
||||||
|
Editor.prototype.showSettingsMenu = function () {
|
||||||
|
showSettingsMenu(this);
|
||||||
|
};
|
||||||
|
editor.commands.addCommands([{
|
||||||
|
name: "showSettingsMenu",
|
||||||
|
bindKey: {win: "Ctrl-q", mac: "Command-q"},
|
||||||
|
exec: function(editor, line) {
|
||||||
|
editor.showSettingsMenu();
|
||||||
|
},
|
||||||
|
readOnly: true
|
||||||
|
}]);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue