hgiesel / closet

The Web Framework for Flashcards
https://closetengine.com
GNU General Public License v3.0
65 stars 6 forks source link

Option to automatically fill specific field with markup when accepting occlusions [usability] #41

Closed kleinerpirat closed 3 years ago

kleinerpirat commented 3 years ago

It would be nice to be able to assign a specific field as a container for the "rect-block" when making image occlusions, so Closet could automatically fill it (see mockup below) instead of only adding the markup to the clipboard, since it's quite easy to forget pasting it before adding a note.

Adding the commands manually seems like a redundant task for the use case of standard image occlusions, and should be automated in my opinion, because it is unintuitive for non-tech-savy users. One could even argue that visible commands aren't even necessary for the majority of users and should therefore be hidden somewhere outside of the fields, but auto-pasting them would be a good compromise.


mockup GIF
hgiesel commented 3 years ago

To summarize, I see two ideas here:

  1. Auto-filling a Code field, when accepting the occlusions

The commands need to be in a field however, as they need to be injected into the template, in order to work on the mobile platforms. This is why I made the Collapsible Fields add-on. It is completely possible to auto-fill a field, while it is collapsed, which is how I imagined it.

I imagined the Code field to be suffixed with a 0, like Code 0. This nicely follows the naming convention for the other Code fields.

I will also give the "rect block" an additional prefix in this field, as to still allow possible "power users" to add their own commands below it, and not be automatically replaced. Something like:

[#!autogen [[rect1::1,2,3,4]]
[[rect2::1,3,5,4]]
[[rect3::7,6,6,4]] #]
... extra commands go here
  1. Auto-accepting, if the user adds the note while the Occlusion editor is open.

This would also be easy to do, with the add_cards_will_add_note(problem, note) gui hook.

How would you imagine the behavior in the editor however? I'm afraid users will be very confused, if they then close the "Edit Current Card" window, with the occlusions open, and they were not automatically accepted. Same for the browser. I'm afraid neither the browser, nor edit current offer any convenient hooks for this kind of behavior. I might have to add those myself first.

kleinerpirat commented 3 years ago
  1. Wrapping the block with [#!autogen ... #] is a very neat idea to meet both average and power user demands. Great thinking! Edit: I also like the idea of the suffix 0, seems like the way to go in order to keep things simple.

  2. Maybe instead of adding a new hook to Anki you could add a custom event/signal within Closet that fires whenever a significant change is made in an occlusion editor
    e.g.:
    • "rectX was dragged to a new position"
    • "rectX was resized"
    • "added/deleted/renamed rect"

    Since you can prompt a change in the webview through your custom context menu ("accept occlusions") and typing closet commands, I reckon something like that would be possible, right?

    Edit: This challenges the concept of accepting occlusions and rephrases the second idea to "Auto-fill Code 0 field, if a change is made in the occlusion editor", but I'm not sure if that is desirable in your eyes. "Accept occlusions" would still be necessary for users without a Code 0 field...
hgiesel commented 3 years ago
  1. is implemented since e6d4ed7bc5, and will be the default behaviour going forward.
  2. When trying to implement it, I actually noticed that my first idea won't work, because of asynchronous issues between the QT web view and Anki. I've implemented a transitory solution, which simply notifies the user, if the tries add a card, while the occlusion editor is open. (5ce51d6dcba83869124f4)

For the future, I will try to implement a live-update solution, like you suggested, but that requires some more work in the JavaScript part of occlusion editor. Updates on that are tracked in #42.