Hello. I am trying to add a button to Visual Editor, to apply smallcaps template to selected text. So far, I have been able to create the button, following the example at VisualEditor/Gadgets/Add a tool. Now I can insert some fixed text in smallcaps, with this code:
var myTemplate = [ {
type: 'mwTransclusionBlock',
attributes: {
mw: {
parts: [ {
template: {
target: {
href: 'Template:Smallcaps',
wt: 'Smallcaps'
},
params: {
1: {
wt: 'my parameter'
}
}
}
} ]
}
}
}, {
type: '/mwTransclusionBlock'
} ];
And then assigning it to a toolbar button, as described in VisualEditor/Gadgets/Add a tool. Now, the next step is replacing the fixed text 'my parameter', with the selected text from the editor.
I have very little knowledge of Javascript, maybe this is a trivial issue but I don't know how to deal with it. Any help is much appreciated.