summaryrefslogtreecommitdiff
path: root/ext/js/app/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-01-31 08:40:57 -0500
committerGitHub <noreply@github.com>2024-01-31 13:40:57 +0000
commit2356223942a21d1683ac38eed8e7b9485f453d87 (patch)
tree4e97b53a9d4829378ebc60eb5b8e40b6f5b665ee /ext/js/app/frontend.js
parent87ed7c8affd3ade9d3cd2d9ed1a61dd5f224e473 (diff)
Document util + google docs util state refactor (#590)
* Remove static from GoogleDocsUtil since it has state * Create TextSourceGenerator * Remove DocumentUtil custom registrations * Use TextSourceGenerator
Diffstat (limited to 'ext/js/app/frontend.js')
-rw-r--r--ext/js/app/frontend.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js
index 837364ad..d1c32b03 100644
--- a/ext/js/app/frontend.js
+++ b/ext/js/app/frontend.js
@@ -22,6 +22,7 @@ import {log} from '../core/logger.js';
import {promiseAnimationFrame} from '../core/utilities.js';
import {DocumentUtil} from '../dom/document-util.js';
import {TextSourceElement} from '../dom/text-source-element.js';
+import {TextSourceGenerator} from '../dom/text-source-generator.js';
import {TextSourceRange} from '../dom/text-source-range.js';
import {TextScanner} from '../language/text-scanner.js';
import {yomitan} from '../yomitan.js';
@@ -84,6 +85,8 @@ export class Frontend {
this._contentScale = 1.0;
/** @type {Promise<void>} */
this._lastShowPromise = Promise.resolve();
+ /** @type {TextSourceGenerator} */
+ this._textSourceGenerator = new TextSourceGenerator();
/** @type {TextScanner} */
this._textScanner = new TextScanner({
node: window,
@@ -91,7 +94,8 @@ export class Frontend {
ignorePoint: this._ignorePoint.bind(this),
getSearchContext: this._getSearchContext.bind(this),
searchTerms: true,
- searchKanji: true
+ searchKanji: true,
+ textSourceGenerator: this._textSourceGenerator
});
/** @type {boolean} */
this._textScannerHasBeenEnabled = false;
@@ -949,6 +953,7 @@ export class Frontend {
*/
async _prepareGoogleDocs() {
const {GoogleDocsUtil} = await import('../accessibility/google-docs-util.js');
- DocumentUtil.registerGetRangeFromPointHandler(GoogleDocsUtil.getRangeFromPoint.bind(GoogleDocsUtil));
+ const googleDocsUtil = new GoogleDocsUtil();
+ this._textSourceGenerator.registerGetRangeFromPointHandler(googleDocsUtil.getRangeFromPoint.bind(googleDocsUtil));
}
}