diff --git a/packages/core/src/editor/Block.css b/packages/core/src/editor/Block.css
index ef2867121d..7b272dcc86 100644
--- a/packages/core/src/editor/Block.css
+++ b/packages/core/src/editor/Block.css
@@ -579,6 +579,8 @@ NESTED BLOCKS
.bn-inline-content-section
.bn-preview-with-source-popup[data-open="true"]
.bn-source-block-popup {
+ margin-top: 0;
+ z-index: calc(var(--bn-ui-base-z-index, 0) + 15);
width: 300px;
}
diff --git a/packages/react/src/blocks/SourceWithPreview/SourceWithPreview.tsx b/packages/react/src/blocks/SourceWithPreview/SourceWithPreview.tsx
index 65be1cfa13..f54184f610 100644
--- a/packages/react/src/blocks/SourceWithPreview/SourceWithPreview.tsx
+++ b/packages/react/src/blocks/SourceWithPreview/SourceWithPreview.tsx
@@ -1,5 +1,12 @@
import { BlockNoteEditor } from "@blocknote/core";
-import { MouseEvent, ReactNode, useId, useRef } from "react";
+import {
+ autoUpdate,
+ flip,
+ offset,
+ shift,
+ useFloating,
+} from "@floating-ui/react";
+import { MouseEvent, ReactNode, useCallback, useId, useRef } from "react";
import { MdKeyboardReturn } from "react-icons/md";
import { PreviewPlaceholder } from "./PreviewPlaceholder.js";
@@ -129,6 +136,20 @@ export const SourceWithPreview = (
errorPreview
);
+ const { refs, floatingStyles } = useFloating({
+ placement: "bottom-start",
+ strategy: "fixed",
+ middleware: [offset(4), flip(), shift({ padding: 8 })],
+ whileElementsMounted: autoUpdate,
+ });
+
+ const isFloating = inline === true && popup.isOpen;
+
+ const setAnchor = useCallback(
+ (node: HTMLElement | null) => refs.setPositionReference(node),
+ [refs],
+ );
+
// Links the source input to the render error so screen readers announce it
// when the input is focused.
const errorId = useId();
@@ -182,13 +203,18 @@ export const SourceWithPreview = (