Hey there,
I am running into issues with the HTML DOM representation of nested marks. I’d like to be able to nest a link
inside an em
, and the other way around.
It works for link
inside em
:
(The [em]
and [a]
is some CSS trickery with ::before
and ::after
for debugging purposes).
The document JSON looks like this, as expected:
JSON #1
{
"type": "text",
"marks": [
{ "type": "em" }
],
"text": "the "
},
{
"type": "text",
"marks": [
{ "type": "em" },
{ "type": "link", "attrs": { "href": "example.com" } }
],
"text": "example"
},
{
"type": "text",
"marks": [
{ "type": "em" }
],
"text": " site"
}
But the other way around does not work as intended:
I would rather not have the link be broken up; I’d like the link to extend over the entire span.
I can swap the order of link
and em
in the ordered marks map, but then the first example will break, and the second example (this one right here) will succeed.
The DOM is correct either way:
JSON #2
{
"type": "text",
"marks": [
{ "type": "link", "attrs": { "href": "example.com" } }
],
"text": "an "
},
{
"type": "text",
"marks": [
{ "type": "em" },
{ "type": "link", "attrs": { "href": "example.com" } }
],
"text": "amazing"
},
{
"type": "text",
"marks": [
{ "type": "link", "attrs": { "href": "example.com" } }
],
"text": " find"
}
How can I solve this problem?