Skip to content

Instantly share code, notes, and snippets.

@jkcdarunday
Created October 18, 2018 09:33
Show Gist options
  • Save jkcdarunday/af03d8a9b7b09c5bf8f5bd747549f8fe to your computer and use it in GitHub Desktop.
Save jkcdarunday/af03d8a9b7b09c5bf8f5bd747549f8fe to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Taiga Ctrl+Enter support
// @version 1
// @description Maintained by Keith
// @grant none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://gist.github.com/BrockA/2625891/raw/waitForKeyElements.js
// @include https://tchaikovsky.web.lt/*
// @include http://tchaikovsky.web.lt/*
// ==/UserScript==
// Use function provided by waitForKeyElements to execute function on element creation
waitForKeyElements('tg-wysiwyg', onNewEditor);
function onNewEditor(nodes) {
nodes.each(node => {
const $node = $(node);
const textarea = $node.find('textarea')[0];
const save_button = $node.find('[tg-loading="saving"]')[0];
$(textarea).keypress(event => {
const $textarea = $(event.target);
if ((event.ctrlKey || event.metaKey) && (event.keyCode == 13 || event.keyCode == 10)) {
save_button.click()
}
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment