Add hooks to integrate with Action Text #688
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One major challenge that applications face when integrating with morphing-powered Page Refreshes involves
<trix-editor>
elements rendered by Action Text.The emergent guidance instructs applications to skip morphing by marking the
<trix-editor>
as permanent. This guidance, while correct, does not encapsulate the entire story. In the case of Action Text-rendered<trix-editor>
elements, applications might invokeform.rich_text_area
withdata: {turbo_permanent: true}
, expecting for the presence oftrix-editor[data-turbo-permanent]
to be sufficient.However, to achieve the intended behavior, applications must nest their
<trix-editor>
elements within an element with[data-turbo-permanent]
(a<div>
, a<fieldset>
, etc.). This provides a container for thetrix-editor
to inject its associated<input>
and<trix-toolbar>
elements. A<trix-editor>
element will insert an<input type="hidden">
element and a<trix-toolbar>
element when they are absent on connect.Applications can skip a Trix-manage injection by rendering those either (or both) elements ahead of time, then associating them to the
trix-editor
through[input]
and[toolbar]
attributes (respectively).Action Text skips the
<input>
injection step by rendering and associating an Action View-rendered<input type="hidden">
attribute with the appropriate attributes.No matter how the
<input>
connects to the document, it's important for it to keep its[data-turbo-permanent]
synchronized with thetrix-editor
's attribute in order to tolerate a morph.Since Page Refreshes, Morphing, and permanence are all Turbo concepts, and Action Text is a Rails framework,
turbo-rails
feels like the most appropriate codebase (out ofrails
,trix
,turbo
, andturbo-rails
) to house the integration.