Commit Graph

22 Commits

Author SHA1 Message Date
Mark VanLandingham bece535c98
Add config.action_text.attachment_tag_name 2021-03-05 16:57:36 -05:00
Abhay Nikam adc5eb66f8
Action Text: call #to_trix_html on rich_text_area_tag value 2021-02-28 11:20:59 -05:00
Sean Doyle 3500571b43 Improve ActionText extensiblibility
Extensible layout
---

Expose how we render the HTML _surrounding_ rich text content as an
extensible `layouts/action_text/contents/_content.html.erb` template to
encourage user-land customizations, while retaining private API control
over how the rich text itself is rendered by moving the
`#render_action_text_content` helper invocation to the
`action_text/contents/_content.html.erb` partial.

Extensible Attachable `#to_attachable_partial_path`
---

When an application declares a canonical partial for a record, there is
no way to override which partial is used when transformed to Rich Text.
For example, a default `Person < ApplicationRecord` instance returns
`"people/person"` from calls to `#to_partial_path`, resulting in the
`app/views/people/_person.html.erb` partial being rendered.

Prior to this change, when encountering an `<action-text-attachment
sgid="...">` element, ActionText retrieved the corresponding
`Attachable` instance (usually an `ActiveRecord::Base` instance) and
transformed it to rich text HTML by rendering the partial that
corresponds to its `#to_partial_path`.

This proposed change instead invokes
`Attachable#to_attachable_partial_path`. By default,
`#to_attachable_partial_path` is an alias for `#to_partial_path`.

Guides
---

Extend the `guides/action_text_overview` document to
describe how to customize these templates, and to better illustrate how
ActionText::Attachable instances are rendered into HTML.
2020-12-29 20:06:45 -05:00
Jonathan Hefner 614e813161
Disentangle Action Text from ApplicationController
This commit allows Action Text to be used without having an
ApplicationController defined.  In doing so, it also fixes Action Text
attachments to render the correct URL host in mailers.

It also avoids allocating an ActionController::Renderer per request.

Fixes #37183.
Fixes #35578.
Fixes #36963.
Closes #38714.

Co-authored-by: Jeremy Daer <jeremydaer@gmail.com>
2020-10-30 01:01:42 +00:00
George Claghorn b0287d0681 Extract ActionText::Record
Permit applications to hack in custom DB config for ActionText::RichText until AT has first-class multi-DB support:

    ActiveSupport.on_load(:action_text_record) do
      connects_to reading: :action_text_replica, writing: :action_text_primary
    end
2020-09-29 11:59:14 -04:00
Paulo Ancheta b9571ae45f
Add value option to ActionView::Helpers::FormBuilder#rich_text_area 2020-09-01 21:43:07 -04:00
Jan Habermann 40be6b1d4d Cleanup unneeded blank string params in ActionText 2019-08-23 20:17:38 +02:00
Juanito Fatas 52f0b050e2
Update sanitizer in ActionView::Helpers::SanitizeHelper
- The sanitizer has been changed to safe_list_sanitizer.
- deprecate white_list_sanitizer
2019-08-05 03:35:35 +02:00
Akira Matsuda 530f7805ed It may be better to explicitly require 'object/try' where we call `try`
In most cases it works now without explicit require because it's accidentally required through
active_support/core_ext/date_and_time/calculations.rb where we still call `try`,
but that would stop working if we changed the Calculations implementation and remove the require call there.
2019-08-01 18:51:51 +09:00
George Claghorn aa7da0471f Deduplicate ActionText::RichText embeds
Fix that an ActiveRecord::RecordNotUnique error would be raised when saving rich-text content with the same file attached multiple times.
2019-05-17 16:46:16 -04:00
Javan Makhmali 0ec2a90754 Make Action Text's rendering helpers more configurable
- Allow configuring the sanitizer and its options
- Split attachment rendering and sanitizing helpers so each can be overridden by applications
2019-04-22 10:15:25 -04:00
Chris LaRose c03a50ade3 Explicitly require rails-html-sanitizer gem in ActionText helpers
If the [`action_text.helper` initializer][0] runs after
`ActionController::Base` has been loaded, but before the
`rails-html-sanitizer` gem has been `require`d, then the reference to
the constant `Rails::Html` in the body of the
`ActionText::ContentHelper` module raises an `uninitialized constant`
exception.

[0]: 2170338239/actiontext/lib/action_text/engine.rb (L31-L35)
2019-03-06 17:32:03 -08:00
Abhay Nikam b3778c5708 Allows rich_text_area_tag to add I18n translated placeholder text if placeholder option set to true 2019-02-22 10:18:21 +05:30
Javan Makhmali 48c6ef9a72 Fix error saving Action Text content containing non-blob attachables
Failing test before the ActionText::RichText change:

```
Error:
ActionText::ModelTest#test_embed_extraction_only_extracts_file_attachments:
ArgumentError: Could not find or build blob: expected attachable, got #<ActionText::Attachables::RemoteImage:0x00007fb0259fef70 @url="http://example.com/cat.jpg", @content_type="image", @width=nil, @height=nil>
```
2019-01-25 16:57:36 -05:00
George Claghorn c1e949e9e6 Prefer ImageProcessing's resize_to_limit macro over resize_to_fit
Don't upsize images smaller than the specified dimensions.
2019-01-24 11:46:42 -05:00
colorbox 91fc859016 Fix document formatting on Action Text docs [ci skip]
Use `+` instead of backquote.
2019-01-24 17:44:35 +09:00
Javan Makhmali 11b73c40c2 Make trix a peer dependency of actiontext since it’s not used directly 2019-01-17 10:42:09 -05:00
Javan Makhmali 86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
George Claghorn 29bb990f97 Add load hook for ActionText::RichText 2019-01-07 17:04:58 -05:00
bogdanvlviv 78ed534f30
Fix API docs of `ActionText::RichText` [ci skip]
This text should appear on the page
https://api.rubyonrails.org/v6.0/classes/ActionText/RichText.html

Related to 86517942e4
2019-01-05 11:01:47 +02:00
George Claghorn 86517942e4 Generate Action Text's API docs 2019-01-04 23:56:22 -05:00
George Claghorn 0decd2ddc4 Import Action Text 2019-01-04 22:22:49 -05:00