Skip to content

Commit

Permalink
Merge pull request #479 from ruud-sibi/3.x
Browse files Browse the repository at this point in the history
Grid Builder Action is now customizable
  • Loading branch information
awcodes authored Oct 15, 2024
2 parents fef63d8 + 0cf07b6 commit d7de2b5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ TiptapEditor::make('content')

## Overrides

The Link and Media modals are built using Filament Form Component Actions. This means it is easy enough to swap them out with your own implementations.
The Link, Media and Grid Builder modals are built using Filament Form Component Actions. This means it is easy enough to swap them out with your own implementations.

### Link Modal

Expand All @@ -227,6 +227,12 @@ You may override the default Media modal with your own Action and assign to the

See `vendor/awcodes/filament-tiptap-editor/src/Actions/MediaAction.php` for implementation.

### Grid Builder Modal

You may override the default Grid Builder modal with your own Action and assign to the `grid_builder_action` key in the config file. Make sure the default name for your action is `filament_tiptap_grid`.

See `vendor/awcodes/filament-tiptap-editor/src/Actions/GridBuilderAction.php` for implementation.

### Initial height of editor field

You can add extra input attributes to the field with the `extraInputAttributes()` method. This allows you to do things like set the initial height of the editor.
Expand Down
1 change: 1 addition & 0 deletions config/filament-tiptap-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
// 'media_action' => Awcodes\Curator\Actions\MediaAction::class,
'edit_media_action' => FilamentTiptapEditor\Actions\EditMediaAction::class,
'link_action' => FilamentTiptapEditor\Actions\LinkAction::class,
'grid_builder_action' => FilamentTiptapEditor\Actions\GridBuilderAction::class,

/*
|--------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions src/Concerns/HasCustomActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ trait HasCustomActions

public ?string $editMediaAction = null;

public ?string $gridBuilderAction = null;

public function linkAction(string | Closure $action): static
{
$this->linkAction = $action;
Expand Down Expand Up @@ -54,4 +56,17 @@ public function getEditMediaAction(): Action

return $action::make();
}

public function gridBuilderAction(string | Closure $action): static
{
$this->gridBuilderAction = $action;

return $this;
}

public function getGridBuilderAction(): Action
{
$action = $this->evaluate($this->gridBuilderAction) ?? config('filament-tiptap-editor.grid_builder_action');
return $action::make();
}
}
2 changes: 1 addition & 1 deletion src/TiptapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function setUp(): void
$this->registerActions([
SourceAction::make(),
OEmbedAction::make(),
GridBuilderAction::make(),
fn (): Action => $this->getGridBuilderAction(),
fn (): Action => $this->getLinkAction(),
fn (): Action => $this->getMediaAction(),
fn (): Action => $this->getInsertBlockAction(),
Expand Down

0 comments on commit d7de2b5

Please sign in to comment.