16

I know the {{...}} markup but it's rather cumbersome.

Is there a shortcut key to set the selected text to monospace in Confluence or is it possible to set up one somehow?

2

1 Answer 1

6

The way I do this is pretty simple, I added a bookmark/shortcut that executes the click on the monospace button like so:

javascript:$('#rte-monospace').click();

If you use Google Chrome, simply right click bookmark bar, choose "Add Page" and add the javascript snippet in the "URL" field, with any "Name".

E.g:

screenshot


You can also add a keyboard shortcut to the function, using tinyMce's interface directly. Again adding a snippet in a bookmark bar is easiest:

javascript:tinyMCE.activeEditor.addShortcut("ctrl+alt+m","monospace","confMonospace");

Clicking the shortcut enables a toggle toggles the shortcut for the current page. Using it by hitting ctrl+alt+m will mark the selected text as monospaced.

This was mentioned in the related JIRA issue as commented by @ andreas-klöber.


For bonus points, get greasemonkey or tampermonkey and paste in your user script, and update the matching urls to always execute on your confluence domain. Here is an example for the official atlassian confluence site:

// ==UserScript==
// @name         Toggle Confluence monospace with ctrl+alt+m
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  add keyboard shortcut to toggle monospace styling for selected text
// @author       Pavel Savshenko
// @match        https://confluence.atlassian.com/pages/editpage.action*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    if (tinyMCE && tinyMCE.activeEditor)  {
        console.log("Monospace patch loading");
        tinyMCE.activeEditor.addShortcut("ctrl+alt+m","monospace","confMonospace");
    }
})();

This again comes from a comment in the JIRA issue mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.