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

80 lines (79 loc) 2.65 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 l = Object.defineProperty; var o = (e, t, i) => t in e ? l(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i; var n = (e, t, i) => o(e, typeof t != "symbol" ? t + "" : t, i); import c from "../../../icons/align-center.svg.mjs"; import s from "../../../icons/align-left.svg.mjs"; import g from "../../../icons/align-right.svg.mjs"; import h from "../../../icons/delete.svg.mjs"; import { ContextMenu as r } from "../../../core/ui/ContextMenu.mjs"; class d { constructor(t) { n(this, "contextMenu"); n(this, "activeImage", null); this.contextMenu = new r( t, [ { label: t.t("Align Left"), icon: s, action: "align-left", onClick: () => this.handleAction("align-left") }, { label: t.t("Align Center"), icon: c, action: "align-center", onClick: () => this.handleAction("align-center") }, { label: t.t("Align Right"), icon: g, action: "align-right", onClick: () => this.handleAction("align-right") }, { type: "divider" }, { label: t.t("Remove"), icon: h, action: "remove", className: "text-red-600", onClick: () => this.handleAction("remove") } ], { orientation: "vertical" } // Ориентация меню (вертикальная) ); } handleAction(t) { if (this.activeImage) switch (t) { case "align-left": this.activeImage.style.float = "left", this.activeImage.style.marginRight = "1rem"; break; case "align-center": this.activeImage.style.float = "none", this.activeImage.style.display = "block", this.activeImage.style.marginLeft = "auto", this.activeImage.style.marginRight = "auto"; break; case "align-right": this.activeImage.style.float = "right", this.activeImage.style.marginLeft = "1rem"; break; case "remove": this.activeImage.remove(); break; } } show(t, i, a) { this.activeImage = t, this.contextMenu.show(t, i, a); } hide() { this.contextMenu.hide(), this.activeImage = null; } destroy() { this.contextMenu.destroy(), this.contextMenu = null, this.activeImage = null; } } export { d as ImageContextMenu };