defmodule PyrauiWeb.DocsLive.RichTextEditorDocs do use PyrauiWeb, :html def render(assigns) do ~H"""
Rich text editor / WYSIWYG component for blogs, comments, and content editing with formatting controls.
Try the editor below - use the toolbar buttons or keyboard shortcuts to format your text!
Current HTML Output:
{@rich_text_content}
<.rich_text_editor field={@form[:content]} label="Content" />
<.rich_text_editor
field={@form[:content]}
value={"<h2>Welcome</h2><p>This is <strong>pre-filled</strong> content!</p>"}
label="Pre-filled Editor"
/>
The rich text editor uses a JavaScript hook (RichTextEditorHook) to sync content with the hidden input field for form submission.
All formatting is handled client-side using the browser's
document.execCommand
API. The HTML content is automatically synced to a hidden input field for form submission.
| Prop | Type | Default | Description |
|---|---|---|---|
| field | Phoenix.HTML.FormField | - | Form field struct |
| label | string | nil | Label text |
| placeholder | string | "Start typing..." | Placeholder text |
| value | string | nil | Initial HTML content |