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) • 1.59 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 */
"use strict";var s=Object.defineProperty;var n=(a,e,t)=>e in a?s(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>n(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../core/ui/PopupManager.cjs"),p=require("../constants.cjs");class i{constructor(e){l(this,"popup");l(this,"callback",null);l(this,"languageSelect","");l(this,"codeInput","plaintext");this.popup=new c.PopupManager(e,{title:e.t("Insert Code Block"),className:"code-block-modal",closeOnClickOutside:!0,items:[{type:"list",label:e.t("Language"),id:"language",options:p.SUPPORTED_LANGUAGES,value:this.codeInput,onChange:t=>this.languageSelect=t.toString()},{type:"textarea",label:"Code",id:"code",placeholder:e.t("Enter your code here..."),onChange:t=>this.codeInput=t.toString()}],buttons:[{label:"Cancel",variant:"secondary",onClick:()=>this.popup.hide()},{label:"Save",variant:"primary",onClick:()=>this.handleSubmit()}]})}handleSubmit(){const e=this.languageSelect,t=this.codeInput.trim();t&&this.callback&&(this.callback(t,e),this.popup.hide())}show(e,t="",o="plaintext"){this.callback=e,this.popup.setValue("language",o),this.popup.setValue("code",t),this.popup.show(),this.popup.setFocus("code")}destroy(){this.popup.destroy(),this.callback=null,this.popup=null}}exports.CodeBlockModal=i;