Rich Text Editor
Basic rich text editor component (contenteditable + toolbar).
Preview
Draft release notes here.
Arguments
rich_text_editor(value='Draft <strong>release notes</strong> here.')
Usage
views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import RichTextEditor
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = RichTextEditor(value='Draft <strong>release notes</strong> here.')
@event_handler()
def update_content(self, value, **kwargs):
self.component.value = valuemy_template.html
django
{{ component }}Events this component sends to the view: update_content.
Parameters
| Name | Type | Default |
|---|---|---|
| name | str | 'content' |
| value | str | '' |
| event | str — renames the event | 'update_content' |
| placeholder | str | 'Start typing...' |
| height | str | '200px' |
| label | str | '' |
| custom_class | str | '' |
| **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.rich_text_editor | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 5 of this component's classes at line 500, 924, 925, 926, 929. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/components.css | Defines 1 of this component's classes at line 1045. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/scaffold.css | Defines 1 of this component's classes at line 437. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |