API Reference
SubtitleOptions
typescript
interface SubtitleOptions {
enabledModes: ("dev" | "build" | "export")[];
chunkMode: "sentence" | "line";
sentenceDelimiters: string[];
maxDisplayWidth: number;
}| Option | Type | Default | Description |
|---|---|---|---|
enabledModes | string[] | ['export'] | Reserved option (not currently used by built-in setup) |
chunkMode | string | 'sentence' | Subtitle chunking strategy |
sentenceDelimiters | string[] | ['.', '!', '?', '。', '!', '?', '…', '\\n'] | Delimiters used when chunkMode=sentence |
maxDisplayWidth | number | 80 | Word-based wrapping width (fullwidth=2) |
SubtitleEntry
typescript
interface SubtitleEntry {
start: number;
text: string;
}start: click index where this subtitle becomes activetext: subtitle text
defaultOptions
typescript
const defaultOptions: SubtitleOptions;parseNoteToSubtitleTimeline
typescript
function parseNoteToSubtitleTimeline(
note: string | undefined,
options?: Partial<SubtitleOptions>,
): SubtitleEntry[];Converts a note string into a click-driven subtitle timeline.
Parsing rules:
- Normalize CRLF to LF and trim
- Handle
[click],[click:n], and[subtitle:pause]markers - Split text by
chunkMode - Wrap long chunks by word units using display width (
fullwidth=2, combining marks=0) - Optimize wrapping for balanced chunk sizes
- Avoid tiny trailing one-word chunks when a small overflow merge is better
- Keep starts monotonic when marker values overlap or go backward
[subtitle:pause]flushes current buffer and advances cursor by 1, producing a click step with no subtitle
Built-in Setup Behavior
The packaged Slidev setup currently injects subtitles only in export mode:
setup/main.tsregistersSubtitleDisplaysetup/transformers.tsprepends<SubtitleDisplay />only when the slide has a note and mode isexport