Open qntoine opened 1 year ago
This repository is actually a fork of that one, and some of the vestiges of the "only apply to selected text" is found within the architecture for this plugin.
Unfortunately, Anki changes have been pretty dramatic across the past 3 years since that plugin was seeing active development, and there've been numerous and frequent breaking changes. That will mean that we won't be able to directly lift the code from that repository/reenable it within this one, and it'll take additional research and development, especially as this plugin supports a wide range of Anki versions (meaning we need to ensure backwards compatibility and figure out how to do selection in each version).
It can definitely be done, but this might rank lower on the overall priority list (or at least, on my personal one) as I can't imagine applying furigana to only a subset of an input box is an altogether frequent need. Not to mention it'll produce a more difficult UX for users to discover they can do this.
To explore base assumptions though: what would you use case be for needing to apply furigana to only part of the text in the input box? Could that same need be solved with a different feature?
Thank you for the detailed explanation on the background of this feature.
To go back to the use case, my point is simply that displaying all furigana does not mimic an actual reading experience in Japanese (even in a learning context, e.g. a textbook or flashcards), where only readings for the most difficult words are shown. Displaying all furigana is distracting and can hinder your ability to progress as your brain may intuitively will go for the easiest route and hinge on furigana first. It is like watching a movie with subtitles on by default: nice to have and even needed in some cases, but unnecessary and distracting in others.
One alternative feature I can think of to elegantly solve this issue would be to add an option to hide furigana by default and display them only when hovering over (for mouse interfaces) or clicking (for touch interfaces) on a certain word.
It seems doable with Ruby (there are many examples available online, including something as simple as ruby rt { visibility: hidden; } ruby:hover rt { visibility: visible; }
added to the Styling section), only the solution would need to work on all platforms preferably (Anki for desktop, Anki Mobile, Ankidroid, and Ankiweb).
Hello, I should add some background since I'm mostly responsible for removing this feature. Unfortunately Anki removed a lot of the javascript binding "hacks" that we were using to be able to fetch the selected text. I tried my best to keep it by testing several techniques and ultimately decided to remove the feature during the refactoring since none of these techniques worked. I would love to bring it back if we manage to find a way to fetch the user selected text.
This repo is indeed a fork of SimpleFurigana
, which is itself a form of ClozeFuriganaTool
but has been heavily refactored to make it follow the Anki new releases and make it work on newer versions.
The original author of SimpleFurigana
recently reached out to me to tell me that he is too busy to maintain it and prefer to deprecate it and redirect users to this repo.
I think your feature request for hide furigana by default is easy to implement. Could you create a separate issue for that feature request so that we don't loose sight of it ? Can't give an ETA though, but I welcome contributions.
One suggestion for implementation: if text is selected, generate furigana for it, if not, generate furigana for the entire field.
Maybe, it's possible to somehow reuse the code used in AJT Japanese add-on?
def get_selected_text(self) -> Optional[str]:
if self.editor is not None and self.editor.currentField is None:
return None
if len(sel_text := self.webview.selectedText()) > 0:
return sel_text
return None
The original file: https://github.com/Ajatt-Tools/Japanese/blob/30a876be5d6864cd82e3a25214591b925ad69c92/japanese/context_menu.py#L64
This repository is actually a fork of that one, and some of the vestiges of the "only apply to selected text" is found within the architecture for this plugin.
Unfortunately, Anki changes have been pretty dramatic across the past 3 years since that plugin was seeing active development, and there've been numerous and frequent breaking changes. That will mean that we won't be able to directly lift the code from that repository/reenable it within this one, and it'll take additional research and development, especially as this plugin supports a wide range of Anki versions (meaning we need to ensure backwards compatibility and figure out how to do selection in each version).
It can definitely be done, but this might rank lower on the overall priority list (or at least, on my personal one) as I can't imagine applying furigana to only a subset of an input box is an altogether frequent need. Not to mention it'll produce a more difficult UX for users to discover they can do this.
To explore base assumptions though: what would you use case be for needing to apply furigana to only part of the text in the input box? Could that same need be solved with a different feature?
One important use-case for applying furigana to selection, is to keep cards minimal, i.e. the unknown target is shown only inside a sentence, while there's no need to add furigana to other already familiar parts of the same sentence.
Here's an example of a card front:
Here's an example of a card back:
Please consider adding the option to selectively generate readings based on current text selection, as opposed to the full field.
That option was available in another plugin (SimpleFurigana). The author went MIA but the plugin code is still available on Github under GPL 3.0 (see https://github.com/jcsirot/anki-simple-furigana).
Thank you!