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

41 lines (40 loc) 1.6 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 d = Object.defineProperty; var b = (o, e, t) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t; var n = (o, e, t) => b(o, typeof e != "symbol" ? e + "" : e, t); class f { constructor(e, t) { n(this, "table"); this.table = t; } execute() { this.autoResizeColumns(); } autoResizeColumns() { const e = this.table.querySelectorAll(".table-header-row, .table-row"); if (e.length === 0) return; e[0].querySelectorAll(".table-cell, .table-header-cell").forEach((y, c) => { let a = 0; e.forEach((r) => { const s = r.querySelectorAll(".table-cell, .table-header-cell"); if (s[c]) { const i = s[c].textContent || "", l = document.createElement("span"); l.style.visibility = "hidden", l.style.position = "absolute", l.style.whiteSpace = "nowrap", l.textContent = i, document.body.appendChild(l); const h = l.offsetWidth + 20; a = Math.max(a, h), document.body.removeChild(l); } }), e.forEach((r) => { const s = r.querySelectorAll(".table-cell, .table-header-cell"); s[c] && (s[c].style.width = `${a}px`); }); }); } undo() { this.table.querySelectorAll(".table-cell, .table-header-cell").forEach((t) => { t.style.width = ""; }); } } export { f as ResizeColumnsCommand };