mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show an indicator for a highlight that has notes
This commit is contained in:
parent
3f90a15a04
commit
62c82232c5
@ -126,7 +126,7 @@ def create_wrapper_function(wrapper_elem, r, intersecting_wrappers, process_wrap
|
|||||||
wrapper_counter = 0
|
wrapper_counter = 0
|
||||||
|
|
||||||
|
|
||||||
def wrap_text_in_range(styler, r, process_wrapper):
|
def wrap_text_in_range(styler, r, class_to_add, process_wrapper):
|
||||||
if not r:
|
if not r:
|
||||||
sel = window.getSelection()
|
sel = window.getSelection()
|
||||||
if not sel or not sel.rangeCount:
|
if not sel or not sel.rangeCount:
|
||||||
@ -136,6 +136,8 @@ def wrap_text_in_range(styler, r, process_wrapper):
|
|||||||
return None, v'[]'
|
return None, v'[]'
|
||||||
|
|
||||||
wrapper_elem = document.createElement('span')
|
wrapper_elem = document.createElement('span')
|
||||||
|
if class_to_add:
|
||||||
|
wrapper_elem.classList.add(class_to_add)
|
||||||
wrapper_elem.dataset.calibreRangeWrapper = v'++wrapper_counter' + ''
|
wrapper_elem.dataset.calibreRangeWrapper = v'++wrapper_counter' + ''
|
||||||
if styler:
|
if styler:
|
||||||
styler(wrapper_elem)
|
styler(wrapper_elem)
|
||||||
|
@ -748,7 +748,8 @@ class IframeBoss:
|
|||||||
return
|
return
|
||||||
bounds = cfi_for_selection()
|
bounds = cfi_for_selection()
|
||||||
style = highlight_style_as_css(data.style, opts.is_dark_theme, opts.color_scheme.foreground)
|
style = highlight_style_as_css(data.style, opts.is_dark_theme, opts.color_scheme.foreground)
|
||||||
annot_id, intersecting_wrappers = wrap_text_in_range(style, None, self.add_highlight_listeners)
|
cls = 'crw-has-dot' if data.has_notes else None
|
||||||
|
annot_id, intersecting_wrappers = wrap_text_in_range(style, None, cls, self.add_highlight_listeners)
|
||||||
removed_highlights = v'[]'
|
removed_highlights = v'[]'
|
||||||
if annot_id is not None:
|
if annot_id is not None:
|
||||||
intersecting_uuids = {annot_id_uuid_map[x]:True for x in intersecting_wrappers}
|
intersecting_uuids = {annot_id_uuid_map[x]:True for x in intersecting_wrappers}
|
||||||
@ -788,7 +789,8 @@ class IframeBoss:
|
|||||||
if not r:
|
if not r:
|
||||||
continue
|
continue
|
||||||
style = highlight_style_as_css(h.style, opts.is_dark_theme, opts.color_scheme.foreground)
|
style = highlight_style_as_css(h.style, opts.is_dark_theme, opts.color_scheme.foreground)
|
||||||
annot_id, intersecting_wrappers = wrap_text_in_range(style, r, self.add_highlight_listeners)
|
cls = 'crw-has-dot' if h.notes else None
|
||||||
|
annot_id, intersecting_wrappers = wrap_text_in_range(style, r, cls, self.add_highlight_listeners)
|
||||||
if annot_id is not None:
|
if annot_id is not None:
|
||||||
annot_id_uuid_map[annot_id] = h.uuid
|
annot_id_uuid_map[annot_id] = h.uuid
|
||||||
for crw in intersecting_wrappers:
|
for crw in intersecting_wrappers:
|
||||||
|
@ -686,7 +686,8 @@ class SelectionBar:
|
|||||||
self.current_highlight_style = ed.current_style
|
self.current_highlight_style = ed.current_style
|
||||||
self.current_notes = ed.current_notes
|
self.current_notes = ed.current_notes
|
||||||
self.send_message(
|
self.send_message(
|
||||||
'apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid(), existing=ed.annot_id
|
'apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid(), existing=ed.annot_id,
|
||||||
|
has_notes=v'!!self.current_notes'
|
||||||
)
|
)
|
||||||
self.state = WAITING
|
self.state = WAITING
|
||||||
self.update_position()
|
self.update_position()
|
||||||
@ -743,7 +744,7 @@ class SelectionBar:
|
|||||||
self.create_highlight()
|
self.create_highlight()
|
||||||
else:
|
else:
|
||||||
self.current_notes = ''
|
self.current_notes = ''
|
||||||
self.send_message('apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid())
|
self.send_message('apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid(), has_notes=False)
|
||||||
self.state = WAITING
|
self.state = WAITING
|
||||||
self.update_position()
|
self.update_position()
|
||||||
|
|
||||||
|
@ -97,6 +97,20 @@ def apply_colors(is_content_popup):
|
|||||||
# for firefox: https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-width
|
# for firefox: https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-width
|
||||||
text += '\nhtml, body { scrollbar-width: none !important }'
|
text += '\nhtml, body { scrollbar-width: none !important }'
|
||||||
|
|
||||||
|
# show a dot after highlights that have notes
|
||||||
|
text += '''\n\n
|
||||||
|
.crw-has-dot::after {
|
||||||
|
content: "\xa0";\
|
||||||
|
vertical-align: text-top;\
|
||||||
|
background-color: currentColor !important;\
|
||||||
|
text-decoration: none !important;\
|
||||||
|
display: inline-block;\
|
||||||
|
height: 0.7ex;\
|
||||||
|
width: 0.7ex;\
|
||||||
|
border-radius: 50%;\
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
ss.textContent = text
|
ss.textContent = text
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user