Class: TipTap::Document

Inherits:
Node
  • Object
show all
Defined in:
lib/tip_tap/document.rb

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_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

#blockquote(&block) ⇒ Object

Raises:

  • (ArgumentError)


45
46
47
48
49
# File 'lib/tip_tap/document.rb', line 45

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

  add_content(Nodes::Blockquote.new(&block))
end

#bullet_list(&block) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
# File 'lib/tip_tap/document.rb', line 29

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

  add_content(Nodes::BulletList.new(&block))
end

#codeblock(&block) ⇒ Object

Raises:

  • (ArgumentError)


51
52
53
54
55
# File 'lib/tip_tap/document.rb', line 51

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

  add_content(Nodes::Codeblock.new(&block))
end

#heading(level: 1, &block) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/tip_tap/document.rb', line 13

def heading(level: 1, &block)
  raise ArgumentError, "Block required" if block.nil?

  add_content(Nodes::Heading.new(level: level, &block))
end

#image(src:) ⇒ Object



41
42
43
# File 'lib/tip_tap/document.rb', line 41

def image(src:)
  add_content(Nodes::Image.new(src: src))
end

#ordered_list(&block) ⇒ Object

Raises:

  • (ArgumentError)


35
36
37
38
39
# File 'lib/tip_tap/document.rb', line 35

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

  add_content(Nodes::OrderedList.new(&block))
end

#paragraph(&block) ⇒ Object



19
20
21
# File 'lib/tip_tap/document.rb', line 19

def paragraph(&block)
  add_content(Nodes::Paragraph.new(&block))
end

#table(&block) ⇒ Object

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/tip_tap/document.rb', line 57

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

  add_content(Nodes::Table.new(&block))
end

#task_list(&block) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
# File 'lib/tip_tap/document.rb', line 23

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

  add_content(Nodes::TaskList.new(&block))
end