themoeway / yomitan

Pop-up dictionary browser extension. Successor to Yomichan.
https://yomitan.wiki
GNU General Public License v3.0
1.18k stars 93 forks source link

Features that use "scanSelectedText" break some handlebars #1076

Open Kuuuube opened 3 months ago

Kuuuube commented 3 months ago

Description When using either the Scan selected text keybind or the Lookup in Yomitan context menu item, the following handlebars do not capture any text before the scanned text:

{sentence}
{sentence-furigana}
{cloze-prefix}

Yomitan version 0283b29

jamesmaa commented 3 months ago

I suppose this is because _disallowExpandSelection is set to true in TextSourceRange? Hence the extractSentence in TextSourceGenerator is not functioning properly?

I think the fix involves changing this line https://github.com/themoeway/yomitan/blob/76ca08bd59f0e8bfa1bb20ac813f48e7ab241265/ext/js/dom/text-source-generator.js#L66

to not just blindly copy source (which has _disallowExpandSelection === true), but to find a way to set this value to false after copying

onweeks commented 3 months ago

Might be relevant: I am also getting incorrect highlights when using the cloze-prefix/cloze-body/cloze-suffix for highlighting in sentences for Anki cards. For example, when adding 快く:

Skærmbillede 2024-06-30 123457

Currently switched to simply having the sentence only with no highlighting