Markdown

Extends Textarea * has the same features

# Basics

Markdown a lightweight markup language designed to indicate formatting in plain text, while maximizing its human readability.

use MoonShine\Fields\Markdown;
 
//...
 
public function fields(): array
{
return [
Markdown::make('Description')
];
}
 
//...

# Toolbar

The toolbar() method allows you to change the toolbar.

toolbar(string|bool|array $value)
use MoonShine\Fields\Markdown;
 
//...
 
Markdown::make('Description')
->toolbar(['bold', 'italic', 'strikethrough', 'code', 'quote', 'horizontal-rule'])

# Options

The addOption() method allows you to add or change options for the markdown editor.

addOption(string $name, string|int|float|bool|array $value)
use MoonShine\Fields\Markdown;
 
//...
 
Markdown::make('Description')
->addOption('toolbar', ['bold', 'italic', 'strikethrough', 'code', 'quote', 'horizontal-rule'])

# Global configuration

If you need to change settings for the editor globally, you can use the static method setDefaultOption().

setDefaultOption(string $name, string|int|float|bool|array $value)
namespace App\Providers;
 
use MoonShine\Fields\Markdown;
use MoonShine\Providers\MoonShineApplicationServiceProvider;
 
class MoonShineServiceProvider extends MoonShineApplicationServiceProvider
{
public function boot(): void
{
parent::boot();
 
Markdown::setDefaultOption('toolbar', ['bold', 'italic', 'strikethrough', 'code', 'quote']);
}
}