ActionText is a power-packed tool designed to
build WYSIWYG editors for our Rails applications easily.
Action Text brings rich text content
and editing to Rails.
It includes the Trix editor that handles everything from formatting
to links to quotes to lists to embedded images
<trix-editor> doesn’t support the
<textarea> or other form fields.
consider the following HTML and event listener:
Here, the target is an instance of
HTMLTextAreaElement that relies on the
[HTMLTextAreaElement.form] property for access to its associated
<form>(returns a reference to the parent form element).
Given the way the
[form] attribute can reference a
element that is not an ancestor,
that same event listener would
continue to work with this HTML:
[form] attribute with another
[id] value can associate
a field to a
is not an ancestor.
That means that the same event listener from above
would continue to work with the following HTML:
<textarea> element were replaced with a
the event listener’s reliance on accessing the form
as a property would break,
<trix-editor> custom element
doesn’t declare that property.
So, how to provide property access for
similar to how an
<textarea> element can access
a form outside of its direct tree of ancestors via
and the corresponding .form property?
To acheive this, we can use
rich_text_area_tag returns a trix-editor tag that instantiates
that Trix will write to on changes,
so that the content will be sent on form submissions.
To know more about the fix, checkout this