Store current toc node information when creating highlights

This commit is contained in:
Kovid Goyal 2020-09-01 20:08:10 +05:30
parent 1cfc3c8c78
commit 5ce9010cc3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 2 deletions

View File

@ -237,7 +237,7 @@ class AnnotationsManager: # {{{
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 @@ class AnnotationsManager: # {{{
}
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):

View File

@ -965,7 +965,8 @@ class SelectionBar:
_('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()