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) • 2.04 kB
JavaScript
"use strict";var n=Object.defineProperty;var h=(o,t,l)=>t in o?n(o,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[t]=l;var e=(o,t,l)=>h(o,typeof t!="symbol"?t+"":t,l);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../core/ui/PopupManager.cjs");class i{constructor(t){e(this,"popup");e(this,"callback",null);e(this,"url","");e(this,"anchor","");e(this,"title","");e(this,"nofollowCheckbox",!1);e(this,"targetBlankCheckbox",!1);this.popup=new s.PopupManager(t,{title:t.t("Insert Link"),className:"link-menu",closeOnClickOutside:!0,buttons:[{label:t.t("Cancel"),variant:"secondary",onClick:()=>this.popup.hide()},{label:t.t("Insert"),variant:"primary",onClick:()=>this.handleSubmit()}],items:[{type:"input",id:"link-url",label:t.t("URL"),value:this.url,onChange:l=>this.url=l.toString()},{type:"input",id:"link-anchor",label:t.t("Anchor"),value:this.anchor,onChange:l=>this.anchor=l.toString()},{type:"input",id:"link-title",label:t.t("Title"),value:this.title,onChange:l=>this.title=l.toString()},{type:"checkbox",id:"link-nofollow",label:t.t('Add rel="nofollow"'),value:this.nofollowCheckbox,onChange:l=>this.nofollowCheckbox=l},{type:"checkbox",id:"link-blank",label:t.t('Open in new tab (target="_blank")'),value:this.targetBlankCheckbox,onChange:l=>this.targetBlankCheckbox=l}]})}handleSubmit(){const t={url:this.url.trim(),anchor:this.anchor.trim(),title:this.title.trim(),nofollow:this.nofollowCheckbox,targetBlank:this.targetBlankCheckbox};t.url&&(this.callback&&this.callback(t),this.popup.hide())}show(t,l={}){this.callback=t,this.popup.setValue("link-url",l.url||""),this.popup.setValue("link-anchor",l.anchor||""),this.popup.setValue("link-title",l.title||""),this.popup.setValue("link-blank",l.targetBlank||""),this.popup.setValue("link-nofollow",l.nofollow||""),this.url=l.url||"",this.anchor=l.anchor||"",this.title=l.title||"",this.nofollowCheckbox=l.nofollow||!1,this.targetBlankCheckbox=l.targetBlank||!1,this.popup.show(),this.popup.setFocus("link-url")}}exports.LinkMenu=i;