aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/text-scanner.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index 073b1a6c..4994faea 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -17,6 +17,7 @@
/* global
* DocumentUtil
+ * TextSourceElement
*/
class TextScanner extends EventDispatcher {
@@ -321,6 +322,12 @@ class TextScanner extends EventDispatcher {
({definitions, sentence, type} = result);
this._inputInfoCurrent = inputInfo;
this.setCurrentTextSource(textSource);
+ } else if (textSource instanceof TextSourceElement && await this._hasJapanese(textSource.fullContent)) {
+ definitions = [];
+ sentence = {sentence: '', offset: 0};
+ type = 'terms';
+ this._inputInfoCurrent = inputInfo;
+ this.setCurrentTextSource(textSource);
}
} catch (e) {
error = e;
@@ -978,4 +985,12 @@ class TextScanner extends EventDispatcher {
}
}
}
+
+ async _hasJapanese(text) {
+ try {
+ return await yomichan.api.textHasJapaneseCharacters(text);
+ } catch (e) {
+ return false;
+ }
+ }
}