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