Something went wrong. Try again.
The Cavu Reader
Something went wrong. Try again.
4.0 kB · 118 lines
TSX
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119/** * How this author's markdown becomes records: the studio-local conversion * settings (lib/publisher/conversion). Rendered above the file list on * both write surfaces, since both parse files the same way. * * There is no Save button — nothing here goes to the network. A change * writes to localStorage and re-parses the already-picked files, so the * plan preview below updates as the author reads. */import { SCENE_BREAK_CHOICES, STRATEGY_CHOICES, VERSE_CHOICES, type ConversionSettings,} from '#/lib/publisher/conversion'
export function TypesettingPanel({ settings, onChange, disabled, ruleStrategyActive,}: { settings: ConversionSettings onChange(next: ConversionSettings): void disabled?: boolean /** * True when a picked file splits chapters on thematic breaks. Those * rules are consumed as chapter boundaries before the scene-break * setting ever sees them, so say so rather than appear to do nothing. */ ruleStrategyActive?: boolean}) { const set = <K extends keyof ConversionSettings>(key: K, value: ConversionSettings[K]) => onChange({ ...settings, [key]: value })
const verseHint = VERSE_CHOICES.find((c) => c.id === settings.verse)?.hint const sceneHint = SCENE_BREAK_CHOICES.find((c) => c.id === settings.sceneBreak)?.hint
return ( <section className="import-section studio-typesetting"> <h2>Typesetting</h2> <p className="import-hint"> How your markdown is read. These stay in this browser — they shape the records the studio writes, not the book itself, and you can change them between releases. </p>
<label className="studio-checkbox"> <input checked={settings.smartPunctuation} disabled={disabled} onChange={(e) => set('smartPunctuation', e.target.checked)} type="checkbox" /> <span>Smart punctuation — curly quotes, en and em dashes, ellipses</span> </label> <p className="import-hint"> Turning this on changes the text of every chapter you upload from now on. Chapters already published are left alone until you replace them. </p>
<label className="field"> <span>Chapter breaks</span> <select disabled={disabled} onChange={(e) => set('chapterStrategy', e.target.value as ConversionSettings['chapterStrategy'])} value={settings.chapterStrategy} > {STRATEGY_CHOICES.map((c) => ( <option key={c.id} value={c.id}> {c.label} </option> ))} </select> </label> <p className="import-hint"> The starting point for every file you pick. You can still override it per file below. </p>
<label className="field"> <span>Verse</span> <select disabled={disabled} onChange={(e) => set('verse', e.target.value as ConversionSettings['verse'])} value={settings.verse} > {VERSE_CHOICES.map((c) => ( <option key={c.id} value={c.id}> {c.label} </option> ))} </select> </label> {verseHint && <p className="import-hint">{verseHint}</p>}
<label className="field"> <span>Scene breaks</span> <select disabled={disabled} onChange={(e) => set('sceneBreak', e.target.value as ConversionSettings['sceneBreak'])} value={settings.sceneBreak} > {SCENE_BREAK_CHOICES.map((c) => ( <option key={c.id} value={c.id}> {c.label} </option> ))} </select> </label> {sceneHint && <p className="import-hint">{sceneHint}</p>} {ruleStrategyActive && ( <p className="studio-flag"> A file is splitting chapters on its thematic breaks, so those rules become chapter boundaries and never reach this setting. </p> )} </section> )}