UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

2 lines (1 loc) 1.1 kB
"use strict";var u=Object.defineProperty;var y=(t,e,s)=>e in t?u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var a=(t,e,s)=>y(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d{constructor(){a(this,"plugins",new Map)}register(e){if(this.plugins.has(e.name))throw new Error(`Plugin ${e.name} is already registered`);this.plugins.set(e.name,e)}unregister(e){const s=this.plugins.get(e);s!=null&&s.destroy&&s.destroy(),this.plugins.delete(e)}getPlugins(){return this.plugins}getHotkeys(){const e={},s={};return this.plugins.forEach((l,r)=>{const o=r.charAt(0).toUpperCase()+r.slice(1)+" Plugin",c=l.hotkeys??[];for(const g in c){const i=c[g],n=i.keys;s[n]?console.warn(`Hotkey conflict: The key combination "${n}" is already used for the command "${s[n]}".`):s[n]=i.command,e[o]||(e[o]=[]),e[o].push({command:i.command,description:i.description,icon:i.icon,keys:i.keys})}}),e}getPlugin(e){return this.plugins.get(e)}destroy(){for(const[e,s]of this.plugins)s.destroy&&s.destroy();this.plugins.clear()}}exports.DefaultPluginManager=d;