mirror of
https://github.com/koreader/koreader.git
synced 2025-12-24 12:14:05 +01:00
Annotations: pageno honors reference pages and hidden flows (#12214)
This commit is contained in:
@@ -24,7 +24,7 @@ function ReaderAnnotation:buildAnnotation(bm, highlights, init)
|
|||||||
if chapter == nil then
|
if chapter == nil then
|
||||||
chapter = self.ui.toc:getTocTitleByPage(bm.page)
|
chapter = self.ui.toc:getTocTitleByPage(bm.page)
|
||||||
end
|
end
|
||||||
pageno = self.ui.paging and bm.page or self.document:getPageFromXPointer(bm.page)
|
pageno = self.ui.bookmark:getBookmarkPageString(bm.page)
|
||||||
end
|
end
|
||||||
if self.ui.paging and bm.pos0 and not bm.pos0.page then
|
if self.ui.paging and bm.pos0 and not bm.pos0.page then
|
||||||
-- old single-page reflow highlights do not have page in position
|
-- old single-page reflow highlights do not have page in position
|
||||||
@@ -53,7 +53,7 @@ function ReaderAnnotation:buildAnnotation(bm, highlights, init)
|
|||||||
text_edited = hl.edited, -- true if highlighted text has been edited
|
text_edited = hl.edited, -- true if highlighted text has been edited
|
||||||
note = note, -- user's note, editable
|
note = note, -- user's note, editable
|
||||||
chapter = chapter, -- book chapter title
|
chapter = chapter, -- book chapter title
|
||||||
pageno = pageno, -- book page number
|
pageno = pageno, -- book page number (honors reference pages and hidden flows)
|
||||||
page = bm.page, -- highlight location, xPointer or number (pdf)
|
page = bm.page, -- highlight location, xPointer or number (pdf)
|
||||||
pos0 = bm.pos0, -- highlight start position, xPointer (== page) or table (pdf)
|
pos0 = bm.pos0, -- highlight start position, xPointer (== page) or table (pdf)
|
||||||
pos1 = bm.pos1, -- highlight end position, xPointer or table (pdf)
|
pos1 = bm.pos1, -- highlight end position, xPointer or table (pdf)
|
||||||
@@ -227,10 +227,11 @@ end
|
|||||||
|
|
||||||
-- items handling
|
-- items handling
|
||||||
|
|
||||||
function ReaderAnnotation:updatePageNumbers()
|
function ReaderAnnotation:updatePageNumbers(force_update)
|
||||||
if self.needs_update and self.ui.rolling then -- triggered by ReaderRolling on document layout change
|
if self.ui.paging then return end
|
||||||
|
if force_update or self.needs_update then -- triggered by ReaderRolling on document layout change
|
||||||
for _, item in ipairs(self.annotations) do
|
for _, item in ipairs(self.annotations) do
|
||||||
item.pageno = self.document:getPageFromXPointer(item.page)
|
item.pageno = self.ui.bookmark:getBookmarkPageString(item.page)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.needs_update = nil
|
self.needs_update = nil
|
||||||
@@ -265,7 +266,7 @@ function ReaderAnnotation:updateItemByXPointer(item)
|
|||||||
item.text = chapter and T(_("in %1"), chapter) or nil
|
item.text = chapter and T(_("in %1"), chapter) or nil
|
||||||
end
|
end
|
||||||
item.chapter = chapter
|
item.chapter = chapter
|
||||||
item.pageno = self.document:getPageFromXPointer(item.page)
|
item.pageno = self.ui.bookmark:getBookmarkPageString(item.page)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReaderAnnotation:isItemInPositionOrderRolling(a, b)
|
function ReaderAnnotation:isItemInPositionOrderRolling(a, b)
|
||||||
@@ -396,7 +397,7 @@ end
|
|||||||
|
|
||||||
function ReaderAnnotation:addItem(item)
|
function ReaderAnnotation:addItem(item)
|
||||||
item.datetime = os.date("%Y-%m-%d %H:%M:%S")
|
item.datetime = os.date("%Y-%m-%d %H:%M:%S")
|
||||||
item.pageno = self.ui.paging and item.page or self.document:getPageFromXPointer(item.page)
|
item.pageno = self.ui.bookmark:getBookmarkPageString(item.page)
|
||||||
local index = self:getInsertionIndex(item)
|
local index = self:getInsertionIndex(item)
|
||||||
table.insert(self.annotations, index, item)
|
table.insert(self.annotations, index, item)
|
||||||
return index
|
return index
|
||||||
|
|||||||
@@ -350,6 +350,7 @@ function ReaderPageMap:addToMainMenu(menu_items)
|
|||||||
-- Reset a few stuff that may use page labels
|
-- Reset a few stuff that may use page labels
|
||||||
self.ui.toc:resetToc()
|
self.ui.toc:resetToc()
|
||||||
self.ui.view.footer:onUpdateFooter()
|
self.ui.view.footer:onUpdateFooter()
|
||||||
|
self.ui.annotation:updatePageNumbers(true)
|
||||||
UIManager:setDirty(self.view.dialog, "partial")
|
UIManager:setDirty(self.view.dialog, "partial")
|
||||||
end,
|
end,
|
||||||
hold_callback = function(touchmenu_instance)
|
hold_callback = function(touchmenu_instance)
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ end
|
|||||||
|
|
||||||
--- Parse and export highlights from the currently opened document.
|
--- Parse and export highlights from the currently opened document.
|
||||||
function Exporter:exportCurrentNotes()
|
function Exporter:exportCurrentNotes()
|
||||||
self.ui.annotation:updatePageNumbers()
|
self.ui.annotation:updatePageNumbers(true)
|
||||||
local clippings = self:getDocumentClippings()
|
local clippings = self:getDocumentClippings()
|
||||||
self:exportClippings(clippings)
|
self:exportClippings(clippings)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user