Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
49 stars 6 forks source link

[Feature Request] Being able to select my own context sentence #3

Closed it0na72 closed 1 year ago

it0na72 commented 1 year ago

Once again, thanks for this amazing script. I have noticed the script tends to only add the sentence the word is in until there's a comma or a dot.

Would it be possible to implement a system where you could highlight the whole context you would like to add in the note? Sometimes the sentence the word is, doesn't have enough context to remember it in the future while reviewing it.

Thanks in advance.

nairyosangha commented 1 year ago

This is something I've been meaning to do as well. Adding extra context shouldn't be too hard. I'm not sure about letting the user highlight the text they want though, how would that work? You'd have to close the popup to select extra text, at which point you can't create a card anymore

I was thinking more along the lines of adding an extra option in the long-press menu: image

Which would then show you the currently selected text, which the user can then add to: image

It would look a bit better than this of course, but you get the idea

it0na72 commented 1 year ago

Your option does indeed look better than what I had in mind. Looking forward to seeing this released!

nairyosangha commented 1 year ago

https://github.com/Ajatt-Tools/anki.koplugin/tree/custom_context There's a working implementation on the branch above. Gonna try it for a few days before I merge to master, to see if I run into problems.

This is what it ends up looking like: You can delete/add either single characters or whole sentences, before or after the word you looked up. image

it0na72 commented 1 year ago

Thank you for this! Will take it for a spin and keep you updated.

nairyosangha commented 1 year ago

Made a few more changes:

nairyosangha commented 1 year ago

Also, inituitively I want to use the buttons on the top/left to expand the prepended content, but that actually removes content, should I switch those around?

it0na72 commented 1 year ago

Also, intuitively I want to use the buttons on the top/left to expand the prepended content, but that actually removes content, should I switch those around?

So I tried it out and this was immediately what I noticed. It might be worth changing these buttons around if you have the time.

Regarding both the other updates, they sound really nice too. However, when I'm adding a card with custom context, the scroll bar is quite small to check if the context I added is correct. Would it be possible to make the window of the custom context update its size depending on the size of the custom context?

nairyosangha commented 1 year ago

So I tried it out and this was immediately what I noticed. It might be worth changing these buttons around if you have the time.

Easy fix, will do

Would it be possible to make the window of the custom context update its size depending on the size of the custom context?

Resizing on the fly is a pain to deal with, you have to do more repaints to have it render correctly, and (as far as I know) you have to manually calculate the amount of space your text will take, so I'd rather not right now. I did set the size to 150px initially, I'll make it scale to half of the screen. That should get rid of the need to scroll in most cases.

the scroll bar is quite small to check if the context I added is correct

You know you can tap anywhere on the text to make it scroll, right? :smile:

it0na72 commented 1 year ago

Thank you for this, will update the script and keep you in touch!