User:Bottersnike237/Satomi.js

function encapsulate(before, after) { 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(before + val + after); m.getLinearFragment(new ve.Range(selRange.start + before.length, selRange.end + before.length)).select; }

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.before, cmd.after); 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 = cmd.before + "..." + cmd.after; 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([	{		before: "",		keys: 'cmd+shift+[',	}, {		before: ""	} ]);