fix(tiptap): don't fail on node without content
This commit is contained in:
parent
17a471e880
commit
45071b7bb6
2 changed files with 13 additions and 0 deletions
|
@ -44,6 +44,8 @@ class TiptapService
|
|||
else
|
||||
tags[id]
|
||||
end
|
||||
in { type: type } if ["paragraph", "title", "heading"].include?(type) && !node.key?(:content)
|
||||
# noop
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ RSpec.describe TiptapService do
|
|||
type: 'title',
|
||||
content: [{ type: 'text', text: 'Title' }]
|
||||
},
|
||||
{
|
||||
type: 'title' # remained empty in editor
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
attrs: { textAlign: 'right' },
|
||||
|
@ -31,6 +34,10 @@ RSpec.describe TiptapService do
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'paragraph'
|
||||
# no content, empty line
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
content: [
|
||||
|
@ -70,6 +77,10 @@ RSpec.describe TiptapService do
|
|||
attrs: { level: 3 },
|
||||
content: [{ type: 'text', text: 'Heading 3' }]
|
||||
},
|
||||
{
|
||||
type: 'heading',
|
||||
attrs: { level: 3 } # remained empty in editor
|
||||
},
|
||||
{
|
||||
type: 'bulletList',
|
||||
content: [
|
||||
|
|
Loading…
Reference in a new issue