Markdown Editor

Split-pane markdown editor with live preview.

python 13 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

NameTypeDefaultDescription
namestr'content'form field name
valuestr''initial markdown content
previewboolTrueshow preview pane (default True)
toolbarboolTrueshow formatting toolbar (default True)
placeholderstr'Write markdown...'textarea placeholder text
rowsint12textarea rows
disabledboolFalsedisable editing
eventstr — renames the event''djust event on change
custom_classstr''additional CSS classes
modestr'markdown'initial editing mode; visual requires the optional visual bundle
bubble_menuboolTrueshow a formatting menu over a selection in visual mode (default True). It never replaces the browser's context menu.
floating_menuboolFalseshow a block menu on an empty line in visual mode (default False)
**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 2139, 2141, 2142, 2144, 2145, 2146, 2147, 2682. 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 275, 279, 282, 283, 297. Override those rules, or the custom properties they read, in a stylesheet loaded after it.