Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
105
vendor/filament/forms/docs/11-markdown-editor.md
vendored
Normal file
105
vendor/filament/forms/docs/11-markdown-editor.md
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
---
|
||||
title: Markdown editor
|
||||
---
|
||||
import Aside from "@components/Aside.astro"
|
||||
import AutoScreenshot from "@components/AutoScreenshot.astro"
|
||||
import UtilityInjection from "@components/UtilityInjection.astro"
|
||||
|
||||
## Introduction
|
||||
|
||||
The markdown editor allows you to edit and preview markdown content, as well as upload images using drag and drop.
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
```
|
||||
|
||||
<AutoScreenshot name="forms/fields/markdown-editor/simple" alt="Markdown editor" version="5.x" />
|
||||
|
||||
## Security
|
||||
|
||||
By default, the editor outputs raw Markdown and HTML, and sends it to the backend. Attackers are able to intercept the value of the component and send a different raw HTML string to the backend. As such, it is important that when outputting the HTML from a Markdown editor, it is sanitized; otherwise your site may be exposed to Cross-Site Scripting (XSS) vulnerabilities.
|
||||
|
||||
When Filament outputs raw HTML from the database in components such as `TextColumn` and `TextEntry`, it sanitizes it to remove any dangerous JavaScript. However, if you are outputting the HTML from a Markdown editor in your own Blade view, this is your responsibility. One option is to use Filament's `sanitizeHtml()` helper to do this, which is the same tool we use to sanitize HTML in the components mentioned above:
|
||||
|
||||
```blade
|
||||
{!! str($record->content)->markdown()->sanitizeHtml() !!}
|
||||
```
|
||||
|
||||
<Aside variant="danger">
|
||||
Filament's built-in HTML sanitizer permits inline `style` attributes in order to support rich text formatting features such as font colors, text highlighting, and image sizing. This means that CSS properties like `background: url(...)` or `position: fixed` will not be stripped from sanitized HTML. If your content comes from untrusted users, you should consider restricting the default configuration. See the [security documentation](../advanced/security#customizing-the-sanitizer) for details on how to customize the sanitizer.
|
||||
</Aside>
|
||||
|
||||
## Customizing the toolbar buttons
|
||||
|
||||
You may set the toolbar buttons for the editor using the `toolbarButtons()` method. The options shown here are the defaults:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
->toolbarButtons([
|
||||
['bold', 'italic', 'strike', 'link'],
|
||||
['heading'],
|
||||
['blockquote', 'codeBlock', 'bulletList', 'orderedList'],
|
||||
['table', 'attachFiles'],
|
||||
['undo', 'redo'],
|
||||
])
|
||||
```
|
||||
|
||||
Each nested array in the main array represents a group of buttons in the toolbar.
|
||||
|
||||
<UtilityInjection set="formFields" version="5.x">As well as allowing a static value, the `toolbarButtons()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
||||
|
||||
<AutoScreenshot name="forms/fields/markdown-editor/custom-toolbar" alt="Markdown editor with customized toolbar buttons" version="5.x" />
|
||||
|
||||
## Setting the height
|
||||
|
||||
You may control the editor's height by defining the `minHeight()` and `maxHeight()` methods, which accept any CSS length value:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
->minHeight('12rem')
|
||||
->maxHeight('24rem')
|
||||
```
|
||||
|
||||
The editor has a minimum height of `10rem` by default. Once the content exceeds `maxHeight()`, the editor stops growing and becomes scrollable. Each method may be used on its own — `minHeight()` sets a starting height while still allowing the editor to grow, and `maxHeight()` caps how tall it may become. Pass `null` to `minHeight()` to use a `3rem` minimum height for the interactive editor, or to `maxHeight()` to remove the cap. Disabled content uses its natural height when `minHeight()` is `null`. These constraints also apply when the editor is disabled.
|
||||
|
||||
<UtilityInjection set="formFields" version="5.x">As well as allowing static values, the `minHeight()` and `maxHeight()` methods also accept functions to dynamically calculate them. You can inject various utilities into the functions as parameters.</UtilityInjection>
|
||||
|
||||
## Uploading images to the editor
|
||||
|
||||
Images may be uploaded to the editor. They will always be uploaded to a publicly available URL with public storage permissions, since generating temporary file upload URLs is not supported in static content. You may customize where images are uploaded using configuration methods:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
->fileAttachmentsDisk('s3')
|
||||
->fileAttachmentsDirectory('attachments')
|
||||
```
|
||||
|
||||
<UtilityInjection set="formFields" version="5.x">As well as allowing static values, the `fileAttachmentsDisk()` and `fileAttachmentsDirectory()` methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.</UtilityInjection>
|
||||
|
||||
### Validating uploaded images
|
||||
|
||||
You may use the `fileAttachmentsAcceptedFileTypes()` method to control a list of accepted mime types for uploaded images. By default, `image/png`, `image/jpeg`, `image/gif`, and `image/webp` are accepted:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
->fileAttachmentsAcceptedFileTypes(['image/png', 'image/jpeg'])
|
||||
```
|
||||
|
||||
You may use the `fileAttachmentsMaxSize()` method to control the maximum file size for uploaded images. The size is specified in kilobytes. By default, the maximum size is 12288 KB (12 MB):
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
MarkdownEditor::make('content')
|
||||
->fileAttachmentsMaxSize(5120) // 5 MB
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue