Markdown Editor
Split-pane markdown editor with live preview.
Preview
Usage
views.py
python
from djust import LiveView
from djust.components import MarkdownEditor
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = MarkdownEditor()my_template.html
django
{{ component }}Needs its script on the page: <script src="{% static 'djust_components/markdown-editor.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.
Parameters
| Name | Type | Default |
|---|---|---|
| name | str | 'content' |
| value | str | '' |
| preview | bool | True |
| toolbar | bool | True |
| placeholder | str | 'Write markdown...' |
| rows | int | 12 |
| disabled | bool | False |
| event | str — renames the event | '' |
| custom_class | str | '' |
| mode | str | 'markdown' |
| **kwargs | — passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.markdown_editor | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 8 of this component's classes at line 2085, 2087, 2088, 2090, 2091, 2092, 2093, 2579. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_components/markdown-editor.css | Defines 5 of this component's classes at line 226, 230, 233, 234, 248. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |