Skip to content

Commit

Permalink
fix: take autoload flag into account
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Apr 19, 2024
1 parent 246b860 commit 590bf9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/plugins/codemirror/CodeMirrorEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ import { basicLight } from 'cm6-theme-basic-light'
import { basicSetup } from 'codemirror'
import { languages } from '@codemirror/language-data'
import { useCodeMirrorRef } from '../sandpack/useCodeMirrorRef'
import { codeMirrorExtensions$ } from '.'
import { codeMirrorAutoLoadLanguageSupport$, codeMirrorExtensions$ } from '.'

export const COMMON_STATE_CONFIG_EXTENSIONS: Extension[] = []

export const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) => {
const [readOnly, codeMirrorExtensions] = useCellValues(readOnly$, codeMirrorExtensions$)
const [readOnly, codeMirrorExtensions, autoLoadLanguageSupport] = useCellValues(
readOnly$,
codeMirrorExtensions$,
codeMirrorAutoLoadLanguageSupport$
)

const codeMirrorRef = useCodeMirrorRef(nodeKey, 'codeblock', language, focusEmitter)
const { setCode } = useCodeBlockEditorContext()
Expand Down Expand Up @@ -44,7 +48,7 @@ export const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }: Code
if (readOnly) {
extensions.push(EditorState.readOnly.of(true))
}
if (language !== '') {
if (language !== '' && autoLoadLanguageSupport) {
const languageData = languages.find((l) => {
return l.name === language || l.alias.includes(language) || l.extensions.includes(language)
})
Expand Down

0 comments on commit 590bf9e

Please sign in to comment.