Methods
- A
- F
- N
- T
Constants
ATTRIBUTES | = | %w( sgid contentType url href filename filesize width height previewable content ) + COMPOSED_ATTRIBUTES |
ATTRIBUTE_TYPES | = | { "previewable" => ->(value) { value.to_s == "true" }, "filesize" => ->(value) { Integer(value.to_s, exception: false) || value }, "width" => ->(value) { Integer(value.to_s, exception: false) }, "height" => ->(value) { Integer(value.to_s, exception: false) }, :default => ->(value) { value.to_s } } |
COMPOSED_ATTRIBUTES | = | %w( caption presentation ) |
SELECTOR | = | "[data-trix-attachment]" |
TAG_NAME | = | "figure" |
Attributes
[R] | node |
Class Public methods
from_attributes(attributes) Link
# File actiontext/lib/action_text/trix_attachment.rb, line 19 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