Monaco Editor Wrapper for integration with react + webpack. Based on SurenAt93/monaco-react/ but does not load from a CDN. It loads monaco via monaco-editor-webpack-plugin
and gives installation instructions for a new or existing project via rescripts
.
npm install @etclabscore/react-monaco-editor --save
npm install @rescripts/cli @rescripts/utilities --save-dev
npm install monaco-editor-webpack-plugin --save-dev
package.json
{
"name": "built-with-rescripts",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-scripts": "2.1.1"
}
"devDependencies": {
"@rescripts/cli": "^0.0.11",
"@rescripts/rescript-env": "^0.0.10"
}
"scripts": {
- "start": "react-scripts start",
+ "start": "rescripts start",
- "build": "react-scripts build",
+ "build": "rescripts build",
- "test": "react-scripts test",
+ "test": "rescripts test",
- "eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const { prependWebpackPlugin } = require("@rescripts/utilities");
module.exports = function override(config, env) {
return prependWebpackPlugin(new MonacoWebpackPlugin({
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
languages: ["json"]
}), config);
}
package.json
{
"name": "built-with-rescripts",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-scripts": "2.1.1"
}
"devDependencies": {
"@rescripts/cli": "^0.1.0"
}
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
+ "rescripts": [
+ "rescript-monaco"
+ ]
}
import MonacoEditor from "@etclabscore/react-monaco-editor";
const MyComponent = ({value}) => {
const handleEditorDidMount = (editor) => {
}
const handleChange = (ev, value) => {
}
return (
<MonacoEditor
height="100vh"
value={value}
editorDidMount={handleEditorDidMount}
language="json"
onChange={handleChange}
/>
);
}
How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.