UNPKG

@textbus/core

Version:

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

62 lines (61 loc) 2.34 kB
import { Attribute, ComponentConstructor, Component, ComponentLiteral, Formatter, Slot, SlotLiteral, AsyncSlotLiteral, AsyncSlot, AsyncComponentLiteral, AsyncComponentConstructor, AsyncComponent, Metadata } from '../model/_api'; import { Textbus } from '../textbus'; /** * 注册表 * 用于缓存一个 Textbus 实例内可用的 Component、Formatter、Attribute。 * Registry 也可以根据数据创建组件或插槽的实例 */ export declare class Registry { textbus: Textbus; private componentMap; private formatMap; private attributeMap; constructor(textbus: Textbus, components: ComponentConstructor[], attributes: Attribute<any>[], formatters: Formatter<any>[]); /** * 根据组件名获取组件 * @param name 组件名 */ getComponent(name: string): ComponentConstructor<import("../model/types").State> | null; /** * 根据格式名获取格式 * @param name 格式名 */ getFormatter(name: string): Formatter<any> | null; /** * 根据名字获取 Attribute 实例 * @param name */ getAttribute(name: string): Attribute<any> | null; /** * 根据组件名和数据创建组件 * @param name * @param data * @param metadata 异步组件元数据 */ createComponentByData(name: string, data: any, metadata?: Metadata): Component<import("../model/types").State> | null; /** * 根据插槽数据生成插槽实例 * @param slotLiteral */ createSlot(slotLiteral: AsyncSlotLiteral): AsyncSlot; createSlot(slotLiteral: SlotLiteral): Slot; /** * 根据组件数据生成组件实例 * @param componentLiteral */ createComponent(componentLiteral: ComponentLiteral | AsyncComponentLiteral): Component | AsyncComponent | null; /** * 指定组件创建实例 * @param componentLiteral * @param factory */ createComponentByFactory(componentLiteral: ComponentLiteral, factory: ComponentConstructor): Component; createComponentByFactory(componentLiteral: AsyncComponentLiteral, factory: AsyncComponentConstructor): AsyncComponent; /** * 将插槽数据填充到指定的插槽 * @param source * @param target */ fillSlot<T extends SlotLiteral, U extends Slot>(source: T, target: U): U; private loadSlot; }