refactor: small Divi tree helpers out of DiviWriter (M3)
Block::isPlaceholder replaces the divi/placeholder literals (ledger T4); NodeIndex::parentBlock/sectionLabel replace the two parentBlock copies and DiviWriter::sectionLabel; DiviChange::idOf and Outline::summary replace the duplicated id resolution and outline text; DiviSchema holds the shared input properties. Behaviour unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -65,7 +65,7 @@ final class TreeEditor
|
||||
|
||||
return [
|
||||
'container' => $container,
|
||||
'parent' => $container instanceof Block && $container->name() !== 'divi/placeholder' ? $container : null,
|
||||
'parent' => $container instanceof Block && ! $container->isPlaceholder() ? $container : null,
|
||||
'index' => $key === 'before' ? $sibling : $sibling + 1,
|
||||
];
|
||||
}
|
||||
@@ -96,7 +96,7 @@ final class TreeEditor
|
||||
/** @param array{container: Container, parent: ?Block, index: int} $position */
|
||||
public function move(NodeIndex $index, Block $node, array $position): ?string
|
||||
{
|
||||
for ($ancestor = $position['parent']; $ancestor !== null; $ancestor = $this->parentBlock($index, $ancestor)) {
|
||||
for ($ancestor = $position['parent']; $ancestor !== null; $ancestor = $index->parentBlock($ancestor)) {
|
||||
if ($ancestor === $node) {
|
||||
return 'ein Knoten kann nicht in sich selbst verschoben werden';
|
||||
}
|
||||
@@ -139,13 +139,6 @@ final class TreeEditor
|
||||
return $copy;
|
||||
}
|
||||
|
||||
private function parentBlock(NodeIndex $index, Block $block): ?Block
|
||||
{
|
||||
$parent = $index->parentOf($block);
|
||||
|
||||
return $parent instanceof Block && $parent->name() !== 'divi/placeholder' ? $parent : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruling S9: inserting at the document root of an empty page (no divi/placeholder yet)
|
||||
* first wraps it in one, the same way DiviContentComposer (Task 9) writes new content –
|
||||
|
||||
Reference in New Issue
Block a user