简体   繁体   English

如何为摩纳哥编辑器添加新的语言语法?

[英]How do I add a new language syntax to Monaco editor?

I added my language and followed the instructions here to build https://github.com/Microsoft/monaco-languages 我添加了我的语言,并按照此处的说明构建了https://github.com/Microsoft/monaco-languages

npm run prepublish

This outputs a release folder with dev, esm and min folders inside, but what to do with this output to add it to the Monaco editor? 这将输出一个发布文件夹,其中包含dev,esm和min文件夹,但是如何处理此输出并将其添加到Monaco编辑器中?

If you just want to test things out: 如果您只想测试一下:

~$ git clone https://github.com/Microsoft/monaco-editor
~$ cd monaco-editor
~/monaco-editor$ npm install .
~/monaco-editor$ npm run simpleserver

Just make sure monaco-editor and monaco-languages (or any other plugins) are under the same directory. 只要确保monaco-editormonaco-languages (或任何其他插件)在同一目录下即可。

If you want to create your own release then you can simply edit https://github.com/Microsoft/monaco-editor/blob/master/metadata.js#L68-L70 to point to your monaco-languages . 如果要创建自己的发行版,则只需编辑https://github.com/Microsoft/monaco-editor/blob/master/metadata.js#L68-L70即可指向您的monaco-languages I guess you could also update the package.json to install your own version of monaco-languages , or simple copy over your ~/monaco-languages/release folder to ~/monaco-editor/node_modules/monaco-languages/ . 我想您也可以更新package.json来安装自己的monaco-languages版本,或将~/monaco-languages/release文件夹中的简单副本复制到~/monaco-editor/node_modules/monaco-languages/

After that just ~/monaco-editor$ npm run release and you'll get your release folder. 之后,只需~/monaco-editor$ npm run release ,您就会获得release文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM