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

Dan*_*vek 8 monaco-editor

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

use*_*782 5

您必须在像这样的编辑器之间共享模型

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,
})
Run Code Online (Sandbox Code Playgroud)
<div id="container1" style="height:50%;"></div>
<div id="container2" style="height:50%;"></div>
Run Code Online (Sandbox Code Playgroud)

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