Skip to content

Commit

Permalink
Merge pull request rails#44421 from jonathanhefner/guide-action_text-…
Browse files Browse the repository at this point in the history
…custom-rendering

Update instructions for rich text custom rendering [ci-skip]
  • Loading branch information
jonathanhefner committed Feb 14, 2022
2 parents 1fb6d1b + 940980d commit 93c1405
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions guides/source/action_text_overview.md
Expand Up @@ -113,16 +113,8 @@ end

## Rendering Rich Text content

Action Text will sanitize and render rich content on your behalf.

By default, the Action Text editor and content are styled by the Trix defaults.

If you want to change these defaults, remove the `// require "actiontext.scss"`
line from your `application.scss` to omit the [contents of that
file](https://raw.githubusercontent.com/basecamp/trix/master/dist/trix.css).

By default, Action Text will render rich text content into an element that
declares the `.trix-content` class:
By default, Action Text will render rich text content inside an element with the
`.trix-content` class:

```html+erb
<%# app/views/layouts/action_text/contents/_content.html.erb %>
Expand All @@ -131,13 +123,18 @@ declares the `.trix-content` class:
</div>
```

If you'd like to change the rich text's surrounding HTML with your own layout,
declare your own `app/views/layouts/action_text/contents/_content.html.erb`
template and call `yield` in place of the content.
Elements with this class, as well as the Action Text editor, are styled by the
[`trix` stylesheet](https://raw.githubusercontent.com/basecamp/trix/master/dist/trix.css).
To provide your own styles instead, remove the `= require trix` line from the
`app/assets/stylesheets/actiontext.css` stylesheet created by the installer.

To customize the HTML rendered around rich text content, edit the
`app/views/layouts/action_text/contents/_content.html.erb` layout created by the
installer.

You can also style the HTML used for embedded images and other attachments
(known as blobs). On installation, Action Text will copy over a partial to
`app/views/active_storage/blobs/_blob.html.erb`, which you can specialize.
To customize the HTML rendered for embedded images and other attachments (known
as blobs), edit the `app/views/active_storage/blobs/_blob.html.erb` template
created by the installer.

### Rendering attachments

Expand Down

0 comments on commit 93c1405

Please sign in to comment.