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.57 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 a=Object.defineProperty;var n=(e,l,t)=>l in e?a(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;var o=(e,l,t)=>n(e,typeof l!="symbol"?l+"":l,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../../utils/helpers.cjs");class i{constructor(l){o(this,"container");o(this,"onInsertSymbol");o(this,"buttons",[]);this.container=b.createContainer("math-toolbar flex gap-2 mb-4"),this.onInsertSymbol=l,this.initialize()}initialize(){[{label:"+",symbol:"+"},{label:"-",symbol:"-"},{label:"×",symbol:"\\times"},{label:"÷",symbol:"\\div"},{label:"√",symbol:"\\sqrt{}"},{label:"^",symbol:"^{}"},{label:"∫",symbol:"\\int_{}^{}"},{label:"∑",symbol:"\\sum_{}^{}"},{label:"sin",symbol:"\\sin()"},{label:"cos",symbol:"\\cos()"},{label:"tan",symbol:"\\tan()"},{label:"lim",symbol:"\\lim_{}"},{label:"frac",symbol:"\\frac{}{}"},{label:"(",symbol:"\\left(\\right)"},{label:")",symbol:"\\right)"}].forEach(t=>{const s=b.createButton(t.label,()=>this.onInsertSymbol(t.symbol));s.className="math-toolbar-button px-3 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600",this.container.appendChild(s),this.buttons.push(s)})}getElement(){return this.container}destroy(){this.buttons.forEach(l=>l.remove()),this.buttons=[],this.container.innerHTML=""}}exports.MathToolbar=i;