Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

Adds keyboard and context-menu controls to rotate selected nodes and flip them across common axes/diagonals, keeping rotations strictly to x/y coordinate changes.

  • Transform utilities: rotateSelectedNodes and flipSelectedNodes now only adjust node coordinates (no type-specific rotate metadata).
  • Keyboard shortcuts: Use r for clockwise rotation (Alt for 5° steps); e remains for line start toggling and q is unused.
  • Context menu: Rotate ±45° and flip (vertical, horizontal, 45°, 135°) actions remain available when nodes are selected.
  • Settings UI & i18n: Updated shortcut documentation and localized strings to reflect the r shortcut.
  • Tests: Updated transform helper coverage to align with coordinate-only changes, including edge cases for empty selections, single nodes, and missing IDs.

Screenshot: https://github.com/user-attachments/assets/45b8a6ee-2104-445c-b522-8aa607f4f76e

Original prompt

This section details on the original issue you should resolve

<issue_title>Rotate and flip for selected</issue_title>
<issue_description>Rotate all selected nodes by applying x and y transform.
This action should be triggered by shortcuts e and q with a 45-degree clockwise or counter-clockwise rotation. When holding alt, each press should only result in a 5-degree rotation. The shortcuts section in the settings modal should also be updated.
This action could also be triggered by a right click in the context menu.

Flip all selected nodes by first finding the middle x and then swapping the left part and the right part. This action could be executed via the context menu with 4 variations (flip by the middle vertical line, middle horizontal line, middle 45 degree and middle 135 degree line)
</issue_description>

Comments on the Issue (you are @copilot in this section)

@thekingofcity > > 希望能够加入对选定区域或整图旋转/镜像功能 > > https://www.bilibili.com/video/BV1PebazHEYE/#reply272486982016

#1112


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add rotate and flip functionality for selected nodes Add rotate/flip transforms for selected nodes with shortcuts and context menu Jan 13, 2026
Copilot AI requested a review from thekingofcity January 13, 2026 08:19
@thekingofcity
Copy link
Member

@copilot There is no need to update any attributes in the node's type, only updating x and y of a node should suffice. I also see a conflict in shortcuts e, simply use r for clockwise rotation and update the docs in the settings modal. Leave e unchanged and q unused.

Copy link
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot There is no need to update any attributes in the node's type, only updating x and y of a node should suffice. I also see a conflict in shortcuts e, simply use r for clockwise rotation and...

Updated to keep e unchanged and use r for clockwise rotation (Alt for 5°); transforms now only adjust x/y without touching node-specific rotate metadata. Lint and tests pass. UI screenshot: https://github.com/user-attachments/assets/45b8a6ee-2104-445c-b522-8aa607f4f76e (commit 9d03987).

@thekingofcity thekingofcity marked this pull request as ready for review January 31, 2026 14:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements rotate and flip transformations for selected nodes with keyboard shortcuts and context menu controls. The feature allows users to rotate nodes clockwise (default 45°, or 5° with Alt key) using the 'r' shortcut, or rotate/flip via the context menu with various options (±45° rotation, vertical/horizontal/diagonal flips).

Changes:

  • Added transform utilities (rotateSelectedNodes, flipSelectedNodes) that modify node coordinates through geometric transformations
  • Implemented 'r' keyboard shortcut for clockwise rotation with Alt modifier for fine control
  • Extended context menu with rotate (±45°) and flip (vertical, horizontal, 45°, 135°) options
  • Updated settings documentation and i18n strings across all supported languages (en, zh-Hans, zh-Hant, ko, ja)

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/util/transform.ts New utility file implementing rotation and flip transformations using geometric formulas
src/util/transform.test.ts Test suite covering rotation and flip operations with basic scenarios
src/components/svg-wrapper.tsx Added 'r' keyboard shortcut handler for rotation with Alt modifier support
src/components/context-menu.tsx Added rotate/flip menu items with proper enable/disable logic, refactored handlePlaceDown for readability
src/components/page-header/settings-modal.tsx Added 'r' shortcut documentation in settings UI
src/i18n/translations/en.json Added English strings for rotate/flip actions and shortcut description
src/i18n/translations/zh-Hans.json Added Simplified Chinese translations
src/i18n/translations/zh-Hant.json Added Traditional Chinese translations
src/i18n/translations/ko.json Added Korean translations
src/i18n/translations/ja.json Added Japanese translations
package-lock.json Peer dependency reorganization from npm install

@thekingofcity thekingofcity changed the title Add rotate/flip transforms for selected nodes with shortcuts and context menu #754 Rotate and flip for selected Feb 1, 2026
@thekingofcity thekingofcity merged commit 079ca86 into main Feb 1, 2026
1 check passed
@thekingofcity thekingofcity deleted the copilot/rotate-flip-selected-nodes branch February 1, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rotate and flip for selected

2 participants