Diferencia entre revisiones de «MediaWiki:Gadget-Versalitas.js»

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
Etiqueta: Revertido
 
(No se muestran 18 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
function makeMyTool() {
ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
ve.ui.VersalitasCommand.super.call( this, 'Versalitas' );
};
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );


//Create and register command
ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
var inicio = 'PRUEBA UNO';
var model = surface.getModel(),
doc = model.getDocument(),
range = model.getSelection().getRange(),
docRange = doc.shallowCloneFromRange( range );


ve.ui.commandRegistry.register(
ve.init.target.getWikitextFragment( docRange, false ).done( function ( wikitext ) {
new ve.ui.Command( 'mwWikitext', 'toggleWrapSelection',  
model.getFragment().insertContent([
{ args: [ '<nowiki>', '</nowiki>', nowikiLabel ], supportedSelections: [ 'linear' ] }
{
)
type: 'mwTransclusionInline',
);
attributes: {
mw: {
parts: [{
template: {
target: {
href: 'Template:Versales',
wt: 'Versales'
},
params: {
1: {
wt: wikitext
}
}
}
}]
}
}
} , {
type: '/mwTransclusionInline'
} ] );
} );
};


//Create and register wikitext command
ve.ui.commandRegistry.register( new ve.ui.VersalitasCommand() );
if ( ve.ui.wikitextCommandRegistry ) {
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command( 'mycommand', 'mwWikitext', 'wrapSelection', {
args: [ '{{MyTemplate|', '}}', 'my parameter' ],
supportedSelections: [ 'linear' ]
} )
);
}


//Create and register tool
ve.ui.VersalitasTool = function VeUiVersalitasTool() {
function MyTool() {
ve.ui.VersalitasTool.super.apply( this, arguments );
MyTool.parent.apply( this, arguments );
};
}
OO.inheritClass( ve.ui.VersalitasTool, ve.ui.Tool );
OO.inheritClass( MyTool, ve.ui.MWTransclusionDialogTool );
ve.ui.VersalitasTool.static.name = 'Versalitas';
 
ve.ui.VersalitasTool.static.group = 'textStyle';
MyTool.static.name = 'mytool';
ve.ui.VersalitasTool.static.icon = 'largerText';
MyTool.static.group = 'textStyle';
ve.ui.VersalitasTool.static.title = 'Versalitas';
MyTool.static.title = 'My tool';
ve.ui.VersalitasTool.static.commandName = 'Versalitas';
MyTool.static.commandName = 'mycommand';
ve.ui.toolFactory.register( ve.ui.VersalitasTool );
ve.ui.toolFactory.register( MyTool );
 
}
 
// Initialize
mw.hook( 've.loadModules' ).add( function( addPlugin ) {
addPlugin( makeMyTool );
} );

Revisión actual - 17:48 22 ene 2022

ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
	ve.ui.VersalitasCommand.super.call(	this, 'Versalitas' );
};
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );

ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
	var model = surface.getModel(),
		doc = model.getDocument(),
		range = model.getSelection().getRange(),
		docRange = doc.shallowCloneFromRange( range );

	ve.init.target.getWikitextFragment( docRange, false ).done( function ( wikitext ) {
		model.getFragment().insertContent([
			{
				type: 'mwTransclusionInline',
				attributes: {
					mw: {
						parts: [{
							template: {
								target: {
									href: 'Template:Versales',
									wt: 'Versales'
								},
								params: {
									1: {
										wt: wikitext
									}
								}
							}
						}]
					}
				}
			} , {
				type: '/mwTransclusionInline'
			} ] );
	} );
};

ve.ui.commandRegistry.register( new ve.ui.VersalitasCommand() );

ve.ui.VersalitasTool = function VeUiVersalitasTool() {
	ve.ui.VersalitasTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.VersalitasTool, ve.ui.Tool );
ve.ui.VersalitasTool.static.name = 'Versalitas';
ve.ui.VersalitasTool.static.group = 'textStyle';
ve.ui.VersalitasTool.static.icon = 'largerText';
ve.ui.VersalitasTool.static.title = 'Versalitas';
ve.ui.VersalitasTool.static.commandName = 'Versalitas';
ve.ui.toolFactory.register( ve.ui.VersalitasTool );