Skip to content

Commit

Permalink
Merge pull request #505 from victore13/overwrite-oembedaction-file
Browse files Browse the repository at this point in the history
feat: implemented the possibility of overwriting the `OEmbedAction` file.
  • Loading branch information
awcodes authored Nov 26, 2024
2 parents 6b5428d + 12a50ae commit 9138c39
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ You may override the default Grid Builder modal with your own Action and assign

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

### OEmbed Modal

You may override the default OEmbed modal with your own Action and assign to the `oembed_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/OEmbedAction.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 @@ -38,6 +38,7 @@
'edit_media_action' => FilamentTiptapEditor\Actions\EditMediaAction::class,
'link_action' => FilamentTiptapEditor\Actions\LinkAction::class,
'grid_builder_action' => FilamentTiptapEditor\Actions\GridBuilderAction::class,
'oembed_action' => FilamentTiptapEditor\Actions\OEmbedAction::class,

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

public ?string $gridBuilderAction = null;

public ?string $oembedAction = null;

public function linkAction(string | Closure $action): static
{
$this->linkAction = $action;
Expand All @@ -29,6 +31,13 @@ public function mediaAction(string | Closure $action): static
return $this;
}

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

return $this;
}

public function getLinkAction(): Action
{
$action = $this->evaluate($this->linkAction) ?? config('filament-tiptap-editor.link_action');
Expand Down Expand Up @@ -70,4 +79,11 @@ public function getGridBuilderAction(): Action

return $action::make();
}

public function getOEmbedAction(): Action
{
$action = $this->evaluate($this->oembedAction) ?? config('filament-tiptap-editor.oembed_action');

return $action::make();
}
}
3 changes: 1 addition & 2 deletions src/TiptapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Filament\Forms\Components\Concerns\HasPlaceholder;
use Filament\Forms\Components\Field;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use FilamentTiptapEditor\Actions\OEmbedAction;
use FilamentTiptapEditor\Actions\SourceAction;
use FilamentTiptapEditor\Concerns\CanStoreOutput;
use FilamentTiptapEditor\Concerns\HasCustomActions;
Expand Down Expand Up @@ -166,7 +165,7 @@ protected function setUp(): void

$this->registerActions([
SourceAction::make(),
OEmbedAction::make(),
fn (): Action => $this->getOEmbedAction(),
fn (): Action => $this->getGridBuilderAction(),
fn (): Action => $this->getLinkAction(),
fn (): Action => $this->getMediaAction(),
Expand Down

0 comments on commit 9138c39

Please sign in to comment.