Methods
- caption
- fragment_by_canonicalizing_attachments
- from_attachable
- from_attachables
- from_attributes
- from_node
- full_attributes
- inspect
- new
- to_html
- to_plain_text
- to_s
- with_full_attributes
Constants
ATTRIBUTES | = | %w( sgid content-type url href filename filesize width height previewable presentation caption ) |
SELECTOR | = | TAG_NAME |
TAG_NAME | = | "action-text-attachment" |
Attributes
[R] | attachable | |
[R] | node |
Class Public methods
fragment_by_canonicalizing_attachments(content)
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 14
def fragment_by_canonicalizing_attachments(content)
fragment_by_minifying_attachments(fragment_by_converting_trix_attachments(content))
end
🔎 See on GitHub
from_attachable(attachable, attributes = {})
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 26
def from_attachable(attachable, attributes = {})
if node = node_from_attributes(attachable.to_rich_text_attributes(attributes))
new(node, attachable)
end
end
🔎 See on GitHub
from_attachables(attachables)
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 22
def from_attachables(attachables)
Array(attachables).map { |attachable| from_attachable(attachable) }.compact
end
🔎 See on GitHub
from_attributes(attributes, attachable = nil)
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 32
def from_attributes(attributes, attachable = nil)
if node = node_from_attributes(attributes)
from_node(node, attachable)
end
end
🔎 See on GitHub
from_node(node, attachable = nil)
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 18
def from_node(node, attachable = nil)
new(node, attachable || ActionText::Attachable.from_node(node))
end
🔎 See on GitHub
new(node, attachable)
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 55
def initialize(node, attachable)
@node = node
@attachable = attachable
end
🔎 See on GitHub
Instance Public methods
caption()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 60
def caption
node_attributes["caption"].presence
end
🔎 See on GitHub
full_attributes()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 64
def full_attributes
node_attributes.merge(attachable_attributes).merge(sgid_attributes)
end
🔎 See on GitHub
inspect()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 88
def inspect
"#<#{self.class.name} attachable=#{attachable.inspect}>"
end
🔎 See on GitHub
to_html()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 80
def to_html
HtmlConversion.node_to_html(node)
end
🔎 See on GitHub
to_plain_text()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 72
def to_plain_text
if respond_to?(:attachable_plain_text_representation)
attachable_plain_text_representation(caption)
else
caption.to_s
end
end
🔎 See on GitHub
to_s()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 84
def to_s
to_html
end
🔎 See on GitHub
with_full_attributes()
📝 Source code
# File actiontext/lib/action_text/attachment.rb, line 68
def with_full_attributes
self.class.from_attributes(full_attributes, attachable)
end
🔎 See on GitHub