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 kB
JavaScript
;var i=Object.defineProperty;var m=(s,e,t)=>e in s?i(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var n=(s,e,t)=>m(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class p{constructor(){n(this,"storageKey","html-editor-templates")}getTemplates(){const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):[]}saveTemplate(e){const t=this.getTemplates(),a={id:crypto.randomUUID(),name:e.name,content:e.content,createdAt:Date.now(),updatedAt:Date.now()};return t.push(a),localStorage.setItem(this.storageKey,JSON.stringify(t)),a}updateTemplate(e,t){const a=this.getTemplates(),o=a.findIndex(l=>l.id===e);if(o===-1)throw new Error("Template not found");const r={...a[o],...t,updatedAt:Date.now()};return a[o]=r,localStorage.setItem(this.storageKey,JSON.stringify(a)),r}deleteTemplate(e){const t=this.getTemplates().filter(a=>a.id!==e);localStorage.setItem(this.storageKey,JSON.stringify(t))}}exports.TemplateManager=p;