Markdown Editor

Split-pane markdown editor with live preview.

python 11 params

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

NameTypeDefault
namestr'content'
valuestr''
previewboolTrue
toolbarboolTrue
placeholderstr'Write markdown...'
rowsint12
disabledboolFalse
eventstr — renames the event''
custom_classstr''
modestr'markdown'
**kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.markdown_editorSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 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.
cssdjust_components/markdown-editor.cssDefines 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.