tiptap-php icon indicating copy to clipboard operation
tiptap-php copied to clipboard

Don't fail on missing code tag in code block parsing

Open dbohn opened this issue 1 year ago • 0 comments

When parsing an HTML input using this library, that contains a <pre>-tag without any child element like the code tag generated by TipTap itself, the parser will generate an error, as it tries to call the getAttribute method on a child node, that is of type DOMText (or even null, if the block is empty). The error occurs, while infering the language of the code block.

This might not happen, if using the tip tap editor, but it breaks the use case of the sanitize method, as it would fail and not sanitize in this case.

This PR adds a check for the type of the respective child node.

dbohn avatar Aug 11 '22 07:08 dbohn