fix: bound custom fontsizes between 6 and 64 (#1577)

Adds bounding for markdown (and AI) fontsize and fixedfontsize.
This commit is contained in:
Sylvie Crowe 2024-12-19 13:01:12 -08:00 committed by GitHub
parent a940de6df6
commit 0f15e4ff56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,7 @@ import {
resolveSrcSet,
transformBlocks,
} from "@/app/element/markdown-util";
import { useAtomValueSafe } from "@/util/util";
import { boundNumber, useAtomValueSafe } from "@/util/util";
import { clsx } from "clsx";
import { Atom } from "jotai";
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
@ -380,10 +380,10 @@ const Markdown = ({
const mergedStyle = { ...style };
if (fontSizeOverride != null) {
mergedStyle["--markdown-font-size"] = `${fontSizeOverride}px`;
mergedStyle["--markdown-font-size"] = `${boundNumber(fontSizeOverride, 6, 64)}px`;
}
if (fixedFontSizeOverride != null) {
mergedStyle["--markdown-fixed-font-size"] = `${fixedFontSizeOverride}px`;
mergedStyle["--markdown-fixed-font-size"] = `${boundNumber(fixedFontSizeOverride, 6, 64)}px`;
}
return (
<div className={clsx("markdown", className)} style={mergedStyle}>