React-monaco-editor
## 示例
要在本地构建示例,请运行:
```bash
yarn
cd example
yarn
yarn start
```
然后在浏览器中打开 `http://localhost:8886`。
## 安装
```bash
yarn add react-monaco-editor
```
## 与 Webpack 结合使用
```
…
```
将 [Monaco Webpack 插件](https://github.com/Microsoft/monaco-editor-webpack-plugin) `monaco-editor-webpack-plugin` 添加到您的 `webpack.config.js`:
```js
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
plugins: [
new MonacoWebpackPlugin({
// available options are documented at https://github.com/microsoft/monaco-editor/blob/main/webpack-plugin/README.md#options
languages: ['json']
})
]
};
```
附注: Monaco Editor 内部使用 CSS 导入,因此如果您在项目中使用 CSS 模块,则默认会出现冲突。为了避免这种情况,请为应用程序和 monaco-editor 包单独配置 css-loader:
```js
// Specify separate paths
const path = require('path');
const APP_DIR = path.resolve(__dirname, './src');
const MONACO_DIR = path.resolve(__dirname, './node_modules/monaco-editor');
{
test: /.css$/,
include: APP_DIR,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
options: {
modules: true,
namedExport: true,
},
}],
}, {
test: /.css$/,
include: MONACO_DIR,
use: ['style-loader', 'css-loader'],
}
## 属性
下面所有属性都是可选的.
- 编辑宽度。 默认为"100Q".
- 编辑的高度。 默认为"100Q".
- 编辑器中创建的汽车的`价值 ' 价值。
- 编辑器中创建的汽车模型的初始值`defaultValue'。
- " 语言 " -- -- 汽车的初始语言在编辑器中创建了模型。
- 编辑主题
- " 选项 " 是指[摩纳哥接口ISTANDONIONEDROION EDEATION Construction Options](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html)。
- " 管理服务 " 指[摩纳哥接口编辑服务](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IEditorOver)