module ActionText::Attachments::TrixConversion
Public Instance Methods
fragment_by_converting_trix_attachments(content)
click to toggle source
# File lib/action_text/attachments/trix_conversion.rb, line 8 def fragment_by_converting_trix_attachments(content) Fragment.wrap(content).replace(TrixAttachment::SELECTOR) do |node| from_trix_attachment(TrixAttachment.new(node)) end end
from_trix_attachment(trix_attachment)
click to toggle source
# File lib/action_text/attachments/trix_conversion.rb, line 14 def from_trix_attachment(trix_attachment) from_attributes(trix_attachment.attributes) end
to_trix_attachment(content = trix_attachment_content)
click to toggle source
# File lib/action_text/attachments/trix_conversion.rb, line 19 def to_trix_attachment(content = trix_attachment_content) attributes = full_attributes.dup attributes["content"] = content if content TrixAttachment.from_attributes(attributes) end
Private Instance Methods
trix_attachment_content()
click to toggle source
# File lib/action_text/attachments/trix_conversion.rb, line 26 def trix_attachment_content if partial_path = attachable.try(:to_trix_content_attachment_partial_path) ActionText::Content.renderer.render(partial: partial_path, object: self, as: model_name.element) end end