mirror of
https://github.com/penpot/penpot.git
synced 2026-05-01 06:08:09 +00:00
Steps to reproduce: paste an SVG authored in Inkscape (or any editor that follows the inkscape:label convention) into a penpot file. The group/element names visible in the source editor are dropped — penpot shows generic auto-ids like 'g1234' or 'path5678' instead. Root cause: parse-svg-element in common/src/app/common/files/shapes_ builder.cljc derived the shape name from (or (:id attrs) (tag->name tag)). Inkscape stores user-given element labels in the inkscape:label and sodipodi:label namespaced attributes while id holds an auto- generated technical id, so the operator's chosen name was always overridden by the technical id when present. tubax/xml->clj (the SVG parser the import pipeline already uses for upload, paste, and library import) keeps namespaced attributes as :prefix:name keywords — the same shape this file already reads :xlink:href from on line 134, and that app.common.svg uses for the xlink: namespace at lines 300-307. Fix: extract the name-resolution logic into a public resolve-element- name helper that prefers :inkscape:label, then :sodipodi:label, then :id, then (tag->name tag). Existing SVGs that don't carry either label namespace fall through the same chain as before, so the behaviour for non-Inkscape-authored SVGs is unchanged. This restores the behaviour dfelinto's penpot-icon-generator-plugin relies on (linked from the issue body) — that plugin reads element names from the imported SVG to map Blender icons to penpot components. Tests: 6 deftest blocks in common/test/common_tests/files/shapes_ builder_test.cljc covering the priority order (inkscape > sodipodi > id > tag), each fallback in isolation, and the empty-attrs case. Registered in common-tests.runner. Closes #7869 Co-authored-by: Andrey Antukh <niwi@niwi.nz>