Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m2s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m40s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
- Seiten-Plugin: Seitenbaum mit Adressen, Seitennavigation, Brotkrumen und optional Hauptnavigation; Sichtbarkeit vererbt sich auf Unterseiten - Pagebuilder (Block-Registry im Kern, Plugins tragen Blöcke bei): Abschnitt, Spalten, Tabs, Akkordeon, Box, Überschrift, Text (TipTap), Zitat, Schaltflächen, Symbolliste, Tabelle, Trennlinie, Abstand, Bild, Galerie, Video (erst nach Klick), Titelbild, Ansprechpartner, Downloads, Unterseiten, Neuigkeiten, Termine; Sichtbarkeit je Block; Bereinigung beim Speichern - Editor im Portal: Ziehen und Ablegen, Autospeichern als Entwurf, Rückgängig, Gerätevorschau, Versionen, Zeitsteuerung, Bearbeitungssperre, Freigabe anfordern - Rechte „inkl. Unterseiten“ werden im Rechte-Cache aufgelöst - Neuigkeiten: Schreiben im Portal, Freigabe-Workflow mit Benachrichtigungen - Bereich „Redaktion“, Benachrichtigungen im Portal - storage/.migrations-fingerprint nicht mehr ausliefern Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
|
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
|
|
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
|
|
|
|
/**
|
|
* Wandelt Inhalte aus dem Rich-Text-Editor in sicheres HTML für das Portal.
|
|
* Wird beim Speichern aufgerufen; das Ergebnis liegt fertig in der Datenbank.
|
|
*/
|
|
class RichText
|
|
{
|
|
public function toSafeHtml(?string $content): string
|
|
{
|
|
if (blank($content)) {
|
|
return '';
|
|
}
|
|
|
|
$html = RichContentRenderer::make($content)
|
|
->fileAttachmentsDisk('uploads')
|
|
->toHtml();
|
|
|
|
return $this->sanitizer()->sanitize($html);
|
|
}
|
|
|
|
/**
|
|
* HTML aus dem Portal-Editor (TipTap) bereinigen.
|
|
*/
|
|
public function sanitize(?string $html): string
|
|
{
|
|
return blank($html) ? '' : $this->sanitizer()->sanitize((string) $html);
|
|
}
|
|
|
|
public function readingMinutes(?string $html): int
|
|
{
|
|
$words = str_word_count(strip_tags((string) $html), 0, 'ÄÖÜäöüß');
|
|
|
|
return max(1, (int) ceil($words / 200));
|
|
}
|
|
|
|
private function sanitizer(): HtmlSanitizer
|
|
{
|
|
$config = (new HtmlSanitizerConfig)
|
|
->allowSafeElements()
|
|
->allowLinkSchemes(['https', 'http', 'mailto', 'tel'])
|
|
->allowRelativeLinks()
|
|
->allowMediaSchemes(['https', 'http'])
|
|
->allowRelativeMedias()
|
|
->forceAttribute('a', 'rel', 'noopener noreferrer')
|
|
->dropElement('iframe')
|
|
->withMaxInputLength(500_000);
|
|
|
|
return new HtmlSanitizer($config);
|
|
}
|
|
}
|