@wangeditor-next/yjs-for-react
Version:
React specific components/utils for wangeditor-next-yjs.
45 lines (44 loc) • 1.86 kB
TypeScript
/**
* @description to-html entry
* @author wangfupeng
*/
import { Descendant, Element as SlateElement } from 'slate';
import { IDomEditor } from '../editor/interface';
import type { INodeToHtmlOptions } from './node2html';
export type styleToHtmlFnType = (node: Descendant, elemHtml: string, editor?: IDomEditor) => string;
export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
/**
* 注册 toHtml 处理文本样式的函数
* @param fn 处理 toHtml 文本样式的函数
*/
export declare function registerStyleToHtmlHandler(fn: styleToHtmlFnType): void;
/**
* Transform the HTML fragments of the document's top-level nodes.
*
* Element serializers intentionally stay node-local. Modules that need
* neighboring blocks to produce valid HTML (for example semantic lists) use
* this hook after every node has been serialized.
*/
export type HtmlTransformFnType = (htmlList: string[], nodes: Descendant[], editor: IDomEditor, options: INodeToHtmlOptions) => string[];
export declare const HTML_TRANSFORM_HANDLER_LIST: HtmlTransformFnType[];
export declare function registerHtmlTransformHandler(fn: HtmlTransformFnType): void;
export declare function transformHtml(htmlList: string[], nodes: Descendant[], editor: IDomEditor, options?: INodeToHtmlOptions): string[];
interface IElemToHtmlRes {
html: string;
prefix?: string;
suffix?: string;
}
export type ElemToHtmlFnType = (elemNode: SlateElement, childrenHtml: string, editor?: IDomEditor) => string | IElemToHtmlRes;
export declare const ELEM_TO_HTML_CONF: {
[key: string]: ElemToHtmlFnType;
};
export interface IElemToHtmlConf {
type: string;
elemToHtml: ElemToHtmlFnType;
}
/**
* 注册 elem to html 函数
* @param conf { type, elemToHtml } ,type 即 node.type
*/
export declare function registerElemToHtmlConf(conf: IElemToHtmlConf): void;
export {};