awcodes / filament-tiptap-editor

A Rich Text Editor plugin for Filament Forms.
MIT License
272 stars 73 forks source link

Editing the source of a field returns an exception on submit. #201

Closed sjardim closed 10 months ago

sjardim commented 10 months ago

Filament Version

v3.0.91

Plugin Version

v3.1.0

PHP Version

PHP 8.2

Problem description

When editing the source of a field, the source action throws an exception:

Too few arguments to function FilamentTiptapEditor\TiptapEditor::renderBlockPreviews(), 1 passed in /Users/sjardim/Herd/filament-flexible/vendor/awcodes/filament-tiptap-editor/src/Actions/SourceAction.php on line 36 and exactly 2 expected

Possible solution:

Change the method renderBlockPreviews() inside /src/TipTapEditor.php to expect the component instance as null for default, as such:

 public function renderBlockPreviews(array $document, ?TiptapEditor $component = null): array
    {
        $content = $document['content'];

        $component ?? $component = $this;

...rest of function body

Expected behavior

The sourceAction class should return the edited state to the field.

Steps to reproduce

Click on the "source" button on the editor, make some changes to the source HTML, and submit these changes.

Reproduction repository

No response

Relevant log output

No response