frozen-fields icon indicating copy to clipboard operation
frozen-fields copied to clipboard

Ensuring compatibility with multi column and add-ons in general

Open Arthur-Milchior opened this issue 4 years ago • 12 comments

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:

  • [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

Arthur-Milchior avatar Mar 24 '20 08:03 Arthur-Milchior

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

Arthur-Milchior avatar Mar 24 '20 08:03 Arthur-Milchior

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

glutanimate avatar Mar 26 '20 17:03 glutanimate

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+

Arthur-Milchior avatar Apr 02 '20 22:04 Arthur-Milchior

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

glutanimate avatar Apr 02 '20 22:04 glutanimate

No hurry

Arthur-Milchior avatar Apr 02 '20 22:04 Arthur-Milchior

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

ijgnd avatar Apr 26 '20 12:04 ijgnd

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

Arthur-Milchior avatar Apr 27 '20 18:04 Arthur-Milchior

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 avatar Apr 27 '20 19:04 Arthur-Milchior

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 avatar Apr 27 '20 19:04 Arthur-Milchior

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

Arthur-Milchior avatar May 02 '20 09:05 Arthur-Milchior

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 avatar May 03 '20 00:05 Arthur-Milchior

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

Arthur-Milchior avatar May 04 '20 20:05 Arthur-Milchior