PHP Version
8.4
Version
2.0.0
Bug Description
The DOMParser loses the state of task items when processing HTML. The HTML in the example below is the output of the TipTap editor. After parsing the HTML, the checked state of the items is lost.
<?php
require_once 'vendor/autoload.php';
use Tiptap\Core\DOMParser;
use Tiptap\Core\DOMSerializer;
use Tiptap\Nodes\TaskItem;
use Tiptap\Nodes\TaskList;
function test(?string $html): ?string
{
$schema = new \Tiptap\Core\Schema([
new Tiptap\Extensions\StarterKit,
new Tiptap\Marks\Link,
new TaskList,
new TaskItem,
]);
$document = new DOMParser($schema)->process($html);
$processedHtml = new DOMSerializer($schema)->process($document);
return $processedHtml;
}
// Test input HTML with checked tasks
$inputHtml = '<ul data-type="taskList"><li data-checked="true" data-type="taskItem"><label><input type="checkbox" checked="checked"><span></span></label><div><p>Task 1</p></div></li><li data-checked="false" data-type="taskItem"><label><input type="checkbox"><span></span></label><div><p>Task 2</p></div></li><li data-checked="false" data-type="taskItem"><label><input type="checkbox"><span></span></label><div><p>Task 3</p></div></li></ul><p></p>';
echo "Input HTML:\n";
echo $inputHtml . "\n\n";
echo "Output HTML:\n";
$output = test($inputHtml);
echo $output . "\n\n";
Expected Behavior
I would expect that the checked state is also present after the processing.
Additional Context (Optional)
No response
Dependency Updates
PHP Version
8.4
Version
2.0.0
Bug Description
The DOMParser loses the state of task items when processing HTML. The HTML in the example below is the output of the TipTap editor. After parsing the HTML, the checked state of the items is lost.
Expected Behavior
I would expect that the checked state is also present after the processing.
Additional Context (Optional)
No response
Dependency Updates