Files
genoffice/apps/docs/tests/doc-style-css-hf-default-fs.test.ts
T
merrick-2002andGenOffice 69b4ce0560 Sync snapshot (2026-09-06) (#243)
- Docs: Word-style dark page, phased fast open for long documents, fonts embedded in the DOCX, spellcheck toggle, hyperlink editing, and ~80 Word fidelity fixes (CJK/JP metrics, header/footer, tables, anchored pictures)
- Sheets: hold formula recalculation while file data streams in, large-workbook scroll/load performance, combo charts, duplicate/unique conditional formatting by display text, RTL frozen-pane fix, workbooks whose ZIP entries carry a leading slash
- Slides: MTX-compressed embedded font support, CJK/Latin face selection and PowerPoint script fallbacks, theme colors kept on paragraph defaults and bullets, more reliable AI edits with a layout audit after each batch
- PDF: AI page ops, text block move/align, notes and markup editing, watermark and header/footer, form check boxes, metadata; the cloud Export as Word fallback is removed, conversion is always on-device
- AI: Gemini tool schema translation, OpenCode Zen/Go providers, markdown tables and code blocks in chat, current date in the system prompt
- Shell: Office-style ribbon collapse across all editors, native Windows ARM64 installer, BUILD_DIR override for packaging

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-09-07 00:18:14 +08:00

58 lines
2.2 KiB
TypeScript

/**
* Header/footer strip default font size: Word's Header/Footer styles are based
* on Normal, so unstyled strip runs take the document default size. The var is
* shrink-only — strips price their line boxes with the document-wide script
* strut, which overshoots Word on Latin-only strip lines, so a default above
* the static 10.5pt guess must not grow the push-down reserve
* (prod_082 8pt regression / prod_008+091 guard).
*/
import { describe, expect, it } from 'vitest'
import type { ParsedDocFull, StyleDisplay, StyleInfo } from '@genoffice/docx-engine'
import { docStyleCss } from '../src/renderer/doc-style-css'
;(globalThis as { CSS?: unknown }).CSS ??= { escape: (s: string) => s }
function parsedWith(opts: {
ddSizeHalfPoints?: number
normalSizeHalfPoints?: number
}): ParsedDocFull {
const styles = new Map<string, StyleInfo>()
if (opts.normalSizeHalfPoints) {
styles.set('Normal', {
styleId: 'Normal',
name: 'Normal',
type: 'paragraph',
isDefault: true,
display: { sizeHalfPoints: opts.normalSizeHalfPoints } as StyleDisplay,
} as StyleInfo)
}
return {
styles,
docDefaults: opts.ddSizeHalfPoints ? { sizeHalfPoints: opts.ddSizeHalfPoints } : {},
blocks: [],
} as unknown as ParsedDocFull
}
describe('docStyleCss --hf-default-fs', () => {
it('emits the strip default size when the document default is below 10.5pt', () => {
const css = docStyleCss(parsedWith({ ddSizeHalfPoints: 16 }))
expect(css).toContain('.page-wrap, .doc-page, .pv-page { --hf-default-fs:8pt }')
})
it('prefers Normal over docDefaults', () => {
const css = docStyleCss(parsedWith({ ddSizeHalfPoints: 24, normalSizeHalfPoints: 19 }))
expect(css).toContain('--hf-default-fs:9.5pt')
})
it('stays silent at or above the 10.5pt static guess', () => {
expect(docStyleCss(parsedWith({ ddSizeHalfPoints: 21 }))).not.toContain('--hf-default-fs')
expect(docStyleCss(parsedWith({ ddSizeHalfPoints: 22 }))).not.toContain('--hf-default-fs')
})
it("no size anywhere: Word's built-in 10pt default drives body and strips", () => {
const css = docStyleCss(parsedWith({}))
expect(css).toContain('font-size:10pt')
expect(css).toContain('--hf-default-fs:10pt')
})
})