Skip to content

Commit

Permalink
Merge pull request #11 from ashleyhindle/feature/allow-placeholder-se…
Browse files Browse the repository at this point in the history
…tting

Add placeholder ability
  • Loading branch information
freekmurze committed Mar 27, 2023
2 parents 4c1ec2b + b3a6c92 commit 8a3e17a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/views/markdownField.blade.php
Expand Up @@ -29,7 +29,7 @@ function debounce(func, timeout = 300) {
autoDownloadFontAwesome: false,
element: $refs.editor,
uploadImage: true,
placeholder: @js(__('Start writing…')),
placeholder: @js(__($getPlaceholder() ?? 'Start writing…')),
initialValue: state ?? '',
spellChecker: false,
autoSave: false,
Expand Down
1 change: 1 addition & 0 deletions src/MarkdownEditor.php
Expand Up @@ -10,6 +10,7 @@
class MarkdownEditor extends Field implements Contracts\HasFileAttachments
{
use Concerns\HasFileAttachments;
use Concerns\HasPlaceholder;
use Concerns\InteractsWithToolbarButtons;

protected string $view = 'filament-markdown-editor::markdownField';
Expand Down
10 changes: 9 additions & 1 deletion tests/MarkdownEditorTest.php
@@ -1,8 +1,16 @@
<?php

use Livewire\Livewire;
use Spatie\FilamentMarkdownEditor\MarkdownEditor;
use Spatie\FilamentMarkdownEditor\Tests\TestSupport\TestFormComponent;
use Spatie\FilamentMarkdownEditor\Tests\TestSupport\TestFormPlaceholderComponent;

it('can render the component', function () {
Livewire::test(TestFormComponent::class)->assertSeeHtml('editor');
Livewire::test(TestFormComponent::class)
->assertSeeHtml('editor');
});

it('can render the component with a great placeholder', function () {
$test = Livewire::test(TestFormPlaceholderComponent::class)
->assertSeeHtml("placeholder: 'Pikachu'");
});
15 changes: 15 additions & 0 deletions tests/TestSupport/TestFormPlaceholderComponent.php
@@ -0,0 +1,15 @@
<?php

namespace Spatie\FilamentMarkdownEditor\Tests\TestSupport;

use Spatie\FilamentMarkdownEditor\MarkdownEditor;

class TestFormPlaceholderComponent extends TestFormComponent
{
protected function getFormSchema(): array
{
return [
MarkdownEditor::make('content')->placeholder('Pikachu'),
];
}
}

0 comments on commit 8a3e17a

Please sign in to comment.