PDF: import embedded highlights (#15040)
This commit is contained in:
1 parent
7fdba6a997
commit
3f2cd054d8
3 files changed
+81
-1
No files matched your search
@@ -9,6 +9,7 @@ local DocSettings = require("docsettings")
|
||||
local Event = require("ui/event")
|
||||
local Geom = require("ui/geometry")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local LineWidget = require("ui/widget/linewidget")
|
||||
@@ -995,6 +996,19 @@ function ReaderBookmark:onShowBookmark()
|
||||
},
|
||||
})
|
||||
table.insert(buttons, {}) -- separator
|
||||
if bookmark.document.is_pdf then
|
||||
table.insert(buttons, {
|
||||
{
|
||||
text = _("Import embedded highlights"),
|
||||
enabled = bookmark.document.configurable.text_wrap == 0,
|
||||
callback = function()
|
||||
UIManager:close(bm_dialog)
|
||||
bookmark:importEmbeddedHighlights()
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
table.insert(buttons, {}) -- separator
|
||||
table.insert(buttons, {
|
||||
{
|
||||
text = _("Current page"),
|
||||
@@ -1626,6 +1640,18 @@ function ReaderBookmark:filterByHighlightColor()
|
||||
self.ui.highlight:showHighlightColorDialog(filter_by_color_callback)
|
||||
end
|
||||
|
||||
function ReaderBookmark:importEmbeddedHighlights()
|
||||
local boxes = self.document:getEmbeddedAnnotationsBoxes()
|
||||
if boxes then
|
||||
local count = self.ui.highlight:saveHighlightsFromBoxes(boxes)
|
||||
self.bookmark_menu[1].close_callback()
|
||||
self:onShowBookmark()
|
||||
UIManager:show(InfoMessage:new{ text = T(N_("1 highlight added", "%1 highlights added", count), count) })
|
||||
else
|
||||
UIManager:show(InfoMessage:new{ text = _("No embedded highlights found") })
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderBookmark:doesBookmarkMatchTable(item)
|
||||
if self.match_table[item.type] then
|
||||
if self.match_table.search_str then
|
||||
|
||||
Reference in new issue
Block a user