summaryrefslogtreecommitdiff
path: root/ext/fg/js/range.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/range.js')
-rw-r--r--ext/fg/js/range.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/fg/js/range.js b/ext/fg/js/range.js
index 819bbfd8..18c0d6bb 100644
--- a/ext/fg/js/range.js
+++ b/ext/fg/js/range.js
@@ -39,6 +39,11 @@ class Range {
return length;
}
+ containsPoint(point) {
+ const rect = this.paddedRect();
+ return point.x >= rect.left && point.x <= rect.right;
+ }
+
paddedRect() {
const node = this.range.startContainer;
const startOffset = this.range.startOffset;
@@ -53,7 +58,7 @@ class Range {
return rect;
}
- static fromPoint(point) {
+ static fromPos(point) {
const range = document.caretRangeFromPoint(point.x, point.y);
return range === null ? null : new Range(range);
}