fix(webui): prevent equation tags from overlapping formulas

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-14 14:32:14 +08:00
1 parent 74b22b6522
commit bdb6c369d0
2 files changed
+8

No files matched your search

+6
View File
@@ -11,6 +11,7 @@
top: 0;
left: 50%;
width: max-content;
min-width: 100%;
padding-block: 0.1em;
transform-origin: top center;
}
@@ -23,6 +24,11 @@
font-size: 1.1em;
}
/* KaTeX tags are out of flow; reserve equal space to keep the formula centered. */
.math-fit .katex-html:has(> .tag) {
padding-inline: calc(var(--math-tag-width) + 1em);
}
/* Math-heavy prose uses a tighter reading rhythm than ordinary chat. */
.markdown-content:has(.math-fit) {
--cjk-line-height: 1.65;
+2
View File
@@ -9,6 +9,8 @@ export function DisplayMath({ children }: { children: ReactNode }) {
useLayoutEffect(() => {
const update = () => {
if (!frame.current || !content.current) return;
const tag = content.current.querySelector<HTMLElement>(".katex-html > .tag");
content.current.style.setProperty("--math-tag-width", `${tag?.offsetWidth ?? 0}px`);
const width = content.current.offsetWidth;
const scale = width ? Math.min(1, frame.current.clientWidth / width) : 1;
const height = content.current.offsetHeight * scale;