UNPKG

@textbus/core

Version:

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

58 lines (57 loc) 2.09 kB
import { Observable } from '@tanbo/stream'; import { State } from './types'; import { AsyncComponentLiteral, Component, ComponentConstructor, ComponentLiteral, ComponentStateLiteral } from './component'; import { AsyncSlotLiteral, ContentType, Slot, SlotJSON } from './slot'; import { FormatLiteral } from './format'; import { Textbus } from '../textbus'; export declare class AsyncModelLoader { onRequestLoad: Observable<void>; onLoaded: Observable<void>; get isLoaded(): boolean; private _loaded; private requestLoadEvent; private loadedEvent; constructor(); load(): void; markAsLoaded(): void; } export interface Metadata { [key: string]: any; } /** * 异步加载组件 * * metadata 用于记录子文档静态数据 */ export declare abstract class AsyncComponent<M extends Metadata = Metadata, T extends State = State> extends Component<T> { metadata: M; constructor(state: T, metadata: M); loader: AsyncModelLoader; toJSON(): AsyncComponentLiteral<State>; } export interface AsyncComponentConstructor<M extends Metadata = Metadata, T extends State = State> extends ComponentConstructor<T> { /** * 通过 JSON 创建组件实例 * @param textbus * @param data 组件状态字面量 * @param metadata 异步组件元数据 */ fromJSONAndMetadata?(textbus: Textbus, data: ComponentStateLiteral<T>, metadata: M): AsyncComponent<M, T>; } export declare class AsyncSlotJSON<T> extends SlotJSON implements AsyncSlotLiteral<T> { metadata: T; async: true; constructor(schema: ContentType[], content: Array<string | ComponentLiteral>, attributes: Record<string, any>, formats: FormatLiteral, metadata: T); } /** * 异步加载插槽 * * metadata 用于记录子文档静态数据 */ export declare class AsyncSlot<M extends Metadata = Metadata, U extends Record<string, any> = Record<string, any>> extends Slot { loader: AsyncModelLoader; readonly metadata: M; readonly data: U; constructor(schema: ContentType[], metadata: M, data?: U); toJSON(): AsyncSlotJSON<M>; }