Download the PHP package te7a-houdini/laravel-trix without Composer
On this page you can find all versions of the php package te7a-houdini/laravel-trix. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download te7a-houdini/laravel-trix
More information about te7a-houdini/laravel-trix
Files in te7a-houdini/laravel-trix
Package laravel-trix
Short Description trix editor for laravel inspired by ActionText for rails
License MIT
Homepage https://github.com/te7ahoudini/laravel-trix
Informations about the package laravel-trix
Configurable Basecamp Trix Editor delivered to your laravel application
inspired by Rails Action Text
- Installation
- Usage
- Using @trix($model, $field, $config = [])
- Storing Rich Text Fields
- Render Trix For Existing Model
- Storing Attachment
- Changing Storage Disk
- Configuration Table
- Testing
Installation
You can install the package via composer:
Then publish the configurations and migrations:
After the migration has been published then run the migrations to create required tables:
then add @trixassets
directive at the head tag of your html
Usage
let's assume we have Post model
& want to add trix editor.
Using @trix($model, $field, $config = [])
you can use @trix directive inside any view to render trix editor.
Storing Rich Text Fields
now lets try to store content
rich text field when hitting submit button.
first add HasTrixRichText
trait to your model
then you can easily store any rich text fields by multiple ways:
Render Trix For Existing Model
there's multiple ways to render trix for already existing model
Render Html For Existing Model
You can render the html content for already existing model
Storing Attachment
when uploading a file to trix editor. an ajax request is sent to store_attachment_action
in laravel-trix
config file. which uses Laravel Storage and then this action returns url
if upload is success according to Basecamp Trix api .
the uploaded file will be stored in trix_attachments
table as pending
attachment.
once model is saved . all pending
attachments will have is_pending
column = 0
so in order to make storing attachment very easy make sure to use HasTrixRichText
trait in your model.
Changing Storage Disk
you can change attachment storage disk from laravel-trix
config file .
or if you want to change the storage disk for specific rich text field you can do that
Deleting Rich Text Field and Attachments
you can remove related rich text fields and attachments on a model deleting:
Configuration Table
if you want to hide buttons or toolbar you can do this. for more configuration refer to the table below.
configuration | type | values | description |
---|---|---|---|
hideToolbar | Boolean | True or False | hides the the toolbar |
hideTools | Array | ['text-tools', 'block-tools', 'file-tools', 'history-tools'] | hides group of buttons |
hideButtonIcons | Array | ['attach', 'bold', 'italic', 'strike', 'link', 'heading-1', 'quote', 'code', 'bullet-list', 'number-list', 'decrease-nesting-level', 'increase-nesting-level'] | hides a single button |
disk | String | 'local' or 's3' or 'any-disk' | sets the attachment storage per field |
id | String | 'any-value-you-want' | the id of input which renders trix. check this link . current id follows this convention (model lowered class name)-field-modelId like post-content-1 or post-content-new-model |
containerElement | String | valid html tag like span or div |
default container tag is set to span you can change it as you want |
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Ahmed Abd El Ftah
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-trix with dependencies
laravel/framework Version ~5.8.0|~6.0|~7.0|~8.0|~9.0|^10.0|^11.0|^12.0