X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b80184cd93d502ab2b4c0f21c1139842ca946057..refs/pull/154/head:/resources/assets/js/controllers.js diff --git a/resources/assets/js/controllers.js b/resources/assets/js/controllers.js index bec96f319..406fd7e77 100644 --- a/resources/assets/js/controllers.js +++ b/resources/assets/js/controllers.js @@ -379,6 +379,15 @@ module.exports = function (ngApp, events) { saveDraft(); }; + // Listen to shortcuts coming via events + $scope.$on('editor-keydown', (event, data) => { + // Save shortcut (ctrl+s) + if (data.keyCode == 83 && (navigator.platform.match("Mac") ? data.metaKey : data.ctrlKey)) { + data.preventDefault(); + saveDraft(); + } + }); + /** * Discard the current draft and grab the current page * content from the system via an AJAX request. @@ -405,6 +414,13 @@ module.exports = function (ngApp, events) { const pageId = Number($attrs.pageId); $scope.tags = []; + + $scope.sortOptions = { + handle: '.handle', + items: '> tr', + containment: "parent", + axis: "y" + }; /** * Push an empty tag to the end of the scope tags. @@ -415,6 +431,7 @@ module.exports = function (ngApp, events) { value: '' }); } + $scope.addEmptyTag = addEmptyTag; /** * Get all tags for the current book and add into scope. @@ -463,6 +480,9 @@ module.exports = function (ngApp, events) { } }; + /** + * Save the tags to the current page. + */ $scope.saveTags = function() { setTagOrder(); let postData = {tags: $scope.tags}; @@ -473,6 +493,15 @@ module.exports = function (ngApp, events) { }) }; + /** + * Remove a tag from the current list. + * @param tag + */ + $scope.removeTag = function(tag) { + let cIndex = $scope.tags.indexOf(tag); + $scope.tags.splice(cIndex, 1); + }; + }]); };