import type { AstNode as AstNodeBase, TokenTypes, LintError } from '../base'; import type { NodeLike } from '../mixin/nodeLike'; import type { AstText, Token } from '../internal'; import type { TokenTypeMap, SelectedTokenTypes } from '../map'; export type AstNodes = AstText | Token; export interface Dimension { readonly height: number; readonly width: number; } export interface Position { readonly top: number; readonly left: number; } export interface Font { bold: boolean; italic: boolean; } export interface AstNode extends NodeLike { } /** * Node-like * * 类似Node */ export declare abstract class AstNode implements AstNodeBase { #private; data?: string | undefined; readonly childNodes: readonly AstNodes[]; abstract get type(): TokenTypes | 'text'; abstract set type(value: TokenTypes | "text"); /** * Get the visible text * * 可见部分 */ text(): string; lint(): LintError[] & { output?: string; }; /** parent node / 父节点 */ get parentNode(): Token | undefined; /** next sibling node / 后一个兄弟节点 */ get nextSibling(): AstNodes | undefined; /** previous sibling node / 前一个兄弟节点 */ get previousSibling(): AstNodes | undefined; /** * Get the root node * * 获取根节点 */ getRootNode(): Token | this; /** * Convert the position to the character index * * 将行列号转换为字符位置 * @param top line number / 行号 * @param left column number / 列号 */ indexFromPos(top: number, left: number): number | undefined; /** * Convert the character indenx to the position * * 将字符位置转换为行列号 * @param index character index / 字符位置 */ posFromIndex(index: number): Position | undefined; /** * Get the relative character index of the current node, or its `j`-th child node * * 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置 * @param j rank of the child node / 子节点序号 */ getRelativeIndex(j?: number): number; /** * Get the absolute character index of the current node * * 获取当前节点的绝对位置 */ getAbsoluteIndex(): number; /** * Get the position and dimension of the current node * * 获取当前节点的行列位置和大小 */ getBoundingClientRect(): Dimension & Position; /** * Whether to be of a certain type * * 是否是某种类型的节点 * @param type token type / 节点类型 * @since v1.10.0 */ is(type: K): this is TokenTypeMap[K]; is(type: TokenTypes): this is T; /** * Get the text and the start/end positions of all lines * * 获取所有行的wikitext和起止位置 * @since v1.16.3 */ getLines(): [string, number, number][]; }