glutanimate / frozen-fields

A fork of Tiago Barroso's Frozen Fields add-on with support for Anki 2.1
https://ankiweb.net/shared/info/516643804
Other
24 stars 4 forks source link

Ensuring compatibility with multi column and add-ons in general #20

Open Arthur-Milchior opened 4 years ago

Arthur-Milchior commented 4 years ago

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.

2020-03-24-085707_1916x1041_scrot

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:

Arthur-Milchior commented 4 years ago

The related PR for multi column add-on is https://github.com/hssm/anki-addons/pull/32

glutanimate commented 4 years ago

Thanks, Arthur! This looks very promising. Will look over it more thoroughly soon.

Arthur-Milchior commented 4 years ago

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+

glutanimate commented 4 years ago

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

Arthur-Milchior commented 4 years ago

No hurry

ijgnd commented 4 years ago

@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.

Arthur-Milchior commented 4 years ago

Does not work anymore. I don't get why. I'm looking at it

Arthur-Milchior commented 4 years ago

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.

Arthur-Milchior commented 4 years ago

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"

Arthur-Milchior commented 4 years ago

I just pushed a correction to the last problem I had: having fields which takes all columns

Arthur-Milchior commented 4 years ago

2020-05-03-021010_956x1041_scrot I don't know how to make gif, so I can't as easily show that there is no flickering

Arthur-Milchior commented 4 years ago

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