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
88 lines (87 loc) • 3.09 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 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
};