I’m adding a class attribute to the paragraph node using addGlobalAttributes
, but when no class has been set the data is still output with a null
class value:
[
{
"type": "paragraph",
"attrs": {
"class": null
},
"content": [
{
"type": "text",
"text": "Test"
}
]
}
]
Is there a way to prevent that, and just have nothing saved if no value is set?
I did find that setting the default to undefined
kind of works, but you still end up with an empty attrs
object even when there are no other attributes:
[
{
"type": "paragraph",
"attrs": {},
"content": [
{
"type": "text",
"text": "Test"
}
]
}
]
Ideally I’d like it to look like this if no class or any other attributes are set:
[
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Test"
}
]
}
]