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
33 lines (32 loc) • 1.3 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 a = Object.defineProperty;
var c = (o, t, e) => t in o ? a(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
var s = (o, t, e) => c(o, typeof t != "symbol" ? t + "" : t, e);
class u {
constructor(t, e) {
s(this, "table");
s(this, "previousContents", /* @__PURE__ */ new Map());
this.table = e;
}
execute() {
this.table.querySelectorAll(".table-cell, .table-header-cell").forEach((e, n) => {
const l = e.querySelector("input, textarea");
l ? (this.previousContents.set(
n.toString(),
l.value
), l.value = "") : (this.previousContents.set(n.toString(), e.textContent || ""), e.textContent = "");
}), console.log("Table cleared");
}
undo() {
this.table.querySelectorAll(".table-cell, .table-header-cell").forEach((e, n) => {
const l = this.previousContents.get(n.toString());
if (l !== void 0) {
const r = e.querySelector("input, textarea");
r ? r.value = l : e.textContent = l;
}
});
}
}
export {
u as ClearTableCommand
};