[DragAndDrop] Support dropping internal content within the same editor - #3412
Merged
Conversation
Add HandleDropInternalContent experimental feature so content dragged and dropped within the same editor is moved via the Content Model instead of pasted as HTML. Split handleDroppedContent into handleDroppedExternalContent and handleDroppedInternalContent, capturing the dragged model on dragstart and merging it at the drop position. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cf3fc3cb-44b2-4b1c-8290-0da8393f2b5e
|
juliaroldi
marked this pull request as ready for review
July 23, 2026 16:31
juliaroldi
requested review from
BryanValverdeU,
JiuqingSong,
flyingbee2012,
ianeli1 and
vinguyen12
July 23, 2026 16:31
JiuqingSong
reviewed
Jul 24, 2026
Comment on lines
+29
to
+31
| const range = doc.createRange(); | ||
| range.setStart(domPosition.node, domPosition.offset); | ||
| range.collapse(true); |
Collaborator
There was a problem hiding this comment.
It seems range is not used at all
| this.isInternalDragging = true; | ||
| this.internalDrag = true; | ||
| if (this.editor?.isExperimentalFeatureEnabled('HandleDropInternalContent')) { | ||
| const model = editor.getContentModelCopy('disconnected'); |
Collaborator
There was a problem hiding this comment.
be careful about the "disconnected" mode, make sure you test the case when selected content has entity, see after drop if the entity is correctly dropped and if the DOM element is still the same one
JiuqingSong
approved these changes
Jul 29, 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
Adds support for dropping content within the same editor (internal drag-and-drop), gated behind the new
HandleDropInternalContentexperimental feature.DragAndDropPluginnow tracks internal drags (internalDragflag set ondragstart) and, onbeforeDrop, routes internal drops to the newhandleDroppedInternalContenthandler while external drops continue through the renamedhandleDroppedExternalContent(formerlyhandleDroppedContent).handleDroppedInternalContentinserts the dragged content at the drop position using the Content Model: it resolves the drop point viagetNodePositionFromEvent, clones and trims the current selection, deletes the original selection, then merges the cloned model at the insertion point and restores the selection across the newly inserted range.HandleDropInternalContentvalue to theExperimentalFeaturetype and wires it into the demo site's editor options and experimental features panel.How to test
yarn builddemo), enable the HandleDropInternalContent experimental feature, then select content in the editor and drag it to a different position within the same editor.