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

79 lines (78 loc) 2.63 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 a = Object.defineProperty; var l = (e, t, i) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i; var n = (e, t, i) => l(e, typeof t != "symbol" ? t + "" : t, i); import c from "../../../icons/align-center.svg.mjs"; import s from "../../../icons/align-left.svg.mjs"; import h from "../../../icons/align-right.svg.mjs"; import r from "../../../icons/delete.svg.mjs"; import { ContextMenu as g } from "../../../core/ui/ContextMenu.mjs"; class y { constructor(t) { n(this, "contextMenu"); n(this, "activeVideo", null); this.contextMenu = new g( 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: h, action: "align-right", onClick: () => this.handleAction("align-right") }, { type: "divider" }, { label: t.t("Delete"), icon: r, action: "remove", className: "text-red-600", onClick: () => this.handleAction("remove") } ], { orientation: "vertical" } ); } handleAction(t) { if (this.activeVideo) switch (t) { case "align-left": this.activeVideo.style.float = "left", this.activeVideo.style.marginRight = "1rem"; break; case "align-center": this.activeVideo.style.float = "none", this.activeVideo.style.display = "block", this.activeVideo.style.marginLeft = "auto", this.activeVideo.style.marginRight = "auto"; break; case "align-right": this.activeVideo.style.float = "right", this.activeVideo.style.marginLeft = "1rem"; break; case "remove": this.activeVideo.remove(); break; } } show(t, i, o) { this.activeVideo = t, this.contextMenu.show(t, i, o); } hide() { this.contextMenu.hide(), this.activeVideo = null; } destroy() { this.hide(), this.contextMenu.destroy && this.contextMenu.destroy(), this.contextMenu = null, this.activeVideo = null; } } export { y as VideoContextMenu };