class ActionText::TrixAttachment
Constants
- ATTRIBUTES
- ATTRIBUTE_TYPES
- COMPOSED_ATTRIBUTES
- SELECTOR
- TAG_NAME
Attributes
Public Class Methods
# File actiontext/lib/action_text/trix_attachment.rb, line 21 def from_attributes(attributes) attributes = process_attributes(attributes) trix_attachment_attributes = attributes.except(*COMPOSED_ATTRIBUTES) trix_attributes = attributes.slice(*COMPOSED_ATTRIBUTES) node = ActionText::HtmlConversion.create_element(TAG_NAME) node["data-trix-attachment"] = JSON.generate(trix_attachment_attributes) node["data-trix-attributes"] = JSON.generate(trix_attributes) if trix_attributes.any? new(node) end
# File actiontext/lib/action_text/trix_attachment.rb, line 53 def initialize(node) @node = node end
Public Instance Methods
# File actiontext/lib/action_text/trix_attachment.rb, line 57 def attributes @attributes ||= attachment_attributes.merge(composed_attributes).slice(*ATTRIBUTES) end
# File actiontext/lib/action_text/trix_attachment.rb, line 61 def to_html ActionText::HtmlConversion.node_to_html(node) end
# File actiontext/lib/action_text/trix_attachment.rb, line 65 def to_s to_html end