61 lines
1.2 KiB
TypeScript
61 lines
1.2 KiB
TypeScript
type InlineToken = {
|
|
type: "text" | "bold" | "anchor" | "image";
|
|
content: string;
|
|
data?: any;
|
|
};
|
|
|
|
type InlineTokenInsert = {
|
|
start: number;
|
|
end: number;
|
|
} & InlineToken;
|
|
|
|
type Line = string | InlineToken[];
|
|
|
|
type MultilineToken = {
|
|
type: "code" | "p";
|
|
lines: SingleLineToken[];
|
|
};
|
|
|
|
type SingleLineCfg = {
|
|
rx: RegExp;
|
|
create: (line: string) => SingleLineToken;
|
|
replaceRx: RegExp;
|
|
shouldMendNextLine?: boolean;
|
|
};
|
|
|
|
type SingleLineToken = {
|
|
type: "h1" | "h2" | "h3" | "text" | `list${number}`;
|
|
line: Line;
|
|
raw: string;
|
|
mends?: boolean;
|
|
cfg?: SingleLineCfg;
|
|
};
|
|
type Token = SingleLineToken | MultilineToken;
|
|
|
|
type MultilineCfg = {
|
|
rx: RegExp;
|
|
closeRx?: RegExp;
|
|
create: (tokens: Token[]) => SingleLineToken[];
|
|
replace: (line: string) => string;
|
|
};
|
|
|
|
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
|
|
type BlockToken = {
|
|
type: "block" | "grid" | "card";
|
|
metadata: any;
|
|
children: BlockChildren[];
|
|
parent?: string;
|
|
closed: boolean;
|
|
};
|
|
|
|
type BlockChildren = ParagraphToken | BlockToken | SingleLineToken;
|
|
|
|
type ParagraphToken = {
|
|
content: SingleLineToken[];
|
|
allowsInline: boolean;
|
|
type: "p" | "code";
|
|
metadata: any;
|
|
closed: boolean;
|
|
};
|