Skip to content

Instantly share code, notes, and snippets.

@SMUsamaShah
Last active May 1, 2025 13:32
Show Gist options
  • Save SMUsamaShah/d28d5833888ecace34e98e25e1b96da5 to your computer and use it in GitHub Desktop.
Save SMUsamaShah/d28d5833888ecace34e98e25e1b96da5 to your computer and use it in GitHub Desktop.
Confluence Monospace Keyboard Shortcut
// ==UserScript==
// @name Monospace Keyboard Shortcut for Confluence
// @version 0.8
// @grant none
// @include */editpage.action?*
// @include */createpage.action?*
// @include */resumedraft.action?*
// @run-at document-idle
// @description Adds keyboard shortcuts for formatting, Ctrl+Alt+m - monospace, Ctrl+Alt+j - superscript, Ctrl+Alt+k - subscript
// ==/UserScript==
(function() {
'use strict';
const waitForEditor = function () {
if (!AJS.Rte.getEditor()) {
setTimeout(waitForEditor, 500);
return;
}
let editor = AJS.Rte.getEditor();
//if (!editor) {
// if (tinyMCE) {
// editor = tinyMCE.activeEditor;
// }
//}
if (editor) {
console.log("Monospace shorcut loading");
editor.addShortcut("ctrl+k","monospace","confMonospace");
editor.addShortcut("ctrl+alt+j","superscript","Superscript");
editor.addShortcut("ctrl+alt+n","subscript","Subscript");
}
}
waitForEditor();
})();
@SMUsamaShah
Copy link
Author

tinyMCE.activeEditor.addShortcut("ctrl+k","monospace",()=>tinyMCE.activeEditor.formatter.toggle('code'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment