summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-16 21:50:50 -0500
committerGitHub <noreply@github.com>2021-01-16 21:50:50 -0500
commit5c57015a79a79805638c6a97d13784372587e4f2 (patch)
tree210cb45e14bb059523fcb02b00f7303b269e7072 /ext/fg
parentd89f23261cd619a406d4d50006871b10f1e653c6 (diff)
TextSource* API update (#1255)
* Add collapse function to TextSource* * Add isConnected getter to TextSource*
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/text-source-element.js13
-rw-r--r--ext/fg/js/text-source-range.js12
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/fg/js/text-source-element.js b/ext/fg/js/text-source-element.js
index a0e1254f..43526060 100644
--- a/ext/fg/js/text-source-element.js
+++ b/ext/fg/js/text-source-element.js
@@ -40,6 +40,10 @@ class TextSourceElement {
return this._endOffset;
}
+ get isConnected() {
+ return this._element.isConnected;
+ }
+
clone() {
return new TextSourceElement(this._element, this._fullContent, this._startOffset, this._endOffset);
}
@@ -73,6 +77,15 @@ class TextSourceElement {
return delta;
}
+ collapse(toStart) {
+ if (toStart) {
+ this._endOffset = this._startOffset;
+ } else {
+ this._startOffset = this._endOffset;
+ }
+ this._content = '';
+ }
+
getRect() {
return this._element.getBoundingClientRect();
}
diff --git a/ext/fg/js/text-source-range.js b/ext/fg/js/text-source-range.js
index 60086e7f..377016da 100644
--- a/ext/fg/js/text-source-range.js
+++ b/ext/fg/js/text-source-range.js
@@ -41,6 +41,13 @@ class TextSourceRange {
return this._imposterSourceElement;
}
+ get isConnected() {
+ return (
+ this._range.startContainer.isConnected &&
+ this._range.endContainer.isConnected
+ );
+ }
+
clone() {
return new TextSourceRange(this._range.cloneRange(), this._content, this._imposterContainer, this._imposterSourceElement);
}
@@ -74,6 +81,11 @@ class TextSourceRange {
return length - state.remainder;
}
+ collapse(toStart) {
+ this._range.collapse(toStart);
+ this._content = '';
+ }
+
getRect() {
return this._range.getBoundingClientRect();
}