diff --git a/src/pyj/read_book/annotations.pyj b/src/pyj/read_book/annotations.pyj index f1102db45e..a7126ac52e 100644 --- a/src/pyj/read_book/annotations.pyj +++ b/src/pyj/read_book/annotations.pyj @@ -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): diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index 30faf7bc72..e9ce649ec1 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -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()