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

58 lines (57 loc) 1.74 kB
var h = Object.defineProperty; var c = (i, t, e) => t in i ? h(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e; var n = (i, t, e) => c(i, typeof t != "symbol" ? t + "" : t, e); import o from "../../../icons/delete.svg.mjs"; import r from "../../../icons/edit.svg.mjs"; import { ContextMenu as s } from "../../../core/ui/ContextMenu.mjs"; class v { constructor(t, e) { n(this, "contextMenu"); n(this, "activeChart", null); this.chartMenu = e, this.contextMenu = new s( t, [ { label: t.t("Edit"), icon: r, action: "edit", onClick: () => this.handleEdit() }, { label: t.t("Delete"), icon: o, action: "delete", className: "text-red-600", onClick: () => this.handleDelete() } ], { orientation: "vertical" } // Ориентация меню (вертикальная) ); } handleEdit() { if (!this.activeChart) return; const t = this.activeChart.getAttribute("data-chart-type"), e = this.activeChart.getAttribute("data-chart-data"); if (t && e) try { this.chartMenu.edit(this.activeChart); } catch (a) { console.error("Failed to parse chart data:", a); } } handleDelete() { this.activeChart && this.activeChart.remove(); } show(t, e, a) { this.activeChart = t, this.contextMenu.show(t, e, a); } hide() { this.contextMenu.hide(), this.activeChart = null; } destroy() { typeof this.contextMenu.destroy == "function" && this.contextMenu.destroy(), this.contextMenu = null, this.activeChart = null, this.chartMenu = null; } } export { v as ChartContextMenu };