UNPKG

@textbus/core

Version:

Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.

42 lines (41 loc) 1.34 kB
import { Slot } from './slot'; import { Component } from './component'; /** * Textbus 虚拟 DOM 文本节点 */ export declare class VTextNode { textContent: string; location: NodeLocation | null; constructor(textContent?: string); } export interface VElementListeners { [listenKey: string]: <T extends Event>(ev: T) => any; } export type VChildNode = VElement | VTextNode | Component | string | number | boolean | null | undefined; /** * 虚拟 DOM 节点在数据内的范围 */ export interface NodeLocation { startIndex: number; endIndex: number; slot: Slot; } export declare function createVNode(tagName: string, attrs?: Record<string, any> | null, children?: VChildNode[]): VElement; /** * Textbus 虚拟 DOM 元素节点 */ export declare class VElement { tagName: string; children: Array<VElement | VTextNode | Component>; location: NodeLocation | null; readonly attrs: Map<string, any>; readonly styles: Map<string, string | number>; readonly classes: Set<string>; readonly listeners: VElementListeners; constructor(tagName: string, attrs?: Record<string, any> | null, children?: VChildNode[]); /** * 在最后位置添加一个子节点。 * @param newNodes */ appendChild(...newNodes: Array<VElement | VTextNode | Component>): void; }