Support looking up image tags
This commit is contained in:
parent
a889e1ffaa
commit
a72e958ebf
@ -108,7 +108,7 @@ class Client {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.lastTextSource !== null && this.lastTextSource.compareOrigin(textSource) === 0) {
|
||||
if (this.lastTextSource !== null && this.lastTextSource.equals(textSource)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -17,40 +17,43 @@
|
||||
*/
|
||||
|
||||
|
||||
class Image {
|
||||
class ImageSource {
|
||||
constructor(image) {
|
||||
|
||||
this.img = image;
|
||||
this.length = -1;
|
||||
}
|
||||
|
||||
text() {
|
||||
const text = this.textRaw();
|
||||
return this.length < 0 ? text : text.substring(0, this.length);
|
||||
}
|
||||
|
||||
textRaw() {
|
||||
return this.img.getAttribute('alt') || '';
|
||||
}
|
||||
|
||||
setLength(length) {
|
||||
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
containsPoint(point) {
|
||||
|
||||
const rect = this.getRect();
|
||||
return point.x >= rect.left && point.x <= rect.right;
|
||||
}
|
||||
|
||||
getRect() {
|
||||
|
||||
}
|
||||
|
||||
getPaddedRect() {
|
||||
|
||||
return this.img.getBoundingClientRect();
|
||||
}
|
||||
|
||||
select() {
|
||||
|
||||
// NOP
|
||||
}
|
||||
|
||||
deselect() {
|
||||
|
||||
// NOP
|
||||
}
|
||||
|
||||
compareOrigin(range) {
|
||||
|
||||
equals(other) {
|
||||
return other.img && other.textRaw() == this.textRaw();
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ class RangeSource {
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
|
||||
compareOrigin(range) {
|
||||
return range.rng.compareBoundaryPoints(Range.START_TO_START, this.rng);
|
||||
equals(other) {
|
||||
return other.rng && other.rng.compareBoundaryPoints(Range.START_TO_START, this.rng) == 0;
|
||||
}
|
||||
|
||||
static seekEnd(node, length) {
|
||||
|
Loading…
Reference in New Issue
Block a user