Diffs: add viewer payload validation and presentation defaults

This commit is contained in:
Gustavo Madeira Santana
2026-03-01 22:06:50 -05:00
parent 0202d79df4
commit 6532757cdf
13 changed files with 345 additions and 40 deletions

View File

@@ -52,13 +52,15 @@ function resolveBeforeAfterFileName(input: Extract<DiffInput, { kind: "before_af
function buildDiffOptions(options: DiffRenderOptions): DiffViewerOptions {
const fontFamily = escapeCssString(options.presentation.fontFamily);
const fontSize = Math.max(10, Math.floor(options.presentation.fontSize));
const lineHeight = Math.max(20, Math.round(fontSize * 1.6));
const lineHeight = Math.max(20, Math.round(fontSize * options.presentation.lineSpacing));
return {
theme: {
light: "pierre-light",
dark: "pierre-dark",
},
diffStyle: options.presentation.layout,
diffIndicators: options.presentation.diffIndicators,
disableLineNumbers: !options.presentation.showLineNumbers,
expandUnchanged: options.expandUnchanged,
themeType: options.presentation.theme,
backgroundEnabled: options.presentation.background,