yomidevs / yomitan

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

[Feature Request] Make anki dictionary export more customizable #462

Closed afn478 closed 3 months ago

afn478 commented 9 months ago

(I'm sorry for the long text, I'm going into detail for how I imagine this feature to be implemented)

(Potential duplicate of https://github.com/themoeway/yomitan/issues/322 but the idea I'm presenting is not with separate card template field names for each dict but for the same anki meaning field.)

Add option(s) for on the fly selection of dictionaries' entries to be exported to anki card

This could particularly helpful on mobile devices and especially android ereaders. Right now, you have to decide between enabling scanning in popups and exporting individual definitions by with selection-text. With this, one can enable both at the same time. Further, as selecting text on ereaders can be difficult, the feature would eliminate that need.

Even on PC though, it would be an elegant native solution for individually selecting the desired entry/entries for each card as you wouldn't have to worry about getting the right handlebars that do this.

Implementation 1

As shown in the very crude mockup below, adding the large button (or the small one as well) would help selecting which dictionary's entry will be exported into the anki card.

The mockup isn't exactly consistent, but by my idea, the button(s) would be placed after an entry's tags (each entry being denoted by the number) or on the very right hand side at the same height as the entry number.

One small challenge would be how to fit the Ctrl + E shortcut into all of this. It would probably only apply for the main button above.

Screenshot_20231227_180148_Firefox.jpg

Implementation 2

A completely different approach: Make a checkbox before each dictionary name tag and make yomitan permanently remember which dicts you selected on the fly. Then one of the fields you could add to your anki template would be something like {selected-dictionaries}. This way, each checkboxed dictionary would be exported into the anki card, by using the existing button at the top (-> this means the Ctrl+E shortcut will work here!).

The big benefit here is that one can change the dictionaries for export on the fly, but also since Yomitan would remember the previously selected dicts for export, pressing the button (or the shortcut) right after scanning something new would still export from said entries. It would be fast and elegant since it would not rely on custom handlebars from the community.

One challenge here though would be: How would you add the sub-entries of formatted dicts like jmdict extra (as seen in the mockups)? Maybe it makes sense to only have each whole dictionary selectable for now.

feature_mockup_2.jpg

In both cases, a toggle would be put in the Anki section of the Yomitan settings reading something like "Enable separate export buttons for each entry" or "Make dictionaries selectable for export".

Which one?

I am not sure which one I would choose, hence why I offered both ideas. The elegant one would be the second, as it seems to be much easier to integrate into the popup as-is visually. It would also be the most frictionless if you aren't actively changing which dicts to export from every time. Otherwise, if you always decide which dictionary with every lookup, the first one would be more suited. It would also not have the issue with the sub-entries, i.e. you could select each sub-entry as well.

I would not say no to both being implemented, but that would probably be a lot of development effort.

I have no knowledge whatsoever about the code base or how difficult it is to implement new features, so please forgive me if I'm making an outrageous request.

MarvNC commented 9 months ago

Personally I feel like the export settings are complicated enough and that additional buttons like this would be feature creep and would confuse many users. IMO the default behavior of exporting all dictionaries is optimal, but just needs better styling/filtering on the anki side as well as better instructions/ux with the handlebars and templates. Also, you can replicate this behavior by setting the grouping mode to "no grouping".

afn478 commented 9 months ago

Also, you can replicate this behavior by setting the grouping mode to \"no grouping\".

You're right about that, but particularly on android devices, this takes up so much space that you will have to scroll around a lot, because of the replicated term and tags and pitch. On ereaders, scrolling is the one thing you want to avoid as much qs possible. I guess some kind of visual redesign of the popup would make the first idea possible.

daniesteban commented 9 months ago

I support the request. Giving an example I'm dealing with. It's in English because I'm using yezichak at this moment, but I presume that something similar happens with Japanese. If I want to add a card for the word blowout from the example sentence Tire blowouts happen when a tire suddenly loses all its air pressure, an English dictionary gives all these definitions:

blowout n yzkW-en-en A sudden puncturing of a pneumatic tyre/tire. A sudden release of oil and gas from a well. The cleaning of the flues of a boiler from scale, etc., by a blast of steam. An unsightly flap of skin caused by an ear piercing that is too large. An instance of having one's hair blow-dried and styled. (tattoo) The blurring of a tattoo due to ink penetrating too far into the skin and dispersing. n sl yzkW-en-en A social function, especially one with large quantities of food. A large or extravagant meal. An argument; an altercation. n chief-sport sl yzkW-en-en A contest that is decidedly one-sided; an overwhelming victory. n geol yzkW-en-en A sandy depression in a sand dune ecosystem caused by the removal of sediments by wind. n 🇦🇺 yzkW-en-en An extreme and unexpected increase in costs, such as in government estimates for a project.

For that sentence the only right meaning is A sudden puncturing of a pneumatic tyre/tire, but at this time there is no way to use only that definition (unless I edit the card after insert it). The Implementation 1 suggested by @afn478 would solve the issue. It isn't only a smartphone problem, because having several useless definitions greatly affects the cards study time and comprehension. In any case, I guess the activation of individual definitions selection would be optional and disabled by default, so there shouldn't be any confusion for current users. If useful there is a much tinier addon called Ankimine that uses that approach: Screenshot_2024-01-08_07-48-30

BilderLoong commented 6 months ago

I also need this feature. For now, I use the below approach, but it doesn't work well in some cases.

My temporary solution: Yomitan supports exporting {selection-text} to Anki, so I write some code in my Anki template by using this library to style the {selection-text} in the glossary.

The code in my Anki note template is:

  findAndReplaceDOMText(document.body, {
  wrap:'u',
  find: new RegExp(`{{selection-text}}`),
})

The downside of this solution is that when the {selection-text} crosses multiple tag boundaries, the match often doesn't work well.

Kuuuube commented 3 months ago

Closing as this level of specificity is unlikely to ever be added. Some parts of this request are solved by using the popup-selection-text handlebar. Support for more anki card format configurations is tracked in this issue #893.