Exporter: selected files (#10453)

Export highlights for selected files.
Having a button "Select all files in folder", it is easy to export the whole folder.
So, closes #10402.

To keep even number of buttons, added a feature "Show selected files list". May be useful to check selections before an operation. Just a sorted list, no titlebar or popup menu, tapping a file jumps to its folder.
This commit is contained in:
hius07
2023-05-19 10:55:49 +03:00
committed by GitHub
parent 7e98b9de4b
commit 3d5775241d
3 changed files with 89 additions and 9 deletions

View File

@@ -150,11 +150,14 @@ function Exporter:getDocumentClippings()
return self.parser:parseCurrentDoc(self.view) or {}
end
--- Parse and export highlights from the currently opened document.
function Exporter:exportCurrentNotes()
local clippings = self:getDocumentClippings()
self:exportClippings(clippings)
end
--- Parse and export highlights from all the documents in History
-- and from the Kindle "My Clippings.txt".
function Exporter:exportAllNotes()
local clippings = {}
clippings = updateHistoryClippings(clippings, self.parser:parseHistory())
@@ -170,6 +173,19 @@ function Exporter:exportAllNotes()
self:exportClippings(clippings)
end
--- Parse and export highlights from selected documents.
-- @tparam table files list of files as a table of {[file_path] = true}
function Exporter:exportFilesNotes(files)
local clippings = self.parser:parseFiles(files)
for title, booknotes in pairs(clippings) do
-- chapter number is zero
if #booknotes == 0 then
clippings[title] = nil
end
end
self:exportClippings(clippings)
end
function Exporter:exportClippings(clippings)
if type(clippings) ~= "table" then return end
local exportables = {}