Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have split-panes in monaco editor?

Is it possible to get split panes in Monaco editor? Similar to what's done in VSCode or what is being used in the Diff Editor provided by Monaco itself.

like image 778
Daniel Belohlavek Avatar asked Oct 16 '17 22:10

Daniel Belohlavek


People also ask

Is Monaco editor safe?

Is ngx-monaco-editor safe to use? The npm package ngx-monaco-editor was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as safe to use.

What is Monaco editor used for?

The Monaco Editor is the code editor that powers VS Code. A good page describing the code editor's features is here. It is licensed under the MIT License and supports Edge, Chrome, Firefox, Safari and Opera. The Monaco editor is not supported in mobile browsers or mobile web frameworks.


1 Answers

You have to share model among editors like

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>

You can test that code in playground https://microsoft.github.io/monaco-editor/playground.html

like image 143
user3130782 Avatar answered Sep 22 '22 00:09

user3130782