Add language template
This commit is contained in:
parent
0b6031eef7
commit
3dfd3a5dab
8 changed files with 129 additions and 16 deletions
|
@ -77,15 +77,17 @@
|
|||
mode = widget.getAttribute('data-mode'),
|
||||
theme = widget.getAttribute('data-theme'),
|
||||
wordwrap = widget.getAttribute('data-wordwrap'),
|
||||
toolbar = prev(widget),
|
||||
main_block = toolbar.parentNode;
|
||||
toolbar = prev(widget);
|
||||
var main_block = div.parentNode.parentNode;
|
||||
|
||||
// Toolbar maximize/minimize button
|
||||
var min_max = toolbar.getElementsByClassName('django-ace-max_min');
|
||||
min_max[0].onclick = function () {
|
||||
minimizeMaximize(widget, main_block, editor);
|
||||
return false;
|
||||
};
|
||||
if (toolbar != null) {
|
||||
// Toolbar maximize/minimize button
|
||||
var min_max = toolbar.getElementsByClassName('django-ace-max_min');
|
||||
min_max[0].onclick = function () {
|
||||
minimizeMaximize(widget, main_block, editor);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
editor.getSession().setValue(textarea.value);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class AceWidget(forms.Textarea):
|
|||
width="100%",
|
||||
height="300px",
|
||||
no_ace_media=False,
|
||||
toolbar=True,
|
||||
*args,
|
||||
**kwargs
|
||||
):
|
||||
|
@ -28,6 +29,7 @@ class AceWidget(forms.Textarea):
|
|||
self.width = width
|
||||
self.height = height
|
||||
self.ace_media = not no_ace_media
|
||||
self.toolbar = toolbar
|
||||
super(AceWidget, self).__init__(*args, **kwargs)
|
||||
|
||||
@property
|
||||
|
@ -61,10 +63,14 @@ class AceWidget(forms.Textarea):
|
|||
|
||||
html = "<div%s><div></div></div>%s" % (flatatt(ace_attrs), textarea)
|
||||
|
||||
# add toolbar
|
||||
html = (
|
||||
'<div class="django-ace-editor"><div style="width: 100%%" class="django-ace-toolbar">'
|
||||
'<a href="./" class="django-ace-max_min"></a></div>%s</div>'
|
||||
) % html
|
||||
if self.toolbar:
|
||||
toolbar = (
|
||||
'<div style="width: {}" class="django-ace-toolbar">'
|
||||
'<a href="./" class="django-ace-max_min"></a>'
|
||||
"</div>"
|
||||
).format(self.width)
|
||||
html = toolbar + html
|
||||
|
||||
html = '<div class="django-ace-editor">{}</div>'.format(html)
|
||||
|
||||
return mark_safe(html)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue