/
Range.ts
94 lines (85 loc) · 2.63 KB
/
Range.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import INode from '../nodes/node/INode';
import IDocument from '../nodes/document/IDocument';
import IDocumentFragment from '../nodes/document-fragment/IDocumentFragment';
/**
* Range.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/API/Range.
*/
export default class Range {
public static _ownerDocument: IDocument = null;
public readonly startOffset: number = 0;
public readonly endOffset: number = 0;
public readonly startContainer: INode = null;
public readonly endContainer: INode = null;
/**
* Constructor.
*/
constructor() {
this.startContainer = (<typeof Range>this.constructor)._ownerDocument;
this.endContainer = (<typeof Range>this.constructor)._ownerDocument;
}
/**
* Returns a boolean value indicating whether the range's start and end points are at the same position.
*
* @returns Collapsed.
*/
public get collapsed(): boolean {
return this.startContainer === this.endContainer && this.startOffset === this.endOffset;
}
/**
* Returns the deepest Node that contains the startContainer and endContainer nodes.
*
* @returns Node.
*/
public get commonAncestorContainer(): INode {
// TODO: Implement
return null;
}
/**
* Returns -1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the Range.
*
* @param _referenceNode Reference node.
* @param [_offset=0] Offset.
* @returns -1,0, or 1.
*/
public comparePoint(_referenceNode: INode, _offset = 0): number {
// TODO: Implement
return 0;
}
/**
* Returns a DocumentFragment copying the objects of type Node included in the Range.
*
* @returns Document fragment.
*/
public cloneContents(): IDocumentFragment {
// TODO: Implement
return null;
}
/**
* Returns a Range object with boundary points identical to the cloned Range.
*
* @returns Range.
*/
public cloneRange(): Range {
// TODO: Implement
return null;
}
/**
* Returns a DocumentFragment by invoking the HTML fragment parsing algorithm or the XML fragment parsing algorithm with the start of the range (the parent of the selected node) as the context node. The HTML fragment parsing algorithm is used if the range belongs to a Document whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead.
*
* @param _tagString Tag string.
* @returns Document fragment.
*/
public createContextualFragment(_tagString: string): IDocumentFragment {
// TODO: Implement
return null;
}
/**
* Returns string currently being represented by the selection object.
*/
public toString(): string {
return '';
}
}