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 {
21
21
} from "@blocknote/core" ;
22
22
import {
23
23
NodeView ,
24
- NodeViewContent ,
25
24
NodeViewProps ,
26
25
NodeViewWrapper ,
27
26
ReactNodeViewRenderer ,
27
+ useReactNodeView ,
28
28
} from "@tiptap/react" ;
29
29
import { FC , ReactNode } from "react" ;
30
30
import { renderToDOMSpec } from "./@util/ReactRenderUtil.js" ;
@@ -168,8 +168,11 @@ export function createReactBlockSpec<
168
168
const blockContentDOMAttributes =
169
169
this . options . domAttributes ?. blockContent || { } ;
170
170
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
+ }
173
176
174
177
const BlockContent = blockImplementation . render ;
175
178
return (
Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ import {
16
16
StyleSchema ,
17
17
} from "@blocknote/core" ;
18
18
import {
19
- NodeViewContent ,
20
19
NodeViewProps ,
21
20
NodeViewWrapper ,
22
21
ReactNodeViewRenderer ,
22
+ useReactNodeView ,
23
23
} from "@tiptap/react" ;
24
24
// import { useReactNodeView } from "@tiptap/react/dist/packages/react/src/useReactNodeView";
25
25
import { FC } from "react" ;
@@ -149,8 +149,11 @@ export function createReactInlineContentSpec<
149
149
return ( props ) =>
150
150
ReactNodeViewRenderer (
151
151
( 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
+ }
154
157
155
158
const Content = inlineContentImplementation . render ;
156
159
return (
You can’t perform that action at this time.
0 commit comments