only paste Japanese text from clipboard

This commit is contained in:
siikamiika 2019-11-13 13:51:47 +02:00
parent db4a303365
commit 29c38b06b2
2 changed files with 10 additions and 1 deletions

View File

@ -248,7 +248,7 @@ class DisplaySearch extends Display {
} else if (IS_FIREFOX === false) {
curText = (await apiClipboardGet()).trim();
}
if (curText && (curText !== this.clipboardPrevText)) {
if (curText && (curText !== this.clipboardPrevText) && jpIsJapaneseText(curText)) {
if (this.isWanakanaEnabled()) {
this.query.value = window.wanakana.toKana(curText);
} else {

View File

@ -26,6 +26,15 @@ function jpIsKana(c) {
return wanakana.isKana(c);
}
function jpIsJapaneseText(text) {
for (const c of text) {
if (jpIsKanji(c) || jpIsKana(c)) {
return true;
}
}
return false;
}
function jpKatakanaToHiragana(text) {
let result = '';
for (const c of text) {