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(
10
10
const div = document . createElement ( "div" ) ;
11
11
12
12
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.
15
24
// This is currently only used for Styles. In this case, react context etc. won't be available inside `fc`
16
25
root = createRoot ( div ) ;
17
26
flushSync ( ( ) => {
18
27
root ! . render ( fc ( ( el ) => ( contentDOM = el || undefined ) ) ) ;
19
28
} ) ;
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
- ) ;
27
29
}
28
30
29
31
if ( ! div . childElementCount ) {
You can’t perform that action at this time.
0 commit comments