Biete im Fließtext Schriftgröße, Schriftfarbe und Ausrichtung an
Das Webprofil von FormattedText kennt zusätzlich Ausrichtung (zentriert, rechtsbündig), Schriftgröße (klein, groß, sehr groß) und Schriftfarbe (Marine, Grün, Rot, Grau) aus festen Werten. Verwaltung, Dokumente und PDF lassen sie weg. Der Editor des Fließtexts bekommt die Werkzeuge dafür (eigene Erweiterung für die Größe); auf der Seite werden Klassen und Tokens statt Inline-Stilen ausgegeben, Farben passen sich dunklen und grünen Flächen an. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28bd5590bc
commit
57f3a18b82
18 files changed
+565
-34
No files matched your search
@@ -5,7 +5,9 @@
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\RichEditor\RichEditorTool;
|
||||
use Filament\Forms\Components\RichEditor\TextColor;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Js;
|
||||
|
||||
/**
|
||||
@@ -14,23 +16,43 @@
|
||||
*/
|
||||
final class RichField
|
||||
{
|
||||
/** Farbwerte der Schriftfarben im Editor (Weiß/Cremefläche); auf der Seite bestimmt `widgets.css` je Fläche. */
|
||||
private const SITE_COLOR_VALUES = ['marine' => '#032551', 'gruen' => '#3b7b09', 'rot' => '#a8212b', 'grau' => '#3e4c5c'];
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @param bool $images Bilder aus dem Medienbestand einfügen; nur auf Seiten mit dem gemeinsamen Picker
|
||||
* ({@see ManagesEditorialSurface::openTextImagePicker()})
|
||||
* @param bool $website Texte der Website (Fließtext): zusätzlich Schriftgröße, Schriftfarbe und Ausrichtung aus festen
|
||||
* Werten ({@see FormattedText::SITE_SIZES}, {@see FormattedText::SITE_COLORS}); gespeichert wird
|
||||
* mit dem Webprofil von {@see FormattedText}
|
||||
*/
|
||||
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false, bool $images = false): RichEditor
|
||||
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false, bool $images = false, bool $website = false): RichEditor
|
||||
{
|
||||
$toolbar = FormattedText::TOOLBAR;
|
||||
|
||||
if ($website) {
|
||||
array_splice($toolbar, 1, 0, [['fontSize', 'textColor'], ['alignStart', 'alignCenter', 'alignEnd']]);
|
||||
}
|
||||
|
||||
if ($images) {
|
||||
array_splice($toolbar, count($toolbar) - 1, 0, [['bild']]);
|
||||
}
|
||||
|
||||
$field = RichEditor::make($name)->toolbarButtons($toolbar);
|
||||
|
||||
if ($website) {
|
||||
$field
|
||||
->plugins([new FontSizePlugin])
|
||||
->textColors(Arr::mapWithKeys(
|
||||
FormattedText::SITE_COLORS,
|
||||
fn (string $label, string $key): array => [$key => TextColor::make($label, self::SITE_COLOR_VALUES[$key])],
|
||||
))
|
||||
->customTextColors(false);
|
||||
}
|
||||
|
||||
if ($images) {
|
||||
$field->tools([
|
||||
RichEditorTool::make('bild')
|
||||
|
||||
Reference in new issue
Block a user