Always wrap SVG symbols in <g> so all get Ignition metadata

Single-element SVGs (like FIO paths) were exported as bare <path>
without tagpaths/color/state/priority. Now all symbols are wrapped
in a <g> group with the Ignition data attributes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-04-01 19:14:25 +04:00
parent d84ff495b5
commit 1cd4c9dc44

View File

@ -322,20 +322,8 @@ async function buildSvgString(): Promise<string> {
lines.push(` <g ${idAttr} transform="${fullTransform}">`);
lines.push(` ${innerContent}`);
lines.push(' </g>');
} else if (children.length === 1) {
// Single element, no group — put id/label/transform directly on it
const el = children[0].cloneNode(true) as Element;
const elTransform = el.getAttribute('transform');
el.setAttribute('transform', elTransform ? `${baseTransform} ${elTransform}` : baseTransform);
el.setAttribute('id', label);
let s = new XMLSerializer().serializeToString(el)
.replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"/g, '');
// Inject inkscape:label after the tag name
const firstSpace = s.indexOf(' ');
s = s.slice(0, firstSpace) + ` inkscape:label="${label}"` + s.slice(firstSpace);
lines.push(` ${s}`);
} else {
// Multiple children without a group — wrap in <g> with id/label
// Always wrap in <g> so every symbol gets Ignition metadata (tagpaths, color, state, priority)
const innerContent = serializeChildren(svgEl);
lines.push(` <g ${idAttr} transform="${baseTransform}">`);
lines.push(` ${innerContent}`);