UNPKG

1.67 kBTypeScriptView Raw
1import { ExtendedType, Operation, Path } from '..';
2import { TextDirection } from '../types/types';
3/**
4 * `Point` objects refer to a specific location in a text node in a Slate
5 * document. Its path refers to the location of the node in the tree, and its
6 * offset refers to the distance into the node's string of text. Points can
7 * only refer to `Text` nodes.
8 */
9export interface BasePoint {
10 path: Path;
11 offset: number;
12}
13export type Point = ExtendedType<'Point', BasePoint>;
14export interface PointTransformOptions {
15 affinity?: TextDirection | null;
16}
17export interface PointInterface {
18 /**
19 * Compare a point to another, returning an integer indicating whether the
20 * point was before, at, or after the other.
21 */
22 compare: (point: Point, another: Point) => -1 | 0 | 1;
23 /**
24 * Check if a point is after another.
25 */
26 isAfter: (point: Point, another: Point) => boolean;
27 /**
28 * Check if a point is before another.
29 */
30 isBefore: (point: Point, another: Point) => boolean;
31 /**
32 * Check if a point is exactly equal to another.
33 */
34 equals: (point: Point, another: Point) => boolean;
35 /**
36 * Check if a value implements the `Point` interface.
37 */
38 isPoint: (value: any) => value is Point;
39 /**
40 * Transform a point by an operation.
41 */
42 transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;
43}
44export declare const Point: PointInterface;
45/**
46 * `PointEntry` objects are returned when iterating over `Point` objects that
47 * belong to a range.
48 */
49export type PointEntry = [Point, 'anchor' | 'focus'];
50//# sourceMappingURL=point.d.ts.map
\No newline at end of file