Showing
2 changed files
with
18 additions
and
1 deletions
| ... | @@ -379,6 +379,15 @@ module.exports = function (ngApp, events) { | ... | @@ -379,6 +379,15 @@ module.exports = function (ngApp, events) { |
| 379 | saveDraft(); | 379 | saveDraft(); |
| 380 | }; | 380 | }; |
| 381 | 381 | ||
| 382 | + // Listen to shortcuts coming via events | ||
| 383 | + $scope.$on('editor-keydown', (event, data) => { | ||
| 384 | + // Save shortcut (ctrl+s) | ||
| 385 | + if (data.keyCode == 83 && (navigator.platform.match("Mac") ? data.metaKey : data.ctrlKey)) { | ||
| 386 | + data.preventDefault(); | ||
| 387 | + saveDraft(); | ||
| 388 | + } | ||
| 389 | + }); | ||
| 390 | + | ||
| 382 | /** | 391 | /** |
| 383 | * Discard the current draft and grab the current page | 392 | * Discard the current draft and grab the current page |
| 384 | * content from the system via an AJAX request. | 393 | * content from the system via an AJAX request. | ... | ... |
| ... | @@ -185,6 +185,10 @@ module.exports = function (ngApp, events) { | ... | @@ -185,6 +185,10 @@ module.exports = function (ngApp, events) { |
| 185 | scope.mceChange(content); | 185 | scope.mceChange(content); |
| 186 | }); | 186 | }); |
| 187 | 187 | ||
| 188 | + editor.on('keydown', (event) => { | ||
| 189 | + scope.$emit('editor-keydown', event); | ||
| 190 | + }); | ||
| 191 | + | ||
| 188 | editor.on('init', (e) => { | 192 | editor.on('init', (e) => { |
| 189 | scope.mceModel = editor.getContent(); | 193 | scope.mceModel = editor.getContent(); |
| 190 | }); | 194 | }); |
| ... | @@ -305,8 +309,9 @@ module.exports = function (ngApp, events) { | ... | @@ -305,8 +309,9 @@ module.exports = function (ngApp, events) { |
| 305 | lastScroll = now; | 309 | lastScroll = now; |
| 306 | }); | 310 | }); |
| 307 | 311 | ||
| 308 | - // Insert image shortcut | 312 | + // Editor key-presses |
| 309 | input.keydown(event => { | 313 | input.keydown(event => { |
| 314 | + // Insert image shortcut | ||
| 310 | if (event.which === 73 && event.ctrlKey && event.shiftKey) { | 315 | if (event.which === 73 && event.ctrlKey && event.shiftKey) { |
| 311 | event.preventDefault(); | 316 | event.preventDefault(); |
| 312 | var caretPos = input[0].selectionStart; | 317 | var caretPos = input[0].selectionStart; |
| ... | @@ -316,7 +321,10 @@ module.exports = function (ngApp, events) { | ... | @@ -316,7 +321,10 @@ module.exports = function (ngApp, events) { |
| 316 | input.focus(); | 321 | input.focus(); |
| 317 | input[0].selectionStart = caretPos + ("; | 322 | input[0].selectionStart = caretPos + ("; |
| 318 | input[0].selectionEnd = caretPos + ('; | 323 | input[0].selectionEnd = caretPos + ('; |
| 324 | + return; | ||
| 319 | } | 325 | } |
| 326 | + // Pass key presses to controller via event | ||
| 327 | + scope.$emit('editor-keydown', event); | ||
| 320 | }); | 328 | }); |
| 321 | 329 | ||
| 322 | // Insert image from image manager | 330 | // Insert image from image manager | ... | ... |
-
Please register or sign in to post a comment