From 1a90cf92d097f1c2f4ff3f0c2e9473af124c5257 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Fri, 14 Mar 2025 18:48:48 +0100 Subject: [PATCH 1/2] Fixed drag & drop for blocks with iframes not working --- packages/core/src/extensions/SideMenu/dragging.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/core/src/extensions/SideMenu/dragging.ts b/packages/core/src/extensions/SideMenu/dragging.ts index 2f0afc98c3..59ad00baf9 100644 --- a/packages/core/src/extensions/SideMenu/dragging.ts +++ b/packages/core/src/extensions/SideMenu/dragging.ts @@ -66,6 +66,7 @@ function blockPositionsFromSelection(selection: Selection, doc: Node) { } function setDragImage(view: EditorView, from: number, to = from) { + // debugger; if (from === to) { // Moves to position to be just after the first (and only) selected block. to += view.state.doc.resolve(from + 1).node().nodeSize; @@ -99,6 +100,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(" "); From 6f98d8820fa08078eb5e0eed0e26d45d3bb5a8c0 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Fri, 14 Mar 2025 18:49:36 +0100 Subject: [PATCH 2/2] Removed comment --- packages/core/src/extensions/SideMenu/dragging.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/extensions/SideMenu/dragging.ts b/packages/core/src/extensions/SideMenu/dragging.ts index 59ad00baf9..7ee8a1395a 100644 --- a/packages/core/src/extensions/SideMenu/dragging.ts +++ b/packages/core/src/extensions/SideMenu/dragging.ts @@ -66,7 +66,6 @@ function blockPositionsFromSelection(selection: Selection, doc: Node) { } function setDragImage(view: EditorView, from: number, to = from) { - // debugger; if (from === to) { // Moves to position to be just after the first (and only) selected block. to += view.state.doc.resolve(from + 1).node().nodeSize;