Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix action text extra trix content wrapper #43133

Conversation

alexandreruban
Copy link
Contributor

Closes #42315

Summary

When copying an ActionText::RichText between two models, an extra <div class="trix-content">...</div> was added as described in the issue. This comes from the fact that an ActionText::RichText is serialized in a ActionText::Content.

# app/models/action_text/rich_text.rb

module ActionText
  class RichText < Record
    serialize :body, ActionText::Content
  end
end

When the serialization happens in the ActionText::Content.dump method, we didn't have a case to handle serialization of ActionText::RichText, but there is no need to serialize again. We can simply retrieve the HTML body of the ActionText::Content associatied with the ActionText::RichText.

@rails-bot rails-bot bot added the actiontext label Aug 30, 2021
@alexandreruban alexandreruban force-pushed the fix-action-text-extra-trix-content-wrapper branch 2 times, most recently from f799854 to 3011bb6 Compare September 19, 2021 09:09
@alexandreruban alexandreruban force-pushed the fix-action-text-extra-trix-content-wrapper branch from 3011bb6 to 458908e Compare September 20, 2021 08:38
@rafaelfranca rafaelfranca merged commit 7d8dd74 into rails:main Sep 20, 2021
rafaelfranca added a commit that referenced this pull request Sep 20, 2021
…rix-content-wrapper

Fix action text extra trix content wrapper
@alexandreruban alexandreruban deleted the fix-action-text-extra-trix-content-wrapper branch September 20, 2021 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copying ActionText associations between models creates an extra "trix-content" wrapper div
2 participants