mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix notes indicator not being updated when editing notes from the highlights panels
This commit is contained in:
parent
832211b904
commit
7db1a9d0a4
@ -152,6 +152,12 @@ def wrap_text_in_range(styler, r, class_to_add_to_last, process_wrapper):
|
|||||||
return crw, Object.keys(intersecting_wrappers)
|
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():
|
def reset_highlight_counter():
|
||||||
nonlocal wrapper_counter
|
nonlocal wrapper_counter
|
||||||
wrapper_counter = 0
|
wrapper_counter = 0
|
||||||
|
@ -9,8 +9,8 @@ from select import move_end_of_selection, selection_extents, word_at_point
|
|||||||
from fs_images import fix_fullscreen_svg_images
|
from fs_images import fix_fullscreen_svg_images
|
||||||
from iframe_comm import IframeClient
|
from iframe_comm import IframeClient
|
||||||
from range_utils import (
|
from range_utils import (
|
||||||
highlight_associated_with_selection, reset_highlight_counter, select_crw,
|
highlight_associated_with_selection, last_span_for_crw, reset_highlight_counter,
|
||||||
unwrap_all_crw, unwrap_crw, wrap_text_in_range
|
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.cfi import cfi_for_selection, range_from_cfi
|
||||||
from read_book.extract import get_elements
|
from read_book.extract import get_elements
|
||||||
@ -752,6 +752,16 @@ class IframeBoss:
|
|||||||
window.setTimeout(def():
|
window.setTimeout(def():
|
||||||
self.send_message('annotations', type='edit-highlight')
|
self.send_message('annotations', type='edit-highlight')
|
||||||
, 50)
|
, 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':
|
elif data.type is 'remove-highlight':
|
||||||
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
||||||
if crw_:
|
if crw_:
|
||||||
|
@ -828,6 +828,10 @@ class SelectionBar:
|
|||||||
def send_message(self, type, **kw):
|
def send_message(self, type, **kw):
|
||||||
self.view.iframe_wrapper.send_message('annotations', type=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):
|
def handle_message(self, msg):
|
||||||
if msg.type is 'highlight-applied':
|
if msg.type is 'highlight-applied':
|
||||||
notes = self.current_notes
|
notes = self.current_notes
|
||||||
|
@ -1066,6 +1066,7 @@ class View:
|
|||||||
|
|
||||||
def set_notes_for_highlight(self, uuid, notes):
|
def set_notes_for_highlight(self, uuid, notes):
|
||||||
if self.annotations_manager.set_notes_for_highlight(uuid, notes):
|
if self.annotations_manager.set_notes_for_highlight(uuid, notes):
|
||||||
|
self.selection_bar.notes_edited(uuid)
|
||||||
self.selection_bar.update_position()
|
self.selection_bar.update_position()
|
||||||
|
|
||||||
def on_next_spine_item(self, data):
|
def on_next_spine_item(self, data):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user