Speichere formatierte Texte als bereinigtes HTML mit einem Editor (ADR-50)
Ein Baustein (FormattedText) bereinigt, bringt Werte in die kanonische Form und wandelt Klartext des Altbestands; RichField ist der eine Editor, ManagesRichFields verbindet ihn mit den Arbeitsplätzen. Formatiert sind Texte der Übungen und Textbausteine, Kurzbeschreibung und Beschreibung, Lernziel und Ausstattung. Mitgliederansicht und PDF zeigen fett, kursiv, Listen, Überschrift, Zitat und Link (PDF: schräge Schnitte, nur wenn gebraucht). Das Livewire-Limit für verschachtelte Pfade steigt auf 30, weil Aufzählungen sonst abgelehnt werden. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
be24f3bf64
commit
9fbd933e1e
50 files changed
+1461
-181
No files matched your search
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
@@ -35,7 +36,7 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
'document' => 'Dokument',
|
||||
'text' => 'Text',
|
||||
])->required()->live();
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)
|
||||
$fields[] = RichField::make('body', 'Text', live: false)
|
||||
->visible(fn ($get): bool => $get('shape') === 'text')
|
||||
->required(fn ($get): bool => $get('shape') === 'text');
|
||||
$fields[] = self::fileField()
|
||||
@@ -46,12 +47,12 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.')
|
||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||
} elseif ($element?->output_class === 'text') {
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||
$fields[] = RichField::make('body', 'Text', live: false)->required();
|
||||
}
|
||||
|
||||
return [
|
||||
...$fields,
|
||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
||||
RichField::make('description', 'Beschreibung', live: false)
|
||||
->helperText('Gilt für das Medium, nicht nur für diese eine Stelle.'),
|
||||
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(3),
|
||||
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
|
||||
@@ -125,7 +126,7 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
self::remember($element, $data);
|
||||
|
||||
if ($output === 'text') {
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
$body = FormattedText::canonical((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($body === '') {
|
||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||
@@ -164,7 +165,7 @@ public static function update(ContentElement $element, array $data): ?ContentEle
|
||||
|
||||
if ($element->output_class === 'text') {
|
||||
$latest = $element->versions()->orderByDesc('number')->first();
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
$body = FormattedText::canonical((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($latest instanceof ContentElementVersion && $body !== '') {
|
||||
$revised = app(ContentService::class)->reviseElementContent($latest, $body);
|
||||
@@ -185,11 +186,11 @@ public static function fill(ContentElement $element): array
|
||||
|
||||
return [
|
||||
'working_title' => $element->working_title,
|
||||
'description' => $element->description,
|
||||
'description' => FormattedText::html($element->description),
|
||||
'usage_note' => $element->usage_note,
|
||||
'license_note' => $element->license_note,
|
||||
'thumbnail_alt' => $element->thumbnail_alt,
|
||||
'body' => $latest?->body,
|
||||
'body' => FormattedText::html($latest?->body),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -198,7 +199,10 @@ public static function fill(ContentElement $element): array
|
||||
*/
|
||||
public static function remember(ContentElement $element, array $data): void
|
||||
{
|
||||
app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null);
|
||||
$description = FormattedText::same((string) ($data['description'] ?? ''), $element->description)
|
||||
? $element->description
|
||||
: (FormattedText::canonical((string) ($data['description'] ?? '')) ?: null);
|
||||
app(ContentService::class)->describe($element, (string) $data['working_title'], $description);
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'usage_note' => $data['usage_note'] ?? null,
|
||||
'license_note' => $data['license_note'] ?? null,
|
||||
|
||||
Reference in new issue
Block a user