TextSource* API update (#1255)
* Add collapse function to TextSource* * Add isConnected getter to TextSource*
This commit is contained in:
parent
d89f23261c
commit
5c57015a79
@ -40,6 +40,10 @@ class TextSourceElement {
|
|||||||
return this._endOffset;
|
return this._endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isConnected() {
|
||||||
|
return this._element.isConnected;
|
||||||
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
return new TextSourceElement(this._element, this._fullContent, this._startOffset, this._endOffset);
|
return new TextSourceElement(this._element, this._fullContent, this._startOffset, this._endOffset);
|
||||||
}
|
}
|
||||||
@ -73,6 +77,15 @@ class TextSourceElement {
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse(toStart) {
|
||||||
|
if (toStart) {
|
||||||
|
this._endOffset = this._startOffset;
|
||||||
|
} else {
|
||||||
|
this._startOffset = this._endOffset;
|
||||||
|
}
|
||||||
|
this._content = '';
|
||||||
|
}
|
||||||
|
|
||||||
getRect() {
|
getRect() {
|
||||||
return this._element.getBoundingClientRect();
|
return this._element.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,13 @@ class TextSourceRange {
|
|||||||
return this._imposterSourceElement;
|
return this._imposterSourceElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isConnected() {
|
||||||
|
return (
|
||||||
|
this._range.startContainer.isConnected &&
|
||||||
|
this._range.endContainer.isConnected
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
return new TextSourceRange(this._range.cloneRange(), this._content, this._imposterContainer, this._imposterSourceElement);
|
return new TextSourceRange(this._range.cloneRange(), this._content, this._imposterContainer, this._imposterSourceElement);
|
||||||
}
|
}
|
||||||
@ -74,6 +81,11 @@ class TextSourceRange {
|
|||||||
return length - state.remainder;
|
return length - state.remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse(toStart) {
|
||||||
|
this._range.collapse(toStart);
|
||||||
|
this._content = '';
|
||||||
|
}
|
||||||
|
|
||||||
getRect() {
|
getRect() {
|
||||||
return this._range.getBoundingClientRect();
|
return this._range.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user