add keyboard shortcuts to partial view editor

This commit is contained in:
Mads Rasmussen
2017-03-02 16:05:31 +01:00
parent 9a99ad1416
commit 199c5a9606
4 changed files with 119 additions and 14 deletions

View File

@@ -130,6 +130,30 @@
};
}
function getPartialViewEditorShortcuts(){
return {
"name": "Umbraco", //No need to localise Umbraco is the same in all languages :)
"shortcuts": [
{
"description": localizationService.format(["template_insert", "template_insertPageField"], "%0% %1%"),
"keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }]
},
{
"description": localizationService.format(["template_insert", "template_insertDictionaryItem"], "%0% %1%"),
"keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }]
},
{
"description": localizationService.format(["template_insert", "template_insertMacro"], "%0% %1%"),
"keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }]
},
{
"description": localizationService.localize("template_queryBuilder"),
"keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }]
}
]
};
}
////////////
var service = {
@@ -141,7 +165,8 @@
getAddSectionSnippet: getAddSectionSnippet,
getGeneralShortcuts: getGeneralShortcuts,
getEditorShortcuts: getEditorShortcuts,
getTemplateEditorShortcuts: getTemplateEditorShortcuts
getTemplateEditorShortcuts: getTemplateEditorShortcuts,
getPartialViewEditorShortcuts: getPartialViewEditorShortcuts
};
return service;

View File

@@ -15,6 +15,16 @@
vm.page.menu.currentSection = appState.getSectionState("currentSection");
vm.page.menu.currentNode = null;
//Used to toggle the keyboard shortcut modal
//From a custom keybinding in ace editor - that conflicts with our own to show the dialog
vm.showKeyboardShortcut = false;
//Keyboard shortcuts for help dialog
vm.page.keyboardShortcutsOverview = [];
vm.page.keyboardShortcutsOverview.push(templateHelper.getGeneralShortcuts());
vm.page.keyboardShortcutsOverview.push(templateHelper.getEditorShortcuts());
vm.page.keyboardShortcutsOverview.push(templateHelper.getPartialViewEditorShortcuts());
// bind functions to view model
vm.save = save;
vm.openPageFieldOverlay = openPageFieldOverlay;
@@ -270,6 +280,72 @@
},
onLoad: function(_editor) {
vm.editor = _editor;
//Update the auto-complete method to use ctrl+alt+space
_editor.commands.bindKey("ctrl-alt-space", "startAutocomplete");
//Unassigns the keybinding (That was previously auto-complete)
//As conflicts with our own tree search shortcut
_editor.commands.bindKey("ctrl-space", null);
//TODO: Move all these keybinding config out into some helper/service
// Assign new keybinding
_editor.commands.addCommands([
//Disable (alt+shift+K)
//Conflicts with our own show shortcuts dialog - this overrides it
{
name: 'unSelectOrFindPrevious',
bindKey: 'Alt-Shift-K',
exec: function () {
//Toggle the show keyboard shortcuts overlay
$scope.$apply(function () {
vm.showKeyboardShortcut = !vm.showKeyboardShortcut;
});
},
readOnly: true
},
{
name: 'insertUmbracoValue',
bindKey: 'Alt-Shift-V',
exec: function () {
$scope.$apply(function () {
openPageFieldOverlay();
});
},
readOnly: true
},
{
name: 'insertDictionary',
bindKey: 'Alt-Shift-D',
exec: function () {
$scope.$apply(function () {
openDictionaryItemOverlay();
});
},
readOnly: true
},
{
name: 'insertUmbracoMacro',
bindKey: 'Alt-Shift-M',
exec: function () {
$scope.$apply(function () {
openMacroOverlay();
});
},
readOnly: true
},
{
name: 'insertQuery',
bindKey: 'Alt-Shift-Q',
exec: function () {
$scope.$apply(function () {
openQueryBuilderOverlay();
});
},
readOnly: true
},
]);
// initial cursor placement
// Keep cursor in name field if we are create a new template

View File

@@ -67,18 +67,23 @@
<umb-editor-footer>
<umb-editor-footer-content-right>
<umb-editor-footer-content-left>
<umb-keyboard-shortcuts-overview
model="vm.page.keyboardShortcutsOverview"
show-overlay="vm.showKeyboardShortcut">
</umb-keyboard-shortcuts-overview>
</umb-editor-footer-content-left>
<umb-button
type="submit"
button-style="success"
state="vm.page.saveButtonState"
shortcut="ctrl+s"
label="Save"
label-key="buttons_save">
</umb-button>
</umb-editor-footer-content-right>
<umb-editor-footer-content-right>
<umb-button
type="submit"
button-style="success"
state="vm.page.saveButtonState"
shortcut="ctrl+s"
label="Save"
label-key="buttons_save">
</umb-button>
</umb-editor-footer-content-right>
</umb-editor-footer>

View File

@@ -161,9 +161,8 @@
//As conflicts with our own tree search shortcut
_editor.commands.bindKey("ctrl-space", null);
//TODO: Move all these keybinding config out into some helper/service
// Assign new keybinding
_editor.commands.addCommands([
//Disable (alt+shift+K)
//Conflicts with our own show shortcuts dialog - this overrides it