Skip to content

Commit

Permalink
Merge pull request #17 from mansoorkhan96/feat/add-option-to-strip-tags
Browse files Browse the repository at this point in the history
feat: Add option to strip tags
  • Loading branch information
mansoorkhan96 authored Apr 25, 2024
2 parents fa39174 + 0191ba0 commit 3fc926d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ php artisan vendor:publish --tag="filament-versionable-views"

If you want more control over how the versions are stored, you may read the [Laravel Versionable Docs](https://github.com/overtrue/laravel-versionable).

## Strip Tags from Diff

You can easily remove/strip HTML tags from the diff by just overriding `shouldStripTags` method inside your revisions page.

```php
class ArticleRevisions extends RevisionsPage
{
protected static string $resource = ArticleResource::class;

public function shouldStripTags(): bool
{
return true;
}
}
```

## Testing

```bash
Expand Down
8 changes: 7 additions & 1 deletion src/RevisionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class RevisionsPage extends Page

protected static string $view = 'filament-versionable::revisions-page';

public function shouldStripTags(): bool
{
return false;
}

public static function getNavigationIcon(): ?string
{
return static::$navigationIcon ?? 'heroicon-o-clock';
Expand Down Expand Up @@ -54,7 +59,8 @@ public function diff(): array
->diff()
->toSideBySideHtml(
differOptions: ['fullContextIfIdentical' => true],
renderOptions: ['lineNumbers' => false, 'showHeader' => false, 'detailLevel' => 'word', 'spacesToNbsp' => false]
renderOptions: ['lineNumbers' => false, 'showHeader' => false, 'detailLevel' => 'word', 'spacesToNbsp' => false],
stripTags: $this->shouldStripTags()
);
}

Expand Down

0 comments on commit 3fc926d

Please sign in to comment.