Skip to content

Commit c6e3721

Browse files
committed
feat: export direct element node
1 parent d611449 commit c6e3721

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/MDXEditor.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
markdownSourceEditorValue$,
1515
placeholder$,
1616
rootEditor$,
17+
contentEditableWrapperElement$,
1718
setMarkdown$,
1819
spellCheck$,
1920
topAreaChildren$,
@@ -49,8 +50,10 @@ const LexicalProvider: React.FC<{
4950
const RichTextEditor: React.FC = () => {
5051
const t = useTranslation()
5152
const setContentEditableRef = usePublisher(contentEditableRef$)
52-
const onRef = (_contentEditableRef: HTMLDivElement) => {
53-
setContentEditableRef({ current: _contentEditableRef })
53+
const setEditorRootWrapperElement = usePublisher(contentEditableWrapperElement$)
54+
const onRef = (el: HTMLDivElement | null) => {
55+
setEditorRootWrapperElement(el)
56+
setContentEditableRef({ current: el })
5457
}
5558

5659
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder, bottomAreaChildren] =

src/plugins/core/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ function rebind() {
426426
}, [] as Teardowns)
427427
}
428428

429+
export const contentEditableWrapperElement$ = Cell<HTMLDivElement | null>(null)
430+
429431
/** @internal */
430432
export const activeEditorSubscriptions$ = Cell<EditorSubscription[]>([], (r) => {
431433
r.pipe(r.combine(activeEditorSubscriptions$, activeEditor$), rebind())

0 commit comments

Comments
 (0)