Add a MarkdownInput widget, and make use of it

Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
Skia
2017-06-10 19:39:40 +02:00
parent 4b9fa0cd57
commit 2925cde8ab
6 changed files with 38 additions and 14 deletions

View File

@ -27,7 +27,7 @@ from django import forms
from django.db import transaction
from django.core.exceptions import ValidationError
from django.contrib.auth import logout, login, authenticate
from django.forms import CheckboxSelectMultiple, Select, DateInput, TextInput, DateTimeInput
from django.forms import CheckboxSelectMultiple, Select, DateInput, TextInput, DateTimeInput, Textarea
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget
@ -73,6 +73,13 @@ class SelectDate(DateInput):
attrs = {'class': "select_date"}
return super(SelectDate, self).render(name, value, attrs)
class MarkdownInput(Textarea):
def render(self, name, value, attrs=None):
output = '<div class="markdown_editor">%(content)s</div>' % {
'content': super(MarkdownInput, self).render(name, value, attrs),
}
return output
class SelectFile(TextInput):
def render(self, name, value, attrs=None):
if attrs: