frozen-fields
frozen-fields copied to clipboard
Ensuring compatibility with multi column and add-ons in general
Description
Compatibility with Multi column add-on has been broken for some time. The fact that both add-ons entirely redefine "loadNote" and replace all of "#fields" does not help.
I did change to both add-ons so that:
Both add-on uses recent hooks, (a hook for note loading as been added recently, I'll love to use it when .24 is out). In particular load js file directly.
multi column redefine javascript's setFields
, since it need to do a lot of change. This way, there is no need for event, the direct table is directly computed.
frozen field only do edition where the edition needs to be done. This allows it to avoid redefining the whole setFields
function, and thus easily be compatible with other add-on.
And even better, for me, it makes both add-ons easily compatible with other add-ons dealing with editor, such as "resize image in editor" and "latex image in editor"
Checklist:
Please replace the space inside the brackets with an x and fill out the ellipses if the following items apply:
- [x] I've read and understood the contribution guidelines
- [x] I've tested my changes against at least one of the following Anki builds:
- [x] Latest standard Anki 2.1 binary build [required for Anki-compatible 2.1 add-ons]
- [ ] Latest alternative Anki 2.1 binary build
- [ ] Latest Anki 2.0 binary build [required for Anki 2.0-compatible add-ons]
- [x] I've tested my changes on at least one of the following platforms:
- [x] Linux, version:
- [ ] Windows, version:
- [ ] macOS, version:
- [ ] My changes potentially affect non-desktop platforms, of which I've tested:
- [ ] AnkiMobile, version:
- [ ] AnkiDroid, version:
- [ ] AnkiWeb
The related PR for multi column add-on is https://github.com/hssm/anki-addons/pull/32
Thanks, Arthur! This looks very promising. Will look over it more thoroughly soon.
FYI: HSSM and Damien gave me the "multi column editor" add-on. I just updated the add-on (for anki 22+). The change I sent to you works with and without the "multi column editor" add-on. And you can actually test it by installing the multi column editor add-on on anki 2.1.22+
Thanks for the update, Arthur. Glad to hear you're now maintaining "multi column editor"! Sorry for taking a bit on merging this. It's just that I've been super busy lately. Will look into it asap
No hurry
@glutanimate: If you could merge and release this soon this should avoid some problems.
As far as I see once you have released this @Arthur-Milchior can remove his addon Advanced note editor (Multi-column, Frozen fields, LaTeX's result in editor) because then all of it's functionality should work from the original add-ons.
The latest version of Arthur's "Advanced note editor" was released before 2.1.22 so it doesn't use the 2.1.22 hooks and so it relies on overwrting central Editor methods which in turn breaks other add-ons (like an add-on of mine). It doesn't make sense for Arthur to update his temporary add-on which will be irrelevant once you've update frozen fields.
Thanks.
Does not work anymore. I don't get why. I'm looking at it
Corrected. I put back the star at its old place.
Many add-ons want to add a button to some field. As an example, "multi column window" have a button which allow to switch between field having full width and small field. Cleaning html I sent you recently have a button which allow to clean one particular field. I find that having the button above the field is far more natural than putting the cursor in the field and then clicking the button on top of the editor. I was trying to ensure that frozen field was consistent with all other add-ons I created which add feature on fields themselves. And also to create a pattern that other may follow, that we may had all buttons we want near the name, where there is a lot of place. I admit that it forces me to have a small button in order not to loose space
I would be okay with creating an option in the add-on config to switch between both style.
I pushed again to remove the flickering. This actually allow to simplify the code and totally avoid to reload the note. It sends a message to JS to tell it to change the star, and js sends the message to python to tell to change the status of "sticky"
I just pushed a correction to the last problem I had: having fields which takes all columns
I don't know how to make gif, so I can't as easily show that there is no flickering
While using anki, I realized an unexpected problem. Sometime, anki asks the note to be loaded twice quickly, which does not let callback enough time to be executed. So the code was executed twice. This was not a problem before because the code erased everything and replaced by a new table. Now that the code modify the current table, this led to errors. I corrected it by ensuring that if Frozen-fields' code was already executed, it ensure that the star has the correct value instead of adding a new star