Class: TipTap::Nodes::Image
Instance Attribute Summary
#output_buffer
Attributes included from HasContent
#attrs, #content
Instance Method Summary
collapse
#to_plain_text
#to_h
#html_attributes, #html_class_name, #html_tag, included, #inline_styles
Methods included from HasContent
#add_content, #blank?, #each, #find_node, included, #initialize, #size
included, #type_name
Instance Method Details
#alt ⇒ Object
27
28
29
|
# File 'lib/tip_tap/nodes/image.rb', line 27
def alt
attrs["alt"]
end
|
#include_empty_content_in_json? ⇒ Boolean
10
11
12
|
# File 'lib/tip_tap/nodes/image.rb', line 10
def include_empty_content_in_json?
false
end
|
#src ⇒ Object
31
32
33
|
# File 'lib/tip_tap/nodes/image.rb', line 31
def src
attrs["src"]
end
|
#to_html ⇒ Object
14
15
16
|
# File 'lib/tip_tap/nodes/image.rb', line 14
def to_html
image_tag(src, alt: alt)
end
|
#to_markdown(context = Markdown::Context.root) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/tip_tap/nodes/image.rb', line 18
def to_markdown(context = Markdown::Context.root)
return "" if src.blank?
alt_text = alt.to_s
escaped_alt = alt_text.gsub("[", "\\[").gsub("]", "\\]")
escaped_src = src.to_s.gsub("(", "\\(").gsub(")", "\\)")
""
end
|