UNPKG

1.71 kBTypeScriptView Raw
1import { Ancestor, Descendant, ExtendedType, Path } from '..';
2/**
3 * `Element` objects are a type of node in a Slate document that contain other
4 * element nodes or text nodes. They can be either "blocks" or "inlines"
5 * depending on the Slate editor's configuration.
6 */
7export interface BaseElement {
8 children: Descendant[];
9}
10export type Element = ExtendedType<'Element', BaseElement>;
11export interface ElementInterface {
12 /**
13 * Check if a value implements the 'Ancestor' interface.
14 */
15 isAncestor: (value: any) => value is Ancestor;
16 /**
17 * Check if a value implements the `Element` interface.
18 */
19 isElement: (value: any) => value is Element;
20 /**
21 * Check if a value is an array of `Element` objects.
22 */
23 isElementList: (value: any) => value is Element[];
24 /**
25 * Check if a set of props is a partial of Element.
26 */
27 isElementProps: (props: any) => props is Partial<Element>;
28 /**
29 * Check if a value implements the `Element` interface and has elementKey with selected value.
30 * Default it check to `type` key value
31 */
32 isElementType: <T extends Element>(value: any, elementVal: string, elementKey?: string) => value is T;
33 /**
34 * Check if an element matches set of properties.
35 *
36 * Note: this checks custom properties, and it does not ensure that any
37 * children are equivalent.
38 */
39 matches: (element: Element, props: Partial<Element>) => boolean;
40}
41export declare const Element: ElementInterface;
42/**
43 * `ElementEntry` objects refer to an `Element` and the `Path` where it can be
44 * found inside a root node.
45 */
46export type ElementEntry = [Element, Path];
47//# sourceMappingURL=element.d.ts.map
\No newline at end of file