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:
2026-09-26 18:24:29 +02:00
co-authored by Claude Opus 5.5
parent ecfece719d
commit d2cc82f31b
18 changed files with 188 additions and 86 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace LIT\MCP\Integrations\Divi\Pages;
use LIT\MCP\Integrations\Divi\BlockTree\Block;
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
/**
@@ -74,6 +75,17 @@ final class DiviChange
return $this->changed;
}
/**
* Path ID of an entry in the tree after the change: a removed node keeps its ID from before
* the removal; a surviving node is looked up in $index (null if it is not there).
*
* @param array{block: ?Block, id: ?string, type: string, action: string, label: string} $entry
*/
public static function idOf(array $entry, NodeIndex $index): ?string
{
return $entry['id'] ?? ($entry['block'] !== null ? $index->idOf($entry['block']) : null);
}
/** @return list<Block> */
public function touched(): array
{