feat: Warnung, wenn lokale Werte ein zugewiesenes Preset überdecken
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
be6ca5bee0
commit
1f9b50f1a6
@@ -9,6 +9,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystem;
|
||||
use LIT\MCP\Integrations\Divi\Design\PresetAssignment;
|
||||
use LIT\MCP\Integrations\Divi\Schema\ShortformMap;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
@@ -16,8 +17,9 @@ defined('ABSPATH') || exit;
|
||||
/**
|
||||
* Quality warnings of a Divi write (spec §5.5) – only about the nodes this call created or
|
||||
* changed (and their children): fixed colors/fonts where a global one fits, images without
|
||||
* alt text, empty modules, heading jumps, the code module. Similar existing sections
|
||||
* (lit/library-find-similar) follow with the Library in Etappe 3. Pure PHP.
|
||||
* alt text, empty modules, heading jumps, the code module, local values that cover an assigned
|
||||
* preset (ruling R5). Similar existing sections (lit/library-find-similar) follow with the Library
|
||||
* in Etappe 3. Pure PHP.
|
||||
*/
|
||||
final class Warnings
|
||||
{
|
||||
@@ -33,7 +35,7 @@ final class Warnings
|
||||
'divi/slide' => ['image.innerContent', 'src', 'alt'],
|
||||
];
|
||||
|
||||
public function __construct(private DesignSystem $design)
|
||||
public function __construct(private DesignSystem $design, private ?PresetAssignment $presets = null)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,7 +60,8 @@ final class Warnings
|
||||
...$this->code($block, $id),
|
||||
...$this->image($block, $id),
|
||||
...$this->empty($block, $id),
|
||||
...$this->fixedValues($block, $id)
|
||||
...$this->fixedValues($block, $id),
|
||||
...$this->coveredPresets($block, $id)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,6 +164,27 @@ final class Warnings
|
||||
return $warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruling R5: local values that cover an explicitly assigned preset of the block. Only Divi blocks that name a
|
||||
* preset cost work (opaque blocks – global instances – are never looked into); the preset book is read when the
|
||||
* first such block comes up, never for a page without presets.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
private function coveredPresets(Block $block, string $id): array
|
||||
{
|
||||
if ($this->presets === null || ! $block->isDivi() || $block->isOpaque() || ! self::namesPresets($block)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->presets->overrides()->describe($id, $block->attrs(), $this->presets->names());
|
||||
}
|
||||
|
||||
private static function namesPresets(Block $block): bool
|
||||
{
|
||||
return NodeSummary::presetIds($block) !== [] || NodeSummary::groupPresets($block) !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Heading jumps (h2 → h4) in page order where the later heading belongs to a touched block.
|
||||
*
|
||||
|
||||
@@ -160,6 +160,6 @@ class DiviComposition
|
||||
|
||||
public function warnings(): Warnings
|
||||
{
|
||||
return new Warnings($this->design->read());
|
||||
return new Warnings($this->design->read(), $this->presets());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user