Jump to content

User:Matma Rex/nwe-nowiki.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
mw.loader.using( 'ext.visualEditor.targetLoader', function () {
	mw.libs.ve.targetLoader.addPlugin( function () {
		if ( !ve.ui.wikitextCommandRegistry ) {
			// If VE wikitext mode is not available, this will not exist
			return;
		}

		var nowikiLabel = 'Disable markup';

		ve.ui.wikitextCommandRegistry.register(
			new ve.ui.Command(
				'nowiki', 'mwWikitext', 'toggleWrapSelection',
				{ args: [ '<nowiki>', '</nowiki>', nowikiLabel ], supportedSelections: [ 'linear' ] }
			)
		);

		ve.ui.NowikiTool = function () {
			ve.ui.NowikiTool.super.apply( this, arguments );
		};
		OO.inheritClass( ve.ui.NowikiTool, ve.ui.Tool );
		ve.ui.NowikiTool.static.name = 'nowiki';
		ve.ui.NowikiTool.static.group = 'textStyle';
		ve.ui.NowikiTool.static.icon = 'noWikiText';
		ve.ui.NowikiTool.static.title = nowikiLabel;
		ve.ui.NowikiTool.static.commandName = 'nowiki';
		ve.ui.toolFactory.register( ve.ui.NowikiTool );
	} );
} );