mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit button on highlight panel works again
This commit is contained in:
parent
13e2ec4b63
commit
16d241b9d2
@ -600,8 +600,6 @@ class IframeBoss:
|
||||
if sc_name:
|
||||
if self.handle_navigation_shortcut(sc_name, evt):
|
||||
evt.preventDefault()
|
||||
elif sc_name is 'create_annotation':
|
||||
self.initiate_creation_of_annotation()
|
||||
else:
|
||||
self.send_message('handle_shortcut', name=sc_name)
|
||||
|
||||
@ -712,27 +710,9 @@ class IframeBoss:
|
||||
else:
|
||||
end_reference_mode()
|
||||
|
||||
def initiate_creation_of_annotation(self, existing, start_in_notes_edit):
|
||||
self.auto_scroll_action('stop')
|
||||
in_flow_mode = current_layout_mode() is 'flow'
|
||||
if not existing:
|
||||
annot_id = set_selection_to_highlight()
|
||||
if annot_id:
|
||||
existing = annot_id_uuid_map[annot_id]
|
||||
self.send_message(
|
||||
'annotations',
|
||||
type='create-annotation',
|
||||
in_flow_mode=in_flow_mode,
|
||||
extents=selection_extents(in_flow_mode),
|
||||
existing=existing or None,
|
||||
start_in_notes_edit=v'!!start_in_notes_edit',
|
||||
)
|
||||
|
||||
def annotations_msg_received(self, data):
|
||||
in_flow_mode = current_layout_mode() is 'flow'
|
||||
if data.type is 'create':
|
||||
self.initiate_creation_of_annotation(None, data.start_in_notes_edit)
|
||||
elif data.type is 'set-selection':
|
||||
if data.type is 'set-selection':
|
||||
set_selections_extents_to(data.extents)
|
||||
elif data.type is 'position-handles-at-point':
|
||||
extents = selection_extents_at_point(data.x, data.y, in_flow_mode)
|
||||
@ -766,7 +746,9 @@ class IframeBoss:
|
||||
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
||||
if crw_ and select_crw(crw_):
|
||||
self.ensure_selection_visible()
|
||||
self.initiate_creation_of_annotation(data.uuid)
|
||||
window.setTimeout(def():
|
||||
self.send_message('annotations', type='edit-highlight')
|
||||
, 50)
|
||||
elif data.type is 'remove-highlight':
|
||||
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid]
|
||||
if crw_:
|
||||
|
@ -725,7 +725,7 @@ class SelectionBar:
|
||||
self.annotations_manager.delete_highlight(annot_id)
|
||||
|
||||
def edit_highlight(self, annot_id):
|
||||
pass # TODO: Implement this
|
||||
self.send_message('edit-highlight', uuid=annot_id)
|
||||
# }}}
|
||||
|
||||
# Interact with iframe {{{
|
||||
@ -743,6 +743,9 @@ class SelectionBar:
|
||||
_('Failed to apply highlighting, try adjusting extent of highlight')
|
||||
)
|
||||
self.annotations_manager.add_highlight(msg, self.current_highlight_style.style, notes)
|
||||
if msg.type is 'edit-highlight':
|
||||
if self.state is WAITING:
|
||||
self.create_highlight()
|
||||
else:
|
||||
print('Ignoring annotations message with unknown type:', msg.type)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user