Last active
May 1, 2025 13:32
-
-
Save SMUsamaShah/d28d5833888ecace34e98e25e1b96da5 to your computer and use it in GitHub Desktop.
Confluence Monospace Keyboard Shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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(); | |
})(); |
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
Source: https://jira.atlassian.com/browse/CONFSERVER-23966?focusedId=1669095&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-1669095
https://stackoverflow.com/questions/58877097/add-a-custom-key-shortcut-within-javascript-in-confluence