File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
packages/react/src/schema Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ import {
2121} from "@blocknote/core" ;
2222import {
2323 NodeView ,
24- NodeViewContent ,
2524 NodeViewProps ,
2625 NodeViewWrapper ,
2726 ReactNodeViewRenderer ,
27+ useReactNodeView ,
2828} from "@tiptap/react" ;
2929import { FC , ReactNode } from "react" ;
3030import { renderToDOMSpec } from "./@util/ReactRenderUtil.js" ;
@@ -168,8 +168,11 @@ export function createReactBlockSpec<
168168 const blockContentDOMAttributes =
169169 this . options . domAttributes ?. blockContent || { } ;
170170
171- // hacky, should export `useReactNodeView` from tiptap to get access to ref
172- const ref = ( NodeViewContent ( { } ) as any ) . ref ;
171+ const ref = useReactNodeView ( ) . nodeViewContentRef ;
172+
173+ if ( ! ref ) {
174+ throw new Error ( "nodeViewContentRef is not set" ) ;
175+ }
173176
174177 const BlockContent = blockImplementation . render ;
175178 return (
Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ import {
1616 StyleSchema ,
1717} from "@blocknote/core" ;
1818import {
19- NodeViewContent ,
2019 NodeViewProps ,
2120 NodeViewWrapper ,
2221 ReactNodeViewRenderer ,
22+ useReactNodeView ,
2323} from "@tiptap/react" ;
2424// import { useReactNodeView } from "@tiptap/react/dist/packages/react/src/useReactNodeView";
2525import { FC } from "react" ;
@@ -149,8 +149,11 @@ export function createReactInlineContentSpec<
149149 return ( props ) =>
150150 ReactNodeViewRenderer (
151151 ( props : NodeViewProps ) => {
152- // hacky, should export `useReactNodeView` from tiptap to get access to ref
153- const ref = ( NodeViewContent ( { } ) as any ) . ref ;
152+ const ref = useReactNodeView ( ) . nodeViewContentRef ;
153+
154+ if ( ! ref ) {
155+ throw new Error ( "nodeViewContentRef is not set" ) ;
156+ }
154157
155158 const Content = inlineContentImplementation . render ;
156159 return (
You can’t perform that action at this time.
0 commit comments