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
43 lines (42 loc) • 2.83 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 l = (t, e, s) => e in t ? a(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var i = (t, e, s) => l(t, typeof e != "symbol" ? e + "" : e, s);
class n {
constructor(e, s, o) {
i(this, "table");
i(this, "options");
i(this, "previousState");
this.table = s, this.options = o, this.previousState = {
classes: Array.from(this.table.classList),
width: this.table.style.width || null
};
}
execute() {
this.table.classList.remove(
"responsive-table",
"responsive-table--scroll",
"responsive-table--touch",
"responsive-table--cards"
), this.table.classList.remove(
"breakpoint-320",
"breakpoint-480",
"breakpoint-640",
"breakpoint-768",
"breakpoint-1024",
"breakpoint-1280",
"breakpoint-1440",
"breakpoint-1536",
"breakpoint-1920",
"breakpoint-2560"
), this.options.breakpoint && this.table.classList.add(`breakpoint-${this.options.breakpoint}`), (this.options.enableScroll || this.options.enableTouch || this.options.enableCards) && this.table.classList.add("responsive-table"), this.options.enableScroll && (this.table.classList.add("responsive-table--scroll"), this.table.style.removeProperty("width")), this.options.enableTouch && this.table.classList.add("responsive-table--touch"), this.options.enableCards && this.table.classList.add("responsive-table--cards"), this.options.breakpoint && this.table.style.setProperty("--responsive-breakpoint", `${this.options.breakpoint}px`), this.options.enableScroll ? this.table.style.setProperty("--responsive-enable-scroll", "1") : this.table.style.setProperty("--responsive-enable-scroll", "0"), this.options.enableTouch ? this.table.style.setProperty("--responsive-enable-touch", "1") : this.table.style.setProperty("--responsive-enable-touch", "0"), this.options.enableCards ? this.table.style.setProperty("--responsive-enable-cards", "1") : this.table.style.setProperty("--responsive-enable-cards", "0");
}
undo() {
this.table.className = "", this.previousState.classes.forEach((e) => {
this.table.classList.add(e);
}), this.previousState.width ? this.table.style.width = this.previousState.width : this.table.style.removeProperty("width"), this.table.style.removeProperty("--responsive-breakpoint"), this.table.style.removeProperty("--responsive-enable-scroll"), this.table.style.removeProperty("--responsive-enable-touch"), this.table.style.removeProperty("--responsive-enable-cards");
}
}
export {
n as ApplyTableResponsiveCommand
};