fix(attestation): don't render block levels presentation elements into a p
This commit is contained in:
parent
c9956c4881
commit
4db4cf1513
5 changed files with 26 additions and 7 deletions
|
@ -96,11 +96,11 @@ class TiptapService
|
|||
text
|
||||
end
|
||||
in type: 'mention', attrs: { id: }, **rest
|
||||
text_or_representation = substitutions.fetch(id) { "--#{id}--" }
|
||||
text = if text_or_representation.respond_to?(:to_tiptap_node)
|
||||
node_to_html(text_or_representation.to_tiptap_node, substitutions, level + 1)
|
||||
text_or_presentation = substitutions.fetch(id) { "--#{id}--" }
|
||||
text = if text_or_presentation.respond_to?(:to_tiptap_node)
|
||||
handle_presentation_node(text_or_presentation, substitutions, level + 1)
|
||||
else
|
||||
text_or_representation
|
||||
text_or_presentation
|
||||
end
|
||||
|
||||
if rest[:marks].present?
|
||||
|
@ -113,6 +113,16 @@ class TiptapService
|
|||
end
|
||||
end
|
||||
|
||||
def handle_presentation_node(presentation, substitutions, level)
|
||||
node = presentation.to_tiptap_node
|
||||
content = node_to_html(node, substitutions, level)
|
||||
if presentation.block_level?
|
||||
"</p>#{content}<p>"
|
||||
else
|
||||
content
|
||||
end
|
||||
end
|
||||
|
||||
def text_align(attrs)
|
||||
if attrs.present? && attrs[:textAlign].present?
|
||||
" style=\"text-align: #{attrs[:textAlign]}\""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue