Class: TipTap::Nodes::TableCell

Inherits:
TipTap::Node show all
Defined in:
lib/tip_tap/nodes/table_cell.rb

Direct Known Subclasses

TableHeader

Instance Attribute Summary

Attributes included from HtmlRenderable

#output_buffer

Attributes included from HasContent

#attrs, #content

Instance Method Summary collapse

Methods included from PlainTextRenderable

#to_plain_text

Methods included from JsonRenderable

#include_empty_content_in_json?, #to_h

Methods included from HtmlRenderable

#html_attributes, #html_class_name, #html_tag, included, #inline_styles, #to_html

Methods included from HasContent

#add_content, #blank?, #each, #find_node, included, #initialize, #size

Methods included from Registerable

included, #type_name

Instance Method Details

#paragraph(&block) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/tip_tap/nodes/table_cell.rb', line 11

def paragraph(&block)
  raise ArgumentError, "Block required" if block.nil?

  add_content(Paragraph.new(&block))
end

#to_markdown(context = Markdown::Context.root) ⇒ Object



17
18
19
20
21
# File 'lib/tip_tap/nodes/table_cell.rb', line 17

def to_markdown(context = Markdown::Context.root)
  values = content.map { |node| node.to_markdown(context) }.reject(&:blank?)
  joined = values.join("<br>")
  joined.gsub("\n\n", "<br><br>").gsub("\n", "<br>")
end