WIP
This commit is contained in:
parent
8b097221db
commit
defe4e5759
@ -57,7 +57,7 @@ class Client {
|
|||||||
if (this.enabled && (e.shiftKey || e.which === 2)) {
|
if (this.enabled && (e.shiftKey || e.which === 2)) {
|
||||||
this.searchAt(this.lastMousePos);
|
this.searchAt(this.lastMousePos);
|
||||||
} else {
|
} else {
|
||||||
this.popup.hide();
|
this.hidePopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class Client {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lastRange !== null && this.lastRange.equalTo(range)) {
|
if (this.lastRange !== null && this.lastRange.equals(range)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,15 +110,13 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showPopup(range, length, content) {
|
showPopup(range, length, content) {
|
||||||
if (this.options.highlightText) {
|
this.popup.showNextTo(range, content);
|
||||||
range.setEnd(range.endContainer, range.startOffset + length);
|
|
||||||
|
|
||||||
const selection = window.getSelection();
|
if (this.options.highlightText) {
|
||||||
selection.removeAllRanges();
|
this.range.select(length);
|
||||||
selection.addRange(range);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.popup.showNextTo(range, content);
|
this.lastRange = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
hidePopup() {
|
hidePopup() {
|
||||||
|
@ -67,10 +67,10 @@ class Range {
|
|||||||
|
|
||||||
deselect() {
|
deselect() {
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
selection.removeRange(this.range);
|
selection.removeAllRanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
equalTo(range) {
|
equals(range) {
|
||||||
const equal =
|
const equal =
|
||||||
range.compareBoundaryPoints(Range.END_TO_END, this.range) === 0 &&
|
range.compareBoundaryPoints(Range.END_TO_END, this.range) === 0 &&
|
||||||
range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
|
range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user