fix(чат): широкие таблицы не обрезаются — сообщение во всю ширину, видимый скролл и подсказка; версия 2026-11-18b
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
+39
-1
@@ -319,8 +319,22 @@ button { font-family: inherit; }
|
||||
.msg-ai li { margin: .15rem 0; }
|
||||
.msg-ai strong { font-weight: 600; }
|
||||
.msg-ai hr { border: none; border-top: 1px solid var(--border-light); margin: .6rem 0; }
|
||||
.msg-ai .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; }
|
||||
.msg-ai .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
|
||||
/* Полоса прокрутки у таблицы должна быть видна в обеих темах: общий «тихий»
|
||||
скроллбар в тёмной теме сливался с фоном, и казалось, что таблица обрезана
|
||||
(жалоба Хозяина 18.11). */
|
||||
.msg-ai .table-wrap::-webkit-scrollbar { height: 10px; }
|
||||
.msg-ai .table-wrap::-webkit-scrollbar-thumb { background: var(--text-muted); border: 2px solid transparent; background-clip: padding-box; border-radius: 6px; }
|
||||
.msg-ai .table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text); }
|
||||
/* Таблица хочет больше места — сообщение расширяется на всю ленту (сказал Хозяин 18.11). */
|
||||
.msg-ai.has-table { max-width: 100%; }
|
||||
.msg-table-hint { font-size: .75rem; color: var(--text-muted); margin-left: .5rem; white-space: nowrap; }
|
||||
.msg-ai table { border-collapse: collapse; margin: 0; font-size: .82rem; width: auto; min-width: 100%; }
|
||||
/* Внутри таблицы слова не рвём по буквам: при узкой ленте колонки сжимались до одной
|
||||
буквы («Н а и м е н о в а н и е»), вместо того чтобы дать таблице прокрутку.
|
||||
Минимальная ширина колонки держит слово целиком, а широкая таблица крутится вбок. */
|
||||
.msg-ai .table-wrap table { word-break: normal; overflow-wrap: break-word; }
|
||||
.msg-ai .table-wrap th, .msg-ai .table-wrap td { min-width: 5em; }
|
||||
.msg-ai th, .msg-ai td { border: 1px solid var(--border-light); padding: .35rem .6rem; text-align: left; vertical-align: top; white-space: normal; max-width: 360px; }
|
||||
.msg-ai th { background: var(--bg); font-weight: 600; position: sticky; top: 0; }
|
||||
.msg-ai td.num, .msg-ai th.num { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
|
||||
@@ -905,9 +919,33 @@ function enhanceTables(container) {
|
||||
btn.onclick = () => tableToExcel(table, 'смета.xlsx', title);
|
||||
bar.appendChild(btn);
|
||||
wrap.parentNode.insertBefore(bar, wrap);
|
||||
container.classList.add('has-table');
|
||||
// Подсказка «прокрутите вбок» — только если таблица правда шире обёртки.
|
||||
// Меряем после вставки в страницу: до неё размеры нулевые.
|
||||
requestAnimationFrame(updateTableHints);
|
||||
});
|
||||
}
|
||||
|
||||
// Обновляет подсказки у всех таблиц: нужна и после вставки, и после смены ширины окна —
|
||||
// иначе на узком окне таблица молча обрезается без объяснения (жалоба Хозяина 18.11).
|
||||
function updateTableHints() {
|
||||
document.querySelectorAll('.msg-ai .table-wrap').forEach(wrap => {
|
||||
const bar = wrap.previousElementSibling;
|
||||
if (!bar || !bar.classList.contains('msg-table-bar')) return;
|
||||
const hint = bar.querySelector('.msg-table-hint');
|
||||
const wide = wrap.scrollWidth > wrap.clientWidth + 1;
|
||||
if (wide && !hint) {
|
||||
const s = document.createElement('span');
|
||||
s.className = 'msg-table-hint';
|
||||
s.textContent = '↔ Прокрутите таблицу вбок';
|
||||
bar.appendChild(s);
|
||||
} else if (!wide && hint) {
|
||||
hint.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener('resize', updateTableHints);
|
||||
|
||||
// --- Генерация НАСТОЯЩЕГО .xlsx (OOXML zip) без внешних библиотек. ---
|
||||
// Трюк «HTML c расширением .xls» открывался как простыня тегов в Numbers/
|
||||
// LibreOffice — это сырой zip с правильными XML-частями, открывается везде.
|
||||
|
||||
Reference in New Issue
Block a user