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:
@@ -45,6 +45,20 @@ final class NodeIndexTest extends TestCase
|
||||
self::assertSame(0, preg_match(NodeIndex::ID_PATTERN, "s1\n"));
|
||||
}
|
||||
|
||||
public function testParentBlockSkipsThePlaceholderAndSectionLabelWalksUp(): void
|
||||
{
|
||||
$index = NodeIndex::build((new Parser())->parse($this->fixture('synthetic-basic.html')));
|
||||
$button = $index->find('s0.r0.c1.m2');
|
||||
|
||||
self::assertTrue($index->root() instanceof \LIT\MCP\Integrations\Divi\BlockTree\Block
|
||||
&& $index->root()->isPlaceholder());
|
||||
self::assertSame($index->find('s0.r0.c1'), $index->parentBlock($button));
|
||||
self::assertNull($index->parentBlock($index->find('s0')), 'the placeholder is no parent node');
|
||||
self::assertSame('Hero', $index->sectionLabel($button));
|
||||
self::assertSame('Hero', $index->sectionLabel($index->find('s0')));
|
||||
self::assertSame('', $index->sectionLabel(null));
|
||||
}
|
||||
|
||||
public function testDocumentWithoutPlaceholderIsItsOwnRoot(): void
|
||||
{
|
||||
$document = (new Parser())->parse('<!-- wp:divi/section /-->');
|
||||
|
||||
Reference in New Issue
Block a user