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

2 lines (1 loc) 1.43 kB
"use strict";var r=Object.defineProperty;var a=(o,t,e)=>t in o?r(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var i=(o,t,e)=>a(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../core/ui/PopupManager.cjs"),u=require("../constants.cjs"),h=require("../../../icons/clear.svg.cjs");class l{constructor(t){i(this,"editor");i(this,"popup");i(this,"onSelect",null);this.editor=t,this.popup=new s.PopupManager(t,{title:t.t("Typography Styles"),className:"typography-menu",closeOnClickOutside:!0,buttons:[{label:t.t("Cancel"),variant:"secondary",onClick:()=>this.popup.hide()}],items:this.createPopupItems()})}createPopupItems(){const t=[];return t.push({type:"button",id:"typography-clear",text:this.editor.t("Clear Formatting"),buttonVariant:"primary",icon:h.default,value:"clear",onChange:e=>{var p;(p=this.onSelect)==null||p.call(this,e.toString()),this.popup.hide()}}),t.push({type:"divider",id:"typography-divider"}),u.TYPOGRAPHY_STYLES.forEach(e=>{t.push({type:"button",id:`typography-${e.value}`,text:this.editor.t(e.label),buttonVariant:"secondary",icon:e.icon,value:e.value,className:e.preview,onChange:p=>{var n;(n=this.onSelect)==null||n.call(this,p.toString()),this.popup.hide()}})}),t}show(t){this.onSelect=t,this.popup.show()}destroy(){this.popup.destroy(),this.editor=null,this.popup=null,this.onSelect=null}}exports.TypographyMenu=l;