"
in type: 'orderedList', content:
"#{children(content, substitutions, level + 1)}"
in type: 'listItem', content:
"
#{children(content, substitutions, level + 1)}
"
in type: 'text', text:, **rest
if rest[:marks].present?
apply_marks(text, rest[:marks])
else
text
end
in type: 'mention', attrs: { id: }, **rest
text = substitutions.fetch(id) { "--#{id}--" }
if rest[:marks].present?
apply_marks(text, rest[:marks])
else
text
end
in { type: type } if ["paragraph", "title", "heading"].include?(type) && !node.key?(:content)
# noop
end
end
def text_align(attrs)
if attrs.present? && attrs[:textAlign].present?
" style=\"text-align: #{attrs[:textAlign]}\""
else
""
end
end
def apply_marks(text, marks)
marks.reduce(text) do |text, mark|
case mark
in type: 'bold'
"#{text}"
in type: 'italic'
"#{text}"
in type: 'underline'
"#{text}"
in type: 'strike'
"#{text}"
in type: 'highlight'
"#{text}"
end
end
end
end