Skip to content

JKHarley/filament-trumbowyg

Repository files navigation

Filament Trumbowyg

Latest Version on Packagist Total Downloads

Trumbowyg wysiwyg editor field for Filament.

Screenshot 2022-11-27 at 18 04 49

Disclaimer

Warning: This field does not work with the Filament block builder. I'm actively trying to make this compatible and will hopefully have an update in the near future. The WYSIWYG default theme may also not work as expected in some cases with the Filament 3 theming. If you're using Filament in light mode make sure to set reset_css to false in the filament-trumbowyg.php config in a future update I will be adding the ability to customise the WYSIWYG theme.

Installation

You can install the package via composer:

composer require jkharley/filament-trumbowyg

Usage

use JKHarley\FilamentTrumbowyg\Trumbowyg;

Trumbowyg::make('my-field')

Buttons Pane Customisation

You can customise the buttons pane by passing an array of buttons to the buttons key in the filament-trumbowyg config file. This will overwrite the default buttons pane set by Trumbowyg and will be used across all Trumbowyg fields.

php artisan vendor:publish --tag="filament-trumbowyg-config"
// config/filament-trumbowyg.php
'buttons' => [
    ['undo', 'redo'],
    ['strong', 'em', 'del'],
    'link',
    'fullscreen',
]

Screenshot 2022-11-30 at 18 20 13

Alternatively you can pass an array of buttons to the buttons method on the field. You can also use this to overwrite the buttons set in the config file for a specific field.

Trumbowyg::make('my-field')
    ->buttons([
        ['undo', 'redo'],
        ['strong', 'em', 'del'],
        'link',
        'fullscreen',
    ]),

Basic Options

Most options under the basic options selection on the Trumbowyg website are supported with this field. Each option can be added as a chained method on the field or all fields can default to a value set in the config file. Here are the options that can be passed with an example value:

Trumbowyg::make('my-field')
    ->tagClasses([])
    ->changeActiveDropdownIcon(true)
    ->removeFormatPasted(true)
    ->tagsToRemove(['script'])
    ->tagsToKeep([])
    ->minimalLinks(true)
    ->linkTargets(['_self'])
    ->imageWidthModalEdit(true)
    ->urlProtocol('ftp')

Future Additions

  • Localization
  • Theme customisation
  • SVG icon customisation

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.