Zeige formatierte Texte überall als Klartext, wo kein HTML hingehört
Öffentliche Leser, Shop, Medienliste und Bibliothek lesen Kurzbeschreibung, Beschreibung und Lernziel als Klartext; Mitgliederseiten zu Programm, Inhalt und Artikel zeigen die formatierte Fassung. Der Editor trägt die deutsche Bezeichnung des Felds als Namen für Hilfstechnik, der Tastaturfokus landet im Editor, und der Abgleich merkt sich nur eine Prüfsumme. ADR-50 nennt Rückfall und Suche. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9fbd933e1e
commit
99122ddfee
14 files changed
+85
-33
No files matched your search
@@ -28,24 +28,30 @@ trait ManagesRichFields
|
||||
/** @var array<string, mixed> Zustand der Editoren (Dokumente) je Eigenschaft */
|
||||
public array $rich = [];
|
||||
|
||||
/** @var array<string, string> Zuletzt abgeglichener kanonischer Wert je Eigenschaft */
|
||||
/** @var array<string, string> Prüfsumme des zuletzt abgeglichenen kanonischen Werts je Eigenschaft */
|
||||
public array $richSeen = [];
|
||||
|
||||
/**
|
||||
* Eigenschaften dieser Seite, die mit dem Editor bearbeitet werden.
|
||||
* Eigenschaften dieser Seite, die mit dem Editor bearbeitet werden, mit ihrer Bezeichnung (Name für Hilfstechnik).
|
||||
*
|
||||
* @return list<string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function richFelder(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
protected function richNamen(): array
|
||||
{
|
||||
return array_keys($this->richFelder());
|
||||
}
|
||||
|
||||
public function richTextSchema(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->statePath('rich')
|
||||
->components(array_map(fn (string $name): RichEditor => RichField::make($name), $this->richFelder()));
|
||||
->components(array_map(fn (string $name, string $label): RichEditor => RichField::make($name, $label, hideLabel: true), $this->richNamen(), $this->richFelder()));
|
||||
}
|
||||
|
||||
public function richKomponente(string $name): ?Component
|
||||
@@ -58,7 +64,7 @@ public function updatedRich(mixed $value = null, ?string $key = null): void
|
||||
{
|
||||
$name = explode('.', (string) $key)[0];
|
||||
|
||||
if ($name !== '' && in_array($name, $this->richFelder(), true)) {
|
||||
if ($name !== '' && in_array($name, $this->richNamen(), true)) {
|
||||
$this->richPull($name);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +80,7 @@ protected function richPull(string $name): void
|
||||
|
||||
$html = FormattedText::canonicalHtml((string) $component->getState());
|
||||
$this->{$name} = $html;
|
||||
$this->richSeen[$name] = $html;
|
||||
$this->richSeen[$name] = md5($html);
|
||||
}
|
||||
|
||||
/** Wert der Eigenschaft in den Editor schreiben. */
|
||||
@@ -88,16 +94,16 @@ protected function richPush(string $name): void
|
||||
|
||||
$canonical = FormattedText::canonical((string) $this->{$name});
|
||||
$component->state($canonical === '' ? null : $canonical);
|
||||
$this->richSeen[$name] = $canonical;
|
||||
$this->richSeen[$name] = md5($canonical);
|
||||
}
|
||||
|
||||
/** Vor dem Rendern: Eigenschaften, die der Server geändert hat, in den Editor übernehmen. */
|
||||
public function renderingManagesRichFields(): void
|
||||
{
|
||||
foreach ($this->richFelder() as $name) {
|
||||
foreach ($this->richNamen() as $name) {
|
||||
$canonical = FormattedText::canonical((string) $this->{$name});
|
||||
|
||||
if (! array_key_exists($name, $this->richSeen) || $this->richSeen[$name] !== $canonical) {
|
||||
if (! array_key_exists($name, $this->richSeen) || $this->richSeen[$name] !== md5($canonical)) {
|
||||
$this->richPush($name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
@@ -488,8 +489,8 @@ private function haystack(ContentElement $element): string
|
||||
return mb_strtolower(implode("\n", array_filter([
|
||||
$element->working_title,
|
||||
$element->display_title,
|
||||
$element->description,
|
||||
$element->summary,
|
||||
FormattedText::plain($element->description),
|
||||
FormattedText::plain($element->summary),
|
||||
$element->teaser,
|
||||
$element->search_terms,
|
||||
$element->usage_note,
|
||||
@@ -504,7 +505,7 @@ private function haystack(ContentElement $element): string
|
||||
*/
|
||||
private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array
|
||||
{
|
||||
$description = trim((string) ($element->description ?: $element->summary ?: ''));
|
||||
$description = FormattedText::plain((string) ($element->description ?: $element->summary ?: ''));
|
||||
$usageNote = trim((string) $element->usage_note);
|
||||
$licenseNote = trim((string) $element->license_note);
|
||||
$typeKey = $this->typeKey((string) $element->output_class);
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
final class RichField
|
||||
{
|
||||
/**
|
||||
* @param ?string $label Mit Bezeichnung für Formulare und Dialoge; ohne bleibt sie dem Arbeitsplatz überlassen
|
||||
* @param ?string $label Bezeichnung des Felds; sie ist auch der Name für Hilfstechnik
|
||||
* @param bool $live Arbeitsplätze gleichen beim Verlassen des Felds ab ({@see ManagesRichFields}); Dialoge nicht
|
||||
* @param bool $hideLabel Die Bezeichnung zeigt der Arbeitsplatz selbst
|
||||
*/
|
||||
public static function make(string $name, ?string $label = null, bool $live = true): RichEditor
|
||||
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false): RichEditor
|
||||
{
|
||||
$field = RichEditor::make($name)->toolbarButtons(FormattedText::TOOLBAR);
|
||||
|
||||
@@ -23,6 +24,10 @@ public static function make(string $name, ?string $label = null, bool $live = tr
|
||||
$field->live(onBlur: true);
|
||||
}
|
||||
|
||||
return $label === null ? $field->hiddenLabel() : $field->label($label);
|
||||
if ($label !== null) {
|
||||
$field->label($label);
|
||||
}
|
||||
|
||||
return $label === null || $hideLabel ? $field->hiddenLabel() : $field;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user