Markdown tables now have variable column width

This commit is contained in:
mkt
2026-06-06 13:40:12 +02:00
parent eefb9e69ab
commit 79ea236da0

View File

@@ -103,6 +103,51 @@ for i in $(seq 1 90); do
done
echo "EspoCRM responded with HTTP $code (rc=$?)"
# --- GUI customization: variable column widths for Markdown tables -------------
# Core CSS forces `table-layout: fixed; width: 100%` on `.complex-text table`,
# giving every column an equal width. Register a custom CSS file via cssList so
# those tables size columns to content (table-layout: auto). Created by this
# provisioning script (on the persisted bind-mount) so it survives re-runs; the
# rebuild step below refreshes the cached cssList metadata.
podman exec "$WEB_CTR" sh -lc 'mkdir -p /var/www/html/client/custom/css /var/www/html/custom/Espo/Custom/Resources/metadata/app'
podman exec -i "$WEB_CTR" sh -c 'cat > /var/www/html/client/custom/css/table-var-col.css' <<'CSSEOF'
/**
* Variable column widths for Markdown tables in text fields.
*
* EspoCRM core CSS forces `table-layout: fixed; width: 100%` on
* `.complex-text table`, which makes all columns equally wide.
* `auto` lets columns size to content instead.
*
* Registered via custom/Espo/Custom/Resources/metadata/app/client.json (cssList).
*/
.complex-text table {
table-layout: auto !important;
width: auto !important;
max-width: 100% !important;
}
CSSEOF
echo "Wrote client/custom/css/table-var-col.css (rc=$?)"
# Merge the CSS path into cssList (idempotent; preserves other keys/entries and
# keeps "__APPEND__" first). Uses the container's php so no host jq is required.
podman exec "$WEB_CTR" php -r '
$file = "/var/www/html/custom/Espo/Custom/Resources/metadata/app/client.json";
$css = "client/custom/css/table-var-col.css";
$data = is_file($file) ? json_decode(file_get_contents($file), true) : [];
if (!is_array($data)) { $data = []; }
$list = (isset($data["cssList"]) && is_array($data["cssList"])) ? $data["cssList"] : [];
$list = array_values(array_filter($list, function ($x) use ($css) { return $x !== "__APPEND__" && $x !== $css; }));
array_unshift($list, "__APPEND__");
$list[] = $css;
$data["cssList"] = $list;
file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n");
'
echo "Registered table-var-col.css in cssList (rc=$?)"
# Match ownership of the other EspoCRM customization files (webserver user).
podman exec "$WEB_CTR" chown -R www-data:www-data /var/www/html/client/custom /var/www/html/custom/Espo/Custom/Resources/metadata
echo "Fixed ownership of customizations (rc=$?)"
# Rebuild EspoCRM cache so customizations on the persisted bind-mount take effect
# and the client cacheTimestamp is bumped (forces browsers to reload custom views,
# e.g. custom field views like the signature image button). The image entrypoint