fix: Task 7 review round 1 - copy the raw admin label verbatim on duplicate
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,6 @@ namespace LIT\MCP\Integrations\Divi\Pages;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\AttrMap;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
@@ -86,10 +85,16 @@ final class DiviDuplicateNodeAbility implements Ability
|
||||
|
||||
$copy = $this->writer->composition($page)->editor()->duplicate($page->index, $node);
|
||||
if ($copy->isDivi() && ! $copy->isOpaque()) {
|
||||
$label = NodeSummary::label($node);
|
||||
$copy->setAttrs(AttrMap::set($copy->attrs(), 'module.meta.adminLabel', [
|
||||
'desktop' => ['value' => ($label === '' ? $node->shortName() : $label) . ' (Kopie)'],
|
||||
]));
|
||||
// The raw stored desktop value (never NodeSummary::label()'s display-shortened
|
||||
// text): a long or multi-line label must be copied verbatim, only " (Kopie)" added.
|
||||
// Setting only the ".desktop.value" leaf keeps every other breakpoint untouched.
|
||||
$raw = AttrMap::desktop($node->attrs(), 'module.meta.adminLabel');
|
||||
$label = is_string($raw) ? $raw : '';
|
||||
$copy->setAttrs(AttrMap::set(
|
||||
$copy->attrs(),
|
||||
'module.meta.adminLabel.desktop.value',
|
||||
($label === '' ? $node->shortName() : $label) . ' (Kopie)'
|
||||
));
|
||||
}
|
||||
|
||||
$change = (new DiviChange(sprintf('Knoten %s dupliziert', $id)))->changed($copy, 'duplicated');
|
||||
|
||||
Reference in New Issue
Block a user