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

37 lines (36 loc) 1.42 kB
/*! 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 a = (t, e, r) => e in t ? n(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; var o = (t, e, r) => a(t, typeof e != "symbol" ? e + "" : e, r); import { FormManager as m } from "../services/FormManager.mjs"; import { createLineBreak as s } from "../../../utils/helpers.mjs"; class l { constructor(e, r) { o(this, "formElement"); o(this, "formManager"); o(this, "editor"); this.formElement = r, this.formManager = new m(e), this.editor = e; } execute() { const e = this.formManager.parseForm(this.formElement); if (!e) { console.error("Failed to parse form configuration"); return; } const r = this.createDuplicatedConfig(e), i = this.formManager.createForm(r); this.formElement.insertAdjacentHTML("afterend", i), this.editor.insertContent(s()), console.log("Form duplicated"); } createDuplicatedConfig(e) { return { ...e, id: `form_${Date.now()}_duplicate`, fields: e.fields.map((r) => ({ ...r, id: `field_${Date.now()}_${Math.random().toString(36).substr(2, 9)}` })) }; } } export { l as DuplicateFormCommand };