Skip to content

Fix #522: SVG round trips keep hidden objects and data-* attributes - #580

Merged
bflatastic merged 1 commit into
mainfrom
fix/issue-522
Oct 8, 2026
Merged

bflatastic merged 1 commit into
mainfrom
fix/issue-522

Conversation

@bflatastic

Copy link
Copy Markdown
Member

An SVG animation rig now survives a round trip: hidden alternates stay in the file as display="none", and their data-* attributes (pivots) are kept.

  • Hidden objects: SVG's hiddenLayers option now keeps hidden objects as well as hidden layers, each written hidden on its own element (display="none" on the path, image, text or group, in every styling mode). The PSD exporter's option of the same name already covered both. document.save / Save As sets it unless told otherwise, as before for layers, so an SVG Save As keeps hidden objects by default. Plain exports (Export As, document.export) still leave them out unless asked. The CLI's convert asks, since a conversion keeps the document.
  • data-* attributes: they are kept as the object's own data, in a new ObjectAttributes.data field (an ordered list of key/value pairs). It is empty in older files and saved by the native format. Our own data-name and data-vc-* attributes are left aside.
    • Import keeps them on the objects and layers their elements become, at most 64 per element.
    • Export writes them back.
    • object.setProps {data: {key: "value" | null}} sets or removes them. A data- prefix on the key is optional, and keys are checked.
  • Tests:
    • svg hidden_objects_and_data_attributes_round_trip uses the issue's rig plus a lone hidden path. A plain export leaves the hidden objects out. With hiddenLayers, in all three styling modes, they are written hidden, are not drawn by resvg, and reopen hidden with all their data-*.
    • engine object_data_is_set_saved_and_written_to_svg covers set, remove, undo in one step, rejected keys, SVG output and the native save/load.
  • Docs: docs/mcp.md (SVG options paragraph), the CLI convert help text, ROADMAP (SVG bullet and Last updated).

With the issue's rig-repro.svg, vectorcraft-cli convert rig-repro.svg out.svg now writes character, arm, arm-raised and eye-closed, the last two with display="none", and data-pivot on character, arm and arm-raised. Converting the output again only changes the title. Saving as .vectorcraft and converting back keeps everything.

Checks

  • Rebased on origin/main 207bd09.
  • cargo test -p vectorcraft-svg -p vectorcraft-doc -p vectorcraft-engine -p vectorcraft-format -p vectorcraft-cli -p vectorcraft-mcp -p vectorcraft-ui-egui, cargo clippy on svg/doc/engine/cli with --all-targets -- -D warnings, cargo fmt --all, cargo xtask wasm.

🤖 Generated with Claude Code

An SVG used as an animation rig lost its hidden alternates and their
rotation pivots: the exporter left hidden objects out (only hidden layers
could be kept), and the importer dropped data-* attributes.

- SVG export: hiddenLayers (on by default for document.save, as before)
  now keeps hidden objects too, each written display="none" on its own
  element (path, image, text or group). Exports still leave them out
  unless asked; the CLI's convert asks, as a conversion keeps the
  document.
- An object's own data: ObjectAttributes.data, the data-* attributes in
  order (ours, data-name and data-vc-*, aside). The importer keeps them on
  the objects and layers they belong to (at most 64 per element), the
  exporter writes them back, the native format saves them (missing in
  older files), and object.setProps {data: {key: value|null}} sets or
  removes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant