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.23 kB
JavaScript
/*! 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 s=Object.defineProperty;var a=(i,t,e)=>t in i?s(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>a(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../../core/ui/ContextMenu.cjs"),r=require("../../../icons/copy.svg.cjs"),c=require("../../../icons/delete.svg.cjs"),d=require("../../../icons/edit.svg.cjs"),p=require("../../../icons/export.svg.cjs");class C{constructor(t,e){o(this,"editor");o(this,"onAction");o(this,"currentContextMenu",null);this.editor=t,this.onAction=e}show(t,e,u){this.currentContextMenu&&this.currentContextMenu.destroy();const l=this.getMenuItems(t);this.currentContextMenu=new h.ContextMenu(this.editor,l);let n;"events"in t?n=this.editor.getContainer().querySelector(`[data-calendar-id="${t.id}"]`):n=this.editor.getContainer().querySelector(`[data-event-id="${t.id}"]`),n&&this.currentContextMenu.show(n,e,u)}hide(){this.currentContextMenu&&this.currentContextMenu.hide()}getMenuItems(t){return"events"in t?[{type:"group",groupTitle:this.editor.t("Calendar"),subMenu:[{type:"button",title:this.editor.t("Add Event"),icon:"➕",action:"add-event",onClick:()=>this.executeAction("add-event",t),hotkey:"Ctrl+Shift+E"},{type:"button",title:this.editor.t("Edit Calendar"),icon:d.default,action:"edit-calendar",onClick:()=>this.executeAction("edit-calendar",t),hotkey:"Ctrl+E"}]},{type:"divider"},{type:"group",groupTitle:this.editor.t("Actions"),subMenu:[{type:"button",title:this.editor.t("Copy Calendar"),icon:r.default,action:"copy-calendar",onClick:()=>this.executeAction("copy-calendar",t),hotkey:"Ctrl+C"},{type:"button",title:this.editor.t("Export Calendar"),icon:p.default,action:"export-calendar",onClick:()=>this.executeAction("export-calendar",t),hotkey:"Ctrl+Shift+X"},{type:"button",title:this.editor.t("Import Calendar"),icon:"📥",action:"import-calendar",onClick:()=>this.executeAction("import-calendar",t),hotkey:"Ctrl+Shift+I"}]},{type:"divider"},{type:"group",groupTitle:this.editor.t("Delete"),subMenu:[{type:"button",title:this.editor.t("Delete Calendar"),icon:c.default,action:"delete-calendar",onClick:()=>this.executeAction("delete-calendar",t),variant:"danger",hotkey:"Delete"}]}]:[{type:"group",groupTitle:this.editor.t("Event"),subMenu:[{type:"button",title:this.editor.t("Edit Event"),icon:d.default,action:"edit-event",onClick:()=>this.executeAction("edit-event",t),hotkey:"Ctrl+E"},{type:"button",title:this.editor.t("Copy Event"),icon:r.default,action:"copy-event",onClick:()=>this.executeAction("copy-event",t),hotkey:"Ctrl+C"}]},{type:"divider"},{type:"group",groupTitle:this.editor.t("Delete"),subMenu:[{type:"button",title:this.editor.t("Delete Event"),icon:c.default,action:"delete-event",onClick:()=>this.executeAction("delete-event",t),variant:"danger",hotkey:"Delete"}]}]}executeAction(t,e){this.onAction(t,e),this.hide()}destroy(){var t;(t=this.currentContextMenu)==null||t.destroy()}}exports.CalendarContextMenu=C;