User:Bottersnike237/Satomi.js

function encapsulate(templ) { var m = ve.init.target.getSurface.getModel;

var selection = m.getSelection; var selRange = new ve.Range(selection.getRange.from, selection.getRange.to); var val = m.getLinearFragment(selRange).getText;

m.getLinearFragment(selRange).insertContent(		[{type: 'mwTransclusionInline', attributes: {mw: {			parts: [{				template: {					target: {wt: templ},					params: {1:{wt:val}}				}			}]		}}}]	); }

function registerCommands(commands) { for (var i=0; i<commands.length; i++) { let name1 = 'DoSatomi' + i,			name2 = 'doSatomi' + i,			name3 = 'VeUiDoSatomi' + i + 'Tool', name4 = 'DoSatomi' + i + 'Tool', cmd = commands[i]; ve.ui[name1] = function { ve.ui[name1].super.call(this, name2); };		OO.inheritClass(ve.ui[name1], ve.ui.Command); ve.ui[name1].prototype.execute = function { encapsulate(cmd.templ); return true; };		ve.ui.commandRegistry.register( new ve.ui[name1] ); ve.ui[name4] = function VeUiDoSatomiTool { ve.ui[name4].super.apply(this, arguments); };		OO.inheritClass(ve.ui[name4], ve.ui.Tool); ve.ui[name4].static.name = name2; ve.ui[name4].static.group = 'insert'; ve.ui[name4].static.title = ""; ve.ui[name4].static.commandName = name2; ve.ui.toolFactory.register(ve.ui[name4]); if (cmd.keys) ve.ui.triggerRegistry.register(name2, {			mac: new ve.ui.Trigger(cmd.keys.replace(/ctrl/g, 'cmd')),			pc: new ve.ui.Trigger(cmd.keys.replace(/cmd/g, 'ctrl')),		}); } }

registerCommands([	{		templ: "R",		keys: 'cmd+shift+[',	}, {		templ: "Rt"	} ]);