Skip to content

fix: Drag & drop for blocks with iframes not working #1531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/core/src/extensions/SideMenu/dragging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ function setDragImage(view: EditorView, from: number, to = from) {
unsetDragImage(view.root);
dragImageElement = parentClone;

// Browsers may have CORS policies which prevents iframes from being
// manipulated, so better to stay on the safe side and remove them from the
// drag preview. The drag preview doesn't work with iframes anyway.
const iframes = dragImageElement.getElementsByTagName("iframe");
for (let i = 0; i < iframes.length; i++) {
const iframe = iframes[i];
const parent = iframe.parentElement;

if (parent) {
parent.removeChild(iframe);
}
}

// TODO: This is hacky, need a better way of assigning classes to the editor so that they can also be applied to the
// drag preview.
const classes = view.dom.className.split(" ");
Expand Down
Loading