Remove clamp_height option, apply scrolling style to all markdown divs inside td's

This commit is contained in:
Brian Tiemann 2024-08-22 14:09:29 -04:00
parent 42c4bdddef
commit 0813db666b
4 changed files with 6 additions and 17 deletions

Binary file not shown.

View File

@ -30,16 +30,14 @@
// Remove the bottom margin of <p> elements inside a table cell // Remove the bottom margin of <p> elements inside a table cell
td > .rendered-markdown { td > .rendered-markdown {
max-height: 200px;
overflow-y: scroll;
p:last-of-type { p:last-of-type {
margin-bottom: 0; margin-bottom: 0;
} }
} }
td > .rendered-markdown.vertical-scroll {
max-height: 200px;
overflow-y: scroll;
}
// Markdown preview // Markdown preview
.markdown-widget { .markdown-widget {
.preview { .preview {

View File

@ -3,7 +3,7 @@
{% if customfield.type == 'integer' and value is not None %} {% if customfield.type == 'integer' and value is not None %}
{{ value }} {{ value }}
{% elif customfield.type == 'longtext' and value %} {% elif customfield.type == 'longtext' and value %}
{{ value|markdown:True }} {{ value|markdown }}
{% elif customfield.type == 'boolean' and value == True %} {% elif customfield.type == 'boolean' and value == True %}
{% checkmark value true="True" %} {% checkmark value true="True" %}
{% elif customfield.type == 'boolean' and value == False %} {% elif customfield.type == 'boolean' and value == False %}

View File

@ -159,16 +159,11 @@ def content_type_id(model):
# #
@register.filter('markdown', is_safe=True) @register.filter('markdown', is_safe=True)
def render_markdown(value, clamp_height=False): def render_markdown(value):
""" """
Render a string as Markdown. This filter is invoked as "markdown": Render a string as Markdown. This filter is invoked as "markdown":
{{ md_source_text|markdown }} {{ md_source_text|markdown }}
If clamp_height is True, the "vertical-scroll" class will be added to the container div which sets a max-height
and adds a vertical scrollbar:
{{ md_source_text|markdown:True }}
""" """
if not value: if not value:
return '' return ''
@ -183,11 +178,7 @@ def render_markdown(value, clamp_height=False):
# If the string is not empty wrap it in rendered-markdown to style tables # If the string is not empty wrap it in rendered-markdown to style tables
if html: if html:
classes = ['rendered-markdown'] html = f'<div class="rendered-markdown">{html}</div>'
if clamp_height:
classes.append('vertical-scroll')
classes_str = ' '.join(classes)
html = f'<div class="{classes_str}">{html}</div>'
schemes = get_config().ALLOWED_URL_SCHEMES schemes = get_config().ALLOWED_URL_SCHEMES