Thread:Project:Support desk/edittools, charinsert and common.js

I've modified my /common.js to have a little toolbar of special characters at the top of my edit boxes. I would like to further add a charinsert facility, so that if I click on it while text is selected it wraps additional characters around said text, just like edittools does with, for instance, wiki markup. Can it be done? Here is my current common.js code: var api_liste_fr = ["ɑ","ɑ̃","ə","ɛ","œ","ø","ɛ̃","ɔ","ɔ̃","œ̃","ʃ","ɡ","ɥ","ʒ","ɲ","ŋ","ʁ","‿","ː","ˈ","ˌ"] ; var caracteres_liste_fr = ["’","æ","Æ","€","ñ","œ","Œ","ſ","–","—","…","","",""] ; var barre_caract_perso = function { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {		'sections': {			'caracteres': {				label:'Mes outils',				type:'booklet', //				deferLoad:true,				pages: {					'API_fr': {						'label':'API français',						'layout':'characters',						'characters': api_liste_fr					},					'car_fr': {						'label':'Caractères spéciaux',						'layout':'characters',						'characters': caracteres_liste_fr					}				}			}		}	} ); }; if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { mw.loader.using( 'user.options', function {                if ( mw.user.options.get('usebetatoolbar') ) {                        mw.loader.using( 'ext.wikiEditor.toolbar', function  { $(document).ready( barre_caract_perso ); } );               }        } ); }