Skip to content

feat: duplicate selected screens with hotspots and connections (Cmd+D)#23

Merged
trmquang93 merged 1 commit intomainfrom
feat/duplicate-selection
Apr 3, 2026
Merged

feat: duplicate selected screens with hotspots and connections (Cmd+D)#23
trmquang93 merged 1 commit intomainfrom
feat/duplicate-selection

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Adds duplicateSelection(screenIds) to useScreenManager — deep-clones selected screens with full ID remapping for screen IDs, hotspot IDs, stateGroup, and conditionGroupId; clones only connections where both endpoints are within the selection
  • Exposes via Cmd+D keyboard shortcut (blocks browser bookmark dialog with preventDefault)
  • Exposes via right-click context menu with smart label: "Duplicate Screen" (single) or "Duplicate Selection" (multi)
  • Duplicated screens appear offset +300px horizontally and named with a (copy) suffix
  • Post-duplication, the canvas selection switches to the new screens so they can be dragged immediately
  • The entire operation is a single undo step via the existing pushHistory pattern

Test plan

  • Select 3+ screens with connections between them → Cmd+D → verify new screens appear offset with correct inter-connections
  • Hotspots pointing to screens outside the selection still point to the originals (no new external connections created)
  • Cmd+Z reverts all duplicated screens and connections in one step
  • Right-click single screen (no multi-select) → "Duplicate Screen" works
  • Right-click with 2+ screens selected → "Duplicate Selection" works
  • isReadOnly mode hides the context menu button and blocks Cmd+D
  • Lint and tests pass: npm run lint && npm test

Adds duplicateSelection() to useScreenManager that deep-clones a set of
screens — remapping all screen, hotspot, stateGroup, and conditionGroupId
references — and clones only connections whose both endpoints are within
the selection. Exposed via Cmd+D keyboard shortcut and a context menu
option that labels itself "Duplicate Screen" or "Duplicate Selection"
based on multi-select state. The entire operation is a single undo step.
@trmquang93 trmquang93 merged commit 9f6a759 into main Apr 3, 2026
1 check passed
@github-actions github-actions bot deleted the feat/duplicate-selection branch April 3, 2026 02:39
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