MarkdownEditor
Formatted text stored as Markdown, with a small toolbar and a preview rendered by the server.
use Anvil\Schema\Fields\MarkdownEditor;
MarkdownEditor::make('description')->rows(10)->columnSpanFull(),Options
Section titled “Options”Like the Textarea: rows(n) (default 4) and
maxLength(n). The length is limited to 100 000 characters in any case
(MarkdownEditor::MAX_LENGTH), also with maxLength(null).
Editing
Section titled “Editing”- Toolbar: bold, italic, heading, list, link and code. The buttons wrap the selected text (or insert a placeholder); heading and list work on whole lines.
- Write / Preview: the preview is rendered by the server with the same settings as the detail page, so what the author sees is what readers get. It is an endpoint request of the panel (token protected); outside a panel, and for disabled fields, there is no preview.
- A short help line names the syntax (
**bold**,_italic_,- list,[link](https://…)).
Rendering and security
Section titled “Rendering and security”Markdown is rendered with CommonMark and GitHub Flavored Markdown (tables, strike-through, task lists, autolinks):
- raw HTML is escaped, never rendered,
javascript:,data:and other unsafe links are removed,- external links get
rel="noopener noreferrer nofollow".
The same renderer (Anvil\Support\Markdown) is used for the detail page,
the preview and own views:
<?= \Anvil\Support\Markdown::render($text) ?>Saved value
Section titled “Saved value”The Markdown text, trimmed; null when empty.
Validation
Section titled “Validation”string, max_length[n] (at most 100 000), then the rules of rules().
Read-only
Section titled “Read-only”The rendered Markdown.
The Markdown source as a string.