mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Color controls for the comments editor on the EM page
This commit is contained in:
parent
71c18acc7b
commit
2ddfa2aa43
13
imgsrc/srv/bg.svg
Normal file
13
imgsrc/srv/bg.svg
Normal file
@ -0,0 +1,13 @@
|
||||
<svg viewBox="0 0 128 128" height="128" width="128">
|
||||
<g transform="translate(0,-924.36216)">
|
||||
<g transform="translate(0.00260059,0.00376367)">
|
||||
<path d="m 40.013479,999.06915 c 6.359757,4.67475 20.124993,-3.15171 30.748644,-17.46631 l 33.295197,33.61766 c -10.626597,14.3161 -20.771572,17.651 -27.134275,12.9792"/>
|
||||
<ellipse transform="matrix(-0.8058623,-0.592103,0.59573364,-0.80318206,0,0)" cx="-616.16022" cy="-748.86212" rx="14.290408" ry="32.282364" />
|
||||
<path d="m 85.46409,977.45432 c 3.178405,-2.48472 6.266967,-5.64375 9.022665,-9.36276 0.785028,-1.05546 1.517033,-2.1285 2.198962,-3.20448 7.602843,-12.04097 8.679493,-24.85155 2.075243,-29.70811 -5.9886,-4.40066 -16.413416,-0.87222 -25.244612,7.869"/>
|
||||
<path d="m 31.182284,992.23215 56.121393,44.06525 c 5.727905,4.2086 18.116023,-2.8366 27.674813,-15.719 9.55141,-12.8912 12.66501,-26.74548 6.94153,-30.94971 L 69.644231,940.36975"/>
|
||||
<path d="m 64.359653,971.28577 c -12.75928,-0.0748 -27.904574,4.3303 -33.175896,7.31929 -5.26985,2.98899 -12.095026,8.47882 -15.822804,14.98012 -3.729251,6.50422 -5.051868,17.33732 -0.29457,24.86472 0,0 6.227201,9.4258 7.65439,19.0671 0.768827,3.1928 -1.322617,7.4981 5.275741,8.7647 6.596886,1.2695 4.73226,-12.8912 4.73226,-12.8912 0,0 -0.631851,-3.8085 -1.543544,-7.9101 -1.624551,-9.263 4.813266,-29.4706 4.813266,-29.4706 0,0 1.857261,-2.08159 6.938586,-4.3347 2.947169,-1.27241 8.386396,-5.52794 8.386396,-5.52794 l 5.857515,-5.61883 4.755826,-5.76395 c -0.0044,0 1.281377,-1.66674 2.422834,-3.47861 z"/>
|
||||
<path d="m 24.801907,980.76288 c 0,0 -21.867371,-2.08306 -20.6728915,6.1231 1.1959525,8.20616 7.2611395,3.59148 10.3364455,-1.19032 3.073834,-4.78326 10.336446,-4.93278 10.336446,-4.93278 z"/>
|
||||
<path d="m 15.670251,989.86324 c 0,0 -19.2648493,10.50616 -13.6415164,16.62636 5.6233329,6.1187 8.0343844,-1.0877 7.87679,-6.76666 -0.1575947,-5.676 5.7647264,-9.8597 5.7647264,-9.8597 z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
9
imgsrc/srv/fg.svg
Normal file
9
imgsrc/srv/fg.svg
Normal file
@ -0,0 +1,9 @@
|
||||
<svg viewBox="0 0 128 128" height="128" width="128">
|
||||
<g transform="translate(0,-924.36216)">
|
||||
<g>
|
||||
<rect height="33.711269" width="48.158955" transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,0,0)" y="732.13635" x="-634.40143"/>
|
||||
<polygon points="19.092,13.435 18.385,12.728 13.435,7.778 12.727,7.071 10.605,9.192 16.971,15.557 " transform="matrix(4.8159417,0,0,4.8159417,0.99999969,932.22665)"/>
|
||||
<path d="m 72.511918,1030.9824 c 7.098698,-7.0987 8.23526,-14.183 6.713423,-20.54 l -31.73224,-31.71783 c -5.663548,-0.83798 -12.155437,0.89095 -19.254135,7.98964 -17.024354,17.02439 3.404871,44.26819 -27.23896631,47.67299 30.64383731,17.0292 57.88761931,10.2194 71.51191831,-3.4048 z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 742 B |
@ -53,6 +53,12 @@ def choose_block_style(proceed):
|
||||
)
|
||||
|
||||
|
||||
def insert_heading(editor_id, cmd):
|
||||
editor = registry[editor_id]
|
||||
if cmd:
|
||||
editor.exec_command('formatBlock', f'<{cmd}>')
|
||||
editor.focus()
|
||||
|
||||
|
||||
def insert_link(title, msg, proceed):
|
||||
create_custom_dialog(title, def(parent, close_modal):
|
||||
@ -91,13 +97,34 @@ def insert_link_or_image(editor_id, is_image, ok, url, title):
|
||||
editor.focus()
|
||||
|
||||
|
||||
def insert_heading(editor_id, cmd):
|
||||
def set_color(title, msg, proceed):
|
||||
create_custom_dialog(title, def(parent, close_modal):
|
||||
def action(ok, evt):
|
||||
close_modal()
|
||||
c = evt.currentTarget.closest('.sc-modal-container')
|
||||
color = c.querySelector('input[name="color"]').value
|
||||
proceed(ok, color)
|
||||
|
||||
parent.appendChild(E.div(class_='sc-modal-container',
|
||||
E.div(msg),
|
||||
E.div(E.input(type='color', name='color')),
|
||||
E.div(class_='button-box',
|
||||
create_button(_('OK'), action=action.bind(None, True), highlight=True),
|
||||
'\xa0',
|
||||
create_button(_('Cancel'), action=action.bind(None, False), highlight=False),
|
||||
),
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
def change_color(editor_id, which, ok, color):
|
||||
editor = registry[editor_id]
|
||||
if cmd:
|
||||
editor.exec_command('formatBlock', f'<{cmd}>')
|
||||
if ok:
|
||||
editor.exec_command(which, color)
|
||||
editor.focus()
|
||||
|
||||
|
||||
|
||||
def all_editor_actions(): # {{{
|
||||
if not all_editor_actions.ans:
|
||||
all_editor_actions.ans = {
|
||||
@ -233,6 +260,18 @@ def all_editor_actions(): # {{{
|
||||
'execute': def (editor, activated):
|
||||
insert_link(_('Insert an image'), _('Enter the image URL and optionally the image name'), insert_link_or_image.bind(None, editor.id, True))
|
||||
},
|
||||
'fg': {
|
||||
'icon': 'fg',
|
||||
'title': _('Change the text color'),
|
||||
'execute': def (editor, activated):
|
||||
set_color(_('Choose text color'), _('Choose the color below'), change_color.bind(None, editor.id, 'foreColor'))
|
||||
},
|
||||
'bg': {
|
||||
'icon': 'bg',
|
||||
'title': _('Change the highlight color'),
|
||||
'execute': def (editor, activated):
|
||||
set_color(_('Choose highlight color'), _('Choose the color below'), change_color.bind(None, editor.id, 'hiliteColor'))
|
||||
},
|
||||
}
|
||||
return all_editor_actions.ans
|
||||
# }}}
|
||||
@ -421,7 +460,7 @@ def create_comments_editor(container):
|
||||
for ac_name in 'undo redo select-all remove-format | bold italic underline strikethrough | hr superscript subscript format-block'.split(' '):
|
||||
add(toolbar1, ac_name)
|
||||
|
||||
for ac_name in 'ul ol indent outdent | justify-left justify-center justify-right justify-full | insert-link insert-image'.split(' '):
|
||||
for ac_name in 'ul ol indent outdent | justify-left justify-center justify-right justify-full | insert-link insert-image fg bg'.split(' '):
|
||||
add(toolbar2, ac_name)
|
||||
|
||||
container.setAttribute('style', (container.getAttribute('style') or '') + ';display: flex; flex-direction: column; align-items: stretch')
|
||||
|
Loading…
x
Reference in New Issue
Block a user