Highlights: note format (#15599)
This commit is contained in:
1 parent
e2d4ef3cae
commit
7182dda32b
2 files changed
+24
-6
No files matched your search
@@ -66,14 +66,15 @@ function ReaderAnnotation:buildAnnotation(bm, highlights, init)
|
||||
return { -- annotation
|
||||
datetime = bm.datetime, -- creation time, not changeable
|
||||
datetime_updated = nil, -- last modification time
|
||||
drawer = hl.drawer, -- highlight drawer
|
||||
drawer = hl.drawer, -- highlight style
|
||||
color = hl.color, -- highlight color
|
||||
text = bm.notes, -- highlighted text, editable
|
||||
text_edited = hl.edited, -- true if highlighted text has been edited
|
||||
note = note, -- user's note, editable
|
||||
note_format = nil, -- plain text, or "html" or "md"
|
||||
chapter = chapter, -- book chapter title
|
||||
pageno = pageno, -- book page number (continuous numbering, used by KOHighlights)
|
||||
pageref = pageref, -- book page number (iff: reference pages or hidden flows)
|
||||
pageref = pageref, -- book page number (iff: stable pages or hidden flows)
|
||||
page = bm.page, -- highlight location, xPointer or number (pdf)
|
||||
pos0 = bm.pos0, -- highlight start position, xPointer (== page) or table (pdf)
|
||||
pos1 = bm.pos1, -- highlight end position, xPointer or table (pdf)
|
||||
|
||||
@@ -1285,15 +1285,32 @@ function ReaderHighlight:showChooseHighlightDialog(highlights)
|
||||
end
|
||||
|
||||
function ReaderHighlight:showHighlightNoteOrDialog(index)
|
||||
local bookmark_note = self.ui.annotation.annotations[index].note
|
||||
local anno = self.ui.annotation.annotations[index]
|
||||
local bookmark_note = anno.note
|
||||
if bookmark_note then
|
||||
local note_format = anno.note_format
|
||||
if not note_format then -- try simple heuristics
|
||||
local s = bookmark_note:gsub("^%s*", ""):sub(1, 1)
|
||||
if s == "<" then
|
||||
note_format = "html"
|
||||
elseif s == "#" or s == "*" or s == "[" then
|
||||
note_format = "md"
|
||||
end
|
||||
end
|
||||
local ratio_w, ratio_h
|
||||
if note_format then
|
||||
ratio_w, ratio_h = 0.9, 0.8
|
||||
else
|
||||
ratio_w, ratio_h = 0.8, 0.4
|
||||
end
|
||||
local textviewer
|
||||
textviewer = TextViewer:new{
|
||||
title = _("Note"),
|
||||
show_menu = false,
|
||||
show_menu = note_format ~= nil,
|
||||
text = bookmark_note,
|
||||
width = math.floor(math.min(self.screen_w, self.screen_h) * 0.8),
|
||||
height = math.floor(math.max(self.screen_w, self.screen_h) * 0.4),
|
||||
text_format = note_format,
|
||||
width = math.floor(math.min(self.screen_w, self.screen_h) * ratio_w),
|
||||
height = math.floor(math.max(self.screen_w, self.screen_h) * ratio_h),
|
||||
anchor = function()
|
||||
return self:_getDialogAnchor(textviewer, index)
|
||||
end,
|
||||
|
||||
Reference in new issue
Block a user