User:Ontone/js/veInsertCommentTool.js

/** * Adds 'Insert comment' tool to VisualEditor. * * MediaWiki:Gadgets-definition registration: * * veInsertCommentTool[default|ResourceLoader|dependencies=ext.visualEditor.core]|veInsertCommentTool.js * * Licence: GPLv3+ */ mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init', function {  mw.libs.ve.addPlugin( function  {

/* Localization */ if(!mw.messages.exists('InsertCommentTool-toolname')) { mw.messages.set('InsertCommentTool-toolname', 'Insert comment'); }

InsertCommentTool = function VeUiInsertCommentTool { InsertCommentTool.super.apply( this, arguments ); }; OO.inheritClass( InsertCommentTool, ve.ui.Tool );

InsertCommentTool.static.name = 'insertComment'; InsertCommentTool.static.group = 'insert'; InsertCommentTool.static.autoAddToGroup = false; InsertCommentTool.static.autoAddToCatchall = false; InsertCommentTool.static.icon = 'align-float-left'; InsertCommentTool.static.title = mw.msg('InsertCommentTool-toolname');

InsertCommentTool.static.commandName = 'insertComment'; ve.ui.toolFactory.register( InsertCommentTool );

ve.ui.commandRegistry.register(	new ve.ui.Command( 'insertComment', 'content', 'insert', {			args: [ [					{ type: 'table' }, { type: 'tableSection', attributes: { style: 'body' } }, { type: 'tableRow' }, { type: 'tableCell', attributes: { style: 'data' } }, { type: 'paragraph' }, 'Коментар', { type: '/paragraph' }, { type: '/tableCell' }, { type: '/tableRow' }, { type: 'tableRow' }, { type: 'tableCell', attributes: { style: 'data' } }, { type: 'paragraph' }, { type: 'mwSignature' }, { type: '/mwSignature' }, { type: '/paragraph' }, { type: '/tableCell' }, { type: '/tableRow' }, { type: '/tableSection' }, { type: '/table' }, ],				// Annotate content to match surrounding annotations? false, // Move cursor to after the new content? (otherwise - select it) true ],			supportedSelections: [ 'linear' ] }	) );

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

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

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