-
-
Notifications
You must be signed in to change notification settings - Fork 277
[Draft] Improving trix field #3609
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
[Draft] Improving trix field #3609
Conversation
Code Climate has analyzed commit 9c2d284 and detected 0 issues on this pull request. View more on Code Climate. |
This PR has been marked as stale because there was no activity for the past 15 days. |
This PR has been marked as stale because there was no activity for the past 15 days. |
Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️ |
Hey @Paul-Bob, I don’t have time to finish this PR right now, so I’ll close it for now. The main issue I encountered was that PDFs were not appearing in the body when rendered as HTML—they showed as "file not found" inside the preview. To solve this, I made changes inside the serializer to ensure the frontend receives the correct HTML. Here’s the updated method: def content
# rubocop:disable Style/SafeNavigationChainLength
content = object.content&.to_s&.gsub("<iframe", "<iframe")&.gsub("></iframe>", "></iframe>")
# rubocop:enable Style/SafeNavigationChainLength
matches = content&.scan(%r{<action-text-attachment([^>]*)>([\s\S]*?)</action-text-attachment>})
matches&.each do |match|
type = match[0].match(/content-type="(.*?)"/)[1]
if type.include? "image/"
content = content.sub(
%r{<action-text-attachment([^>]*)>([\s\S]*?)</action-text-attachment>},
match[1],
)
next
end
href = match[0].match(/href="(.*?)"/)[1]
filename = match[0].match(/filename="(.*?)"/)[1]
content = content.sub(
%r{<action-text-attachment([^>]*)>([\s\S]*?)</action-text-attachment>},
"<a href=\"#{href}\" download=\"#{filename}\">#{filename}</a>",
)
end
content
rescue => e
Sentry.capture_exception(e)
"Não foi possível carregar o conteúdo da sua publicação"
end |
Is it working for you now? I haven’t been able to reproduce the issue on my end, and I haven’t had a chance to get hands-on with this PR yet. If there’s a straightforward way to reproduce it, let me know Thanks for sharing your solution! |
Description
Fixes #2715
This PR enhances the Trix Avo field by leveraging Rails' rich_text_tag. Previously, Avo relied on its own attachment strategy, but in this PR, I refactored it to use Rails' direct upload solution, making it possible to edit and add attachments while creating a record.
Checklist:
Screenshots & recording
Manual review steps
Manual reviewer: please leave a comment with output from the test if that's the case.