| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Filament\Fields;
- use Filament\Forms\Components\Textarea;
- use Filament\Support\Enums\FontFamily;
- use Illuminate\Support\Js;
- class MathEditor extends Textarea
- {
- protected string $view = 'filament.fields.math-editor';
- protected int $columns = 12;
- protected function setUp(): void
- {
- parent::setUp();
- $this->columnSpan('full');
- $this->rows(8);
- $this->fontFamily(FontFamily::Mono);
- $this->placeholder('Enter LaTeX code here... e.g., $f(x) = ax^2 + bx + c$');
- $this->helperText('Supported formats: $...$, $$...$$, \(...\), \[...\]');
- }
- public function columns(int $columns): static
- {
- $this->columns = $columns;
- return $this;
- }
- public function getColumns(): int
- {
- return $this->columns;
- }
- public static function getPreview(string $value): ?string
- {
- if (empty($value)) {
- return null;
- }
- // 简单预览:不渲染 LaTeX,仅显示原始内容
- return $value;
- }
- }
|