parallax / filament-syntax-entry
Add a Filament infolist entry for themeable syntax highlighting.
Installs: 17 245
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 5
Open Issues: 6
Requires
- php: ^8.3
- filament/filament: ^3.0
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.15.0
- tempest/highlight: ^1.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9|^8.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
Add a Filament infolist entry for themeable server-side syntax highlighting using tempestphp/highlight.
Installation
Install the package via composer:
composer require parallax/filament-syntax-entry
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-syntax-entry-views"
Upgrading from 1.x
There are a couple of important changes to be aware of when upgrading to version 2.x:
- PHP 8.3 is required for server-side syntax highlighting
- Highlight.js is no longer supported
- Theme selection has been replaced with the ability to create custom themes
Quickstart
Add the Infolist entry
Add the SyntaxEntry
to the $infolist->schema()
method.
<?php namespace App\Filament\Resources; use Parallax\FilamentSyntaxEntry\SyntaxEntry; class ProductResource extends Resource { public static function infolist(Infolist $infolist): Infolist { return $infolist ->schema([ SyntaxEntry::make('metadata'), ]); } }
Setting the language
The default language value is set to json
. To override this value you may use the language()
method:
SyntaxEntry::make('metadata') ->language('json');
The following languages are currently available:
blade
css
gdscript
html
javascript
json
php
sql
twig
xml
yaml
Creating a custom theme
You may override the default theme by using the theme()
method:
SyntaxEntry::make('metadata') ->theme('smudge');
This will wrap the syntax component with a custom class like so:
syntax-entry-theme-smudge
The final step is to follow the tempestphp/highlight documentation on how to create your own theme, and use this in combination with Filament themes.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.