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

3 lines (2 loc) 2.05 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 */ "use strict";var a=Object.defineProperty;var o=(t,e,i)=>e in t?a(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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../icons/align-center.svg.cjs"),s=require("../../../icons/align-left.svg.cjs"),r=require("../../../icons/align-right.svg.cjs"),h=require("../../../icons/delete.svg.cjs"),d=require("../../../core/ui/ContextMenu.cjs");class u{constructor(e){n(this,"contextMenu");n(this,"activeVideo",null);this.contextMenu=new d.ContextMenu(e,[{label:e.t("Align Left"),icon:s.default,action:"align-left",onClick:()=>this.handleAction("align-left")},{label:e.t("Align Center"),icon:c.default,action:"align-center",onClick:()=>this.handleAction("align-center")},{label:e.t("Align Right"),icon:r.default,action:"align-right",onClick:()=>this.handleAction("align-right")},{type:"divider"},{label:e.t("Delete"),icon:h.default,action:"remove",className:"text-red-600",onClick:()=>this.handleAction("remove")}],{orientation:"vertical"})}handleAction(e){if(this.activeVideo)switch(e){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(e,i,l){this.activeVideo=e,this.contextMenu.show(e,i,l)}hide(){this.contextMenu.hide(),this.activeVideo=null}destroy(){this.hide(),this.contextMenu.destroy&&this.contextMenu.destroy(),this.contextMenu=null,this.activeVideo=null}}exports.VideoContextMenu=u;