-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing html with nested lists causes invalid doc structure #36
Comments
I'm seeing this issue as well.
Note how |
Similarly to @Coding-Kiwi, I've also noticed this issue while trying to migrate from HTML to JSON TipTap doc. |
@timoisik if you can take a look at this issue when you have time, it would be great. |
I have the same issue with the $string = "<p>An example</p><ul><li><p>list item a</p><ul><li><p>list item b</p></li></ul></li></ul>";
$sanitizedHtml = (new Tiptap\Editor)->sanitize($string);
// output: <p>An example</p><ul><li><p><p>list item a</p><ul><li><p>list item b</p></li></ul></p></li></ul> |
The workaround from @Coding-Kiwi in #2 (comment) solves the issue for me at this moment: class TipTapListItem extends \Tiptap\Nodes\ListItem
{
public static function wrapper($DOMNode)
{
return null;
}
}
$string = "<p>An example</p><ul><li><p>list item a</p><ul><li><p>list item b</p></li></ul></li></ul>";
$sanitizedHtml = (new Tiptap\Editor([
'extensions' => [
new Tiptap\Extensions\StarterKit([
'listItem' => false,
]),
new TipTapListItem(),
],
]))->sanitize($string) |
See my comment #2 (comment)
If a
<li>
tag contains a<p>
and a sublist<ul>
, the ListItem Node wraps the content with an additional<p>
tag.The resulting json doc can be loaded into tiptap but as soon as you edit a list item, an
Invalid content for node paragraph
is thrown because there is now a<p>
tag containing a<p>
and<ul>
tag which is not valid, because a<p>
tag can only contain phrasing content.The text was updated successfully, but these errors were encountered: