Files
hopdown/dist/types.d.ts
T
2026-10-16 13:27:47 -07:00

32 lines
954 B
TypeScript

export type TokenRole = 'open' | 'close' | 'block';
export interface Token {
role: TokenRole;
value: string;
sequence?: string;
tag?: TagType;
groups?: {
[key: string]: string;
};
meta?: Record<string, string>;
}
export interface TagType {
element: string[];
opener: string[];
closer: string | null;
precedence: number;
isBlock: boolean;
showDelimitersInEditorNodes: boolean;
template: string;
pattern: RegExp | null;
tokenize(role: TokenRole, sequence: string, value: string): Token | null;
toHTML: (token: Token, callback: Function) => string;
toMarkdown: (element: HTMLElement, callback: Function) => string;
toEditorNode: (token: Token, callback: Function) => Node | null;
}
export interface TagCollectionType {
tags: Record<string, TagType>;
ordered: TagType[];
map: Map<string, TagType[]>;
getByElementName(element: string): TagType | undefined;
}