Skip to content

Commit

Permalink
Fix: integration with tiptap editor
Browse files Browse the repository at this point in the history
  • Loading branch information
awcodes committed Dec 6, 2023
1 parent 25c0fe2 commit 7208a6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Actions/MediaAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Livewire\Component;

class MediaAction extends Action
{
Expand All @@ -26,17 +27,14 @@ protected function setUp(): void
->arguments([
'src' => '',
])
->modalWidth('screen')
->modalHeading(__('curator::views.panel.heading'))
->modalFooterActions(fn() => [])
->modalContent(static function (TiptapEditor|CuratorPicker $component, array $arguments) {
->action(function (TiptapEditor|CuratorPicker $component, Component $livewire, array $arguments) {

$selected = $arguments['src'] !== ''
? [App::get(Media::class)->firstWhere('name', Str::of($arguments['src'])->afterLast('/')->beforeLast
('.'))]
: [];

return View::make('curator::components.actions.picker-action', [
$livewire->dispatch('open-modal', id: 'curator-panel', settings: [
'acceptedFileTypes' => Config::get('curator.accepted_file_types'),
'directory' => Config::get('curator.directory'),
'diskName' => Config::get('curator.disk'),
Expand Down
8 changes: 8 additions & 0 deletions src/Components/Modals/CuratorPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,14 @@ public function updateFileAction(): Action
if ($item) {
$item->update($this->form->getState());

$this->selected = collect($this->selected)->map(function ($selectedItem) use ($item) {
if ($selectedItem['id'] === $item->id) {
return $item->refresh();
}

return $selectedItem;
})->toArray();

Notification::make('curator_update_success')
->success()
->body(__('curator::notifications.update_success'))
Expand Down

0 comments on commit 7208a6b

Please sign in to comment.