Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do you disable the autocomplete macros collectively, in "The Editor"?

Coline Macorol October 30, 2017

I'm trying to reduce users reliance on macros, per customer request. I need them to use macros only through the "+" button on the editor toolbar. 

So far, the following jQuery code has not worked, and I've followed all of Confluence tutorials on their Developers' guide.

AJS.toInit(function(){
AJS.$("#d").keypress(function (e) {

var charTyped = String.fromCharCode(e.which);
if (charTyped == "{" || charTyped == "!") {

e.preventDefault();

var sel = window.getSelection();
if (sel.rangeCount > 0) {

var range = sel.getRangeAt(0);
range.deleteContents();


var text = (charTyped == ")") ? "{}" : "()";
var textNode = document.createTextNode(text);
range.insertNode(textNode);


range.setStart(textNode, 1);
range.setEnd(textNode, 1);
sel.removeAllRanges();
sel.addRange(range);
}
}


});
});

It works on JSbin, yet there is no result on Confluence. Is there a file that overrides this type of attempts that are trying to affect the autocomplete functionality?

Is there a way I can modify a local js file to disable this functionality for all users? 

1 answer

0 votes
AnnWorley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2017

We don't recommend altering the behavior of the editor using JQuery. It could lead to unpredictable behavior in the editor.

Each user's profile has an autocomplete setting that can be disabled: Enabling and disabling autocomplete. I tested and when I disabled that setting the macro menu did not come up when I typed { into the editor.

Coline Macorol October 31, 2017

You are right @AnnWorley, disabling the autocomplete setting works, yet you have to flip this switch, on each user's account manually. This is not efficient from an Admin perspective.

Likewise, the "@", "//", and other keyboard shortcuts are disabled when you turn the autocomplete setting off. We only need to disable the "{" and "!" keyboard shortcuts collectively for all of our Confluence users.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events