Skip to content

Commit

Permalink
Fix links
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Feb 19, 2024
1 parent ee7ade2 commit 643f40e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ A basic version of attachments uploading would look something like this:

The package contains a demo application with basic image uploading functionality implemented in the Workbench application. Here's some relevant links:

- The Stimulus controller that manages uploading (you should be able to map what's going on there to any JavaScript framework you'd like) can be found at [app-layout.blade.php](workbench/resources/views/components/app-layout.blade.php), look for the "rich-text-uploader" Stimulus controller;
- The upload route can be found at [./workbench/routes/web.php](), look for the `POST /attachments` route;
- The Trix Input Blade component at [./workbench/resources/views/components/trix-input.blade.php](). This is copy of the component that ships with the package with some tweaks.
- The Stimulus controller that manages uploading (you should be able to map what's going on there to any JavaScript framework you'd like) can be found at [resources/views/components/app-layout.blade.php](workbench/resources/views/components/app-layout.blade.php), look for the "rich-text-uploader" Stimulus controller;
- The upload route can be found at [routes/web.php](workbench/routes/web.php), look for the `POST /attachments` route;
- The Trix Input Blade component at [resources/components/trix-input.blade.php](workbench/resources/views/components/trix-input.blade.php). This is copy of the component that ships with the package with some tweaks.

However, you're not limited to this basic attachment handling in Trix. A more advanced attachment behavior could create its own backend model, then set the `sgid` attribute on the attachment, which would let you have full control over the rendered HTML when the document renders outside the Trix editor.

Expand All @@ -257,11 +257,11 @@ The `$options` array passed to the `richTextRender` is there in case you're rend

You may use Blade to render an HTML partial for the attachable. For a reference, the Workbench application ships with a User Mentions feature, which may be used as an example of content attachments. Here's some relevant links:

- The User model which implements the `AttachmentContract` can be found at [./workbench/app/Models/User.php]();
- The model uses a custom Trait called `Mentionee` which uses the `Attachable` trait under the hood, so take a look at the [./workbench/app/Models/User/Mentionee.php]() trait;
- In the frontend, we're using [Zurb's Tribute](https://github.com/zurb/tribute) lib to detect mentions whenever the user types the `@` symbol in Trix. The Simulus controller that sets it up can be found at [./workbench/resources/views/components/app-layout.blade.php](). Look for the "rich-text-mentions" controller. This is the same implement covered in the RailsConf talk mentioned earlier, so check that out if you need some help understanding what's going on. There are two Trix components in the workbench app, one used for posts and comments which may be found at [./workbench/resources/views/components/trix-input.blade.php]() and one for the Chat composer, which may be found at [./workbench/resources/views/chat/partials/trix-input.blade.php]. In both components you will find a `data-action` entry listening for the `tribute-replaced` event, that's the event Tribute will dispatch for us to create the Trix attachment, providing us the selected option the user has picked from the dropdown;
- The mentioner class will look for mentions in the `GET /mentions?search=` route, which you may find at [./workbench/routes/web.php](). Note that we're turning the `sgid` and the `content` field, those are used for the Trix attachment. The `name` field is also returning, which is used by Tribute itself to compose the mentions feature.
- The Blade view that will render the user attachment can be found at [./workbench/resources/views/mentions/partials/user.blade.php]()
- The User model which implements the `AttachmentContract` can be found at [User Model](workbench/app/Models/User.php);
- The model uses a custom Trait called `Mentionee` which uses the `Attachable` trait under the hood, so take a look at the [Mentionee Trait](workbench/app/Models/User/Mentionee.php) trait;
- In the frontend, we're using [Zurb's Tribute](https://github.com/zurb/tribute) lib to detect mentions whenever the user types the `@` symbol in Trix. The Simulus controller that sets it up can be found at [resources/views/components/app-layout.blade.php](workbench/resources/views/components/app-layout.blade.php). Look for the "rich-text-mentions" controller. This is the same implement covered in the RailsConf talk mentioned earlier, so check that out if you need some help understanding what's going on. There are two Trix components in the workbench app, one used for posts and comments which may be found at [resources/views/components/trix-input.blade.php](workbench/resources/views/components/trix-input.blade.php) and one for the Chat composer, which may be found at [resources/views/chat/partials/trix-input.blade.php](workbench/resources/views/chat/partials/trix-input.blade.php). In both components you will find a `data-action` entry listening for the `tribute-replaced` event, that's the event Tribute will dispatch for us to create the Trix attachment, providing us the selected option the user has picked from the dropdown;
- The mentioner class will look for mentions in the `GET /mentions?search=` route, which you may find at [routes/web.php](workbench/routes/web.php). Note that we're turning the `sgid` and the `content` field, those are used for the Trix attachment. The `name` field is also returning, which is used by Tribute itself to compose the mentions feature.
- The Blade view that will render the user attachment can be found at [resources/views/mentions/partials/user.blade.php](workbench/resources/views/mentions/partials/user.blade.php)

You can later retrieve all attachments from that rich text content. See [The Content Object](#content-object) section for more.

Expand Down

0 comments on commit 643f40e

Please sign in to comment.