hssm / anki-addons

Add-ons for Anki.
9 stars 7 forks source link

Using recent hooks #32

Closed Arthur-Milchior closed 4 years ago

Arthur-Milchior commented 4 years ago

Hi,

This PR makes plenty of different things. The main reason for this PR is to uses hooks added in recent version of anki. In particular a hook to deal directly with bridge command, and one to import javascript files.

First, I believe that having javascript in a .js file will help read and edit the javascript, thanks to IDE being able to help with JS. It should also helps, I hope, in combining together multiple add-ons which deal with changing the editor. I'm thinking in particular of Frozen Fields, Resize note in editor, and Show latex image in editor

Arthur-Milchior commented 4 years ago

The last commit's main purpose is that it simply redefine setFields. I feel that it makes the code far simpler to read. And ensure that other add-on affecting the editor's web will be able to deal with the fields easily (currently, since your add-on change the fields, the problem is that any change done by other add-ons get cancelled by yours)

Arthur-Milchior commented 4 years ago

The last commit add an id which has just been accepted in anki. It allows me to easily make the add-on compatible with frozen field, 2020-03-24-085707_1916x1041_scrot

Arthur-Milchior commented 4 years ago

The related PR for Frozen Fields is https://github.com/glutanimate/frozen-fields/pull/20

Arthur-Milchior commented 4 years ago

2020-03-24-121226_1916x1041_scrot Last commit adds a small button, which allow to change the size quickly. I hope the little text makes clear what the effect will be

Arthur-Milchior commented 4 years ago

Hi @hssm I do realize that you have been quite busy recently with advanced browser (and probably also with your life outside of anki). May I ask whether this change seems interesting to you, and whether you think you'll incorporate it into the add-on ? Or whether I should just upload a corrected version of the add-on myself.

hssm commented 4 years ago

Hi Arthur. To be honest, I haven't been very fond of this add-on for a while now, so I think it's best if you take ownership of it. Let me know where you've published it and I'll update the docs to refer to it.

I use the add-on myself but I don't need it to do any more than it already does, so I haven't been too motivated to make changes to it. Also, the approach it takes to achieve its function isn't the best anymore. When I wrote it, Anki used an older browser engine, so it was the only way. Since Anki 2.1, we should now be able to use CSS Grid to position the elements instead, saving us from editing the HTML content of the editor (which I suspect is causing a lot of issues, both with other add-ons and in general since it may alter note content).

That could be something for you to look into if you're interested.

Arthur-Milchior commented 4 years ago

I just wrote to @dae to asks whether it would be possible to change the owner of the add-on. So that people simply gets the new version when they update. See https://ankiweb.net/shared/info/3491767031 I assume it should be a simple change in a database. Otherwise, I'll post my version online, and that will get rid of all negative review of your add-on, which are out of date

Arthur-Milchior commented 4 years ago

I may eventually take a look at "grid". I must admit I don't know css enough to do it. But it seems an interesting idea for sure

Arthur-Milchior commented 4 years ago

I'm not entirely convinced by grid in this particular case. Because the name of the field and the field content are on different lines of the table, changing it to a grid may be more work than just redifining the method setFields. And redifining it seems to break less thing than moving the content of the table

dae commented 4 years ago

@hssm if you'd like me to assign the existing ID to Arthur, please let me know

@Arthur-Milchior if hssm wants to do that, please message me at least 12 hours from now when you are around, as when I change the owner the downloads will break until you upload a new version

Arthur-Milchior commented 4 years ago

@dae I'll do. I message you here, or do you prefer somewhere else ? ?

dae commented 4 years ago

here is fine

hssm commented 4 years ago

@dae Yes, please reassign the ID.

dae commented 4 years ago

@Arthur-Milchior it's now assigned to you, and downloads may fail until you upload a new version

Arthur-Milchior commented 4 years ago

Uploaded

hssm commented 4 years ago

Great, thanks to both. I can confirm that it updated in-client and it works as expected.