From b5cd7ed32f5d402d95ef7cf6ba21b28955ecd5df Mon Sep 17 00:00:00 2001 From: Chad Wilken Date: Wed, 1 Nov 2023 10:51:10 -0500 Subject: [PATCH 1/2] Allow customizing the separator when rendering to plain text --- lib/tip_tap/plain_text_renderable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tip_tap/plain_text_renderable.rb b/lib/tip_tap/plain_text_renderable.rb index 08d4359..12b038d 100644 --- a/lib/tip_tap/plain_text_renderable.rb +++ b/lib/tip_tap/plain_text_renderable.rb @@ -3,8 +3,8 @@ module TipTap module PlainTextRenderable # Useful for searching - def to_plain_text - content.map(&:to_plain_text).join(" ") + def to_plain_text(separator: " ") + content.map(&:to_plain_text).join(separator) end end end From fbffad5c9c6f4da83612139f8db3ba08377b3d25 Mon Sep 17 00:00:00 2001 From: Chad Wilken Date: Wed, 1 Nov 2023 10:54:05 -0500 Subject: [PATCH 2/2] Pass separator to all invocations of to_plain_text --- lib/tip_tap/nodes/text.rb | 2 +- lib/tip_tap/plain_text_renderable.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tip_tap/nodes/text.rb b/lib/tip_tap/nodes/text.rb index e55635b..b184b97 100644 --- a/lib/tip_tap/nodes/text.rb +++ b/lib/tip_tap/nodes/text.rb @@ -37,7 +37,7 @@ def to_html value end - def to_plain_text + def to_plain_text(separator: " ") text end diff --git a/lib/tip_tap/plain_text_renderable.rb b/lib/tip_tap/plain_text_renderable.rb index 12b038d..f7262c7 100644 --- a/lib/tip_tap/plain_text_renderable.rb +++ b/lib/tip_tap/plain_text_renderable.rb @@ -4,7 +4,7 @@ module TipTap module PlainTextRenderable # Useful for searching def to_plain_text(separator: " ") - content.map(&:to_plain_text).join(separator) + content.map { |node| node.to_plain_text(separator: separator) }.join(separator) end end end