Skip to content

Commit 161d6dd

Browse files
fix: Drag & drop for blocks with iframes not working (#1531)
* Fixed drag & drop for blocks with iframes not working * Removed comment
1 parent 37f0765 commit 161d6dd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/core/src/extensions/SideMenu/dragging.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ function setDragImage(view: EditorView, from: number, to = from) {
9999
unsetDragImage(view.root);
100100
dragImageElement = parentClone;
101101

102+
// Browsers may have CORS policies which prevents iframes from being
103+
// manipulated, so better to stay on the safe side and remove them from the
104+
// drag preview. The drag preview doesn't work with iframes anyway.
105+
const iframes = dragImageElement.getElementsByTagName("iframe");
106+
for (let i = 0; i < iframes.length; i++) {
107+
const iframe = iframes[i];
108+
const parent = iframe.parentElement;
109+
110+
if (parent) {
111+
parent.removeChild(iframe);
112+
}
113+
}
114+
102115
// TODO: This is hacky, need a better way of assigning classes to the editor so that they can also be applied to the
103116
// drag preview.
104117
const classes = view.dom.className.split(" ");

0 commit comments

Comments
 (0)