MediaWiki:Common.js
From Trickster Development Wiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using([
'ext.visualEditor.core',
'ext.visualEditor.desktopArticleTarget.init'
], function () {
// Wait until VE is actually ready
mw.hook('ve.activationComplete').add(function () {
const target = ve.init.target;
const surface = target.getSurface();
if (!surface) return;
// Register a new command
surface.commandRegistry.register(
new ve.ui.Command(
'customCode',
'annotation',
'toggle',
{ type: 'textStyle/code' }
)
);
// Bind shortcut: Ctrl + Alt + C
surface.getView().getDocument().on('keydown', function (e) {
if (e.ctrlKey && e.altKey && e.key.toLowerCase() === 'c') {
e.preventDefault();
surface.execute('customCode');
}
});
});
});
/*That's to change the shitty Code command to Ctrl+alt+c*/