export type TokenRole = 'open' | 'close' | 'block'; export interface Token { role: TokenRole; value: string; sequence?: string; tag?: TagType; groups?: { [key: string]: string; }; /** For link tokens: the href and optional title. */ href?: string; title?: string; meta?: Record; } /** * A Tag is the core abstraction: it knows how to match markdown syntax, * convert it to HTML, and convert the HTML back to markdown. Tags are * registered by HTML selector (e.g. 'STRONG,B') so the converter can * look them up during HTML→markdown conversion. */ export interface TagType { element: string[]; opener: string[]; closer: string | null; precedence: number; isBlock: boolean; template?: string; pattern?: RegExp | null; showDelimitersInEditorNodes?: boolean; aliases?: string[]; 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; ordered: TagType[]; map: Map; getByElementName(element: string): TagType | undefined; }