wshanks / Zutilo

Zotero plugin providing some additional editing features
Other
1.53k stars 72 forks source link

Add shortcuts for BetterBibTex #72

Closed mijalche closed 6 years ago

mijalche commented 7 years ago

I use Zutilo shortcuts and I find it a very very good add-on for Zotero. I also extensively use BetterBibTex. At BetterBibTex I created the issue Keyboard shortcuts for BBT - https://github.com/retorquere/zotero-better-bibtex/issues/754 after discussion with @retorquere I would like to submit this request to you to add additional options in your shortcuts that will call:

According @retorquere for safety it would be best to wait until the Zotero.BetterBibTeX.ready promise resolves.

What do you think can you add this to Zutilo?

Thank you and keep the good work

wshanks commented 7 years ago

Yes, that seems reasonable to add. I have trouble finding time to work on Zutilo and LyZ recently, but I will see what I can do.

mijalche commented 7 years ago

Thanks. Highly appreciated! I can test the builds

wshanks commented 6 years ago

I just pushed a draft to the bbt branch. I am attaching the xpi (named as .zip because GitHub doesn't allow attaching .xpi files). Let me know how it works for you. It seems to work for me.

It was slightly tricky to get the scoping to work out to check for BBT and the ready promise because Zutilo sets up its shortcuts in an isolated context that doesn't know about the Zotero object and then injects that into the window.

zutilo.zip

mijalche commented 6 years ago

it works perfectly for me. Thank you very much!

retorquere commented 6 years ago

Yeah sorry about that added complication but I really don't know any other way to make sure everything is appropriately "settled" in Z5.

wshanks commented 6 years ago

No problem, the way it works now is mostly clean. I just had started out trying to check the promise before creating the shortcuts which didn't work well because I couldn't find a clean way to reference Zotero at that point in the code. Now it checks for BBT with AddonManager and creates shortcuts that wait on the promise when they are called.

The other awkward part was that the AddonManager callback delays the BBT shortcut set up until after another step is done that loops over all the shortcuts and does more set up, so they were getting missed. For now, I just redo that setup in the AddonManager callback (it would be better to only set up the BBT shortcuts rather than redoing everything).

retorquere commented 6 years ago

Right, for a bootstrapped extension that's going to be the safest approach I think.

wshanks commented 6 years ago

Closed by 8ab3316c77d6b71e53dfdf3002d60fa8c55fa193