stelzch / zotero.koplugin

Display Zotero collection on E-Readers with KOReader
GNU General Public License v3.0
45 stars 2 forks source link

FR Idea: Sync Zotero Annotations #13

Open ryanwwest opened 5 months ago

ryanwwest commented 5 months ago

Zotero's Web API v3 allows syncing annotations, which in Zotero will include annotations for PDF, EPUB, and HTML (which is a pretty large subset of what KOReader allows for annotation too). Zotero's annotation offerings uses the open Web Annotation Data Model schema are actually quite similar to KOReader's - there is a start and stop position for a highlight, a copy of the highlighted text 'style' (colors for Zotero, vs. highlighted/underlined/strikethrough/invert for KOReader), and a few more fields. Both of them also support basic text notes which are both anchored to highlights.

I think there is sufficient feature overlap that there could be a translation layer that displays Zotero annotations as KOReader annotations when the Zotero attachment is opened in KOReader (after browsing and selecting). Eventually even modifying/adding/deleting annotations in KOReader and syncing the changes back to the Web API would be ideal, but read-only would be a first step. This would make annotations much more valuable as they are no longer isolated to one system. (Ideally, a universal file format based on WADM might be better, but two largely supported programs is better than one).

There are some issues to overcome with annotation translation:

  1. KOReader highlights are positioned differently from Zotero's (e.g. different coordinate 0,0 orientation, different scale, more). I tried to figure this out a few months ago but didn't get there
  2. KOReader highlight styles are primarily intended for black-and-white screens while Zotero highlights are only stylized by color (and RGB color is allowed, but the UI picker only shows ~9 options). My initial idea has been to map the first four preset Zotero colors to the four KOReader black-white-friendly options, but KOReader color highlighting may be added soon and partially solve this.
  3. KOReader's bookmark and highlight structure in Lua docsettings are a bit confusing.
  4. Zotero area selections and hovering notes (not anchored to text) don't have a corollary in KOReader (maybe add them as a KOReader FR in the future?). Technically neither do Zotero item notes (not attachment notes), but the latter one can probably be ignored. Zotero will probably add more features, and only some will be KOReader-recognizable.
  5. Would need to decide how to deal with offline Zotero annotation storage in KOReader, though I think the plugin itself needs to be further developed first.

Here's an example set of highlights in Zotero on top, the same in KOReader on bottom, followed by the data structure used for the two Zotero highlights which I think is accessible via Web API:

image

I might be able to help build this at some point, but I don't currently have the time. I have the beginnings of a translation layer in Python but it's early on and needs to be in Lua anyway.

antrmn commented 1 month ago

KOReader's bookmark and highlight structure in Lua docsettings are a bit confusing.

I wonder if this is still true in the latest version of KOReader (2024.07)

CobriMediaJulien commented 5 days ago

i hope colored highlights come soon. with the new eink color displays that would be awesome

ryanwwest commented 5 days ago

@CobriMediaJulien I think the next KOReader release might add color highlights (https://github.com/koreader/koreader/issues/9024).