MediaWiki:Common.js: Difference between revisions
From Trickster Development Wiki
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
mw.loader.using(['ext.visualEditor.desktopArticleTarget.init'], function () { | 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; | |||
e.preventDefault(); | // 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+ | /*That's to change the shitty Code command to Ctrl+alt+c*/ | ||
Latest revision as of 19:50, 18 April 2026
/* 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*/