1 | import { ExtendedType, Operation, Path, Point, PointEntry } from '..';
|
2 | import { RangeDirection } from '../types/types';
|
3 | /**
|
4 | * `Range` objects are a set of points that refer to a specific span of a Slate
|
5 | * document. They can define a span inside a single node or a can span across
|
6 | * multiple nodes.
|
7 | */
|
8 | export interface BaseRange {
|
9 | anchor: Point;
|
10 | focus: Point;
|
11 | }
|
12 | export type Range = ExtendedType<'Range', BaseRange>;
|
13 | export interface RangeEdgesOptions {
|
14 | reverse?: boolean;
|
15 | }
|
16 | export interface RangeTransformOptions {
|
17 | affinity?: RangeDirection | null;
|
18 | }
|
19 | export interface RangeInterface {
|
20 | /**
|
21 | * Get the start and end points of a range, in the order in which they appear
|
22 | * in the document.
|
23 | */
|
24 | edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
|
25 | /**
|
26 | * Get the end point of a range.
|
27 | */
|
28 | end: (range: Range) => Point;
|
29 | /**
|
30 | * Check if a range is exactly equal to another.
|
31 | */
|
32 | equals: (range: Range, another: Range) => boolean;
|
33 | /**
|
34 | * Check if a range includes a path, a point or part of another range.
|
35 | */
|
36 | includes: (range: Range, target: Path | Point | Range) => boolean;
|
37 | /**
|
38 | * Check if a range includes another range.
|
39 | */
|
40 | surrounds: (range: Range, target: Range) => boolean;
|
41 | /**
|
42 | * Get the intersection of a range with another.
|
43 | */
|
44 | intersection: (range: Range, another: Range) => Range | null;
|
45 | /**
|
46 | * Check if a range is backward, meaning that its anchor point appears in the
|
47 | * document _after_ its focus point.
|
48 | */
|
49 | isBackward: (range: Range) => boolean;
|
50 | /**
|
51 | * Check if a range is collapsed, meaning that both its anchor and focus
|
52 | * points refer to the exact same position in the document.
|
53 | */
|
54 | isCollapsed: (range: Range) => boolean;
|
55 | /**
|
56 | * Check if a range is expanded.
|
57 | *
|
58 | * This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
|
59 | */
|
60 | isExpanded: (range: Range) => boolean;
|
61 | /**
|
62 | * Check if a range is forward.
|
63 | *
|
64 | * This is the opposite of [[Range.isBackward]] and is provided for legibility.
|
65 | */
|
66 | isForward: (range: Range) => boolean;
|
67 | /**
|
68 | * Check if a value implements the [[Range]] interface.
|
69 | */
|
70 | isRange: (value: any) => value is Range;
|
71 | /**
|
72 | * Iterate through all of the point entries in a range.
|
73 | */
|
74 | points: (range: Range) => Generator<PointEntry, void, undefined>;
|
75 | /**
|
76 | * Get the start point of a range.
|
77 | */
|
78 | start: (range: Range) => Point;
|
79 | /**
|
80 | * Transform a range by an operation.
|
81 | */
|
82 | transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;
|
83 | }
|
84 | export declare const Range: RangeInterface;
|
85 | //# sourceMappingURL=range.d.ts.map |
\ | No newline at end of file |