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

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
(Se ha deshecho la revisión 679 de Juancc (disc.))
Etiqueta: Deshacer
 
(No se muestran 18 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: {
fragment = model.getFragment(),
target: {
doc = model.getDocument(),
href: 'Template:Versales',
range = fragment.getSelection().getRange();
wt: 'MyTemplate'
 
},
// Obtener el contenido seleccionado
params: {
var selectedContent = doc.getData( range );
1: {
wt: 'my parameter'
// Crear el contenido para {{versal}}
}
var versalStart = [
{
type: 'mwTransclusionInline',
attributes: {
mw: {
parts: [{
template: {
target: {
href: 'Template:Versal',
wt: 'versal'
},
params: {}
}
}
}
}]
} ]
}
}
}
},
{
type: '/mwTransclusionInline'
}
}
}, {
];
type: '/mwTransclusionBlock'
} ];


ve.ui.commandRegistry.register(
// Crear el contenido para {{fin}}
new ve.ui.Command( 'mycommand', 'content', 'insert', {
var versalEnd = [
args: [ myTemplate, false, true ],
{
supportedSelections: [ 'linear' ]
type: 'mwTransclusionInline',
} )
attributes: {
);
mw: {
 
parts: [{
//Create and register wikitext command
template: {
if ( ve.ui.wikitextCommandRegistry ) {
target: {
ve.ui.wikitextCommandRegistry.register(
href: 'Template:Fin',
new ve.ui.Command( 'mycommand', 'mwWikitext', 'wrapSelection', {
wt: 'fin'
args: [ '{{Versales|', '}}', 'my parameter' ],
},
supportedSelections: [ 'linear' ]
params: {}
} )
}
);
}]
}
}
}
},
{
type: '/mwTransclusionInline'
}
];


//Create and register tool
// Combinar todo: {{versal}} + contenido seleccionado + {{fin}}
function MyTool() {
var newContent = versalStart.concat( selectedContent ).concat( versalEnd );
MyTool.parent.apply( this, arguments );
}
OO.inheritClass( MyTool, ve.ui.MWTransclusionDialogTool );


MyTool.static.name = 'mytool';
// Reemplazar el contenido seleccionado
MyTool.static.group = 'insert';
fragment.insertContent( newContent );
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 - 19:29 29 jun 2025

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(),
		fragment = model.getFragment(),
		doc = model.getDocument(),
		range = fragment.getSelection().getRange();

	// Obtener el contenido seleccionado
	var selectedContent = doc.getData( range );
	
	// Crear el contenido para {{versal}}
	var versalStart = [
		{
			type: 'mwTransclusionInline',
			attributes: {
				mw: {
					parts: [{
						template: {
							target: {
								href: 'Template:Versal',
								wt: 'versal'
							},
							params: {}
						}
					}]
				}
			}
		},
		{
			type: '/mwTransclusionInline'
		}
	];

	// Crear el contenido para {{fin}}
	var versalEnd = [
		{
			type: 'mwTransclusionInline',
			attributes: {
				mw: {
					parts: [{
						template: {
							target: {
								href: 'Template:Fin',
								wt: 'fin'
							},
							params: {}
						}
					}]
				}
			}
		},
		{
			type: '/mwTransclusionInline'
		}
	];

	// Combinar todo: {{versal}} + contenido seleccionado + {{fin}}
	var newContent = versalStart.concat( selectedContent ).concat( versalEnd );

	// Reemplazar el contenido seleccionado
	fragment.insertContent( newContent );
};

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