User:Ontone/js/veTextHighlight.js

/** * Adds 'Highlight' style to text styles menu in VisualEditor. * The code below makes use of existing VE's HighlightAnnotation classes and * thus is of limited educational value. * * Uncomment the two code blocks to add 'Highlight' tool as a separate button * on the main toolbar (rather than in 'Text styles' menu). * * MediaWiki:Gadgets-definition registration: * * veTextHighlight[default|ResourceLoader|dependencies=ext.visualEditor.core]|veTextHighlight.js * * Licence: GPLv3+ */

mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init', function {  mw.libs.ve.addPlugin( function  {

/* Localization */ if(!mw.messages.exists('HighlightAnnotationTool-toolname')) { mw.messages.set('HighlightAnnotationTool-toolname', 'Highlight'); }

HighlightAnnotationTool = function VeUiHighlightAnnotationTool( toolGroup, config ) { ve.ui.AnnotationTool.call( this, toolGroup, config ); };

OO.inheritClass( HighlightAnnotationTool, ve.ui.AnnotationTool );

HighlightAnnotationTool.static.name = 'highlight'; HighlightAnnotationTool.static.group = 'textStyle'; /* HighlightAnnotationTool.static.autoAddToGroup = false; HighlightAnnotationTool.static.autoAddToCatchall = false; HighlightAnnotationTool.static.icon = 'highlight'; HighlightAnnotationTool.static.title = mw.msg('HighlightAnnotationTool-toolname'); HighlightAnnotationTool.static.annotation = { name: 'textStyle/highlight' }; HighlightAnnotationTool.static.commandName = 'highlight'; ve.ui.toolFactory.register( HighlightAnnotationTool );

ve.ui.commandRegistry.register( new ve.ui.Command ( 'highlight', 'annotation', 'toggle', { args: ['textStyle/highlight'], supportedSelections: ['linear', 'table'] } ) );

ve.ui.triggerRegistry.register( 'highlight', {    mac: new ve.ui.Trigger( 'cmd+shift+4' ),    pc: new ve.ui.Trigger( 'ctrl+shift+4' )  } );

/* ve.init.mw.Target.static.toolbarGroups.push ( {   include: [ 'highlight' ] } );

} ); // mw.libs.ve.addPlugin }); // mw.loader.using