rails/actiontext/CHANGELOG.md

25 lines
900 B
Markdown
Raw Normal View History

Action Text: forward form: option to hidden input Trix's `<trix-editor>` doesn't support the [form][] property like `<textarea>` or other form fields. For example, consider the following HTML and event listener: ```html <form action="/articles" method="post"> <textarea name="content"></textarea> <button type="submit">Save</button> </form> <script> addEventListener("keydown", ({ key, metaKey, target }) => { if (target.form && key == "Enter" && (metaKey || ctrlKey)) { form.requestSubmit() } }) </script> ``` The `target` (an instance of `HTMLTextAreaElement` relies on the [HTMLTextAreaElement.form][] property for access to its associated `<form>`. While it's usually equivalent to `target.closest("form")`, that isn't always the case. Declaring a `[form]` attribute with another `<form>` element's `[id]` value can associate a field to a `<form>` that is _not an ancestor_. That means that the event listener from above would continue to work with this HTML: ```html <textarea name="content" form="new_article"></textarea> <!-- elsewhere --> <form id="new_article" action="/articles" method="post"> <button type="submit">Save</button> </form> ``` Unfortunately, if the `<textarea>` element were replaced with a `<trix-editor>`, the event listener's reliance on accessing the form as a property would break, since the `<trix-editor>` custom element doesn't declare that property. There is currently a pull request ([basecamp/trix#899][]) to add support for accessing the `form` as a property of the `<trix-editor>` element. The [feedback][] provided on that pull request suggests that we implement the `form` property by delegating to the `<input type="hidden">` element. Currently, `<input type="hidden">` elements constructed by Action Text helpers cannot declare the `[form]` attribute. This commit adds support by special-casing the `options[:form]` key within `ActionText::TagHelper#rich_text_area_tag`. [form]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement#properties [basecamp/trix#899]: https://github.com/basecamp/trix/pull/899#discussion_r618543357 [feedback]: https://github.com/basecamp/trix/pull/899#discussion_r618543357
2021-04-25 20:11:17 +08:00
* Add support for passing `form:` option to `rich_text_area_tag` and
`rich_text_area` helpers to specify the `<input type="hidden" form="...">`
value.
*Sean Doyle*
* Add `config.action_text.attachment_tag_name`, to specify the HTML tag that contains attachments.
*Mark VanLandingham*
2020-09-30 11:16:18 +08:00
* Expose how we render the HTML _surrounding_ rich text content as an
extensible `layouts/action_view/contents/_content.html.erb` template to
encourage user-land customizations, while retaining private API control over how
the rich text itself is rendered by `action_text/contents/_content.html.erb`
partial.
*Sean Doyle*
* Add `with_all_rich_text` method to eager load all rich text associations on a model at once.
*Matt Swanson*, *DHH*
2020-11-03 05:12:47 +08:00
2020-12-03 07:37:26 +08:00
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/actiontext/CHANGELOG.md) for previous changes.