File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
packages/react/src/schema/@util Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,22 @@ export function renderToDOMSpec(
1010 const div = document . createElement ( "div" ) ;
1111
1212 let root : Root | undefined ;
13- if ( ! editor ) {
14- // If no editor is provided, use a temporary root.
13+ const { _tiptapEditor } = editor || { } ;
14+
15+ if ( _tiptapEditor ?. contentComponent ) {
16+ // Render temporarily using `EditorContent` (which is stored somewhat hacky on `_tiptapEditor.contentComponent`)
17+ // This way React Context will still work, as `fc` will be rendered inside the existing React tree
18+ _tiptapEditor . contentComponent . renderToElement (
19+ fc ( ( el ) => ( contentDOM = el || undefined ) ) ,
20+ div
21+ ) ;
22+ } else {
23+ // If no editor is provided, or if _tiptapEditor or _tiptapEditor.contentComponent is undefined, use a temporary root.
1524 // This is currently only used for Styles. In this case, react context etc. won't be available inside `fc`
1625 root = createRoot ( div ) ;
1726 flushSync ( ( ) => {
1827 root ! . render ( fc ( ( el ) => ( contentDOM = el || undefined ) ) ) ;
1928 } ) ;
20- } else {
21- // Render temporarily using `EditorContent` (which is stored somewhat hacky on `editor._tiptapEditor.contentComponent`)
22- // This way React Context will still work, as `fc` will be rendered inside the existing React tree
23- editor . _tiptapEditor . contentComponent . renderToElement (
24- fc ( ( el ) => ( contentDOM = el || undefined ) ) ,
25- div
26- ) ;
2729 }
2830
2931 if ( ! div . childElementCount ) {
You can’t perform that action at this time.
0 commit comments