feat: global instance in the builder's format, deglobalize, library content rules

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 00:53:38 +02:00
co-authored by Claude Opus 5.5
parent ce1ad7c6c3
commit 2700fd615a
11 changed files with 587 additions and 4 deletions
+5 -3
View File
@@ -7,6 +7,7 @@ namespace LIT\MCP\Integrations\Divi\Compose;
use LIT\MCP\Integrations\Divi\BlockTree\Block;
use LIT\MCP\Integrations\Divi\BlockTree\Container;
use LIT\MCP\Integrations\Divi\BlockTree\Document;
use LIT\MCP\Integrations\Divi\BlockTree\GlobalInstance;
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
defined('ABSPATH') || exit;
@@ -14,7 +15,8 @@ defined('ABSPATH') || exit;
/**
* Structural changes on a parsed page (spec §5.7): where to insert (parent / before / after,
* optional index), move, remove, duplicate – always checked against StructureRules. Works on
* the tree only; saving is DiviWriter's job. Pure PHP.
* the tree only; saving is DiviWriter's job. Global instances count as their root type
* (blockName, GlobalInstance::effectiveName()). Pure PHP.
*/
final class TreeEditor
{
@@ -79,7 +81,7 @@ final class TreeEditor
public function insert(array $position, array $blocks): ?string
{
foreach ($blocks as $block) {
$violation = $this->rules->violation($position['parent'], $block->name());
$violation = $this->rules->violation($position['parent'], GlobalInstance::effectiveName($block));
if ($violation !== null) {
return $violation;
}
@@ -104,7 +106,7 @@ final class TreeEditor
}
}
$violation = $this->rules->violation($position['parent'], $node->name());
$violation = $this->rules->violation($position['parent'], GlobalInstance::effectiveName($node));
if ($violation !== null) {
return $violation;
}