4
我有一個嵌入我的應用程序的摩納哥代碼編輯器。如何將文本插入到摩納哥編輯器中?
如何以編程方式在特定行上插入文本?
var editor = monaco.editor.create(document.getElementById("container"), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: "javascript",
lineNumbers: false,
roundedSelection: false,
scrollBeyondLastLine: false,
readOnly: false,
theme: "vs-dark",
});
// how do I do this?
editor.insertText("FOO");
[一些額外的上下文](https://github.com/Microsoft/monaco-editor/issues/192) – chris