Skip to content

Commit

Permalink
Add ordered_list to TipTap::Document (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
visini authored Sep 19, 2024
1 parent 3b3b87f commit 03fc040
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/tip_tap/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def bullet_list(&block)
add_content(Nodes::BulletList.new(&block))
end

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

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

def image(src:)
add_content(Nodes::Image.new(src: src))
end
Expand Down
16 changes: 16 additions & 0 deletions spec/tip_tap/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@
end
end

describe "ordered_list" do
it "adds an ordered list node" do
document = TipTap::Document.new do |document|
document.ordered_list do |ol|
ol.list_item do |li|
li.paragraph do |para|
para.text("Hello World!")
end
end
end
end

expect(document.content.first).to be_a(TipTap::Nodes::OrderedList)
end
end

describe "blockquote" do
it "adds a blockquote node" do
document = TipTap::Document.new do |document|
Expand Down

0 comments on commit 03fc040

Please sign in to comment.