Button and image scanning (#705)
* Update TextSourceElement.equals check to match TextSourceRange.equals * Force full query to be visible when scanning buttons or images with more text * Update style of query parser
This commit is contained in:
parent
bdcdf9b1f5
commit
1184320e3e
@ -20,6 +20,7 @@
|
|||||||
* FrameOffsetForwarder
|
* FrameOffsetForwarder
|
||||||
* PopupProxy
|
* PopupProxy
|
||||||
* TextScanner
|
* TextScanner
|
||||||
|
* TextSourceElement
|
||||||
* api
|
* api
|
||||||
* docSentenceExtract
|
* docSentenceExtract
|
||||||
*/
|
*/
|
||||||
@ -423,15 +424,13 @@ class Frontend {
|
|||||||
const sentenceExtent = this._options.anki.sentenceExt;
|
const sentenceExtent = this._options.anki.sentenceExt;
|
||||||
const layoutAwareScan = this._options.scanning.layoutAwareScan;
|
const layoutAwareScan = this._options.scanning.layoutAwareScan;
|
||||||
const sentence = docSentenceExtract(textSource, sentenceExtent, layoutAwareScan);
|
const sentence = docSentenceExtract(textSource, sentenceExtent, layoutAwareScan);
|
||||||
this._showPopupContent(
|
const query = textSource.text();
|
||||||
textSource,
|
const details = {
|
||||||
optionsContext,
|
|
||||||
{
|
|
||||||
focus,
|
focus,
|
||||||
history: false,
|
history: false,
|
||||||
params: {
|
params: {
|
||||||
type,
|
type,
|
||||||
query: textSource.text(),
|
query,
|
||||||
wildcards: 'off'
|
wildcards: 'off'
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
@ -442,8 +441,12 @@ class Frontend {
|
|||||||
content: {
|
content: {
|
||||||
definitions
|
definitions
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if (textSource instanceof TextSourceElement && textSource.fullContent !== query) {
|
||||||
|
details.params.full = textSource.fullContent;
|
||||||
|
details.params['full-visible'] = 'true';
|
||||||
}
|
}
|
||||||
);
|
this._showPopupContent(textSource, optionsContext, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
_showPopupContent(textSource, optionsContext, details=null) {
|
_showPopupContent(textSource, optionsContext, details=null) {
|
||||||
|
@ -32,6 +32,14 @@ class TextSourceRange {
|
|||||||
this.imposterSourceElement = imposterSourceElement;
|
this.imposterSourceElement = imposterSourceElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get startOffset() {
|
||||||
|
return this.range.startOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
get endOffset() {
|
||||||
|
return this.range.endOffset;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -230,8 +238,7 @@ class TextSourceElement {
|
|||||||
other instanceof TextSourceElement &&
|
other instanceof TextSourceElement &&
|
||||||
this._element === other.element &&
|
this._element === other.element &&
|
||||||
this._fullContent === other.fullContent &&
|
this._fullContent === other.fullContent &&
|
||||||
this._startOffset === other.startOffset &&
|
this._startOffset === other.startOffset
|
||||||
this._endOffset === other.endOffset
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +217,12 @@ h2 {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root[data-yomichan-page=float] #query-parser-container {
|
||||||
|
padding-left: 0.72em;
|
||||||
|
padding-right: 0.72em;
|
||||||
|
border-bottom: 0.07142857142857142em solid var(--light-border-color); /* 14px => 1px */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entries
|
* Entries
|
||||||
|
Loading…
Reference in New Issue
Block a user