Skip to content

Commit

Permalink
Merge pull request #14467 from jdalsem/ctrl-enter
Browse files Browse the repository at this point in the history
feat(ckeditor): ctrl+enter in the editor field will submit the form
  • Loading branch information
jdalsem committed Sep 28, 2023
2 parents 0e9d8af + 5b0bd6a commit a326f76
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mod/ckeditor/views/default/ckeditor/editor.js
Expand Up @@ -44,6 +44,15 @@ define(['jquery', 'elgg', 'elgg/hooks', 'ckeditor/ckeditor'], function ($, elgg,
$(editor.sourceElement).trigger('change');
});

editor.keystrokes.set('Ctrl+Enter', (event, cancel ) => {
$submit_button = $(editor.sourceElement).closest('form').find('button[type="submit"]').eq(0);
if ($submit_button.length) {
$submit_button.trigger('click');
}

cancel();
});

$(window).on('beforeunload.ckeditor', function(event) {
if ($(editor.sourceElement).data('dirty') && $(editor.sourceElement).closest('form').is(':visible')) {
return true;
Expand Down

0 comments on commit a326f76

Please sign in to comment.