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

3 lines (2 loc) 3.3 kB
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */ "use strict";var i=Object.defineProperty;var c=(o,e,a)=>e in o?i(o,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[e]=a;var n=(o,e,a)=>c(o,typeof e!="symbol"?e+"":e,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l{constructor(){n(this,"categoriesKey","html-editor-calendar-categories");n(this,"tagsKey","html-editor-calendar-tags")}getCategories(){const e=localStorage.getItem(this.categoriesKey);return e?JSON.parse(e):this.getDefaultCategories()}getCategory(e){return this.getCategories().find(t=>t.id===e)||null}createCategory(e,a){const t=this.getCategories(),r={id:crypto.randomUUID(),name:e,color:a,createdAt:Date.now()};return t.push(r),localStorage.setItem(this.categoriesKey,JSON.stringify(t)),r}updateCategory(e,a){const t=this.getCategories(),r=t.findIndex(g=>g.id===e);if(r===-1)throw new Error("Category not found");const s={...t[r],...a};return t[r]=s,localStorage.setItem(this.categoriesKey,JSON.stringify(t)),s}deleteCategory(e){const a=this.getCategories().filter(t=>t.id!==e);localStorage.setItem(this.categoriesKey,JSON.stringify(a))}getTags(){const e=localStorage.getItem(this.tagsKey);return e?JSON.parse(e):this.getDefaultTags()}getTag(e){return this.getTags().find(t=>t.id===e)||null}createTag(e,a){const t=this.getTags(),r={id:crypto.randomUUID(),name:e,color:a,createdAt:Date.now()};return t.push(r),localStorage.setItem(this.tagsKey,JSON.stringify(t)),r}updateTag(e,a){const t=this.getTags(),r=t.findIndex(g=>g.id===e);if(r===-1)throw new Error("Tag not found");const s={...t[r],...a};return t[r]=s,localStorage.setItem(this.tagsKey,JSON.stringify(t)),s}deleteTag(e){const a=this.getTags().filter(t=>t.id!==e);localStorage.setItem(this.tagsKey,JSON.stringify(a))}getCategoryByName(e){return this.getCategories().find(t=>t.name.toLowerCase()===e.toLowerCase())||null}getTagByName(e){return this.getTags().find(t=>t.name.toLowerCase()===e.toLowerCase())||null}getEventsByCategory(e,a){return a.filter(t=>t.category===e)}getEventsByTag(e,a){return a.filter(t=>{var r;return(r=t.tags)==null?void 0:r.includes(e)})}getCategoryStats(e){const a={};return this.getCategories().forEach(r=>{a[r.id]=this.getEventsByCategory(r.id,e).length}),a}getTagStats(e){const a={};return this.getTags().forEach(r=>{a[r.id]=this.getEventsByTag(r.name,e).length}),a}getDefaultCategories(){return[{id:"work",name:"Work",color:"#3b82f6",createdAt:Date.now()},{id:"personal",name:"Personal",color:"#10b981",createdAt:Date.now()},{id:"meeting",name:"Meeting",color:"#f59e0b",createdAt:Date.now()},{id:"travel",name:"Travel",color:"#8b5cf6",createdAt:Date.now()},{id:"health",name:"Health",color:"#ef4444",createdAt:Date.now()}]}getDefaultTags(){return[{id:"urgent",name:"Urgent",color:"#ef4444",createdAt:Date.now()},{id:"important",name:"Important",color:"#f59e0b",createdAt:Date.now()},{id:"follow-up",name:"Follow-up",color:"#3b82f6",createdAt:Date.now()},{id:"completed",name:"Completed",color:"#10b981",createdAt:Date.now()},{id:"cancelled",name:"Cancelled",color:"#6b7280",createdAt:Date.now()}]}}exports.CategoryManager=l;