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
79 lines (78 loc) • 2.53 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 */
var s = Object.defineProperty;
var c = (i, t, e) => t in i ? s(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
var r = (i, t, e) => c(i, typeof t != "symbol" ? t + "" : t, e);
import { ContextMenu as u } from "../../../core/ui/ContextMenu.mjs";
class h {
constructor(t, e) {
r(this, "editor");
r(this, "currentContextMenu", null);
this.editor = e;
}
show(t, e, o) {
this.currentContextMenu && (this.currentContextMenu.destroy(), this.currentContextMenu = null);
const l = [
{
label: this.editor.t("Edit Timer"),
icon: "✏️",
action: "edit-timer",
onClick: () => {
o("edit-timer"), this.closeContextMenu();
},
type: "button"
},
{
label: this.editor.t("Copy Timer"),
icon: "📋",
action: "copy-timer",
onClick: () => {
o("copy-timer"), this.closeContextMenu();
},
type: "button"
},
{
label: this.editor.t("Export Timer"),
icon: "📤",
action: "export-timer",
onClick: () => {
o("export-timer"), this.closeContextMenu();
},
type: "button"
},
{
label: this.editor.t("Import Timer"),
icon: "📥",
action: "import-timer",
onClick: () => {
o("import-timer"), this.closeContextMenu();
},
type: "button"
},
{
type: "divider"
},
{
label: this.editor.t("Delete Timer"),
icon: "🗑️",
action: "delete-timer",
className: "danger",
onClick: () => {
o("delete-timer"), this.closeContextMenu();
},
type: "button"
}
];
this.currentContextMenu = new u(this.editor, l);
const n = document.createElement("div");
n.style.position = "fixed", n.style.left = `${t.clientX}px`, n.style.top = `${t.clientY}px`, document.body.appendChild(n), this.currentContextMenu.show(n, t.clientX, t.clientY), document.body.removeChild(n);
}
closeContextMenu() {
this.currentContextMenu && (this.currentContextMenu.destroy(), this.currentContextMenu = null);
}
destroy() {
this.closeContextMenu(), this.editor = null;
}
}
export {
h as TimerContextMenu
};