UNPKG

1.27 kBTypeScriptView Raw
1export declare const FOLD_FLOW = "flow";
2export declare const FOLD_BLOCK = "block";
3export declare const FOLD_QUOTED = "quoted";
4/**
5 * `'block'` prevents more-indented lines from being folded;
6 * `'quoted'` allows for `\` escapes, including escaped newlines
7 */
8export type FoldMode = 'flow' | 'block' | 'quoted';
9export interface FoldOptions {
10 /**
11 * Accounts for leading contents on the first line, defaulting to
12 * `indent.length`
13 */
14 indentAtStart?: number;
15 /** Default: `80` */
16 lineWidth?: number;
17 /**
18 * Allow highly indented lines to stretch the line width or indent content
19 * from the start.
20 *
21 * Default: `20`
22 */
23 minContentWidth?: number;
24 /** Called once if the text is folded */
25 onFold?: () => void;
26 /** Called once if any line of text exceeds lineWidth characters */
27 onOverflow?: () => void;
28}
29/**
30 * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
31 * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
32 * terminated with `\n` and started with `indent`.
33 */
34export declare function foldFlowLines(text: string, indent: string, mode?: FoldMode, { indentAtStart, lineWidth, minContentWidth, onFold, onOverflow }?: FoldOptions): string;