mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
MarkdownWidget
This commit is contained in:
parent
189668fbfb
commit
3f641122d4
@ -27,7 +27,7 @@ class CommentField(forms.CharField):
|
|||||||
"""
|
"""
|
||||||
A textarea with support for Markdown rendering. Exists mostly just to add a standard `help_text`.
|
A textarea with support for Markdown rendering. Exists mostly just to add a standard `help_text`.
|
||||||
"""
|
"""
|
||||||
widget = forms.Textarea
|
widget = widgets.MarkdownWidget
|
||||||
help_text = f"""
|
help_text = f"""
|
||||||
<i class="mdi mdi-information-outline"></i>
|
<i class="mdi mdi-information-outline"></i>
|
||||||
<a href="{static('docs/reference/markdown/')}" target="_blank" tabindex="-1">
|
<a href="{static('docs/reference/markdown/')}" target="_blank" tabindex="-1">
|
||||||
|
@ -116,6 +116,10 @@ class SelectDurationWidget(forms.NumberInput):
|
|||||||
template_name = 'widgets/select_duration.html'
|
template_name = 'widgets/select_duration.html'
|
||||||
|
|
||||||
|
|
||||||
|
class MarkdownWidget(forms.Textarea):
|
||||||
|
template_name = 'widgets/markdowninput.html'
|
||||||
|
|
||||||
|
|
||||||
class NumericArrayField(SimpleArrayField):
|
class NumericArrayField(SimpleArrayField):
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{# Render the field label, except for: #}
|
{# Render the field label, except for: #}
|
||||||
{# 1. Checkboxes (label appears to the right of the field #}
|
{# 1. Checkboxes (label appears to the right of the field #}
|
||||||
{# 2. Textareas with no label set (will expand across entire row) #}
|
{# 2. Textareas with no label set (will expand across entire row) #}
|
||||||
{% if field|widget_type == 'checkboxinput' or field|widget_type == 'textarea' and not label %}
|
{% if field|widget_type == 'checkboxinput' or field|widget_type == 'textarea' or field|widget_type == 'markdownwidget' and not label %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label text-lg-end{% if field.field.required %} required{% endif %}">
|
<label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label text-lg-end{% if field.field.required %} required{% endif %}">
|
||||||
{{ label }}
|
{{ label }}
|
||||||
|
22
netbox/utilities/templates/widgets/markdown_input.html
Normal file
22
netbox/utilities/templates/widgets/markdown_input.html
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<div class="border rounded markdown-preview">
|
||||||
|
<ul class="nav nav-tabs px-3 pt-2 rounded-top bg-transparent border-0">
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button class="nav-link active " id="comment-input-tab" data-bs-toggle="tab" data-bs-target="#comment-input" type="button" role="tab" aria-controls="comment-input" aria-selected="true">
|
||||||
|
Write
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button class="nav-link " id="markdown-preview-tab" data-bs-toggle="tab" data-bs-target="#markdown-preview" type="button" role="tab" aria-controls="markdown-preview" aria-selected="false">
|
||||||
|
Preview
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content bg-body rounded-bottom border-top">
|
||||||
|
<div class="tab-pane show active" id="comment-input" role="tabpanel" aria-labelledby="comment-input-tab">
|
||||||
|
{% include "django/forms/widgets/textarea.html" %}
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane show" id="markdown-preview" role="tabpanel" aria-labelledby="markdown-preview-tab">
|
||||||
|
<div class="test">This is rendered markdown</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user