import { AstNode } from './node'; import type { TokenTypes, LintError } from '../base'; import type { ElementLike } from '../mixin/elementLike'; import type { AstNodes, Token } from '../internal'; export interface CaretPosition { readonly offsetNode: AstNodes; readonly offset: number; } export interface AstElement extends AstNode, ElementLike { } /** * HTMLElement-like * * 类似HTMLElement */ export declare abstract class AstElement extends AstNode { readonly name?: string; readonly data: undefined; /** number of child nodes / 子节点总数 */ get length(): number; /** * Remove a child node * * 移除子节点 * @param i position of the child node / 移除位置 */ removeAt(i: number): AstNodes; /** * Insert a child node * * 插入子节点 * @param node node to be inserted / 待插入的子节点 * @param i position to be inserted at / 插入位置 */ insertAt(node: T, i?: number): T; /** * Insert a batch of child nodes at the end * * 在末尾批量插入子节点 * @param elements nodes to be inserted / 插入节点 */ append(...elements: (AstNodes | string)[]): void; /** * Modify the text child node * * 修改文本子节点 * @param str new text / 新文本 * @param i position of the text child node / 子节点位置 */ setText(str: string, i?: number): string; /** * Get the caret position from the character index * * 找到给定位置 * @param index character index / 位置 */ caretPositionFromIndex(index?: number): CaretPosition | undefined; /** * Get the closest ancestor element from the character index * * 找到给定位置所在的最内层非文本节点 * @param index character index / 位置 */ elementFromIndex(index?: number): Token | undefined; /** * Get the closest ancestor element from the position * * 找到给定位置所在的最内层非文本节点 * @param x column number / 列数 * @param y line number / 行数 */ elementFromPoint(x: number, y: number): Token | undefined; }