Trix is an open-source WYSIWYG editor from the creators of Basecamp and it’s designed to be a different editor. Here is how they describe it:
Most WYSIWYG editors are wrappers around HTML’s contenteditable and execCommand APIs, designed by Microsoft to support live editing of web pages in Internet Explorer 5.5, and eventually reverse-engineered and copied by other browsers.
Trix sidesteps these inconsistencies by treating contenteditable as an I/O device: when input makes its way to the editor, Trix converts that input into an editing operation on its internal document model, then re-renders that document back into the editor. This gives Trix complete control over what happens after every keystroke, and avoids the need to use execCommand at all.
First, install the Composer package:
composer require te7a-houdini/laravel-trix
Publish the assets:
php artisan vendor:publish --provider="Te7aHoudini\LaravelTrix\LaravelTrixServiceProvider"
Then, run the migrations:
php artisan migrate
Once you’ve installed the package pretend you have an articles Model and you want the Trix editor on it’s create and update forms. All you need to do is use Blade and it’s included directives:
<html><head>@trixassets</head><body><form method="POST" action="route('article.store')">@csrf@trix(\App\Article::class, 'content')<input type="submit"></form></body></html>
The package includes a lot more features like handling uploaded files, rendering for existing models, and advanced configuration. You can find out more about this package from the Github page and read the full user guide.