Skip to content

Commit

Permalink
Merge branch 'pr/14416' into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Oct 8, 2024
2 parents ac74418 + b53c62b commit ef7729a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/forms/docs/03-fields/10-rich-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ RichEditor::make('content')
->fileAttachmentsDirectory('attachments')
->fileAttachmentsVisibility('private')
```

## Disabling Grammarly checks

If the user has Grammarly installed and you would like to it from analyzing the contents of the editor, you can use the `disableGrammarly()` method:

```php
use Filament\Forms\Components\RichEditor;

RichEditor::make('content')
->disableGrammarly()
```
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ class="trix-button trix-button--dialog"
@endif
x-ref="trix"
wire:ignore
@if ($isGrammarlyDisabled())
data-gramm="false"
data-gramm_editor="false"
data-enable-grammarly="false"
@endif
{{
$getExtraInputAttributeBag()->class([
'prose min-h-[theme(spacing.48)] max-w-none !border-none px-3 py-1.5 text-base text-gray-950 dark:prose-invert focus-visible:outline-none dark:text-white sm:text-sm sm:leading-6',
Expand Down
22 changes: 22 additions & 0 deletions packages/forms/src/Components/Concerns/CanDisableGrammarly.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Filament\Forms\Components\Concerns;

use Closure;

trait CanDisableGrammarly
{
protected bool | Closure $isGrammarlyDisabled = false;

public function disableGrammarly(bool | Closure $condition = true): static
{
$this->isGrammarlyDisabled = $condition;

return $this;
}

public function isGrammarlyDisabled(): bool
{
return (bool) $this->evaluate($this->isGrammarlyDisabled);
}
}
1 change: 1 addition & 0 deletions packages/forms/src/Components/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Field extends Component implements Contracts\HasHintActions, Contracts\Has
use Concerns\CanBeAutofocused;
use Concerns\CanBeMarkedAsRequired;
use Concerns\CanBeValidated;
use Concerns\CanDisableGrammarly;
use Concerns\HasExtraFieldWrapperAttributes;
use Concerns\HasHelperText;
use Concerns\HasHint;
Expand Down

0 comments on commit ef7729a

Please sign in to comment.