1 回答

TA貢獻1874條經驗 獲得超12個贊
成立。
//Set CTRL+SHIFT+L shortcut for monospace formatting in the editor
window.AJS.Rte.getEditor().shortcuts.add("ctrl+shift+l","monospace","confMonospace");
PS感謝您的帖子:
https://webapps.stackexchange.com/questions/35383/shortcut-key-for-monospaced-character-format-in-confluence(過時,但有助于理解如何傳遞參數)
https://searchcode.com/codesearch/view/37330905/ #47,看看快捷鍵列表Confluence.KeyboardShortcuts
PPS 瀏覽器就緒 Javascript 代碼(在 Atlassian Confluence 6.15.2 中測試)
簡單??:
// Set monospace formatting for a key shortcut in confluence
// Use a browser extension for injecting this code snippet
(function () {
window.AJS.Rte.getEditor().shortcuts.add(
'ctrl+shift+l',
"monospace",
"confMonospace"
);
}());
過度保護?? :
// Set monospace formatting for a key shortcut in confluence
// Use a browser extension for injecting this code snippet
console.log('include CJS');
let confKeyAdd = {
run: function () {
this.key = {
keyCode: 'ctrl+shift+l',
codeType: 'monospace',
codeConfType: 'confMonospace'
};
this.setKey();
},
waiter: function (shouldWaitCall, successCall, repeat = 10, interval = 1000) {
let timerId;
//wait here
timerId = setInterval(
function () {
if (--repeat < 0) {
console.log('confKeyAdd: Have not found an object.');
clearTimeout(timerId);
return;
}
if (shouldWaitCall()) {
console.log('confKeyAdd: Still waiting... [' + repeat + ']');
return;
}
clearTimeout(timerId);
// call me!
successCall();
},
interval
);
},
setKey() {
let _this = this;
// first call: should-wait
// second call: success
this.waiter(
function () {
console.log('confKeyAdd: Checking...');
return typeof window.AJS === 'undefined'
|| window.AJS.Rte.getEditor() === null
|| !window.AJS.Rte.getEditor().shortcuts;
},
function () {
console.log('confKeyAdd: Adding a key shortcut for: ' + _this.key.keyCode);
window.AJS.Rte.getEditor().shortcuts.add(
_this.key.keyCode,
_this.key.codeType,
_this.key.codeConfType
);
},
);
}
};
confKeyAdd.run();
添加回答
舉報