Merge pull request #821 from SuanmoSuanyangTechnology/feature/ui_upgrade_zy

fix(web): editor third variable init
This commit is contained in:
yingzhao
2026-04-08 14:22:54 +08:00
committed by GitHub

View File

@@ -100,15 +100,29 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
}
if (match) {
const [_, nodeId, label] = match;
const [_, nodeId, rest] = match;
const restParts = rest.split('.');
const isThreeLevel = restParts.length >= 2;
const parentLabel = isThreeLevel ? restParts.slice(0, -1).join('.') : undefined;
const label = restParts[restParts.length - 1];
const suggestion = optionsRef.current.find(s => {
let suggestion = optionsRef.current.find(s => {
if (nodeId === 'sys') {
return s.nodeData.type === 'start' && s.label === `sys.${label}`
return s.nodeData.type === 'start' && s.label === `sys.${rest}`
}
return s.nodeData.id === nodeId && s.label === label
return s.nodeData.id === nodeId && s.label === rest
});
// Search in children for three-level variables (e.g. nodeId.parentLabel.label)
if (!suggestion && isThreeLevel) {
for (const s of optionsRef.current) {
if (s.nodeData.id === nodeId && s.label === parentLabel && s.children) {
const child = s.children.find(c => c.label === label);
if (child) { suggestion = child; break; }
}
}
}
if (suggestion) {
paragraph.append($createVariableNode(suggestion));
} else {