Skip to content

Commit fa62100

Browse files
committed
fix: correct theme for the nested lexial editors
1 parent d3ca9e7 commit fa62100

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/plugins/core/NestedLexicalEditor.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
importVisitors$,
2929
jsxComponentDescriptors$,
3030
jsxIsAvailable$,
31+
lexicalTheme$,
3132
nestedEditorChildren$,
3233
rootEditor$,
3334
usedLexicalNodes$
@@ -37,15 +38,14 @@ import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'
3738
import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer.js'
3839
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'
3940
import classNames from 'classnames'
40-
import { lexicalTheme } from '../../styles/lexicalTheme'
4141
import { exportLexicalTreeToMdast } from '../../exportMarkdownFromLexical'
4242
import { importMdastTreeToLexical } from '../../importMarkdownToLexical'
4343
import styles from '../../styles/ui.module.css'
4444
import { SharedHistoryPlugin } from './SharedHistoryPlugin'
4545
import { mergeRegister } from '@lexical/utils'
4646
import { VoidEmitter } from '../../utils/voidEmitter'
4747
import { isPartOftheEditorUI } from '../../utils/isPartOftheEditorUI'
48-
import { useCellValues, usePublisher } from '@mdxeditor/gurx'
48+
import { useCellValues, usePublisher, useRealm } from '@mdxeditor/gurx'
4949
import { DirectiveNode } from '../directives'
5050
import { LexicalJsxNode } from '../jsx/LexicalJsxNode'
5151

@@ -181,6 +181,7 @@ export const NestedLexicalEditor = function <T extends Mdast.RootContent>(props:
181181
const updateMdastNode = useMdastNodeUpdater<T>()
182182
const removeNode = useLexicalNodeRemove()
183183
const content = getContent(mdastNode)
184+
const realm = useRealm()
184185

185186
const [
186187
rootEditor,
@@ -191,7 +192,8 @@ export const NestedLexicalEditor = function <T extends Mdast.RootContent>(props:
191192
directiveDescriptors,
192193
codeBlockEditorDescriptors,
193194
jsxIsAvailable,
194-
nestedEditorChildren
195+
nestedEditorChildren,
196+
lexicalTheme
195197
] = useCellValues(
196198
rootEditor$,
197199
importVisitors$,
@@ -201,15 +203,16 @@ export const NestedLexicalEditor = function <T extends Mdast.RootContent>(props:
201203
directiveDescriptors$,
202204
codeBlockEditorDescriptors$,
203205
jsxIsAvailable$,
204-
nestedEditorChildren$
206+
nestedEditorChildren$,
207+
lexicalTheme$
205208
)
206209

207210
const setEditorInFocus = usePublisher(editorInFocus$)
208211

209212
const [editor] = React.useState(() => {
210213
const editor = createEditor({
211214
nodes: usedLexicalNodes,
212-
theme: lexicalTheme
215+
theme: realm.getValue(lexicalTheme$)
213216
})
214217
return editor
215218
})
@@ -261,6 +264,7 @@ export const NestedLexicalEditor = function <T extends Mdast.RootContent>(props:
261264
updateMdastNode(getUpdatedMdastNode(structuredClone(mdastNode) as any, content as any))
262265
})
263266
}
267+
264268
return mergeRegister(
265269
editor.registerCommand(
266270
FOCUS_COMMAND,
@@ -330,7 +334,7 @@ export const NestedLexicalEditor = function <T extends Mdast.RootContent>(props:
330334
])
331335

332336
return (
333-
<LexicalNestedComposer initialEditor={editor}>
337+
<LexicalNestedComposer initialEditor={editor} initialTheme={lexicalTheme}>
334338
<RichTextPlugin
335339
contentEditable={
336340
<ContentEditable {...contentEditableProps} className={classNames(styles.nestedEditor, contentEditableProps?.className)} />

0 commit comments

Comments
 (0)