Repository: zeppelin Updated Branches: refs/heads/master 7db9ab472 -> 6f8b29f5f
[ZEPPELIN-3062] Removes ctrl+s default behavior from notebook ### What is this PR for? As a programmer I habitually press CTRL + S out of fear for my sanity. Other web text editing tools (google docs, jupyter notebooks) ignore the base functionality of CTRL + S of saving the HTML page, and do nothing instead. This is a small change that will makes the user experience of Zeppelin notebooks much much better. ### What type of PR is it? Improvement ### Todos ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-3062 ### How should this be tested? * I tested manually: 1. Ran `yarn run dev` 2. Went to `localhost:9000` 3. Created a new note, now anytime a user presses 'CTRL+S' in the scope of the note nothing happens, and the user can continue coding uninterrupted. ### Screenshots (if appropriate) ### Questions: Author: Tess <[email protected]> Closes #2677 from tessbianchi/ZEPPELIN-3062 and squashes the following commits: db80533 [Tess] Removes ctrl+s default behavior from notebook Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/6f8b29f5 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/6f8b29f5 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/6f8b29f5 Branch: refs/heads/master Commit: 6f8b29f5f53d0ea871e618365367587d2377a793 Parents: 7db9ab4 Author: Tess <[email protected]> Authored: Tue Oct 31 20:48:45 2017 -0400 Committer: Lee moon soo <[email protected]> Committed: Thu Nov 23 09:16:24 2017 -0800 ---------------------------------------------------------------------- zeppelin-web/src/app/notebook/notebook.controller.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6f8b29f5/zeppelin-web/src/app/notebook/notebook.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index d09a0b2..48fc6e7 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -173,15 +173,23 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, // register mouseevent handler for focus paragraph document.addEventListener('click', $scope.focusParagraphOnClick) - $scope.keyboardShortcut = function (keyEvent) { + let keyboardShortcut = function (keyEvent) { // handle keyevent if (!$scope.viewOnly && !$scope.revisionView) { $scope.$broadcast('keyEvent', keyEvent) } } + $scope.keydownEvent = function (keyEvent) { + if ((keyEvent.ctrlKey || keyEvent.metaKey) && String.fromCharCode(keyEvent.which).toLowerCase() === 's') { + keyEvent.preventDefault() + } + + keyboardShortcut(keyEvent) + } + // register mouseevent handler for focus paragraph - document.addEventListener('keydown', $scope.keyboardShortcut) + document.addEventListener('keydown', $scope.keydownEvent) $scope.paragraphOnDoubleClick = function (paragraphId) { $scope.$broadcast('doubleClickParagraph', paragraphId)
