melat0nin / zotero-roam-export

A Zotero addon for exporting to Roam
MIT License
179 stars 12 forks source link

Is there a way to use the clipboard, in addition to file export-import? #5

Closed pinusm closed 4 years ago

pinusm commented 4 years ago

I might be talking out of sheer ignorance, but I was thinking maybe a custom CSL could allow a workflow that goes through the clipboard (Create Citation/Bibliography dialog) , and avoid the interim file creation. Do you know if that's feasible? I'm guessing this would be limited to a single reference, as Roam would have trouble making sense of multiple references in a single paste operation. Have you considered this approach before? This would obviously be in addition to the current workflow, as it allows multi-ref/collection exports.

melat0nin commented 4 years ago

AFAIK the limitation there would be that translators (which shift+ctrl+c invokes) cannot access collection names or the objects of related items, so that information is not available to them. This was the problem with the previous version of this addon, which was a translator (see https://github.com/melat0nin/translators). I stopped developing that because the lack of deeper access to the Zotero database severely limited its utility (for me, at least -- I use collections as topic groupings, so this is a fundamental way to map my Zotero database into my Roam graph via topic linkages between items/pages).

See e.g. here in the Zotero codebase: https://github.com/zotero/zotero/blob/ad9604e267e3bc3635aa215632a530e93f4e791b/chrome/content/zotero/fileInterface.js#L187. The in-built exportItemsToClipboard function uses Zotero.Translate, which limits access to the current item's data only.

It might be possible to adapt the addon's code to do the export to the clipboard instead of a file, but it's not something I have time to prioritise at the moment unfortunately. Happy to accept PRs if you're willing though! It'd need (i) exporting to clipboard (the code referenced above could help), and (ii) a new keyboard shortcut (this would probably require digging into fileInterface.js to emulate.

melat0nin commented 4 years ago

You might find this useful, although it has the same problem of only having limited access to the database: https://gist.github.com/clement-moulin-frier/0502aff4e9117cca8f5f9200f0eb4b0f

pinusm commented 4 years ago

That's super! Thanks! A PR is a bit over my head programming-skill-wise, but I'll try to use the translator, and report back if I encounter any issues.. Closing, as this is becoming unrelated to zotero-roam-export.