Skip to content

Commit 1c97c4d

Browse files
Merge pull request #42 from ziming/support-markdown-editor
support markdown editor
2 parents c796d0b + 5e664a6 commit 1c97c4d

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

config/filament-comments.php

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
*/
3434
'prune_after_days' => 30,
3535

36+
37+
/*
38+
* Options: 'rich', 'markdown'
39+
*/
40+
'editor' => 'rich',
41+
3642
/*
3743
* The rich editor toolbar buttons that are available to users.
3844
*/

resources/views/comments.blade.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
</div>
4747

4848
<div class="prose dark:prose-invert [&>*]:mb-2 [&>*]:mt-0 [&>*:last-child]:mb-0 prose-sm text-sm leading-6 text-gray-950 dark:text-white">
49-
{{ Str::of($comment->comment)->toHtmlString() }}
49+
@if(config('filament-comments.editor') === 'markdown')
50+
{{ Str::of($comment->comment)->markdown()->toHtmlString() }}
51+
@else
52+
{{ Str::of($comment->comment)->toHtmlString() }}
53+
@endif
5054
</div>
5155
</div>
5256
</div>

src/Livewire/CommentsComponent.php

+16-6
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,24 @@ public function form(Form $form): Form
3131
return $form;
3232
}
3333

34+
if (config('filament-comments.editor') === 'markdown') {
35+
$editor = Forms\Components\MarkdownEditor::make('comment')
36+
->hiddenLabel()
37+
->required()
38+
->placeholder(__('filament-comments::filament-comments.comments.placeholder'))
39+
->toolbarButtons(config('filament-comments.toolbar_buttons'));
40+
} else {
41+
$editor = Forms\Components\RichEditor::make('comment')
42+
->hiddenLabel()
43+
->required()
44+
->placeholder(__('filament-comments::filament-comments.comments.placeholder'))
45+
->extraInputAttributes(['style' => 'min-height: 6rem'])
46+
->toolbarButtons(config('filament-comments.toolbar_buttons'));
47+
}
48+
3449
return $form
3550
->schema([
36-
Forms\Components\RichEditor::make('comment')
37-
->hiddenLabel()
38-
->required()
39-
->placeholder(__('filament-comments::filament-comments.comments.placeholder'))
40-
->extraInputAttributes(['style' => 'min-height: 6rem'])
41-
->toolbarButtons(config('filament-comments.toolbar_buttons'))
51+
$editor,
4252
])
4353
->statePath('data');
4454
}

0 commit comments

Comments
 (0)