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

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
 
(No se muestran 14 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
function makeMyTool() {
ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
//Create and register command
ve.ui.VersalitasCommand.super.call( this, 'Versalitas' );
var myTemplate = [ {
};
type: 'mwTransclusionBlock',
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );
attributes: {
 
mw: {
ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
parts: [ {
var model = surface.getModel(),
template: {
doc = model.getDocument(),
target: {
range = model.getSelection().getRange(),
href: 'Template:Versales',
docRange = doc.shallowCloneFromRange( range );
wt: 'MyTemplate'
 
},
ve.init.target.getWikitextFragment( docRange, false ).done( function ( wikitext ) {
params: {
model.getFragment().insertContent([
1: {
{
wt: 'my parameter'
type: 'mwTransclusionInline',
attributes: {
mw: {
parts: [{
template: {
target: {
href: 'Template:Versales',
wt: 'Versales'
},
params: {
1: {
wt: wikitext
}
}
}
}
}
}]
}
}
} ]
}
}
} , {
}
type: '/mwTransclusionInline'
}, {
} ] );
type: '/mwTransclusionBlock'
} );
} ];
};
 
ve.ui.commandRegistry.register(
new ve.ui.Command( 'mycommand', 'content', 'insert', {
args: [ myTemplate, false, true ],
supportedSelections: [ 'linear' ]
} )
);
 
//Create and register wikitext command
if ( ve.ui.wikitextCommandRegistry ) {
ve.ui.wikitextCommandRegistry.register(
new ve.ui.Command( 'mycommand', 'mwWikitext', 'wrapSelection', {
args: [ '{{Versales|', '}}', 'my parameter' ],
supportedSelections: [ 'linear' ]
} )
);
}
 
//Create and register tool
function MyTool() {
MyTool.parent.apply( this, arguments );
}
OO.inheritClass( MyTool, ve.ui.MWTransclusionDialogTool );
 
MyTool.static.name = 'mytool';
MyTool.static.group = 'insert';
MyTool.static.title = 'My tool';
MyTool.static.commandName = 'mycommand';
ve.ui.toolFactory.register( MyTool );


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


// Initialize
ve.ui.VersalitasTool = function VeUiVersalitasTool() {
mw.hook( 've.loadModules' ).add( function( addPlugin ) {
ve.ui.VersalitasTool.super.apply( this, arguments );
addPlugin( makeMyTool );
};
} );
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 );

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 );