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?
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.