hgiesel / closet

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

[usability] Hide cmd fields bar the next one #46

Open hgiesel opened 3 years ago

hgiesel commented 3 years ago

So initially, cmds 0 + cmds 1 will be shown, if 1 is filled, 2 will be revealed in Editor. This functionality belongs into the Closet add-on, not collapsible fields.

kleinerpirat commented 3 years ago

Still considering adding this functionality? I think it would be a huge win for the look and feel of the addon.

With this implemented, would there still be a reason not to add 100+ cmd-fields to a note type? I don't think anyone would ever need that amount, but it might be a comforting thought that there's practically no limit to the amount of cards you can get out of a note.

Ignoring the practicality of creating such large notes, would there be a noticable performance impact when loading them for review? I guess it depends on how efficiently Anki stores card templates..

hgiesel commented 3 years ago

I'm certainly still interested in implementing this. I have to rewrite the editor code for Anki v2.1.41 anyway, so that might be a good time. Also it would basically be the same code as in the "Add note id" add-on for the note ID field, because while the fields should not be visible to the user, they still need to be present in the editor (basically displayed off-screen).

Last time I tested, there was no such performance impact on Desktop, but there was one AnkiMobile, because it does not cache the note types. No idea about AnkiDroid. So it's not really viable (at least for me).

kleinerpirat commented 2 years ago

because while the fields should not be visible to the user, they still need to be present in the editor.

Not so sure about this anymore. Here's how I do this currently:

on_editor_will_load_note(js, note, editor):
    return re.sub(r""",\s\["cmds [^0]+?\d*?", ".*?"\]""", "", js)

This will remove all cmds fields except cmds0 from setFields and therefore prevents loading them in the editor. Cmds are processed hidden from user view with JS + Python. My reasoning is that most people who want to use my notetype won't have the time or motivation to learn Closet commands, so I'd provide GUI solutions that then translate back to commands.

With the now much more complex Svelte editor, load times for big notetypes have significantly increased. Without abovementioned hack, I'm dealing with ~10s of blank screen for my biggest notetype. Could there be a bottleneck that makes this an O(n²) process rather than a linear one? ChangeNotetype had a similar loading time to the editor until I optimized it to only load the selected dropdown option at first and the rest once the select is focused (PR coming soon). Anyway, what I'm trying to say is this issue might actually become more relevant after the next major Anki update.

Curious how you would handle this once you get back to Closet :)