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

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
Etiqueta: Reversión manual
 
(No se muestran 16 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
function makeUnlinkYearsTool() {
ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
// Function to modify wikitext
ve.ui.VersalitasCommand.super.call( this, 'Versalitas' );
function unlinkYears( wikitext ) {
};
return wikitext.replace( /\[\[(\d+)\]\]/g, '$1' )
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );
.replace( /\[\[\d+\|(.*?)\]\]/g, '$1' );
}


// Create and register command
ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
function UnlinkYearsCommand() {
var model = surface.getModel(),
UnlinkYearsCommand.parent.call( this, 'unlinkYears' );
doc = model.getDocument(),
}
range = model.getSelection().getRange(),
OO.inheritClass( UnlinkYearsCommand, ve.ui.Command );
docRange = doc.shallowCloneFromRange( range );


UnlinkYearsCommand.prototype.execute = function ( surface ) {
ve.init.target.getWikitextFragment( docRange, false ).done( function ( wikitext ) {
var surfaceModel, fragment, wikitext, data = [], onCompleteText;
model.getFragment().insertContent([
// Get fragment to work on
{
surfaceModel = surface.getModel();
type: 'mwTransclusionInline',
fragment = surfaceModel.getFragment();
attributes: {
if ( fragment.getSelection().isCollapsed() ) {
mw: {
surfaceModel.setLinearSelection(
parts: [{
new ve.Range( 0, surfaceModel.getDocument().data.getLength() )
template: {
);
target: {
fragment = surfaceModel.getFragment();
href: 'Template:Versales',
onCompleteText = true;
wt: 'Versales'
}
},
// Visual mode
params: {
if ( ve.init.target.getSurface().getMode() !== 'source' ) {
1: {
fragment.annotateContent(
wt: wikitext
'clear',
}
fragment.getAnnotations( true ).filter( function ( annotation ) {
}
return annotation.getType() === 'link/mwInternal' &&
}
/^\d+$/.test( annotation.getAttribute( 'normalizedTitle' ) );
}]
} )
}
);
}
return true;
} , {
}
type: '/mwTransclusionInline'
// Source mode
} ] );
wikitext = fragment.getText( true ).replace( /^\n/, '' ).replace( /\n\n/g, '\n' );
} );
wikitext = unlinkYears( wikitext );
};
wikitext.split( '' ).forEach( function ( c ) {
if ( c === '\n' ) {
data.push( { type: '/paragraph' } );
data.push( { type: 'paragraph' } );
} else {
data.push( c );
}
} );
if ( onCompleteText ) {
fragment.insertContent( wikitext );
} else {
fragment.insertContent( data );
}
if ( onCompleteText ) {
fragment.collapseToStart().select();
}
return true;
};
 
ve.ui.commandRegistry.register( new UnlinkYearsCommand() );
 
// Create, register and insert tool
function UnlinkYearsTool() {
UnlinkYearsTool.parent.apply( this, arguments );
}
OO.inheritClass( UnlinkYearsTool, ve.ui.Tool );


UnlinkYearsTool.static.name = 'unlinkYears';
ve.ui.commandRegistry.register( new ve.ui.VersalitasCommand() );
UnlinkYearsTool.static.group = 'utility';
UnlinkYearsTool.static.title = 'Unlink years';
UnlinkYearsTool.static.icon = 'noWikiText';
UnlinkYearsTool.static.commandName = 'unlinkYears';
UnlinkYearsTool.static.autoAddToCatchall = false;
UnlinkYearsTool.static.deactivateOnSelect = false;


UnlinkYearsTool.prototype.onUpdateState = function () {
ve.ui.VersalitasTool = function VeUiVersalitasTool() {
UnlinkYearsTool.parent.prototype.onUpdateState.apply( this, arguments );
ve.ui.VersalitasTool.super.apply( this, arguments );
this.setActive( false );
};
};
OO.inheritClass( ve.ui.VersalitasTool, ve.ui.Tool );
 
ve.ui.VersalitasTool.static.name = 'Versalitas';
ve.ui.toolFactory.register( UnlinkYearsTool );
ve.ui.VersalitasTool.static.group = 'textStyle';
 
ve.ui.VersalitasTool.static.icon = 'largerText';
ve.init.mw.DesktopArticleTarget.static.actionGroups[ 1 ].include.push( 'unlinkYears' );
ve.ui.VersalitasTool.static.title = 'Versalitas';
}
ve.ui.VersalitasTool.static.commandName = 'Versalitas';
 
ve.ui.toolFactory.register( ve.ui.VersalitasTool );
// Initialize
mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).then( function () {
mw.libs.ve.addPlugin( function () {
return mw.loader.using( [ 'ext.visualEditor.core' ] )
.then( function () {
makeUnlinkYearsTool();
} );
} );
} );

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