DOMParser removing the some child nodes

const initialValue = '<p><span style="font-size:36px;"><span style="color:#00ff22;"><span style="background-color:#77b9c9;">hhkjhk hkjhkjh hjkhkj</span></span></span></p>'
DOMParser.fromSchema(schema).parse(document.createRange().createContextualFragment(initialValue))

I have tried to parse the below HTML string using the above code

<p>
     <span style="font-size:36px;">
         <span style="background-color:#77b9c9;">
            <span style="color:#00ff22;">world !!!</span>
        </span>
    </span>
</p>

but I got

<p>
      <span style="color:#00ff22;">world !!!</span>
   </p>

The issue is some of the span tags were removed even if it has style tag in it

how do achieve the exact HTML without losing some span tags? please help me with the necessary schema

1 Like

That’s not what this library was built for. It represents the document using a precise schema, it’s not an arbitrary-HTML editor.

can you please provide the respective schema? to have all the styles of the parent ‘span’ tag need to applied to the child ‘span’

Hi @Abishek ,the following schema should help with this issue,

{
  content: 'inline*',
  group: 'inline',
  inline: true,
}