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
50 lines (49 loc) • 2.19 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 u = Object.defineProperty;
var b = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var r = (i, e, t) => b(i, typeof e != "symbol" ? e + "" : e, t);
import { createForm as E, createContainer as m, createLabel as p, createInputField as f, createTextarea as C, createFormSubmitHandler as v } from "../../../utils/helpers.mjs";
class F {
constructor(e, t, o) {
r(this, "editor");
r(this, "onSubmit");
r(this, "calendar");
r(this, "formElement");
this.editor = e, this.onSubmit = t, this.calendar = o;
}
getElement() {
var d, s;
const e = document.createElement("div");
e.className = "calendar-form-container", this.formElement = E("calendar-form", null, "POST");
const t = m("form-group mb-4"), o = p(this.editor.t("Calendar Title"), "calendar-title"), n = f(
"text",
this.editor.t("Enter calendar title"),
((d = this.calendar) == null ? void 0 : d.title) || ""
);
n.id = "calendar-title", n.name = "title", n.required = !0, t.appendChild(o), t.appendChild(n), this.formElement.appendChild(t);
const l = m("form-group mb-4"), h = p(this.editor.t("Description"), "calendar-description"), a = C(
this.editor.t("Enter calendar description"),
((s = this.calendar) == null ? void 0 : s.description) || ""
);
return a.id = "calendar-description", a.name = "description", a.rows = 3, l.appendChild(h), l.appendChild(a), this.formElement.appendChild(l), this.formElement.addEventListener(
"submit",
v(this.formElement, (c) => {
this.onSubmit({
title: c.title,
description: c.description
});
})
), e.appendChild(this.formElement), e;
}
submit() {
if (!this.formElement) return !1;
const e = new Event("submit", {
bubbles: !0,
cancelable: !0
});
return this.formElement.dispatchEvent(e), !0;
}
}
export {
F as CalendarForm
};