fix(project): grow cells and repair Enter
This commit is contained in:
@@ -106,6 +106,29 @@
|
||||
{ label: "전체 열 너비 자동 맞춤", icon: opts.icon("width"), onClick: fitAll },
|
||||
] : [];
|
||||
}
|
||||
const growingCells = new Set();
|
||||
let growFrame = 0;
|
||||
function queueCellGrowth(e) {
|
||||
const field = e.target.closest("input, textarea, [contenteditable='true']");
|
||||
const td = field && field.closest("td, th");
|
||||
if (!admin || !td || !table.contains(td)) return;
|
||||
growingCells.add(td);
|
||||
if (growFrame) return;
|
||||
growFrame = requestAnimationFrame(function () {
|
||||
growFrame = 0; let changed = false;
|
||||
growingCells.forEach(function (cell) {
|
||||
if (!table.contains(cell)) return;
|
||||
const keys = (cell.dataset.meetCols || "").split(",").filter(Boolean), key = keys.at(-1);
|
||||
if (!key) return;
|
||||
const width = measure(cell) - keys.slice(0, -1).reduce((sum, k) => sum + widths[k], 0);
|
||||
if (width > widths[key]) { widths[key] = width; changed = true; }
|
||||
});
|
||||
growingCells.clear();
|
||||
if (changed) { applyWidths(); saveWidths(); }
|
||||
});
|
||||
}
|
||||
table.addEventListener("input", queueCellGrowth);
|
||||
table.addEventListener("compositionend", queueCellGrowth);
|
||||
table.addEventListener("dblclick", function (e) {
|
||||
const h = e.target.closest(".pj-meet-colresize");
|
||||
if (h) { e.preventDefault(); e.stopPropagation(); fit(h.dataset.col); }
|
||||
|
||||
Reference in New Issue
Block a user