UNPKG

2.25 kBTypeScriptView Raw
1import Emitter from './emitter.js';
2import type { EmitterSource } from './emitter.js';
3import type Cursor from '../blots/cursor.js';
4import type Scroll from '../blots/scroll.js';
5type NativeRange = AbstractRange;
6interface NormalizedRange {
7 start: {
8 node: NativeRange['startContainer'];
9 offset: NativeRange['startOffset'];
10 };
11 end: {
12 node: NativeRange['endContainer'];
13 offset: NativeRange['endOffset'];
14 };
15 native: NativeRange;
16}
17export interface Bounds {
18 bottom: number;
19 height: number;
20 left: number;
21 right: number;
22 top: number;
23 width: number;
24}
25export declare class Range {
26 index: number;
27 length: number;
28 constructor(index: number, length?: number);
29}
30declare class Selection {
31 scroll: Scroll;
32 emitter: Emitter;
33 composing: boolean;
34 mouseDown: boolean;
35 root: HTMLElement;
36 cursor: Cursor;
37 savedRange: Range;
38 lastRange: Range | null;
39 lastNative: NormalizedRange | null;
40 constructor(scroll: Scroll, emitter: Emitter);
41 handleComposition(): void;
42 handleDragging(): void;
43 focus(): void;
44 format(format: string, value: unknown): void;
45 getBounds(index: number, length?: number): DOMRect | {
46 bottom: number;
47 height: number;
48 left: number;
49 right: number;
50 top: number;
51 width: number;
52 } | null;
53 getNativeRange(): NormalizedRange | null;
54 getRange(): [Range, NormalizedRange] | [null, null];
55 hasFocus(): boolean;
56 normalizedToRange(range: NormalizedRange): Range;
57 normalizeNative(nativeRange: NativeRange): {
58 start: {
59 node: Node;
60 offset: number;
61 };
62 end: {
63 node: Node;
64 offset: number;
65 };
66 native: AbstractRange;
67 } | null;
68 rangeToNative(range: Range): [Node | null, number, Node | null, number];
69 setNativeRange(startNode: Node | null, startOffset?: number, endNode?: Node | null, endOffset?: number | undefined, force?: boolean): void;
70 setRange(range: Range | null, force: boolean, source?: EmitterSource): void;
71 setRange(range: Range | null, source?: EmitterSource): void;
72 update(source?: EmitterSource): void;
73}
74export default Selection;