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

156 lines (155 loc) 4.69 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 */ var s = Object.defineProperty; var h = (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) => h(i, typeof t != "symbol" ? t + "" : t, e); import { ContextMenu as a } from "../../../core/ui/ContextMenu.mjs"; import r from "../../../icons/copy.svg.mjs"; import c from "../../../icons/delete.svg.mjs"; import d from "../../../icons/edit.svg.mjs"; import p from "../../../icons/export.svg.mjs"; class M { constructor(t, e) { o(this, "editor"); o(this, "onAction"); o(this, "currentContextMenu", null); this.editor = t, this.onAction = e; } show(t, e, l) { this.currentContextMenu && this.currentContextMenu.destroy(); const u = this.getMenuItems(t); this.currentContextMenu = new a(this.editor, u); 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, l); } 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, 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, action: "copy-calendar", onClick: () => this.executeAction("copy-calendar", t), hotkey: "Ctrl+C" }, { type: "button", title: this.editor.t("Export Calendar"), icon: p, 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, 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, action: "edit-event", onClick: () => this.executeAction("edit-event", t), hotkey: "Ctrl+E" }, { type: "button", title: this.editor.t("Copy Event"), icon: r, 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, 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(); } } export { M as CalendarContextMenu };