Open louis030195 opened 2 years ago
@louis030195
import CodeMirror from '@uiw/react-codemirror';
import { StreamLanguage } from '@codemirror/language';
import { handlebars } from '@codemirror/legacy-modes/mode/handlebars';
const codeStr = `code string....`;
export default function App() {
return (
<CodeMirror
value={codeStr}
height="200px"
extensions={[StreamLanguage.define(handlebars)]}
onChange={(value, viewUpdate) => {
console.log('value:', value);
}}
/>
);
}
Module not found: Error: Can't resolve '@codemirror/legacy-modes/mode/handlebars' ?
package.json
...
"dependencies": {
...
"@codemirror/language": "^6.0.0",
"@codemirror/legacy-modes": "^6.0.0",
...
@louis030195
import CodeMirror from '@uiw/react-codemirror'; import { StreamLanguage } from '@codemirror/language'; import { handlebars } from '@codemirror/legacy-modes/mode/handlebars'; const codeStr = `code string....`; export default function App() { return ( <CodeMirror value={codeStr} height="200px" extensions={[StreamLanguage.define(handlebars)]} onChange={(value, viewUpdate) => { console.log('value:', value); }} /> ); }
This solves my problem!
@louis030195 I'm having the same issue. Did you ever figure out how to import?
If I understand correctly, this might be a v5 vs v6 issue? v6 doesn't have handlebars support maybe?
Is seems v6 does not support handlebars, so how can v6 support handlebars?
@tslater @lenqwang https://github.com/uiwjs/react-codemirror/issues/333#issuecomment-1238887212
@tslater @lenqwang https://github.com/uiwjs/react-codemirror/issues/333#issuecomment-1238887212
I don't find the handlebars module file
I don't think there is any good way to use it on v6 yet. You'd have to implement it yourself.
@lenqwang @tslater https://codemirror.net/5/mode/handlebars/index.html Is it this one? I think the definition is also very simple.
Yes, I had to implement it myself. Although I searched the entire internet. However, I am very curious why the official has not provided an implementation of handlebars.
Thanks a lot, These links are very useful to me
Hello!
It's not so clear how to use this lib with handlebars, if it is even possible, I see codemirror support it so why not?
I couldn't find it in
import { handlebars } from '@codemirror/legacy-modes/mode/handlebars';
?Thanks a lot