diff --git a/packages/forms/docs/03-fields/10-rich-editor.md b/packages/forms/docs/03-fields/10-rich-editor.md index f3f35d47dd1..bc8b109321f 100644 --- a/packages/forms/docs/03-fields/10-rich-editor.md +++ b/packages/forms/docs/03-fields/10-rich-editor.md @@ -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() +``` diff --git a/packages/forms/resources/views/components/rich-editor.blade.php b/packages/forms/resources/views/components/rich-editor.blade.php index 26ca64e99a9..8275e781976 100644 --- a/packages/forms/resources/views/components/rich-editor.blade.php +++ b/packages/forms/resources/views/components/rich-editor.blade.php @@ -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', diff --git a/packages/forms/src/Components/Concerns/CanDisableGrammarly.php b/packages/forms/src/Components/Concerns/CanDisableGrammarly.php new file mode 100644 index 00000000000..9c378e41079 --- /dev/null +++ b/packages/forms/src/Components/Concerns/CanDisableGrammarly.php @@ -0,0 +1,22 @@ +isGrammarlyDisabled = $condition; + + return $this; + } + + public function isGrammarlyDisabled(): bool + { + return (bool) $this->evaluate($this->isGrammarlyDisabled); + } +} diff --git a/packages/forms/src/Components/Field.php b/packages/forms/src/Components/Field.php index 00fa01af0b4..71078936128 100644 --- a/packages/forms/src/Components/Field.php +++ b/packages/forms/src/Components/Field.php @@ -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;