UNPKG

slate-hyperscript

Version:

A hyperscript helper for creating Slate documents.

37 lines • 1.76 kB
import { createAnchor, createCursor, createElement, createFocus, createFragment, createPoint, createSelection, createText } from './creators'; /** * `HyperscriptCreators` are dictionaries of `HyperscriptCreator` functions * keyed by tag name. */ type HyperscriptCreators<T = any> = Record<string, (tagName: string, attributes: { [key: string]: any; }, children: any[]) => T>; /** * `HyperscriptShorthands` are dictionaries of properties applied to specific * kind of object, keyed by tag name. They allow you to easily define custom * hyperscript tags for your domain. */ type HyperscriptShorthands = Record<string, Record<string, any>>; /** * Create a Slate hyperscript function with `options`. */ declare const createHyperscript: <E extends HyperscriptShorthands = {}, C extends HyperscriptCreators = {}>(options?: { creators?: C | undefined; elements?: E | undefined; }) => <S extends (keyof E | "anchor" | "cursor" | "editor" | "element" | "focus" | "fragment" | "point" | "selection" | "text" | keyof C) & string>(tagName: Function | S, attributes?: Object, ...children: any[]) => ReturnType<({ anchor: typeof createAnchor; cursor: typeof createCursor; editor: (tagName: string, attributes: { [key: string]: any; }, children: any[]) => import("slate").Editor; element: typeof createElement; focus: typeof createFocus; fragment: typeof createFragment; point: typeof createPoint; selection: typeof createSelection; text: typeof createText; } & Record<keyof E, (tagName: string, attributes: { [key: string]: any; }, children: any[]) => import("slate").BaseElement> & C)[S]>; export { createHyperscript, HyperscriptCreators, HyperscriptShorthands }; //# sourceMappingURL=hyperscript.d.ts.map