diegodlh / zotero-cita

Cita: a Wikidata addon for Zotero with citations metadata support
GNU General Public License v3.0
234 stars 12 forks source link

Add the "citations" tab in the right panel of the PDF viewer of Zotero #208

Closed Futur3r closed 1 year ago

Futur3r commented 2 years ago

It would be great to have the "citations" tab inside the right panel of the "viewer mode" while reading a PDF. To be able to view the bibliography of an article dynamically (i.e use cita functionalities) and contribute manually to wikidata while looking directly at the bibliography of an article.

Right now, I need to got back and forth between an article and my library to check if there is the reference I'm looking for. And I'm not contributing manually through cita because that makes it too tedious.

Dominic-DallOsto commented 2 years ago

Great idea!

Do you know any other extensions which modify the PDF reader view in a similar way? That'd help for building this off.

Futur3r commented 2 years ago

Unfortunately no. I know of only one that add a lot of functionalities in the note taking part of the right panel in viewer mode. It's the plugin Better Notes.

Futur3r commented 1 year ago

Do you know any other extensions which modify the PDF reader view in a similar way? That'd help for building this off.

Now I do ! The PDF Translate plugin adds a tab in the PDF reader view.

Futur3r commented 1 year ago

I searched a bit and if I'm not wrong (and I very probably am), adding this:

    //Add Citations tab to the item pane of the pdf reader
    var itemPaneTabboxReader = doc.getElementById('notes-pane-deck');
    ZoteroOverlay.citationsPane(doc, itemPaneTabboxReader);

there -> https://github.com/diegodlh/zotero-cita/blob/20dfda1cb5a05015253b3c3afffaea17653fe221/src/zoteroOverlay.jsx#L430

Could make it work ? Or at least that's the idea ?

Dominic-DallOsto commented 1 year ago

Thanks! That added a Citations tab to the PDF reader, but for some reason the tab is empty for me.

Once I find out why and fix it, hopefully that's all there is to it...

On 31/12/2022 9:58 pm, Futurer wrote:

I searched a bit and if I'm not wrong (and I very probably am), adding this:

|//Add Citations tab to the item pane of the pdf reader var itemPaneTabboxReader = doc.getElementById('notes-pane-deck'); ZoteroOverlay.citationsPane(doc, itemPaneTabboxReader); |

there -> https://github.com/diegodlh/zotero-cita/blob/20dfda1cb5a05015253b3c3afffaea17653fe221/src/zoteroOverlay.jsx#L430

Could make it work ? Or at least that's the idea ?

— Reply to this email directly, view it on GitHub https://github.com/diegodlh/zotero-cita/issues/208#issuecomment-1368279187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGM5S3FT6AT375W7JISMOD3WQCM6RANCNFSM6AAAAAARXJ4BXU. You are receiving this because you commented.Message ID: @.***>

Futur3r commented 1 year ago

In the zotero-pdf-translate add-on, the equivalent of my last code is defined here.

getReaderTabContainer(): Element { const deck = document.querySelector(".notes-pane-deck").previousElementSibling; // @ts-ignore return deck.selectedPanel; }

And that function is used on the line 266 of the view.ts.

tabContainer = this._Addon.reader.getReaderTabContainer();
const tabbox = tabContainer.querySelector("tabbox") as HTMLElement;
tabbox.querySelector("tabs").appendChild(tab);

And, in Zotero (not related to the previous add-on), when I switch from on "library view" to the pdf reader view, I can see that message in the logs zotero(3)(+0000801): Notifier.trigger('select', 'tab', [tab-OkaYFBqR], {"tab-OkaYFBqR":{"type":"reader"}}) called [observers: 4]

In comparison, when I switch back to the "library view", I see this zotero(3)(+0002388): Notifier.trigger('select', 'tab', [zotero-pane], {"zotero-pane":{"type":"library"}}) called [observers: 4]

The function Zotero.Notifier.trigger() is called here. Zotero.Notifier.trigger('select', 'tab', [tab.id], { [tab.id]: { type: tab.type } }, true);

My hypothesis is that you need to pass the corresponding tab id (i.e [tab-OkaYFBqR]) and tab type (i.e {"zotero-pane":{"type":"library"}) to some function that will know which data of which item to show up ?

Dominic-DallOsto commented 1 year ago

Thanks, yeah. I needed to use the Notifier to listen for new tabs being selected to ensure they always have the Citations tab added. And then needed to change a couple of things with the Citations tabs code, because it assumed only one copy of it would ever exist.

It should be working now - I added a PR with these changes and here's a test build. Just rename the .zip to .xpi because Github won't allow uploading .xpi files.

zotero-cita-v0.5.4-beta.zip

Futur3r commented 1 year ago

Tested it, no problem :) !