mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-21 19:23:18 +02:00
Fix notes indicator not being updated when editing notes from the highlights panels
This commit is contained in:
parent
832211b904
commit
7db1a9d0a4
4 changed files with 23 additions and 2 deletions
|
|
@ -152,6 +152,12 @@ def wrap_text_in_range(styler, r, class_to_add_to_last, process_wrapper):
|
|||
return crw, Object.keys(intersecting_wrappers)
|
||||
|
||||
|
||||
def last_span_for_crw(crw):
|
||||
nodes = document.querySelectorAll(f'span[data-calibre-range-wrapper="{crw}"]')
|
||||
if nodes and nodes.length:
|
||||
return nodes[-1]
|
||||
|
||||
|
||||
def reset_highlight_counter():
|
||||
nonlocal wrapper_counter
|
||||
wrapper_counter = 0
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
from fs_images import fix_fullscreen_svg_images
|
||||
from iframe_comm import IframeClient
|
||||
from range_utils import (
|
||||
highlight_associated_with_selection, reset_highlight_counter, select_crw,
|
||||
unwrap_all_crw, unwrap_crw, wrap_text_in_range
|
||||
highlight_associated_with_selection, last_span_for_crw, reset_highlight_counter,
|
||||
select_crw, unwrap_all_crw, unwrap_crw, wrap_text_in_range
|
||||
)
|
||||
from read_book.cfi import cfi_for_selection, range_from_cfi
|
||||
from read_book.extract import get_elements
|
||||
|
|
@ -752,6 +752,16 @@ def annotations_msg_received(self, data):
|
|||
window.setTimeout(def():
|
||||
self.send_message('annotations', type='edit-highlight')
|
||||
, 50)
|
||||
elif data.type is 'notes-edited':
|
||||
cls = 'crw-has-dot'
|
||||
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
||||
if crw_:
|
||||
node = last_span_for_crw(crw_)
|
||||
if node:
|
||||
if data.has_notes:
|
||||
node.classList.add(cls)
|
||||
else:
|
||||
node.classList.remove(cls)
|
||||
elif data.type is 'remove-highlight':
|
||||
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
||||
if crw_:
|
||||
|
|
|
|||
|
|
@ -828,6 +828,10 @@ def edit_highlight(self, annot_id):
|
|||
def send_message(self, type, **kw):
|
||||
self.view.iframe_wrapper.send_message('annotations', type=type, **kw)
|
||||
|
||||
def notes_edited(self, annot_id):
|
||||
notes = self.annotations_manager.notes_for_highlight(annot_id)
|
||||
self.send_message('notes-edited', uuid=annot_id, has_notes=bool(notes))
|
||||
|
||||
def handle_message(self, msg):
|
||||
if msg.type is 'highlight-applied':
|
||||
notes = self.current_notes
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,7 @@ def sync_data_received(self, reading_pos_cfi, annotations_map):
|
|||
|
||||
def set_notes_for_highlight(self, uuid, notes):
|
||||
if self.annotations_manager.set_notes_for_highlight(uuid, notes):
|
||||
self.selection_bar.notes_edited(uuid)
|
||||
self.selection_bar.update_position()
|
||||
|
||||
def on_next_spine_item(self, data):
|
||||
|
|
|
|||
Loading…
Reference in a new issue