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:
parent
04ed6105e1
commit
f20990894a
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue