Class: TipTap::Nodes::Paragraph

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

Instance Attribute Summary

Attributes included from HtmlRenderable

#output_buffer

Attributes included from HasContent

#attrs, #content

Instance Method Summary collapse

Methods included from JsonRenderable

#include_empty_content_in_json?, #to_h

Methods included from HtmlRenderable

#html_class_name, #html_tag, included, #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

#text(text, marks: []) ⇒ Object



11
12
13
# File 'lib/tip_tap/nodes/paragraph.rb', line 11

def text(text, marks: [])
  add_content(Text.new(text, marks: marks))
end

#to_plain_text(separator: " ") ⇒ Object

Override the default to_plain_text method to account for the nested Text nodes we don’t want to use the separator when joining the text nodes since it could be a newline or some other character that we don’t want to include in the plain text



18
19
20
# File 'lib/tip_tap/nodes/paragraph.rb', line 18

def to_plain_text(separator: " ")
  content.map { |node| node.to_plain_text(separator: separator) }.join("")
end