Class: ActionText::TrixAttachment
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actiontext/lib/action_text/trix_attachment.rb |
Constant Summary
-
ATTRIBUTES =
# File 'actiontext/lib/action_text/trix_attachment.rb', line 11%w( sgid contentType url href filename filesize width height previewable content ) + COMPOSED_ATTRIBUTES
-
ATTRIBUTE_TYPES =
# File 'actiontext/lib/action_text/trix_attachment.rb', line 12{ "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 =
# File 'actiontext/lib/action_text/trix_attachment.rb', line 10%w( caption presentation )
-
SELECTOR =
# File 'actiontext/lib/action_text/trix_attachment.rb', line 8"[data-trix-attachment]"
-
TAG_NAME =
# File 'actiontext/lib/action_text/trix_attachment.rb', line 7"figure"
Class Method Summary
Instance Attribute Summary
- #node readonly
Instance Method Summary
Constructor Details
.new(node) ⇒ TrixAttachment
Class Method Details
.from_attributes(attributes)
[ GitHub ]# File 'actiontext/lib/action_text/trix_attachment.rb', line 21
def from_attributes(attributes) attributes = process_attributes(attributes) = attributes.except(*COMPOSED_ATTRIBUTES) trix_attributes = attributes.slice(*COMPOSED_ATTRIBUTES) node = ActionText::HtmlConversion.create_element(TAG_NAME) node["data-trix-attachment"] = JSON.generate( ) node["data-trix-attributes"] = JSON.generate(trix_attributes) if trix_attributes.any? new(node) end
Instance Attribute Details
#node (readonly)
[ GitHub ]# File 'actiontext/lib/action_text/trix_attachment.rb', line 51
attr_reader :node
Instance Method Details
#attributes
[ GitHub ]# File 'actiontext/lib/action_text/trix_attachment.rb', line 57
def attributes @attributes ||= .merge(composed_attributes).slice(*ATTRIBUTES) end
#to_html
[ GitHub ]# File 'actiontext/lib/action_text/trix_attachment.rb', line 61
def to_html ActionText::HtmlConversion.node_to_html(node) end
#to_s
[ GitHub ]# File 'actiontext/lib/action_text/trix_attachment.rb', line 65
def to_s to_html end