diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-01 10:00:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 15:00:59 +0000 |
commit | dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch) | |
tree | 04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/language | |
parent | 2356223942a21d1683ac38eed8e7b9485f453d87 (diff) |
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style
* Rename file
* Update init
* Update config
* Remove dead code
Diffstat (limited to 'ext/js/language')
-rw-r--r-- | ext/js/language/text-scanner.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 6228a82c..d78c4c74 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -22,7 +22,6 @@ import {log} from '../core/logger.js'; import {clone} from '../core/utilities.js'; import {DocumentUtil} from '../dom/document-util.js'; import {TextSourceElement} from '../dom/text-source-element.js'; -import {yomitan} from '../yomitan.js'; /** * @augments EventDispatcher<import('text-scanner').Events> @@ -32,6 +31,7 @@ export class TextScanner extends EventDispatcher { * @param {import('text-scanner').ConstructorDetails} details */ constructor({ + api, node, getSearchContext, ignoreElements = null, @@ -43,6 +43,8 @@ export class TextScanner extends EventDispatcher { textSourceGenerator }) { super(); + /** @type {import('../comm/api.js').API} */ + this._api = api; /** @type {HTMLElement|Window} */ this._node = node; /** @type {import('text-scanner').GetSearchContextCallback} */ @@ -1204,7 +1206,7 @@ export class TextScanner extends EventDispatcher { /** @type {import('api').FindTermsDetails} */ const details = {}; if (this._matchTypePrefix) { details.matchType = 'prefix'; } - const {dictionaryEntries, originalTextLength} = await yomitan.api.termsFind(searchText, details, optionsContext); + const {dictionaryEntries, originalTextLength} = await this._api.termsFind(searchText, details, optionsContext); if (dictionaryEntries.length === 0) { return null; } textSource.setEndOffset(originalTextLength, false, layoutAwareScan); @@ -1236,7 +1238,7 @@ export class TextScanner extends EventDispatcher { const searchText = this.getTextSourceContent(textSource, 1, layoutAwareScan); if (searchText.length === 0) { return null; } - const dictionaryEntries = await yomitan.api.kanjiFind(searchText, optionsContext); + const dictionaryEntries = await this._api.kanjiFind(searchText, optionsContext); if (dictionaryEntries.length === 0) { return null; } textSource.setEndOffset(1, false, layoutAwareScan); @@ -1564,7 +1566,7 @@ export class TextScanner extends EventDispatcher { */ async _hasJapanese(text) { try { - return await yomitan.api.textHasJapaneseCharacters(text); + return await this._api.textHasJapaneseCharacters(text); } catch (e) { return false; } |