Diferencia entre revisiones de «MediaWiki:Common.js»

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
Línea 12: Línea 12:
// INICIO PRUEBAS
// INICIO PRUEBAS


function makeMyTool() {
function integrateIntoVE() {
//Create and register command
var myTemplate = [ {
type: 'mwTransclusionBlock',
attributes: {
mw: {
parts: [ {
template: {
target: {
href: 'Template:MyTemplate',
wt: 'MyTemplate'
},
params: {
1: {
wt: 'my parameter'
}
}
}
} ]
}
}
}, {
type: '/mwTransclusionBlock'
} ];


ve.ui.commandRegistry.register(
    function Tool1() {
new ve.ui.Command( 'mycommand', 'content', 'insert', {
        Tool1.super.apply( this, arguments );
args: [ myTemplate, false, true ],
    }
supportedSelections: [ 'linear' ]
    OO.inheritClass( Tool1, OO.ui.Tool );
} )
    Tool1.static.name = 'mytool1';
);
    Tool1.static.title = 'Tool 1';
    Tool1.prototype.onUpdateState = function () {};
    Tool1.prototype.onSelect = function () {
        //Implement me
    };


//Create and register wikitext command
    function Tool2() {
if ( ve.ui.wikitextCommandRegistry ) {
        Tool2.super.apply( this, arguments );
ve.ui.wikitextCommandRegistry.register(
    }
new ve.ui.Command( 'mycommand', 'mwWikitext', 'wrapSelection', {
    OO.inheritClass( Tool2, OO.ui.Tool );
args: [ '{{MyTemplate|', '}}', 'my parameter' ],
    Tool2.static.name = 'mytool2';
supportedSelections: [ 'linear' ]
    Tool2.static.title = 'Tool 2';
} )
    Tool2.prototype.onUpdateState = function () {};
);
    Tool2.prototype.onSelect = function () {
}
        //Implement me
 
    };
//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 );


    toolbar = ve.init.target.getToolbar();
    myToolGroup = new OO.ui.ListToolGroup( toolbar, {
        title: 'My tools',
        include: [ 'mytool1', 'mytool2' ]
    } );
    ve.ui.toolFactory.register( Tool1 );
    ve.ui.toolFactory.register( Tool2 );
    toolbar.addItems( [ myToolGroup ] );
}
}


// Initialize
mw.hook( 've.activationComplete' ).add( integrateIntoVE );
mw.hook( 've.loadModules' ).add( function( addPlugin ) {
addPlugin( makeMyTool );
} );

Revisión del 11:57 13 ene 2022

/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */

/* PERSONALIZAR EL EDITOR */
// Anadimos boton para versalitas
ve.ui.wikitextCommandRegistry.register(
	new ve.ui.Command(
		'versal', 'mwWikitext', 'toggleWrapSelection',
		{ args: [ '<span style="font-variant:small-caps">', '</span>', 'Versalitas' ], supportedSelections: [ 'linear' ] }
	)
);

// INICIO PRUEBAS

function integrateIntoVE() {

    function Tool1() {
        Tool1.super.apply( this, arguments );
    }
    OO.inheritClass( Tool1, OO.ui.Tool );
    Tool1.static.name = 'mytool1';
    Tool1.static.title = 'Tool 1';
    Tool1.prototype.onUpdateState = function () {};
    Tool1.prototype.onSelect = function () {
        //Implement me
    };

    function Tool2() {
        Tool2.super.apply( this, arguments );
    }
    OO.inheritClass( Tool2, OO.ui.Tool );
    Tool2.static.name = 'mytool2';
    Tool2.static.title = 'Tool 2';
    Tool2.prototype.onUpdateState = function () {};
    Tool2.prototype.onSelect = function () {
        //Implement me
    };

    toolbar = ve.init.target.getToolbar();
    myToolGroup = new OO.ui.ListToolGroup( toolbar, {
        title: 'My tools',
        include: [ 'mytool1', 'mytool2' ]
    } );
    ve.ui.toolFactory.register( Tool1 );
    ve.ui.toolFactory.register( Tool2 );
    toolbar.addItems( [ myToolGroup ] );
}

mw.hook( 've.activationComplete' ).add( integrateIntoVE );