Keyboard shortcut settings

This commit is contained in:
benweet 2013-09-30 01:16:01 +01:00
parent 8ef1e6ae3b
commit 1229f9f06d
4 changed files with 86 additions and 49 deletions

View File

@ -6,6 +6,7 @@ define([
"utils",
"settings",
"eventMgr",
"shortcutMgr",
"mousetrap",
"text!html/bodyIndex.html",
"text!html/bodyViewer.html",
@ -21,7 +22,7 @@ define([
'ace/ext/spellcheck',
'ace/ext/searchbox'
], function($, _, crel, ace, utils, settings, eventMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
], function($, _, crel, ace, utils, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
var core = {};
@ -58,9 +59,9 @@ define([
}
if(windowId === undefined) {
windowId = utils.randomString();
localStorage["frontWindowId"] = windowId;
localStorage.frontWindowId = windowId;
}
var frontWindowId = localStorage["frontWindowId"];
var frontWindowId = localStorage.frontWindowId;
if(frontWindowId != windowId) {
windowUnique = false;
if(intervalId !== undefined) {
@ -260,7 +261,7 @@ define([
// only check every 5 lines
processedLines++;
if((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
if((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(customWorker, 20); // benweet
self.currentLine = currentLine;
return;
@ -271,7 +272,6 @@ define([
if(startLine <= endLine)
self.fireUpdateEvent(startLine, endLine);
}
;
self.$worker = function() {
self.lines.splice(0, self.lines.length);
self.states.splice(0, self.states.length);
@ -281,10 +281,12 @@ define([
})(aceEditor.session.bgTokenizer);
shortcutMgr.configureAce(aceEditor);
eventMgr.onAceCreated(aceEditor);
}
// Create the layout
var $editorButtonsElt = undefined;
function createLayout() {
var layoutGlobalConfig = {
closable: true,
@ -340,7 +342,7 @@ define([
$(".preview-container").html('<div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>');
layout = $('body').layout($.extend(layoutGlobalConfig, {
east__resizable: true,
east__size: .5,
east__size: 0.5,
east__minSize: 260
}));
}
@ -349,7 +351,7 @@ define([
$(".preview-container").html('<div id="preview-contents"><div id="wmd-preview" class="preview-content"></div></div>');
layout = $('body').layout($.extend(layoutGlobalConfig, {
south__resizable: true,
south__size: .5,
south__size: 0.5,
south__minSize: 200
}));
}
@ -367,7 +369,7 @@ define([
// north resizer is very small
// var $previewButtonsContainerElt = $('<div
// class="preview-button-container">');
$resizerDecorator = $('<div class="resizer-decorator">');
var $resizerDecorator = $('<div class="resizer-decorator">');
$previewButtonsElt = $('<div class="extension-preview-buttons">');
$editorButtonsElt = $('<div class="extension-editor-buttons">');
if(viewerMode || settings.layoutOrientation == "horizontal") {

View File

@ -48,6 +48,7 @@ define([
'</html>'
].join(""),
sshProxy: SSH_PROXY_URL,
shortcuts: {},
extensionSettings: {}
};

View File

@ -5,91 +5,91 @@ define([
], function(_, eventMgr, settings) {
var shortcutMgr = {};
var shortcuts = {
'bold': {
title: 'Strong',
defaults: {
defaultKey: {
win: 'Ctrl-B',
mac: 'Command-B|Ctrl-B',
},
isPageDown: true
},
'italic': {
title: 'Emphasis',
defaults: {
name: 'Emphasis',
defaultKey: {
win: 'Ctrl-I',
mac: 'Command-I|Ctrl-I',
},
isPageDown: true
},
'link': {
title: 'Hyperlink',
defaults: {
name: 'Hyperlink',
defaultKey: {
win: 'Ctrl-L',
mac: 'Command-L|Ctrl-L',
},
isPageDown: true
},
'quote': {
title: 'Blockquote',
defaults: {
name: 'Blockquote',
defaultKey: {
win: 'Ctrl-Q',
mac: 'Command-Q|Ctrl-Q',
},
isPageDown: true
},
'code': {
title: 'Code Sample',
defaults: {
name: 'Code Sample',
defaultKey: {
win: 'Ctrl-K',
mac: 'Command-K|Ctrl-K',
},
isPageDown: true
},
'image': {
title: 'Image',
defaults: {
name: 'Image',
defaultKey: {
win: 'Ctrl-G',
mac: 'Command-G|Ctrl-G',
},
isPageDown: true
},
'olist': {
title: 'Numbered List',
defaults: {
name: 'Numbered List',
defaultKey: {
win: 'Ctrl-O',
mac: 'Command-O|Ctrl-O',
},
isPageDown: true
},
'ulist': {
title: 'Bulleted List',
defaults: {
name: 'Bulleted List',
defaultKey: {
win: 'Ctrl-U',
mac: 'Command-U|Ctrl-U',
},
isPageDown: true
},
'heading': {
title: 'Heading',
defaults: {
name: 'Heading',
defaultKey: {
win: 'Ctrl-H',
mac: 'Command-H|Ctrl-H',
},
isPageDown: true
},
'hr': {
title: 'Horizontal Rule',
defaults: {
name: 'Horizontal Rule',
defaultKey: {
win: 'Ctrl-R',
mac: 'Command-R|Ctrl-R',
},
isPageDown: true
},
'undo': {
title: 'Undo',
defaults: {
name: 'Undo',
defaultKey: {
win: 'Ctrl-Z',
mac: 'Command-Z',
},
@ -100,7 +100,7 @@ define([
},
'redo': {
title: 'Redo',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-Z|Ctrl-Y',
mac: 'Command-Shift-Z|Command-Y',
},
@ -111,7 +111,7 @@ define([
},
'selectall': {
title: 'Select All',
defaults: {
defaultKey: {
win: 'Ctrl-A',
mac: 'Command-A',
},
@ -122,7 +122,7 @@ define([
},
'removeline': {
title: 'Remove Line',
defaults: {
defaultKey: {
win: 'Ctrl-D',
mac: 'Command-D',
},
@ -133,7 +133,7 @@ define([
},
'duplicateSelection': {
title: 'Duplicate Selection',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-D',
mac: 'Command-Shift-D',
},
@ -144,7 +144,7 @@ define([
},
'sortlines': {
title: 'Sort Lines',
defaults: {
defaultKey: {
win: 'Ctrl-Alt-S',
mac: 'Command-Alt-S',
},
@ -155,7 +155,7 @@ define([
},
'indent': {
title: 'Sort Lines',
defaults: {
defaultKey: {
win: 'Ctrl-Alt-S',
mac: 'Command-Alt-S',
},
@ -166,7 +166,7 @@ define([
},
'modifyNumberUp': {
title: 'Number Up',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-Up',
mac: 'Alt-Shift-Up',
},
@ -177,7 +177,7 @@ define([
},
'modifyNumberDown': {
title: 'Number Down',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-Down',
mac: 'Alt-Shift-Down',
},
@ -188,33 +188,35 @@ define([
},
'find': {
title: 'Find',
defaults: {
defaultKey: {
win: 'Ctrl-F',
mac: 'Command-F',
},
exec: function(editor) {
var config = require("ace/config");
config.loadModule("ace/ext/searchbox", function(e) {
e.Search(editor)
e.Search(editor);
});
},
readOnly: true
},
'replace': {
title: 'Replace',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-F',
mac: 'Command-Option-F',
},
exec: function(editor) {
var config = require("ace/config");
config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
config.loadModule("ace/ext/searchbox", function(e) {
e.Search(editor, true);
});
},
readOnly: true
},
'togglerecording': {
title: 'Toggle Recording',
defaults: {
defaultKey: {
win: 'Ctrl-Alt-E',
mac: 'Command-Option-E',
},
@ -225,7 +227,7 @@ define([
},
'replaymacro': {
title: 'Replay Macro',
defaults: {
defaultKey: {
win: 'Ctrl-Shift-E',
mac: 'Command-Shift-E',
},
@ -235,13 +237,16 @@ define([
readOnly: true
},
};
_.each(shortcuts, function(shortcut, key) {
shortcut.values = settings.shortcuts[key] || shortcut.defaults;
shortcut.name = key;
shortcut.bindKey = settings.shortcuts[key] || shortcut.defaultKey;
});
shortcutMgr.configureAce = function() {
shortcutMgr.configureAce = function(aceEditor) {
_.each(shortcuts, function(shortcut) {
shortcut.exec && aceEditor.commands.addCommand(_.pick(shortcut, 'name', 'bindKey', 'exec', 'readOnly', 'multiSelectAction'));
});
};
return shortcutMgr;

View File

@ -1028,7 +1028,36 @@ ul,ol {
.ace_search {
background-color: @primary-bg;
border: 0;
border: 6px solid @panel-bg;
border-top: 0;
padding: 10px 15px 5px;
font-family: @font-family-base;
min-width: 318px;
.ace_search_field {
width: 200px;
}
.ace_replacebtn {
padding: 0 4px;
}
.ace_searchbtn_close {
background: transparent;
margin: 0;
font-size: (@font-size-base * 1.5);
font-weight: @close-font-weight;
text-shadow: @close-text-shadow;
.opacity(.3);
&:before {
content: '\d7';
}
&:hover,
&:focus {
color: @close-color;
text-decoration: none;
cursor: pointer;
.opacity(.5);
background: transparent;
}
}
}
#wmd-input {