forked from akai/readest
fix(kosync): populate chapter field on synced annotations (#4134)
Annotations and bookmarks inserted into KOReader via the Readest sync plugin were missing the chapter field, which native KOReader highlights stamp at creation time. Downstream tools that group highlights by chapter (e.g. obsidian-koreader-highlights, KOReader's own Markdown exporter) treated these as orphans. Resolve the chapter title from the xpointer using the same TOC call that ReaderHighlight uses natively, and include it on both annotation and bookmark item tables. Closes #4133
This commit is contained in:
@@ -300,6 +300,10 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog
|
||||
|
||||
-- Resolve KOReader page number from xpointer
|
||||
local pageno = ui.document:getPageFromXPointer(xp0) or note.page
|
||||
-- Resolve chapter title so downstream tools can group by chapter,
|
||||
-- matching native KOReader highlight creation behavior.
|
||||
local chapter = ui.toc and ui.toc:getTocTitleByPage(xp0) or nil
|
||||
if chapter == "" then chapter = nil end
|
||||
|
||||
if note_type == "bookmark" then
|
||||
if existing_bookmarks[xp0] then goto continue end
|
||||
@@ -309,6 +313,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog
|
||||
page = xp0,
|
||||
text = note.text or "",
|
||||
note = note.note or "",
|
||||
chapter = chapter,
|
||||
pageno = pageno,
|
||||
datetime = datetime_str,
|
||||
datetime_updated = datetime_updated_str,
|
||||
@@ -335,6 +340,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog
|
||||
note = note.note or "",
|
||||
drawer = drawer,
|
||||
color = READEST_TO_KO_COLOR[note.color] or "yellow",
|
||||
chapter = chapter,
|
||||
pageno = pageno,
|
||||
datetime = datetime_str,
|
||||
datetime_updated = datetime_updated_str,
|
||||
|
||||
Reference in New Issue
Block a user