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
40 lines (39 loc) • 1.34 kB
JavaScript
var a = Object.defineProperty;
var r = (o, t, n) => t in o ? a(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n;
var p = (o, t, n) => r(o, typeof t != "symbol" ? t + "" : t, n);
import { createContainer as u, createInputField as h, createButton as l } from "../../../utils/helpers.mjs";
class d {
constructor() {
p(this, "optionsContainer", null);
p(this, "optionInputs", []);
}
// Устанавливает контейнер для опций
setOptionsContainer(t) {
this.optionsContainer = t;
}
// Добавляет новую опцию
addOption(t = "") {
if (!this.optionsContainer) return;
const n = u("option-container mb-2"), i = h("text", "Option Value", t);
i.className = "option-input", this.optionInputs.push(i);
const e = l(
"Remove",
() => {
n.remove(), this.optionInputs = this.optionInputs.filter((s) => s !== i);
},
"danger"
);
n.appendChild(i), n.appendChild(e), this.optionsContainer.appendChild(n);
}
// Возвращает все опции
getOptions() {
return this.optionInputs.map((t) => t.value);
}
// Очищает все опции
clearOptions() {
this.optionsContainer && (this.optionsContainer.innerHTML = ""), this.optionInputs = [];
}
}
export {
d as OptionManager
};