From b9095629edb08e7489721d487e9bd74767b96835 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Fri, 20 Jan 2017 11:58:08 +0000 Subject: [PATCH 01/27] Update Keyboard Shortcut Directive to support a callback function being passed in & the bool thjat toggles the overlay/div from being shown --- .../umbkeyboardshortcutsoverview.directive.js | 10 ++++++---- .../components/umb-keyboard-shortcuts-overview.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js index 1bbfb850d9..703b20daca 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js @@ -114,12 +114,12 @@ When this combination is hit an overview is opened with shortcuts based on the m function link(scope, el, attr, ctrl) { - scope.shortcutOverlay = false; - scope.toggleShortcutsOverlay = function() { - scope.shortcutOverlay = !scope.shortcutOverlay; + scope.showOverlay = !scope.showOverlay; + scope.onToggle(); }; + } var directive = { @@ -128,7 +128,9 @@ When this combination is hit an overview is opened with shortcuts based on the m templateUrl: 'views/components/umb-keyboard-shortcuts-overview.html', link: link, scope: { - model: "=" + model: "=", + onToggle: "&", + showOverlay: "=" } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html index 6368bb1e37..33bb4d36be 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html @@ -17,7 +17,7 @@ -
+
From 6fb3c91d3f74d9223a921722146d3ce02e5f39a4 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Fri, 20 Jan 2017 15:19:42 +0000 Subject: [PATCH 02/27] Updates Keyboard Shorcut directive in template editor view to use the new attribute on the directive to pass in show overlay bool --- src/Umbraco.Web.UI.Client/src/views/templates/edit.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.html b/src/Umbraco.Web.UI.Client/src/views/templates/edit.html index e747a56138..ec8ca3e9b4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.html @@ -99,6 +99,15 @@ + + + + + + + From f0bdb1a2e92bba9c51175a65e507c30ad216e527 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Fri, 20 Jan 2017 15:21:17 +0000 Subject: [PATCH 03/27] Updates ACE Editor Directive to load in the additional library that enables simple auto-complete --- .../src/common/directives/components/umbaceeditor.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js index c97851bbb9..40a1a2cc6d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbaceeditor.directive.js @@ -125,7 +125,7 @@ function link(scope, el, attr, ngModel) { // Load in ace library - assetsService.loadJs('lib/ace-builds/src-min-noconflict/ace.js').then(function () { + assetsService.load(['lib/ace-builds/src-min-noconflict/ace.js', 'lib/ace-builds/src-min-noconflict/ext-language_tools.js']).then(function () { if (angular.isUndefined(window.ace)) { throw new Error('ui-ace need ace to work... (o rly?)'); } else { From 304b863b028a3f1b359adde5a11f45827fb63425 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Fri, 20 Jan 2017 15:24:09 +0000 Subject: [PATCH 04/27] Adds in keyboard shortcuts to power the dialog/UI and adds in the custom keyboard bindings for opening our cusotm dialogs for inserting macros, partials etc --- .../src/views/templates/edit.controller.js | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 526107daae..165eb95777 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -15,6 +15,96 @@ vm.page.menu = {}; 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 + //TODO: Localise strings + vm.page.keyboardShortcutsOverview = [ + { + "name": "General", + "shortcuts": [ + { + "description": "Undo", + "keys": [{ "key": "ctrl" }, { "key": "z" }] + }, + { + "description": "Redo", + "keys": [{ "key": "ctrl" }, { "key": "y" }] + }, + { + "description": "Save", + "keys": [{ "key": "ctrl" }, { "key": "s" }] + } + ] + }, + { + "name": "Editor", + "shortcuts": [ + { + "description": "Comment/Uncomment lines", + "keys": [{ "key": "ctrl" }, { "key": "/" }] + }, + { + "description": "Remove Line", + "keys": [{ "key": "ctrl" }, { "key": "d" }] + }, + { + "description": "Copy Lines Up", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] + }, + { + "description": "Copy Lines Down", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] + }, + { + "description": "Move Lines Up", + "keys": [{ "key": "alt" }, { "key": "up" }] + }, + { + "description": "Move Lines Down", + "keys": [{ "key": "alt" }, { "key": "down" }] + } + ] + }, + { + "name": "Umbraco", + "shortcuts": [ + { + "description": "Insert Value", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] + }, + { + "description": "Insert Partial View", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] + }, + { + "description": "Insert Dictionary Item", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }] + }, + { + "description": "Insert Macro Item", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }] + }, + { + "description": "Insert Query", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }] + }, + { + "description": "Insert Section", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] + }, + { + "description": "Choose Master Template", + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] + }, + ] + } + ]; + + vm.save = function () { vm.page.saveButtonState = "busy"; @@ -140,6 +230,111 @@ onLoad: function(_editor) { vm.editor = _editor; + //TODO: Move all these keybinding config out into some helper/service + _editor.commands.addCommands([ + //Disable (alt+shift+K) + //Conflicts with our own show shortcuts dialog - this overrides it + { + name: 'unSelectOrFindPrevious', + bindKey: { + win: 'Alt-Shift-K' + }, + exec: function() { + //Toggle the show keyboard shortcuts overlay + $scope.$apply(function(){ + vm.showKeyboardShortcut = !vm.showKeyboardShortcut; + }); + + }, + readOnly: true + }, + { + name: 'insertUmbracoValue', + bindKey: { + win: 'Alt-Shift-V' + }, + exec: function() { + $scope.$apply(function(){ + openPageFieldOverlay(); + }); + }, + readOnly: true + }, + { + name: 'insertPartialView', + bindKey: { + win: 'Alt-Shift-P' + }, + exec: function() { + $scope.$apply(function(){ + openPartialOverlay(); + }); + }, + readOnly: true + }, + { + name: 'insertDictionary', + bindKey: { + win: 'Alt-Shift-D' + }, + exec: function() { + $scope.$apply(function(){ + openDictionaryItemOverlay(); + }); + }, + readOnly: true + }, + { + name: 'insertUmbracoMacro', + bindKey: { + win: 'Alt-Shift-M' + }, + exec: function() { + $scope.$apply(function(){ + openMacroOverlay(); + }); + }, + readOnly: true + }, + { + name: 'insertQuery', + bindKey: { + win: 'Alt-Shift-Q' + }, + exec: function() { + $scope.$apply(function(){ + openQueryBuilderOverlay(); + }); + }, + readOnly: true + }, + { + name: 'insertSection', + bindKey: { + win: 'Alt-Shift-S' + }, + exec: function() { + $scope.$apply(function(){ + openSectionsOverlay(); + }); + }, + readOnly: true + }, + { + name: 'chooseMasterTemplate', + bindKey: { + win: 'Alt-Shift-T' + }, + exec: function() { + $scope.$apply(function(){ + openMasterTemplateOverlay(); + }); + }, + readOnly: true + }, + + ]); + // initial cursor placement // Keep cursor in name field if we are create a new template // else set the cursor at the bottom of the code editor From 8f73514c1dda1917ed645bf9a6221b063e8a703a Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Fri, 20 Jan 2017 21:23:40 +0000 Subject: [PATCH 05/27] An initial start of localising the keyboard shortcut dialog for template editor (Only adding keys into en.xml for now) --- .../src/views/templates/edit.controller.js | 40 +++++++++++++------ src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 9 +++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 165eb95777..49edc49684 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -24,18 +24,18 @@ //TODO: Localise strings vm.page.keyboardShortcutsOverview = [ { - "name": "General", + "name": "General - warren", "shortcuts": [ { - "description": "Undo", + "description": localizationService.localize("buttons_undo"), "keys": [{ "key": "ctrl" }, { "key": "z" }] }, { - "description": "Redo", + "description": localizationService.localize("buttons_redo"), "keys": [{ "key": "ctrl" }, { "key": "y" }] }, { - "description": "Save", + "description": localizationService.localize("buttons_save"), "keys": [{ "key": "ctrl" }, { "key": "s" }] } ] @@ -44,36 +44,36 @@ "name": "Editor", "shortcuts": [ { - "description": "Comment/Uncomment lines", + "description": localizationService.localize("shortcuts_commentLine"), "keys": [{ "key": "ctrl" }, { "key": "/" }] }, { - "description": "Remove Line", + "description": localizationService.localize("shortcuts_removeLine"), "keys": [{ "key": "ctrl" }, { "key": "d" }] }, { - "description": "Copy Lines Up", + "description": localizationService.localize("shortcuts_copyLineUp"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] }, { - "description": "Copy Lines Down", + "description": localizationService.localize("shortcuts_copyLineDown"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] }, { - "description": "Move Lines Up", + "description": localizationService.localize("shortcuts_moveLineUp"), "keys": [{ "key": "alt" }, { "key": "up" }] }, { - "description": "Move Lines Down", + "description": localizationService.localize("shortcuts_moveLineDown"), "keys": [{ "key": "alt" }, { "key": "down" }] } ] }, { - "name": "Umbraco", + "name": "Umbraco", //No need to localise Umbraco is the same in all languages :) "shortcuts": [ { - "description": "Insert Value", + "description": "Insert Value", //Check Per's PR of localisation - can we reuse keys? "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] }, { @@ -230,6 +230,22 @@ onLoad: function(_editor) { vm.editor = _editor; + //Enable simple/basic auto complete + _editor.setOptions({ + enableBasicAutocompletion: true, + enableSnippets: false, //The Razor mode snippets are awful (Need a way to override these) + enableLiveAutocompletion: true + }); + + //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 _editor.commands.addCommands([ //Disable (alt+shift+K) diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 3f317ad407..0eb5d84ab5 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -100,6 +100,8 @@ Show styles Insert table Generate models + Undo + Redo To change the document type for the selected content, first select from the list of valid types for this location. @@ -558,6 +560,13 @@ Toggle list view Toggle allow as root + + Comment/Uncomment lines + Remove line + Copy Lines Up + Copy Lines Down + Move Lines Up + Move Lines Down From 652a7a3655b1fd02603f6815c12e63347f436855 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 22 Jan 2017 19:05:58 +0000 Subject: [PATCH 06/27] Update more translation keys from Per's update to the template editor (Will need to merge in after this) --- .../src/views/templates/edit.controller.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 49edc49684..85fdc067a4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -20,11 +20,10 @@ //From a custom keybinding in ace editor - that conflicts with our own to show the dialog vm.showKeyboardShortcut = false; - //Keyboard shortcuts - //TODO: Localise strings + //Keyboard shortcuts for help dialog vm.page.keyboardShortcutsOverview = [ { - "name": "General - warren", + "name": "General - FooBar", "shortcuts": [ { "description": localizationService.localize("buttons_undo"), @@ -73,31 +72,31 @@ "name": "Umbraco", //No need to localise Umbraco is the same in all languages :) "shortcuts": [ { - "description": "Insert Value", //Check Per's PR of localisation - can we reuse keys? + "description": localizationService.localize("template_insert") + localizationService.localize("template_insertPageField"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] }, { - "description": "Insert Partial View", + "description": localizationService.localize("template_insert") + localizationService.localize("template_insertPartialView"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] }, { - "description": "Insert Dictionary Item", + "description": localizationService.localize("template_insert") + localizationService.localize("template_insertDictionaryItem"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }] }, { - "description": "Insert Macro Item", + "description": localizationService.localize("template_insert") + localizationService.localize("template_insertMacro"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }] }, { - "description": "Insert Query", + "description": localizationService.localize("template_queryBuilder"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }] }, { - "description": "Insert Section", + "description": localizationService.localize("template_insert") + localizationService.localize("template_insertSections"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] }, { - "description": "Choose Master Template", + "description": localizationService.localize("template_mastertemplate"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] }, ] From 23abbdb288b978f28e7ef88beef2a0d3e9a49f02 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 22 Jan 2017 22:12:16 +0000 Subject: [PATCH 07/27] Update Localize Directive (attribute & element) with some specifics in documentation about the format of the string for the key. Localize attribute now supports a key without having to be prefixed with @ --- .../localization/localize.directive.js | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js index 0a69ef5340..8dadf955bf 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js @@ -3,9 +3,15 @@ angular.module("umbraco.directives") /** * @ngdoc directive * @name umbraco.directives.directive:localize - * @restrict EA + * @restrict E * @function - * @description Localize directive + * @description + * Localize a specific token to put into the HTML as an item + * ##Usage + *
+    * Close
+    * Fallback value
+    * 
**/ .directive('localize', function ($log, localizationService) { return { @@ -24,10 +30,27 @@ angular.module("umbraco.directives") }; }) + /** + * @ngdoc directive + * @name umbraco.directives.directive:localize + * @restrict A + * @function + * @description + * Add a HTML attribute to an element containing the HTML attribute name you wish to localise + * Using the format of '@section_key' or 'section_key' + + * ##Usage + *
+    * 
+    * 
+    * 
+ *
+ **/ .directive('localize', function ($log, localizationService) { return { restrict: 'A', link: function (scope, element, attrs) { + //Support one or more attribute properties to update var keys = attrs.localize.split(','); angular.forEach(keys, function(value, key){ @@ -35,13 +58,15 @@ angular.module("umbraco.directives") if(attr){ if(attr[0] === '@'){ - - var t = localizationService.tokenize(attr.substring(1), scope); - localizationService.localize(t.key, t.tokens).then(function(val){ - element.attr(value, val); - }); - + //If the translation key starts with @ then remove it + attr = attr.substring(1); } + + var t = localizationService.tokenize(attr, scope); + + localizationService.localize(t.key, t.tokens).then(function(val){ + element.attr(value, val); + }); } }); } From 883980ab8d1dae6034582a462380b7dcc971e6cf Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 22 Jan 2017 22:16:26 +0000 Subject: [PATCH 08/27] Update localizationService documentation about the usage of %0% tokens being replaced with passed in values --- .../src/common/services/localization.service.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js index 430ed02242..f4c601a07e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js @@ -135,8 +135,13 @@ angular.module('umbraco.services') * * @description * Checks the dictionary for a localized resource string - * @param {String} value the area/key to localize - * @param {Array} tokens if specified this array will be sent as parameter values + * @param {String} value the area/key to localize in the format of 'section_key' + * alternatively if no section is set such as 'key' then we assume the key is to be looked in + * the 'general' section + * + * @param {Array} tokens if specified this array will be sent as parameter values + * This replaces %0% and %1% etc in the dictionary key value with the passed in strings + * * @returns {String} localized resource string */ localize: function (value, tokens) { From fc7cba1da9a9d31921f513fc11868983ef9401e6 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 23 Jan 2017 12:31:18 +0000 Subject: [PATCH 09/27] Add in localizeMany & concat to localizationService as dont like seeing nested promises in our code base to fetch two items to pass to notificationService --- .../common/services/localization.service.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js index f4c601a07e..558356b306 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js @@ -151,6 +151,46 @@ angular.module('umbraco.services') }); }, + localizeMany: function(keys) { + if(keys){ + + //The LocalizationService.localize promises we want to resolve + var promises = []; + + for(var i = 0; i < keys.length; i++){ + promises.push(service.localize(keys[i], undefined)); + } + + return $q.all(promises).then(function(localizedValues){ + return localizedValues; + }); + } + }, + + concat: function(keys) { + if(keys){ + + //The LocalizationService.localize promises we want to resolve + var promises = []; + + for(var i = 0; i < keys.length; i++){ + promises.push(service.localize(keys[i], undefined)); + } + + return $q.all(promises).then(function(localizedValues){ + + //Build a concat string by looping over the array of resolved promises/translations + var returnValue = ""; + + for(var i = 0; i < localizedValues.length; i++){ + returnValue += localizedValues[i]; + } + + return returnValue; + }); + } + } + }; //This happens after login / auth and assets loading From b764a47e7e3206d2e1c3f6b77b36d0f0a48033db Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 23 Jan 2017 20:58:56 +0000 Subject: [PATCH 10/27] Adds in new format function to localizationService simialr to C# String.Format() usign %0% as tokens. Documents the new functions added. --- .../common/services/localization.service.js | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js index 558356b306..8d1d274e85 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js @@ -151,6 +151,30 @@ angular.module('umbraco.services') }); }, + /** + * @ngdoc method + * @name umbraco.services.localizationService#localizeMany + * @methodOf umbraco.services.localizationService + * + * @description + * Checks the dictionary for multipe localized resource strings at once, preventing the need for nested promises + * with localizationService.localize + * + * ##Usage + *
+         * localizationService.localizeMany(["speechBubbles_templateErrorHeader", "speechBubbles_templateErrorText"]).then(function(data){
+         *      var header = data[0];
+         *      var message = data[1];
+         *      notificationService.error(header, message);
+         * });
+         * 
+ * + * @param {Array} keys is an array of strings of the area/key to localize in the format of 'section_key' + * alternatively if no section is set such as 'key' then we assume the key is to be looked in + * the 'general' section + * + * @returns {Array} An array of localized resource string in the same order + */ localizeMany: function(keys) { if(keys){ @@ -167,6 +191,28 @@ angular.module('umbraco.services') } }, + /** + * @ngdoc method + * @name umbraco.services.localizationService#concat + * @methodOf umbraco.services.localizationService + * + * @description + * Checks the dictionary for multipe localized resource strings at once & concats them to a single string + * Which was not possible with localizationSerivce.localize() due to returning a promise + * + * ##Usage + *
+         * localizationService.concat(["speechBubbles_templateErrorHeader", "speechBubbles_templateErrorText"]).then(function(data){
+         *      var combinedText = data;
+         * });
+         * 
+ * + * @param {Array} keys is an array of strings of the area/key to localize in the format of 'section_key' + * alternatively if no section is set such as 'key' then we assume the key is to be looked in + * the 'general' section + * + * @returns {String} An concatenated string of localized resource string passed into the function in the same order + */ concat: function(keys) { if(keys){ @@ -189,6 +235,57 @@ angular.module('umbraco.services') return returnValue; }); } + }, + + /** + * @ngdoc method + * @name umbraco.services.localizationService#format + * @methodOf umbraco.services.localizationService + * + * @description + * Checks the dictionary for multipe localized resource strings at once & formats a tokenized message + * Which was not possible with localizationSerivce.localize() due to returning a promise + * + * ##Usage + *
+         * localizationService.format(["template_insert", "template_insertSections"], "%0% %1%").then(function(data){
+         *      //Will return 'Insert Sections'
+         *      var formattedResult = data;
+         * });
+         * 
+ * + * @param {Array} keys is an array of strings of the area/key to localize in the format of 'section_key' + * alternatively if no section is set such as 'key' then we assume the key is to be looked in + * the 'general' section + * + * @param {String} message is the string you wish to replace containing tokens in the format of %0% and %1% + * with the localized resource strings + * + * @returns {String} An concatenated string of localized resource string passed into the function in the same order + */ + format: function(keys, message){ + if(keys){ + + //The LocalizationService.localize promises we want to resolve + var promises = []; + + for(var i = 0; i < keys.length; i++){ + promises.push(service.localize(keys[i], undefined)); + } + + return $q.all(promises).then(function(localizedValues){ + + //Replace {0} and {1} etc in message with the localized values + for(var i = 0; i < localizedValues.length; i++){ + var token = "%" + i + "%"; + var regex = new RegExp(token, "g"); + + message = message.replace(regex, localizedValues[i]); + } + + return message; + }); + } } }; From 70accfa95a5549d4902fb400a196b1ba1aa13391 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 19:37:33 +0000 Subject: [PATCH 11/27] Uses new localizationService.format function for the shortcuts dialog --- .../src/views/templates/edit.controller.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 85fdc067a4..4043aa4a73 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -23,7 +23,7 @@ //Keyboard shortcuts for help dialog vm.page.keyboardShortcutsOverview = [ { - "name": "General - FooBar", + "name": localizationService.localize("shortcuts_generalHeader"), "shortcuts": [ { "description": localizationService.localize("buttons_undo"), @@ -40,7 +40,7 @@ ] }, { - "name": "Editor", + "name": localizationService.localize("shortcuts_editorHeader"), "shortcuts": [ { "description": localizationService.localize("shortcuts_commentLine"), @@ -72,19 +72,19 @@ "name": "Umbraco", //No need to localise Umbraco is the same in all languages :) "shortcuts": [ { - "description": localizationService.localize("template_insert") + localizationService.localize("template_insertPageField"), + "description": localizationService.format(["template_insert", "template_insertPageField"], "%0% %1%"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] }, { - "description": localizationService.localize("template_insert") + localizationService.localize("template_insertPartialView"), + "description": localizationService.format(["template_insert", "template_insertPartialView"], "%0% %1%"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] }, { - "description": localizationService.localize("template_insert") + localizationService.localize("template_insertDictionaryItem"), + "description": localizationService.format(["template_insert", "template_insertDictionaryItem"], "%0% %1%"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }] }, { - "description": localizationService.localize("template_insert") + localizationService.localize("template_insertMacro"), + "description": localizationService.format(["template_insert", "template_insertMacro"], "%0% %1%"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }] }, { @@ -92,7 +92,7 @@ "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }] }, { - "description": localizationService.localize("template_insert") + localizationService.localize("template_insertSections"), + "description": localizationService.format(["template_insert", "template_insertSections"], "%0% %1%"), "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] }, { From 29b297e072882615c79d24b0843ca7e2b2d5753a Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 19:41:39 +0000 Subject: [PATCH 12/27] Add in UI translation items --- src/Umbraco.Web.UI/umbraco/config/lang/da.xml | 10 ++++++++++ src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 3 +++ src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml index fb032a7f22..b7ba94c243 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml @@ -526,6 +526,16 @@ Brug listevisning Tillad på rodniveau + + Comment/Uncomment lines + Remove line + Copy Lines Up + Copy Lines Down + Move Lines Up + Move Lines Down + + General + Editor diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 0eb5d84ab5..c3aac3a243 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -567,6 +567,9 @@ Copy Lines Down Move Lines Up Move Lines Down + + General + Editor diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index aa9f33695d..7139d0e398 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -553,6 +553,16 @@ Toggle list view Toggle allow as root + + Comment/Uncomment lines + Remove line + Copy Lines Up + Copy Lines Down + Move Lines Up + Move Lines Down + + General + Editor Background color From bcfea6986c2ff31163a83dde9eeea52fc2b436ae Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 19:54:26 +0000 Subject: [PATCH 13/27] Updates the localizationService ugly nested promises to the new localizeMany function --- .../src/views/templates/edit.controller.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 4043aa4a73..1ae009ecc4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -122,10 +122,10 @@ rebindCallback: function (orignal, saved) {} }).then(function (saved) { - localizationService.localize("speechBubbles_templateSavedHeader").then(function (headerValue) { - localizationService.localize("speechBubbles_templateSavedText").then(function(msgValue) { - notificationsService.success(headerValue, msgValue); - }); + localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){ + var header = data[0]; + var message = data[1]; + notificationService.success(header, message); }); @@ -167,10 +167,10 @@ vm.page.saveButtonState = "error"; - localizationService.localize("speechBubbles_validationFailedHeader").then(function (headerValue) { - localizationService.localize("speechBubbles_validationFailedMessage").then(function(msgValue) { - notificationsService.error(headerValue, msgValue); - }); + localizationService.localizeMany(["speechBubbles_validationFailedHeader", "speechBubbles_validationFailedMessage"]).then(function(data){ + var header = data[0]; + var message = data[1]; + notificationService.error(header, message); }); }); From 49bcf413a4b18add4e11cc77ee5a9e3ff21e7735 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 20:45:42 +0000 Subject: [PATCH 14/27] Adds the auto-complete & snippets for the JS/Scripts ACE Editor config --- .../src/views/scripts/edit.controller.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index d2a5fcbc0e..2b1fba5cd5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -108,11 +108,21 @@ theme: "chrome", showPrintMargin: false, advanced: { - fontSize: '14px' + fontSize: '14px', + enableSnippets: true, + enableBasicAutocompletion: true, + enableLiveAutocompletion: false }, 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); // initial cursor placement // Keep cursor in name field if we are create a new script From f9835d3ec5b7cc11e0f6cd0826792a4f73f648fd Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 20:46:36 +0000 Subject: [PATCH 15/27] Move snippets & completion out of onLoad callback out onto config object for the template editor --- .../src/views/templates/edit.controller.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 1ae009ecc4..0b36a86672 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -224,18 +224,14 @@ theme: "chrome", showPrintMargin: false, advanced: { - fontSize: '14px' + fontSize: '14px', + enableSnippets: false, //The Razor mode snippets are awful (Need a way to override these) + enableBasicAutocompletion: true, + enableLiveAutocompletion: false }, onLoad: function(_editor) { vm.editor = _editor; - //Enable simple/basic auto complete - _editor.setOptions({ - enableBasicAutocompletion: true, - enableSnippets: false, //The Razor mode snippets are awful (Need a way to override these) - enableLiveAutocompletion: true - }); - //Update the auto-complete method to use ctrl+alt+space _editor.commands.bindKey("ctrl-alt-space", "startAutocomplete"); From f3242e8d6af0a709c5dc54aad9933cd18684218c Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 20:57:12 +0000 Subject: [PATCH 16/27] Adds in keyboard shortcut dialog & generic keyboard shortcuts (common to all ACE editors) to the JS editor --- .../src/views/scripts/edit.controller.js | 74 +++++++++++++++++++ .../src/views/scripts/edit.html | 28 ++++--- 2 files changed, 92 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index 2b1fba5cd5..178892311a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -14,6 +14,60 @@ vm.page.menu.currentNode = null; vm.page.saveButtonState = "init"; + //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 = [ + { + "name": localizationService.localize("shortcuts_generalHeader"), + "shortcuts": [ + { + "description": localizationService.localize("buttons_undo"), + "keys": [{ "key": "ctrl" }, { "key": "z" }] + }, + { + "description": localizationService.localize("buttons_redo"), + "keys": [{ "key": "ctrl" }, { "key": "y" }] + }, + { + "description": localizationService.localize("buttons_save"), + "keys": [{ "key": "ctrl" }, { "key": "s" }] + } + ] + }, + { + "name": localizationService.localize("shortcuts_editorHeader"), + "shortcuts": [ + { + "description": localizationService.localize("shortcuts_commentLine"), + "keys": [{ "key": "ctrl" }, { "key": "/" }] + }, + { + "description": localizationService.localize("shortcuts_removeLine"), + "keys": [{ "key": "ctrl" }, { "key": "d" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineUp"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineDown"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineUp"), + "keys": [{ "key": "alt" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineDown"), + "keys": [{ "key": "alt" }, { "key": "down" }] + } + ] + } + ]; + vm.script = {}; // bind functions to view model @@ -123,6 +177,26 @@ //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 + _editor.commands.addCommands([ + //Disable (alt+shift+K) + //Conflicts with our own show shortcuts dialog - this overrides it + { + name: 'unSelectOrFindPrevious', + bindKey: { + win: 'Alt-Shift-K' + }, + exec: function() { + //Toggle the show keyboard shortcuts overlay + $scope.$apply(function(){ + vm.showKeyboardShortcut = !vm.showKeyboardShortcut; + }); + + }, + readOnly: true + }, + ]); // initial cursor placement // Keep cursor in name field if we are create a new script diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.html b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.html index 18e5e8525c..4c58356732 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.html @@ -29,19 +29,27 @@ + - + + - - + -
+ + + + + +
From 8f43e9450a419aed8091ad7b746128bac5a1076a Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 29 Jan 2017 21:07:32 +0000 Subject: [PATCH 17/27] Update JS editor to use simplier localizationMany as opposed to nested promises for sucess & error notifications --- .../src/views/scripts/edit.controller.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index 178892311a..cc16105983 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -93,10 +93,10 @@ rebindCallback: function (orignal, saved) {} }).then(function (saved) { - localizationService.localize("speechBubbles_fileSavedHeader").then(function (headerValue) { - localizationService.localize("speechBubbles_fileSavedText").then(function(msgValue) { - notificationsService.success(headerValue, msgValue); - }); + localizationService.localizeMany(["speechBubbles_fileSavedHeader", "speechBubbles_fileSavedText"]).then(function(data){ + var header = data[0]; + var message = data[1]; + notificationService.success(header, message); }); vm.page.saveButtonState = "success"; @@ -114,10 +114,10 @@ vm.page.saveButtonState = "error"; - localizationService.localize("speechBubbles_validationFailedHeader").then(function (headerValue) { - localizationService.localize("speechBubbles_validationFailedMessage").then(function(msgValue) { - notificationsService.error(headerValue, msgValue); - }); + localizationService.localizeMany(["speechBubbles_validationFailedHeader", "speechBubbles_validationFailedMessage"]).then(function(data){ + var header = data[0]; + var message = data[1]; + notificationService.error(header, message); }); }); From b6bc83ba71476e7a0232152b8bc6b09cebe74c9b Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Wed, 22 Feb 2017 11:53:36 +0000 Subject: [PATCH 18/27] Moves the bulky JSON objects for shortcuts to show in the shortcut overviews into helper service so can be reused a bit easier --- .../common/services/templatehelper.service.js | 95 ++++++++++++++++++- .../src/views/scripts/edit.controller.js | 54 +---------- .../src/views/templates/edit.controller.js | 86 +---------------- 3 files changed, 102 insertions(+), 133 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js index 01e544c78d..63eed66917 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js @@ -1,7 +1,7 @@ (function() { 'use strict'; - function templateHelperService() { + function templateHelperService(localizationService) { //crappy hack due to dictionary items not in umbracoNode table function getInsertDictionarySnippet(nodeName) { @@ -36,6 +36,94 @@ return "@section " + sectionName + "\r\n{\r\n\r\n\t{0}\r\n\r\n}\r\n"; } + function getGeneralShortcuts(){ + return { + "name": localizationService.localize("shortcuts_generalHeader"), + "shortcuts": [ + { + "description": localizationService.localize("buttons_undo"), + "keys": [{ "key": "ctrl" }, { "key": "z" }] + }, + { + "description": localizationService.localize("buttons_redo"), + "keys": [{ "key": "ctrl" }, { "key": "y" }] + }, + { + "description": localizationService.localize("buttons_save"), + "keys": [{ "key": "ctrl" }, { "key": "s" }] + } + ] + }; + } + + function getEditorShortcuts(){ + return { + "name": localizationService.localize("shortcuts_editorHeader"), + "shortcuts": [ + { + "description": localizationService.localize("shortcuts_commentLine"), + "keys": [{ "key": "ctrl" }, { "key": "/" }] + }, + { + "description": localizationService.localize("shortcuts_removeLine"), + "keys": [{ "key": "ctrl" }, { "key": "d" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineUp"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineDown"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineUp"), + "keys": [{ "key": "alt" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineDown"), + "keys": [{ "key": "alt" }, { "key": "down" }] + } + ] + }; + } + + function getTemplateEditorShortcuts(){ + 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_insertPartialView"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] + }, + { + "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" }] + }, + { + "description": localizationService.format(["template_insert", "template_insertSections"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] + }, + { + "description": localizationService.localize("template_mastertemplate"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] + } + ] + }; + } + //////////// var service = { @@ -44,7 +132,10 @@ getQuerySnippet: getQuerySnippet, getRenderBodySnippet: getRenderBodySnippet, getRenderSectionSnippet: getRenderSectionSnippet, - getAddSectionSnippet: getAddSectionSnippet + getAddSectionSnippet: getAddSectionSnippet, + getGeneralShortcuts: getGeneralShortcuts, + getEditorShortcuts: getEditorShortcuts, + getTemplateEditorShortcuts: getTemplateEditorShortcuts }; return service; diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index cc16105983..9121b6db88 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService) { + function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService, templateHelper) { var vm = this; var currentPosition = null; @@ -19,54 +19,10 @@ vm.showKeyboardShortcut = false; //Keyboard shortcuts for help dialog - vm.page.keyboardShortcutsOverview = [ - { - "name": localizationService.localize("shortcuts_generalHeader"), - "shortcuts": [ - { - "description": localizationService.localize("buttons_undo"), - "keys": [{ "key": "ctrl" }, { "key": "z" }] - }, - { - "description": localizationService.localize("buttons_redo"), - "keys": [{ "key": "ctrl" }, { "key": "y" }] - }, - { - "description": localizationService.localize("buttons_save"), - "keys": [{ "key": "ctrl" }, { "key": "s" }] - } - ] - }, - { - "name": localizationService.localize("shortcuts_editorHeader"), - "shortcuts": [ - { - "description": localizationService.localize("shortcuts_commentLine"), - "keys": [{ "key": "ctrl" }, { "key": "/" }] - }, - { - "description": localizationService.localize("shortcuts_removeLine"), - "keys": [{ "key": "ctrl" }, { "key": "d" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineUp"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineDown"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineUp"), - "keys": [{ "key": "alt" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineDown"), - "keys": [{ "key": "alt" }, { "key": "down" }] - } - ] - } - ]; + vm.page.keyboardShortcutsOverview = []; + vm.page.keyboardShortcutsOverview.push(templateHelper.getGeneralShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getEditorShortcuts()); + vm.script = {}; diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 0b36a86672..b7d19dd2ec 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -21,88 +21,10 @@ vm.showKeyboardShortcut = false; //Keyboard shortcuts for help dialog - vm.page.keyboardShortcutsOverview = [ - { - "name": localizationService.localize("shortcuts_generalHeader"), - "shortcuts": [ - { - "description": localizationService.localize("buttons_undo"), - "keys": [{ "key": "ctrl" }, { "key": "z" }] - }, - { - "description": localizationService.localize("buttons_redo"), - "keys": [{ "key": "ctrl" }, { "key": "y" }] - }, - { - "description": localizationService.localize("buttons_save"), - "keys": [{ "key": "ctrl" }, { "key": "s" }] - } - ] - }, - { - "name": localizationService.localize("shortcuts_editorHeader"), - "shortcuts": [ - { - "description": localizationService.localize("shortcuts_commentLine"), - "keys": [{ "key": "ctrl" }, { "key": "/" }] - }, - { - "description": localizationService.localize("shortcuts_removeLine"), - "keys": [{ "key": "ctrl" }, { "key": "d" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineUp"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineDown"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineUp"), - "keys": [{ "key": "alt" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineDown"), - "keys": [{ "key": "alt" }, { "key": "down" }] - } - ] - }, - { - "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_insertPartialView"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] - }, - { - "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" }] - }, - { - "description": localizationService.format(["template_insert", "template_insertSections"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] - }, - { - "description": localizationService.localize("template_mastertemplate"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] - }, - ] - } - ]; - + vm.page.keyboardShortcutsOverview = []; + vm.page.keyboardShortcutsOverview.push(templateHelper.getGeneralShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getEditorShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getTemplateEditorShortcuts()); vm.save = function () { From d062b513265eab3e7a040b805a8653849ecdbbc5 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 11:20:08 +0100 Subject: [PATCH 19/27] fix reference to notificationsService --- .../src/views/scripts/edit.controller.js | 4 ++-- .../src/views/templates/edit.controller.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index 9121b6db88..8daf400cc7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -52,7 +52,7 @@ localizationService.localizeMany(["speechBubbles_fileSavedHeader", "speechBubbles_fileSavedText"]).then(function(data){ var header = data[0]; var message = data[1]; - notificationService.success(header, message); + notificationsService.success(header, message); }); vm.page.saveButtonState = "success"; @@ -73,7 +73,7 @@ localizationService.localizeMany(["speechBubbles_validationFailedHeader", "speechBubbles_validationFailedMessage"]).then(function(data){ var header = data[0]; var message = data[1]; - notificationService.error(header, message); + notificationsService.error(header, message); }); }); diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index b7d19dd2ec..2827a6dae7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -47,7 +47,7 @@ localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){ var header = data[0]; var message = data[1]; - notificationService.success(header, message); + notificationsService.success(header, message); }); @@ -92,7 +92,7 @@ localizationService.localizeMany(["speechBubbles_validationFailedHeader", "speechBubbles_validationFailedMessage"]).then(function(data){ var header = data[0]; var message = data[1]; - notificationService.error(header, message); + notificationsService.error(header, message); }); }); From 13cf9f46e71b91a8631362da9c810e8c5aadd53c Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 11:29:52 +0100 Subject: [PATCH 20/27] fix ace shortcut overwrites on mac --- .../src/views/scripts/edit.controller.js | 5 +-- .../src/views/templates/edit.controller.js | 32 +++++-------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index 8daf400cc7..d8c3723d2d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -140,15 +140,12 @@ //Conflicts with our own show shortcuts dialog - this overrides it { name: 'unSelectOrFindPrevious', - bindKey: { - win: 'Alt-Shift-K' - }, + bindKey: 'Alt-Shift-K', exec: function() { //Toggle the show keyboard shortcuts overlay $scope.$apply(function(){ vm.showKeyboardShortcut = !vm.showKeyboardShortcut; }); - }, readOnly: true }, diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 2827a6dae7..d68cf83a36 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -169,9 +169,7 @@ //Conflicts with our own show shortcuts dialog - this overrides it { name: 'unSelectOrFindPrevious', - bindKey: { - win: 'Alt-Shift-K' - }, + bindKey: 'Alt-Shift-K', exec: function() { //Toggle the show keyboard shortcuts overlay $scope.$apply(function(){ @@ -183,9 +181,7 @@ }, { name: 'insertUmbracoValue', - bindKey: { - win: 'Alt-Shift-V' - }, + bindKey: 'Alt-Shift-V', exec: function() { $scope.$apply(function(){ openPageFieldOverlay(); @@ -195,9 +191,7 @@ }, { name: 'insertPartialView', - bindKey: { - win: 'Alt-Shift-P' - }, + bindKey: 'Alt-Shift-P', exec: function() { $scope.$apply(function(){ openPartialOverlay(); @@ -207,9 +201,7 @@ }, { name: 'insertDictionary', - bindKey: { - win: 'Alt-Shift-D' - }, + bindKey: 'Alt-Shift-D', exec: function() { $scope.$apply(function(){ openDictionaryItemOverlay(); @@ -219,9 +211,7 @@ }, { name: 'insertUmbracoMacro', - bindKey: { - win: 'Alt-Shift-M' - }, + bindKey: 'Alt-Shift-M', exec: function() { $scope.$apply(function(){ openMacroOverlay(); @@ -231,9 +221,7 @@ }, { name: 'insertQuery', - bindKey: { - win: 'Alt-Shift-Q' - }, + bindKey: 'Alt-Shift-Q', exec: function() { $scope.$apply(function(){ openQueryBuilderOverlay(); @@ -243,9 +231,7 @@ }, { name: 'insertSection', - bindKey: { - win: 'Alt-Shift-S' - }, + bindKey: 'Alt-Shift-S', exec: function() { $scope.$apply(function(){ openSectionsOverlay(); @@ -255,9 +241,7 @@ }, { name: 'chooseMasterTemplate', - bindKey: { - win: 'Alt-Shift-T' - }, + bindKey: 'Alt-Shift-T', exec: function() { $scope.$apply(function(){ openMasterTemplateOverlay(); From 6c3f1c0e324bb78fc6b9402604a5a709f69fc63f Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 13:04:55 +0100 Subject: [PATCH 21/27] add mac/win versions of keyboard shortcuts --- .../umbkeyboardshortcutsoverview.directive.js | 88 ++++++++++++++----- .../src/common/services/platform.service.js | 23 +++++ .../common/services/templatehelper.service.js | 10 ++- .../umb-keyboard-shortcuts-overview.html | 2 +- 4 files changed, 96 insertions(+), 27 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/common/services/platform.service.js diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js index 703b20daca..1d8f5b0fec 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js @@ -107,36 +107,76 @@ When this combination is hit an overview is opened with shortcuts based on the m @param {object} model keyboard shortcut model. See description and example above. **/ -(function() { - 'use strict'; +(function () { + 'use strict'; - function KeyboardShortcutsOverviewDirective() { + function KeyboardShortcutsOverviewDirective(platformService) { - function link(scope, el, attr, ctrl) { + function link(scope, el, attr, ctrl) { - scope.toggleShortcutsOverlay = function() { - scope.showOverlay = !scope.showOverlay; - scope.onToggle(); - }; + var eventBindings = []; + var isMac = platformService.isMac(); + scope.toggleShortcutsOverlay = function () { + scope.showOverlay = !scope.showOverlay; + scope.onToggle(); + }; + function onInit() { + + angular.forEach(scope.model, function (shortcutGroup) { + angular.forEach(shortcutGroup.shortcuts, function (shortcut) { + + shortcut.platformKeys = []; + + // get shortcut keys for mac + if (isMac && shortcut.keys && shortcut.keys.mac) { + shortcut.platformKeys = shortcut.keys.mac; + // get shortcut keys for windows + } else if (!isMac && shortcut.keys && shortcut.keys.win) { + shortcut.platformKeys = shortcut.keys.win; + // get default shortcut keys + } else if (shortcut.keys && shortcut && shortcut.keys.length > 0) { + shortcut.platformKeys = shortcut.keys; + } + + }); + }); + } + + onInit(); + + eventBindings.push(scope.$watch('model', function(newValue, oldValue){ + if (newValue !== oldValue) { + onInit(); + } + })); + + // clean up + scope.$on('$destroy', function () { + // unbind watchers + for (var e in eventBindings) { + eventBindings[e](); + } + }); + + } + + var directive = { + restrict: 'E', + replace: true, + templateUrl: 'views/components/umb-keyboard-shortcuts-overview.html', + link: link, + scope: { + model: "=", + onToggle: "&", + showOverlay: "=" + } + }; + + return directive; } - var directive = { - restrict: 'E', - replace: true, - templateUrl: 'views/components/umb-keyboard-shortcuts-overview.html', - link: link, - scope: { - model: "=", - onToggle: "&", - showOverlay: "=" - } - }; - - return directive; - } - - angular.module('umbraco.directives').directive('umbKeyboardShortcutsOverview', KeyboardShortcutsOverviewDirective); + angular.module('umbraco.directives').directive('umbKeyboardShortcutsOverview', KeyboardShortcutsOverviewDirective); })(); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js new file mode 100644 index 0000000000..7834c2f781 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js @@ -0,0 +1,23 @@ +(function() { + 'use strict'; + + function platformService() { + + function isMac() { + return navigator.platform.toUpperCase().indexOf('MAC')>=0; + } + + //////////// + + var service = { + isMac: isMac + }; + + return service; + + } + + angular.module('umbraco.services').factory('platformService', platformService); + + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js index 63eed66917..5d00e2d56d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js @@ -70,11 +70,17 @@ }, { "description": localizationService.localize("shortcuts_copyLineUp"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] + "keys": { + "win": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }], + "mac": [{ "key": "cmd" }, { "key": "alt" }, { "key": "up" }] + } }, { "description": localizationService.localize("shortcuts_copyLineDown"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] + "keys": { + "win": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }], + "mac": [{ "key": "cmd" }, { "key": "alt" }, { "key": "down" }] + } }, { "description": localizationService.localize("shortcuts_moveLineUp"), diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html index 33bb4d36be..8b12ee4afd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-keyboard-shortcuts-overview.html @@ -35,7 +35,7 @@
{{ keyboardShortcut.description }}
-
+
{{ key.key }}
From dabeaa26e6caadbf16ceefcdf09672f4b8b54d3c Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 13:14:02 +0100 Subject: [PATCH 22/27] fix documentation --- .../directives/components/localization/localize.directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js index 8dadf955bf..553cf24630 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js @@ -2,7 +2,7 @@ angular.module("umbraco.directives") /** * @ngdoc directive - * @name umbraco.directives.directive:localize + * @name umbraco.directives.directive:localize (Component) * @restrict E * @function * @description @@ -32,7 +32,7 @@ angular.module("umbraco.directives") /** * @ngdoc directive - * @name umbraco.directives.directive:localize + * @name umbraco.directives.directive:localize (Attribute) * @restrict A * @function * @description From b67286f40d62a5feaefeecab6a45baf1f48215c2 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 13:52:56 +0100 Subject: [PATCH 23/27] make showOverlay optional --- .../components/umbkeyboardshortcutsoverview.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js index 1d8f5b0fec..40fe431fb8 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbkeyboardshortcutsoverview.directive.js @@ -170,7 +170,7 @@ When this combination is hit an overview is opened with shortcuts based on the m scope: { model: "=", onToggle: "&", - showOverlay: "=" + showOverlay: "=?" } }; From 5d298e431385022868d1d5b659a86a7aec152d19 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 14:45:08 +0100 Subject: [PATCH 24/27] make sure overlays close after shortcut overlay has been opened --- .../directives/components/overlays/umboverlay.directive.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js index d69c7f6ba0..d728865015 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js @@ -478,8 +478,10 @@ Opens an overlay to show a custom YSOD.
numberOfOverlays = overlayHelper.getNumberOfOverlays(); - if(numberOfOverlays === overlayNumber) { - scope.closeOverLay(); + if (numberOfOverlays === overlayNumber) { + scope.$apply(function () { + scope.closeOverLay(); + }); } event.preventDefault(); From 9a99ad14163d540c768b3b492b46ba73b4018934 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 15:28:40 +0100 Subject: [PATCH 25/27] combine documentation for localize component and attribute directive --- .../localization/localize.directive.js | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js index 553cf24630..3833dc50b9 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/localization/localize.directive.js @@ -2,15 +2,29 @@ angular.module("umbraco.directives") /** * @ngdoc directive - * @name umbraco.directives.directive:localize (Component) - * @restrict E + * @name umbraco.directives.directive:localize + * @restrict EA * @function - * @description - * Localize a specific token to put into the HTML as an item + * @description + *
+ * Component
+ * Localize a specific token to put into the HTML as an item + *
+ *
+ * Attribute
+ * Add a HTML attribute to an element containing the HTML attribute name you wish to localise + * Using the format of '@section_key' or 'section_key' + *
* ##Usage *
+    * 
     * Close
     * Fallback value
+    *
+    * 
+    * 
+    * 
+    * 
*
**/ .directive('localize', function ($log, localizationService) { @@ -30,22 +44,6 @@ angular.module("umbraco.directives") }; }) - /** - * @ngdoc directive - * @name umbraco.directives.directive:localize (Attribute) - * @restrict A - * @function - * @description - * Add a HTML attribute to an element containing the HTML attribute name you wish to localise - * Using the format of '@section_key' or 'section_key' - - * ##Usage - *
-    * 
-    * 
-    * 
- *
- **/ .directive('localize', function ($log, localizationService) { return { restrict: 'A', From 199c5a960665da00ca66d8753a56c463572c7015 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 16:05:31 +0100 Subject: [PATCH 26/27] add keyboard shortcuts to partial view editor --- .../common/services/templatehelper.service.js | 27 ++++++- .../src/views/partialviews/edit.controller.js | 76 +++++++++++++++++++ .../src/views/partialviews/edit.html | 27 ++++--- .../src/views/templates/edit.controller.js | 3 +- 4 files changed, 119 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js index 5d00e2d56d..aefbc5625b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js @@ -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; diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js index a493ed30c1..adcb3dea07 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js @@ -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 diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html index 2c974fcfaa..45ef1d38a4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.html @@ -67,18 +67,23 @@ - + + + + - - - - + + + + diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index d68cf83a36..4305238932 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -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 From 711981adab24eff8da2904f375b8e1f414ed253a Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 2 Mar 2017 16:10:41 +0100 Subject: [PATCH 27/27] remove comment --- .../src/views/partialviews/edit.controller.js | 1 - src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js index adcb3dea07..fcd91071c0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/partialviews/edit.controller.js @@ -288,7 +288,6 @@ //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) diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 4305238932..9edb659d09 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -161,7 +161,6 @@ //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)