label('Schriftgröße') ->action(arguments: '{ size: $getEditor().getAttributes(\'fontSize\')[\'data-size\'] ?? null }') ->toggle() ->icon('fi-o-lead'), ]; } public function getEditorActions(): array { return [ Action::make('fontSize') ->label('Schriftgröße') ->modalHeading('Schriftgröße') ->modalWidth(Width::Large) ->fillForm(fn (array $arguments): array => ['size' => array_key_exists((string) ($arguments['size'] ?? ''), FormattedText::SITE_SIZES) ? $arguments['size'] : 'normal']) ->schema([ Select::make('size') ->label('Größe') ->options(['normal' => 'Normal', ...FormattedText::SITE_SIZES]) ->native(false) ->required() ->helperText('Gilt für den markierten Text. „Normal“ nimmt die Auszeichnung zurück.'), ]) ->action(function (array $arguments, array $data, RichEditor $component): void { $collapsed = ($arguments['editorSelection']['head'] ?? null) === ($arguments['editorSelection']['anchor'] ?? null); $size = (string) ($data['size'] ?? 'normal'); $extend = $collapsed ? [EditorCommand::make('extendMarkRange', arguments: ['fontSize'])] : []; $component->runCommands( array_key_exists($size, FormattedText::SITE_SIZES) ? [...$extend, EditorCommand::make('setFontSize', arguments: [['size' => $size]])] : [...$extend, EditorCommand::make('unsetFontSize')], editorSelection: $arguments['editorSelection'], ); }), ]; } }