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

87 lines (86 loc) 2.86 kB
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); import { PopupManager as s } from "../../../core/ui/PopupManager.mjs"; class p { 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(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"); } } export { p as LinkMenu };