Diferencia entre revisiones de «MediaWiki:Gadget-Versalitas.js»
De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
Etiqueta: Deshacer  | 
				|||
| (No se muestran 17 ediciones intermedias del mismo usuario) | |||
| Línea 1: | Línea 1: | ||
(function () {  | 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 = [  | ||
	var   | 		{  | ||
			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 );  | |||
Revisión actual - 18: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 );