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:
1composer require te7a-houdini/laravel-trix
Publish the assets:
1php artisan vendor:publish --provider="Te7aHoudini\LaravelTrix\LaravelTrixServiceProvider"
Then, run the migrations:
1php 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:
1<html>2 <head>3 @trixassets4 </head>56 <body>7 <form method="POST" action="route('article.store')">8 @csrf9 @trix(\App\Article::class, 'content')10 <input type="submit">11 </form>12 </body>13</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.