mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 10:54:53 +02:00
Store current toc node information when creating highlights
This commit is contained in:
parent
1cfc3c8c78
commit
5ce9010cc3
2 changed files with 7 additions and 2 deletions
|
|
@ -237,7 +237,7 @@ def cfi_for_highlight(self, uuid, spine_index):
|
|||
x = 2 * (spine_index + 1)
|
||||
return f'epubcfi(/{x}{h.start_cfi})'
|
||||
|
||||
def add_highlight(self, msg, style, notes):
|
||||
def add_highlight(self, msg, style, notes, toplevel_toc_node, toc_node):
|
||||
now = Date().toISOString()
|
||||
for uuid in msg.removed_highlights:
|
||||
self.remove_highlight(uuid)
|
||||
|
|
@ -255,6 +255,10 @@ def add_highlight(self, msg, style, notes):
|
|||
}
|
||||
if notes:
|
||||
annot.notes = notes
|
||||
if toplevel_toc_node?.title:
|
||||
annot.top_level_section_title = toplevel_toc_node.title
|
||||
if toc_node?.title:
|
||||
annot.lowest_level_section_title = toc_node.title
|
||||
self.sync_annots_to_server('highlights')
|
||||
|
||||
def highlights_for_currently_showing(self):
|
||||
|
|
|
|||
|
|
@ -965,7 +965,8 @@ def handle_message(self, msg):
|
|||
_('Highlighting failed'),
|
||||
_('Failed to apply highlighting, try adjusting extent of highlight')
|
||||
)
|
||||
self.annotations_manager.add_highlight(msg, self.current_highlight_style.style, notes)
|
||||
self.annotations_manager.add_highlight(
|
||||
msg, self.current_highlight_style.style, notes, self.view.current_toc_toplevel_node, self.view.current_toc_node)
|
||||
elif msg.type is 'edit-highlight':
|
||||
if self.state is WAITING:
|
||||
self.create_highlight()
|
||||
|
|
|
|||
Loading…
Reference in a new issue