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
@@ -16,6 +16,7 @@
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\EditorialWorkingDraft;
|
||||
use App\Domain\Catalog\ForeignCompositions;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
@@ -26,6 +27,7 @@
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\ManagesRichFields;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Http\Controllers\ContentPreviewController;
|
||||
@@ -48,6 +50,7 @@ abstract class EditComposition extends EditRecord
|
||||
{
|
||||
use AssignsPillars;
|
||||
use ManagesEditorialSurface;
|
||||
use ManagesRichFields;
|
||||
use WithFileUploads;
|
||||
|
||||
protected string $view = 'filament.editorial.edit';
|
||||
@@ -382,6 +385,14 @@ public function redaktionTitel(): string
|
||||
return $title !== '' ? $title : $this->hostLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
protected function richFelder(): array
|
||||
{
|
||||
return ['summary', 'description', 'learningGoal', 'materialNote', 'partBody', 'newTextBody'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
@@ -395,8 +406,8 @@ public function redaktionFelder(): array
|
||||
['id' => 'name', 'label' => 'Name in der Verwaltung', 'model' => 'designation', 'kind' => 'text', 'stored' => $stored('designation'), 'required' => true, 'hilfe' => 'Pflichtangabe. Erscheint in Listen der Verwaltung.'],
|
||||
['id' => 'titel', 'label' => 'Titel', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Namen.'],
|
||||
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')],
|
||||
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 3, 'stored' => $stored('summary')],
|
||||
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'description', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Beschreibt das Angebot. Kein Lehrtext und kein Lernziel.'],
|
||||
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'rich', 'stored' => $stored('summary')],
|
||||
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'description', 'kind' => 'rich', 'stored' => $stored('description'), 'hilfe' => 'Beschreibt das Angebot. Kein Lehrtext und kein Lernziel.'],
|
||||
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
|
||||
];
|
||||
}
|
||||
@@ -1248,7 +1259,7 @@ public function loadTemplate(int $versionId): void
|
||||
public function addText(): void
|
||||
{
|
||||
$title = trim($this->newTextTitle);
|
||||
$body = trim($this->newTextBody);
|
||||
$body = FormattedText::canonical($this->newTextBody);
|
||||
|
||||
if ($title === '' || $body === '') {
|
||||
$this->feedback = 'Der Text braucht einen Titel und einen Inhalt.';
|
||||
@@ -1578,7 +1589,7 @@ private function writePartText(): string|false
|
||||
}
|
||||
|
||||
$title = trim($this->partTitle);
|
||||
$body = trim($this->partBody);
|
||||
$body = FormattedText::canonical($this->partBody);
|
||||
|
||||
if ($title === '' || $body === '') {
|
||||
$this->feedback = 'Der Text braucht einen Titel und einen Inhalt.';
|
||||
@@ -1598,7 +1609,7 @@ private function writePartText(): string|false
|
||||
return false;
|
||||
}
|
||||
|
||||
$changed = $title !== (string) ($member['title'] ?? '') || $body !== trim((string) $version->body);
|
||||
$changed = $title !== (string) ($member['title'] ?? '') || ! FormattedText::same($body, $version->body);
|
||||
|
||||
if (! $changed) {
|
||||
return '';
|
||||
@@ -1755,10 +1766,10 @@ public function publishRevision(): bool
|
||||
$this->actor(),
|
||||
$note !== '' ? $note : null,
|
||||
[
|
||||
'learning_goal' => $this->blank($this->learningGoal),
|
||||
'learning_goal' => $this->richBlank('learningGoal'),
|
||||
'duration_minutes' => $minutes,
|
||||
'duration_max' => $this->blank($this->durationMax),
|
||||
'material_note' => $this->blank($this->materialNote),
|
||||
'material_note' => $this->richBlank('materialNote'),
|
||||
'prerequisites' => $this->blank($this->prerequisites),
|
||||
],
|
||||
$this->releaseConsent,
|
||||
@@ -2079,8 +2090,8 @@ protected function didacticChanged(CompositionVersion $version): bool
|
||||
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'origin' => $variant->origin,
|
||||
])->all());
|
||||
|
||||
return $version->learning_goal !== $this->blank($this->learningGoal)
|
||||
|| $version->material_note !== $this->blank($this->materialNote)
|
||||
return ! FormattedText::same($version->learning_goal, $this->learningGoal)
|
||||
|| ! FormattedText::same($version->material_note, $this->materialNote)
|
||||
|| $version->prerequisites !== $this->blank($this->prerequisites)
|
||||
|| ($version->duration_max === null ? null : (string) $version->duration_max) !== $this->blank($this->durationMax)
|
||||
|| $storedVariants !== $this->normalizeVariants($this->variants)
|
||||
@@ -2104,6 +2115,14 @@ protected function minutes(string $value): int|false|null
|
||||
return $minutes > 0 ? $minutes : false;
|
||||
}
|
||||
|
||||
/** Formatierte Eigenschaft in kanonischer Form für das Speichern; leer wird null. */
|
||||
protected function richBlank(string $name): ?string
|
||||
{
|
||||
$value = $this->richWert($name);
|
||||
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
protected function blank(string $value): ?string
|
||||
{
|
||||
$value = trim($value);
|
||||
@@ -2138,9 +2157,9 @@ protected function persistRedaktion(): bool
|
||||
app(IdentityProfile::class)->fill($record, [
|
||||
'display_title' => $this->displayTitle,
|
||||
'teaser' => $this->teaser,
|
||||
'summary' => $this->summary,
|
||||
'summary' => $this->richStore('summary', $record->summary),
|
||||
'search_terms' => $this->searchTerms,
|
||||
'description' => $this->description,
|
||||
'description' => $this->richStore('description', $record->description),
|
||||
], $this->actor());
|
||||
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
|
||||
$this->persistPillarIds($record);
|
||||
@@ -2291,9 +2310,9 @@ protected function payload(): array
|
||||
$minutes = $this->minutes($this->durationMinutes);
|
||||
|
||||
return [
|
||||
'learning_goal' => $this->blank($this->learningGoal),
|
||||
'learning_goal' => $this->richBlank('learningGoal'),
|
||||
'duration_minutes' => $minutes === false ? $this->durationMinutes : $minutes,
|
||||
'material_note' => $this->blank($this->materialNote),
|
||||
'material_note' => $this->richBlank('materialNote'),
|
||||
'duration_max' => $this->blank($this->durationMax),
|
||||
'prerequisites' => $this->blank($this->prerequisites),
|
||||
'variants' => $this->normalizeVariants($this->variants),
|
||||
@@ -2392,9 +2411,10 @@ protected function normalizePayload(array $payload): array
|
||||
}
|
||||
|
||||
return [
|
||||
'learning_goal' => $payload['learning_goal'] ?? null,
|
||||
// Formatierte Angaben nur in kanonischer Form vergleichen: Klartext des Altbestands und dasselbe als HTML sind gleich.
|
||||
'learning_goal' => FormattedText::canonical($payload['learning_goal'] ?? null) ?: null,
|
||||
'duration_minutes' => $payload['duration_minutes'] ?? null,
|
||||
'material_note' => $payload['material_note'] ?? null,
|
||||
'material_note' => FormattedText::canonical($payload['material_note'] ?? null) ?: null,
|
||||
'duration_max' => isset($payload['duration_max']) && $payload['duration_max'] !== '' ? (string) $payload['duration_max'] : null,
|
||||
'prerequisites' => $payload['prerequisites'] ?? null,
|
||||
'variants' => $this->normalizeVariants($payload['variants'] ?? []),
|
||||
|
||||
Reference in new issue
Block a user