misc fixes

This commit is contained in:
Kovid Goyal 2023-10-20 20:42:18 +05:30
parent 278985f353
commit ba8b17a288
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -74,16 +74,18 @@ def insert_image():
if img.src: if img.src:
window.URL.revokeObjectURL(img.src) window.URL.revokeObjectURL(img.src)
img.src = '' img.src = ''
img.parentElement.style.display = 'none'
for f in files: for f in files:
if acceptable_image_types.indexOf(f.type) > -1: if acceptable_image_types.indexOf(f.type) > -1:
h = parent.querySelector('.button-box').offsetHeight h = parent.querySelector('.button-box').offsetHeight
img.parentElement.style.display = 'block'
non_content_height = (container.offsetHeight - parent.offsetHeight) + 'px' non_content_height = (container.offsetHeight - parent.offsetHeight) + 'px'
img.style.maxHeight = f'calc({max_container_height} - {non_content_height} - {h}px - 1rem)' img.style.maxHeight = f'calc({max_container_height} - {non_content_height} - {h}px - 1rem)'
img.src = window.URL.createObjectURL(f) img.src = window.URL.createObjectURL(f)
return return
alert(_('No valid image file found')) alert(_('No valid image file found'))
parent.appendChild(E.div(class_='moose', parent.appendChild(E.div(
ondragenter=def(e): ondragenter=def(e):
e.stopPropagation(), e.preventDefault() e.stopPropagation(), e.preventDefault()
, ,
@ -97,7 +99,7 @@ def insert_image():
E.div( E.div(
style='display: flex;', style='display: flex;',
E.div( E.div(
style='min-width: 40%; max-width: 40%; margin-right: 0.5rem', style='display: none; min-width: 40%; max-width: 40%; margin-right: 0.5rem',
E.img(style='max-width: 100%'), E.img(style='max-width: 100%'),
), ),
E.div( E.div(
@ -109,7 +111,7 @@ def insert_image():
_('Select an image from your files'), _('Select an image from your files'),
class_='blue-link', href='javascript:void(0)', onclick=def (): class_='blue-link', href='javascript:void(0)', onclick=def ():
parent.querySelector('input[type=file]').click() parent.querySelector('input[type=file]').click()
), E.span(_(' or drag and drop an image onto this dialog.')) ), E.span(_(' or drag and drop an image here.'))
), ),
), ),
E.div(class_='button-box', E.div(class_='button-box',