@@ -90,7 +90,22 @@ const BaseCodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(
9090 const [ undoDepth , setUndoDepth ] = useState ( 0 ) ;
9191 const [ redoDepth , setRedoDepth ] = useState ( 0 ) ;
9292
93- const { modules, isLoading } = useModules ( props ) ;
93+ // Create normalized props object with all defaults applied
94+ // This ensures that when we spread props, all default values are included
95+ // Note: We spread props first, then override with destructured values (which have defaults applied)
96+ // This ensures that if a prop is undefined in props, the default value is used
97+ const normalizedProps : CodeEditorProps = {
98+ ...props ,
99+ copyButtonAppearance,
100+ enableSearchPanel,
101+ extensions : consumerExtensions ,
102+ forceParsing : forceParsingProp ,
103+ isLoading : isLoadingProp ,
104+ } ;
105+
106+ const { modules, isLoading } = useModules ( {
107+ ...normalizedProps ,
108+ } ) ;
94109
95110 // Get formatting functionality
96111 const { formatCode, isFormattingAvailable } = useCodeFormatter ( {
@@ -102,11 +117,8 @@ const BaseCodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(
102117 const customExtensions = useExtensions ( {
103118 editorViewInstance : editorViewRef . current ,
104119 props : {
105- ...props ,
106- forceParsing : forceParsingProp ,
120+ ...normalizedProps ,
107121 onChange : onChangeProp ,
108- isLoading : isLoadingProp ,
109- extensions : consumerExtensions ,
110122 baseFontSize,
111123 /**
112124 * CodeEditorTooltip in particular renders outside of the LeafyGreenProvider
@@ -283,7 +295,7 @@ const BaseCodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(
283295
284296 const searchPanelExtension = useSearchPanelExtension ( {
285297 props : {
286- ...props ,
298+ ...normalizedProps ,
287299 darkMode,
288300 baseFontSize,
289301 } ,
@@ -335,7 +347,6 @@ const BaseCodeEditor = forwardRef<CodeEditorHandle, CodeEditorProps>(
335347 ! EditorView ||
336348 ! Prec ||
337349 ! commands ||
338- ! searchModule ||
339350 ! StateEffect
340351 ) {
341352 return ;
0 commit comments