我想在项目中使用Monaco编辑器,并希望在Microsoft的开源编辑器Monaco编辑器(https://github.com/Microsoft/monaco-editor/)中运行服务器端语言,例如C#或node。
这里有几个例子。
https://dotnet.microsoft.com/languages
如果您看到上述示例,则可以看到它们正在运行带有我想实现相同功能的运行按钮的c#。
我知道我需要为诸如C#之类的特定语言安装运行时,并且在本地计算机中已经安装了该运行时,但是仍然无法运行它。
我们将不胜感激任何帮助。
答案 0 :(得分:0)
What you see there is not a Monaco feature and is up to you to implement. How you do that, will depend largely on the language you're trying to run.
The first example (and jsFiddle and CodePen and many others) simply displays an iframe
to show the result. That iframe
loads a file with a unique name that contains the HTML, CSS and JavaScript code entered in the editor. You can confirm that this is what they're doing, using Chrome Dev Tools.
If you're going to run a language like C#, know that you will need full control of your web server. The flow will be something like this:
stdout
and stderr
) into string variables. Those strings are returned by the web service.This is very doable, but getting it to perform well when your volumes pick up will be a special problem.