Skip to content

FE-504: Add copy/paste and select all to petrinaut editor#8533

Draft
kube wants to merge 2 commits intocf/fe-512-create-filterablelistsubview-componentfrom
cf/petrinaut-copy-paste
Draft

FE-504: Add copy/paste and select all to petrinaut editor#8533
kube wants to merge 2 commits intocf/fe-512-create-filterablelistsubview-componentfrom
cf/petrinaut-copy-paste

Conversation

@kube
Copy link
Collaborator

@kube kube commented Mar 12, 2026

🌟 What is the purpose of this PR?

Add clipboard support and selection shortcuts to the petrinaut editor, enabling users to copy, paste, and select all items in the SDCPN canvas.

🔗 Related links

🔍 What does this change?

  • Copy (Cmd/Ctrl+C): Serializes selected items (places, transitions, token types, differential equations, parameters) to clipboard as a versioned JSON format (petrinaut-sdcpn v1). Arcs between selected nodes are preserved within their transitions; arcs to unselected nodes are stripped.
  • Paste (Cmd/Ctrl+V): Deserializes clipboard data, generates new UUIDs for all items, deduplicates names with numeric suffixes, remaps internal references (arc→place, place→colorId/differentialEquationId, equation→colorId), and offsets pasted nodes by 50px. Newly pasted items are automatically selected.
  • Select All (Cmd/Ctrl+A): Selects all canvas nodes (places and transitions).
  • Escape to deselect: Clears selection in addition to switching to cursor mode.
  • Clipboard format: Versioned payload validated with zod, includes source document ID for future cross-document reconciliation.
  • zod added as a dependency for clipboard payload validation.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🐾 Next steps

  • Cross-document paste with dependency reconciliation (copy from one document, paste into another — may need to bring referenced types/equations along)
  • Cut (Cmd/Ctrl+X) support

🛡 What tests cover this?

  • 77 unit tests across 3 test files:
    • deduplicate-name.test.ts — name suffix logic (12 tests)
    • serialize.test.ts — serialization, arc stripping, payload parsing with zod validation (32 tests)
    • paste.test.ts — ID generation, name deduplication, position offset, arc remapping, reference remapping, data preservation (33 tests)

❓ How to test this?

  1. Checkout the branch
  2. Open the petrinaut editor with a net containing places, transitions, types, equations, and parameters
  3. Select items and press Cmd+C, then Cmd+V — confirm duplicates appear with new names and offset positions
  4. Press Cmd+A — confirm all canvas nodes are selected
  5. Press Escape — confirm selection is cleared
  6. Copy items from one document and paste into another — confirm they paste as independent copies

Implement clipboard support with a versioned JSON format (petrinaut-sdcpn v1)
validated by zod. Copy serializes selected items (places, transitions, token
types, differential equations, parameters) with arc preservation. Paste
duplicates items with new UUIDs, deduplicates names, remaps internal references,
and offsets node positions. Cmd+A selects all canvas nodes, Escape clears
selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
petrinaut Ready Ready Preview, Comment Mar 12, 2026 1:32am
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
hash Ignored Ignored Preview Mar 12, 2026 1:32am
hashdotdesign Ignored Ignored Preview Mar 12, 2026 1:32am
hashdotdesign-tokens Ignored Ignored Preview Mar 12, 2026 1:32am

@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team labels Mar 12, 2026
Copy link
Collaborator Author

kube commented Mar 12, 2026

@kube kube changed the title Make TopBar title input fill available space FE-504: Add copy/paste and select all to petrinaut editor Mar 12, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant