readerhighlight: restore highlight for orphaned bookmark

reviewable/pr11553/r2
hius07 2 months ago committed by GitHub
parent 1b60e318c1
commit 50052eaf23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2224,14 +2224,27 @@ function ReaderHighlight:updateHighlightPageNumbers()
local bookmark = bookmarks[i]
if bookmark.highlighted then
local highlight = self:getHighlightByDatetime(bookmark.datetime)
if not highlight and (self.ui.rolling or bookmark.pos0.page == bookmark.pos1.page) then
-- restore highlight for orphaned bookmark
-- do not bother with restoring pboxes for pdf multi-page highlight, keep bookmark orphaned
highlight = {
datetime = bookmark.datetime,
text = bookmark.notes,
chapter = bookmark.chapter,
pos0 = bookmark.pos0,
pos1 = bookmark.pos1,
drawer = self.view.highlight.saved_drawer,
}
if self.ui.paging then
highlight.pboxes = self.document:getPageBoxesFromPositions(bookmark.page, bookmark.pos0, bookmark.pos1)
end
end
if highlight then
local pageno = self.ui.paging and bookmark.page or self.document:getPageFromXPointer(bookmark.page)
if highlights[pageno] == nil then
highlights[pageno] = {}
end
table.insert(highlights[pageno], highlight)
else -- orphan
table.remove(bookmarks, i)
end
end
end

Loading…
Cancel
Save