[DragAndDrop] Copy internal content with Ctrl-drag - #3428
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Julia Roldi (juliaroldi)
marked this pull request as ready for review
August 4, 2026 19:49
Julia Roldi (juliaroldi)
requested review from
Bryan Valverde U (BryanValverdeU),
Jiuqing Song (JiuqingSong),
flyingbee2012,
Ian Elizondo (ianeli1) and
Vi Nguyen (vinguyen12)
and
a lite review from Copilot
August 4, 2026 19:49
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates internal drag-and-drop handling in roosterjs-content-model-plugins to support copy-on-drop when the user holds Ctrl during an internal drag operation, while keeping the existing move-on-drop behavior when Ctrl is not pressed.
Changes:
- Update
handleDroppedInternalContentto skip deleting the source selection whenevent.ctrlKeyis true (copy behavior). - Preserve existing selection deletion + normalization behavior when Ctrl is not pressed (move behavior).
- Add regression tests to verify
deleteSelectionis (not) invoked for Ctrl vs non-Ctrl drops.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedInternalContent.ts | Adds Ctrl-modifier branching to support copy vs move behavior during internal drops. |
| packages/roosterjs-content-model-plugins/test/dragAndDrop/utils/handleDroppedInternalContentTest.ts | Adds targeted unit coverage ensuring selection deletion occurs only for non-Ctrl drops. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (deleteSelection(model, [], context).deleteResult == 'range') { | ||
| normalizeContentModel(model); | ||
| if (!event.ctrlKey) { |
Collaborator
There was a problem hiding this comment.
On Mac, should this be Meta key?
Jiuqing Song (JiuqingSong)
approved these changes
Aug 4, 2026
…u/juliaroldi/dra-ctrl
…roosterjs into u/juliaroldi/dra-ctrl
|
|
||
| if (deleteSelection(model, [], context).deleteResult == 'range') { | ||
| normalizeContentModel(model); | ||
| if (!event.ctrlKey || !event.metaKey) { |
Jiuqing Song (JiuqingSong)
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Update
handleDroppedInternalContentso holding Ctrl during an internal drag-and-drop copies the selected content instead of deleting the original selection. Preserve the existing move behavior when Ctrl is not pressed, with regression coverage for both paths.How to test
yarn test:fast --testPathPattern=handleDroppedInternalContent.