Monaco-editor: Disable minimap

Created on 11 Aug 2017  路  6Comments  路  Source: microsoft/monaco-editor

I have a code to create an editor in an AngularJS directive:

function newMonacoeditorEditor(iElement, monacoeditorOptions) {
    var editor = monaco.editor.create(iElement[0], {
        language: monacoeditorOptions.language,
        lineNumbers: monacoeditorOptions.lineNumbers
    });
    console.log("newMonacoeditorEditor")
    return editor
}

I would like to know how to always disable the minimap?

Thank you

Most helpful comment

e.g.

monaco.editor.create(document.getElementById("container"), {
    value: "function hello() {\n\talert('Hello world!');\n}",
    language: "javascript",
    minimap: {
        enabled: false
    }
});

All 6 comments

e.g.

monaco.editor.create(document.getElementById("container"), {
    value: "function hello() {\n\talert('Hello world!');\n}",
    language: "javascript",
    minimap: {
        enabled: false
    }
});

It works, thank you very much @alexandrudima

How does one disable minimap once the editor has been created?

@David-Carty You can use the updateOptions API for that.

editor = monaco.editor.create(document.getElementById("container"), {
    value: "function hello() {\n\talert('Hello world!');\n}",
    language: "javascript",
    minimap: {
        enabled: true
    }
});

setTimeout(() => {
    alert("Disabling")
    editor.updateOptions({
        minimap: {
            enabled: false
        }
    })
}, 3000);

Thank you. Is there anyway of detecting if the minimap is enabled as I want to create a toggle?

@David-Carty You can track the minimap enablement on your side in a variable.

Was this page helpful?
0 / 5 - 0 ratings