Skip to content

Commit

Permalink
CodeMirror Int: Statically load resource files
Browse files Browse the repository at this point in the history
codemirror-react's default behavior is to automatically load language
resource files when it is created.  This doesn't work for me as I need
to have my entire bundle prepared ahead of time.

I created a pr to add the ability to disable this behavior
uiwjs/react-codemirror#132

The maintainer was pretty quick to merge my change, so I can statically
load resource files now
  • Loading branch information
nickgirardo committed Aug 11, 2021
1 parent fa35c14 commit bad3ae5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@types/node": "^12.20.16",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@uiw/react-codemirror": "^3.0.15",
"@uiw/react-codemirror": "^3.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.3.5"
Expand Down
2 changes: 2 additions & 0 deletions src/components/CodeRegion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactElement, useState } from 'react';

import CodeMirror from '@uiw/react-codemirror';
import 'codemirror/keymap/sublime';
import 'codemirror/mode/javascript/javascript';

// TODO currently for catching errors I'm just wrapping the whole thing
// in a try catch. This can be escaped by a user if they wanted
Expand Down Expand Up @@ -55,6 +56,7 @@ export const CodeRegion = (props: Props):ReactElement => {
value={ props.code }
onChange={ (editor) => setCodeMirrorProgram(editor.getValue()) }
height={ props.codeHeight || '12em' }
lazyLoadMode={ false }
options={{
theme: 'nicks-theme',
keyMap: 'sublime',
Expand Down

0 comments on commit bad3ae5

Please sign in to comment.