Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Arthur-Milchior
Copy link
Contributor

If the user tries to add a cloze in a field that is not a cloze type, the user gets an alert message.

I could have removed the buttons or disabled them, as it's done when the note type is not a cloze deletion, but I think it's better to avoid changes in the buttons. And anyway, the alert would still be useful if the user tried to use the shortcut to add the cloze.

In order to do this, I added a back-end method (that I expect we may reuse in ankidroid) to get the index of the fields used in cloze. This set is sent to the note editor, which propagates it where needed.

In mathjax, the cloze symbol is removed when the selected field is not a cloze field

I would appreciate help, as the alert message is not properly displayed, instead it shows

missing key: adding-cloze-outside-cloze-field

@dae
Copy link
Member

dae commented Mar 24, 2025

You'll need to add the ADDING module in editor/base.ts to fix that error. That said, we already have a warning that pops up when cloze markers are added to a non-cloze field, and this warning works even when not using the cloze button. I'm not sure how much extra value this is adding?

@Arthur-Milchior Arthur-Milchior force-pushed the note_type_button branch 3 times, most recently from 8d87baf to 6f20c47 Compare April 9, 2025 00:14
@Arthur-Milchior
Copy link
Contributor Author

I also realized that it was buggy after a note type change. This is repaired. I now disabled the buttons when the focus is in a field that is not a focus field. To be consistent with the button, I also ensured the shortcut does nothing, instead of displaying an alert.

I'm not claiming that this is adding a ton of value to be clear. Especially not for power users. But I introduced a friend to anki and saw him trying various things, and hence trying to add a cloze while he was in "back extra". I found strange that there was no warning sooner to let them know it can't be done, and wanted to correct that. I expect he was not the only one who didn't understand the limitation at first.

And while I admit that the message already appear to tell the user that cloze can't be used in back extra, I think that disabling the button is good practice. Not only does it give feedback to the new user that the available actions are not the same in all fields, but it ensures that, while trying the app, they won't try to add a cloze where it should not be.

I first thought you were referring to the warning that appears if you try to add the note. Which I found to arrive quite late.
I missed the warning that arrive very soon after entering the cloze, because of #3909.

@dae
Copy link
Member

dae commented Apr 10, 2025

Please fix the tests and then I'll merge it in.

This allows to remove the negations and, in my opinion, make the code
easier to understand and edit.
More specifically, if the user focus in a field that is not a cloze
field, the button are still there but appear as disabled. The shortcut
instead of adding the cloze context shows an alert explaining why this
can't be done.

While this message is already displayed when the user tries to add a
note with cloze in non-cloze field, I suspect it will save time to
stop the user as soon as possible from making mistake. This should
make very clear what is authorized and what is not.

It'll also be a reminder of whether the current field is a cloze or
not.

In order to do this, I added a back-end method (that I expect we may
reuse in ankidroid) to get the index of the fields used in cloze. This
set is sent to the note editor, which propagates it where needed.

In mathjax, the cloze symbol is removed when the selected field is not
a cloze field.
@Arthur-Milchior
Copy link
Contributor Author

Done

@dae
Copy link
Member

dae commented Apr 24, 2025

Thanks Arthur.

@dae dae merged commit efaaae8 into ankitects:main Apr 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants