From 583b70d13dfdc05ffc0907629074ef69e111af80 Mon Sep 17 00:00:00 2001 From: Edward Barton Date: Wed, 15 May 2024 10:59:32 -0700 Subject: [PATCH 1/2] Feat: add blank? method --- lib/tip_tap/has_content.rb | 4 ++++ lib/tip_tap/version.rb | 2 +- spec/tip_tap/document_spec.rb | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/tip_tap/has_content.rb b/lib/tip_tap/has_content.rb index 48e45fd..0ad51fb 100644 --- a/lib/tip_tap/has_content.rb +++ b/lib/tip_tap/has_content.rb @@ -40,6 +40,10 @@ def size content.size end + def blank? + content&.all?(&:blank?) + end + module ClassMethods # Create a new instance from a TipTap JSON object. # All nodes are recursively parsed and converted to Ruby objects diff --git a/lib/tip_tap/version.rb b/lib/tip_tap/version.rb index f1b0900..e8a0c4a 100644 --- a/lib/tip_tap/version.rb +++ b/lib/tip_tap/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module TipTap - VERSION = "0.9.0" + VERSION = "0.9.1" end diff --git a/spec/tip_tap/document_spec.rb b/spec/tip_tap/document_spec.rb index 0329625..a79f429 100644 --- a/spec/tip_tap/document_spec.rb +++ b/spec/tip_tap/document_spec.rb @@ -244,4 +244,22 @@ expect(document.content.first).to be_a(TipTap::Nodes::Codeblock) end end + + describe "blank?" do + context "when the document is NOT blank" do + it "returns false" do + document = TipTap::Document.new do |document| + document.paragraph { |p| p.text("Hello World!") } + end + expect(document.blank?).to eq(false) + end + end + + context "when the document is blank" do + it "returns true" do + document = TipTap::Document.new.tap(&:paragraph) + expect(document.blank?).to eq(true) + end + end + end end From 4a38382893e204fd403734b01377dfeffba1a5f2 Mon Sep 17 00:00:00 2001 From: Edward Barton Date: Wed, 15 May 2024 11:03:59 -0700 Subject: [PATCH 2/2] Chore: update version --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 262bc67..fffbce8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tiptap-ruby (0.9.0) + tiptap-ruby (0.9.1) actionview (>= 6.0) activesupport (>= 6.0)