Language definition based on the closest lang attribute (#297)

* Language definition based on the closest `lang` attribute

* Update index.js
This commit is contained in:
Alex Kozack 2021-04-27 15:41:26 +03:00 committed by GitHub
parent 04ed6105e1
commit f20990894a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,7 +38,10 @@ const handleMouseUp = async e => {
removeTranslatecontainer(); removeTranslatecontainer();
const ignoredDocumentLang = getSettings("ignoredDocumentLang").split(",").map(s => s.trim()).filter(s => !!s); const ignoredDocumentLang = getSettings("ignoredDocumentLang").split(",").map(s => s.trim()).filter(s => !!s);
if (!!document.documentElement.lang && ignoredDocumentLang.includes(document.documentElement.lang)) return; if (ignoredDocumentLang.length) {
const ignoredLangSelector = ignoredDocumentLang.map(lang => `[lang="${lang}"]`).join(',')
if (!!e.target.closest(ignoredLangSelector)) return;
}
const selectedText = getSelectedText(); const selectedText = getSelectedText();
prevSelectedText = selectedText; prevSelectedText = selectedText;