是否可以在摩纳哥编辑中使用分割窗格?

时间:2017-10-16 22:04:54

标签: monaco-editor

是否可以在摩纳哥编辑器中获得拆分窗格?类似于在VSCode中所做的或者在摩纳哥自己提供的Diff Editor中使用的内容。

1 个答案:

答案 0 :(得分:3)

您必须在编辑者之间共享模型

const ed1 = monaco.editor.create(document.getElementById("container1"), {
    value: "function hello() {\n\talert('Hello world!');\n}",
    language: "javascript"
})
const model = ed1.getModel()

monaco.editor.create(document.getElementById("container2"), {
    model,
})

<div id="container1" style="height:50%;"></div>
<div id="container2" style="height:50%;"></div>

您可以在游乐场https://microsoft.github.io/monaco-editor/playground.html中测试该代码