fix: lit/divi-presets-assign verweigert leeren Text als Preset (Eingabe und Gruppen); Stapelgrenze und Preset-Schema aus PresetAssignment

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 17:36:45 +02:00
co-authored by Claude Sonnet 5.5
parent 6b5de199f9
commit b805ed64dd
4 changed files with 69 additions and 39 deletions
@@ -8,6 +8,7 @@ use LIT\MCP\Abilities\Annotations;
use LIT\MCP\Abilities\Errors;
use LIT\MCP\Integrations\Divi\BlockTree\Block;
use LIT\MCP\Integrations\Divi\Compose\ColumnWidths;
use LIT\MCP\Integrations\Divi\Design\PresetAssignment;
use WP_Error;
defined('ABSPATH') || exit;
@@ -36,8 +37,8 @@ final class DiviUpdateAbility extends DiviWriteAbility
{
return 'Ändert vorhandene Divi-Knoten: changes = Liste von {id, set: {Kurzform-Felder}, attrs: {Attributpfad: '
. '{Breakpoint: Wert}}, preset, group_presets, clear_overrides, label}. null entfernt einen Wert. '
. 'preset = Name/ID oder Liste (Stapel, bis 10; bei gleicher Priorität gewinnt das letzte Preset im '
. 'Stapel); group_presets = {Gruppe: Preset}, z. B. {"font-body": "Fließtext"}. Überdecken lokale Werte '
. 'preset = Name/ID oder Liste (Stapel, bis ' . PresetAssignment::MAX_STACK . '; bei gleicher Priorität '
. 'gewinnt das letzte Preset im Stapel); group_presets = {Gruppe: Preset}, z. B. {"font-body": "Fließtext"}. Überdecken lokale Werte '
. 'ein Preset, meldet die Antwort das; clear_overrides: true entfernt sie (nach set/attrs). Nicht '
. 'genannte Einstellungen bleiben unverändert. Jeder Knoten nur einmal pro Aufruf; denselben Pfad nicht '
. 'zugleich über set und attrs. tree_rev aus lit-divi-outline ist Pflicht; alles oder nichts.';
@@ -61,16 +62,18 @@ final class DiviUpdateAbility extends DiviWriteAbility
'type' => 'object',
'description' => 'Vollform: Attributpfad → Breakpoint-Werte.',
],
'preset' => self::presetValue(
'Preset-Name oder -ID, Liste (Stapel, 1–10) oder null zum Entfernen. Bei gleicher '
. 'Priorität gewinnt das letzte Preset im Stapel.'
'preset' => PresetAssignment::valueSchema(
true,
'Preset-Name oder -ID, Liste (Stapel, 1–' . PresetAssignment::MAX_STACK
. ') oder null zum Entfernen. Bei gleicher Priorität gewinnt das letzte '
. 'Preset im Stapel.'
),
'group_presets' => [
'type' => 'object',
'description' => 'Gruppen-Presets: {Gruppe: Preset-Name | Liste | null}. Gruppe = '
. 'Kurzname (font-body), voller Name (divi/font-body) oder Attributpfad; null '
. 'entfernt den Eintrag der Gruppe.',
'additionalProperties' => self::presetValue(),
'additionalProperties' => PresetAssignment::valueSchema(true),
],
'clear_overrides' => [
'type' => 'boolean',
@@ -172,21 +175,4 @@ final class DiviUpdateAbility extends DiviWriteAbility
return $change;
}
/**
* Schema of one preset value: a name or id, a stack of 1–10 of them, or null.
*
* @return array<string, mixed>
*/
private static function presetValue(string $description = ''): array
{
$schema = [
'type' => ['string', 'array', 'null'],
'items' => ['type' => 'string'],
'minItems' => 1,
'maxItems' => 10,
];
return $description === '' ? $schema : $schema + ['description' => $description];
}
}