fix(core): Dragging between editors revisions#7674
fix(core): Dragging between editors revisions#7674mweidner037 wants to merge 11 commits intoueberdosis:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 5c620ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 72 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…one with internal drag handles
Borrowed from GlobalDragHandle/Vue demo
There was a problem hiding this comment.
Pull request overview
This PR revises Tiptap’s cross-editor drag-and-drop behavior by moving “remove source content on drop” logic into the core Drop extension (so it runs exactly once), making removal conditional on whether the drag should be treated as move vs copy, and improving global drag-handle dragstart dataTransfer population so drags out of the editor work reliably.
Changes:
- Move cross-editor “delete source selection after drop” logic from
PasteRuleinto the coreDropextension, and gate deletion by copy-modifier detection. - Update
@tiptap/extension-drag-handleto populatedataTransferwithtext/htmlandtext/plainon dragstart. - Add two new demos (GlobalDragHandleMultiEditor, NodeViewDragHandleMultiEditor) to validate the behavior.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/extension-drag-handle/src/helpers/dragHandler.ts | Sets dataTransfer HTML/plain payloads on dragstart to match ProseMirror behavior. |
| packages/core/src/PasteRule.ts | Removes prior cross-editor deletion logic from paste rules plugin. |
| packages/core/src/extensions/drop.ts | Adds global drag source tracking and conditional source deletion on cross-editor drop. |
| demos/src/Experiments/NodeViewDragHandleMultiEditor/React/styles.scss | Styles for the new NodeView drag-handle multi-editor demo. |
| demos/src/Experiments/NodeViewDragHandleMultiEditor/React/index.jsx | New demo mounting two editors with draggable nodeviews. |
| demos/src/Experiments/NodeViewDragHandleMultiEditor/React/index.html | HTML entry for the new NodeView drag-handle demo. |
| demos/src/Experiments/NodeViewDragHandleMultiEditor/React/DraggableItem.js | Demo extension defining a draggable block node with a React nodeview. |
| demos/src/Experiments/NodeViewDragHandleMultiEditor/React/Component.jsx | Demo nodeview component rendering a drag handle + content. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/styles.scss | Styles for the new global drag-handle multi-editor demo. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/index.jsx | New demo mounting two editors with the global drag handle component. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/index.html | HTML entry for the new GlobalDragHandle demo. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/extensions/recommendation/views/RecommendationView.jsx | Demo nodeview for a draggable “recommendation” node. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/extensions/recommendation/views/index.jsx | Barrel export for recommendation views. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/extensions/recommendation/Recommendation.jsx | Demo extension for a draggable recommendation node. |
| demos/src/Experiments/GlobalDragHandleMultiEditor/React/extensions/recommendation/index.jsx | Barrel export for the recommendation extension. |
| .changeset/sixty-falcons-boil.md | Changeset for core bug fix (extra deletion on cross-editor drag). |
| .changeset/short-steaks-cover.md | Changeset for core minor feature (modifier-key copy vs move). |
| .changeset/cyan-carpets-wonder.md | Changeset for drag-handle patch (set dataTransfer so dragging outside works). |
Changes Overview
#5893 added support for drag-and-drop between multiple editors - namely, ensuring that the source content is removed on drop. This PR revises that behavior:
deleteRangecommand to end with a nontrivial selection, causing the second paste rule to delete extra content.Implementation Approach
Testing Done
Verification Steps
Try out the new demos:
Hold Alt (Mac) or Control (Windows/Linux) while dragging to test out the drag-as-copy feature.
You can also
git checkout main packagesto try these demos without the PR's fixes. GlobalDragHandleMultiEditor in particular is exciting - every drag deletes the entire source editor content, due to issue 1.Additional Notes
Checklist
Related Issues