-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
could anybody tell me how to install codemirror2 on react18.2.0 #299
Comments
Having same issue |
O man, I'm also having the same issue |
I was able to successfully implement the feature by downgrading the codemirror library to version ^5.65.13. Here's how I did it: In your package.json file, adjust the dependencies to include these versions: // package.json
"dependencies": {
"codemirror": "^5.65.13",
"react-codemirror2": "^7.2.1",
} Then, in your main.js file, you should import the necessary language and CSS styles. Here's how: // main.js
import ReactDOM from 'react-dom/client';
// Importing the necessary language and CSS styles
import 'codemirror/mode/htmlmixed/htmlmixed';
import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material.css';
// Other necessary imports
import './index.css';
import App from './App.js';
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<App />
); Finally, here is the component that utilizes the editor. You can find it in the html-editor.js file: // html-editor.js
import React from 'react';
import { Controlled as ControlledEditor } from 'react-codemirror2';
const HtmlEditor = ({ field, value, onChange }) => {
return (
<ControlledEditor
value={value}
options={{
lineWrapping: true,
lint: true,
lineNumbers: true,
mode: 'htmlmixed',
htmlMode: true,
theme: 'material',
}}
onBeforeChange={(editor, data, value) => {
onChange({ field, value });
}}
/>
);
};
export default HtmlEditor; |
No description provided.
The text was updated successfully, but these errors were encountered: