Skip to content

Commit

Permalink
Add support for minimal links
Browse files Browse the repository at this point in the history
  • Loading branch information
JKHarley committed Jul 21, 2023
1 parent d5ad663 commit 06759bd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/filament-trumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
'tags_to_remove' => [],
'tags_to_keep' => [],
'url_protocol' => false,
'minimal_links' => false,
];
11 changes: 11 additions & 0 deletions resources/views/trumbowyg.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@
options.urlProtocol = @json(config('filament-trumbowyg.url_protocol'))
@endif
@if (!is_null($getMinimalLinks()))
options.minimalLinks = @json($getMinimalLinks());
@endif
@if (
is_null($getMinimalLinks()) &&
!is_null(config('filament-trumbowyg.minimal_links'))
)
options.minimalLinks = @json(config('filament-trumbowyg.minimal_links'))
@endif
$(id).trumbowyg(options);
if (window.livewire.data) {
Expand Down
2 changes: 2 additions & 0 deletions src/Trumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Filament\Forms\Components\Concerns\HasPlaceholder;
use JKHarley\FilamentTrumbowyg\traits\HasButtons;
use JKHarley\FilamentTrumbowyg\traits\HasChangeActiveDropdownIcon;
use JKHarley\FilamentTrumbowyg\traits\HasMinimalLinks;
use JKHarley\FilamentTrumbowyg\traits\HasRemoveFormatPasted;
use JKHarley\FilamentTrumbowyg\traits\HasSemantic;
use JKHarley\FilamentTrumbowyg\traits\HasTagClasses;
Expand All @@ -23,6 +24,7 @@ class Trumbowyg extends \Filament\Forms\Components\Field
use HasTagsToRemove;
use HasTagsToKeep;
use HasUrlProtocol;
use HasMinimalLinks;

protected string $view = 'filament-trumbowyg::trumbowyg';
}
22 changes: 22 additions & 0 deletions src/traits/HasMinimalLinks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace JKHarley\FilamentTrumbowyg\traits;

use Closure;

trait HasMinimalLinks
{
protected bool|Closure|null $minimalLinks = null;

public function minimalLinks(bool|Closure|null $minimalLinks): static
{
$this->minimalLinks = $minimalLinks;

return $this;
}

public function getMinimalLinks(): ?bool
{
return $this->evaluate($this->minimalLinks);
}
}

0 comments on commit 06759bd

Please sign in to comment.