tabletop-commander/types.d.ts

90 lines
1.6 KiB
TypeScript

type InlineToken = {
type:
| "text"
| "bold"
| "anchor"
| "image"
| "popover"
| "italic"
| "inline-code";
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 = {
type: string;
metadata: Record<string, string>;
parent?: Token;
children?: Token[];
uuid: string;
raw: string;
content: string;
rendersChildrenOnly?: boolean;
rendersContentOnly?: boolean;
};
type tokenMarker = {
start: number;
end: number;
type: string;
parent?: tokenMarker;
token?: Token;
};
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;
};