@@ -7,6 +7,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
7
7
import * as React from 'react'
8
8
import { createContext , useContext , useMemo , useRef , useState } from 'react'
9
9
10
+ import type { InlineBlockNode } from '../../../features/blocks/client/nodes/InlineBlocksNode.js'
10
11
import type { LexicalRichTextFieldProps } from '../../../types.js'
11
12
import type { SanitizedClientEditorConfig } from '../types.js'
12
13
@@ -19,16 +20,18 @@ export interface EditorConfigContextType {
19
20
// Editor focus handling
20
21
blurEditor : ( editorContext : EditorConfigContextType ) => void
21
22
childrenEditors : React . RefObject < Map < string , EditorConfigContextType > >
23
+ createdInlineBlock ?: InlineBlockNode
22
24
editor : LexicalEditor
23
25
editorConfig : SanitizedClientEditorConfig
24
- editorContainerRef : React . RefObject < HTMLDivElement >
25
26
27
+ editorContainerRef : React . RefObject < HTMLDivElement >
26
28
fieldProps : MarkRequired < LexicalRichTextFieldProps , 'path' | 'schemaPath' >
27
29
focusedEditor : EditorConfigContextType | null
28
30
// Editor focus handling
29
31
focusEditor : ( editorContext : EditorConfigContextType ) => void
30
32
parentEditor : EditorConfigContextType
31
33
registerChild : ( uuid : string , editorContext : EditorConfigContextType ) => void
34
+ setCreatedInlineBlock ?: React . Dispatch < React . SetStateAction < InlineBlockNode | undefined > >
32
35
unregisterChild ?: ( uuid : string ) => void
33
36
uuid : string
34
37
}
@@ -61,6 +64,7 @@ export const EditorConfigProvider = ({
61
64
const childrenEditors = useRef < Map < string , EditorConfigContextType > > ( new Map ( ) )
62
65
const [ focusedEditor , setFocusedEditor ] = useState < EditorConfigContextType | null > ( null )
63
66
const focusHistory = useRef < Set < string > > ( new Set ( ) )
67
+ const [ createdInlineBlock , setCreatedInlineBlock ] = useState < InlineBlockNode > ( )
64
68
65
69
const editorContext = useMemo (
66
70
( ) =>
@@ -70,6 +74,7 @@ export const EditorConfigProvider = ({
70
74
focusHistory . current . clear ( ) // Reset focus history when focus is lost
71
75
} ,
72
76
childrenEditors,
77
+ createdInlineBlock,
73
78
editor,
74
79
editorConfig,
75
80
editorContainerRef,
@@ -105,6 +110,7 @@ export const EditorConfigProvider = ({
105
110
childrenEditors . current = newMap
106
111
}
107
112
} ,
113
+ setCreatedInlineBlock,
108
114
unregisterChild : ( childUUID ) => {
109
115
if ( childrenEditors . current . has ( childUUID ) ) {
110
116
const newMap = new Map ( childrenEditors . current )
@@ -116,6 +122,8 @@ export const EditorConfigProvider = ({
116
122
uuid,
117
123
} ) as EditorConfigContextType ,
118
124
[
125
+ createdInlineBlock ,
126
+ setCreatedInlineBlock ,
119
127
editor ,
120
128
childrenEditors ,
121
129
editorConfig ,
0 commit comments