@textbus/core
Version:
Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.
61 lines (60 loc) • 2.34 kB
TypeScript
import { Observable } from '@tanbo/stream';
import { State } from './types';
import { AsyncComponentLiteral, Component, ComponentConstructor, ComponentLiteral, ComponentStateLiteral } from './component';
import { ContentType, Slot, SlotJSON, SlotLiteral } 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 interface AsyncSlotLiteral<T extends Record<string, any> = Record<string, any>, U = any> extends SlotLiteral<T> {
async: true;
metadata: U;
}
export declare class AsyncSlotJSON<T extends Record<string, any>, U extends Record<string, any> = Record<string, any>> extends SlotJSON<T> implements AsyncSlotLiteral<T, U> {
metadata: U;
async: true;
constructor(schema: ContentType[], content: Array<string | ComponentLiteral>, attributes: Record<string, any>, formats: FormatLiteral, state: T, metadata: U);
}
/**
* 异步加载插槽
*
* metadata 用于记录子文档静态数据
*/
export declare class AsyncSlot<U extends Record<string, any> = Record<string, any>, M extends Metadata = Metadata> extends Slot<U> {
loader: AsyncModelLoader;
readonly metadata: M;
constructor(schema: ContentType[], state: U | undefined, metadata: M);
toJSON(): AsyncSlotJSON<U, M>;
}