1 | import { Range } from '..';
|
2 | import { ExtendedType } from '../types/custom-types';
|
3 | /**
|
4 | * `Text` objects represent the nodes that contain the actual text content of a
|
5 | * Slate document along with any formatting properties. They are always leaf
|
6 | * nodes in the document tree as they cannot contain any children.
|
7 | */
|
8 | export interface BaseText {
|
9 | text: string;
|
10 | }
|
11 | export type Text = ExtendedType<'Text', BaseText>;
|
12 | export interface TextEqualsOptions {
|
13 | loose?: boolean;
|
14 | }
|
15 | export type DecoratedRange = Range & {
|
16 | /**
|
17 | * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.
|
18 | * It is useful for overlapping decorations with the same key but different values.
|
19 | */
|
20 | merge?: (leaf: Text, decoration: object) => void;
|
21 | };
|
22 | export interface TextInterface {
|
23 | /**
|
24 | * Check if two text nodes are equal.
|
25 | *
|
26 | * When loose is set, the text is not compared. This is
|
27 | * used to check whether sibling text nodes can be merged.
|
28 | */
|
29 | equals: (text: Text, another: Text, options?: TextEqualsOptions) => boolean;
|
30 | /**
|
31 | * Check if a value implements the `Text` interface.
|
32 | */
|
33 | isText: (value: any) => value is Text;
|
34 | /**
|
35 | * Check if a value is a list of `Text` objects.
|
36 | */
|
37 | isTextList: (value: any) => value is Text[];
|
38 | /**
|
39 | * Check if some props are a partial of Text.
|
40 | */
|
41 | isTextProps: (props: any) => props is Partial<Text>;
|
42 | /**
|
43 | * Check if an text matches set of properties.
|
44 | *
|
45 | * Note: this is for matching custom properties, and it does not ensure that
|
46 | * the `text` property are two nodes equal.
|
47 | */
|
48 | matches: (text: Text, props: Partial<Text>) => boolean;
|
49 | /**
|
50 | * Get the leaves for a text node given decorations.
|
51 | */
|
52 | decorations: (node: Text, decorations: DecoratedRange[]) => Text[];
|
53 | }
|
54 | export declare const Text: TextInterface;
|
55 | //# sourceMappingURL=text.d.ts.map |
\ | No newline at end of file |