tabletop-commander/types.d.ts

65 lines
1.3 KiB
TypeScript

type InlineToken = {
type: "text" | "bold" | "anchor" | "image" | "popover";
content: string;
data?: any;
uuid: string;
};
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;
uuid: string;
};
type Token = SingleLineToken | MultilineToken;
type MultilineCfg = {
rx: RegExp;
closeRx?: RegExp;
create: (tokens: Token[]) => SingleLineToken[];
replace: (line: string) => string;
};
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
type BlockToken = {
type: "block" | "grid" | "card" | "accordion";
metadata: any;
children: BlockChildren[];
parent?: string;
closed: boolean;
uuid: string;
};
type BlockChildren = ParagraphToken | BlockToken | SingleLineToken;
type ParagraphToken = {
content: SingleLineToken[];
allowsInline: boolean;
type: "p" | "code";
metadata: any;
closed: boolean;
uuid: string;
};